#calculate Terminating impedance
#Variable declaration
Zo = 100 #o/p impedance(Ohms)
s = 5 #VSWR
#Calculations
Zmax = Zo*s
#Results
print "Terminating impedance = ",Zmax,"Ohms"
#calculate Characteristic impedance,Attenuation constant,Phase constant,Power delivered to the load
import math
import cmath
#Varaible declaration
R = 8 #resistance(Ohms)
L = 2*10**-3 #inductance(H/km)
C = 0.002*10**-6 #capacitance(F)
G = 0.07*10**-6 #conductance(s/km)
f = 2*10**3 #frequency(Hz)
Vs = 2 #input signal(V)
l = 500. #line length(km)
#Calculations
w = 2*math.pi*f
x = complex(R,w*L)
y = complex(G,w*C)
Zo = cmath.sqrt(x/y)
gamma = cmath.sqrt(x*y)
Is = Vs/Zo.real
Il = Is*cmath.exp(-1*gamma*l)
P = Il**2*Zo.real
#Results
print "Characteristic impedance =",Zo,"Ohms"
print "Attenuation constant =",round(gamma.real,6),"NP/km"
print "Phase constant =", round(gamma.imag,6),"rad/km"
print "\ncalculation error in the textbook"
print "\nPower delivered to the load =", round((abs(P)/1E-6),1), "uW"
#calculate Phase velocity
import math
#Varaible declaration
f = 2*10**3 #frequency(Hz)
B = 0.02543 #phase constant(rad/km)
#Calculations
w = 2*math.pi*f
Vp = w/B
#Results
print "Phase velocity =",round((Vp/1E+3),2),"km/sec"
#calculate Current drawn from generator,Power delivered to the load,Current flowing through the load
import cmath
import math
#Variable declaration
f = 37.5*10**6 #frequency(Hz)
V = 200 #Voltage signal(Vrms)
r = 200 #internal resistance(Ohms)
Zo = 200 #characteristic impedance(Ohms)
l = 10 #line length(m)
Zl = 100 #resistive load(Ohms)
c = 3*10**8 #velocity of propagation(m/s)
#Calculations
#Part a
lamda = c/f
Bl = (5*math.degrees(math.pi))/4
x = complex(Zl,(Zo*math.tan(Bl)))
y = complex(Zo,(Zl*math.tan(Bl)))
Zi = Zo*(x/y)
Vs = (Zi.real*Zo)/(Zi.real+Zo)
Is = Zo/(Zi.real+Zo)
#Part b
P = Vs*Is
#Part c
Il = math.sqrt(P/Zl)
#Results
print "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n"
print "Current drawn from generator is",round(Is,3),"A"
print "Power delivered to the load is",round(P,2),"W"
print "Current flowing through the load is",round(Il,3),"A"
#calculate Reflection co-efficient, VSWR
import cmath
import math
#Variable declaration
zo = 50 #characteristic impedance(Ohms)
f = 300*10**6 #frequency(Hz)
zl = complex(50,50) #terminating load(Ohms)
c = 3*10**8 #velocity of propagation(m/s)
#Calculations
lamda = c/f
rho = (zl-zo)/(zl+zo)
phi = cmath.phase(rho)
s = (1+abs(rho))/(1-abs(rho))
#Results
print "Reflection co-efficient =",round(abs(rho),4),"with phase =",round(math.degrees(phi),1)
print "VSWR =",round(s,2)
#calculate position of the stub,Length of stub
import math
#Variable declaration
Zl = 100. #load resistance(Ohms)
Zo = 600. #characteristic impedance(Ohms)
f = 100*10**6 #frequency(Hz)
c = 3*10**8 #velocity of propagation(m/s)
#Calculations
lamda = c/f
l = (lamda*math.atan(math.sqrt(Zl/Zo)))/(2*math.pi)
l_dash = (lamda*math.atan(math.sqrt((Zl*Zo)/(Zo-Zl))))/(2*math.pi)
#Results
print "The position of the stub is", round(l,3),"m\n"
print "Please note that the solution for l_dash given in the textbook is incorrect"
print "Length of stub is",round(l_dash,3),"m"
#calculate Terminating impedance
import cmath
import math
#Variable declaration
s = 3.2 #VSWR
Xmin = 0.237 #minimum voltage(V)
Zo = 50 #characteristic impedance(Ohms)
#Calculations
q = math.tan(math.degrees(2*math.pi*Xmin))
x = complex(1,-(s*q))
y = complex(s, -q)
Zl = Zo*(x/y)
#Result
print "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n"
print "Terminating impedance =", Zl,"Ohms"
#calculate VSWR,First Vmax is loacted at load and first Vmin is located at,Vmin,Impedance at Vmin
import math
#Variable declaration
Zo = 50. #characteristic impedance(Ohms)
Zl = 100. #load resistance(Ohms)
f = 300*10**3 #frequency(Hz)
Pl = 50*10**-3 #load power(W)
c = 3*10**8 #velocity of propagation(m/s)
#Calculations
lamda = c/f
#Part a
rho = (Zl-Zo)/(Zl+Zo)
s = (1+abs(rho))/(1-abs(rho))
#Part b
#Since real Zl>Zo, first Vmax is located at the load
Vmin_pos = lamda/4
#Part c
Vmax = math.sqrt(Pl*Zl)
Vmin = Vmax/s
#Part d
Zin_at_Vmin = Zo/s
Zin_at_Vmax = Zo*s
#Results
print "VSWR = ", s
print "First Vmax is loacted at load and first Vmin is located at=", Vmin_pos,"m from the load"
print "Vmax = ",round(Vmax,2),"V","\nVmin = ",round(Vmin,2),"V"
print "Impedance at Vmin is ", Zin_at_Vmin,"Ohm and impedance at Vmax is",Zin_at_Vmax,"Ohm"
#calculate Reflection loss, transmission loss, return loss
import math
#Variable declaration
Zo = 600. #characteristic impedance(Ohms)
Zs = 50 #source impedance(Ohms)
l = 200 #length of line(m)
Zl = 500. #load resistance(Ohms)
#Calculations
rho = (Zl-Zo)/(Zl+Zo)
#Part a
ref_l = math.log10(1/(1-((abs(rho))**2)))
#Part b
#Since, the line is lossless,
att_l = 0
trans_l = ref_l+att_l
#Part c
ret_l = math.log10(abs(rho))
#Results
print "Reflection loss =",round(ref_l,4),"dB"
print "Transmission loss =",round(trans_l,4),"dB"
print "Return loss =",round(ret_l,3),"dB (Calculation error in the textbook)"
#calculate Characteristic impedance,Phase velocity
import cmath
import math
#Variable declaration
l = 10 #length of line(km)
zsc = complex(1895.47,2234.29)
zoc = complex(216.99,-143.37)
f = 1*10**3 #frequency(Hz)
#Calculations
zo = cmath.sqrt(zsc*zoc)
x = cmath.sqrt(zsc/zoc)
t = (1+x)/(1-x)
gamma = cmath.log(t)/(l*2)
B = gamma.imag
w = 2*math.pi*f
Vp = w/B
#Results
print "There is calculation mistake throughout the problem in the textbook\n"
print "Characteristic impedance =",zo,"Ohms"
print "Phase velocity =",round((Vp/1E+3),3),"*10^3 m/sec"