#Variable declaration
V_A = 225.0 #Potential at point A(V)
R_A = 5.0 #Resistance of line A(ohm)
V_B = 210.0 #Potential at point B(V)
R_B = 1.0 #Resistance of line B(ohm)
V_C = 230.0 #Potential at point C(V)
R_C = 1.0 #Resistance of line C(ohm)
V_D = 230.0 #Potential at point D(V)
R_D = 2.0 #Resistance of line D(ohm)
V_E = 240.0 #Potential at point E(V)
R_E = 2.0 #Resistance of line E(ohm)
#Calculation
V_0 = ((V_A/R_A)+(V_B/R_B)+(V_C/R_C)+(V_D/R_D)+(V_E/R_E))/((1/R_A)+(1/R_B)+(1/R_C)+(1/R_D)+(1/R_E)) #Potential at point O(V)
I_A = (V_A-V_0)/R_A #Current leaving supply point A(A)
I_B = (V_B-V_0)/R_B #Current leaving supply point B(A)
I_C = (V_C-V_0)/R_C #Current leaving supply point C(A)
I_D = (V_D-V_0)/R_D #Current leaving supply point D(A)
I_E = (V_E-V_0)/R_E #Current leaving supply point E(A)
#Result
print('Potential of point O, V_0 = %.f V' %V_0)
print('Current leaving supply point A, I_A = %.f A' %I_A)
print('Current leaving supply point B, I_B = %.f A' %I_B)
print('Current leaving supply point C, I_C = %.f A' %I_C)
print('Current leaving supply point D, I_D = %.2f A' %I_D)
print('Current leaving supply point E, I_E = %.2f A' %I_E)
from sympy import Symbol,diff,solve
#Variable declaration
I = 600.0 #Constant current drawn(A)
V_A = 575.0 #Potential at point A(V)
V_B = 590.0 #Potential at point B(V)
R = 0.04 #Track resistance(ohm/km)
#Calculation
x = Symbol('x') #x(km)
I_A = (177.0-24*x)/0.32 #Simplifying
V_P = V_A-I_A*R*x #Potential at P in terms of x(V)
dVP_dx = diff(V_P,x) #dV_P/dx
x_sol = solve(dVP_dx,x) #Value of x(km)
I_A_1 = (177.0-24*x_sol[0])/0.32 #Current drawn from end A(A)
I_B = I-I_A_1 #Current drawn from end B(A)
#Result
print('Point of minimum potential along the track, x = %.2f km' %x_sol[0])
print('Current supplied by station A, I_A = %.f A' %I_A_1)
print('Current supplied by station B, I_B = %.f A' %I_B)
print('\nNOTE: ERROR: Calculation mistake in the textbook solution')
from sympy import Symbol,solve
#Variable declaration
l = 400.0 #Length of cable(m)
i = 1.0 #Load(A/m)
I_1 = 120.0 #Current at 40m from end A(A)
l_1 = 40.0 #Distance from end A(A)
I_2 = 72.0 #Current at 72m from end A(A)
l_2 = 120.0 #Distance from end A(A)
I_3 = 48.0 #Current at 200m from end A(A)
l_3 = 200.0 #Distance from end A(A)
I_4 = 120.0 #Current at 320m from end A(A)
l_4 = 320.0 #Distance from end A(A)
r = 0.15 #Cable resistance(ohm/km)
V_A = 250.0 #Voltage at end A(A)
V_B = 250.0 #Voltage at end A(A)
#Calculation
I = Symbol('I') #Current from end A(A)
A_A1 = l_1*r*(I-(1.0/2)*i*l_1) #Drop over length(V)
I_d_1 = 40.0 #Distributed tapped off current(A)
I_A1_A2 = I-l_1-l_2 #Current fed in over length(A)
A1_A2 = (l_2-l_1)*r*(I_A1_A2-(1.0/2)*i*(l_2-l_1)) #Drop over length(V)
I_d_2 = 80.0 #Distributed tapped off current(A)
I_A2_A3 = I_A1_A2-(I_2+I_d_2) #Current fed in over length(A)
A2_A3 = (l_3-l_2)*r*(I_A2_A3-(1.0/2)*i*(l_3-l_2)) #Drop over length(V)
I_d_3 = 80.0 #Distributed tapped off current(A)
I_A3_A4 = I_A2_A3-(I_3+I_d_3) #Current fed in over length(A)
A3_A4 = (l_4-l_3)*r*(I_A3_A4-(1.0/2)*i*(l_4-l_3)) #Drop over length(V)
I_d_4 = 120.0 #Distributed tapped off current(A)
I_A4_B = I_A3_A4-(I_4+I_d_4) #Current fed in over length(A)
A4_B = (l-l_4)*r*(I_A4_B-(1.0/2)*i*(l-l_4)) #Drop over length(V)
V_drop = A_A1+A1_A2+A2_A3+A3_A4+A4_B #Total voltage drop in terms of I
I_solved = solve(V_drop) #Current(A)
I = I_solved[0]
I_total = 760.0 #Total load current(A)
I_B = I_total-I #Current from B(A)
A_A3 = 2.0*r/1000*(l_1*(I-20)+(l_2-l_1)*(I-200)+(l_3-l_2)*(I-352)) #Potential drop over length A_A3(V)
V_A3 = V_A-A_A3 #Voltage at the lowest run lamp(V)
#Result
print('Position of lowest-run lamp, A_3 = %.f m' %l_3)
print('Voltage at the lowest-run lamp = %.1f V' %V_A3)
from sympy import Symbol,solve
#Variable declaration
l = 450.0 #Length of wire(m)
V_A = 250.0 #Voltage at end A(V)
V_B = 250.0 #Voltage at end A(V)
r = 0.05 #Conductor resistance(ohm/km)
i = 1.5 #Load(A/m)
I_C = 20.0 #Current at C(A)
l_C = 60.0 #Distance to C from A(m)
I_D = 40.0 #Current at D(A)
l_D = 100.0 #Distance to D from A(m)
l_E = 200.0 #Distance to E from A(m)
#Calculation
x = Symbol('x') #Current to point D from end A(A)
AD = (I_C+x)*r*l_C+x*r*(l_D-l_C) #Drop in length AD
BD = (i*r*V_A**2/2)+(I_D-x)*r*(450-l_D) #Drop in length BD
x_solve = solve(AD-BD) #Current(A)
x_sol = x_solve[0] #Current(A)
I_F = x_sol-I_D #Current supplied to load from end A(A)
l_F = l_E+(I_F/i) #Point of minimum potential at F from A(m)
V_F = V_B-(375.0-I_F)*(250-(l_F-200))*r/1000 #Potential at F from end B(V)
#Result
print('Point of minimum potential occurs at F from A = %.2f metres' %l_F)
print('Potential at point F = %.2f V' %V_F)
from sympy import Symbol,solve,diff
#Variable declaration
V_O = 240.0 #Voltage at point O(V)
V = 230.0 #Minimum potential(V)
rho_cu = 1.73*10**-6 #resistivity of copper(ohm-cm)
I_D = 40.0 #Current at D(A)
I_C = 30.0 #Current at C(A)
I_B = 20.0 #Current at B(A)
I_A = 400.0 #Current at A(A)
l_AD = 50.0 #Length between A & D(m)
l_DC = 100.0 #Length between D & C(m)
l_CB = 75.0 #Length between C & B(m)
l_BA = 35.0 #Length between B & A(m)
#Calculation
x = Symbol('x') #Current in section AD(A)
ADCBA = l_AD*x+l_DC*(x-I_D)+l_CB*(x-I_D-I_C)+l_BA*(x-I_D-I_C-I_B) #KVL around loop ADCBA
x_solve = solve(ADCBA) #Value of current in section AD(A)
x_sol = x_solve[0] #Current in section AD(A)
a_d = Symbol('a_d')
r = rho_cu*100*2/a_d #Resistance of ring distributor per metre(ohm)
V_AC = r*(x_sol*l_AD+l_DC*(x_sol-I_D)) #Voltage drop from A to C(V)
a_f = Symbol('a_f')
V_OA_drop = (I_D+I_C+I_B)*I_A*rho_cu*100*2/a_f #Drop in feeder OA(V)
V_diff = V_O-V
a_d = 1.09123076923077*a_f/(V_diff*a_f-12.456) #a_d in terms of a_f
volume = 260*a_d+400*a_f #Total volume of copper in both ring distributor & feeder
a_f_solve = solve(diff(volume,a_f)) #Value of a_f(cm^2)
a_f_sol = a_f_solve[1] #Desirable value of a_f(cm^2)
a_d_sol = 1.09123076923077*a_f_sol/(V_diff*a_f_sol-12.456) #a_d in terms of a_f
ratio = a_f_sol/a_d_sol #Ratio of a_f to a_d
#Result
print('Ratio, a_f/a_d = %.2f ' %ratio)
print('\nNOTE: ERROR: Calculation mistakes from finding total volume of copper in both ring distributor & feeder')
from sympy import Symbol,solve
#Variable declaration
l_AB = 100.0 #Length between A & B(m)
l_BC = 150.0 #Length between B & C(m)
l_CD = 200.0 #Length between C & D(m)
l_AD = 350.0 #Length between A & D(m)
l_AE = 200.0 #Length between A & E(m)
l_ED = 250.0 #Length between E & D(m)
I_B = 10.0 #Current at B(A)
I_C = 20.0 #Current at C(A)
I_D = 50.0 #Current at D(A)
I_E = 39.0 #Current at E(A)
#Calculation
x = Symbol('x') #Current in section AB(A)
ABCDEA = x*l_AB+(x-I_B)*l_BC+(x-I_B-I_C)*l_CD+(x-I_B-I_C-I_D)*l_ED+(x-I_B-I_C-I_D-I_E)*l_AE #KVL around loop ABCDEA
x_solve = solve(ABCDEA) #Solution for current in section AB(A)
x_sol = x_solve[0] #Value of current in section AB(A)
V_AD = x_sol*l_AB+(x_sol-I_B)*l_BC+(x_sol-I_B-I_C)*l_CD #Voltage drop from A to D in terms of ρ/a_1(V)
R_AD = (l_AB+l_BC+l_CD)*(l_AE+l_ED)/(l_AB+l_BC+l_CD+l_AE+l_ED) #Resistance of n/w across terminals AD in terms of ρ/a
I_AD = V_AD/(R_AD+l_AD) #Current in interconnector AD(A)
V_A_D = I_AD*l_AD #Voltage drop between A & D in terms of ρ/a_2
a2_a1 = V_A_D/V_AD
length_with = (l_AB+l_BC+l_CD+l_AE+l_ED+l_AD) #Length of conductor with interconnector(m)
length_without = (l_AB+l_BC+l_CD+l_AE+l_ED) #Length of conductor without interconnector(m)
volume_with = a2_a1*length_with/length_without #Weight of copper with interconnector
#Result
print('Ratio of weight of copper with & without interconnector = %.3f : 1 (or) 1 : %.2f' %(volume_with,1/volume_with))
from sympy import Symbol,solve
#Variable declaration
r_out = 0.05 #Resistance of each outer per 100 metre length(ohm)
r_neutral = 0.10 #Resistance of each neutral per 100 metre length(ohm)
V_A = 200.0 #Potential at point A(V)
V_B = 200.0 #Potential at point B(V)
l_AC = 100.0 #Length between A & C(m)
l_CD = 150.0 #Length between C & D(m)
l_DB = 200.0 #Length between D & B(m)
l_AF = 200.0 #Length between A & F(m)
l_FE = 100.0 #Length between F & E(m)
l_EB = 150.0 #Length between E & B(m)
I_C = 20.0 #Current at point C(A)
I_D = 30.0 #Current at point D(A)
I_F = 60.0 #Current at point F(A)
I_E = 40.0 #Current at point E(A)
#Calculation
x = Symbol('x') #Current in positive outer alone(A)
equ_1 = r_out*(l_DB*(I_D-x))-r_out*(l_AC*(I_C+x)+l_CD*x)
x_solve = solve(equ_1)
x_sol = x_solve[0] #Feasible solution of current(A)
y = Symbol('y') #Current in negative outer alone(A)
equ_2 = r_out*((I_E-y)*l_FE+(I_E+I_F-y)*l_AF)-r_out*(l_EB*y)
y_solve = solve(equ_2)
y_sol = y_solve[0] #Feasible solution of current(A)
I_pos_out = I_C+x_sol #Current entering positive outer(A)
I_neg_out = I_E+I_F-y_sol #Current returning via negative outer(A)
I_middle = I_neg_out-I_pos_out #Current in the middle wire towards G(A)
r_CD = r_out*l_CD/100.0 #Resistance between C & D(ohm)
r_D = r_out*l_DB/100.0 #Resistance between D & B(ohm)
r_IH = r_neutral*l_FE*0.5/100.0 #Resistance between I & H(ohm)
r_IJ = r_neutral*l_FE*0.5/100.0 #Resistance between I & J(ohm)
r_GH = r_neutral*l_AF*0.5/100.0 #Resistance between G & H(ohm)
r_AF = r_out*l_AF/100.0 #Resistance between A & F(ohm)
I_CD = x_sol #Current flowing into D from C(A)
I_out_D = I_D-x_sol #Current flowing into D from outer side(A)
I_GH = I_C+I_middle #Current flowing into H from G(A)
I_IH = I_F-I_GH #Current flowing into H from I(A)
I_BJ = I_E-(I_D-I_IH) #Current flowing into J from B(A)
I_FE = y_sol-I_E #Current flowing into E from F(A)
I_IJ = I_D-I_IH #Current flowing into J from I(A)
V_C = V_A-(I_pos_out*r_out-I_middle*r_neutral) #Potential at load point C(A)
V_D = V_C-(I_CD*r_CD+I_IH*r_IH-I_GH*r_GH) #Potential at load point D(A)
V_F = V_A-(I_middle*r_neutral+I_GH*r_neutral+I_neg_out*r_AF) #Potential at load point F(A)
V_E = V_F-(-I_IH*r_IH+I_IJ*r_IJ-I_FE*r_out) #Potential at load point E(A)
#Result
print('Potential difference at load point C = %.3f V' %V_C)
print('Potential difference at load point D = %.3f V' %V_D)
print('Potential difference at load point E = %.3f V' %V_E)
print('Potential difference at load point F = %.3f V' %V_F)
#Variable declaration
V = 440.0 #Voltage between outer(V)
I_pos = 210.0 #Ligting load current on positive side(A)
I_neg = 337.0 #Ligting load current on negative side(A)
I_power = 400.0 #Power load current(A)
P_loss = 1.5 #Loss in each balancer machine(kW)
#Calculation
P = I_power*V/1000.0 #Power(kW)
load_pos = I_pos*V*0.5/1000.0 #Load on positive side(kW)
load_neg = I_neg*V*0.5/1000.0 #Load on negative side(kW)
loss_total = 2*P_loss #Total loss on rotary balancer set(kW)
load_main = P+load_pos+load_neg+loss_total #Load on main machine(kW)
I = load_main*1000/V #Current(A)
I_M = I-610.0 #Current through balancer machine(A)
I_G = 127.0-I_M #Current through generator(A)
output_G = I_G*V*0.5/1000.0 #Output of generator(kW)
input_M = I_M*V*0.5/1000.0 #Input to balancer machine(kW)
#Result
print('Load on the main machine = %.2f kW' %load_main)
print('Output of generator = %.2f kW' %output_G)
print('Input to balancer machine = %.2f kW' %input_M)
import math
import cmath
#Variable declaration
V_a = 11.0*10**3 #Line voltage at A(V)
Z_AB = complex(1.0,0.8) #Impedance between A & B(ohm)
Z_AC = complex(3.0,2.0) #Impedance between A & C(ohm)
Z_BD = complex(3.0,4.0) #Impedance between B & D(ohm)
Z_CD = complex(1.0,0.7) #Impedance between C & D(ohm)
I_B = 60.0 #Current at B(A)
I_C = 30.0 #Current at C(A)
I_D = 50.0 #Current at D(A)
pf_B = 0.8 #Power factor at B
pf_C = 0.9 #Power factor at C
pf_D = 0.707 #Power factor at D
#Calculation
sin_phi_B = (1-pf_B**2)**0.5
I_B1 = I_B*(pf_B-1j*sin_phi_B) #Load current(A)
sin_phi_C = (1-pf_C**2)**0.5
I_C1 = I_C*(pf_C-1j*sin_phi_C) #Load current(A)
sin_phi_D = (1-pf_D**2)**0.5
I_D1 = I_D*(pf_D-1j*sin_phi_D) #Load current(A)
V_A = V_a/3**0.5 #Phase voltage at A(V)
I_AC = I_C1 #Current in section AC when C & D is removed(A)
I_BD = I_D1 #Current in section BD when C & D is removed(A)
I_AB = I_B1+I_D1 #Current in section AB when C & D is removed(A)
V_AC_drop = I_AC*Z_AC #Voltage drop at section AC(V)
V_AB_drop = I_AB*Z_AB #Voltage drop at section AB(V)
V_BD_drop = I_BD*Z_BD #Voltage drop at section BD(V)
V_drop_D = V_BD_drop+V_AB_drop #Total drop upto D(V)
pd_CD = V_drop_D-V_AC_drop #Potential difference between C & D(V)
Z_C_D = Z_AB+Z_BD+Z_AC #Impedance of network looking from terminal C & D(ohm)
I_CD = pd_CD/(Z_C_D+Z_CD) #Current flowing in section CD(A)
I_AC = I_CD+I_C1 #Current flowing in section AC(A)
I_BD = I_D1-I_CD #Current flowing in section BD(A)
I_AB = I_BD+I_B1 #Current flowing in section AB(A)
V_drop_AC = I_AC*Z_AC #Drop caused by current flowing in section AC(V/phase)
V_drop_AC_line = V_drop_AC*3**0.5 #Drop caused by current flowing in section AC(V)
V_C = V_a-V_drop_AC_line #Voltage at C(V)
#Result
print('Current in section CD, I_CD = (%.2f%.2fj) A' %(I_CD.real,I_CD.imag))
print('Current in section AC, I_AC = (%.2f%.2fj) A' %(I_AC.real,I_AC.imag))
print('Current in section BD, I_BD = (%.2f%.2fj) A' %(I_BD.real,I_BD.imag))
print('Current in section AB, I_AB = (%.2f%.2fj) A' %(I_AB.real,I_AB.imag))
print('Voltage at load point C = %.2f∠%.2f° kV' %(abs(V_C)/1000,cmath.phase(V_C)*180/math.pi))