%% 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-16 11:11:02 浏览: 83
可以通过在程序开头添加以下代码来设定求解容差:
```
options = optimset('TolFun', 1e-6, 'TolX', 1e-6);
```
这里将函数求解的容差设为1e-6,可以根据需要进行调整。然后在调用函数的时候,将选项作为第三个参数传入,例如:
```
fminsearch(@(x) myfun(x, y, z), x0, options)
```
其中,`myfun`是要求解的函数,`x0`是初值,`options`是设定的选项。
相关问题
%% constitutive model Drucker-Prager屈服函数 %% = (A+B(1+C*EXP(nε))*(1+b1*η) %% constitutive model Modified-Drucker-Prager屈服函数 ... %% = (A+B(1+C*EXP(nε))*(a1+a2*exp(a3η)) %% constitutive model parameter A=1; B=2; C=3; n=1; %% Drucker-Prager Parameter b1 = 0.1; %% Modified-Drucker-Prager Parameter a1 = 1; a2 = 2; a3 = 3; %% plastic strain ss = 1; %% stress state tria = sqrt(3)/3; %% Drucker-Prager屈服函数 f1 = (A+B(1+C*EXP(n*ss)))*(1+b1*tria); %% Modified-Drucker-Prager屈服函数 f2 = (A+B(1+C*EXP(n*ss)))*(a1+a2*exp(a3*tria)); 将这段程序改成,输入矩阵ss,求出f1和f2的值
可以将原有的程序改成以下形式:
```matlab
% constitutive model parameters
A = 1;
B = 2;
C = 3;
n = 1;
b1 = 0.1;
a1 = 1;
a2 = 2;
a3 = 3;
% input matrix ss
ss = [1 2 3; 4 5 6; 7 8 9];
% stress state tria
tria = sqrt(3)/3;
% calculate f1 and f2
f1 = (A + B.*(1+C.*exp(n.*ss))).*(1+b1.*tria);
f2 = (A + B.*(1+C.*exp(n.*ss))).*(a1+a2.*exp(a3.*tria));
```
这样,输入矩阵 `ss` 就可以是任意大小的矩阵,`f1` 和 `f2` 的值也会相应地计算出来,并以大小与 `ss` 相同的矩阵形式返回。
MATLAB 程序yieldstress = 333.8624; %% Drucker-Prager parameter a1 = -0.1039; %% 坐标轴范围 limitxy = 500; %% vmc = @(x, y) sqrt(x.^2 - x.*y + y.^2)-yieldstress.*(1+a1*(-sqrt(3)/3)); % trc = @(x, y) 0.5 * max(cat(3, abs(x - y), abs(x), abs(y))-1, [], 3); xx = linspace(-limitxy, limitxy, 1000); yy = linspace(-limitxy, limitxy, 1000); [X, Y] = ndgrid(xx, yy); [C,h] = contour(X, Y, vmc(X, Y), [1 1]); % xlim([-limitxy, limitxy]); % ylim([-limitxy, limitxy]); w = h.LineWidth; h.LineWidth = 1; % h.LineStyle = ":"; h.EdgeColor = "b"; h.FaceColor = "r";,设定yieldstress为矩阵,并将程序简化
抱歉,您的代码中将 yieldstress 定义为标量而非矩阵。以下是将程序简化后的代码:
yieldstress = 333.8624;
a1 = -0.1039;
limitxy = 500;
vmc = @(x, y) sqrt(x.^2 - x.*y + y.^2) - yieldstress.*(1+a1*(-sqrt(3)/3));
xx = linspace(-limitxy, limitxy, 1000);
yy = linspace(-limitxy, limitxy, 1000);
[X, Y] = ndgrid(xx, yy);
[C, h] = contour(X, Y, vmc(X, Y), [1 1]);
h.LineWidth = 1;
h.EdgeColor = "b";
h.FaceColor = "r";
% xlim([-limitxy, limitxy]);
% ylim([-limitxy, limitxy]);
阅读全文