用四元函数求解二阶常微分方程

2024-05-29 07:33:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我在研究一个阻尼的,驱动摆的动力学,二阶常微分方程定义为so,特别是我正在编程:

d^2y/dt^2+c*dy/dt+sin(y)=a*cos(wt)

import numpy as np
import matplotlib.pyplot as plt
from scipy import integrate


def pendeq(t,y,a,c,w):
    y0 = -c*y[1] - np.sin(y[0]) + a*np.cos(w*t)
    y1 = y[1]
    z = np.array([y0, y1])
    return z

a = 2.1
c = 1e-4
w = 0.666667     # driving angular frequency

t = np.array([0, 5000])   # interval of integration
y = np.array([0, 0])      # initial conditions

yp = integrate.quad(pendeq, t[0], t[1], args=(y,a,c,w))

这个问题看起来确实与Need help solving a second order non-linear ODE in python非常相似,但是我得到了错误

^{pr2}$

我做错什么了??在


Tags: import定义asnpdtsincos动力学

热门问题