I try to solve the Duffing equation using odeint
:
def func(z, t):
q, p = z
return [p, F*np.cos(OMEGA * t) + Fm*np.cos(3*OMEGA * t) + 2*gamma*omega*p - omega**2 * q - beta * q**3]
OMEGA = 1.4
T = 1 / OMEGA
F = 0.2
gamma = 0.1
omega = -1.0
beta = 0.0
Fm = 0
z0 = [1, 0]
psi = 1 / ((omega**2 - OMEGA**2)**2 + 4*gamma**2*OMEGA**2)
wf = np.sqrt(omega**2 - gamma**2)
t = np.linspace(0, 100, 1000)
sol1 = odeintw(func, z0, t, atol=1e-13, rtol=1e-13, mxstep=1000)
When F = gamma = beta = 0
we have a system of two linear homogeneous equations. It's simple!
But when F not equal 0
the system becomes non homogeneous. The problem is that the numerical solution does not coincide with the analytical one:
Figure 1
the numerical solution does not take into account the inhomogeneous solution of the equation.
I have not been able to figure out if it is possible to use here solve_bvp
function. Could you help me?