from __future__ import division
from math import sqrt, pi
#Given
#a
L=1.2*10**-3#distributed inductance
C=0.05*10**-6#distributed capacitance
Zo=sqrt(L/C)#Characteristic Impedance
print 'The characteristic Impedance is Zo= %0.2f ohm'%(Zo)
Wo=1# Assumedfor ease of calculation
G=1J*sqrt(L*C)*Wo
print '\nPropagation constant is Gama={0:0.1f}+{1:0.2e}j W'.format(G.real,G.imag)
#b
#i
lamda=0.4e3#wavelength=Line length
c=3e8
f=c/lamda
#ii
L=L*0.4
C=C*0.4
v=1/(sqrt(L*C))
print '\n The freq at which the line length is equal to wavelength is: %d KHz\n The velocity of propagation is: %0.2f km/sec'%(f*1e-3,v*1e-3)
from math import cos, sin, tan,pi
#Given
v=3e8# velocty of light
f=1.2e6# Operating Freq
lamda=v/f
#print lamda)
l=100# length of the Tx-Line
phi=2*(pi*l)/(lamda)# Phase shift in degrees
Zo=500# Characteristic impedance
#a Open circuited Line
Zin=-1J*Zo*(cos(phi)/sin(phi))
#b Short circuited Line
Z1in=1J*Zo*tan(phi)
print 'The phase shift is: %d degrees'%(phi*180/pi)
print 'Open Circuited line impedance: {0:0.2f}'.format(-Zin.imag),'ohms'
print 'Short Circuited line impedance: {0:.2f}'.format(Z1in.imag),'ohms'
from __future__ import division
from cmath import exp,sqrt,log,atan,pi
#Given
f=1600
w=1000
Zoc=2460*exp(1J*-86.5*pi/180)# Open circuited Line impedance
Zsc=21.5*exp(1J*14*pi/180)# Short circuited Line impedance
Zo=sqrt(Zoc*Zsc)# Characteristic impedance
A=(sqrt(Zsc/Zoc)).real# tan(a+ jBeta) = A + jB
B=(sqrt(Zsc/Zoc)).imag
l=1/4
alpha=(1/(4*l))*log(((1+A**2+B)**2)/(((1-A)**2)+B**2)) #Attenuation Constant
Beta=(1/(2*l))*atan((2*B)/(1-A**2-B)) #phase constant
#the tx-Line parameters
R=(Zo*complex(alpha,Beta)).real
L=(Zo*complex(alpha,Beta)).imag
G=(complex(alpha,Beta)/Zo).real
C=(complex(alpha,Beta)/Zo).imag
print 'The Characteristic impedance:Zo= '
print Zo
print 'The value of Alpha={0:.3f} '.format(alpha.real),'nepere/km\n'
print 'The value of Beta= {0:0.3f}'.format(Beta.real)
print 'the tx-Line parameters are\nR= %0.2f ohms\nL= %0.2f mH\nG= %0.2f umhos\nC= %0.2f mF\n'%(R,L,G*1e6,C*1e3)
# Note : There are some calculation errors in the solution presented in the book
from __future__ import division
from math import sqrt,pi
#Given
d=0.7# distance between two insertions
Ld_m= (80e-3)*(10/7)#Loading coil inductance
#print Ld_m)
Rd_m=100/7#Loading coil resistance
#print Rd_m)
R=20+Rd_m#Line resistance
L=Ld_m# Line inductance
C=0.05e-6# Line Capacitance
alfa=0.5*R*sqrt(C/L)#Attenuation Constant
#
fc=(pi*d*sqrt(L*C))**-1#cut off freq
print 'The atenuation constant is %0.3f nepers/mile\nThe Cut-off Freq is %d KHz'%(alfa,fc*1e-3)
# Note : There are some calculation errors in the solution presented in the book
from cmath import exp,pi
#Given
a=0.7#attenuation constant
b=0.3#phase constant
Gamma=a+(1J*b)#propagation constant
l=0.5# half length of line( for midpoint)
Vs=10# Excitation voltage
V_mod=Vs*(exp(-a*l))#Magnitude of the Vs
phi=b*l*180/pi#phase shift
V=V_mod*(exp(-1J*(phi*pi/180)))#voltage at the mid point
print 'the voltage at the mid point of the line is \n {0:0.2f}+{0:.2f}j\n V with Angle = -%0.2fdegrees'.format(V.real,V.imag)%phi
# Note : There are some calculation errors in the solution presented in the book
from cmath import pi,sqrt,polar,phase,exp
#Given
R=0.01
l=1e3
L=1e-6
G=1e-6
C=0.001e-6
f=1.59e3# operating freq
w=2*pi*f# angular freq
#a
Zo=sqrt((R+(1J*w*L))*0.35/(G+(1J*w*C)))#characteristic impedance
Z0=polar(Zo)
Z0r=Z0[0]
Z0i=Z0[1]
#b
Beta=sqrt(0.5*(sqrt((((R**2)+(round(w**2)*(L**2)))*(round(G**2)+(round(w**2)*(C**2)))))-(round(R*G)-((w**2)*L*C))))#Phase constant
v=w/Beta#phase velocity
#c
Alpha=sqrt(0.5*(sqrt((((R**2)+((w**2)*(L**2)))*((G**2)+((w**2)*(C**2)))))+((R*G)-((w**2)*L*C))))#attenuation constant
Vs=1#Assumed for easeof calculation
A=(Vs-(Vs*exp(-Alpha*l)))*100
print 'The characteristic impedance Zo= %0.2f /_%0.2f ohm\n'%(Z0r,Z0i*180/pi)
print ' The Phase velocity is: v= %3.2e m/sec\n Percent decrease in the voltage is %0.2f%c'%(v.real,A.real,'%')
# Note : There are some calculation errors in the solution presented in the book
from cmath import cosh,polar,pi
#GivenR=0.01
x=10#line length
Zo=100# characteristic impedance
a=0.1# attenuation constant
Beta=0.05# phase constant
Is=20e-3# source current
Gamma=a+ 1J*Beta# propagation constant
I=Is/cosh(Gamma*x)# received current
Ii=polar(I)
I_r=Ii[0]
I_i=Ii[1]
print 'The current received is= %0.2f mA at phase%0.2f'%(1000*I_r,I_i*180/pi)
from cmath import exp,polar,cosh,sinh,pi
#Given
l=100# Tx-line length
ZR=200#Terminal resistance
Zo=600#Characteristic impedance
a=0.01#attenuation constant
Beta=0.03#phase constant
d=0#reflection coeff at load is Zero
Gamma=a+1J*Beta#propagation constant
Kd=((ZR-Zo)/(ZR+Zo))*exp(-2*Gamma*d)#reflection coeff at point D d km from load
Kdd=polar(Kd)
Kdr=Kdd[0]
Kdi=Kdd[1]
d1=100# distance
Ks=((ZR-Zo)/(ZR+Zo))*exp(-2*Gamma*d1)#reflection coeff at the sending end
[Ksr,Ksi]=polar(Ks)
Zin=Zo*(((ZR*cosh(Gamma*l))+(Zo*sinh(Gamma*l)))/((Zo*cosh(Gamma*l))+(ZR*sinh(Gamma*l))))#Input impedance
Zz=polar(Zin)
Zinr=Zz[0]
Zini=Zz[1]
print 'The input impedance is %0.2f /_%0.2fdeg\nReflection Coeff is %0.2f /_%0.2fdeg'%(Zinr,Zini*180/pi,Ksr,Ksi*180/pi)
# Note : There are some calculation errors in the solution presented in the book
from cmath import sqrt,polar,pi
#Given
L=1e-3#inductance
R=40# Resistance
C=0.1e-6# capacitance
G=1e-6#conductance
w=5000# angular freq
Zo=sqrt(complex(R,(w*L))/complex(G,(w*C)))#Characteristic impedance
#Zr=sqrt(sqrt(R**2+(w*L)**2)/sqrt(G**2+(w*C)**2))
Zz=polar(Zo)
ZoR=Zz[0]
ZoI=Zz[1]
print 'The characteristic impedance is %0.2f /_%0.2fdeg'%(ZoR,ZoI*180/pi)
# Note : There are some calculation errors in the solution presented in the book
from cmath import polar,exp
#Given
l=0.5#half line distance
Vs=10#Excitation voltage
Gamma=0.7+1J*0.3#propagation constant
Vv=polar(Vs*(exp(-Gamma*l)))#vtg at mid point
Vr=Vv[0]
Vi=Vv[1]
print 'The voltage at the mid point of the line is %0.2f /_%0.2f '%(Vr,Vi*180/pi)
from math import sqrt
#Given
Zo=50# characteristic impedance
P=500e-3#Supplied power
S=1.4#VSWR on the line
Emax=sqrt(Zo*S*P)#Max vtg
Emin=sqrt(Zo*P/S)# Min vtg
print 'The max voltage on line is %0.2f V\n The min voltage on line is %0.2f V'%(Emax,Emin)
from math import sqrt
#Given
Zo=100# Characteristic Impedance
P=100e-3#Load power
Zr=140#Load Resistance
f=100e3# Operating freq
#a
K=(Zr-Zo)/(Zo+Zr)#Vtg Reflection coeff
#b
S=(1+K)/(1-K)#VSWR
#c+d
Emax=sqrt(Zr*P)#Max line vltg
Imin=Emax/Zr#Min line current
Emin=Emax/S# Min line vltg
Imax=S*Imin#Max line current
#e
R=14000/40
Zr=(Zo**2)/R#
print '\nThe voltage reflection coeff is %0.2f\nThe VSWR is %0.2f\n\n\nThe Max and min voltage and crresponding crrent is\n Emax= %0.2fV Imin= %0.2fmA\n Emin= %0.2fV Imax= %0.2fmA\n\n The Termination resistance should be %0.2f ohm'%(K,S,Emax,Imin*1e3,Emin,Imax*1e3,Zr)
from math import exp,log
#Given
V=0.5#receiving vtg
Vs=2#Source vtg
al=-log(V/Vs)#attenuation
al2=al*1.5
V=Vs*exp(-al2)#receiving voltage
print 'the receiving voltage will be %0.2f V'%(V)
from cmath import sqrt
#Given
Zin=25+1J*15# Internal Impedance
Zr=70-1J*42#load
f=3e6#operating freq
v=3e8#light velocity
L=v/(4*f)#length of the line
Zo=sqrt(Zin*Zr)#Characteristic Impedance
print 'The lrngth should be %d metres\nThe Characteristic Impedance should be %0.2f ohms'%(L,Zo.real)
from math import sqrt,pi
from __future__ import division
#Given
#a
L=1e-3# inductance
C=61.25e-9#capacitance
Ld=44e-3#coil inductance
d=2#distance intervals after which coils are added
Lt=(L*2)+(Ld*2)#total inductance
Ct=C*2#total capacitance
fc=(pi*sqrt(Lt*Ct))**-1#cut off freq
#b
I=100e-3#milliameter range
R=1#milliameter resistance
Zo=100#characteristic impedance
Zin=(Zo**2)/R#input impedance
Er=I*R#
Es=Er*sqrt(Zin/Zo)
print 'The cut-off freq is %0.2f KHz \n the voltage being measured is %d V'%(fc*1e-3,Es)
from math import sqrt
#Given
f=20e6#tuned freq
ZR=100#Equivalent aerial Resistance
Zin=500#input impedance
c=3e8
lamda=c/f
l=lamda/4#lamda/4 Transformer
Zo=sqrt(Zin*ZR)#Characteristic impedance
print 'the Length of the transformer(stub) is %0.2f metres\n The characteristic impedance of this transformer is %d ohms'%(l,round(Zo))
from math import pi,cos,sin
#Given
lamda=5#wavelength
Zo=200#Characteristic impedance
Zo1=100#Zo'
ZL=50+(1J*50)# load impedance
l1=0.4*lamda
l2=0.2*lamda
Beta=(2*pi/lamda)# phase difference
Z2=Zo1*(((ZL*cos(Beta*l2))+(1J*Zo1*sin(Beta*l2)))/((Zo1*cos(Beta*l2))+(1J*ZL*sin(Beta*l2))))#I/p Impedance offered by I2toI1
Z1=Zo*(((Z2*cos(Beta*l1))+(1J*Zo*sin(Beta*l1)))/((Zo*cos(Beta*l1))+(1J*Z2*sin(Beta*l1))))#I/p impedance
print 'The sending end (Source end)impedance (Zl)is: '
print '{0:0.2f}+{1:0.2f}j'.format(Z1.real,Z1.imag)