# -*- coding: Latin-1 -*- # Programme de tracé du diagramme de phase d'un pendule simple # avec l'approximation des petits angles (linéaire) # Dominique Lefebvre pour TangenteX.com # 29/12/2015 # # importation des librairies from scipy.integrate import odeint from scipy import array, arange,linspace,pi from matplotlib.pyplot import figure,plot,show,xlabel,ylabel,xlim,ylim,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) # table des variations des conditions initiales pour tracer # le diagramme de phase borne_init = pi/10. nb_orbites = 10 theta_init = linspace(0,borne_init,nb_orbites) # calcul et tracé du portrait de phase figure(figsize=(6,6)) for theta0 in theta_init: theta, theta_point = odeint(Pendule,(theta0,0),time).T plot(theta, theta_point) # titre et libellés title("Diagramme de phase - pendule lineaire") xlabel('$\\theta$', fontsize = 20) ylabel('$\dot{\\theta}$', fontsize = 20) tight_layout() show()