[SciPy-User] Zero crossing detection

Anne Archibald peridot.faceted@gmail....
Mon Mar 29 15:56:13 CDT 2010

On 29 March 2010 15:31, Moritz Maus <moritz.maus@uni-jena.de> wrote:
> Is there a way for the ODE-integrators to
> a.) stop the simulation when a specific event occurred or
> b.) doing a MatLab (Simulink)-like "zero crossing detection", (when
> these timepoints are not pre-defined?)

The short answer is no. (And we apologize for this.)

There's a much more powerful set of tools available for working with
ODEs provided in the python package pydstool; they provide many
features including this one. Alternatively, there are a number of
wrappers for the ODEPACK integrator LSODAR (which is included but not
wrapped in scipy) which provides exactly this capability. Finally, you
can get some approximation of this behviour using scipy's integrators;
they can be made to advance "one step" of the underlying integrator at
a time, and while in this mode they can be used to "backtrack" as far
as the beginning of the step. So you can just keep advancing until you
meet your criterion then backtrack.

This brings me to a warning: no ODE solver I know of is able to deal
with "here there be dragons"-type events, that is, situations where
you not only want the integrator to stop, but where it is not allowed
to evaluate anything past that point (perhaps because your RHS
function yields nonsense). The standard approach is to write RHS
functions so that they detect out-of-bounds conditions and return some
not-too-offensive value, hoping that this won't send the integrator
into a frenzy.


> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user

More information about the SciPy-User mailing list