I am studying the dynamics of a damped, controlled pendulum with a second-order ODE defined as so , and in particular I will program:
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
t = np.array([0, 5000])
y = np.array([0, 0])
yp = integrate.quad(pendeq, t[0], t[1], args=(y,a,c,w))
This problem really looks like I need help solving a second-order nonlinear ODE in python , but I get an error
Supplied function does not return a valid float.
What am I doing wrong?
source
share