steady state criterion

31 Ansichten (letzte 30 Tage)
Rose
Rose am 6 Apr. 2011
Bearbeitet: Vyas am 26 Apr. 2016
Hi, I have a system of 4 ODE's and I solved it by using ode15s solver. But I want to stop simulations when the steady state is reached. Can someone tell me how to do it? I need to know this urgent!! Thanks and regards.
  1 Kommentar
Vyas
Vyas am 26 Apr. 2016
Bearbeitet: Vyas am 26 Apr. 2016
Hello,
I do have a similar set of ODE's which solves a chemical kinetics system. I am using some constraints to solve these equations and I am able to solve for few set of unknowns. However when I use more unknowns (~8) with 2 constraints to solve for rest 6 unknowns using ODE, I see the problem will not be solved till the final time. For e.g., I have specified initial time and final time as [t0 tf] which i pass to the ODE15s solver. So for the higher number of unknowns, the ODE solver will not solve until 'tf' has achieved (not blowing up as well). Can anyone help me why ODE solves only to a fraction of final time 'tf'? And also tell me how to fix this? I have seen events being used to stop the code when steady state achieved. I want something reverse. I want to know why the ODE solver do not finishes till the specified time!!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt Tearle
Matt Tearle am 6 Apr. 2011
By "steady state" do you mean an equilibrium solution, or some non-equilibrium state that the solution settles to after an initial transient (eg a periodic solution)? If the latter, I don't know off the top of my head how you'd do that. If the former, you can use an event.
Write an event function, where, in your case the event should be something like the norm of the derivatives is zero (or, realistically, close to zero).
function [x,isterm,dir] = eventfun(t,y)
dy = copy-n-paste-from-your-ode-equation-function;
x = norm(dy) - 1e-5;
isterm = 1;
dir = 0; %or -1, doesn't matter
This defines an event for the integration to be whenever the norm of the derivatives is less than 10^-5. You can tweak that definition according to your knowledge of the system (and the likely values of the derivatives, in particular). The value of isterm will tell ode45 to stop integrating once the event occurs. The direction shouldn't matter, because there's really no way for the norm of the derivatives to increase to 1e-5.
Once you've done this, add the event to your ode options:
opts = odeset('Events',@eventfun);
Then call ode15s with that option structure. You can use an infinite integration time (or just very big), and the integration will stop when (if!) the event occurs:
[t,z] = ode15s(@odefun,[0 Inf],y0,opts);
  10 Kommentare
Rose
Rose am 7 Apr. 2011
It worked!!!! Thanks Thanks Thanks Matt :)
But I think it is not taking into account the RelTol and AbsTol
How can I fix it?
Rose
Rose am 7 Apr. 2011
I think I did it :) Thanks a lot for your help! I am so relaxed now!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Laura Proctor
Laura Proctor am 6 Apr. 2011
You can set the error tolerance of the ODE solver using the function ODESET and then pass in the structure created from ODESET into your ODE solver.
For example:
options = odeset('RelTol',1e-2,'AbsTol',[1e-3,1e-3,1e-4,1e-2]);
[T,Y] = ode15s(@myFcn,t,y0,options);
Try this out to see if you're able to get better results.
You may also be interested in event handling, which is where you can make your simulation stop once an event happens (such as when the output goes below a specific value). You also do this using ODESET function - look at the topic Event Location Property in the documentation for ODESET for more details on this.
  1 Kommentar
Rose
Rose am 7 Apr. 2011
I tried it and it gave me better results but I want to apply the steady state criterion particularly!!

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by