RK45 ode 求解器 python3
RK45 ode solver python3
请问如何使用这个function?
我有一个函数 return 右侧微分方程列表 right(t, x0)
。
import scipy.integrate as ode
t, r =ode.RK45(right(t, x0), t0, tmax, dt)
错误:
TypeError: 'list' object is not callable
请问第一个参数应该是什么?
您将函数作为对象而不是函数值传递,因此
solver = ode.RK45(right)
solver.set_initial(y0,t0)
然后在 solver.integrate
的循环中计算所需的积分步骤,请参阅文档中的示例。
如果您有任何最新版本的 scipy
,请使用较新的 solve_ivp
界面,一次调用即可提供所有内容
solution = solve_ivp(right, [t0, tmax], y0, method = "RK45", t_eval = np.arange(t0,tmax,dt))
并在solution.t
和solution.y
中找到解决方案组件,其中后者是每个状态组件的时间序列的元组。
请问如何使用这个function?
我有一个函数 return 右侧微分方程列表 right(t, x0)
。
import scipy.integrate as ode
t, r =ode.RK45(right(t, x0), t0, tmax, dt)
错误:
TypeError: 'list' object is not callable
请问第一个参数应该是什么?
您将函数作为对象而不是函数值传递,因此
solver = ode.RK45(right)
solver.set_initial(y0,t0)
然后在 solver.integrate
的循环中计算所需的积分步骤,请参阅文档中的示例。
如果您有任何最新版本的 scipy
,请使用较新的 solve_ivp
界面,一次调用即可提供所有内容
solution = solve_ivp(right, [t0, tmax], y0, method = "RK45", t_eval = np.arange(t0,tmax,dt))
并在solution.t
和solution.y
中找到解决方案组件,其中后者是每个状态组件的时间序列的元组。