[SciPy-User] possible bug with scipy.integrate.ode

Warren Weckesser warren.weckesser@enthought....
Fri Nov 4 08:01:07 CDT 2011


On Fri, Nov 4, 2011 at 7:35 AM, Flavio Coelho <fccoelho@gmail.com> wrote:

> Hi,
>
> I am a long time user of scipy.integrate.odeint for solving ODEs. Today I
> decided to test the "other solver" in scipy: scipy.integrate.ode I am
> getting strange results for model below:
>
> def fun(y,t):
> """
> Logistic model
>  """
> a = .5
> k = 1000.0
>  return a*(1-y/k)*y
>
> r = ode(fun).set_integrator('vode',method='bdf', with_jacobian=False)
> r.set_initial_value(1e-6,0)
> res = np.zeros(10000)
> i = 0
> while r.successful() and r.t < 100:
> r.integrate(r.t+.01)
> res[i] = r.y
>  i += 1
>
>
> odeint solves this correctly and returns the caracteristic logistic curve
> which maxes out at 1000. ode, however, keeps growing beyond 1000.
>
> I may be doing something stupid, since I am not familiar with the usage of
> ode. Or there maybe a bug in ode.
>
>

Flávio,

It is unfortunate, but odeint and ode use different conventions for the
order of the arguments of the function that defines the system of
differential equations.  If you change the signature of your definition of
'fun' to 'def fun(t, y):', your example works fine.

Warren




> I'll just stay away from ode for now, but I thought it might be a good
> Idea to report this.
>
>
> --
> Flávio Codeço Coelho
> ================
> +55(21) 3799-5567
> Professor
> Escola de Matemática Aplicada
> Fundação Getúlio Vargas
> Rio de Janeiro - RJ
> Brasil
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20111104/0f2fa7bd/attachment.html 


More information about the SciPy-User mailing list