Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: forced discard of ODE step
Posted:
May 25, 2013 12:40 AM


On 5/24/2013 10:17 PM, Mateusz Gos wrote: > Hi, > > I have a set of differential equations solved with ode45. > At times it might be possible for the solver to find a valid time step > (meeting the tolerance criteria), but for some of the variables in that >time step to be physically not possible. So in other words such step is >correct mathematically, but not physically. > Of course I can check for these variables, but how do I make the solver > discard a particular iteration and start a new one with different time > step, regardless of what it has determined tolerancewise? > > Thank you, > Matt >
I do not know how you can make it discard the step, since it allready made it. But may be you can stop ode45 at the point of your choice and then restart it again using IC at that point such that the new IC's is what you want to use. If so, you can look at ode45 OutputFcn
http://www.mathworks.com/help/matlab/ref/odeset.html
"The solver calls status = myfun(t,y,[]) after each integration step on which output is requested. t contains points where output was generated during the step, and y is the numerical solution at the points in t. "
....
"myfun must return a status output value of 0 or 1. If status = 1, the solver halts integration. You can use this mechanism, for instance, to implement a Stop button."
I've used OutputFcn for display the solution as ode45 was running for another reason, but it is possible to use it to check for specific conditions and halt ode45. Then restart again, since you know the solution at that moment.
Nasser



