DOP853統合メソッドがありません(SciPy)

Aug 18 2020

私はSciPyによって提供されたいくつかの統合方法をチェックしていました。そこではDOP853がウェブページに従って含まれるべきです(https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html#scipy.integrate.solve_ivp)。

ただし、他とは異なり、DOP853は機能せず、次のメッセージが表示されます。

~/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.

その方法をどのように使用できるか、またはどこで見つけることができるか知っていますか?微分方程式を高精度に解くのに推奨され、複素数領域に適用できるので、特に必要です。

回答

1 Alex Aug 18 2020 at 17:39

使用しているscipyのバージョンを確認します。DOP853は、比較的最近1.4.0で導入されました。

1.4.1では、DOP853が適切にリストされています。

>>> 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.