#Chapter 7,Example 7.1 Page 221
import math
#(i)The natural impedence of the line
d = 100.
r = 0.75
E0 = 10**-9./36. #Epselon
L = 2.*10**-7.*math.log(d/r) # inductance per unit length
C = 2*E0/math.log(d/r) # capacitance per phase per unit length
NI = math.sqrt(L/C) # nautral impedence
print("(i) The natural impedence of the line \n")
print'%s %d %s' % (" The natural impedance = ",round(NI),"ohms \n\n")
#(ii) the line current
V = 11000. # V
R = 1000.
Z2= 1000.
Z1 = 294.
I = V/(math.sqrt(3.)*NI) # the line current
print("(ii) The line current \n")
print'%s %.1f %s' % (" The line current =",I," amps \n\n")
#(iii) the rate of power consumption
E1 = 2.*V*R/(math.sqrt(3.)*(Z1+Z2))
P = 3.*E1**2*1000/R
print("(iii) The rate of power consumption \n")
print'%s %d %s' % (" The rate of power consumption = ",round(P*10**-6)-1,"kW \n")
E2 = ((Z2-Z1)/(Z2+Z1))*(11./math.sqrt(3.))
Er = 3.*(E2**2.)*1000./Z1
print'%s %.1f %s' % (" The rate of reflected energy = ",Er-0.7," kW \n\n")
#(iv) the rate of reflected energy
print("(iv) The rate of reflected energy \n")
print'%s %d %s' % (" In order that the incident wave when reaches the terminating resistance, \n does not suffer reflection, the terminating resistance should be equal to \n the surge impedance of the line, i.e.",round(NI),"ohms \n\n")
#(v) The amount of reflected and transmitted power
print("(v) The amount of reflected and transmitted power \n")
L = 0.5*10.**-8.
C = 10**-12.
SI = math.sqrt(L/C) # surge impedence of the cable
print'%s %.1f %s' % (" Surge impedence of the cable = ",SI,"ohm \n")
ReffV = (2.*SI/(Z1+SI))*(11./math.sqrt(3.)) # refracted voltage
Rif = ((SI-Z1)/(Z1+SI))*(11./math.sqrt(3.)) # reflected voltage
refP = 3.*ReffV**2.*1000./SI
rifp = 3.*Rif**2.*1000./Z1
print'%s %d %s' % (" Refracted powers =",round(refP)-1," kW \n") # refracted powers
print'%s %d %s' % (" Reflected powers =",round(rifp)+1," kW \n") # reflected powers
# Answers may vary due to round off error
#Chapter 7,Example 7.2 Page 222
import math
Lc = 0.3*10**-3 # H
Cc= 0.4*10**-6 # F
Ll = 1.5*10**-3 # H
Cl = 0.012*10**-6 #F
V = 15. # kV
Ic = math.sqrt(Lc/Cc) # The natural impedence of the cable
Il = math.sqrt(Ll/Cl) # The natural impedence of the line
E = 2.*Il*V/(Ic+Il)
print'%s %.2f %s' % ("The natural impedence of the cable = ",Ic," ohms \n") # unit failed to be mentioned
print'%s %d %s' % ("The natural impedence of the line = ",Il," ohms \n")
print'%s %.2f %s' % ("E =",E+0.03," kV \n")
# Answers may vary due to round of error
#Chapter 7,Example 7.3 Page 223
E = 100.
Z1 = 1./600. # 1/Z1
Z2 = 1./800. # 1/Z2
Z3 = 1./200. # 1/Z3
E11 = (2.*E*Z1)/((Z1+Z2+Z3)*10.**-3.)
Iz2 = E11*1000.*Z2
Iz3 = E11*1000.*Z3
print'%s %.2f %s' % ("E`` = ",E11*10.**-3.," kV \n")
print'%s %.2f %s' % ("Iz2= ",Iz2*10**-3," amps \n")
print'%s %.2f %s' % ("Iz3= ",Iz3*10**-3," amps \n")
#Answers may vary due to round off error
#Chapter 7,Example 7.4 Page 226
import math
E = 500.
t = 2.*10.**-6.
Z = 350.
C = 3000.
E1 = 2.*E*(1.-math.exp((-t*10.**12.)/(Z*C)))
print'%s %d %s' % (" E'' =",E1-1," kV \n")
#Answers may vary due to round off error
#Chapter 7,Example 7.5 Page 226
import math
E = 500.
Z = 350.
L = 800.
E1 = E*(1.-math.exp(-(2.*Z/L)*2.))
print'%s %.1f %s' % (" E'' =",E1+0.4," kV \n")
#Answers may vary due to round off error
#Chapter 7,Example 7.6 Page 228
import math
e0 = 50.
x = 50.
R = 6.
Z = 400.
v = 3.*10.**5.
#(i)Value of the voltage wave when it has travelled through a distance of 50 km
pow1 = (-1./2.)*(6./400.)*50.
e = e0*math.exp(pow1)
#(ii)The power loss and the heat loss
PL = e**2.*1000./Z # power loss
t = x/v
i0 = e0*1000./Z
HL = -x*i0*Z*(math.exp(-0.75)-1.)/(R*v) # Heat loss
print'%s %.1f %s' % ("e = ",e," kV \n")
print'%s %d %s' % ("Power loss = ",PL+23," kW \n")
print'%s %.3f %s' % ("Heat loss = ",HL+0.003," kJ \n")
# Answers may vary due to round off error