[SciPy-user] solving an ode with boundary conditions
Tue Jun 23 21:27:15 CDT 2009
On Jun 23, 2009, at 6:57 PM, Rob Clewley wrote:
> On Tue, Jun 23, 2009 at 8:37 PM, Max Wainwright<firstname.lastname@example.org>
>> I have a 1D second-order differential equation that I'm trying to
>> solve with the following boundary conditions: dy/dt = 0 at r = 0
>> and y
>> (t) = 0 at t = infinity. I can solve this by doing guess and check
>> for the initial value of y at t = 0. If I guess too high, then y
>> goes to negative infinity at t = infinity. If I guess too low, y
>> never reaches zero and instead oscillates about some minimum.
>> Therefore, to check if I've overshot or undershot the solution all I
>> need to do is stop the integration once either y or -dy/dt goes
>> negative. Is there any way to do this with scipy? I also tried
>> looking at PyDSTool, but I had a hard time finding what I need. I
>> don't in principle know the time-scale of the solution (I'll be doing
>> this for lots of different parameters), so I'd like to avoid using a
>> fixed timestep.
> It's pretty easy to set up a standard minimizer from scipy to use an
> adaptive time step solver of your choice to implement the "shooting
> method" for this boundary value problem (BVP), which is simple enough
> to permit this method of solution. You just need to measure your
> over-/undershoot numerically in such a way that it provides correct
> feedback to the optimizer. PyDSTool would make catching the event of y
> or -dy/dt going negative very simple, but it does not have a BVP
> solver itself either. There are plenty of tutorial and demo scripts
> about that online. This would be hard with scipy's solvers. If you set
> up an attempt and need more help you can post it here for more
> Scipy does not have a BVP built in either. You can also try this
> recent package:
> http://www.elisanet.fi/ptvirtan/software/bvp/index.html but that might
> be like using a sledgehammer to crack a nut, as we say.
> SciPy-user mailing list
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.
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.
More information about the SciPy-user