[SciPy-Dev] ode and odeint callable parameters

Benny Malengier benny.malengier at gmail.com
Tue Jan 26 08:49:19 EST 2016


As a follow up, I adapted your code, to add odes, and also cvode versions
via the odes scikit.
Timings on my PC:

Time for dop853:      5.587895
Time for vode/BDF:  0.005166
Time for lsoda:         0.006365
Time for cvode/BDF: 0.006328
Time for cvode/BDF - class:   0.006171
Time for cvode/BDF - cython: 0.003059
Time for lsoda     - cython:      0.00459
Time for vode/BDF  - cython: 0.003977

So, fastes is odes with cvode and cython rhs. Then VODE and cython (almost
30% slower), then LSODA and cython.

Without cython, VODE is fastest, then cvode without a wrapper around the
function (almost 20% slower), then normal cvode = lsoda.

Nice to see C beating Fortran, but that is probably due to the trip around
to python.

Benny

2016-01-26 12:48 GMT+01:00 Benny Malengier <benny.malengier at gmail.com>:

>
>
> 2016-01-26 11:43 GMT+01:00 Marcel Oliver <m.oliver at jacobs-university.de>:
>
>>
>>  > Some extra tests seem in order. How does method=adams in ode succeed?
>> Should
>>  > you be able to quickly make an ipython notebook ...
>>
>> I attach a small code snippet.  In fact, my memory failed me in that
>> dop853 indeed complains about insufficient nmax (nsteps in the Python
>> API).  What breaks is the accuracy of the solution, but it's still
>> remarkably good and can be controlled by nsteps.  It's obvious that
>> one should not solve this kind of problem with dop853, but I am still
>> amazed that it does not fall flat on its face.
>>
>> In fact, vode/Adams dies completely (as it should) and vode/BDF gives
>> lots of warnings and computes a completely wrong solution (BDF schemes
>> are supposed to work here).  lsoda is fine, though.
>>
>
> You forgot
> , with_jacobian=True
> when doing bdf metho via ode. So change into:
>
> r2 = ode(van_der_pol).set_integrator('vode', method='bdf',
> with_jacobian=True)
>
> Normally, as vode is for stiff methods, you set ml or mr to indicate how
> banded the jacobian is. Here you want full jacobian, so you should indicate
> this, see doc.
> Result then is as lsoda.
>
> Can I use your code in an example under the scipy license ? I'll see what
> odes does.
>
> Benny
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20160126/af10e2ed/attachment.html>


More information about the SciPy-Dev mailing list