[SciPy-User] odeint with saturation?
Jonathan Stickel
jjstickel at vcn.com
Fri Oct 15 11:55:42 EDT 2010
On 10/12/10 11:00 , scipy-user-request at scipy.org wrote:
> Date: Tue, 12 Oct 2010 08:12:41 -0400
> From: Brian Blais<bblais at bryant.edu>
> Subject: [SciPy-User] odeint with saturation?
> To: SciPy Users List<scipy-user at scipy.org>
>
> Hello,
>
> I am using odeint to solve some diff eqs, and it works great, but
> some of my cases have saturating values. In many cases a value can't
> go negative (if it does, it should just be set equal to zero). It
> doesn't seem as if odeint can do this, but is there an easy or
> preferred way of solving that kind of system?
>
>
> thanks!
>
> Brian Blais
>
Brian
Maybe you have figured this out on your own already, but I have one
suggestion. In your function that defines the set of ODEs, do something
like:
...
if var < eps && dvar<0:
dvar = 0
...
return [array of rate variables including dvar]
Where 'var' is the variable you want to prevent being negative and
'dvar' is the rate for var calculated earlier in your function.
HTH,
Jonathan
P.S. I found that the effort to learn how to use scipy.integrate.ode
was the effort. It provides more control and a slightly better solver
than scipy.integrate.odeint. YMMV.
More information about the SciPy-User
mailing list