58 lines
1.2 KiB
Python
58 lines
1.2 KiB
Python
|
# -*-coding:Latin-1 -*
|
||
|
from math import *
|
||
|
print("Entrez la fréquence de coupure:")
|
||
|
frequence = input()
|
||
|
#print(f)
|
||
|
print("Entrez l'impédance d'entrée:")
|
||
|
impedance=input()
|
||
|
print("Entrez l'amplitude max:")
|
||
|
amplitude=input()
|
||
|
print("Entrez l'ordre du filtre:")
|
||
|
ordre=input()
|
||
|
#Calcul des paramètres
|
||
|
#Calcule de wc
|
||
|
wc=2*pi*frequence
|
||
|
#Calcul de b
|
||
|
b=log(cosh(amplitude/17.37)/sinh(amplitude/17.37))
|
||
|
#Calcul de gamma
|
||
|
gamma=sinh(b/(2*ordre))
|
||
|
#initialisation i
|
||
|
i=1
|
||
|
ak=[0]*ordre
|
||
|
bk=[0]*ordre
|
||
|
gk=[0]*ordre
|
||
|
#Cacule de ak
|
||
|
for i in range(ordre):
|
||
|
ak[i-1]=sin((2*(i-1)*pi)/(2*ordre))
|
||
|
#Calcul de bk
|
||
|
for i in range(ordre):
|
||
|
bk[i-1]=pow(gamma,2)+(sin(i*pi)/ordre)
|
||
|
print("test")
|
||
|
print(bk)
|
||
|
#Calcul de gk
|
||
|
|
||
|
gk[0] = ((2*ak[1])/gamma)
|
||
|
print(ak)
|
||
|
print(gk[0])
|
||
|
print(bk[0])
|
||
|
for i in range(ordre):
|
||
|
gk[i]=((4*ak[i-1]*ak[i])/(bk[i-1]*gk[i-1]))
|
||
|
#Calcul de ck et lk
|
||
|
if (ordre%2)==0:
|
||
|
for i in range(ordre):
|
||
|
lk[i]=(impedance/wc)*gk[i]
|
||
|
for i in range(ordre):
|
||
|
ck[i]=(1/impedance)*(1/wc)*gk[i-1]
|
||
|
else:
|
||
|
for i in range(ordre):
|
||
|
lk[i]=(impedance/wc)*gk[i-1]
|
||
|
for i in range(ordre):
|
||
|
ck[i]=(1/impedance)*(1/wc)*gk[i]
|
||
|
#Calcul de Rn
|
||
|
if ordre==1:
|
||
|
rn=1*impedance
|
||
|
else:
|
||
|
rn=pow((tanh(b/4)),2)
|
||
|
|
||
|
print(ck)
|