import numpy as np import matplotlib.pyplot as plt m = 0.05 x0 = 0.5E-2 k = 4.5 omega = np.sqrt(k/m) t = np.linspace(0, 20, 1000) x = x0 * np.sin(omega*t) v = x0 * omega * np.cos(omega*t) a = -x0 * omega**2 * np.sin(omega*t) fig, ax = plt.subplots(3, 1, sharex = True) ax[0].set_title("Mouvement d'un pendule simple: m = %.3f g, $x_0$ = %.2f cm, k = %.2f N/m" %(m*1000, x0*100, k)) ax[0].plot(t, x, 'r') ax[0].set_ylabel("Position (m)") ax[0].set_xlim([np.min(t), np.max(t)]) ax[0].set_ylim([-1.2 * np.max(x), 1.2 * np.max(x)]) #ax[0].grid() ax[1].plot(t, v, 'g') ax[1].set_ylabel("Vitesse (m/s)") ax[1].set_xlim([np.min(t), np.max(t)]) ax[1].set_ylim([-1.2 * np.max(v), 1.2 * np.max(v)]) ax[1].grid() ax[2].plot(t, a, 'b') ax[2].set_xlabel('Temps(s)') ax[2].set_ylabel("Accélération (m/s²)") ax[2].set_xlim([np.min(t), np.max(t)]) ax[2].set_ylim([-1.2 * np.max(a), 1.2 * np.max(a)]) ax[2].grid() plt.figure() plt.title("Espace des phases") plt.plot(x, v, "m") plt.ylabel("Vitesse") plt.xlabel("Position") plt.axis("equal") plt.show()