import math
#Variable declaration
f = 50.0 #Frequency(Hz)
d = 4.0 #Spacing b/w conductors(m)
D = 2.0 #Distance of telephone line below conductor(m)
s = 60.0/100 #Spacing b/w telephone line(m)
r = 2.0 #Radius of power line(mm)
I = 150.0 #Current in power line(A)
#Calculation
D_ac = (D**2+((d-s)/2)**2)**0.5 #Distance b/w a & c(m)
D_ad = (D**2+(((d-s)/2)+s)**2)**0.5 #Distance b/w a & d(m)
M = 4.0*10**-7*math.log(D_ad/D_ac)*1000 #Mutual inductance b/w circuits(H/km)
V_CD = 2.0*math.pi*f*M*I #Voltage induced in the telephone line(V/km)
#Result
print('Mutual inductance between the circuits, M = %.e H/km' %M)
print('Voltage induced in the telephone line, V_CD = %.2f V/km' %V_CD)
import math
#Variable declaration
f = 50.0 #Frequency(Hz)
l = 160.0 #Length of line(km)
V = 132.0*10**3 #Line voltage(V)
P = 25.0*10**6 #Load delivered(W)
PF = 0.8 #Lagging power factor
r = 5.0/1000 #Radius of power line conductor(m)
d = 4.0 #Spacing b/w conductors(m)
OS = 6.0 #Distance(m)
OT = 6.5 #Distance(m)
CT = 18.0 #Distance(m)
#Calculation
AO = 3**0.5*d/2.0 #Distance A to O(m). From figure E6.2
AS = OS+AO #Distance A to S(m)
AT = AO+OT #Distance A to T(m)
OB = d/2.0 #Distance O to B(m)
BS = (OB**2+OS**2)**0.5 #Distance B to S(m)
BT = (OB**2+OT**2)**0.5 #Distance B to T(m)
M_A = 0.2*math.log(AT/AS) #Mutual inductance at A(mH/km)
M_B = 0.2*math.log(BT/BS) #Mutual inductance at B(mH/km)
M = M_B-M_A #Mutual inductance at C(mH/km)
I = P/(3**0.5*V*PF) #Current(A)
E_m = 2.0*math.pi*f*M*I*10**-3*l #Induced voltage(V)
V_A = V/3**0.5 #Phase voltage(V)
h = AO+CT #Height(m)
V_SA = V_A*math.log10(((2*h)-AS)/AS)/math.log10(((2*h)-r)/r) #Potential(V)
H = CT #Height(m)
V_B = V_A #Phase voltage(V)
V_SB = V_B*math.log10(((2*H)-BS)/BS)/math.log10(((2*H)-r)/r) #Potential(V)
V_S = V_SB-V_SA #Total potential of S w.r.t earth(V)
#Result
print('Induced voltage at fundamental frequency, E_m = %.1f V' %E_m)
print('Potential of telephone conductor S above earth, V_S = %.f V' %V_S)
print('\nNOTE: ERROR: Changes in obtained answer is due to precision and calculation mistakes in textbook')