两个ODE求解器之间的差异



我想知道,求解微分方程的ODEINTsolve_ivp之间有什么区别。它们之间有什么优势和缺点?

f1 = solve_ivp(f, [0,1], y0) #y0 is the initial point
f2 = odeint(f, y0, [0, 1], args=(a, b)) # a and b are arguments of function f

谢谢

嗯,主要区别是:

  1. odeint首先出现,是从fortran package odepack中使用 lsoda 解决odes。
  2. solve_ivp是一种更通用的解决方案,可以使用确定要使用哪个集成符来求解ODE的解决方案。如果将method参数定义为method='LSODA',则将使用与odeint相同的集成器。此外,您可以选择其他方法,例如 BDF RK25

关于性能,有一张票证表明solve_ivp较慢。这也许是因为它用python写。

https://github.com/scipy/scipy/sissues/8257

在Scipy中检查两个文档:

https://docs.scipy.org/doc/scipy-1.2.1.2.1/reference/generated/scipy.integrate.odeint.html https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.integrate.solve.solve_ivp.html

最新更新