Diagramme de Bode de la fonction de transfert H.
from math import * from cmath import polar,exp from kandinsky import fill_rect as fr def H(w): w0=500 # return (1/(1+1j*w/w0)) #passe_bas # return 1/(1-1j*w0/w) #passe_haut return 3/(1-5*(w0/w)**2+1j*w0/w) def between(x,y1,y2,limits): good=lambda y: min(max(y,limits[0]),limits[1]) y1_,y2_=good(y1),good(y2) fr(x,min(y1_,y2_),1,max(y1_-y2_,y2_-y1_)+1,[(255,0,0),(100,100,255)][(y1,y2)==(y1_,y2_)]) scale=[1e-3,1e8] l_dB,l_arg=polar(H(scale[0])) l_dB=int(log10(l_dB)*20) l_arg=int(l_arg/pi*50) bl=[26,166] #base_line for i in range(2): fr(8,110*i+4,304,104,(0,)*3) fr(10,110*i+6,300,100,(255,)*3) fr(10,bl[i],300,1,(120,)*3) for i in range(300): w=scale[0]*(scale[1]/scale[0])**(i/299) dist,ang=polar(H(w)) if log10(scale[0]*(scale[1]/scale[0])**((i-1)/299))//1!=log10(w)//1: fr(10+i,6,1,100,(155,)*3) fr(10+i,116,1,100,(155,)*3) dB=int(log10(dist)*20) between(10+i,bl[0]-l_dB,bl[0]-dB,[6,105]) l_dB=dB arg=int(ang/pi*50) between(10+i,bl[1]-l_arg,bl[1]-arg,[116,215]) l_arg=arg