If I use as a result in the function the given vector (option 2) then it works but if I use option 1 - which should be just another way to express the same thing - it gives an error
"
[IDA ERROR] IDASolve
* At t = 1e-006 and h = 7.22418e-016, the corrector convergence failed repeatedly or with |h| = hmin.
error: IDASolve failed
error: called from ode15s at line 316 column 17
diff_ode15s_Robertson_DAE_problem_with_a_Conservation_Law at line 27 column 6"
(the line where the ode15 s function is used: ode15s(@f,t,y0,options)
"
I would like to understand this error. Can anyone help me??
Thanks.
Regards
Tommy7571
Tommy7571
Gast
Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
Verfasst am: 19.10.2018, 15:14
Titel: Robertson DAE Problem
Hello,
I found how to run the program. The following code works:
Code:
1;
# y1' = -0.04'y1+10^4*y2*y3;
# y2' = 0.04*y1-10^4*y2*y3-3*10^7*y2^2
# y3' = 3E7*y2^2
#the conservation law is
# y'(1) + y'(2) + y'(3) = 0
#with initial conditions the conservation law is
# y(1) + y(2) + y(3) = 1
function dy = f(t,y)
dy = zeros(3,1); % a column vecto #dy = [0 ; 0 ; 0];
dy(1)=-0.04*y(1)+(1e4)*y(2).*y(3);
dy(2)=0.04*y(1)-(1e4)*y(2).*y(3)-(3*10^7)*y(2).^2; # mit Komponenten geht es auch!!!!
dy(3)=3e7*y(2).^2;
# vorige Fehler:
# kein .* ; # options = odeset('Mass',M,'RelTol',1e-4,'AbsTol',1e-6); absTol falsche Länge
# dy = [-0.04*y(1)+1e4*y(2).*y(3); # zuerst ging es nur damit !!
# 0.04*y(1)-1e4*y(2).*y(3)-3e7*y(2).^2;
# y(1)+y(2)+y(3)-1];
endfunction
t = logspace(-6,6,50);#t = [0, 4*logspace(-6,6)]; # ursprünglich im Code, geht auch
y0 =[1; 0; 0]; #initial conditions als Spaltenvektor
M = [100; 010; 000];
absT = [1e-6 1e-10 1e-6];
# options = odeset('RelTol',1E-4,'AbsTol',absT); # für ode45
#options = odeset('Mass',M,'RelTol',1e-4);# ode15s # geht nicht
options = odeset('RelTol',1e-4,'AbsTol',absT); # für ode15s mit Mass M geht es nicht !!
# [t,y] = ode45(@(t,y) f(t,y),t,y0,options); # geht nicht, #y = lsode("f",y0,t); geht nicht
# [t,y] = ode15s(@(t,y) f(t,y),t,y0,options); # geht
[t,y] = ode15s(@f,t,y0,options); # ode15s(@f,t,y0,options) geht,
y(:,2) = 1e4*y(:,2);
semilogx(t,y);
ylabel('1e4 * y(:,2)');
title('Robertson DAE problem with a Conservation Law, solved by ODE15S');
The result corresponds exactly to what should result.
However, I am not 100 % satisfied with this solutisince it does only work if I do not try to use the mass option in this case, which ist just the most important point.
If I replace the zero of M(3,3) by a 1, that gives the same sresult and it works!
Is there anyone knowing why the zero in the mass condition in this code leads to "
[IDA ERROR] IDASolve
At t = 1e-006 and h = 7.22418e-016, the corrector convergence failed repeatedly or with |h| = hmin.
error: IDASolve failed"
It is quite a famous example of matlab. It seems not to be an error of the initial conditions....
Thanks in advance
Thommy7571
Einstellungen und Berechtigungen
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.