两个ODE求解器之间的差异

时间:2019-03-13 23:09:49

标签: python solver odeint

我想知道,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 个答案:

答案 0 :(得分:2)

主要区别如下:

  1. odeint首先出现,并使用FORTRAN软件包odepack中的 lsoda 来求解ODE。
  2. solve_ivp是一种更通用的解决方案,它使用户可以决定使用哪个积分器来求解ODE。如果将method参数定义为method='LSODA',则它将使用与odeint相同的积分器。另外,您可以选择其他方法,例如 BDF RK25

关于性能,有一张票证表明solve_ivp的速度较慢。这可能是因为它是用Python编写的。

  

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

在scipy中检查两个文档:

  

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