[SciPy-user] solving an ode with boundary conditions

Rob Clewley rob.clewley at gmail.com
Tue Jun 23 22:39:16 EDT 2009


> Could you kindly point me to an example PyDSTool script that does
> some sort of variable tracking (ie, checking when y goes negative)?
> I'm completely new to the package, and I can't find it in the wiki.

On the wiki it is here:
http://www.cam.cornell.edu/~rclewley/cgi-bin/moin.cgi/Events

If you have any suggestions about navigating the wiki documentation
that might improve the experience for new users please send them to me
privately.

As for example scripts, you can search for "Events" in the
PyDSTool/tests directory and find it in many of them, but I suggest
you start with vode_event_test1.py which should contain all you need
for your problem. There, the Event object thresh_ev_term will
terminate integration when the variable w crosses parameter p_thresh
from above (i.e. w-p_thresh goes from positive to negative). Details
of the set up are explained on the Events wiki page above.

If your RHS is fairly complex I suggest you define an "auxiliary
function" for your RHS and use it to both define your ODE's RHS and to
define the zero-crossing condition for the event. If your RHS is
fairly simple you can just retype the definition into the event
definition.

> I don't think I can use the standard odeint or ode from scipy,
> because I don't know the point at which the over or undershooting
> will become obvious.  It could be at r = .1, or it could be at r =
> 100.  I suppose I could dynamically change the integration range, but
> this seems kind of kludgy.

I agree. I think you will be much better off even using the slower
built-in integrator Vode which has been wrapped in PyDSTool from its
scipy form in order to support event detection. It should be adequate
for your 1D problem without resorting to the other PyDSTool
integrators which have more installation dependencies.

-Rob



More information about the SciPy-User mailing list