kv_gA = 11.0 #Voltage rating of generator A(kV)
MVA_gA = 40.0 #MVA rating of generator A
x_gA = 0.12 #Reactance of generator A(p.u)
kv_gB = 11.0 #Voltage rating of generator B(kV)
MVA_gB = 20.0 #MVA rating of generator B
x_gB = 0.08 #Reactance of generator B(p.u)
kv_Tlv = 11.0 #Low-voltage winding of transformer(kV)
kv_Thv = 66.0 #High-voltage winding of transformer(kV)
x_T = 0.10 #Reactance of Transformer(p.u)
kv_f = 66.0 #Feeder voltage(kV)
x_f = 30.0 #Reactance of feeder(ohm)
MVA_base = 75.0 #Base MVA
kv_base_lv = 11.0 #Base voltage on LT side(kV)
kv_base_hv = 66.0 #Base voltage on HT side(kV)
x_gA_new = x_gA*(MVA_base/MVA_gA) #New Reactance of generator A(p.u)
x_gB_new = x_gB*(MVA_base/MVA_gB) #New Reactance of generator B(p.u)
x_f_new = x_f*(MVA_base/kv_base_hv**2) #New reactance of feeder(p.u)
x_eq = x_T+(x_gA_new*x_gB_new/(x_gA_new+x_gB_new)) #Equivalent reactance(p.u)
V_f = kv_Thv/kv_base_hv #Fault voltage by applying Thevenin's Theorem at FF(p.u)
I_f = V_f/complex(0,x_eq) #Fault current(A)
I_f_ht = I_f*(MVA_base*1000/(3**0.5*kv_base_hv)) #Fault current on HT side(A)
I_f_lt = I_f_ht*kv_base_hv/kv_base_lv #Fault current on LT side(A)
MVA_fault = V_f*MVA_base/x_eq #Fault MVA
I_A = I_f*x_gB_new/(x_gA_new+x_gB_new) #Current in generator A(p.u)
I_A1 = I_A*MVA_base*1000/(3**0.5*kv_base_lv) #Current in generator A(A)
I_B = I_f*x_gA_new/(x_gA_new+x_gB_new) #Current in generator B(p.u)
I_B1 = I_B*MVA_base*1000/(3**0.5*kv_base_lv) #Current in generator B(A)
x_eq2 = x_f_new+x_T+(x_gA_new*x_gB_new/(x_gA_new+x_gB_new)) #Equivalent reactance(p.u)
I_f2 = V_f/complex(0,x_eq2) #Fault current(p.u)
I_f_ht2 = I_f2*(MVA_base*1000/(3**0.5*kv_base_hv)) #Fault current on HT side(A)
MVA_fault2 = V_f*MVA_base/x_eq2 #Fault MVA
I_A_pu = I_f2*x_gB_new/(x_gA_new+x_gB_new) #Current in generator A(p.u)
I_A2 = I_A_pu*MVA_base*1000/(3**0.5*kv_base_lv) #Current in generator A(A)
I_B_pu = I_f2*x_gA_new/(x_gA_new+x_gB_new) #Current in generator B(p.u)
I_B2 = I_B_pu*MVA_base*1000/(3**0.5*kv_base_lv) #Current in generator B(A)
print('Case(a) :')
print('Fault MVA for symmetric fault at the high voltage terminals of transformer = %.2f MVA' %MVA_fault)
print('Fault current shared by generator A , I_A = %.2fj A' %(I_A1.imag))
print('Fault current shared by generator B , I_B = %.2fj A' %(I_B1.imag))
print('\nCase(b) :')
print('Fault MVA for symmetric fault at the load end of the feeder = %.2f MVA' %MVA_fault2)
print('Fault current shared by generator A , I_A = %.2fj A' %(I_A2.imag))
print('Fault current shared by generator B , I_B = %.2fj A' %(I_B2.imag))
MVA_base = 100.0 #Base MVA
x1 = 0.15 #Reactance b/w F & B(p.u) . (Refer textbook diagram for marking)
x2 = 0.1 #Reactance b/w F & B(p.u)
x3 = 0.18 #Reactance b/w B & C(p.u)
x4 = 0.1 #Reactance b/w B & F(p.u)
x5 = 0.05 #Reactance b/w F & C(p.u)
x6 = 0.05 #Reactance b/w F & C(p.u)
x7 = 0.1 #Reactance b/w C & F(p.u)
x8 = 0.12 #Reactance b/w C & F(p.u)
V_f = 1.0 #Fault voltage by applying Thevenin's Theorem at FF(p.u)
x1_eq = x1+x2
x2_eq = x7+x8
x3_eq = x5*x6/(x5+x6)
x4_eq = x3*x4/(x3+x4+x3_eq)
x5_eq = x4*x3_eq/(x3+x4+x3_eq)
x6_eq = x3*x3_eq/(x3+x4+x3_eq)
x7_eq = (x1_eq+x4_eq)*(x2_eq+x6_eq)/(x1_eq+x4_eq+x2_eq+x6_eq)
X_eq = x7_eq+x5_eq #Equivalent reactance
MVA_SC = V_f*MVA_base/X_eq #Short circuit MVA at A
print('Rating of the circuit breaker at the location A = %.1f MVA' %MVA_SC)
print('\nNOTE : ERROR : Delta to star reactance conversion mistake in textbook')
x = 1.2 #Reactance of interconnector(ohm per phase)
kv = 33.0 #Voltage of bus-bars(kV)
SC_MVA1 = 3000.0 #Short-circuit MVA at bus-bar of first station(MVA)
SC_MVA2 = 2000.0 #Short-circuit MVA at bus-bar of second station(MVA)
MVA_base = 3000.0 #Base MVA
kv_base = 33.0 #Base kV
x_c = x*(MVA_base/kv_base**2) #Cable reactance(p.u)
x1 = MVA_base/SC_MVA1 #Reactance b/w e.m.f source & bus-bars for station 1(p.u)
x2 = MVA_base/SC_MVA2 #Reactance b/w e.m.f source & bus-bars for station 2(p.u)
V_f = 1.0 #Fault voltage by applying Thevenin's Theorem at FF(p.u)
X_eq1 = x1*(x_c+x2)/(x1+x_c+x2) #Thevenin reactance for short-circuit at bus bars at station 1(p.u)
SC_MVA1_poss = V_f*MVA_base/X_eq1 #Possible short-circuit at station 1(MVA)
X_eq2 = x2*(x_c+x1)/(x1+x_c+x2) #Thevenin reactance for short-circuit at bus bars at station 2(p.u)
SC_MVA2_poss = V_f*MVA_base/X_eq2 #Possible short-circuit at station 2(MVA)
print('Possible short-circuit MVA at station 1 = %.2f MVA' %SC_MVA1_poss)
print('Possible short-circuit MVA at station 2 = %.2f MVA' %SC_MVA2_poss)
MVA_G1 = 20.0 #MVA rating of generator 1(MVA)
kv_G1 = 13.2 #Voltage rating of generator 1(kV)
x_G1 = 0.14 #Reactance of generator 1(p.u)
MVA_T1 = 20.0 #MVA rating of transformer 1(MVA)
kv_T1_lv = 13.2 #L.V voltage rating of transformer 1(kV)
kv_T1_hv = 132.0 #H.V voltage rating of transformer 1(kV)
x_T1 = 0.08 #Reactance of transformer 1(p.u)
MVA_G2 = 30.0 #MVA rating of generator 2(MVA)
kv_G2 = 13.2 #Voltage rating of generator 2(kV)
x_G2 = 0.16 #Reactance of generator 2(p.u)
MVA_T2 = 30.0 #MVA rating of transformer 2(MVA)
kv_T2_lv = 13.2 #L.V voltage rating of transformer 2(kV)
kv_T2_hv = 132.0 #H.V voltage rating of transformer 2(kV)
x_T2 = 0.12 #Reactance of transformer 2(p.u)
x_L = 75.0 #Line reactance(ohm)
MVA_base = 45.0 #Base MVA
kv_lv_base = 13.2 #L.T base voltage(kV)
kv_hv_base = 132.0 #H.T base voltage(kV)
I_lt_base = MVA_base*1000/(3**0.5*kv_lv_base) #Base current on LT side(A)
x_G1_new = x_G1*(MVA_base/MVA_G1) #New reactance of generator 1(p.u)
x_G2_new = x_G2*(MVA_base/MVA_G2) #New reactance of generator 2(p.u)
x_T1_new = x_T1*(MVA_base/MVA_T1) #New reactance of transformer 1(p.u)
x_T2_new = x_T2*(MVA_base/MVA_T2) #New reactance of transformer 2(p.u)
x_L_new = x_L*(MVA_base/kv_hv_base**2) #New line reactance(p.u)
V_f = 1.0 #Pre-fault voltage at fault point FF(p.u)
x_T = (x_L_new/2)+((x_G1_new+x_T1_new)*(x_G2_new+x_T2_new)/(x_G1_new+x_T1_new+x_G2_new+x_T2_new)) #Thevenin reactance(p.u)
I_f = V_f/complex(0,x_T) #Fault current(A)
I_G1 = I_f*(x_G2_new+x_T2_new)/(x_G1_new+x_T1_new+x_G2_new+x_T2_new) #Fault current shared by generator 1(p.u)
I_f_G1 = I_G1*I_lt_base #Fault current shared by generator 1(A)
I_G2 = I_f*(x_G1_new+x_T1_new)/(x_G1_new+x_T1_new+x_G2_new+x_T2_new) #Fault current shared by generator 2(p.u)
I_f_G2 = I_G2*I_lt_base #Fault current shared by generator 2(A)
print('Fault current fed by generator 1 = %.1fj A' %I_f_G1.imag)
print('Fault current fed by generator 2 = %.1fj A' %I_f_G2.imag)
print('\nNOTE : ERROR : MVA ratings of G2 & T2 are 30 MVA , not 25 MVA as in textbook question')
MVA_base = 20.0 #Base MVA
V_f = 1.0 #Pre-fault voltage at bus 1(p.u).(Refer textbook diagram for marking.After circuit simplification)
x1 = 0.049 #Reactance(p.u)
x2 = 0.064 #Reactance(p.u)
x3 = 0.04 #Reactance(p.u)
x_eq = (x1+x2)*x3/(x1+x2+x3) #Equivalent reactance(p.u)
MVA_fault = V_f*MVA_base/x_eq #Fault MVA
print('SCC of bus 1 = %.f MVA' %MVA_fault)
print('\nNOTE : Changes in answer is due to more decimal places')
x_G1 = 0.15 #Sub-transient reactance of generator 1(p.u)
x_G2 = 0.15 #Sub-transient reactance of generator 2(p.u)
x_T1 = 0.12 #Leakage reactance of transformer 1(p.u)
x_T2 = 0.12 #Leakage reactance of transformer 2(p.u)
x_s = 0.2 #Reactance of tie line(p.u)
load = complex(1.5,0.5) #Load(p.u)
S_12 = complex(0.75,0.25) #Load at tie line(p.u)
V1 = 1.0 #Pre-fault voltage at bus 1(p.u)
import cmath
V_f = 1.0 #Voltage at FF(p.u)
Y_s = 1/complex(0,x_s) #Series admittance of line(p.u)
V2 = (1-(S_12/Y_s.conjugate())).conjugate() #Voltage at bus 2(p.u)
Z_L = (abs(V2)**2/load).conjugate() #Load at bus 2(p.u)
I_s = (V1-V2)*Y_s #Current through tie line(p.u)
I1 = I_s #Current through G1 & T1(p.u)
I_L = V2/Z_L #Load current(p.u)
I2 = I_L - I_s #Pre-fault current from generator 2(p.u)
x_eq = (x_G1+x_T1)*(x_G2+x_T2+x_s)/(x_G1+x_T1+x_G2+x_T2+x_s) #Equivalent reactance of n/w(p.u)
I_f = 1/complex(0,x_eq) #Fault current(p.u)
I_f1 = I_f*(x_G2+x_T2+x_s)/(x_G1+x_T1+x_G2+x_T2+x_s) #Fault current through G1,T1 towards F(p.u)
I_f2 = I_f*(x_G1+x_T1)/(x_G1+x_T1+x_G2+x_T2+x_s) #Fault current through G2,T2 & tie-line towards F(p.u)
V_1f = 0 #Post-fault voltage at bus 1(p.u)
V_2f = V_1f+(I_f2-I_s)*complex(0,x_s) #Post-fault voltage at bus 2(p.u)
SCC = V_f/x_eq #Fault MVA or SCC
print('Case(a) :')
print('SCC of bus 1 = %.2f p.u' %SCC)
print('\nCase(b) :')
print('Total post-fault ac current shared by generator 1 , I_f1 = %.2fj p.u' %I_f1.imag)
print('Total post-fault ac current shared by generator 2 , I_f2 = %.2fj p.u' %I_f2.imag)
print('\nCase(c) :')
print('Post-fault voltage of bus 2 , V_2f = %.3f∠%.2f° p.u' %(abs(V_2f),cmath.phase(V_2f)*180/cmath.pi))
import cmath
I_a = 10.0*cmath.exp(1j*90*cmath.pi/180) #Line current(A)
I_b = 10.0*cmath.exp(1j*-90*cmath.pi/180) #Line current(A)
I_c = 10.0*cmath.exp(1j*0*cmath.pi/180) #Line current(A)
a = 1.0*cmath.exp(1j*120*cmath.pi/180) #Operator
I_a0 = 1.0/3*(I_a+I_b+I_c) #Zero-sequence component(A)
I_a1 = 1.0/3*(I_a+a*I_b+a**2*I_c) #Positive-sequence component(A)
I_a2 = 1.0/3*(I_a+a**2*I_b+a*I_c) #Negative-sequence component(A)
print('Zero-sequence component , I_a0 = %.2f∠%.f° A' %(abs(I_a0),cmath.phase(I_a0)*180/cmath.pi))
print('Positive-sequence component , I_a1 = %.3f∠%.f° A' %(abs(I_a1),cmath.phase(I_a1)*180/cmath.pi))
print('Negative-sequence component , I_a2 = %.1f∠%.f° A' %(abs(I_a2),cmath.phase(I_a2)*180/cmath.pi))
kv = 13.2 #Voltage rating of generator(kV)
MVA = 25.0 #MVA rating of generator
MVA_sc = 170.0 #Short circuit MVA
x0 = 0.05 #Zero sequence reactance(p.u)
x2 = 0.13 #Negative sequence reactance(p.u)
import math
import cmath
MVA_base = 25.0 #Base MVA
kv_base = 13.2 #Line-to-line Base voltage(kV)
I_base = MVA_base*1000/(3**0.5*kv_base) #Base current(A)
x1 = MVA_base/MVA_sc #Positive sequence reactance(p.u)
V_f = 1.0 #Pre-fault terminal voltage(p.u)
Z_f = 0 #Fault impedance
a = 1.0*cmath.exp(1j*120*cmath.pi/180) #Operator
I_a1 = V_f/complex(0,(x0+x1+x2)) #Positive sequence current(p.u)
I_a2 = I_a1 #Negative sequence current(p.u)
I_a0 = I_a1 #Zero sequence current(p.u)
I_a = 3*I_a1*I_base #Fault current at phase a(A)
I_b = 0 #Fault current at phase b(A)
I_c = 0 #Fault current at phase c(A)
V_a1 = V_f - I_a1*complex(0,x1) #Terminal voltage(p.u)
V_a2 = -I_a2*complex(0,x2) #Terminal voltage(p.u)
V_a0 = -I_a0*complex(0,x0) #Terminal voltage(p.u)
V_a = (V_a0+V_a1+V_a2)*kv_base/3**0.5 #Line-to-neutral voltage at terminal(kV)
V_b = (V_a0+a**2*V_a1+a*V_a2)*kv_base/3**0.5 #Line-to-neutral voltage at terminal(kV)
V_c = (V_a0+a*V_a1+a**2*V_a2)*kv_base/3**0.5 #Line-to-neutral voltage at terminal(kV)
V_ab = (V_a-V_b) #Line voltages at terminal(kV)
V_bc = (V_b-V_c) #Line voltages at terminal(kV)
V_ca = (V_c-V_a) #Line voltages at terminal(kV)
I_a12 = V_f/complex(0,(x1+x2)) #Positive sequence current(p.u)
I_a22 = -I_a12 #Negative sequence current(p.u)
I_a02 = 0 #Zero sequence current(p.u)
I_a_2 = (I_a12+I_a22+I_a02)*I_base #Fault current at phase a(A)
I_b_2 = (a**2*I_a12+a*I_a22+I_a02)*I_base #Fault current at phase b(A)
I_c_2 = -I_b_2 #Fault current at phase c(A)
V_a12 = V_f - I_a12*complex(0,x1) #Terminal voltage(p.u)
V_a22 = V_a12 #Terminal voltage(p.u)
V_a02 = 0 #Terminal voltage(p.u)
V_a_2 = (V_a02+V_a12+V_a22)*kv_base/3**0.5 #Line-to-neutral voltage at terminal(kV)
V_b_2 = (V_a02+a**2*V_a12+a*V_a22)*kv_base/3**0.5 #Line-to-neutral voltage at terminal(kV)
V_c_2 = (V_a02+a*V_a12+a**2*V_a22)*kv_base/3**0.5 #Line-to-neutral voltage at terminal(kV)
V_ab2 = (V_a_2-V_b_2) #Line voltages at terminal(kV)
V_bc2 = (V_b_2-V_c_2) #Line voltages at terminal(kV)
V_ca2 = (V_c_2-V_a_2) #Line voltages at terminal(kV)
I_a13 = V_f/complex(0,(x1+(x0*x2/(x0+x2)))) #Positive sequence current(p.u)
I_a23 = -I_a13*x0/(x0+x2) #Negative sequence current(p.u)
I_a03 = -I_a13*x2/(x0+x2) #Zero sequence current(p.u)
I_a_3 = (I_a13+I_a23+I_a03)*I_base #Fault current at phase a(A)
I_b_3 = (I_a03+a**2*I_a13+a*I_a23)*I_base #Fault current at phase b(A)
I_c_3 = (I_a03+a*I_a13+a**2*I_a23)*I_base #Fault current at phase c(A)
V_a13 = V_f-I_a13*complex(0,x1) #Terminal voltage(p.u)
V_a23 = V_a13 #Terminal voltage(p.u)
V_a03 = V_a13 #Terminal voltage(p.u)
V_a3 = (V_a03+V_a13+V_a23)*kv_base/3**0.5 #Line-to-neutral voltage at terminal(kV)
V_b3 = (V_a03+a**2*V_a13+a*V_a23)*kv_base/3**0.5 #Line-to-neutral voltage at terminal(kV)
V_c3 = (V_a03+a*V_a13+a**2*V_a23)*kv_base/3**0.5 #Line-to-neutral voltage at terminal(kV)
V_ab3 = (V_a3-V_b3) #Line voltages at terminal(kV)
V_bc3 = (V_b3-V_c3) #Line voltages at terminal(kV)
V_ca3 = (V_c3-V_a3) #Line voltages at terminal(kV)
print('Case(i) : L-G fault :')
print('Short circuit current , I_a = %.1fj A = %.1f∠%.f° A' %(I_a.imag,abs(I_a),cmath.phase(I_a)*180/math.pi))
print('Short circuit current , I_b = %.f∠%.f° A' %(abs(I_b),cmath.phase(I_b)*180/math.pi))
print('Short circuit current , I_c = %.f∠%.f° A' %(abs(I_c),cmath.phase(I_c)*180/math.pi))
print('Terminal line voltage , V_ab = %.2f∠%.2f° kV' %(abs(V_ab),cmath.phase(V_ab)*180/math.pi))
print('Terminal line voltage , V_bc = %.2f∠%.2f° kV' %(abs(V_bc),cmath.phase(V_bc)*180/math.pi))
print('Terminal line voltage , V_ca = %.2f∠%.2f° kV' %(abs(V_ca),cmath.phase(V_ca)*180/math.pi))
print('\nCase(ii) : L-L fault :')
print('Short circuit current , I_a = %.f∠%.f° A' %(abs(I_a_2),cmath.phase(I_a_2)*180/math.pi))
print('Short circuit current , I_b = %.2f∠%.1f° A' %(abs(I_b_2),cmath.phase(I_b_2)*180/math.pi))
print('Short circuit current , I_c = %.2f∠%.1f° A' %(abs(I_c_2),cmath.phase(I_c_2)*180/math.pi))
print('Terminal line voltage , V_ab = %.3f∠%.1f° kV' %(abs(V_ab2),cmath.phase(V_ab2)*180/math.pi))
print('Terminal line voltage , V_bc = %.f∠%.1f° kV' %(abs(V_bc2),cmath.phase(V_bc2)*180/math.pi))
print('Terminal line voltage , V_ca = %.3f∠%.1f° kV' %(abs(V_ca2),cmath.phase(V_ca2)*180/math.pi))
print('\nCase(iii) : L-L-G fault :')
print('Short circuit current , I_a = %.f∠%.f° A' %(abs(I_a_3),cmath.phase(I_a_3)*180/math.pi))
print('Short circuit current , I_b = %.2f∠%.1f° A' %(abs(I_b_3),cmath.phase(I_b_3)*180/math.pi))
print('Short circuit current , I_c = %.2f∠%.1f° A' %(abs(I_c_3),cmath.phase(I_c_3)*180/math.pi))
print('Terminal line voltage , V_ab = %.3f∠%.f° kV' %(abs(V_ab3),cmath.phase(V_ab3)*180/math.pi))
print('Terminal line voltage , V_bc = %.f∠%.f° kV' %(abs(V_bc3),cmath.phase(V_bc3)*180/math.pi))
print('Terminal line voltage , V_ca = %.3f∠%.f° kV' %(abs(V_ca3),cmath.phase(V_ca3)*180/math.pi))
print('\nNOTE : Changes in answer is due to more decimal places')
x0 = 0.05 #Zero sequence reactance(p.u)
x2 = 0.13 #Negative sequence reactance(p.u)
r = 1.0 #Resistance through which generator neutral is earthed(ohm)
MVA_sc = 170.0 #Short circuit MVA
import math
import cmath
MVA_base = 25.0 #Base MVA
kv_base = 13.2 #Line-to-line Base voltage(kV)
I_base = MVA_base*1000/(3**0.5*kv_base) #Base current(A)
kv_base1 = 11.0 #Base kV
Z_n = r*MVA_base/kv_base1**2 #Neutral impedance(p.u)
V_f = 1.0 #Pre-fault terminal voltage(p.u)
x1 = MVA_base/MVA_sc #Positive sequence reactance(p.u)
I_a1 = V_f/complex(3*Z_n,(x1+x2+x0)) #Positive sequence current(p.u)
I_a0 = I_a1 #Zero sequence current(p.u)
I_a2 = I_a1 #Negative sequence current(p.u)
I_a = 3*I_a1*I_base #Fault current(A)
V_n = 3*I_a0*Z_n*I_base #Potential of neutral(V)
print('Fault current for a L-G short-circuit at its terminals , I_a = %.2f∠%.2f° A' %(abs(I_a),cmath.phase(I_a)*180/math.pi))
print('Neutral potential = %.3f∠%.2f° V' %(abs(V_n),cmath.phase(V_n)*180/math.pi))
print('\nNOTE : ERROR : For calculating neutral potential in textbook Z_n = 1 is taken instead of Z_n = 0.206611570248')
x1_G1 = complex(0,0.17) #Positive sequence reactance of G1(p.u)
x2_G1 = complex(0,0.14) #Negative sequence reactance of G1(p.u)
x0_G1 = complex(0,0.05) #Zero sequence reactance of G1(p.u)
x1_G2 = complex(0,0.17) #Positive sequence reactance of G2(p.u)
x2_G2 = complex(0,0.14) #Negative sequence reactance of G2(p.u)
x0_G2 = complex(0,0.05) #Zero sequence reactance of G2(p.u)
x1_T1 = complex(0,0.11) #Positive sequence reactance of T1(p.u)
x2_T1 = complex(0,0.11) #Negative sequence reactance of T1(p.u)
x0_T1 = complex(0,0.11) #Zero sequence reactance of T1(p.u)
x1_T2 = complex(0,0.11) #Positive sequence reactance of T2(p.u)
x2_T2 = complex(0,0.11) #Negative sequence reactance of T2(p.u)
x0_T2 = complex(0,0.11) #Zero sequence reactance of T2(p.u)
x1_L = complex(0,0.22) #Positive sequence reactance of line(p.u)
x2_L = complex(0,0.22) #Negative sequence reactance of line(p.u)
x0_L = complex(0,0.60) #Zero sequence reactance of line(p.u)
import cmath
a = 1.0*cmath.exp(1j*120*cmath.pi/180) #Operator
Z_1T = (x1_G1+x1_T1)*(x1_G2+x1_T2+x1_L)/(x1_G1+x1_T1+x1_G2+x1_T2+x1_L) #Thevenin reactance of positive sequence(p.u)
Z_2T = (x2_G1+x2_T1)*(x2_G2+x2_T2+x2_L)/(x2_G1+x2_T1+x2_G2+x2_T2+x2_L) #Thevenin reactance of negative sequence(p.u)
Z_0T = (x0_G1+x0_T1)*(x0_T2+x0_L)/(x0_G1+x0_T1+x0_T2+x0_L) #Thevenin reactance of zero sequence(p.u)
V_f = 1.0 #Pre-fault terminal voltage(p.u)
I_a1 = V_f/(Z_1T+Z_2T+Z_0T) #Positive sequence current(p.u)
I_a2 = I_a1 #Negative sequence current(p.u)
I_a0 = I_a1 #Zero sequence current(p.u)
I_a = 3*I_a1 #Fault current(p.u)
I_a1_G1 = I_a1*(x1_L+x1_T2+x1_G2)/(x1_L+x1_T1+x1_G1+x1_T2+x1_G2) #Positive sequence current shared by G1(p.u)
I_a2_G1 = I_a2*(x2_L+x2_T2+x2_G2)/(x2_L+x2_T1+x2_G1+x2_T2+x2_G2) #Negative sequence current shared by G1(p.u)
I_a0_G1 = I_a0*(x0_L+x0_T2)/(x0_L+x0_T1+x0_G1+x0_T2) #Zero sequence current shared by G1(p.u)
I_a_G1 = I_a0_G1+I_a1_G1+I_a2_G1 #Phase current through G1(p.u)
I_b_G1 = I_a0_G1+a**2*I_a1_G1+a*I_a2_G1 #Phase current through G1(p.u)
I_c_G1 = I_a0_G1+a*I_a1_G1+a**2*I_a2_G1 #Phase current through G1(p.u)
I_a1_G2 = I_a1*(x1_T1+x1_G1)/(x1_L+x1_T1+x1_G1+x1_T2+x1_G2)*cmath.exp(1j*30*cmath.pi/180) #Positive sequence current shared by G1(p.u)
I_a2_G2 = I_a2*(x2_T1+x2_G1)/(x2_L+x2_T1+x2_G1+x2_T2+x2_G2)*cmath.exp(1j*-30*cmath.pi/180) #Negative sequence current shared by G1(p.u)
I_a0_G2 = 0 #Zero sequence current shared by G1(p.u)
I_a_G2 = I_a0_G2+I_a1_G2+I_a2_G2 #Phase current through G2(p.u)
I_b_G2 = I_a0_G2+a**2*I_a1_G2+a*I_a2_G2 #Phase current through G2(p.u)
I_c_G2 = I_a0_G2+a*I_a1_G2+a**2*I_a2_G2 #Phase current through G2(p.u)
print('Fault current for a L-G fault at bus 1 , I_a = %.3fj p.u' %I_a.imag)
print('\nPhase currents contributed by G1 :')
print('I_a = %.3f∠%.1f° p.u' %(abs(I_a_G1),cmath.phase(I_a_G1)*180/cmath.pi))
print('I_b = %.3f∠%.1f° p.u' %(abs(I_b_G1),cmath.phase(I_b_G1)*180/cmath.pi))
print('I_c = %.3f∠%.1f° p.u' %(abs(I_c_G1),cmath.phase(I_c_G1)*180/cmath.pi))
print('\nPhase currents contributed by G2 :')
print('I_a = %.3f∠%.1f° p.u' %(abs(I_a_G2),cmath.phase(I_a_G2)*180/cmath.pi))
print('I_b = %.3f∠%.1f° p.u' %(abs(I_b_G2),cmath.phase(I_b_G2)*180/cmath.pi))
print('I_c = %.3f∠%.1f° p.u' %(abs(I_c_G2),cmath.phase(I_c_G2)*180/cmath.pi))
print('\nNOTE : ERROR : Calculation mistakes in Generator G2 part')
kv_G1 = 13.2 #Voltage rating of G1(kV)
MVA_G1 = 40.0 #MVA rating of G1
x1_G1 = 0.2 #Positive sequence reactance of G1(p.u)
x2_G1 = 0.2 #Negative sequence reactance of G1(p.u)
x0_G1 = 0.08 #Zero sequence reactance of G1(p.u)
MVA_T1 = 40.0 #MVA rating of T1
x_T1 = 0.05 #Reactance(p.u)
kv_lv_T1 = 13.2 #L.V side rating of T1(kV)
kv_hv_T1 = 132.0 #H.V side rating of T1(kV)
kv_L = 132.0 #Voltage rating of line(kV)
x1_L = 40.0 #Positive sequence resistance of line(ohm)
x2_L = 40.0 #Negative sequence resistance of line(ohm)
x0_L = 100.0 #Zero sequence resistance of line(ohm)
MVA_T2 = 40.0 #MVA rating of T1
x_T2 = 1.0 #Resistance through which neutral is earthed(ohm)
xp_T2 = 0.05 #Primary reactance of T2(p.u)
xs_T2 = 0.045 #Secondary reactance of T2(p.u)
xt_T2 = 0.06 #Tertiary reactance of T2(p.u)
MVA_base = 40.0 #Base MVA
kv_base_G1 = 13.2 #Voltage base on generator side(kV)
kv_base_L = 132.0 #Voltage base on Line side(kV)
kv_base_T2t = 3.3 #Voltage base on tertiary side of T2(kV)
kv_base_T2s = 66 #Voltage base on secondary side of T2(kV)
R_ng = 2*MVA_base/kv_base_G1**2 #Neutral resistance of generator(p.u)
x1_L_new = x1_L*MVA_base/kv_base_L**2 #New Line reactance(p.u)
x2_L_new = x2_L*MVA_base/kv_base_L**2 #New Line reactance(p.u)
x0_L_new = x0_L*MVA_base/kv_base_L**2 #New Line reactance(p.u)
R_nT = x_T2*MVA_base/kv_base_T2s**2 #Neutral resistance of T2(p.u)
V_f = 1.0 #Pre-fault voltage at fault point(p.u)
Z1 = complex(0,x1_G1+x_T1+(x1_L_new/2)+xp_T2+xs_T2) #Thevenin impedance of positive sequence(p.u)
Z2 = complex(0,x2_G1+x_T1+(x2_L_new/2)+xp_T2+xs_T2) #Thevenin impedance of negative sequence(p.u)
Z0 = complex(0.0024,0.0593) #Thevenin impedance of zero sequence(p.u).Refer diagram
I_f = 3*V_f/(Z1+Z2+Z0) #Fault current(p.u)
I_f1 = abs(I_f)*MVA_base*1000/(3**0.5*kv_base_T2s) #Fault current(A)
MVA_fault = abs(I_f)*MVA_base #Fault MVA
print('Fault current , I_f = %.2f A' %I_f1)
print('Fault MVA for L-G fault = %.2f MVA' %MVA_fault)