import scipy
#Variable Declaration
R=0
G=0
a=0
Ro=70 #characteristic impedence in ohms
B=3 #phase constant in rad/sec
f=100*10**6 #frequency in Hz
w=2*scipy.pi*f #omega in rad/sec
#Calculations
C=B/(w*Ro) #capacitance in F/m
L=Ro*Ro*C #inductance in H/m
#Results
print 'inductance per meter =',round(L*10**9,1),'nH/m'
print 'capacitance per meter =',round(C*10**12,1),'pF/m'
#Variable Declaration
Zo=60 #in ohms
a=20*10**-3 #in Np/m
u=0.6*3*10**8 #in m/sec
f=100*10**6 #in Hz
#Calculations
R=a*Zo #resistance in ohms/m
L=Zo/u #inductance in H/m
G=a*a/R #conductivity in S/m
C=1/(u*Zo) #capacitance in F/m
lam=u/f #wavelentgh in m
#Results
print 'R =',R,'ohm/m'
print 'L =',round(L*10**9,0),'nH/m'
print 'G =',round(G*10**6,0),'micro S/m'
print 'C =',round(C*10**12,2),'pF/m'
print 'lambda =',lam,'m'
import scipy
import cmath
from numpy import *
#Variable Declaration
w=10**6 #omega in rad/sec
B=1 #phase factor in rad/m
a=8.0/8.686 #alpha in Np/m
Y=a+1j #in m^-1
l=2 #length in m
Vg=10 #source voltage in volts
Zo=60+40j #in ohms
Zg=40 #in ohms
Zl=20+50j #load impedance in ohms
#Calculations
s=scipy.tanh(Y*l)
Zin=Zo*(Zl+Zo*s)/(Zo+Zl*s) #input impedance in ohms
Zinr=round(Zin.real,2) #real part of Zin rounded to 2 decimal places
Zini=round(Zin.imag,2) #imaginary part of Zin rounded to 2 decimal places
Io=Vg/(Zin+Zg) #in A
absIo=round(abs(Io),6) #absolute value of Io rounded to 6 decimal place
Ior=Io.real #real part of Io
Ioi=Io.imag #imaginary part of Io
angIo=scipy.arctan(Ioi/Ior)*180/scipy.pi
#in degrees
Vo=Zin*Io
Vop=(Vo+Zo*Io)/2
Vom =(Vo-Zo*Io)/2
Im=((Vop*scipy.e**(-Y)/Zo))-((Vom*scipy.e**Y)/Zo)
#current at the middle in A
absIm=round(abs(Im),5) #absolute value of Im rounded to 6 decimal place
Imr=Im.real #real part of Im
Imi=Im.imag #imaginary part of Im
angIm=360+scipy.arctan(Imi/Imr)*180/scipy.pi
#in degrees
#Results
print 'The input impedance =',Zinr,'+',Zini,'j ohms'
print 'The sending-end current is'
print 'mod =',absIo*10**3,'mA, angle =',round(angIo,2),'degrees'
print 'The current at the middle is'
print 'mod =',absIm*10**3,'mA, angle =',round(angIm,0),'degrees'
import scipy
import cmath
from numpy import *
#Variable Declaration
l=30 #length in m
Zo=50 #in ohms
f=2*10**6 #frequency in Hz
Zl=60+40j #load impedence in ohms
u=0.6*3*10**8 #in m/s
w=2*scipy.pi*f #omega in rad/sec
#Calculations
T=(Zl-Zo)/(Zl+Zo) #reflection coefficient
ang=scipy.arctan(T.imag/T.real)*180/scipy.pi #argument of T is degrees
s=(1+abs(T))/(1-abs(T)) #standing wave ratio
B=w/u #propogation vector in m^-1
Zin=Zo*(Zl+Zo*scipy.tan(B*l)*1j)/(Zo+Zl*scipy.tan(B*l)*1j)
Zinr=round(Zin.real,2) #real part of Zin rounded to 2 decimal places
Zini=round(Zin.imag,2) #imaginary part of Zin rounded to 2 decimal places
#Results
print 'The reflection coefficient is'
print 'mod =',round(abs(T),4),'angle =',round(ang,0),'degrees'
print 'The standing wave ratio s =',round(s,3)
print 'The input impedance =',Zinr,'+',Zini,'j ohms'
import scipy
import cmath
from numpy import *
#Variable Declaration
Zl=100+150j #load impedance in ohms
Zo=75 #impedance of line in ohms
B=2*scipy.pi
#Calculations
T=(Zl-Zo)/(Zl+Zo)
angT=scipy.arctan(T.imag/T.real)*180/scipy.pi
s=(1+abs(T))/(1-abs(T))
Yl=(1/Zl)*10**3 #admittance in mS
Ylr=round(Yl.real,2) #real part of Yl rounded to 2 decimal places
Yli=round(Yl.imag,2) #imaginary part of Yl rounded to 2 decimal places
l1=0.4
Zin=Zo*(Zl+Zo*scipy.tan(B*l1)*1j)/(Zo+Zl*scipy.tan(B*l1)*1j)
Zinr=round(Zin.real,2) #real part of Zin rounded to 2 decimal places
Zini=round(Zin.imag,2) #imaginary part of Zin rounded to 2 decimal places
#Results
print 'r is mod =',round(abs(T),3),',angle =',round(angT,0),'degrees'
print 's =',round(s,2)
print 'The load admittance Yl =',Ylr,'+',Yli,'j mS'
print 'Zin at O.4 lambda from the load =',Zinr,'+',Zini,'j ohms'
#part (e) and (f) don't require computations
import scipy
import cmath
from numpy import *
#Variable Declaration
s=2
l1=11
l2=19
ma=24
mi=16
u=3*10**8 #speed of wave in m/s
Zo=50 #in ohms
#Calculations
l=(l2-l1)*2 #lambda in cm
f=(u/l)*10**-7 #frequency in GHz
L=(24-19)/l #Let us assume load is at 24cm
zl=1.4+0.75j # by smith chart
Zl=Zo*zl #ZL in ohms
#Results
print 'lambda =',l,'cm'
print 'f =',f,'GHz'
print 'ZL =',Zl,'ohms'
import scipy
import cmath
from numpy import *
#Variable Declaration
Zo=100 #in ohms
Zl=40+30j #in ohms
#Calculations
Yo=1.0/Zo #in S
yl=Zo/Zl
ys1=1.04j #By smith chart
ys2=-1.04j #By smith chart
Ys1=Yo*ys1 #in S
Ys2=Yo*ys2 #in S
la=round(0.5-(62-(-39))/720.0,2) #in units of lambda
lb=round((62-39)/720.0,3) #in units of lambda
da=round(88/720.0,4) #in units of lambda
db=round(272/720.0,4) #in units of lambda
#Results
print 'The required stub admittance values in mS are',Ys1*1000,'and',Ys2*1000
print 'The distance between stub and antenna at A =',la,'in units of lambda'
print 'The distance between stub and antenna at B =',lb,'in units of lambda'
print 'The stub lengths =',da,'and',db,'in units of lambda'
print 'Part (d) is done using smith chart'
import scipy
import matplotlib.pyplot as plt
#Variable Declarataion
zo=75 #in ohms
zg=25 #in ohms
zl=100 #in ohms
vg=4 #in volts
l=60 #in m
c=3*10**8 #speed of light in m/s
u=0.1*c #in m/s
#Calculations
gammag=(zg-zo)/(zg+zo)
gammal=(zl-zo)/(zl+zo)
Vo=zo*vg/(zo+zg) #in V
t1=l/u #in micro sec
Io=vg/(zo+zg) #in mA
#Results
t1=[0,4,5,8,9,12,13,15]
I1=[40,31.43,-8.571,-7.959,0.6123,0.5685,-0.0438,-0.438]
fig = plt.figure()
ax = fig.add_subplot(111)
ax.step(t1,I1,where='post')
ax.set_xlabel('Time (micro s)')
ax.set_ylabel(r'I(0,t) in mA')
plt.show()
t2=[0,2,6,7,10,11,14]
I2=[0,34.3,31.9,-2.46,-2.28,0.176,0.176]
fig = plt.figure()
ax = fig.add_subplot(111)
ax.step(t2,I2,where='post')
ax.set_xlabel('Time (micro s)')
ax.set_ylabel(r'I(l,t) in mA')
plt.show()
import scipy
#Variable Declaration
Er=3.8 #relative permittivity
c=3*10**8 #speed of wave in m/s
r=4.5 #ratio of line width to substrate thickness
#Calculations
Eeff=((Er+1)/2)+((Er-1)/(2*(1+12/r)**0.5))
Zo=(120*scipy.pi)/((r+1.393+(0.667*scipy.log(r+1.444)))*((Eeff)**0.5))
f=10**10
l=c/(f*scipy.sqrt(Eeff))
#Results
print 'The effective relative permittivity of the substrate =',round(Eeff,3)
print 'The characteristic impedance of the line =',round(Zo,2),'ohms'
print 'The wavelength of the line at 10 GHz =',round(l*1000,2),'mm'
import scipy
#Variable Declaration
h=1 #in mm
w=0.8 #in mm
Er=6.6 #relative permittivity
P=scipy.arctan(0.0001)
c=5.8*10**7 #conductivity in S/m
f=10**10 #frequency in Hz
mu=4*scipy.pi*10**-7 #permeability of free space
C=3*10**8 #speed of wave in m/s
r=w/h
#Calculations
Ee=((Er+1)/2.0)+((Er-1)/(2.0*(1+12/r)**0.5))
Zo=(120.0*scipy.pi)/((r+1.393+(0.667*scipy.log(r+1.444)))*((Ee)**0.5))
Rs=scipy.sqrt((scipy.pi*f*mu)/c)
ac=8.686*Rs/(w*(10**-3)*Zo)
l=C/(f*(Ee)**0.5)
ad=27.3*(Ee-1)*Er*scipy.tan(P)/((Er-1)*Ee*l)
#Results
print 'attenuation due to conduction loss =',round(ac,2),'dB/m'
print 'attenuation due to dielectric loss =',round(ad,3),'dB/m'