====== Tracer la propagation d'une onde ====== def f(x,t,c,T): return cos(2*pi*(t/T-x/(c*T))) def affiche(c,T,tmax,xmax): dt=tmax/10. dx=xmax/10000. x=[] for i in range(10000): x.append(i*dx) for i in range(0,11): y=[] plt.subplot(11,1,i+1) for j in range(10000): y.append(f(x[j],i*dt,c,T)) plt.plot(x,y,"blue",label="t = {:.4f}s".format(i*dt)) plt.plot([c*i*dt],[f(c*i*dt,i*dt,c,T)],"o",color="red") plt.plot([c*i*dt+c*T],[f(c*i*dt+c*T,i*dt,c,T)],"o",color="green") plt.legend(loc='upper right',framealpha=1.) plt.xlabel("distance (m)") plt.show() affiche(c = 340,T = 1/1000., tmax = 0.002, xmax = 1.2) #utilise la fonction affiche pour une onde de célérité 340 m/s, de fréquence 1kHz donne {{:python:programmes_de_physique_chimie_en_python:438074a8f579ba512c7437bba20b485d.png}}