[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with ODE solver

From: John W. Eaton
Subject: Re: Help with ODE solver
Date: Thu, 12 Sep 2002 19:18:38 -0500

On 12-Sep-2002, Marco Antoniotti <address@hidden> wrote:

| Pardon my obtuseness.  Do you mean that I will have to have a big 'if'
| in the RHS function like
|    if (t < t_crit_1)
|       ...
|    elseif (t_crit_1 <= t && t < t_crit_2)
|       ...
|    elseif (t > t_crit_k)
|       ...
|    end
| and call
|     result = lsdot('RHS', intial_conditions, timesteps, [t_crit_1; t_crit_2 
... t_crit_k]);
| ?

Yes, that would be one way, but then you would need to make all those
t_crit_N values global.  It might make more sense to use a vector of
values and a loop in your RHS function.  Or, you could vectorize it
depending on how your time-dependent parameter values are stored.
Perhaps someone else on the list can help you with the programming

My reason for responding in this thread was to point out that using
tcrit with lsode is important if you have a discontinuity in the
derivative due to changing parameter values.  Simply breaking up the
integration into intervals may not be sufficient because if you don't
specify tcrit, lsode may integrate past your final time point and
interpolate backward to find the final state values.  If you have a
discontinuity there, then the integrator may still have trouble,
respond by reducing the step size to zero, and eventually fail.

BTW, does anyone know if Matlab's ODE solvers have a similar


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]