|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我的代码解常微分一直说要返回列向量,有大神帮忙看看嘛7 d( z; K2 {$ y" R
# e N- G" w) P
这是代码:& o; y5 P' a# D: e
function s=mywork(t,y,eta1,eta2,G1,yieldstress,contactstrain,flow,arg)& ^ P9 l0 f& I$ g* N
switch flow
2 g4 o* [( E. E" _; i; wcase 'creep & recovery'' ^9 s3 s. H6 i
stress0=arg(1);
, w1 \5 C9 |$ h e8 F8 K/ y risetime=arg(2);
2 K( a- Z- M" I3 A/ p0 \: B. p# r) O creeptime=arg(3);
9 l" X* |! v4 L if t<risetime
! ^' E7 J3 L4 N& e! @' N stressrate=stress0/risetime;
/ U3 k: u. D3 R' H$ V stress=stressrate*t;
# d) [: m+ u" B8 A. a elseif t<creeptime
: e. U5 n* }$ K$ ? stressrate=0;
7 d5 d: v, L6 c stress=stress0;0 E* s( ^% {$ O9 T" Q- n
elseif t<creeptime+risetime
' U0 b/ k2 o$ Y/ V9 Q stressrate=stress0/risetime;
. m2 W4 A# A. V% H0 q0 ^& d stress=stress0-stressrate*(t-creeptime);8 A5 q& \3 ?6 {- J8 C9 E- D
else
4 l% G" w6 [" s; |. X9 ?/ }6 d- H0 l. a stressrate=0;2 `4 T" s4 m/ l- }
stress=0;9 \2 E# o- g4 n8 j0 A
end( l) l' y; C& b& a( k1 t4 }( h
gam1=y(1);
: n$ ]' [" t% p; w gam2=y(2);8 P$ E% S V( {& @. y4 O
s(1)=gam2;
4 d, t2 T& j- e6 e6 Y" Q+ _) {4 V* m 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); @% ?. ` f# \) b4 c
# H$ l' m3 A& D8 W" M0 I. g7 H' }# H" D8 [9 @7 a# V- o6 f
" t: I& @ k5 oclear all
# P6 [/ k3 |! Y9 P1 o3 [clc
7 Q( Z: K( f5 nwarning off' A+ ` J, p9 \' t9 I
! q2 @% [( V) B+ M8 k' u; Heta1=10; % [Pa.s]
8 A5 c/ @2 ~. j; }% k! Feta2=20; % Pa.s]- P6 N: [& X. u0 W; _3 H
G1=2; % [Pa]
( M0 j6 I D T, K! jG2=5; %[Pa]# v5 x% W( K; X/ c# s# v6 T9 w
yieldstress=5; % [Pa]
3 r/ b* F3 L7 [5 Z% W' Qcontactstrain=5;; ^1 K# ]% a: V3 K* B/ `
2 y1 G$ S1 u8 i+ D. w7 I# E" Y- X. i) S- O0 u
flow='creep & recovery';1 [" {5 i+ _; c/ M' ^. P* |
stress0=1:2:10;
! x( H. Q' M( e4 _0 ~risetime=0.01;, R( ?1 e8 J, t9 m* f
creeptime=100;; }' r- ~' {' I/ S, d! o F( K( N' P2 A
for i=1:length(stress0)8 E0 t0 z, P9 i: k
[t,strain]=ode15s(@mywork,[0 10],[0 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);, F6 a. j; Q# b" r% ~
subplot(2,3,3); semilogx(t,strain(:,1)); hold on4 X: z& F7 c2 X) V2 N
a{i}=strcatnum2str(stress0(i),'(Pa)');" r5 l' l/ e) ~, g5 N
end- |# W, u! E( [9 J) n
xlin([1e-4 1000]); $ L$ w: w* K) q X. }6 y
xlabel('Time(s)'); ylabel('Shear strain(-)');# Q) K S( q5 U4 O& f
legend(a)
( X7 B, M, w7 G0 j6 ]8 [$ T, `' }7 C) ]
, g4 q& ?( a2 Z% @/ m+ O r! K# Z
1 \: `% n2 f) Q1 Z* @+ I错误使用 odearguments (第 93 行)8 [" r# ~5 E- `2 _( P9 e; t6 P, g6 v
MYWORK 必须返回列向量。
* [" g$ a8 t% x7 c
# j2 q: Z$ W! u+ e" ?出错 ode15s (第 152 行)
+ A M+ {7 P' {6 R- T odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);) @. r) L5 O8 F$ e
$ {8 }7 R* `4 o+ L$ E4 R; a出错 Untitled2 (第 20 行)9 ^* S; K Z2 |7 _7 T
[t,strain]=ode15s(@mywork,[0 10],[1 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);
% N6 u3 U% {" e. | r0 Z0 j2 N d/ G+ X9 o9 G3 u, M2 l$ u
, D z$ Q6 Y @: B! a% J
感谢大神们!6 I e& ?' x6 |9 n$ V8 J
|
|