#Given
N=2
RL=100
Z0=50
#Function to calculate factorial
def fact(n):
if n==0:
return 1
return n*fact(n-1)
#Function to calculate the value of rho
def rho(n,N,RL,Z0):
temp=(2**(-N))*(float((RL-Z0))/(RL+Z0))*(fact(N)/(fact(N-n)*fact(n)))
return temp
def char_imp(rho,Z0):
temp=Z0*(1+rho)/(1-rho)
return temp
rho_0=rho(0,N,RL,Z0)
rho_1=rho(1,N,RL,Z0)
Z1=char_imp(rho_0,Z0)
Z2=char_imp(rho_1,Z0)
frac_bw=0.375
rho_m=(float(RL-Z0)/(RL+Z0))*(cos((-pi/4)*(frac_bw-2)))**2
print "Maximum tolerable co-efficient:",rho_m
VSWR=(1+rho_m)/(1-rho_m)
print "VSWR:",VSWR
#given
f=15*10**6
v=3*10**8
lamda=v/float(f)
a=0.95*10**-3*lamda
a1=3.175*10**-4*lamda
s=3.81*10**-3*lamda
u=ceil((a/2)/(a1/2))
v=ceil(s/(a1/2))
print "u: %f, v: %f" %(u,v)
alpha=log(v)/(log(v)-log(u))
print "Alpha: %f" %alpha
step_up=(1+alpha)**2
print "Step-up ratio: %f" %step_up
Za=30.44*(1-1j)
Z2=step_up*Za/2
print "Z2:",Z2,"ohms"
Z0=276*log10((2*s)/sqrt(a*a1))
print "Z0:",Z0,"ohms"
z2=Z2/Z0
print "z2:",z2,"ohms"
y2=1/z2
print "y2:",y2,"ohms"
#zg is calculated using smith's chart
zg=0+0.23j
yg=1/zg
print "Generator admittance:",yg,"siemens"
yin=y2+yg
print "Input admittance:",yin,"siemens"
zin=1/yin
print "Input impedance:",zin,"ohms"
Zin=Z0*zin
print "Unnormalized impedance:",Zin,"ohms"
C=1/(2*pi*f*Zin.imag)
print "Capacitance: %f pF" %(C*10**12)