#example 8.1
#calculation of surge impedance,velocity and time taken by the surge to travel to the other end
from math import sqrt
#given data
L=1.26*10**-3#inductance(in H/km)
C=0.009*10**-6#capacitance(in F/km)
l=400.#length(in km) of the transmission line
#calculation
v=1/sqrt(L*C)
Xs=sqrt(L/C)
t=l/v
#results
print 'The value of surge impedance is (ohm) = ',round(Xs,1)
print '%s %.1e %s' %('\nThe value of velocity is ',v,' km/s')
print '\nThe time taken by the surge to travel to the other end is (ms) = ',round(t*10**3,2)
#example 8.2
#calculation of the voltage build up at the junction
#given data
Z1=500.#surge impedance(in ohm) of transmission line
Z2=60.#surge impedance(in ohm) of cable
e=500.#value of surge(in kV)
#calculation
tau=(Z1-Z2)/(Z2+Z1)#coefficient of reflection
Vj=(1+tau)*e
#results
print 'The value of the voltage build up at the junction is (kV) = ',round(Vj)
#example 8.5
#calculation of the transmitted,reflected voltage and current waves
from math import sqrt
#given data
L1=0.189*10**-3#inductance(in H/km) of the cable
C1=0.3*10**-6#capacitance(in Farad/km) of the cable
L2=1.26*10**-3#inductance(in H/km) of the overhead line
C2=0.009*10**-6#capacitance(in Farad/km) of the overhead line
e=200.*10**3#surge volatge(in kV)
#calculation
Z1=sqrt(L1/C1)#surge impedance of the cable
Z2=sqrt(L2/C2)#surge impedance of the line
tau=(Z2-Z1)/(Z2+Z1)#when wave travels along the cable
edash=tau*e#reflected wave
edashdash=(1+tau)*e#transmitted wave
Idash=edash/Z1#reflected current wave
Idashdash=edashdash/Z2#transmitted current wave
Z2n=Z1
Z1n=Z2
taun=(Z2n-Z1n)/(Z2n+Z1n)#when wave travels along the line
edashn=taun*e#reflected wave
edashdashn=(1+taun)*e#transmitted wave
Idashdashn=edashdashn/Z2n#transmitted current wave
Idashn=edashn/Z1n#reflected current wave
#results
print 'When wave travels along the cable,the transmitted voltage is (kV) = ',round(edashdash*10**-3,2)
print '\nWhen wave travels along the cable,the reflected voltage is (kV) = ',round(edash*10**-3,2)
print '\nWhen wave travels along the cable,the transmitted current is (kA) = ',round(Idashdash*10**-3,3)
print '\nWhen wave travels along the cable,the reflected current is (kA) = ',round(Idash*10**-3,2)
print '\nWhen wave travels along the line,the transmitted voltage is (kV) = ',round(edashdashn*10**-3,2)
print '\nWhen wave travels along the line,the reflected voltage is (kV) = ',round(edashn*10**-3,2)
print '\nWhen wave travels along the line,the transmitted current is (kA) = ',round(Idashdashn*10**-3,3)
print '\nWhen wave travels along the line,the reflected current is ',round(abs(Idashn*10**-3),3),' kA or ',round(abs(Idashn)),'A'
#example 8.6
#calculation of value of voltage at the receiving end in Bewley lattice diagram
#given data
alpha=0.8
#calculation
Vut=2*alpha/(1+alpha**2)
#results
print 'The value of voltage at the receiving end in Bewley lattice diagram is ',round(Vut,4),'u(t) V'
#example 8.7
#calculation of sparkover voltage and the arrester current
#given data
Xs=400.#surge impedance(in ohm)
Xv=1000.#surge voltage(in kV)
#calculation
#for line terminated
Iam=2*Xv/Xs#maximum arrester current
#as Iam = 5 kA from graph Vd = 330 kV
Vd=330.#sparkover voltage(in kV)
Vso=Vd+(Vd*5./100)
#for continuous line
Iamn=Xv/Xs#maximum arrester current
#as Iamn = 2.5 kA from graph Vdn = 280 kV
Vdn=280#sparkover voltage(in kV)
Vson=Vdn+(Vdn*5./100)
#results
print 'The sparkover voltage for terminated line is (kV) = ',round(Vso)
print '\nThe arrester current for terminated line is (kA) = ',round(Iam)
print '\nThe sparkover voltage for continuous line is (kV) = ',round(Vson)
print '\nThe arrester current for continuous line is (kA) = ',round(Iamn,1)
#values of sparover voltages are
#for terminated line = 346 kV
#for continuous line = 294 kV
#example 8.8
#calculation of rise in voltage at the other end
from cmath import pi,sqrt,cos
#given data
R=0.1#resistance(in ohm/km)
L=1.26*10**-3#inductance(in H/km)
C=0.009*10**-6#capacitance(in F/km)
l=400#length(in km) of the line
V1=230#line voltage(in kV)
f=50#frequency(in Hz)
G=0
#calculation
#Neglecting resistance of line
V1p=V1/sqrt(3)
omega=2*pi*f
Xl=complex(0,omega*L*l)
Xc=complex(0,-1/(omega*C*l))
V2=V1p*((1-(Xl/(2*Xc)))-1)
#Considering all the parameters
omegaL=complex(0,omega*L)
omegaC=complex(0,omega*C)
i=l*sqrt((R+omegaL)*(G+omegaC))
betal=i.imag*l
V2n=V1p/cos(betal)
print 'Neglecting resistance of line,the rise in voltage at the other end is (kV) = ',round(V2.real,2)
print '\nConsidering all the parameters,the rise in voltage at the other end is (kV) = ',round(V2n.real-V1p.real,2)
#By considering all the parameters the rise in voltage at the other end is 94.50 kV
#example 8.9
#working out of insulation coordination
from math import sqrt
#given data
V=220.#voltage(in kV) of substation
BIL=1050.#value of BIL(in kV)
BtoS=1.24#ratio of BIL to SIL
#calculation
Vh=245.#highest voltage(in kV)
Vg=Vh*sqrt(2.)/sqrt(3)#highest system voltage
Vs=3*Vg#expected switching voltage(in kV)
Vfw=760.#impulse sparkover voltage(in kV)
Vd1=690.#discharge voltage(in kV) for 5 kA
Vd2=615.#discharge voltage(in kV) for 2 kA
#SIL = BIL/BtoS = 846 ~ 850 kV
SIL=850.#value of SIL(in kV)
Pmlig=(BIL-Vd1)/BIL#protective margin for lightning impulses
Pmswi=(SIL-Vd2)/SIL#protective margin for switching gears
Pmspr=(BIL-Vfw)/BIL#margin when lightning arrester just sparks
#results
print 'The protective margin for lightning impulses is (percentage) = ',round(Pmlig*100,1)
print '\nThe protective margin for switching gears is (percentage) = ',round(Pmswi*100,1)
print '\nThe margin when lightning arrester just sparks is (percentage) = ',round(Pmspr*100,1)