1
$\begingroup$

I was checking some integration methods provided by SciPy, in which the DOP853 should be included according to the webpage (https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html#scipy.integrate.solve_ivp).

However, unlike others, DOP853 does not work and the following message appears:

~/anaconda3/lib/python3.6/site-packages/scipy/integrate/_ivp/ivp.py in solve_ivp(fun, t_span, y0, method, t_eval, dense_output, events, vectorized, **options)
    425             inspect.isclass(method) and issubclass(method, OdeSolver)):
    426         raise ValueError("`method` must be one of {} or OdeSolver class."
--> 427                          .format(METHODS))
    428 
    429     t0, tf = float(t_span[0]), float(t_span[1])

ValueError: `method` must be one of {'RK23': <class 'scipy.integrate._ivp.rk.RK23'>, 'RK45': <class 'scipy.integrate._ivp.rk.RK45'>, 'Radau': <class 'scipy.integrate._ivp.radau.Radau'>, 'BDF': <class 'scipy.integrate._ivp.bdf.BDF'>, 'LSODA': <class 'scipy.integrate._ivp.lsoda.LSODA'>} or OdeSolver class.

Do you know how I can use that method or where I can find it? I need it in particular as it is recommended for solving differential equations with high precision and it can be applied in the complex domain.

$\endgroup$

1 Answer 1

1
$\begingroup$

I would check what version of scipy you are using. DOP853 was introduced relatively recently in 1.4.0.

In 1.4.1, I see DOP853 listed appropriately.

>>> import scipy
>>> scipy.__version__
'1.4.1'
>>> from scipy.integrate import solve_ivp
>>> def exponential_decay(t, y): return -0.5 * y

>>> sol = solve_ivp(exponential_decay, [0, 10], [2, 4, 8], "DOP853")
>>> print(sol.t)
[ 0.          0.25860956  2.84470518  7.28558373 10.        ]
>>> sol = solve_ivp(exponential_decay, [0, 10], [2, 4, 8], "Invalid")
Traceback (most recent call last):
  File "<pyshell#37>", line 1, in <module>
    sol = solve_ivp(exponential_decay, [0, 10], [2, 4, 8], "Invalid")
  File "C:\WPy64-3771\python-3.7.7.amd64\lib\site-packages\scipy\integrate\_ivp\ivp.py", line 507, in solve_ivp
    .format(METHODS))
ValueError: `method` must be one of {'RK23': <class 'scipy.integrate._ivp.rk.RK23'>, 'RK45': <class 'scipy.integrate._ivp.rk.RK45'>, 'DOP853': <class 'scipy.integrate._ivp.rk.DOP853'>, 'Radau': <class 'scipy.integrate._ivp.radau.Radau'>, 'BDF': <class 'scipy.integrate._ivp.bdf.BDF'>, 'LSODA': <class 'scipy.integrate._ivp.lsoda.LSODA'>} or OdeSolver class.
$\endgroup$
3
  • $\begingroup$ Thanks for the reply. Indeed, my scipy version is out-of-date. Where can I update it? $\endgroup$
    – user33042
    Commented Aug 18, 2020 at 11:51
  • 1
    $\begingroup$ From the command line run: "python -m pip install --upgrade scipy" $\endgroup$
    – Alex
    Commented Aug 18, 2020 at 14:06
  • 1
    $\begingroup$ Or conda update scipy, it depends on your installation. $\endgroup$
    – nicoguaro
    Commented Aug 18, 2020 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.