Computational Science Asked by J.J on December 26, 2020
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.
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-3771python-3.7.7.amd64libsite-packagesscipyintegrate_ivpivp.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.
Correct answer by Alex on December 26, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP