# Chapter 07 : Network Calculations¶

## Example 7.1, Page No 170¶

In [4]:
import math
#initialisation of variables
#Voltage Sources
Ea = 1.5
Eb = 1.5*complex(math.cos(-36.87 * math.pi / 180),math.sin(-36.87 * math.pi / 180))
Ec = 1.5
Ya = -complex(0.8)
Yb = Ya
Yc= Ya
Yd = -complex(5)
Ye = -complex(8)
Yf = -complex(4)
Yg = -complex(2.5)
Yh = Yd

#Calculations
#current sourcs
I1 = Ea * Ya
I2 = Eb * Yb
I3 = I1
I4 = 0
print('Current Sources are')
print(" I1 = - j%.2f per unit" %(-I1.imag))
print(" I2 = %.2f - j%.2f per unit" %(I2.real,-I2.imag))
print(" I3 = - j%.2f per unit " %(-I3.imag))
Y11 = Yd + Yf + Ya
Y22 = Yh + Yg + Yb
Y33 = Ye + Yc + Yg + Yf
Y44 = Yd + Ye + Yh
print(" Y11 = - j%.2f per unit" %(-Y11.imag))
print(" Y22 = - j%.2f per unit" %(-Y22.imag))
print(" Y33 = - j%.2f per unit" %(-Y33.imag))
print(" Y44 = - j%.2f per unit" %(-Y44.imag))
Y12 = 0;Y21 = Y12
Y13 = -Yf;Y31 = Y13
Y14 = -Yd;Y41 = Y14
Y23 = -Yg;Y32 = Y23
Y24 = -Yh;Y42 = Y24;
Y34 = -Ye;Y43 = Y34
print(" Y12 = - j%.2f per unit" %(-Y12.imag))
print(" Y13 = - j%.2f per unit" %(-Y13.imag))
print(" Y14 = - j%.2f per unit" %(-Y14.imag))
print(" Y23 = - j%.2f per unit" %(-Y23.imag))
print(" Y24 = - j%.2f per unit" %(-Y24.imag))
print(" Y34 = - j%.2f per unit" %(-Y34.imag))
#Matrix Form
I = [I1.real,I2.imag,I3.real,I4.imag]
Y = [[Y11.real,Y12.real,Y13.real,Y14.real],
[Y21.real,Y22.real,Y23.real,Y24.real],
[Y31.real,Y32.real,Y33.real,Y34.real],
[Y41.real,Y42.real,Y43.real,Y44.real]]
print('Current Vector =')
for i in range(0, 4):
print("I= %.2f" %I[i])

for x in range(0, 4):
for y in range(0, 4):
print("Y[%.0f][%.0f]= %.2f" %(x,y,Y[x][y]))
print("\n")

Current Sources are
I1 = - j0.00 per unit
I2 = -0.96 - j-0.72 per unit
I3 = - j0.00 per unit
Y11 = - j0.00 per unit
Y22 = - j0.00 per unit
Y33 = - j0.00 per unit
Y44 = - j0.00 per unit
Y12 = - j0.00 per unit
Y13 = - j-0.00 per unit
Y14 = - j-0.00 per unit
Y23 = - j-0.00 per unit
Y24 = - j-0.00 per unit
Y34 = - j-0.00 per unit
Current Vector =
I= -1.20
I= 0.72
I= -1.20
I= 0.00
Y[0][0]= -9.80
Y[0][1]= 0.00
Y[0][2]= 4.00
Y[0][3]= 5.00

Y[1][0]= 0.00
Y[1][1]= -8.30
Y[1][2]= 2.50
Y[1][3]= 5.00

Y[2][0]= 4.00
Y[2][1]= 2.50
Y[2][2]= -15.30
Y[2][3]= 8.00

Y[3][0]= 5.00
Y[3][1]= 5.00
Y[3][2]= 8.00
Y[3][3]= -18.00



## Example 7.2, Page No 171¶

In [5]:
import math
import numpy
#initialisation of variables
#Voltage Sources
Ea = 1.5
Eb = 1.5*complex(math.cos(-36.87*math.pi/180),math.sin(-36.87 * math.pi / 180))
Ec = 1.5;
Ya = complex(-0.8)
Yb = Ya
Yc= Ya
Yd = complex(-5)
Ye = complex(-8)
Yf = complex(-4)
Yg = complex(-2.5)
Yh = Yd

#Calculations
#current sourcs
I1 = Ea * Ya
I2 = Eb * Yb
I3 = I1
I4 = 0
Y11 = Yd + Yf + Ya
Y22 = Yh + Yg + Yb
Y33 = Ye + Yc + Yg + Yf
Y44 = Yd + Ye + Yh
Y12 = 0
Y21 = Y12
Y13 = -Yf
Y31 = Y13
Y14 = -Yd
Y41 = Y14
Y23 = -Yg
Y32 = Y23
Y24 = -Yh
Y42 = Y24
Y34 = -Ye
Y43 = Y34
#Matrix Form
I = [I1,I2,I3,I4]
Y = [[Y11,Y12,Y13,Y14],[Y21,Y22,Y23,Y24],[Y31,Y32,Y33,Y34],[Y41,Y42,Y43,Y44]]
V = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
for x in range(0, 4):
for y in range(0, 4):
if I[x].imag > 0  :
V[x][y]=Y[x][y]/I[x]
else:
V[x][y]=0

#Results
print('Node Voltages V1,V2,V3 and V4 in per unit is')
for x in range(0, 4):
for y in range(0, 4):
print("V[%.0f][%.0f]= %.2f -%.2fi" %(x,y,V[x][y].imag,V[x][y].real))
print("\n")

print('In polar form')
print( "V1 = {0:.2f}".format(abs(V[0][0].real)))
print("Angle = %.2f v " %(math.degrees(math.atan2(V[0][0].imag,V[0][0].real))*180/math.pi))
print( "V2 = {0:.2f}".format(abs(V[1][1].real)))
print("Angle = %.2f v " %(math.degrees(math.atan2(V[1][1].imag,V[1][1].real))*180/math.pi))
print( "V2 = {0:.2f}".format(abs(V[2][2].real)))
print("Angle = %.2f v " %(math.degrees(math.atan2(V[2][2].imag,V[2][2].real))*180/math.pi))
print( "V2 = {0:.2f}".format(abs(V[3][3].real)))
print("Angle = %.2f v " %(math.degrees(math.atan2(V[3][3].imag,V[3][3].real))*180/math.pi))

Node Voltages V1,V2,V3 and V4 in per unit is
V[0][0]= 0.00 -0.00i
V[0][1]= 0.00 -0.00i
V[0][2]= 0.00 -0.00i
V[0][3]= 0.00 -0.00i

V[1][0]= -0.00 --0.00i
V[1][1]= 4.15 -5.53i
V[1][2]= -1.25 --1.67i
V[1][3]= -2.50 --3.33i

V[2][0]= 0.00 -0.00i
V[2][1]= 0.00 -0.00i
V[2][2]= 0.00 -0.00i
V[2][3]= 0.00 -0.00i

V[3][0]= 0.00 -0.00i
V[3][1]= 0.00 -0.00i
V[3][2]= 0.00 -0.00i
V[3][3]= 0.00 -0.00i

In polar form
V1 = 0.00
Angle = 0.00 v
V2 = 5.53
Angle = 2112.50 v
V2 = 0.00
Angle = 0.00 v
V2 = 0.00
Angle = 0.00 v


## Example 7.3, Page No 177¶

In [6]:
import math
#initialisation of variables
Ea = 1.5
Eb = 1.5*complex(math.cos(-36.87 *math.pi / 180),math.sin(-36.87 * math.pi / 180))
Ec = 1.5
Ya = -complex(0.8)
Yb = Ya
Yc= Ya
Yd = -complex(5)
Ye = -complex(8)
Yf = -complex(4)
Yg = -complex(2.5)
Yh = Yd
Y11 = Yd + Yf + Ya
Y22 = Yh + Yg + Yb
Y33 = Ye + Yg + Yf
Y44 = Yd + Ye + Yh
Y12 = 0
Y21 = Y12
Y13 = -Yf
Y31 = Y13
Y14 = -Yd
Y41 = Y14
Y23 = -Yg
Y32 = Y23
Y24 = -Yh
Y42 = Y24
Y34 = -Ye
Y43 = Y34

#Calculations
#Bus Impedance Matrix
Y = [[Y11,Y12,Y13,Y14],[Y21,Y22,Y23,Y24],[Y31,Y32,Y33,Y34],[Y41,Y42,Y43,Y44]]
K = [[Y[0][0],Y[0][1]],[Y[1][0],Y[1][1]]]
L = [[Y[0][2],Y[0][3]],[Y[1][2],Y[1][3]]]
L_T = [[Y[2][0],Y[2][1]],[Y[3][0],Y[3][1]]]
M = [[Y[2][2],Y[2][3]],[Y[3][2],Y[3][3]]]
Ybus = [[0,0],[0,0]]
M_1 = [[complex(0.0913706),complex(0.0406091)],[complex(0.0406091),complex(0.0736041)]]
LMT = [[complex(-4.9263959),complex(-4.0736041)],[complex(-4.0736041),complex(-3.4263959)]]
for x in range(0, 2):
for y in range(0, 2):
Ybus[x][y]=K[x][y]-LMT[x][y]
Y_12 = - Ybus[0][1]
Y_10 = Ybus[0][0] - Y_12
Y_20 = Y_10
print(" Admittance between buses 1 and 2 = - j%.4f per unit" %(-Y_12.imag))
print(" Admittance between buse 1 and reference bus = - j%.4f per unit" %(-Y_10.imag))
print(" Admittance between buse 2 and reference bus = - j%.4f per unit" %(-Y_20.imag))
Z = 1/Y_12 + 1/Y_10 + 1/Y_20
I = (Ea-Eb) / Z
print( "I = {0:.2f}".format(abs(I.real)))
print("Angle = %.2f v " %(math.degrees(math.atan2(I.imag,I.real))))
I1=complex(0.3278120,0.1092710)
Pa = Ea * I1

#Resluts
print(" Power out of source ''a'' = %.3f + j%.3f per unit " %(Pa.real,Pa.imag))
Pb = Eb * I1
print(" Power out of source ''b'' = %.3f - j%.3f per unit " %(Pb.real,-Pb.imag))
Var = (abs(I))**2 * (Z.imag)
print(" Reactie voltamperes in circuit equivalent = %.3f per unit " %Var)
V_1 = Ea - I/Y_10
print(" Voltage at node 1 = %.3f - j%.3f per unit " %(V_1.real,-V_1.imag))

 Admittance between buses 1 and 2 = - j0.0000 per unit
Admittance between buse 1 and reference bus = - j-0.0000 per unit
Admittance between buse 2 and reference bus = - j-0.0000 per unit
I = 0.11
Angle = -108.44 v
Power out of source ''a'' = 0.492 + j0.164 per unit
Power out of source ''b'' = 0.492 - j0.164 per unit
Reactie voltamperes in circuit equivalent = -0.000 per unit
Voltage at node 1 = 1.363 - j0.410 per unit