Python:求解自治二阶 ODE
我有以下自治常微分方程系统,其中x
和v
是向量(初始条件x0
和>v0
)
dx/dt = v
dv/dt = F(x, v)
等价地,可以将其编写为二阶 ODE 系统
d^2 x/ dt^2 = F(x, dx/dt)
我如何使用 Python 来解决这个问题?
from scipy.integrate import solve_ivp, odeint
# Suppose F gives me the right-hand side of the ODE or d^2 x /dt^2
F = lambda x, v: pass
# How can I integrate this ODE system numerically?
# For instance from time `t0` to time `t1`
# Given initial condition `z0 = (x0, v0)`
I have the following autonomous system of ODEs where x
and v
are vectors (with initial conditions x0
and v0
)
dx/dt = v
dv/dt = F(x, v)
Equivalently, one can write it as a second order ODE system
d^2 x/ dt^2 = F(x, dx/dt)
How can I solve this using Python?
from scipy.integrate import solve_ivp, odeint
# Suppose F gives me the right-hand side of the ODE or d^2 x /dt^2
F = lambda x, v: pass
# How can I integrate this ODE system numerically?
# For instance from time `t0` to time `t1`
# Given initial condition `z0 = (x0, v0)`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我有时使用的复制粘贴模板。假设您有
def F(x, v,parameters): return # some np.array of Accelerations
输出为:
Here is my copy-paste templet that I sometimes use. Assume you have
def F(x, v, parameters): return # some np.array of accelerations
The output is: