In [2]:

```
from __future__ import division
from pylab import *
import cmath
import math
#Variable declaration:
Ir = cmath.rect(100,30*math.pi/180) #current in phase R(A)
Iy = cmath.rect(50,300*math.pi/180) #current in phase Y(A)
Ib = cmath.rect(30,180*math.pi/180) #current in phase B(A)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
I0 = 1/3*(Ir+Iy+Ib) #A
I1 = 1/3*(Ir+a*Iy+a**2*Ib) #A
I2 = 1/3*(Ir+a**2*Iy+a*Ib) #A
In = Ir+Iy+Ib #A
#Result:
print "The positive, negative and zero sequence currents in the R-line are"
print "I0 = (",round(abs(I0),2),round(rad2deg(angle(I0)),2),") A"
print "I1 = (",round(abs(I1),2),round(rad2deg(angle(I1)),1),") A"
print "I2 = (",round(abs(I2),2),round(rad2deg(angle(I2)),2),") A"
print "Return current in the neutral wire is"
print "In =(",round(abs(In),2),round(rad2deg(angle(In)),1),") A"
```

In [3]:

```
from __future__ import division
from pylab import *
import cmath
import math
#Variable declaration:
Ir = 12+6j #current in phase A(A)
Iy = 12-12j #current in phase Y(A)
Ib = -15+10j #current in phase B(A)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
#Red phase
Ir0 = 1/3*(Ir+Iy+Ib) #A
Ir1 = 1/3*(Ir+a*Iy+a**2*Ib) #A
Ir2 = 1/3*(Ir+a**2*Iy+a*Ib) #A
#Yellow phase:
Iy0 = Ir0 #A
Iy1 = a**2*Ir1 #A
Iy2 = a*Ir2 #A
#Blue phase:
Ib0 = Ir0 #A
Ib1 = a*Ir1 #A
Ib2 = a**2*Ir2 #A
#Result:
print "The sequence currents of red phase are:"
print "Ir0 =",Ir0.real+round(Ir0.imag,2)*1j,"A"
print "Ir1 =",round(Ir1.real,2)+round(Ir1.imag,2)*1j,"A"
print "Ir2 =",round(Ir2.real,2)+round(Ir2.imag,2)*1j,"A"
print "\nThe sequence currents of red phase are:"
print "Iy0 =",Iy0.real+round(Iy0.imag,2)*1j,"A"
print "Iy1 =",round(Iy1.real,2)+round(Iy1.imag,1)*1j,"A"
print "Iy2 =",round(Iy2.real,1)+round(Iy2.imag,2)*1j,"A"
print "\nThe sequence currents of red phase are:"
print "Ib0 =",Ib0.real+round(Ib0.imag,2)*1j,"A"
print "Ib1 =",round(Ib1.real,2)+round(Ib1.imag,2)*1j,"A"
print "Ib2 =",round(Ib2.real,2)+round(Ib2.imag,2)*1j,"A"
```

In [4]:

```
from __future__ import division
from pylab import *
import cmath
import math
#Variable declaration:
Er0 = 100 #zero sequence voltage of phase R(V)
Er1 = 200-100j #positive sequence voltage of phase R(V)
Er2 = -100 #negative sequence voltage of phase R(V)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
Er = Er0+Er1+Er2 #V
Ey = Er0+a**2*Er1+a*Er2 #V
Eb = Er0+a*Er1+a**2*Er2 #V
#Result:
print "The phase voltages are:"
print "Er =",(round(abs(Er),2),round(rad2deg(angle(Er)),2)),"V"
print "Ey =",(round(abs(Ey)),round(rad2deg(angle(Ey)),2)),"V"
print "Eb =",(round(abs(Eb),2),round(rad2deg(angle(Eb)),1)),"V"
```

In [5]:

```
from __future__ import division
from pylab import *
import cmath
import math
#Variable declaration:
Er0 = 0.5-0.866j #zero sequence components of red phase(V)
Er1 = 2+0j #positive sequence components of red phase(V)
Er = 3+0j #phase R voltage(V)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
Er2 = Er-(Er0+Er1) #negative sequence voltage of red phase(V)
Ey = Er0+a**2*Er1+a*Er2 #phase Y voltage(V)
Eb = Er0+a*Er1+a**2*Er2 #phase B voltage(V)
#Result:
print "The negative sequence component of red phase is"
print "Ir2 = (",round(abs(Er2)),round(rad2deg(angle(Er2))),") V"
print "\nThe phase voltages are:"
print "Iy = (",round(abs(Ey)),round(rad2deg(angle(Ey))),") V"
print "Ib = (",round(abs(Eb)),round(rad2deg(angle(Eb))),") V"
```

In [6]:

```
from __future__ import division
#Variable declaration:
In = 12 #current from neutral to ground(A)
#Calculation:
I0 = In/3 #A
#Result:
print "The zero phase sequence components in phases are",I0,"A each"
```

In [7]:

```
from __future__ import division
import cmath
import math
#Variable declaration:
#(i) Before removal of fuses.
Iri = cmath.rect(90,0) #phase R current(A)
Iyi = cmath.rect(90,math.pi/180*240) #phase Y current(A)
Ibi = cmath.rect(90,math.pi/180*120) #phase B current(A)
#(ii) After removal of fuses.
Irii = 90+0j #A
Iyii = 0 #A
Ibii = 0 #A
#Calculation:
a = cmath.rect(1,120*math.pi/180)
#(i) Before removal of fuses.
#Since the system is balanced, it will have only positive sequence currents.
Ir1i = Iri #A
Iy1i = Iyi #A
Ib1i = Ibi #A
#(ii) After removal of fuses.
#The sequence currents in the three lines will be:
Ir0ii = 1/3*(Irii+Iyii+Ibii) #A
Iy0ii = Ir0ii #A
Ib0ii = Ir0ii #A
Ir1ii = 1/3*(Irii+Iyii+Ibii) #A
Iy1ii = a**2*Ir1ii #A
Ib1ii = a*Ir1ii #A
Ir2ii = 1/3*(Irii+a**2*Iyii+a*Ibii) #A
Iy2ii = a*Ir2ii #A
Ib2ii = a**2*Ir2ii #A
#Result:
print "(i) Before removal of fuses, the symmetrical components are:"
print "\tIr1 = (",round(abs(Ir1i)),round(rad2deg(angle(Ir1i))),") A"
print "\tIy1 = (",round(abs(Iy1i)),360+round(rad2deg(angle(Iy1i))),") A"
print "\tIb1 = (",round(abs(Ib1i)),round(rad2deg(angle(Ib1i))),") A"
print "\n(ii) After the removal of fuses, the symmetrical components are:"
print "\tIr0 = (",round(abs(Ir0ii)),round(rad2deg(angle(Ir0ii))),") A"
print "\tIr1 = (",round(abs(Ir1ii)),round(rad2deg(angle(Ir1ii))),") A"
print "\tIr2 = (",round(abs(Ir2ii)),round(rad2deg(angle(Ir2ii))),") A"
print "\n\tIy0 = (",round(abs(Iy0ii)),round(rad2deg(angle(Iy0ii))),") A"
print "\tIy1 = (",round(abs(Iy1ii)),360+round(rad2deg(angle(Iy1ii))),") A"
print "\tIy2 = (",round(abs(Iy2ii)),round(rad2deg(angle(Iy2ii))),") A"
print "\n\tIb0 = (",round(abs(Ib0ii)),round(rad2deg(angle(Ib0ii))),") A"
print "\tIb1 = (",round(abs(Ib1ii)),round(rad2deg(angle(Ib1ii))),") A"
print "\tIb2 = (",round(abs(Ib2ii)),360+round(rad2deg(angle(Ib2ii))),") A"
```

In [8]:

```
from __future__ import division
import cmath
import math
#Variable declaration:
Ir1 = cmath.rect(200,0) #positive phase sequence component of current(A)
Ir2 = cmath.rect(100,60*math.pi/180) #negative phase sequence component of current(A)
In = cmath.rect(300,300*math.pi/180) #current in the neutral conductor(A)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
Ir0 = 1/3*In #Zero phase sequence current in R-line(A)
Ir = Ir0+Ir1+Ir2 #Current in the R-line(A)
Iy = Ir0+a**2*Ir1+a*Ir2 #Current in the Y-line(A)
Ib = Ir0+a*Ir1+a**2*Ir2 #Current in the B-line(A)
#Result:
print "Current in the R-line is"
print "\tIr = (",round(abs(Ir)),round(rad2deg(angle(Ir))),") A"
print "Current in the Y-line is"
print "\tIy = (",round(abs(Iy)),round(rad2deg(angle(Iy))),") A"
print "Current in the B-line is"
print "\tIb = (",round(abs(Ib)),round(rad2deg(angle(Ib))),") A"
```

In [9]:

```
from __future__ import division
import cmath
import math
#Variable declaration:
Ir = cmath.rect(10,0) #current in line R(A)
Iy = cmath.rect(10,180*math.pi/180) #current in line Y(A)
Ib = cmath.rect(0,0) #current in line B(A)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
#For R-line:
Ir0 = 1/3*(Ir+Iy+Ib) #zero sequence component of Ir(A)
Ir1 = 1/3*(Ir+a*Iy+a**2*Ib) #positive sequence component of Ir(A)
Ir2 = 1/3*(Ir+a**2*Iy+a*Ib) #negative sequence component of Iy(A)
#For Y-line:
Iy0 = Ir0 #zero sequence component of Ir(A)
Iy1 = a**2*Ir1 #positive sequence component of Ir(A)
Iy2 = a*Ir2 #negative sequence component of Iy(A)
#For B-line:
Ib0 = Ir0 #zero sequence component of Ir(A)
Ib1 = a*Ir1 #positive sequence component of Ir(A)
Ib2 = a**2*Ir2 #negative sequence component of Iy(A)
#Result:
print "The sequence components of R-line are:"
print "\tIr0 = (",round(abs(Ir0),2),round(rad2deg(angle(Ir0))),") A"
print "\tIr0 = (",round(abs(Ir1),2),round(rad2deg(angle(Ir1))),") A"
print "\tIr0 = (",round(abs(Ir2),2),round(rad2deg(angle(Ir2))),") A"
print "The sequence components of Y-line are:"
print "\tIy0 = (",round(abs(Iy0),2),round(rad2deg(angle(Iy0))),") A"
print "\tIy1 = (",round(abs(Iy1),2),round(rad2deg(angle(Iy1))),") A"
print "\tIy2 = (",round(abs(Iy2),2),round(rad2deg(angle(Iy2))),") A"
print "The sequence components of B-line are:"
print "\tIb0 = (",round(abs(Ib0),2),round(rad2deg(angle(Ib0))),") A"
print "\tIb1 = (",round(abs(Ib1),2),round(rad2deg(angle(Ib1))),") A"
print "\tIb2 = (",round(abs(Ib2),2),round(rad2deg(angle(Ib2))),") A"
```

In [10]:

```
from __future__ import division
import cmath
import math
#Variable declaration:
Rrb = 10 #resistance of branch RB(ohm)
Rry = 20 #resistance of branch RY(ohm)
Rby = 5 #resistance of branch BY(ohm)
Er = cmath.rect(-100,0) #voltage across BY(V)
Ey = cmath.rect(100,60*math.pi/180) #voltage across BR(V)
Eb = cmath.rect(100,-60*math.pi/180) #voltage across RY(V)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
IR = Er/Rby #Current in in branch BY(A)
IY = Ey/Rrb #Current in in branch RB(A)
IB = Eb/Rry #Current in in branch RY(A)
#Sequence currents in resistors:
IR0 = 1/3*(IR+IY+IB) #Zero sequence component of IR(A)
IR1 = 1/3*(IR+a*IY+a**2*IB) #Positive sequence component of IR(A)
IR2 = 1/3*(IR+a**2*IY+a*IB) #Negative sequence component of IR(A)
IY0 = IR0 #Zero sequence component of IY(A)
IY1 = a**2*IR1 #Positive sequence component of IY(A)
IY2 = a*IR2 #Negative sequence component of IY(A)
IB0 = IR0 #Zero sequence component of IB(A)
IB1 = a*IR1 #Positive sequence component of IB(A)
IB2 = a**2*IR2 #Negative sequence component of IB(A)
#Sequence currents in supply lines:
Ir = IB-IY #Line current in R-line(A)
Iy = IR-IB #Line current in Y-line(A)
Ib = IY-IR #Line current in R-line(A)
Ir0 = 1/3*(Ir+Iy+Ib) #Zero sequence component of Ir(A)
Ir1 = 1/3*(Ir+a*Iy+a**2*Ib) #Positive sequence component of Ir(A)
Ir2 = 1/3*(Ir+a**2*Iy+a*Ib) #Negative sequence component of Ir(A)
#Result:
print "The sequence components of R-line are:"
print "\tIR0 = (",round(abs(IR0),2),round(rad2deg(angle(IR0)),1),") A"
print "\tIR1 = (",round(abs(IR1),2),round(rad2deg(angle(IR1))),") A"
print "\tIR2 = (",round(abs(IR2),2),round(rad2deg(angle(IR2)),1),") A"
print "\nThe sequence components of Y-line are:"
print "\tIY0 = (",round(abs(IY0),2),round(rad2deg(angle(IY0)),1),") A"
print "\tIY1 = (",round(abs(IY1),2),round(rad2deg(angle(IY1))),") A"
print "\tIY2 = (",round(abs(IY2),1),round(rad2deg(angle(IY2)),1),") A"
print "\nThe sequence components of B-line are:"
print "\tIB0 = (",round(abs(IB0),2),round(rad2deg(angle(IB0)),1),") A"
print "\tIB1 = (",round(abs(IB1),2),360+round(rad2deg(angle(IB1))),") A"
print "\tIB2 = (",round(abs(IB2),1),round(rad2deg(angle(IB2)),1),") A"
print "\nThe Sequence currents in supply lines are:"
print "\tIr0 = (",round(abs(Ir0),2),round(rad2deg(angle(Ir0))),") A"
print "\tIr1 = (",round(abs(Ir1),1),round(rad2deg(angle(Ir1))),") A"
print "\tIr2 = (",round(abs(Ir2),2),round(rad2deg(angle(Ir2)),1),") A"
```

In [11]:

```
from __future__ import division
import cmath
import math
#Variable declaration:
I = 20 #current in each line(A)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
#Let R, Y and B be the supply lines. When fuse in the
#line B is removed, the various line currents are :
Ir = cmath.rect(I,0) #A
Iy = cmath.rect(I,math.pi) #A
Ib = cmath.rect(0,0) #A
#For R-line:
Ir0 = 1/3*(Ir+Iy+Ib) #zero sequence component of Ir(A)
Ir1 = 1/3*(Ir+a*Iy+a**2*Ib) #positive sequence component of Ir(A)
Ir2 = 1/3*(Ir+a**2*Iy+a*Ib) #negative sequence component of Iy(A)
#For Y-line:
Iy0 = Ir0 #zero sequence component of Ir(A)
Iy1 = a**2*Ir1 #positive sequence component of Ir(A)
Iy2 = a*Ir2 #negative sequence component of Iy(A)
#For B-line:
Ib0 = Ir0 #zero sequence component of Ir(A)
Ib1 = a*Ir1 #positive sequence component of Ir(A)
Ib2 = a**2*Ir2 #negative sequence component of Iy(A)
#Result:
print "The sequence components of R-line are:"
print "\tIr0 = (",round(abs(Ir0),2),round(rad2deg(angle(Ir0))),") A"
print "\tIr0 = (",round(abs(Ir1),2),round(rad2deg(angle(Ir1))),") A"
print "\tIr0 = (",round(abs(Ir2),2),round(rad2deg(angle(Ir2))),") A"
print "\nThe sequence components of Y-line are:"
print "\tIy0 = (",round(abs(Iy0),2),round(rad2deg(angle(Iy0))),") A"
print "\tIy1 = (",round(abs(Iy1),2),360+round(rad2deg(angle(Iy1))),") A"
print "\tIy2 = (",round(abs(Iy2),2),round(rad2deg(angle(Iy2))),") A"
print "\nThe sequence components of B-line are:"
print "\tIb0 = (",round(abs(Ib0),2),round(rad2deg(angle(Ib0))),") A"
print "\tIb1 = (",round(abs(Ib1),2),round(rad2deg(angle(Ib1))),") A"
print "\tIb2 = (",round(abs(Ib2),2),360+round(rad2deg(angle(Ib2))),") A"
```

In [12]:

```
from __future__ import division
from pylab import *
import cmath
from sympy import *
#Variable declaration:
Zr = 5-10j #impedance connected to line R(ohm)
Zy = 6+5j #impedance connected to line Y(ohm)
Zb = 3+15j #impedance connected to line B(ohm)
VRY = cmath.rect(3300,0) #line RY voltage(V)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
VYB = a**2*VRY #line YB voltage(V)
#Let VR, VY, and VB be the voltages across impedances in R, Y and B
#phases respectively and IR, IY, and IB the resulting line currents.
IR, IY,IB,IR0,IR1,IR2, = symbols('IR IY IB IR0 IR1 IR2')
#IR+IY+IB = 0
IR0 = 0; IY0 = 0; IB0 = 0;
VR = Zr*(IR0+IR1+IR2) #V
VY = Zy*(a**2*IR1+a*IR2) #V
VB = Zb*(a*IR1+a**2*IR2) #V
#solving the equations:
IR11 = solve(VR-VY-VRY,IR1)[0]
VY = Zy*(a**2*IR11+a*IR2)
VB = Zb*(a*IR11+a**2*IR2)
IR22 = solve(VY-VB-VYB,IR2)[0]
VR = Zr*(IR0+IR1+IR22)
VY = Zy*(a**2*IR1+a*IR22)
IR11 = solve(VR-VY-VRY,IR1)[0]
IR = IR11+IR22 #A
#Result:
print "The line current IR is (",round(abs(IR)),round(-rad2deg(cmath.phase(IR)),1),") A"
```

In [13]:

```
from __future__ import division
import cmath
import math
#Variable declaration:
R = 1 #resistance of each load(ohm)
magVRY = 200 #line RY voltage(V)
magVBR = 400 #line BR voltage(V)
magVYB = 346 #line YB voltage(V)
#Calculation:
a = cmath.rect(1,120*math.pi/180)
#This is a case of a balanced star-connected load supplied
#from an unbalanced 3-phase supply.
#Now,
# (2)**22 = (1 + 1·75 cos(theta))**2 + (1·75 sin(theta))**2
# theta = math.acos(4-1+3*1)/3.5
theta = math.pi/2
# alpha = math.acos(1+1.75*math.cos(theta))
alpha = 60*math.pi/180
#As the phase sequence is RYB, therefore, various line voltages are :
VRY = cmath.rect(200,math.pi) #V
VYB = cmath.rect(346,theta) #V
VBR = cmath.rect(400,-alpha) #V
#The current in any phase (or line) is equal to phase voltage
#divided by resistance in that phase.
IR = VRY/(1*3**0.5) #A
IY = VYB/(1*3**0.5) #A
IB = VBR/(1*3**0.5) #A
#Sequence components in red phase are :
IR0 = 1/3*(IR+IY+IB) #A
IR1 = 1/3*(IR+a*IY+a**2*IB) #A
IR2 = 1/3*(IR+a**2*IY+a*IB) #A
#Result:
print "The magnitude of current in any phase is:"
print "\tIR0 = (",round(abs(IR0)),round(rad2deg(angle(IR0))),") A"
print "\tIR1 = (",round(abs(IR1),1),round(rad2deg(angle(IR1))),") A"
print "\tIR2 = (",round(abs(IR2),2),round(rad2deg(angle(IR2))),") A"
```

In [14]:

```
from __future__ import division
#Variable declaration:
MVAg = 10 #MVA rating of generator
Vg = 11 #voltage rating of generator(kV)
Zg1 = 1.2j #Positive sequence impedance of generator(ohm)
Zg2 = 0.9j #Negative sequence impedance of generator(ohm)
Zg0 = 0.4j #Zero sequence impedance of generator(ohm)
Zf1 = 1.0j #Positive sequence impedance of feeder(ohm)
Zf2 = 1.0j #Negative sequence impedance of feeder(ohm)
Zf0 = 3.0j #Zero sequence impedance of feeder(ohm)
#Calculation:
#Suppose the fault is occured on the red phase.
#Taking red phase as the reference,
ER = Vg*1000/3**0.5 #Phase e.m.f. of R-phase(V)
#(i)The total impedance to any sequence current is given by
#the sum of generator and feeder impedances to that sequence current.
Z1 = Zg1+Zf1 #ohm
Z2 = Zg2+Zf2 #ohm
Z0 = Zg0+Zf0 #ohm
#For a line-to-ground fault,
#I1 = I2 = I0
I0 = ER/(Z1+Z2+Z0) #A
IR = 3*I0 #fault current(A)
#(ii)Line-to-neutral voltage of R-phase,
VR = ER-I0*(Zg1+Zg2+Zg0) #V
#Result:
print "(i) The magnitude of fault current is",round(IR.imag)*1j,"A"
print "(ii) Line to neutral voltage at the generator terminal is",round(abs(VR)),"V"
```

In [15]:

```
from __future__ import division
#Variable declaration:
Vg = 11000 #voltage rating of the alternator(V)
MVAg = 10 #MVA rating of generator
X0 = 0.05 #zero sequence reactance(p.u)
X1 = 0.15 #positive sequence reactance(p.u)
X2 = 0.15 #negative sequence reactance(p.u)
#Calculation:
#Taking red phase as the reference, let its phase e.m.f. be
ER = 1 #p.u
#Line-to-ground fault:
#Suppose the fault occurs on the red phase.
#I1 = I2 = I0
I0 = ER/(1j*(X0+X1+X2))
IR = 3*I0 #fault current(A)
#Three phase fault:
#the fault current (say Ish) is limited by the positive sequence reactance only.
Ish = ER/(1j*X1) #fault current(A)
r = IR/Ish #ratio of the two fault currents
#Result:
print "The ratio of two fault currents is",round(abs(r),3)
```

In [16]:

```
from __future__ import division
#Variable declaration:
Vg = 11 #voltage rating of the alternator(kV)
MVAg = 25 #MVA rating of generator
X0 = 0.05 #zero sequence reactance(p.u)
X1 = 0.2 #positive sequence reactance(p.u)
X2 = 0.2 #negative sequence reactance(p.u)
Xn = 0.3 #neutral to ground reactance(ohm)
#Calculation:
#Assume that the fault occurs on the red phase.
#Taking red phase as the reference, let its phase e.m.f. be
ER = 1 #p.u.
#First of all, convert the reactance Xn into p.u.
Xnp = Xn*MVAg*1000/(Vg**2*1000) #p.u
#For a line-to-ground fault,
#I1 = I2 = I0
I0 = ER/(X1+X2+X0+3*Xnp) #p.u
IR = 3*I0 #fault current(p.u)
IRa = MVAg*10**6/(3**0.5*Vg*1000) * IR #fault current in amperes
#Result:
print " The fault current for a single line to ground fault is",round(IRa),"A"
```

In [17]:

```
from __future__ import division
#Variable declaration:
V = 10.4 #voltage between the lines(kV)
X0 = 0.2j #zero sequence reactance(p.u)
X1 = 0.6j #positive sequence reactance(p.u)
X2 = 0.5j #negative sequence reactance(p.u)
#Calculation:
#Taking red phase as the reference, its phase e.m.f. is :
ER = round(V*1000/3**0.5) #Phase e.m.f. of R-phase(V)
IF = 3**0.5*ER/(X1+X2) #fault current(A)
#Result:
print "The fault current is",round(abs(IF),1),"A"
```

In [18]:

```
from __future__ import division
#Variable declaration:
X0 = 0.05j #zero sequence reactance(p.u)
X1 = 0.08j #positive sequence reactance(p.u)
X2 = 0.07j #negative sequence reactance(p.u)
#Calculation:
#Taking red phase as the reference, let its phase e.m.f. be
ER = 1 #p.u
#For a double line-to-ground fault,
#IF = IY+IB
IF = -3*X2*ER/(X1*X2+X2*X0+X2*X0) #fault current(A)
#Result:
print "The fault current is",round(IF.imag,1)*1j,"p.u"
```

In [19]:

```
from __future__ import division
#Variable declaration:
MVAg = 20 #MVA rating of generator
V = 11 #voltage rating of generator(V)
X1 = 20 #positive sequence reactance of generator(%)
X2 = 10 #negative sequence reactance of generator(%)
X0 = 15 #zero sequence reactance of generator(%)
Xn = 5 #generator 1 neutral reactance(%)
#Calculation:
ER = V*1000/3**0.5 #V
#The % reactances in Fig. 18.19b can be converted into ohmic values as under:
x1 = X1*V**2*10/(MVAg*1000) #ohm
x2 = X2*V**2*10/(MVAg*1000) #ohm
x0 = X0*V**2*10/(MVAg*1000) #ohm
IR = 3*ER/(x1+x2+x0)*(-1j) #ohm
#Result:
print "Fault current is",round(IR.imag)*1j,"A"
```

In [20]:

```
from __future__ import division
from sympy import *
#Variable declaration:
IF1 = 2000 #3 phase fault current(A)
IF2 = 2600 #line-to-line fault(A)
IF0 = 4200 #line-toground fault(A)
MVAg = 50 #MVA rating of the generator
V = 11 #voltage rating of the generator(V)
#Calculation:
#Let X1 = positive sequence reactance,
# X2 = negative sequence reactance,and
# X0 = zero sequence reactance of the alternator.
X1,X2,X0 = symbols('X1 X2 X0')
Eph = V*1000/3**0.5 #phase voltage(V)
X11 = solve(Eph/X1-IF1)[0] #positive sequence reactance(ohm)
X22 = solve(3**0.5*Eph/(X11+X2)-IF2,X2)[0] #negative sequence reactance(ohm)
X00 = solve(3*Eph/(X11+X22+X0)-IF0)[0] #zero sequence reactance(ohm)
#Result:
print "The positive sequence reactance is",round(X11,3),"ohm"
print "The negative sequence reactance is",round(X22,3),"ohm"
print "The zero sequence reactance is",round(X00,3),"ohm"
```