# -*- coding: utf-8 -*-
"""
Pendule pesant : non isochronisme des oscillations
"""

import matplotlib.pyplot as plt
import numpy as np
import scipy.integrate

w0 = 7                       # pulsation propre en rad/s
t = np.linspace(0,5,5000)    # liste des instants (prendre qq periodes)

# Avec X = [thetapoint, theta]
def F(X,t):        # Fonction definissant le systeme d'equa diff
    return [-w0**2*np.sin(X[1]),X[0]]         


plt.figure()
plt.xlabel('Temps (s)')
plt.ylabel('Theta (°)')

# lacher sans vitesse initiale a differents angles
for theta0 in [10, 30, 60, 90, 120, 178]:    # theta ici en degres
    CI = [0,theta0*np.pi/180]                # CI [thetapoint en rad/s, theta converti en rad]
    solution = scipy.integrate.odeint(F,CI,t)      # Resolution du systeme differentiel
    plt.plot(t,solution[:,1]*180/np.pi,label='Theta(0)='+str(theta0)+'°')
plt.legend()
