there are something wrong with solving DAEs by using ode15s
显示 更早的评论
when i used the ode15s to solve the DAEs,I got some error infomations. here is the equs:

and at the same times x,y,z satisfie an algebraic relation:

so,I got a DAEs system.
here is my codes:
function out =daestest(t,k)
w2=302.*2.*pi./60;
sita=0.79550314./180.*pi;
beta=35.10858727./180.*pi;
w1=(sin(sita+beta)./sin(beta)-1).*w2;
w1_real=w1+w2;
R=995.68198879/1000;
XA=313.33036053/1000;
XB=699.99999999/1000;
ZA=550/1000;
ZB=0;
m=1;
mu=0.01;
g=-9.8;
G=g*m;
a1=(sin(t*w2)*sin(t*w1_real)+cos(t*w2)*cos(t*w1_real)*cos(sita));
a2=-(cos(t*w1_real)*sin(t*w2)-cos(t*w2)*sin(t*w1_real)*cos(sita));
a3=-cos(t*w2)*sin(sita);
a4=-(-w2^2*(k(1)*(sin(t*w2)*sin(t*w1_real)+cos(t*w2)*cos(t*w1_real)*cos(sita))-k(2)*(cos(t*w1_real)*sin(t*w2)-cos(t*w2)*sin(t*w1_real)*cos(sita))+R*cos(t*w2)*sin(sita)-k(3)*cos(t*w2)*sin(sita))-2*w2*(k(5)*(cos(t*w2)*cos(t*w1_real)+sin(t*w2)*sin(t*w1_real)*cos(sita))-k(4)*(cos(t*w2)*sin(t*w1_real)-cos(t*w1_real)*sin(t*w2)*cos(sita))+w1*k(1)*(cos(t*w2)*cos(t*w1_real)+sin(t*w2)*sin(t*w1_real)*cos(sita))+w1*k(2)*(cos(t*w2)*sin(t*w1_real)-cos(t*w1_real)*sin(t*w2)*cos(sita))-k(6)*sin(t*w2)*sin(sita))-2*w1*k(4)*(cos(t*w1_real)*sin(t*w2)-cos(t*w2)*sin(t*w1_real)*cos(sita))-2*w1*k(5)*(sin(t*w2)*sin(t*w1_real)+cos(t*w2)*cos(t*w1_real)*cos(sita))-w1^2*k(1)*(sin(t*w2)*sin(t*w1_real)+cos(t*w2)*cos(t*w1_real)*cos(sita))+w1^2*k(2)*(cos(t*w1_real)*sin(t*w2)-cos(t*w2)*sin(t*w1_real)*cos(sita)))+1/m*((mu*k(7)*k(4)*(sin(t*w2)*sin(t*w1_real)+cos(t*w2)*cos(t*w1_real)*cos(sita)))/(k(4)^2+k(5)^2+k(6)^2)^(1/2)-(mu*k(7)*k(5)*(cos(t*w1_real)*sin(t*w2)-cos(t*w2)*sin(t*w1_real)*cos(sita)))/(k(4)^2+k(5)^2+k(6)^2)^(1/2)+(2*k(7)*k(1)*(sin(t*w2)*sin(t*w1_real)+cos(t*w2)*cos(t*w1_real)*cos(sita)))/(4*k(1)^2+4*k(2)^2+(4*(XA-XB)^2*(XB-((XA-XB)*(ZB-k(3)))/(ZA-ZB))^2)/(ZA-ZB)^2)^(1/2)-(2*k(7)*k(2)*(cos(t*w1_real)*sin(t*w2)-cos(t*w2)*sin(t*w1_real)*cos(sita)))/(4*k(1)^2+4*k(2)^2+(4*(XA-XB)^2*(XB-((XA-XB)*(ZB-k(3)))/(ZA-ZB))^2)/(ZA-ZB)^2)^(1/2)-(mu*k(7)*k(6)*cos(t*w2)*sin(sita))/(k(4)^2+k(5)^2+k(6)^2)^(1/2)+(k(7)*cos(t*w2)*sin(sita)*(2*XB-(2*(XA-XB)*(ZB-k(3)))/(ZA-ZB))*(XA-XB))/((ZA-ZB)*(4*k(1)^2+4*k(2)^2+(4*(XA-XB)^2*(XB-((XA-XB)*(ZB-k(3)))/(ZA-ZB))^2)/(ZA-ZB)^2)^(1/2)));
b1=-(cos(t*w2)*sin(t*w1_real)-cos(t*w1_real)*sin(t*w2)*cos(sita));
b2=(cos(t*w2)*cos(t*w1_real)+sin(t*w2)*sin(t*w1_real)*cos(sita));
b3=-sin(t*w2)*sin(sita);
b4=-(-2*w2*(k(5)*(cos(t*w1_real)*sin(t*w2)-cos(t*w2)*sin(t*w1_real)*cos(sita))-k(4)*(sin(t*w2)*sin(t*w1_real)+cos(t*w2)*cos(t*w1_real)*cos(sita))+w1*k(1)*(cos(t*w1_real)*sin(t*w2)-cos(t*w2)*sin(t*w1_real)*cos(sita))+w1*k(2)*(sin(t*w2)*sin(t*w1_real)+cos(t*w2)*cos(t*w1_real)*cos(sita))+k(6)*cos(t*w2)*sin(sita))+w2^2*(k(1)*(cos(t*w2)*sin(t*w1_real)-cos(t*w1_real)*sin(t*w2)*cos(sita))-k(2)*(cos(t*w2)*cos(t*w1_real)+sin(t*w2)*sin(t*w1_real)*cos(sita))-R*sin(t*w2)*sin(sita)+k(3)*sin(t*w2)*sin(sita))+2*w1*k(4)*(cos(t*w2)*cos(t*w1_real)+sin(t*w2)*sin(t*w1_real)*cos(sita))+2*w1*k(5)*(cos(t*w2)*sin(t*w1_real)-cos(t*w1_real)*sin(t*w2)*cos(sita))+w1^2*k(1)*(cos(t*w2)*sin(t*w1_real)-cos(t*w1_real)*sin(t*w2)*cos(sita))-w1^2*k(2)*(cos(t*w2)*cos(t*w1_real)+sin(t*w2)*sin(t*w1_real)*cos(sita)))+1/m*((mu*k(7)*k(5)*(cos(t*w2)*cos(t*w1_real)+sin(t*w2)*sin(t*w1_real)*cos(sita)))/(k(4)^2+k(5)^2+k(6)^2)^(1/2)-(mu*k(7)*k(4)*(cos(t*w2)*sin(t*w1_real)-cos(t*w1_real)*sin(t*w2)*cos(sita)))/(k(4)^2+k(5)^2+k(6)^2)^(1/2)-(2*k(7)*k(1)*(cos(t*w2)*sin(t*w1_real)-cos(t*w1_real)*sin(t*w2)*cos(sita)))/(4*k(1)^2+4*k(2)^2+(4*(XA-XB)^2*(XB-((XA-XB)*(ZB-k(3)))/(ZA-ZB))^2)/(ZA-ZB)^2)^(1/2)+(2*k(7)*k(2)*(cos(t*w2)*cos(t*w1_real)+sin(t*w2)*sin(t*w1_real)*cos(sita)))/(4*k(1)^2+4*k(2)^2+(4*(XA-XB)^2*(XB-((XA-XB)*(ZB-k(3)))/(ZA-ZB))^2)/(ZA-ZB)^2)^(1/2)-(mu*k(7)*k(6)*sin(t*w2)*sin(sita))/(k(4)^2+k(5)^2+k(6)^2)^(1/2)+(k(7)*sin(t*w2)*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(a1*b4*c3-a1*b3*c4+a3*b1*c4-a3*b4*c1-a4*b1*c3+a4*b3*c1)/(a1*b2*c3-a1*b3*c2-a2*b1*c3+a2*b3*c1+a3*b1*c2-a3*b2*c1)
(a1*b2*c4-a1*b4*c2-a2*b1*c4+a2*b4*c1+a4*b1*c2-a4*b2*c1)/(a1*b2*c3-a1*b3*c2-a2*b1*c3+a2*b3*c1+a3*b1*c2-a3*b2*c1)
k(1).^2+k(2).^2-((k(3)-ZB).*(XA-XB)./(ZA-ZB)+XB).^2];
when i used this code to solve the DAEs
y0=[0.3133283972712190;0.001104257865152230;0.5500000247589403;0;0;0;0;];
tspan=[2.533037911852984:5e-4:2.6];
M=[1 0 0 0 0 0 0;0 1 0 0 0 0 0;0 0 1 0 0 0 0;0 0 0 1 0 0 0;0 0 0 0 1 0 0;0 0 0 0 0 1 0;0 0 0 0 0 0 0;];
options = odeset('Mass',M);
[t,k]=ode15s(@daestest,tspan,y0,options);
I got the error:
Error using daeic12 (line 166)
Need a better guess y0 for consistent initial conditions.
Error in ode15s (line 310)
[y,yp,f0,dfdy,nFE,nPD,Jfac] =
daeic12(odeFcn,odeArgs,t,ICtype,Mt,y,yp0,f0,...
Error in DAES15s (line 5)
[t,k]=ode15s(@daestest,tspan,y0,options);
So,I changed the initial value of y0 to
y0=[0.3133283972712190;0.001104257865152230;0.5500000247589403;1;1;1;1000;];
I also got the error:
Error using daeic12 (line 76)
This DAE appears to be of index greater than 1.
Error in ode15s (line 310)
[y,yp,f0,dfdy,nFE,nPD,Jfac] =
daeic12(odeFcn,odeArgs,t,ICtype,Mt,y,yp0,f0,...
Error in DAES15s (line 5)
[t,k]=ode15s(@daestest,tspan,y0,options);
I'm very confused,What is the cause of such error information? Please help me analyze this problem,thak you.
8 个评论
Torsten
2017-11-23
7 equations for 6 unknowns ? This cannot work.
Best wishes
Torsten.
Zilong Zhang
2017-11-23
编辑:Zilong Zhang
2017-11-23
Torsten
2017-11-23
Try "reduceDAEIndex":
https://de.mathworks.com/help/symbolic/solve-differential-algebraic-equations.html#bvh12tx-2
Best wishes
Torsten.
Zilong Zhang
2017-11-23
Torsten
2017-11-23
The problem with your system is that there is no explicit ODE equation for k(7), but it must be adjusted such that the algebraic constraint x^2+y^2+...= 0 is satisfied.
My suggestion would be to differentiate the algebraic constraint twice with repsect to t, insert the expressions for x'', y'' and z'' (thus f1(...),f2(...),f3(...)) and solve for k(7). This way, you can circumvent k(7) as solution variable, and it is k(7) which causes the index problem.
Best wishes
Torsten.
Zilong Zhang
2017-11-23
Torsten
2017-11-23
Is Fn = k(7) ?
Best wishes
Torsten.
Zilong Zhang
2017-11-23
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 配置仿真条件 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!