import math
#calculation of characteristic impedance Z0 of the line
er=5.23 #relative dielectric constant of the board material
h=7 #height from microstrip line to the ground in mils
t=2.8 #thickness of the microstrip line in mils
w=10 #width of the microstrip line in mils
Z0=(87*(math.log((5.98*h)/(t+(0.8*w)))))/sqrt(er+1.41)
print"The characteristic impedance of the line(in ohms)is =",round(Z0,2),"ohms" #calculation mistake in book
import math
#(a) Calculate the required width w of the conducting strip in order to have a characteristic impedance of 50 ohms
erd=6 #relative dielectric constant of BeO
d=4*(10**-3) #thickness in meter
Z0=50 #characteristic impedance in ohms
w=(377*(d))/((sqrt(erd))*Z0)
print"The required width of the conducting strip(in metres)is =","{:.3e}".format(w),"m"
#(b) Calculate the strip line capacitance
ed=8.854*(10**-12)*erd
d=4*(10**-3) #thickness in meter
C=(ed*round(w,5))/d #strip line capacitance
C=C*(10**12) #multiply C by 10**12 for converting it in pF/m
print"The strip line capacitance(in pF/m)is =",round(C,1),"pF/m"
#(c) Calculate the strip line inductance
uc=4*math.pi*(10**-7) #permeability of the conductor
d=4*(10**-3) #thickness in meter
L=(uc*d)/w
L=L*(10**6) #converting L in micro H/m
print"The strip line inductance(in uH/m)is =",round(L,2),"micro H/m"
#(d)Calculate the phase velocity of the wave in the parallel strip line
c=3*(10**8) #speed of light in meter/second
vp=c/sqrt(erd)
print"The phase velocity of the wave in the parallel strip line(in m/s)is =","{:.2e}".format(vp),"m/s"
#Determine the characteristic impedance of the coplanar strip line
Pavg=250*(10**-3) #average power flowing in the positive z direction in watt
Io=100*(10**-3) #total peak current in ampere
Z0=(2*Pavg)/(Io**2)
print"The characteristic impedance of the coplanar strip line(in ohms)is =",int(round(Z0)),"ohms"
import math
#(a)Calculate the K factor
er=2.56 #dielectric constant of the insulator(polystyrene)
w=25.0 #strip width in mils
t=14.0 #strip thickness in mils
d=70 #shield depth in mils
K=1.0/(1-(t/d))
print"The K factor is =",K
#(b)Calculate the fringe capacitance
Cf=round(((8.854*er)*(round((2*K*math.log(K+1)),3)-round(((K-1)*math.log((K**2)-1)),2))),)/round(math.pi,2)
print"The fringe capacitance(in pF/m)is =",round(Cf,2),"pF/m"
#(c) Calculate the characteristic impedance of the line
Z0=94.15/((((w/d)*K)+(round(Cf,2)/(8.854*er)))*(sqrt(er)))
print"The characteristic impedance of the line(in ohms)is =",round(Z0,3),"ohms" #answer is wrong in book