#calculate Inductance per unit lengths,Capacitance per unit lengths,Characteristic Impedance ,Velocity of propagation
#chapter-4 page 141 example 4.1
import math
d=0.0049;#Diameter of inner conductor in met
D=0.0110;#Inner Diameter of outer conductor in met
er=2.3;#Polyethylene dielectric
c=3.*10.**8.;#Velocity of Light in m/sec
#CALCULATIONS
x=math.log(D/d);
L=(2.*10.**(-1.)*x);#Inductance per unit lengths in microH/m
C=(55.56*(er/x));#The Capacitance per unit lengths in picoF/m
R0=(x*(60./math.sqrt(er)));#The Characteristic Impedance in ohms
V=(c/math.sqrt(er))/(10.**8.);#The Velocity of propagation in Km/s
#OUTPUT
print '%s %.2f %s %s %.2f %s %s %.2f %s %s %.3f %s' %('\nInductance per unit lengths is L=',L,'microH/m' ,'\nThe Capacitance per unit lengths is C=',C,'picoF/m' ,'\nThe Characteristic Impedance is R0=',R0,'ohms','\nThe Velocity of propagation is V=',V,'*10**8 m/s');
#calculate Attenuation Constant,Phase Constant ,Phase Velocity,Relative Permittivit,Power Loss
#chapter-4 page 142 example 4.2
import math
R=0.05##Resistance in ohm/m
L=0.16173*10.**(-6.)##Inductance per unit lengths in H/m
C=0.15802*10.**(-6.)##The Capacitance per unit lengths in F/m
V=197814.14##The Velocity of propagation in Km/s
l=50.##Length of Coaxial Line in met
Pin=480.##Input Power to the System in watts
f=3.*10.**9.##Frequency in Hz
c=3.*10.**5.##Velocity of Light in Km/sec
e0=8.854*10.**(-12.)##Permittivity in free space in F/m
#CALCULATIONS
Z0=math.sqrt(L/C)#
A=(R/(2.*Z0))##Attenuation Constant in NP/m
w=(2.*(math.pi)*f)##Angular Frequency in rad/sec
B=(w*math.sqrt(L*C))##Phase Constant in rad/m
Vp=(1./math.sqrt(L*C))/(10.**3.)##Phase Velocity in Km/s
er=(((c/V)**2.)/e0)##Relative Permittivity
Pl=(2.*Pin*l)##Power Loss in watts
#OUTPUT
print '%s %.3f %s %s %.2f %s %s %.f %s %s %.f %s %.f %s ' %('\nAttenuation Constant is A=',A,'NP/m','\nPhase Constant is B=',B,'rad/m','\nPhase Velocity is Vp=',Vp,'Km/s','\nRelative Permittivity is er=',er,'\nPower Loss is Pl=',Pl,'watts')#
#chapter-4 page 142 example 4.3
#For an air filled coaxial cable
import math
f=9.375*10.**9.##operating frequency in Hz
c=3.*10.**10.##Velocity of Light in cm/sec
print '%s' %('Assuming a ratio of (b/a)=2.3 and (b+a)<(w/pi) to exclude higher order modes and a dominant mode propagating')#
a=0.36432##length of coaxial cable in cm
x=2.3##ratio of b/a
#CALCULATION
w0=(c/f)##free space wavelength in cm
Pbd=(3600.*(a**2.)*math.log(x))##Breakdown power of a coaxial cable in kW
#OUTPUT
print '%s %.f %s' %('\nBreakdown power of a coaxial cable is Pbd=',Pbd,'kW')#
#calculate Characteristic Impedance, Velocity of propagation
#chapter-4 page 142 example 4.4
import math
b=0.3175##Distance between ground planes of strip line in cm
d=0.0539##Diameter of circular conductor in cm
er=2.32##Dielectric Constant
c=3.*10.**8.##Velocity of Light in m/sec
#CALCULATION
Z0=((60./math.sqrt(er))*math.log((4.*b)/(d*(math.pi))))##Characteristic Impedance in ohms
V=(c/math.sqrt(er))/(10.**8.)##The Velocity of propagation in Km/s
#OUTPUT
print '%s %.2f %s %s %.2f %s' %('Characteristic Impedance is Z0=',Z0,'ohms','\nThe Velocity of propagation is V =',V,'*10**8 m/s')
#chapter-4 page 143 example 4.5
import math
#For a microstrip transmission line
er=9.7##relative dielectric constant of an alumina substrate
x1=0.5##w/h ratio in first transmission line
x2=5##w/h ratio in second transmission line
c=3.*10.**8.##Velocity of Light in m/sec
#CALCULATION
print '%s' %('For case1: w/h=0.5')#
print '%s' %('Since x1=0.5<1, for this we use high impedance analysis')#
Eeff1=(((er+1.)/2.)+((er-1.)/2.)*(1./((math.sqrt(1.+(12./x1)))+(0.04*(1.-x1)**2.))))##Effective dielectric constant
Zo1=((60./math.sqrt(Eeff1))*math.log((8./x1)+(x1/4.)))##Characteristic impedance in ohms
V1=(c/math.sqrt(Eeff1))/10.**8.##Velocity of propagation in 10**8 m/sec
print '%s %.2f %s %.2f %s %s %.1f %s ' %('\nEffective dielectric constant is Eeff1 =',Eeff1,'\nCharacteristic impedance is Zo1 =',Zo1,'ohms','\nVelocity of propagation is V1 =',V1 ,'*10**8 m/sec')#
print '%s' %('\nFor case2: w/h=5')#
print '%s' %('here x2>1')#
Eeff2=(((er+1)/2)+((er-1)/2)*(1/(math.sqrt(1+(12/x2)))))##Effective dielectric constant
Zo2=((120*(math.pi)/math.sqrt(Eeff2))*(1/(x2+1.393+(0.667*math.log(1.444+x2)))))##Characteristic impedance in ohms
V2=(c/math.sqrt(Eeff2))/10**8##Velocity of propagation in 10**8 m/sec
print '%s %.2f %s %.2f %s %s %.2f %s' %('\nEffective dielectric constant is Eeff2 =',Eeff2,'\nCharacteristic impedance is Zo2 =',Zo2,'ohms' ,'\nVelocity of propagation is V2 =',V2,'*10**8 m/sec')#
#Calculate Ratio of area of circular to area of rectangular waveguide in case a and case b
import math
#Variable declaration
a1 = 1.70645 #for case a
b1 = a1/2 #for case a
b2 = 1.4621 #for case b
#Calculations
#Case a(For TE10 mode)
Area_rw1 = a1*b1
Area_cw1 = math.pi
Ratio1 = Area_cw1/Area_rw1
#Case b(For TM mode)
Area_rw2 = b2**2
Area_cw2 = math.pi
Ratio2 = Area_cw2/Area_rw2
#Results
print "Case a"
print "Ratio of area of circular to area of rectangular waveguide =",round(Ratio1,1),"\n"
print "Case b"
print "Ratio of area of circular to area of rectangular waveguide =",round(Ratio2,1)
#Calculate breadth of rectangular waveguide
import math
#Variable declaration
f = 9.*10**9 #frequency(Hz)
lamda_g = 4. #guide wavelength(cm)
c = 3.*10**10 #velocity of propagation(cm/s)
#Calculations
lamda_o = c/f
lamda_c = math.sqrt((lamda_o**2)/(1-(lamda_o**2/lamda_g**2)))
#For TE10 mode,
a = lamda_c/2
b = lamda_c/4 #@since a=2b
#Results
print "The breadth of rectangular waveguide is",round(b,1),"cms"
#Calculate cut-off wavelength,guided wavelength,pahse velocity,group velocity
#Variable declaration
a = 10 #breadth of waveguide(cms)
f = 2.5*10**9 #frequency of signal(Hz)
c = 3*10**10 #velocity of propagation(cm/s)
#Calculations
lamda_c = 2*a #cut-off wavelength
lamda_o = c/f
x = math.sqrt(1-((lamda_o/lamda_c)**2))
lamda_g = (lamda_o/x) #guided wavelength
Vp = c/x #Phase velocity
Vg = c**2/Vp #Group velocity
#Results
print "The cut-off wavelength is", round(lamda_c),"cm"
print "The guided wavelength is",round(lamda_g),"cm"
print "The pahse velocity is",round((Vp/1E+10),2),"*10^10 cm/sec"
print "The group velocity is",round((Vg/1E+10),2),"*10^10 cm/sec"
#chapter-4 page 147 example 4.9
import math
f=8.6*10.**9.##frequency in Hz
c=3.*10.**10.##Velocity of Light in cm/sec
a=2.5##Length of a Waveguide in cm
b=1.##Width of a Waveguide in cm
#CALCULATION
print '%s' %('The condition for the wave to propagate along a guide is that wc>w0.')#
w0=c/f##free space wavelength in cm
print '%s %.3f' %('\nFree space wavelength w0 in cm is =',w0)#
print '%s' %('\nFor TE waves, wc=(2ab/sqrt((mb)**2+(na)**2))')#
print '%s ' %('For TE01 waves')#
m1=0#
n1=1.#
wc1=((2.*a*b)/(math.sqrt((m1*b)**2+(n1*a)**2)))##Cutoff wavelength for TE01 mode in cm
print '%s %.f' %('\nCutoff wavelength for TE01 mode in cm is =',wc1)#
print '%s' %('\nSince wc for TE01=2cm is not greater than w0 TE01,will not propagate for TE01 mode.')#
print '%s' %('For TE10 waves')#
m2=1.#
n2=0#
wc2=((2.*a*b)/(math.sqrt((m2*b)**2.+(n2*a)**2.)))##Cutoff wavelength for TE10 mode in cm
print '%s %.f' %('\nCutoff wavelength for TE10 mode in cm is =',wc2)#
print '%s' %('\nSince wc TE10 > w0 TE10 is a possible mode.')#
fc=(c/wc2)/10.**9.##Cutoff frequency in GHz
print '%s' %('\nFor TE11 and TM11 waves')#
m3=1.#
n3=1.#
wc3=((2.*a*b)/(math.sqrt((m3*b)**2.+(n3*a)**2.)))##Cutoff wavelength for TE11 mode in cm
print '%s %.3f' %('Cutoff wavelength for TE11 and TM11 modes in cm is =',wc3)#
print '%s' %('\nAs wc for TE11 and TM11 is < w0 both TE11 and TM11 do not propagate as higher modes.')#
wg=(w0/math.sqrt(1-(w0/wc2)**2))##Guide wavelength in cm
print '%s' %('\nFrom the above analysis we conclude that only TE10 mode is possible')#
#OUTPUT
print '%s %.f %s %s %.3f %s' %('\nCutoff frequency is fc=',fc,'GHz','\nGuide wavelength is wg=',wg,'cm')#
#Calculate required cross sectional area
import math
#Variable declaration
lamda_c = 10 #cut-off wavelength(cms)
c = 3*10**10 #velocity of propagation
#Calculations
#For TE11 mode in a circular waveguide,
r = (lamda_c*1.841)/(2*math.pi) #radius of circular waveguide(cms)
a = math.pi*r**2 #area of circular waveguide
fc = c/lamda_c #cut-off frequency(Hz)
#Results
print "The required cross sectional area is", round(a,2),"cms^2"
print "Frequencies above",round((fc/1E+9),2),"GHz can be propagated throught the waveguide"
#chapter-4 page 149 example 4.11
#For a rectangular waveguide
import math
f=5.*10.**9.##frequency in Hz
c=3.*10.**10.##Velocity of Light in cm/sec
a=4.##Length of Rectangular Waveguide in cm
b=3.##Width of Rectangular Waveguide in cm
#CALCULATION
print '%s' %('The condition for the wave to propagate along a guide is that wc>w0.')#
w0=c/f##free space wavelength in cm
print '%s %.2f' %('Free space wavelength w0 in cm is =',w0)#
print '%s' %('\nFor TE waves, wc=(2ab/sqrt((mb)**2+(na)**2))')#
print '%s' %('For TE01 waves')#
m1=0#
n1=1.#
wc1=((2.*a*b)/(math.sqrt((m1*b)**2.+(n1*a)**2.)))##Cutoff wavelength for TE01 mode in cm
print '%s %.f' %('\nCutoff wavelength for TE01 mode in cm is =',wc1)#
print '%s' %('\nSince wc for TE01=6cm is not greater than w0 TE01,will not propagate for TE01 mode.')#
print '%s' %('For TE10 waves')#
m2=1.#
n2=0#
wc2=((2.*a*b)/(math.sqrt((m2*b)**2.+(n2*a)**2.)))##Cutoff wavelength for TE10 mode in cm
print '%s %.f' %('\nCutoff wavelength for TE10 mode in cm is =',wc2)#
print '%s' %('\nSince wc TE10 > w0 TE10 is a possible mode.')#
print '%s' %('For TE11 waves')#
m3=1.#
n3=1.#
wc3=((2.*a*b)/(math.sqrt((m3*b)**2.+(n3*a)**2.)))##Cutoff wavelength for TE11 mode in cm
print '%s %.1f' %('\nCutoff wavelength for TE11 mode in cm is =',wc3)#
print '%s' %('\nAs wc TE11 < w0 TE11 does not propagate.')#
#Calculate Cut-off wavelength,Cut-off wavelength,Guide wavelength
import math
#Variable declaration
d = 4 #inner diameter of circular waveguide(cms)
c = 3*10**10 #velocity od propagation(m/s)
fs = 5*10**9 #signal frequency(Hz)
#Calculations
r = d/2 #radius(cms)
lamda_c = (2*math.pi*r)/1.841
fc = c/lamda_c
lamda_o = c/fs
lamda_g = lamda_o/math.sqrt(1-((lamda_o/lamda_c)**2))
#Results
print "Cut-off wavelength =",round(lamda_c,4),"cms"
print "Cut-off frequency =",round((fc/1E+9),3),"GHz"
print "Guide wavelength =",round(lamda_g,2),"cms"
#Calculate Frequency of wave
import math
#Variable declaration
a = 6. #length of rectangular waveguide(cms)
b = 4. #breadth of rectangular waveguide(cms)
d = 4.55 #distance between maximum and minimum(cms)
c = 3.*10**10 #velocity of propagation(cm/s)
#Calculations
#For TE10 mode:
lamda_c = 2*a
lamda_g = d*4
lamda_o = math.sqrt(1./(((1./lamda_g**2)+(1./lamda_c**2))))
f = c/lamda_o
#Results
print "Frequency of wave is",round((f/1E+9)),"GHz"
#Calculate Guide wavelength,Phase constant,Phase velocity
#chapter-4 page 151 example 4.14
#For a rectangular waveguide
import math
b=2.5##Length of Rectangular Waveguide in cm
a=5.##breadth of Rectangular Waveguide in cm
c=3.*10.**10.##Velocity of Light in cm/sec
w0=4.5##Free space wavelength in cm
#CALCULATION
print '%s' %('For a TE10 mode which is the dominant mode')#
wc=2.*a##Cutoff wavelength in cm
wg=(w0/math.sqrt(1.-(w0/wc)**2.))##Guide wavelength in cm
Vp=(c/math.sqrt(1.-(w0/wc)**2.))/10.**10.##Phase Velocity in 10**10 cm/sec
B=((2.*(math.pi)*math.sqrt(wc**2.-w0**2.))/(w0*wc))##Phase constant in radians
#OUTPUT
print "Solutions obtained in the textbook are incorrect due to calculation mistake in lamda_g"
print '%s %1.5f %s %s %1.3f %s %s %1.2f %s ' %('\nGuide wavelength is wg =',wg,'cm','\nPhase constant is B =',B,'radians','\nPhase Velocity is Vp =',Vp,'*10**10 cm/sec')#
#Note: Check the answers once
#Correct answers are
#Guide wavelength is wg = 5.03903 cm
#Phase constant is B = 1.247 radians
#Phase Velocity is Vp = 3.36*10**10 cm/sec
#Calculate For any wave to be propagated, the condition to be met is wc>wo
#chapter-4 page 152 example 4.15
wcTE10=16.##Critical wavelength of TE10 mode in cm
wcTM11=7.16##Critical wavelength of TM11 mode in cm
wcTM21=5.6##Critical wavelength of TM21 mode in cm
print '%s' %('For any wave to be propagated, the condition to be met is wc>wo')#
wo1=10.##Free space wavelength in cm
wo2=5.##Free space wavelength in cm
print '%s %.2f' %('Critical wavelength of TE10 mode in cm is =',wcTE10)#
print '%s %.2f' %('Critical wavelength of TM11 mode in cm is =',wcTM11)#
print '%s %.2f' %('Critical wavelength of TM21 mode in cm is =',wcTM21)#
print '%s' %('\nFor wo1=10cm,\nThe mode that propagates only TE10. Because wcTE10>wo1 and all other modes that is TM11 TM21 donot propagate')#
print '%s' %('\nFor wo2=5cm')#
print '%s' %('wcTE10>wo2, so TE10 mode propagates')#
print '%s' %('wcTM11>wo2, so TE11 mode propagates')#
print '%s' %('wcTE21>wo2, so TE21 mode propagates')#
#Calculate Characteristic Wave Impedance
#chapter-4 page 152 example 4.16
import math
n=120.*(math.pi)##Intrinsic Impedance
a=3.##Length of Rectangular Waveguide in cm
b=2.##Width of Rectangular Waveguide in cm
f=10.**10.##Frequency in Hz
c=3.*10.**10.##Velocity of Light in cm/sec
#CALCULATION
wc=((2.*a*b)/math.sqrt(a**2.+b**2.))##Cutoff wavelength in TM11 mode in cms
w0=(c/f)##Free space wavelength in cms
ZTM=(n*math.sqrt(1.-(w0/wc)**2.))##Characteristic Wave Impedance in ohms
#OUTPUT
print '%s %.3f %s ' %('\nCharacteristic Wave Impedance is ZTM=',ZTM,'ohms')#
#Note: Check the given answer once it is wrong
#correct answer is 163.242 ohms
#Calculate diameter of waveguide,guide wavelength
import math
#Variable declaration
f = 6.*10**9 #frequency(Hz)
c = 3.*10**10 #velocity of propagation(cm/s)
#Calculations
fc = 0.8*f
lamda_c = c/fc
D = (lamda_c*1.841)/math.pi
lamda_o = c/f
lamda_g = lamda_o/(math.sqrt(1-((lamda_o/lamda_c)**2)))
#Results
print "diameter of waveguide =",round(D,4),"cms"
print "guide wavelength =",round(lamda_g,3),"cms"
#chapter-4 page 153 example 4.18
#For a TE10 mode
import math
a=1.5##Length of an air filled square Waveguide in m
b=1.##breadth of an air filled square Waveguide in cm
c=3.*10.**10.##Velocity of Light in cm/sec
f=6.*10.**9.##Impressed Frequency in Hz
er=4.##dielectric constant
#CALCULATION
wc=2.*a##Cutoff wavelength in cm
fc=(c/wc)/10.**9.##Cutoff frequency in GHz
print '%s %.2f' %('Cutoff frequency in GHz is =',fc)#
print '%s' %('\nThe impressed frequency of 6 GHz is less than the Cutoff frequency and hence the signal will not pass through the guide')#
w=(c/f)##Wavelength in cm
print '%s %.2f' %('\nAlternatively, the wavelength of the impressed signal in cm is =',w)#
wair=w#
print '%s' %('\nwhich is longer than the cutoff wavelength (3cm) and hence no propagation of the wave')#
w1=wair/math.sqrt(er)##Wavelength in cm
print '%s' %('If the waveguide is loaded with dielectric of er=4')#
print '%s %.2f' %('\nthen the wavelength in cm is =',w1)
print '%s' %('\nwhich is lessthan wair')#
print '%s' %('Now the signal with 6 GHz frequency will pass through the dielectric loaded waveguide')#
#Calculate amount of attenuation
import math
#Variable declaration
a = 1.5*10**-2 #length of rectangular waveguide(m)
b = 1 #breadth of rectangular waveguide(cms)
f = 6*10**9 #frequency(Hz)
c = 3*10**10 #velocity of propagation(m/s)
m = 1
n = 0
mu = 4*math.pi*10**-7
e = 8.854*10**-12
#Calculations
#For dominant TE10 mode,
lamda_c = 2*a
fc = c/lamda_c
w = 2*math.pi*f
alpha = math.sqrt((((m*math.pi)/a)**2)+(((n*math.pi)/b)**2)- ((w**2)*mu*e))
#Results
print "The amount of attenuation is",round(alpha,1),"nepass/m"
#Calculate The maximum power handling capacity of the waveguide
#chapter-4 page 154 example 4.20
import math
a=3.##Length of Rectangular Waveguide in cm
b=1.##Width of Rectangular Waveguide in cm
f=9.*10.**9.##Frequency in Hz in TE10 mode
c=3.*10.**10.##Velocity of Light in cm/sec
Emax=3000.##Max potential gradient in V/cm
#CALCULATION
w0=(c/f)##Free space wavelength in cms
print '%s %.2f' %('Free space Wavelength in cm is =',w0)#
wc=2.*a##Cutoff wavelength in TE10 mode in cms
wg=(w0/math.sqrt(1.-(w0/wc)**2.))##Guide wavelength in cms
print '%s %.2f' %('Guide Wavelength in cm is =',wg)#
P=((6.63*10.**(-4.))*(Emax**2.)*a*b*(w0/wg))/1000.##Power handling capability of the waveguide in kW
#OUTPUT
print '%s'%('\nSolution obtained in the textbook is incorrect due to rounding off the actual value of lamda_g')
print '%s %3.3f %s' %('\nPower handling capability of the waveguide is P=',P,'kW')#
#Calculate Maximum power
import math
#Variable declaration
f = 9*10**9 #frequency(Hz)
d = 5 #internal diameter(cms)
Emax = 300 #maximum field strength(V/cm)
c = 3*10**10 #velocity of propagation(m/s)
#Calculations
lamda_o = c/f
#For domnant mode TE11,
lamda_c = (math.pi*d)/1.841
lamda_g = lamda_o/math.sqrt(1-((lamda_o/lamda_c)**2))
Pmax = 0.490*(Emax**2)*(d**2)*(lamda_o/lamda_g)
#Results
print "Maximum power =",round((Pmax/1E+6),3),"*10^6 W"
#chapter-4 page 155 example 4.22
#calculate The Peak value of Electric field occuring in the guide
#For an air filled square waveguide
import math
a=0.01##Length of an air filled square Waveguide in m
b=0.01##breadth of an air filled square Waveguide in m
c=3.*10.**8.##Velocity of Light in m/sec
f=30.*10.**9.##Frequency in Hz in TE11 mode
Pmax=746.##Max power =1 horsepower in W
n=120.*(math.pi)##Impedance of freespace in ohms
#CALCULATION
w0=(c/f)##Free space wavelength in m
wc=2.*a##Cutoff wavelength in m
ZTE=(n/math.sqrt(1.-(w0/wc)**2.))##Impedance in ohms
Emax=(math.sqrt((Pmax*4*ZTE)/(a*b)))/1000.##The Peak value of Electric field occuring in the guide in kV/m
#From P=(1/2)*Integration(Re(E*H))da
#and Pmax=(1/(4*ZTE))*Emax**2*a*b
#OUTPUT
print '%s %.2f %s' %('\nThe Peak value of Electric field occuring in the guide is Emax=',Emax,'kV/m')#
#Calculate Breakdown power
import math
#Variable declaration
a = 2.3 #length of rectangular waveguide(cms)
b = 1.0 #breadth of rectangular waveguide(cms)
f = 9.375*10**9 #frequency(Hz)
c = 3*10**10 #velocity of propagation(m/s)
#Calculations
lamda_o = c/f
x = (1-((lamda_o/(2*a))**2))**0.5
Pbd = 597*a*b*x
#Results
print "calculation error"
print "\nBreakdown power =",round(Pbd,2),"W"
#Calculate Breakdown power
import math
#Variable declaration
d = 5. #internal diameter(cms)
a = d/2
f = 9.*10**9 #frequency(Hz)
c = 3.*10**10 #velocity of propagation
#Calculations
lamda_o = c/f
lamda_c = (math.pi*d)/1.841
fc = c/lamda_c
x = (1 - ((fc/f)**2))**0.5
Pbd = 1790.*a*a*x
#Results
print "Breakdown power =",round((Pbd/1E+3),3),"kW"