from __future__ import division
from math import sqrt
#Given,
a=6 #cm
b=4 #cm
d=4.47 #cm
c=3e8 #m/s
lamc=2*a
lamg=2*d
#Signal wavelength
lam=lamg*lamc/(sqrt(lamg**2+lamc**2))
lam=lam/100 #m
f=c/lam
print 'Signal frequency of dominant mode: %0.3f'%(f/1e9), 'Ghz'
from math import pi
#Given,
c=3e8 #m/s
a=2.5 #cm
b=5 #cm
lam=4.5 #cm
lamc=2*b
#Guide wavelength
lamg=lam/(sqrt(1-((lam/lamc)**2)))
print 'Guide wavelength: %0.3f'%lamg,'cm'
#Phase constant
bet=(2*pi)/lamg
bet=bet*100 #rad/m
print 'Phase constant: %0.3f'%bet,'rad/m'
#Phase velocity
w=(2*pi*c)/lam
vp=w/bet
print 'Phase velocity: %0.3f'%vp,'m/s'
#Given,
c=3e8 #m/s
a=4 #cm
b=2 #cm
f=10e9 #Hz
m=1
n=1
#Cutoff wavelength
lamc=2/sqrt((m/a)**2+(n/b)**2)
print 'Cut-off wavelength: %0.3f'%lamc,'cm'
#Wave impedance
lam=c/f #m
lam=lam*100 #cm
eeta=120*pi
z0=eeta*sqrt(1-(lam/lamc)**2)
print 'Wave impedance: %0.3f'%z0,'ohm'
#Given,
c=3e8 #m/s
f=10e9 #Hz
zte=410 #ohm
#Wider dimension
lam=c/f #m
lam=lam*100 #cm
a=3/(2*(sqrt(1-(120*pi/zte)**2)))
print 'Wider dimension: %0.3f'%a, 'cm'
#Given,
c=3e8 #m/s
a=3.0 #cm
b=1.5 #cm
mur=1
er=2.25
x=mur*er
#(i) Cutoff wavelength and frequencuy
print 'TE10 mode'
m1=1
n1=0
lamc10=2/sqrt((m1/a)**2+(n1/b)**2)
print 'Cut-off wavelength:',lamc10, 'cm'
lamc10=lamc10/100
f10=c/(lamc10*sqrt(x))
print 'Cutoff frequency:%0.3f'%(f10/1e9),'Ghz'
print 'TE20 mode'
m2=2
n2=0
lamc20=2/sqrt((m2/a)**2+(n2/b)**2)
print 'Cut-off wavelength:',lamc20, 'cm'
lamc20=lamc20/100
f20=c/(lamc20*sqrt(x))
print 'Cutoff frequency: %0.3f'%(f20/1e9),'Ghz'
print 'TE11 mode'
m3=1
n3=1
lamc11=2/sqrt((m3/a)**2+(n3/b)**2)
print 'Cut-off wavelength: %0.3f'%lamc11,'cm'
lamc11=lamc11/100
f11=c/(lamc11*sqrt(x))
print 'Cutoff frequency: %0.3f'%(f11/1e9), 'Ghz'
#(ii) lambg and Z0
f=4e9 #Hz
lam=c/f
lamg=lam/(sqrt(x-((lam/lamc10)**2)))
print 'Guide wavelength: %0.3f'%(lamg*100),'cm'
fc=3.33e9 #Hz
Z0=(120*pi*(1/sqrt(x))*(b/a))/sqrt(1-((fc/f)**2))
print 'Impedance: %0.3f'%round(Z0), 'ohm'
#Given,
c=3e8 #m/s
a=4 #cm
b=2 #cm
#(i) Mode
lamc=2*a #cm
lamcm=lamc/100 #m
fc=c/lamcm
#20% above fc
f=1.2*fc #Hz
#Operating wavelength
lam1=c/f #cm
#For TE10 mode
lamc10=2*b #cm
lamcm10=lamc10/100 #m
fc10=c/lamcm10
print 'Hence mode of operation is TE10','Since guide is operating at' ,fc/1e6,'MHz'
#(ii)Guide wavelength
lamm1=lam1*100 #cm
lamg=lamm1/(sqrt(1-(lamm1/lamc)**2))
print 'Guide wavelength:%0.3f'%lamg,'cm'
#(iii) Phase velocity
vp=f*lamg
print 'Phase velocity: %0.3f'%(vp/100),'m/s'
#(iii) Group velocity
vg=c**2/vp
print 'Group velocity: %0.3f'%vg, 'm/s'
#Given,
c=3e8 #m/s
a=7 #cm
b=3.5 #cm
f=3e9 #Hz
h0=10 #amp/m
#Wave impedance
lamc=2*a
lam=c/f #m
lam=lam*100 #cm
lamg=lam/sqrt(1-(lam/lamc)**2) #cm
z0=377*lamg/h0 #ohm
a1=a/100 #m
b1=b/100 #m
#Average power transmitted
p=(z0*h0*h0*a1*b1)/4
print 'Average power transmitted: %0.3f'%p, 'W'
#Peak electric field
e0=z0*h0
print 'Peak electric field: %0.3f'%(e0/1000),'kV/m'
#Answer for p is given as 28.3 W but it should be 32.99W
#Given,
c=3e8 #m/s
fc=3e9 #Hz
#Cutoff wavelength
lamc=c/fc
a=lamc/2 #m
a=a*100 #cm
print 'Dimensions:'
print 'a:' ,a,'cm'
b=a/2 #cm
print 'b:' ,b,'cm'
#Given,
c=3e8 #m/s
a=3 #cm
a1=a/100 #m
b=2 #cm
b1=b/100 #m
f=7.5e9 #HZ
p=5e3 #W
mu=pi*4e-7
w=2*pi*f
bet=sqrt(((w/c)**2)-((pi/a1)**2))
#Charecteristic impedance
z0=w*mu*2*b/(bet*a)
print 'Charecteristic impedance : %0.3f'%z0,'ohm'
#Peak electric field
e0=4*w*mu*p/(bet*a*b)
print 'Peak electric field: %0.3f'%e0,'V/m'
#Maximum voltage
v0=e0*b1
print 'Maximum voltage: %0.3f'%(v0/1000),'kV'
#Answer for v0 is given as 3.172 kV it should be 33.71 kV
#Given,
c=3e8 #m/s
a=1.5 #cm
a1=a/100 #m
b=0.8 #cm
b1=b/100 #m
mu=1/c*c
e=4
w=pi*1e11
n=377
#(i) Frequency of operation
f=w/(2*pi)
f1=f/1e9 #ghz
print 'Frequency of operation:' ,f1,'Ghz'
#(ii) Cutt off frequency
fc=(c*sqrt((1/a1)**2+(3/b1)**2))/(2*sqrt(e))
fc1=fc/1e9 #ghz
print 'Cut off frequency: %0.3f'%fc1,'Ghz'
#(iii) Phase constant
bet=(w*sqrt(e)*sqrt(1-(fc/f)**2))/(c)
print 'Phase constant: %0.3f'%bet,'rad/m'
#(iv) Propogation constant
gam=1J*bet
print 'Propogation constant: {:.3}'.format(gam),'rad/s'
#(v) Intrensic wave impedance
zte=(n/sqrt(e))/sqrt(1-(fc/f)**2)
ztm=(n/sqrt(e))*sqrt(1-(fc/f)**2)
print 'Intrinsic wave impedance:\n' ,'ZTM13 :%0.3f'%ztm,'Ohm','ZTE13 : %0.3f'%zte,'Ohm'
#Given
a=2 #cm
a1=1/100 #m
b=1 #cm
b1=b/100 #m
p=10e-3 #W
c=3e8 #m/s
f0=10e9 #Hz
#Peak value of electric field
fc=c/(2*a)
E02=(4*p*377)/(a1*b1*sqrt(1-(fc/f0)**2))
E0=sqrt(E02)
print 'Peak value of electric field: %0.3f'%E0, 'V/m'
#Maximum power transmitted
Ed=3e6 #V/m
Pt=2.6e13*(Ed/f0)**2
print 'Maximum power transmitted: %0.3f'%(Pt/1000), 'kW'
#Answer is given as 2300kW but it is 2340kW
from __future__ import division
import cmath
#Given
f=5e9 #Hz
c=3e8 #m/s
a=7.5 #cm
a1=a/100 #m
b=3.5 #cm
b1=b/100 #m
lam=c/f
lamm=lam*100 #m
print 'TE10 mode'
lamc10=2*a
bet10=(2*pi*sqrt(((lamc10/lamm)**2)-1))/lamc10
print 'Propogation constant: %0.3f'%bet10,'rad/cm'
vp10=(2*pi*f)/bet10
print 'Phase velocity: %0.3f'%(vp10/100),'m/s'
print 'TE01 mode'
lamc01=2*b
bet01=(2*pi*sqrt(((lamc01/lamm)**2)-1))/lamc01
print 'Propogation constant: %0.3f'%bet01, 'rad/cm'
vp01=(2*pi*f)/bet01
print 'Phase velocity: %0.3f'%(vp01/100), 'm/s'
print 'TE11 mode'
lamc11=(2*a*b)/sqrt((a*a)+(b*b))
bet11=(2*pi*sqrt(((lamc11/lamm)**2)-1))/lamc11
print 'Propogation constant: %0.3f'%bet11,'rad/cm'
vp11=(2*pi*f)/bet11
print 'Phase velocity: %0.3f'%(vp11/100), 'm/s'
print 'TE02 mode'
lamc02=b
bet02=(2*pi*cmath.sqrt(((lamc02/lamm)**2)-1))/lamc02
print 'Propogation constant: {:.3f}'.format(bet02), 'rad/cm'
print 'As beta is imaginary, mode gets attenuated'
alp=(2*pi*sqrt(1-((lamc02/lamm)**2)))/lamc02
print 'Propogation constant alpha: %0.3f'%alp, 'Np/m'
from math import log10 , exp
#Given
c=3e8 #m/s
a=2.29 #cm
b=1.02 #cm
a1=a/100 #m
b1=b/100 #m
f=6e9 #Hz
e=1
mu=1/(c**2)
#Cut off frequency
lamc=2*a1
fc=c/lamc
w=2*pi*fc
#Attenuation constant
a=(w*sqrt(1-((f/fc)**2)))/c
adb=-20*log10(exp(-a))
print 'Attenuation constant: %0.3f'%adb,'dB/m'
#Given,
a1=1.84
a2=pi
r=2*pi*(a1/a2)**2
print 'Cross section ratio: %0.3f'% r
#Given
c=3e8 #m/s
f=15e9 #hz
a=1.07 #cm
a1=a/100 #m
b=0.43 #cm
b1=b/100 #m
er=2.08
tandel=0.0004
lam=c/f
#(i) Cut off frequency
m1=1
n1=0
fc10=(c/(2*pi*sqrt(er))*sqrt((m1*pi/a1)**2+(n1*pi/b1)**2))
print 'Cut off frequency for mode TE10: %0.3f'%(fc10/10**9), 'GHz'
m2=2
n2=0
fc20=(c/(2*pi*sqrt(er))*sqrt((m2*pi/a1)**2+(n2*pi/b1)**2))
print 'Cut off frequency at mode TE20: %0.3f'%(fc20/10**9), 'Ghz'
m3=0
n3=1
fc01=(c/(2*pi*sqrt(er))*sqrt((m3*pi/a1)**2+(n3*pi/b1)**2))
print 'Cut off frequency at mode TE01: %0.3f'%(fc01/10**9),'Ghz'
#Dielectric attenuation constant
ad=(pi*tandel)/(lam*sqrt(1-(fc10/f)**2))
adb=-20*log10(exp(-ad))
print 'Attenuation constant: %0.3f'%adb,'dB/m'
#Given
c=3e8 #m/s
a=2.286 #cm
a1=a/100 #m
b=1.016 #cm
b1=b/100 #m
sig=5.8e7 #s/m
f=9.6e9 #Hz
w=2*pi*f
mu=pi*4e-7
et=377
lam=c/f
lamc=2*a1
r=lam/lamc
Rs=sqrt((w*mu)/(2*sig))
ac=(Rs*(1+(2*(b1/a1)*r*r)))/(et*b1*sqrt(1-(r**2)))
adb=-20*log10(exp(-ac))
print 'Conductor attenuation constant: %0.3f'%adb, 'dB/m'
#Given
c=3e8 #m/s
f=9e9 #hz
a=5 #cm
a1=a/100 #m
e=1
mu=1/(c*c)
p11=1.841
fc=(p11*c)/(2*pi*a1)
#Maximum power transmitted
pmax=1790*(a1*a1)*sqrt(1-((fc/f)**2))
print 'Maximum power transmitted:%0.3f'%pmax,'kW'
#Given
c=3e8 #m/s
a=5 #cm
a1=a/100 #m
f=3e9 #hz
p11=1.841
e=1
w=2*pi*f
#(i) Cut off frequency
fc=(p11*c)/(2*pi*a1)
print 'Cut off frequency: %0.3f'%(fc/10**9),'Ghz'
#(ii) Guide wavelength
bet=sqrt(((w*w)/(c*c))-((p11/a1)**2))
lamg=(2*pi)/bet
lamg1=lamg*100 #cm
print 'Guide wavelength: %0.3f'%lamg1, 'cm'
#(iii) Wave impedance
zte=(w*pi*4e-7)/bet
print 'Wave impedance:' ,round(zte),'ohm'
#Given
c=3e8 #m/s
p01=2.405
a=1/100 #cm
p11=1.841
fc01=((c*p01)/(2*pi*a))
fc11=((c*p11)/(2*pi*a))
bw=fc01-fc11
print 'Bandwidth: %0.3f'%(bw/10**9), 'Ghz'
#Given
c=3e8 #m/s
a=2.286 #cm
f=5e9 #Hz
er=2.25
tandel=1e-3
w=2*pi*f
mu=4e-7
sig=5.8e7 #s/m
lamc=2*a
lamm=c/f #m
lam=lamm*100 #cm
ermax=(lam/a)**2
print 'Maximum value of dielectric constant: %0.3f'%ermax
ermin=(lam/(2*a))**2
print 'Minimum value of dielectric constant: %0.3f'%ermin
#Guide wavelength
lam1=lam/sqrt(er) #cm
lamg=lam1/sqrt(1-(lam1/lamc)**2)
print 'Guide wavelength: %0.3f'%lamg, 'cm'
lamm1=lam1/100
ad=(pi/lamm1)*(tandel/sqrt(1-(lam1/lamc)**2))
print 'ad: %0.3f'%ad,'Np/m'
bet=2*pi/lamg
print 'Beta: %0.3f'%bet, 'rad/cm'
vp=w/(bet*100)
print 'Phase velocity: %0.3f'%vp, 'm/s'
#Given
c=3e8 #m/s
a=0.5 #cm
a1=a/100 #m
f=14e9 #Hz
er=2.08
p11=1.841
p01=2.405
tandel=4e-4
w=2*pi*f
u=pi*4e-7
sig=4.1e7
et=377
#(i) Cut off frequencies
fcte11=p11*c/(2*pi*a1*sqrt(er))
fctm01=p01*c/(2*pi*a1*sqrt(er))
print 'Cut off frequencies for TE11 mode: %0.3f'%(fcte11/10**9),'Ghz'
print 'Cut off frequencies for TM01 mode:%0.3f'%(fctm01/10**9), 'Ghz'
#(ii) Overall noise
#Dielectric attenuation
ad=(pi*sqrt(er)*tandel*f)/(c*sqrt(1-((fcte11/f)**2)))
print 'Dielectric attenuation: %0.3f'%(ad*8.686), 'dB/m'
#Conductor attenuation
k=(2*pi*f*sqrt(er))/c
bet=sqrt((k*k)-((p11/a1)**2))
#Surface resistance
rs=sqrt((w*u)/(2*sig))
kc2=(p11/a1)**2
ac=(rs*(kc2-((k**2)/((p11**2)-1))))/(a1*k*et*bet)
print 'Conductor attenuation: %0.3f'%(ac*8.686), 'dB/m'
#Total attenuation
a=(ac+ad)*8.686
print 'Total attenuation: %0.3f'%a,'dB/m'
ta=a*0.3
print 'Total attenuation in 30 cm line: %0.3f'%ta,'dB'
#Answer for condcutor attenuation is wrong in book, hence answer for total loss is different
#Given
c=3e8 #m/s
er=9
a=7 #cm
a1=a/100 #m
b=3.5 #cm
b1=b/100 #m
ur=1
f1=2e9 #Hz
#(i) Cut off frequency
lamc=2*a1
fc=c/(lamc*sqrt(ur*er))
print 'Cut off frequency:%0.3f'%(fc/10**9), 'Ghz'
#(ii) Phase velocity
lam=c/f1 #m
lam1=lam*100 #cm
lamc1=lamc*100 #cm
lamg=lam1/(sqrt((ur*er)-((lamc1/lam1)**2))) #cm
lamg1=lamg/100 #m
vp=f1*lamg1
print 'Phase velocity:%0.3f'%vp, 'm/s'
#/(iii)Guide wavelength
print 'Guide wavelength: %0.3f'%lamg, 'cm'
#Given
c=3e8 #m/s
fc=9e9 #Hz
er=1
er1=4
p11=1.841
#(i) air filled
a=(p11*c)/(2*pi*fc*sqrt(er))
print 'Inside diameter if air filled: %0.3f'%(a*100),'cm'
#(ii) dielectric field
a1=(p11*c)/(2*pi*fc*sqrt(er1))
print 'Inside diameter if dielectric filled: %0.3f'%(a1*100),'cm'
#Answers are calculated wrong in book
#Given
c=3e8 #m/s
er=2.55
d=1 #mm
d1=d/1000 #m
#Cut off frequencies
fctm0=0
print 'Cut off frequency for mode TM0:',fctm0, 'Ghz'
fcte1=c/(4*d1*sqrt(er-1))
print 'Cut off frequency at mode TE1: %0.3f'%(fcte1/10**9),'Ghz'
fctm1=c/(2*d1*sqrt(er-1))
print 'Cut off frequency at mode TM1: %0.3f'%(fctm1/10**9),'Ghz'
#Answers are calculated wrong in book
#Given,
c=3e8 #m/s
f=15e9 #hz
d=5 #mm
d1=d/1000 #m
#Cut off frequency
fc=0.8*f
#Dielctric constant
er=(c/(2*d1*fc))**2+1
print 'Dielectric constant:' ,er