|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我的代码解常微分一直说要返回列向量,有大神帮忙看看嘛! \; Z5 J4 F+ V; J. G( W
+ C1 ^7 M) ]& A) z7 t$ v& B
这是代码:6 V% v8 D0 ~& V1 y4 k8 ^3 {% a
function s=mywork(t,y,eta1,eta2,G1,yieldstress,contactstrain,flow,arg)
: [* r* ?' Q! l# o6 s: j7 p0 U0 W* f9 \switch flow
# y5 _1 Y$ Q L) J5 zcase 'creep & recovery'* ^, R0 o! H$ x- ]* L
stress0=arg(1);. ~& E7 e- u6 s+ D+ \8 d7 V- S2 v# U
risetime=arg(2);
4 L N+ j8 l& i/ [ e creeptime=arg(3);
8 ?( m, [, F; O. U if t<risetime
/ C7 E. k" y* n8 R stressrate=stress0/risetime;
1 t) _$ C% P/ f- q5 ^. ^ stress=stressrate*t;
' X d% Q7 k/ g2 M" c- N4 u" V9 m elseif t<creeptime: S+ h0 q7 Z" P% n# k. ^
stressrate=0;" k/ c# `9 @# H# R/ @4 S" X! }
stress=stress0;
7 E H! V% ?; ]/ y- Z* C+ z elseif t<creeptime+risetime
- U7 F# j0 i B stressrate=stress0/risetime;$ X! J2 p+ w7 ~, T8 L1 P# S5 W, z
stress=stress0-stressrate*(t-creeptime);
) d+ l; `( D$ z else$ X; n2 V# z; o8 F# F2 I
stressrate=0;0 D0 X6 r7 Q4 e) s' ^- U
stress=0;0 w: r a, D7 g# v1 _. l+ N
end" X7 `- t. o( E7 w' [, l8 ?/ m) [! Q
gam1=y(1);+ z+ S- S) P4 u/ V# U6 j8 J# t
gam2=y(2);+ \: M- N! c3 p8 j8 I# ?
s(1)=gam2;
$ F! [% Z8 l9 S/ z s(2)=G1/(eta1*eta2*((abs(gam1)-contactstrain)>0))*((stress-eta2*gam2*((abs(gam1)-contactstrain)>0)-sign(stress-eta2*gam2*((abs(gam1)-contactstrain)>0))*yieldstress)*((abs(stress-eta2*gam2*((abs(gam1)-contactstrain)>0))-yieldstress)>0)-eta1*gam2+eta1/G1*stressrate);
. C2 }( p6 u8 Q" r m
: G. d, Y% b( ~9 P, L6 |+ n4 m! s+ {% V7 m% u! K4 H1 t0 m
( O; X, C3 b) k/ O( b# oclear all
. Z0 f' x9 z6 B+ K `+ z/ V/ Nclc
8 j' _ U# H0 Awarning off
X9 [* \+ b; |# p: i! {- ]% n# \
eta1=10; % [Pa.s]
5 N, v0 x6 `3 O( R7 x3 eeta2=20; % Pa.s]9 F4 I u3 m* n+ R) y* D4 V8 D
G1=2; % [Pa]. S! v5 i2 x Q' \' g
G2=5; %[Pa]
, i) C& Q C8 K6 qyieldstress=5; % [Pa]
. {- P$ ?5 p1 j, ?2 D( ^4 |7 {" jcontactstrain=5;
4 b* W6 I" k$ |" J3 s7 k; a6 K0 ~; T4 T" x) p) U( J
& _4 j7 | K5 G6 L
flow='creep & recovery';5 M: F* v4 a% B& r4 e" v
stress0=1:2:10; K- c |: V0 M' x& V
risetime=0.01;
& g$ J% {" ?% U3 R. _6 v! m" U' rcreeptime=100;5 x9 o K: e% o# Y" p1 t
for i=1:length(stress0)
# }1 v+ [/ {" W" Y" h. n7 Q [t,strain]=ode15s(@mywork,[0 10],[0 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);1 ? x, \1 I6 e9 D
subplot(2,3,3); semilogx(t,strain(:,1)); hold on
, H. o8 |3 h! X) x a{i}=strcatnum2str(stress0(i),'(Pa)');
6 s3 D7 }3 `# H* H9 I) iend
1 Y# F* _( C# M9 I2 f" B4 p" M& txlin([1e-4 1000]); * }9 }- ^9 F+ h) S/ a
xlabel('Time(s)'); ylabel('Shear strain(-)');
( F9 G& _! [9 v0 s6 _" v# ]( l3 Zlegend(a)
4 _3 y) n; z( E5 G- v/ y8 [
% Y- R, p& Z. D7 ?$ [) P: z$ `4 ~% ?* P8 p0 V- W; Y( t6 }+ k
2 e- Y$ _# l9 K( Z) J. T3 W
错误使用 odearguments (第 93 行)8 \9 E M5 m! B6 P
MYWORK 必须返回列向量。
; l+ d, S9 [) {4 u/ w; ~+ k* O& q% L/ l: t+ M) L
出错 ode15s (第 152 行)& G. U$ F, x7 c9 b9 l
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
' p0 {: O* w0 o* Y8 h; r
% A0 @) H! H* y; D出错 Untitled2 (第 20 行)
2 @! n; ~* G# H- Y$ p [t,strain]=ode15s(@mywork,[0 10],[1 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);& R8 o% L4 Y8 v* b2 o; ~
. B' d; a& Z# ^
J0 c l. a2 g& ^+ g) M感谢大神们!
2 v$ Q5 ]- h$ b4 D8 C7 r: y |
|