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

m1=264000000
k1=225000000
x0=0.25
def f(X1,X2,t) :
    x1, dx1_dt = X1
    x2, dx2_dt = X2
    ddx1_dtt = -k1*x1/m1 + k2*(x2-x1)/m2
    ddx2/dtt = -k2*(x2-x1)/m2 - f(dx1_dt - dx2_dt)
    return[dx1_dt, ddx1_dtt]
    return[dx2_dt, ddx2_dtt]
X10 = [x0,0]
X20 = [0,0]
tab_instants = np.linspace(0,60,500)
X_scipy=odeint(f, X0, tab_instants)
plt.plot(tab_instants, X_scipy[:, 0])
plt.xlabel("temps(m)")
plt.y1label("x1(m)")
plt.y2label("x2(m)")
plt.title("oscillation d'un système masse ressort")
plt.grid()
plt.show()
    



           

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: