Search code examples
pythonparallel-processingscipyintegrator

Parallel ODE integration using SciPy


I'm using SciPys integrate.ode module to integrate a large system (~8000 equations) of ODEs. Because I always have to do several of those with different parameters I parallelized it using the multiprocessing module, which seems to be working fine. However, the documentation of SciPy says:

Warning:

This integrator is not re-entrant. You cannot have two ode instances using the “vode” integrator at the same time.

So now my question is if I can trust my results from the parallel runs? Or does this Waring also apply to instances in different processes?


Solution

  • If you try to use the integrator twice in the same session you get an error:

    from scipy.integrate import ode
    
    f = lambda x: x
    
    a = ode(f)
    b = ode(f)
    
    a.set_integrator('vode')
    b.set_integrator('vode')
    
    a.integrate(0.1)
    b.integrate(0.1)
    a.integrate(0.1)
    
    # IntegratorConcurrencyError: Integrator `vode` can be used to 
    # solve only a single problem at a time. If you want to integrate 
    # multiple problems, consider using a different integrator 
    # (see `ode.set_integrator`)
    

    If you do not get this error in a multiprocessing environment it seems reasonable to assume your results are valid.