[SciPy-Dev] ode and odeint callable parameters

Benny Malengier benny.malengier at gmail.com
Tue Jan 19 12:38:27 EST 2016


Why would you ever want to use one or the other?

LSODA (odeint) is fixed coefficient BDF, and VODE (ode) variable
coefficient BDF, so should improve on LSODA as soon as there are often
sharp and frequent time variation. If not present, VODE should be as good
as LSODA.

So, VODE is supposed to be better at handling a wider array of use cases.
So you should just always use VODE (or even better one of the modern
bindings to cvode), and not select at all (or you need to have really a
huge system were fixed coefficient BDF is better, but then you should not
be using python, and cvode can run in parallel on a HPC, has Krylov
methods, and will outperform it.)

Benny

2016-01-19 16:49 GMT+01:00 Irvin Probst <irvin.probst at ensta-bretagne.fr>:

> Hi,
> maybe my question has been asked a thousand times but why are the
> callable's parameters in ode and odeint reversed ?
>
> From scipy.integrate.ode:
>
> http://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.integrate.ode.html#scipy.integrate.ode
>     f : callable f(t, y, *f_args)
>
> From scipy.integrate.odeint:
>
> http://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.integrate.odeint.html
> func : callable(y, t0, ...)
>
> Admittedly one will usually choose ode or odeint depending on what has to
> be done, but from an educational point of view this is really annoying.
> Say you want to show how to use ode or odeint to simulate something ? You
> have to define twice the same dynamics:
>
>
> def f_odeint(y,t):
>     return y[1], -np.sin(y[0])
>
> def f_ode(t,y):
>     return [[y[1], -np.sin(y[0])]]
>
> Then come the usual questions:
> - why do I have to reverse y and t ? => Err... you see... because...
> - why can't I return a tuple in f_ode as in f_odeint ? => see ticket #1187
>
> So I know that reversing the callable's parameters will break half the
> code using ode or odeint in the world and this is out of question, but
> couldn't it be possible to make it a bit more clear somewhere in the doc
> that the parameters are indeed reversed ? Or maybe am I missing some
> obvious explanation ?
>
> Regards.
>
>
>
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> https://mail.scipy.org/mailman/listinfo/scipy-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20160119/c588c9e2/attachment.html>


More information about the SciPy-Dev mailing list