%% Drucker-Prager 参数 a=-0.1039; %% Modified Drucker-Prager 参数 a1=0.9954; a2=0.0046; a3=-5.65469; %% 二维Mises vmc = @(x, y) sqrt(x.^2 - x.y + y.^2)-1; %% 二维 Tresca trc = @(x, y) 0.5 * max(cat(3, abs(x - y), abs(x), abs(y))-1, [], 3); %% Drucker-Prager和Modified Drucker-Prager DruPra = @(x, y) sqrt(x.^2 - x.y + y.^2)(1+a(x+y)/2/ sqrt(x.^2 - x.*y + y.^2))-1; xx = linspace(-6, 6, 1000); yy = linspace(-6, 6, 1000); [X, Y] = ndgrid(xx, yy);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% contour(X, Y, vmc(X, Y), [1 1]) hold on contour(X, Y, trc(X, Y), [1 1]); hold on contour(X, Y, DruPra(X, Y), [1 1]); hold on % contour(X, Y, ModiDruPra(X, Y), [1 1]); title('Mises Yield Surface in 2D Principal Stress Space'); hold on,,给这段程序改成有求解容差的程序
时间: 2023-09-13 11:06:19 浏览: 97
可以将程序改写为以下形式,增加了一个函数 `DruPra_f` 用于计算 Drucker-Prager 函数值,同时在调用 `fminsearch` 函数时添加了选项 `options`,其中设定了求解容差。
```
% Drucker-Prager 参数
a = -0.1039;
% Modified Drucker-Prager 参数
a1 = 0.9954;
a2 = 0.0046;
a3 = -5.65469;
% 二维Mises
vmc = @(x, y) sqrt(x.^2 - x.*y + y.^2) - 1;
% 二维 Tresca
trc = @(x, y) 0.5 * max(cat(3, abs(x - y), abs(x), abs(y)) - 1, [], 3);
% Drucker-Prager函数
DruPra_f = @(x, y) sqrt(x.^2 - x.*y + y.^2) .* (1 + a * (x + y) / 2 / sqrt(x.^2 - x.*y + y.^2)) - 1;
% 设定求解容差
options = optimset('TolFun', 1e-6, 'TolX', 1e-6);
% 生成坐标网格
xx = linspace(-6, 6, 1000);
yy = linspace(-6, 6, 1000);
[X, Y] = ndgrid(xx, yy);
% 绘制等值线图
contour(X, Y, vmc(X, Y), [1 1])
hold on
contour(X, Y, trc(X, Y), [1 1])
hold on
contour(X, Y, DruPra(X, Y), [1 1])
hold on
% contour(X, Y, ModiDruPra(X, Y), [1 1]);
title('Mises Yield Surface in 2D Principal Stress Space')
hold on
% 求解 Drucker-Prager 函数值
x0 = [0, 0];
fminsearch(@(x) DruPra_f(x(1), x(2)), x0, options);
```
注意,在 `DruPra_f` 函数的定义中,需要将 `x.y` 改为 `x.*y`,否则会出现错误。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)