import math
a=0.0006 #The attenuation coeff in N/m
#a) Determinaion of the attenuation coeff in dB/m
a_dB=8.686*a
a_dB=round(a_dB,3)
print 'The attenuation coeff is',a_dB,'dB/m'
#b) Determination of attenuation coeff in dB/mile
k=1609 #conversion coeff for meter to mile
a_dB_mile=k*a_dB
a_dB_mile=round(a_dB_mile,2)
print 'The attenuation coeff is',a_dB_mile,'dB/mile'
import math
Z0=50.0 #measured in ohm
VSWR=2.0
d=0.2 #distance from load to firstt minimum
T=(VSWR -1)/(VSWR+1)
pi=180.0
Ql=pi*(4*0.2-1) #using Euler’s identity
e=complex(math.cos(Ql),math.sin(Ql)) #expansion for e ˆ( jQl )
a=T*e
#Load impedance is given as
ZL=Z0*(1+a)/(1-a)
Zlr=round(ZL.real,2)
Zli=round(ZL.imag,2)
print 'a)The equivalent series resistance is',Zlr,'ohm'
print ' The equivalent series reactance is',Zli,'ohm'
Yl=1/ZL
Yl1=round(1/Yl.real,2)
Yli=round(1/Yl.imag,2)
print 'b)The equivalent parallel resistance is',Yl1,'ohm'
print ' The equivalent parallel reactance is',Yli,'ohm'
import math
from math import pi
d=0.1 #length of 50ohm short−circuited line
Z0=50 #in ohm
f=500*10**6 #freq in Hz
Bl=2*pi*d
#a) Determination of equivalent inductive reactance
Z=complex(0,Z0*math.tan(Bl))
Z=round(Z.imag,2)
print 'The equivalent inductive reactance is',Z,'j','ohm'
import math
from math import pi
VSWR=2.0
l_min=0.2
Z0=50.0
Ql=((4*l_min )-1)*pi
tl=(VSWR -1)/(VSWR+1)
Tl=complex(0,tl*math.e**(Ql))
Zl=Z0*(1+Tl)/(1-Tl)
Zr=round(Zl.real,2)
Zm=round(Zl.imag,2)
print 'a) The equivalent series resistance is',Zr,'ohm'
print ' The equivalent series reactance is',Zm,'ohm'
Yl=1/Zl
Yl=1/Yl.real
Yl=round(Yl,2)
print 'b) The equivalent parallel resistance is',Yl,'ohm'
import math
ZL=complex(30,0)-complex(0,23)
l=0.5 #length of line in m
Z0=50.0 #characteristic impedance in ohm
wl=0.45 #wavelength on the line in m
B=2*pi/wl
Tl=(ZL-Z0)/(ZL+Z0)
VI=1.0 #reference voltage in volt
VR=VI*Tl
z=complex(B*l)
Vi=VI*math.e**(z)
Vr=VR*math.e**(-z)
V=Vi+Vr
I=(Vi-Vr)/Z0
Z=V/I
Z1=round(Z.real,2)
Zi=Z.imag*10**5
Zi=round(Zi,2)*10**-5
print 'The input impedance is',Z1,'+',Zi,'j','ohm'
import math
from math import pi,sqrt
Z0=600.0
Zl=73.0 #in ohm
F=0.9
QF=(2*pi*F)/4
#For matching , the effective load impedance on the main line must equal the characteristic impedance of the mail line
Zl1=Zl
Z01=sqrt(Zl1*Zl)
Tl=(Zl-Z01)/(Zl+Z01)
VI=1 #reference voltage
Vi=VI*math.e**(complex(0,QF));
Vr=Tl*VI*math.e**-(complex(0,QF))
V_in=Vi+Vr
I_in=(Vi-Vr)/Z01
Z_in=V_in/I_in
print'The input impedance is',Z_in,'ohm'
#the voltage reflection coeff is
TL_F=(Z_in -Z0)/(Z_in+Z0)
#the VSWr is given as
VSWR_F=(1+TL_F)/(1-TL_F)
VSWR_Fr=round(VSWR_F.real,2)
VSWR_Fi=VSWR_F.imag
print 'The VSWR is',VSWR_Fr,'+',VSWR_Fi,'j'