Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: forced discard of ODE step
Replies: 4   Last Post: May 27, 2013 7:40 PM

 Messages: [ Previous | Next ]
 Nasser Abbasi Posts: 6,677 Registered: 2/7/05
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 tolerance-wise?
>
> 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

Date Subject Author
5/24/13 Mateusz Gos
5/25/13 Nasser Abbasi
5/26/13 Mateusz Gos
5/27/13 Torsten
5/27/13 Mateusz Gos