# -*- coding: Latin-1 -*- # Programme de tracé du trajectoire de phase d'un pendule simple # avec l'approximation des petits angles (linéaire) # Dominique Lefebvre pour TangenteX.com # 29 décembre 2015 # # importation des librairies from scipy.integrate import odeint from scipy import array, arange,pi, sin from matplotlib.pyplot import figure,plot,show,xlabel,ylabel,title,tight_layout # Définition du système différentiel linéaire def Pendule(Theta,t): theta = Theta[0] theta_point = Theta[1] dtheta = theta_point dtheta_point = -theta return array([dtheta, dtheta_point]) # définition du vecteur temps de l'expérience t0 = 0 tmax = 5*pi pastemps = 0.01 time = arange(t0, tmax, pastemps) theta0 = pi/10. # calcul et tracé du portrait de phase figure(figsize=(6,6)) theta, theta_point = odeint(Pendule,(theta0,0),time).T plot(theta, theta_point) # titre et libellés title("Diagramme de phase - pendule simple") xlabel('$\\theta$', fontsize = 20) ylabel('$\dot{\\theta}$', fontsize = 20) tight_layout() show()