[SciPy-Dev] ODE solvers

Sturla Molden sturla.molden at gmail.com
Thu Jun 4 07:52:32 EDT 2015


Anne Archibald <archibald at astron.nl> wrote:

> * Manage reentrancy constraints (some FORTRAN solvers store state in global
> variables)

Use a threading.Lock instead of the GIL.

> Concerns for implementation:
> * Users should be able to provide compiled callables of some kind and have
> them called without passing through the python interpreter. This presumably
> needs to apply to stopping conditions/event functions too.
> * For fast solutions, a python driver loop may be too slow.

A suggestion:

Provide a Cython cdef class as permitted RHS callback. Users can then
cimport and subclass this Cython class in their own Cython module. There
will only be some tiny overhead (a vtab lookup). The superclass' callback
method should just be "pure virtual" and raise NotImplementedError. We will
have to provide a .pxd similarly to what we now do for sharing BLAS and
LAPACK. It is also possible to have another Cython callback class which
assumes nogil during the ODE solver loop.

One could also reverse this design and export solvers directly to Cython,
which the user can cimport and call with a C function pointer as callback.
It will avoid the vtab lookup, but then we cannot use the same interface
code for Cython and Python.

Another thing:

We should have more solvers, even simple ones like Euler and 4th order
Runge-Kutta for reference. We also lack Bulirsch-Stoer. Ot seems we just
have those that are in odepack.


Sturla




More information about the SciPy-Dev mailing list