Beruflich Dokumente
Kultur Dokumente
1
k
+
Y
T
k
= Y
T
(5.1)
The branch self-admittance of bus j is obtained by the following equation.
Y
j
= Y
T
1 k
2
+
Y
T
k
=
Y
T
k
2
(5.2)
5.3 Transmission Line Admittance Data
The format for line admittance data is designed to show the line admittance matrix of the power
system network in Table 5.4. Columns 1 and 2 contain the bus numbers. Column 3 contains line
admittance between bus nl and bus nr. Column 4 contains branch admittance at bus nl in per
unit; while column 5 contains branch admittance at bus nr in per unit on the specied MVA base.
Introduction to PFATB 9
TABLE 5.4: Line Admittance Data Structure
Bus Bus Line Admittance BranchAdmittance BranchAdmittance
nl nr p.u. at bus nl p.u. at bus nr p.u.
5.4 Transmission Line Flow and Loss Data
The format for line ow and loss data is designed to show the nal solution of line ows and
losses for each line in a single row. Columns 1 and 2 contain bus numbers. Column 3 contains
the line power ows from bus nl to bus nr in per unit; while column 4 contains the line power
ows from bus nr to bus nl in per unit on the specied MVA base. The last column is for the
transmission line power losses between bus nr and bus nl.
TABLE 5.5: Line Flow and Loss Data Structure
Bus Bus Power Flow Power Flow Power Loss
nl nr nl to nr nr to nl MW Mvar
Let us illustrate an example to demonstrate the data preparation with standard data struc-
tures.
Figure 5.2 shows a single-line diagram of a 5-bus power system. Input data are given in Table
5.6, 5.7, 5.8, and the per-unit quantities are based on their own ratings. As shown in Table 5.6,
bus 5, to which a generator is connected, is the swing bus. Bus 4, to which a generator and a load
are connected, is a voltage-controlled bus. Buses 1,2 and 3 are load buses. Note that the load at
buses 1, 2 and 3 are inductive since Q
1
, Q
2
and Q
3
should be negative.
bus 4
bus 3 bus 2
bus 5
bus 1
j0.015
1:1.05
0.08+j0.30
j0.25
j0.25
j0.25
0.04+j0.25
0.1+j0.35
j0.030
2+j1 3.7+j1.3
1.6+j0.8
U =1.05
delta =0
5
5
T-L
T-R
Generator
Generator
1.05:1
j0.25
FIGURE 5.2: One-line Diagram of a 5-bus power system
10 Introduction to PFATB
TABLE 5.6: Bus Data
Bus Type Voltage Angle P
G
Q
G
P
L
Q
L
Q
Gmax
Q
Gmin
p.u. Degree MW Mvar MW Mvar Mvar Mvar
1 Load - - 0 0 1.6 0.8 - -
2 Load - - 0 0 2 1 - -
3 Load - - 0 0 3.7 1.3 - -
4 Controlled 1.05 - 5 - 0 0 -50 50
5 Swing 1.05 0 - - 0 0 -50 50
TABLE 5.7: Line Data
Bus R X 1/2 B Max MVA
to Bus p.u. p.u. p.u p.u.
1-2 0.04 0.25 0.25 12
1-3 0.01 0.35 0 12
2-3 0.08 0.30 0.25 12
TABLE 5.8: Transformer Data
Bus R X 1/2 B Tap Setting
to Bus p.u. p.u. p.u p.u.
2-4 0 0.015 0 1.05
3-5 0 0.030 0 1.05
For each bus k, determine which of the variables: voltage magnitude U
k
, phase angle
k
, net
real power P
k
and reactive power Q
k
are input data and which are unknowns. At each bus, two
of these variables are specied as input data, and the other two are unknowns to be computed by
the power-ow program.
The Table 5.9 and Table 5.10 are listed bus standard data for PFATB. The initial voltage mag-
nitude of each PQ bus labeled in type 1 estimate 1 and its phase angle estimates 0. The initial
voltage magnitude of each PV bus labeled in type 2 estimates 1.05 and its phase angle estimates
0, respectively. The initial voltage magnitude of the slack bus labeled in type 3 estimates 1.05
and its phase angle estimate 0. In Table 5.10, the initial voltage real part e of each PQ bus labeled
in type 1 estimates 1 and its imaginary part f estimates 0. The initial voltage real part e of each
PV bus labeled in type 2 estimates 1.05 and its imaginary part f estimates 0. The initial voltage
real part e of the slack bus labeled in type 3 estimates 1.05 and its imaginary part f estimates 0.
Note that bus 1-3 are load buses with no generations, and their real power P and reactive power
Q should be negative; on the contrary, if the power supplies to buses 1-3, P and Q are positive.
Let us discuss how to specify transformer data. In Figure 5.2, we nd that on the right of bus
4 is the entry of a two-winding transformer labeled as T-L, and on the left of bus 5 is the entry
of another two-winding transformer labeled as T-R. We may observe that T-L is a step-up trans-
former, while T-R is a step-down transformer. Owing to the dierence types of the transformers,
we discuss them in separate steps.
Figure 5.3 shows the PI equivalent circuit of the T-L transformer. We can calculate bus admit-
tance matrix of the T-L transformer as follows.
Introduction to PFATB 11
bus 4 bus 2
j0.015
1:1.05
bus 4 bus 2
High voltage Low voltage
YT/k
1-k
k
2
YT
k-1
k
YT
FIGURE 5.3: PI equivalent circuit of the T-L transformer
If we neglect the other branches on bus 2, we get
Y
44
= Y
T
=
1
j0.015
= j66.66
Y
22
=
Y
T
k
2
=
1
j0.015
1.05
2
= j60.46
Likewise, we calculate bus admittance matrix of the T-R transformer as follows.
bus 3 bus 5
j0.030
1.05:1
bus 3 bus 5
High voltage
Low voltage
YT/k
1-k
k
2
YT
k-1
k
YT
FIGURE 5.4: PI equivalent circuit of the T-R transformer
If we neglect the other branches on bus 3, we get
Y
55
= Y
T
=
1
j0.030
= j33.33
Y
33
=
Y
T
k
2
=
1
j0.030
1.05
2
= j30.23
In the process of the above calculations, we can draw a conclusion k
and B
.
Syntax
[B1,B2,Y] = Bpq(bus,line,nPQ,model)
Description
These are three methods introduced in Chapter 2 of [1] to handle bus admittance matrix used
in the real and reactive power fast decoupling power ow.
Introduction to PFATB 15
[B1,B2,Y] = Bpq(bus,line,nPQ,simplied) returns the bus admittance B
and B
with simpli-
ed method. The matrix B
and B
and B
with XB method
the resistance is ignored during the calculation of B
, expressed in (6.1)(6.4).
B
ij
=
1
x
ij
(6.1)
B
ii
=
n
ji
x
ij
(6.2)
B
ij
=
x
ij
r
2
ij
+x
2
ij
(6.3)
B
ii
=
n
ji
B
ij
(6.4)
[B1,B2,Y] = Bpq(bus,line,nPQ,BX) returns the bus admittance B
and B
with BX methodthe
resistance is ignored during the calculation of B
, expressed in (6.5)(6.8).
B
ij
=
x
ij
r
2
ij
+x
2
ij
(6.5)
B
ii
=
n
ji
x
ij
r
2
ij
+x
2
ij
(6.6)
B
ij
=
1
x
ij
(6.7)
B
ii
=
n
ji
B
ij
(6.8)
lineAM returns the line admittance matrix.
Syntax
YtYm = lineAM(line)
Description
YtYm = lineAM(line) returns line admittance matrix. The data structure of YtYm is tabulated
in Table 5.4.
Example 6.2
16 Introduction to PFATB
3
2
1
0.0125+j0.025
256.6MW
110.2Mvar
0.01+j0.03
0.02+j0.04
138.6MW 45.2Mvar
Slack Bus
V1=1.05 0
FIGURE 6.2: The impedance diagram of a simple system
As shown in Figure 6.2, the 3-bus power system is tested for bus admittance matrix by state-
ment commands busAM, Bpq and line admittance matrix by statement command lineAM. The
example is taken from [2] Example 6.7. The M-le ex2.m is the program codes to exemplify how
to present solutions of evaluating Y
bus
and Y
line
. Try the following:
% ex2.m
clc;
clear all
%% Bus data
% Bus Bus Voltage Angle Load Generator Injected
% No Type Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar
bus = [1 3 1.05 0 0 0 0 0 0 0 0
2 2 1 0 2.566 1.102 0 0 0 0 0
3 2 1 0 1.386 0.452 0 0 0 0 0];
%% Line data
% Bus Bus R X 1/2 B Tr.Tap Setting
% nl nr p.u. p.u. p.u. p.u.
line = [1 2 0.02 0.04 0 1
1 3 0.01 0.03 0 1
2 3 0.0125 0.025 0 1];
% Evaluate Ybus
Y = busAM(bus,line)
% Evaluate Ybus
nPQ = find(bus(:,2) == 2);
[B1,B2] = Bpq(bus,line,nPQ,'simplified')
[B1,B2] = Bpq(bus,line,nPQ,'XB')
[B1,B2] = Bpq(bus,line,nPQ,'BX')
% Evaluate Yline
YtYm = lineAM(line)
The ex2.m results in
Y =
20.0000 50.0000i 10.0000 +20.0000i 10.0000 +30.0000i
10.0000 +20.0000i 26.0000 52.0000i 16.0000 +32.0000i
10.0000 +30.0000i 16.0000 +32.0000i 26.0000 62.0000i
Introduction to PFATB 17
B1 =
50 20
20 52
B2 =
50 20
20 52
B1 =
58.3333 25.0000
25.0000 65.0000
B2 =
50 20
20 52
B1 =
50 20
20 52
B2 =
58.3333 25.0000
25.0000 65.0000
YtYm =
Columns 1 through 4
1.0000 2.0000 10.0000 20.0000i 0
1.0000 3.0000 10.0000 30.0000i 0
2.0000 3.0000 16.0000 32.0000i 0
Column 5
0
0
0
6.2 Execute Algorithms
The algorithms in PFATB toolbox are Gauss-Seidel algorithm, Newton-Raphson algorithm and
P-Q decoupling algorithm. In each algorithm, it is useful to decompose major tasks into subtasks
that do specic parts of the main task. So does the major algorithm program. It is much eas-
ier to read subprograms that a fewer lines, than one large main program that doesnt segregate
the subtasks eectively, particularly if all the power ow algorithms to be solved are relatively
complicated. Each subtask are designed so that it can be evaluated in the testing phase of the
design process. As an addition, the specications and the brief descriptions of function purpose
are added enough in comments to provide the functions task so as to remind you exactly what
was done and for what purpose.
busVnewPQ returns new bus voltage at each PQ bus in Gauss-Seidel algorithm.
Syntax
busV_PQ = busVnewPQ(busV,Y,P,Q,n,nPQ)
Description
busV_PQ = busVnewPQ(busV,Y,P,Q,n,nPQ) returns new bus voltage at each PQ bus from the
following equation.
U
(k+1)
i
=
P
i
jQ
i
U
(k)
i
j=1
Y
ij
U
(k+1)
j
Y
ii
(i j) (6.9)
where i indicates bus i is a only PQ bus in system.
18 Introduction to PFATB
busVnewPV returns new bus voltage and reactive power of each PV bus in Gauss-Seidel algo-
rithm.
Syntax
[busV_PV,Q_PV] = busVnewPV(busV,bus0,Y,P,Q,n,nPQ)
Description
[busV_PV,Q_PV] = busVnewPV(busV,bus0,Y,P,Q,n,nPQ) returns newbus voltage and reactive
power of each PV bus from the following equation.
U
(k+1)
i
=
P
i
jQ
i
U
(k)
i
j=1
Y
ij
U
(k+1)
j
Y
ii
(i j) (6.10)
where i indicates bus i is a only PV bus in system.
Q
(k+1)
i
=
_
_
U
(k)
i
[U
(k)
i
Y
ii
+
n
j=1
Y
ij
U
(k+1)
j
]
_
_
(i j) (6.11)
where i indicates bus i is a only PV bus in system.
dPQpm returns P
i
and Q
is
respectively from real power mismatch equations in Newton-
Rapson with polar coordinate method.
Syntax
[delta_P,delta_Q] = dPQpm(bus,nPQ,Y)
Description
[delta_P,delta_Q] = dPQpm(bus,nPQ,Y) returns P
i
and Q
is
respectively from real power
mismatch equations as follows. Note that P
i
contains each PV and PQ bus, and Q
is
only
contains each PQ bus.
P
i
= P
is
P
i
= P
is
U
i
n
j=1
U
j
(G
ij
cos
ij
+B
ij
sin
ij
) (6.12)
Q
is
= Q
is
Q
i
+Q
vari
= Q
is
+Q
vari
U
i
n
j=1
U
j
(G
ij
sin
ij
B
ij
cos
ij
) (6.13)
where P
is
,Q
is
are the active power and reactive power supplied from generations. Q
vari
is the
injected reactive power from shunt capacitors like capacitors, SVC and so forth.
dPQcm returns P, Q and U
2
respectively from real power mismatch equations in Newton-
Rapson with rectangular coordinate method.
Syntax
[delta_P,delta_Q,delta_U] = dPQcm(bus,bus0,nPQ,Y)
Introduction to PFATB 19
Description
[delta_P,delta_Q,delta_U] = dPQcm(bus,bus0,nPQ,Y) returns P, Q and U
2
respectively
from real power mismatch equations as follows.
For each PQ bus, dPQcm evaluates the following power mismatch equations
P
i
= P
is
P
i
= P
is
e
i
n
j=1
(G
ij
e
j
B
ij
f
j
) f
i
n
j=1
(G
ij
f
j
+B
ij
e
j
) (6.14)
Q
i
= Q
is
+Q
vari
Q
i
= Q
is
+Q
vari
f
i
n
j=1
(G
ij
e
j
B
ij
f
j
) +e
i
n
j=1
(G
ij
f
j
+B
ij
e
j
) (6.15)
For each PV bus, dPQcm evaluates the following power mismatch equations
P
PV
= P
PV0
P
PV
= P
PV0
e
PV
n
j=1
(G
PVj
e
j
B
PVj
f
j
) f
PV
n
j=1
(G
PVj
f
j
+B
PVj
e
j
) (6.16)
U
2
PV
= U
2
PV0
U
2
PV
= U
2
PV0
(f
2
PV
+e
2
PV
) (6.17)
Jacpm returns Jacobian submatrix elements of H,N,K,L in Newton-Rapson with polar coordi-
nate method.
Syntax
J = Jacpm(bus,Y,nPQ)
Description
J = Jacpm(bus,Y,nPQ) returns the Jacobian submatrix H,N,K,L equations as follows.
H
ij
= U
i
U
j
(G
ij
sin
ij
B
ij
cos
ij
) (i j) (6.18)
H
ii
= U
2
i
B
ii
+Q
i
(i = j) (6.19)
N
ij
= U
i
U
j
(G
ij
cos
ij
B
ij
sin
ij
) (i j) (6.20)
N
ii
= U
2
i
G
ii
P
i
(i = j) (6.21)
K
ij
= U
i
U
j
(G
ij
cos
ij
B
ij
sin
ij
) (i j) (6.22)
K
ii
= U
2
i
G
ii
P
i
(i = j) (6.23)
L
ij
= U
i
U
j
(G
ij
sin
ij
B
ij
cos
ij
) (i j) (6.24)
L
ii
= U
2
i
B
ii
Q
i
(i = j) (6.25)
20 Introduction to PFATB
where
P
i
= U
i
n
j=1
U
j
(G
ij
cos
ij
+B
ij
sin
ij
)
Q
i
= U
i
n
j=1
U
j
(G
ij
sin
ij
B
ij
cos
ij
)
The element H
ij
=
P
i
j
indicates that the PQ buses and the PV buses are both included in the
rows and columns of H. H is a (n-1)(n-1) matrix.
The element N
ij
=
P
i
U
j
U
j
indicates that the PQ buses and the PV buses are included in the
rows of N, and also the PQ buses are included in the columns of N. L is a (n-1)(n-1-nPV) matrix.
The element K
ij
=
Q
i
j
indicates that the PQ buses are included in the rows of K, and also
the PQ buses and the PV buses are included in the columns of K. K is a (n-1-nPV)(n-1) matrix.
The element L
ij
=
Q
i
U
j
U
j
indicates that the PQ buses are included in the rows of L, and also
the PQ buses are included in the columns of L. L is a (n-1-nPV)(n-1-nPV) matrix.
Jaccm returns Jacobian submatrix elements of H,N,K,L,R,S in Newton-Rapson with rectangular
coordinate method.
Syntax
J = Jaccm(bus,Y,nPQ)
Description
J = Jaccm(bus,Y,nPQ) returns Jacobian submatrix H,N,K,L,R,S equations as follows.
H
ij
= (G
ij
e
i
+B
ij
f
i
) (i j) (6.26)
H
ii
=
n
j=1
(G
ij
e
j
B
ij
f
j
) G
ii
e
i
B
ii
f
i
(i = j) (6.27)
N
ij
= (G
ij
f
i
B
ij
e
i
) (i j) (6.28)
N
ii
=
n
j=1
(G
ij
f
j
+B
ij
e
j
) G
ii
e
i
+B
ii
f
i
(i = j) (6.29)
K
ij
= G
ij
e
i
+B
ij
f
i
(i j) (i j) (6.30)
K
ii
=
n
j=1
(G
ij
f
j
+B
ij
e
j
) G
ii
f
i
+B
ii
e
i
(i = j) (6.31)
Introduction to PFATB 21
L
ij
= G
ij
f
i
B
ij
e
i
(i j) (6.32)
L
ij
= 0 (i j) (6.33)
L
ii
= 2e
i
(i = j) (6.34)
R
ij
= 0 (i j) (6.35)
R
ii
= 2f
i
(i = j) (6.36)
The element H
ij
=
P
i
f
j
indicates that the PQ buses and the PV buses are both included in the
rows and columns of H. H is a (n-1)(n-1) matrix.
The element N
ij
=
P
i
e
j
indicates that the PQ buses and the PV buses are both included in the
rows and columns of N. N is a (n-1)(n-1) matrix.
The element K
ij
=
Q
i
f
j
indicates that the PQ buses are included in the rows of K, and also the
PQ bus and the PV buses are both included in the columns of K. K is a (n-1-nPV)(n-1) matrix.
The element L
ij
=
Q
i
e
j
indicates that the PQ buses are included in the rows of L, and also the
PQ buses and the PV buses are both included in the columns of L. L is a (n-1-nPV)(n-1) matrix.
The element R
ij
=
U
2
p
e
j
indicates that the PV buses are included in the rows of R, and also
the PQ buses and the PV buses are both included in the columns of R. R is a (nPV)(n-1) matrix.
The element S
ij
=
U
2
p
f
j
indicates its dimension is the same as R .
HLpq returns Jacobian submatrix H,L in P-Q fast decoupling with polar coordinate method.
Syntax
[H,L] = HLpq(bus,nPQ,B1,B2)
Description
[H,L] = HLpq(bus,nPQ,B1,B2) returns Jacobian submatrix H,L equations as follows.
P = H = UB
U (6.37)
Q = LU
1
U = UB
U (6.38)
dAM returns and U in Newton-Rapson with polar coordinate method.
Syntax
[dU,dAng] = dAM(bus,nPQ,Jacobi,delta_P,delta_Q)
Description
22 Introduction to PFATB
[dU,dAng] = dAM(bus,nPQ,Jacobi,delta_P,delta_Q) returns and U by solving the power
ow matrix equation as follows.
_
P
Q
_
=
_
H N
K L
__
U
1
U
_
(6.39)
where
_
P
Q
_
=
_
_
P
1
P
2
.
.
.
P
n1
Q
1
Q
2
.
.
.
Q
n1nPV
_
_
_
H N
K L
_
=
_
_
H
1,1
H
1,2
. . . H
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
H
n1,1
H
n1,2
. . . H
n1,n1
N
1,1
N
1,2
. . . N
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
N
n1,1
N
n1,2
. . . N
n1,n1nPV
K
1,1
K
1,2
. . . K
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
K
n1nPV,1
K
n1nPV,2
. . . K
n1nPV,n1
L
1,1
L
1,2
. . . L
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
L
n1nPV,1
L
n1nPV,2
. . . L
n1nPV,n1nPV
_
_
_
U
1
U
_
=
_
2
.
.
.
n1
U
1
U
1
U
1
U
2
.
.
.
U
1
U
n1
_
_
dPQU returns e and f in Newton-Raphson with rectangular coordinate method.
Syntax
[df,de] = dPQU(bus,Jacobi,delta_P,delta_Q,delta_U)
Description
[df,de] = dPQU(bus,Jacobi,delta_P,delta_Q,delta_U) returns e and f by following equa-
tions.
_
_
P
Q
U
2
_
_
=
_
_
H N
K L
R S
_
_
_
e
f
_
(6.40)
Introduction to PFATB 23
where
_
_
P
Q
U
2
_
_
=
_
_
P
1
P
2
.
.
.
P
n1
Q
1
Q
2
.
.
.
Q
n1nPV
U
2
1
U
2
2
.
.
.
U
2
nPV
_
_
_
_
H N
K L
R S
_
_
=
_
_
H
11
H
12
. . . H
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
H
n1,1
H
n1,2
. . . H
n1,n1
N
11
N
12
. . . N
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
N
n1,1
N
n1,2
. . . N
n1,n1
K
11
K
12
. . . K
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
K
n1nPV,1
K
n1nPV,2
. . . K
n1nPV,n1
L
11
L
12
. . . L
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
L
n1nPV,1
L
n1nPV,2
. . . L
n1nPV,n1
R
11
R
12
. . . R
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
R
nPV,1
R
nPV,2
. . . R
nPV,n1
S
11
S
12
. . . S
1,n1
.
.
.
.
.
.
.
.
.
.
.
.
S
nPV,1
S
nPV,2
. . . S
nPV,n1
_
_
_
f
e
_
=
_
_
f
1
f
2
.
.
.
f
n1
e
1
e
2
.
.
.
e
n1
_
_
dApq returns in P-Q fast decoupling with polar coordinate method.
Syntax
dAng = dApq(bus,H,delta_P)
Description
dAng = dApq(bus,H,delta_P) returns by the following equation.
P = UB
U (6.41)
dMpq returns U in P-Q fast decoupling with polar coordinate method.
Syntax
24 Introduction to PFATB
dU = dMpq(bus,nPQ,L,delta_Q)
Description
dU = dMpq(bus,nPQ,L,delta_Q) returns U by the following equation.
Q = UB
U (6.42)
changePVpm examines reactive power of each PV bus in Newton-Raphson with polar coordi-
nate method.
Syntax
bus_new = changePVpm(bus,Y,nPQ,k)
Description
bus_new= changePVpm(bus,Y,nPQ,k) examines reactive power of each PVbus. If the reactive
power of the PV bus exceeds the generations boundaries of secure limitations within the mini-
mum and maximum, the controlled voltages of the PV bus should drop voltage magnitudes to
balance reactive power in power system.
changePVcm examines reactive power of each PV bus in Newton-Raphson with rectangular co-
ordinate method.
Syntax
bus0_new = changePVcm(bus,bus0,Y,nPQ,k)
Description
bus0_new = changePVcm(bus,bus0,Y,nPQ,k) examines reactive power of each PV bus. If the
reactive power of the PV bus exceeds the generations boundaries of secure limitations within the
minimumand maximum, the controlled voltages of each PV bus should drop voltage magnitudes
to balance reactive power in power system.
powerSW returns active power and reactive power of the swing bus in Gauss-Seidel algorithm.
Syntax
S = powerSW(busV,Y,n)
Description
S = powerSW(busV,Y,n) returns active power and reactive power of the swing bus in Gauss-
Seidel algorithm by using (6.9).
dPQSWPVpm returns reactive power of each PV bus and active power and reactive power of the
swing bus with polar coordinate method.
Syntax
bus = dPQSWPVpm(bus,Y,nPQ)
Description
Introduction to PFATB 25
bus = dPQSWPVpm(bus,Y,nPQ) returns reactive power of each PV bus and active power and
reactive power of the swing bus by the following equations.
After the iterative solution of bus voltage, the next step is to separate the complex power
equation (6.43) into real part and imaginary part to obtain reactive power of each PV bus and
active power and reactive power of the swing bus.
S
s
=
U
s
n
j=1
(Y
sj
U
j
)
(6.43)
At each PV bus, imaginary part of (6.43) is specied as the reactive power equation as follows.
Q
PV
=
n
j=1
U
PV
U
j
(G
PVj
sin(
PV
j
) B
PVj
cos(
PV
j
)) Q
PVl
Q
PVs
(6.44)
where Q
PVl
are the load reactive power and are negative. Q
PVs
are the injected reactive power
from shunt capacitors and are positive. Note that U
PV
PV
is the balanced voltage of the PV bus.
At the swing bus, real part and imaginary part of (6.43) are specied as the reactive power
equation and active power equation, respectively.
P
SW
=
n
j=1
U
SW
U
j
(G
PVj
cos(
SW
j
) +B
PVj
sin(
SW
j
)) P
SWl
(6.45)
Q
SW
=
n
j=1
U
SW
U
j
(G
SWj
sin(
SW
j
) B
SWj
cos(
SW
j
)) Q
SWl
(6.46)
where P
SWl
,Q
SWl
are the load active power and reactive power, and they are generally equal to
zero. Note that U
SW
SW
is the balanced voltage of the swing bus.
dPQSWPVcm returns reactive power of each PV bus and active power and reactive power of the
swing bus with rectangular coordinate method.
Syntax
bus = dPQSWPVcm(bus,Y,nPQ)
Description
bus = dPQSWPVcm(bus,Y,nPQ) returns reactive power of each PV bus and active power and
reactive power of the swing bus by the following equations.
After the iterative solution of bus voltage, the next step is to separate the complex power
equation (6.43) into real part and imaginary part to obtain reactive power of each PV bus and
active power and reactive power of the swing bus.
At each PV bus, imaginary part of (6.33) is specied as the reactive power equation as follows.
Q
PV
= f
PV
n
j=1
B
PVj
f
PVj
+e
PV
n
j=1
B
PVj
e
PVj
Q
PVl
Q
PVs
(6.47)
where Q
PVl
are the load reactive power and are negative. Q
PVs
are the injected reactive power
from shunt capacitors and are positive. Note that e
PV
+jf
PV
is the balanced voltage of the PV bus.
26 Introduction to PFATB
At the swing bus, real part and imaginary part of (6.43) are specied as the reactive power
equation and active power equation, respectively.
P
SW
= e
SW
n
j=1
B
SWj
f
SWj
f
SW
n
j=1
B
SWj
e
SWj
P
SWl
(6.48)
Q
SW
= f
SW
n
j=1
B
SWj
f
SWj
+e
SW
n
j=1
B
SWj
e
SWj
Q
SWl
(6.49)
where P
SWl
,Q
SWl
are the load active power and reactive power, and they are generally equal to
zero. Note that e
SW
+jf
SW
is the balanced voltage of the swing bus.
6.3 Data Reconguration
resetbus returns each bus numbers to the original bus numbers in the bus data matrix and the
line data matrix.
Syntax
[bus_temp,line_temp] = resetbus(bus,line,nodenum)
Description
[bus_temp,line_temp] = resetbus(bus,line,nodenum) returns each bus numbers back to the
original bus numbers in the bus data matrix and the line data matrix.
6.4 Output Solution
powerTSpm returns transmission power line ow and loss with polar coordinate method.
Syntax
S_res = powerTSpm(bus,line,YtYm)
Description
S_res = powerTSpm(bus,line,YtYm) returns transmission line power ow and loss in the for-
mat of Table 5.5 by using the following equations.
i j
Z
T
B
2
B
2
delta S
ij
~
S
~
U
j U
i
S
ij
~
ji
FIGURE 6.3: Transmission line ow and loss
Transmission line ow
Introduction to PFATB 27
In Figure 6.3,
S
ij
are the injected complex powers from bus i to bus j. The load ow from bus
number i to bus number j can be expressed as
S
ij
=
U
i
[
U
i
Y
i0
+(
U
i
U
j
)Y
ij
]
(6.50)
Rearranging (6.50) we can get
S
ij
=
U
2
i
(Y
ij
+Y
i0
)
U
i
U
j
Y
ij
(6.51)
Similarly,
S
ji
are the injected complex powers from bus j to bus i as also shown in Figure 6.3.
The load ow from bus number j to bus number i can be expressed as
S
ji
=
U
j
[
U
j
Y
j0
+(
U
j
U
i
)Y
ji
]
(6.52)
Rearranging (6.52) we can get
S
ji
=
U
2
j
(Y
ji
+Y
j0
)
U
j
U
i
Y
ji
(6.53)
Transmission line loss
Transmission line power loss
S
ij
can be expressed as
S
ij
=
S
ij
+
S
ji
(6.54)
powerTScm returns transmission line power ow and loss with rectangular coordinate method.
Syntax
S_res = powerTScm(bus,line,YtYm)
Description
S_res = powerTScm(bus,line,YtYm) returns transmission line power ow and loss in the for-
mat of Table 5.5 by using equations (6.51), (6.53) and (6.54).
busout outputs each bus voltage magnitude and phase angle and its active and reactive power.
Note that this function is a built-in function for Gauss-Seidel algorithm, Newton-Raphson algo-
rithm and P-Q decoupling algorithm.
Syntax
busout(bus_res,delta_P,delta_Q,n,k)
Description
busout(bus_res,delta_P,delta_Q,n,k) outputs each bus voltage magnitudes and phase angles
and its active and reactive powers in tabulated format(See Section 7).
lineow outputs each transmission line power ow and loss. Note that this function is a built-in
function for Gauss-Seidel algorithm, Newton-Raphson algorithm and P-Q decoupling algorithm.
Syntax
lineflow(s_res,n)
Description
lineow(s_res,n) outputs each transmission line power ow and loss in the format of Table
5.5(See Section 7).
28 Introduction to PFATB
busiter displays each bus increments at each iteration. Note that this function is a built-in func-
tion for Gauss-Seidel algorithm, Newton-Raphson algorithm and P-Q decoupling algorithm.
Syntax
busiter(cell_bus,nodenum,n,k)
Description
busiter(cell_bus,nodenum,n,k) displays each bus increments at each iteration(See Section 7).
Introduction to PFATB 29
7 POWER FLOW ALGORITHMS
This section demonstrates how power ow algorithms can be constructed in steps and using
routines from PFATB toolbox to solve power ow problems.
7.1 Algorithm Convergence Speed
We dene the sum of real and reactive power mismatch of each bus at each iterations as the
convergent speed until the iteration is terminated in the tolerance condition. The graph is con-
structed to show the algorithm performance on convergence by using the following equations.
Algorithm convergence speed in polar coordinate:
Speed(U) =
_
nnPV1
i=1
U
2
(7.1)
Speed() =
_
n1
i=1
2
(7.2)
Algorithm convergence speed in rectangular coordinate:
Speed(e) =
_
n1
i=1
e
2
(7.3)
Speed(f ) =
_
n1
i=1
f
2
(7.4)
30 Introduction to PFATB
7.2 Gauss-Seidel Algorithm
The function GS.m returns to solve power ow in Gauss-Seidel algorithm.
Power-ow Programming Steps
Step 1: Input raw data. Input the electrical grid data in the standard data structure and
estimate start points of the remaining undened bus magnitude and phase angle.
Step 2: Data regeneration. Line data and bus data are specied to change along with bus
numbers simultaneously.
Step 3: Evaluate Y
bus
. Evaluate bus admittance matrix.
Step 4: Evaluate new bus voltage at each PQ bus. Evaluate new bus voltage real part e
i
and
new bus voltage imaginary part f
i
from nonlinear equation (6.9) at each PQ bus.
Step 5: Update variables. Replace the precious bus voltage by substituting new bus voltage
at each PQ bus evaluated from step 4.
Step 6: Evaluate new bus voltage and reactive power at each PV bus. Evaluate U
i
and Q
i
from nonlinear equation (6.10) and (6.11) at each PV bus.
Step 7: Evaluate Q. Evaluate Q
(k+1)
i
by using the following equation.
Q
(k+1)
i
= Q
(k+1)
i
Q
(k)
i
(7.5)
Step 8: Update variables. Replace the precious bus voltage by substituting new bus voltage
at each PV bus evaluated from Step 6.
Step 9: Termination conditions. The process is continued until the residuals Q
(k)
i
, evaluated
from Step 7, are less than tolerance accuracy as follows.
max|Q
(k)
i
| < (7.6)
Note that is the small positive constant, such as 0.001,0.00001, and the smaller numbers are
pretty more accurate.
Step 10: Evaluate power of the swing bus. Evaluate active power and reactive power of the
swing bus by using (6.9).
Step 11: Recongure bus numbers. Return each bus number to the original bus number in
bus data matrix and the line data matrix.
Step 12: Evaluate line ow and loss. Evaluate real and reactive power ows in transmission
lines and transformers, as well as equipment losses.
Step 13: Output solution. Show the nal voltage magnitude and phase angle at each bus
under balanced three-phase steady-state conditions.
Power-ow Program Function
A complete pseudo-code M-le GS.m of Gauss-Seidel algorithm is shown below.
function [bus_res,s_res,k] = GS(bus,line,EPS,kmax)
% GaussSeidel Algorithm
% [BUS_RES,S_RES,K] = GS(BUS,LINE,EPS,KMAX) returns the final bus voltage real part e
% and imaginary part f and line flow and loss.
%
% [bus_res,S_res,k] = GS(bus,line) returns bus voltage bus_res, line flow and loss S_res,
% iteration k at EPS=1.0e6 and kmax = 100 in default.
%
% See also sortbus,busAM,busVnewPQ,busVnewPV,powerSW,resetbus,lineAM,powerTScm
Introduction to PFATB 31
% Author(s):Chao Lei
% $Date:2011/02/02 02:40$
if nargin < 2
error('Please input 2 variables');
end
if nargin == 2
EPS = 1.0e6; % Tolerance Accuracy
kmax = 100; % Maximum iterations
elseif nargin == 3
kmax = 100; % Maximum iterations
end
format long
[bus,line,nPQ,nPV,nodenum] = sortbus(bus,line); % Step 2: Data Regeneration
n = nPQ+nPV+1;
Y = busAM(bus,line); % Step 3: Evaluate Ybus
% Sparse Symmetric Matrix Figure
clf;
figure(1)
spy(Y);
title('Ybus Sparse Symmetric Matrix')
nz = nnz(Y);
pct = 100 / numel(Y);
xlabel(sprintf('nonzeros=%d (%.3f%%)',nz,nz
*
pct));
grid on
j = sqrt(1);
busV = zeros(n,1);
% Complex power expressed in rectangular coordinate
busV = bus(1:n,3).
*
(cos(bus(1:n,4))+j
*
sin(bus(1:n,4)));
busV_temp = zeros(n,1);
busV_PV = busV(nPQ+1:n1,1); % Preallocate
busV_PQ = busV(1:nPQ,1);
de = zeros(n,1); % Preallocate
df = zeros(n,1);
P = zeros(n1,1);
Q = zeros(n1,1);
P = bus(1:n1,5)+bus(1:n1,7); % Active power P
Q = bus(1:n1,6)+bus(1:n1,8)+bus(1:n1,11); % Reactive power Q
% The Constant voltage magnitude of each PV bus
bus0 = zeros(n1nPQ,1);
bus0(:,1) = bus(nPQ+1:n1,3);
k = 1;
while (k kmax)
% Step 4: Evaluate new bus voltage at each PQ bus
busV_PQ = busVnewPQ(busV,Y,P,Q,n,nPQ);
32 Introduction to PFATB
busV = [busV_PQ;busV_PV;bus(n,3)+j
*
bus(n,4)]; % Step 5: Update Variables
% Step 6: Evaluate new bus voltage at each PV bus
[busV_PV,Q_PV] = busVnewPV(busV,bus0,Y,P,Q,n,nPQ);
dQ = Q_PV Q(nPQ+1:n1,1); % Step 7: Evaluate delta Q
% Record Q for comparison at next iteration
Q(nPQ+1:n1,1) = Q_PV;
busV = [busV_PQ;busV_PV;bus(n,3)+j
*
bus(n,4)]; % Step 8: Update Variables
de = real(busV busV_temp); % Evaluate delta e and delta f
df = imag(busV busV_temp);
dfrd(k,:) = df'; % Record the delta e and delta f
derd(k,:) = de';
% Record bus for comparison at next iteration
busV_temp = busV;
if (max(abs(dQ))<EPS); % Step 9: Termination Conditions
break
end
% k equals kmax or not
if (k == kmax);
disp('Solution is not accurate.Please increase the maximum iterations in INPUT argument.')
break;
end
% Save Increments at each iteration
bus_k = zeros(n1,6);
bus_k(:,1) = real(busV(n1,:));
bus_k(:,2) = imag(busV(n1,:));
bus_k(:,3) = de(n1,:);
bus_k(:,4) = df(n1,:);
bus_k(:,5) = Q bus(1:n1,6);
bus_k(nPQ+1:n1,6) = dQ;
[row,column] = size(bus_k);
for i = 1:column
cell_bus{k,i} = bus_k(:,i);
end
k = k+1; % Increase iterations
end
% Show the graph of algorithm convergence
xk = [1:k];
dfrd_sq = sqrt(sum(dfrd.^2,2));
derd_sq = sqrt(sum(derd.^2,2));
figure(2)
plot(xk,dfrd_sq,'k',xk,derd_sq,'k','LineWidth',2)
title('The Convergence Speed of GaussSeidel Algorithm')
xlabel('Iterations');
ylabel('Speed');
legend('E Increments','F Increments')
grid on
Introduction to PFATB 33
% Step 10: Evaluate Power of the swing bus
S = powerSW(busV,Y,n);
% Allocate and update variables into bus matrix
bus(:,3) = real(busV);
bus(:,4) = imag(busV);
bus(n,7) = real(S);
bus(n,8) = imag(S);
bus(nPQ+1:n1,8) = Q(nPQ+1:n1,1) bus(nPQ+1:n1,6);
% Step 11: Reconfigure Bus Numbers
[bus_temp,line_temp] = resetbus(bus,line,nodenum);
% Step 12: Evaluate line flow and loss
YtYm = lineAM(line_temp);
s_res = powerTScm(bus_temp,line_temp,YtYm);
bus_res = bus_temp;
% Step 13: Output Solution
format short
% Output Bus Solution
disp(' ')
disp(' Power Flow Solution by GaussSeidel Algorithm')
busout(bus_res,dQ,n,k);
% Output Line Solution
disp(' ')
disp(' Transmission Line Flow and Loss')
lineflow(s_res,n);
% Display output at each iteration
disp(' ')
disp(' Display output at each iteration')
busiter(cell_bus,nodenum,n,k)
% Subfunction
busout(bus_res,dQ,n,k)
fprintf(' Maximum Active Power Mismatch = %g \n', max(abs(dQ)))
fprintf(' No. of Iterations = %g \n\n', k)
head =[' Bus Real Imaginary Load Generation Injected'
' No. E F MW Mvar MW Mvar Mvar '
' '];
disp(head)
for i = 1:n
fprintf(' %5g', bus_res(i,1)), fprintf(' %7.3f', bus_res(i,3)),
fprintf(' %8.3f', bus_res(i,4)), fprintf(' %9.3f', bus_res(i,5)),
fprintf(' %9.3f', bus_res(i,6)), fprintf(' %9.3f', bus_res(i,7)),
fprintf(' %9.3f ', bus_res(i,8)), fprintf(' %8.3f\n',bus_res(i,11))
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f', sum(bus_res(:,5))),
fprintf(' %9.3f', sum(bus_res(:,6))),
fprintf(' %9.3f', sum(bus_res(:,7))),
fprintf(' %9.3f', sum(bus_res(:,8))),
fprintf(' %9.3f\n\n',sum(bus_res(:,11)))
% Subfunction
function lineflow(s_res,n)
34 Introduction to PFATB
head =[' '
' Bus Bus Power Flow Power Flow Power Loss'
' nl. nr. nl to nr nr to nl MW Mvar '
' '];
disp(head)
for i = 1:n
fprintf(' %5g', s_res(i,1)), fprintf(' %5.0f', s_res(i,2)),
fprintf(' %9.3f+j%7.3f', real(s_res(i,3)),imag(s_res(i,3))),
fprintf(' %9.3f+j%7.3f', real(s_res(i,4)),imag(s_res(i,4))),
fprintf(' %9.3f', real(s_res(i,5))),
fprintf(' %9.3f\n', imag(s_res(i,5))),
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f+j%7.3f', sum(real(s_res(i,3))),sum(imag(s_res(i,3)))),
fprintf(' %9.3f+j%7.3f', sum(real(s_res(i,4))),sum(imag(s_res(i,4)))),
fprintf(' %9.3f', sum(real(s_res(:,5)))),
fprintf(' %9.3f\n\n', sum(imag(s_res(:,5))))
% Subfunction
function busiter(cell_bus,nodenum,n,k)
for i = 1:n1
disp(' ')
fprintf(' Display each iteration at bus %g \n\n', nodenum(i,2))
head =[' Iter Real Imaginary Delta Delta Delta Delta '
' No. E F E F P Q '
' '];
disp(head)
for m = 1:k1
fprintf(' %6.4g', m),
fprintf(' %10.5f', cell_bus{m,1}(i,:)),
fprintf(' %10.5f', cell_bus{m,2}(i,:)),
fprintf(' %9.5f', cell_bus{m,3}(i,:)),
fprintf(' %9.5f', cell_bus{m,4}(i,:)),
fprintf(' %9.5f', cell_bus{m,5}(i,:)),
fprintf(' %9.5f\n', cell_bus{m,6}(i,:))
end
end
Example 7.1
This example is taken from [2] Example 6.8. Figure 7.1 shows the one-line diagram of a simple
three-bus power system with generators at buses 1 and 3. The magnitude of voltage as bus 1 is
adjusted to 1.05 per unit. Voltage magnitude at bus 3 is xed at 1.04 pu with a real power
generation of 200MW. A load consisting of 400MW and 250Mvar is taken from bus 2. Line
impedances are marked in per unit on a 100 MVA base, and the line charging susceptances are
neglected. Obtain the power ow solution by N-R algorithm with polar method. The M-le
ex2.m is the program codes to exemplify how to present solutions of power ow.
Estimate start points of the remaining bus magnitude and phase angle as follows.
TABLE 7.1: The initial estimations of bus magnitude and phase angle
bus number 1 2 3
U
(0)
(0)
1.050
10
1.040
Introduction to PFATB 35
3
2 1
400MW
250Mvar
0.02+j0.04
0.01+j0.03 0.0125+j0.025
Slack Bus
200MW
V
1
=1.05 0
V
3
= 1.04
FIGURE 7.1: One-line diagram of 3-bus system
Let us evaluate this example by calling GS.m to output solutions. Try the following:
% ex7.1.m
clc;
clear all
%% Bus data
% Bus Bus Voltage Angle Load Generator Injected
% No Type Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar
bus = [1 3 1.05 0 0 0 0 0 3.5 3.5 0
2 1 1 0 4 2.5 0 0 0 0 0
3 2 1.04 0 0 0 2 0 3.5 3.5 0];
%% Line data
% Bus Bus R X 1/2 B Tr.tap Setting
% nl nr p.u. p.u. p.u. p.u.
line = [1 2 0.02 0.04 0 1
1 3 0.01 0.03 0 1
2 3 0.0125 0.025 0 1];
%% GaussSeidel Algorithm
[bus_res,s_res,k] = GS(bus,line)
Try it out and then it results in
Power Flow Solution by GaussSeidel Algorithm
Maximum Reactive Power Mismatch = 5.13925e007
No. of Iterations = 21
Bus Real Imaginary Load Generation Injected
No. E F MW Mvar MW Mvar Mvar
1 1.050 0.000 0.000 0.000 2.184 1.409 0.000
2 0.971 0.046 4.000 2.500 0.000 0.000 0.000
3 1.040 0.009 0.000 0.000 2.000 1.462 0.000
Total 4.000 2.500 4.184 2.870 0.000
Transmission Line Flow and Loss
36 Introduction to PFATB
Bus Bus Power Flow Power Flow Power Loss
nl. nr. nl to nr nr to nl MW Mvar
1 2 1.794+j 1.187 1.710+j 1.019 0.084 0.168
1 3 0.391+j 0.221 0.389+j 0.216 0.002 0.005
2 3 2.290+j 1.481 2.389+j 1.677 0.098 0.197
Total 2.290+j 1.481 2.389+j 1.677 0.184 0.370
Display output at each iteration
Display each iteration at bus 2
Iter Real Imaginary Delta Delta Generation Delta
No. E F E F Mvar Q
1 1.04000 0.00125 1.04000 0.00125 0.00000 0.00000
2 1.03999 0.00376 0.00001 0.00501 0.00000 0.00000
3 1.03998 0.00647 0.00001 0.00271 0.00000 0.00000
4 1.03997 0.00770 0.00001 0.00123 0.00000 0.00000
5 1.03997 0.00837 0.00001 0.00066 0.00000 0.00000
6 1.03996 0.00870 0.00000 0.00034 0.00000 0.00000
7 1.03996 0.00887 0.00000 0.00017 0.00000 0.00000
8 1.03996 0.00896 0.00000 0.00009 0.00000 0.00000
9 1.03996 0.00901 0.00000 0.00005 0.00000 0.00000
10 1.03996 0.00903 0.00000 0.00002 0.00000 0.00000
11 1.03996 0.00904 0.00000 0.00001 0.00000 0.00000
12 1.03996 0.00905 0.00000 0.00001 0.00000 0.00000
13 1.03996 0.00905 0.00000 0.00000 0.00000 0.00000
14 1.03996 0.00905 0.00000 0.00000 0.00000 0.00000
15 1.03996 0.00905 0.00000 0.00000 0.00000 0.00000
16 1.03996 0.00905 0.00000 0.00000 0.00000 0.00000
17 1.03996 0.00905 0.00000 0.00000 0.00000 0.00000
18 1.03996 0.00905 0.00000 0.00000 0.00000 0.00000
19 1.03996 0.00905 0.00000 0.00000 0.00000 0.00000
20 1.03996 0.00905 0.00000 0.00000 0.00000 0.00000
Display each iteration at bus 3
Iter Real Imaginary Delta Delta Generation Delta
No. E F E F Mvar Q
1 1.04000 0.00125 1.04000 0.00125 1.16000 1.16000
2 1.03999 0.00376 0.00001 0.00501 1.29435 0.13435
3 1.03998 0.00647 0.00001 0.00271 1.36683 0.07248
4 1.03997 0.00770 0.00001 0.00123 1.41578 0.04895
5 1.03997 0.00837 0.00001 0.00066 1.43793 0.02215
6 1.03996 0.00870 0.00000 0.00034 1.44955 0.01162
7 1.03996 0.00887 0.00000 0.00017 1.45552 0.00597
8 1.03996 0.00896 0.00000 0.00009 1.45856 0.00305
9 1.03996 0.00901 0.00000 0.00005 1.46013 0.00156
10 1.03996 0.00903 0.00000 0.00002 1.46093 0.00080
11 1.03996 0.00904 0.00000 0.00001 1.46134 0.00041
12 1.03996 0.00905 0.00000 0.00001 1.46155 0.00021
13 1.03996 0.00905 0.00000 0.00000 1.46166 0.00011
14 1.03996 0.00905 0.00000 0.00000 1.46171 0.00006
15 1.03996 0.00905 0.00000 0.00000 1.46174 0.00003
16 1.03996 0.00905 0.00000 0.00000 1.46175 0.00001
Introduction to PFATB 37
17 1.03996 0.00905 0.00000 0.00000 1.46176 0.00001
18 1.03996 0.00905 0.00000 0.00000 1.46177 0.00000
19 1.03996 0.00905 0.00000 0.00000 1.46177 0.00000
20 1.03996 0.00905 0.00000 0.00000 1.46177 0.00000
Figure 7.2 shows the process of algorithm convergence until iterations are terminated.
0 5 10 15 20 25
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
The Convergence Graph of GaussSeidel Algorithm
Iterations
S
p
e
e
d
E Increments
F Increments
FIGURE 7.2: The convergence speed of Gauss-Seidel algorithm
38 Introduction to PFATB
7.3 Newton-Raphson Algorithm
The Newton-Raphson algorithm is evaluated either in polar coordinate or in rectangular coordi-
nate. Theyre discussed in two subsection in detail.
7.3.1 N-R Algorithm With Polar Coordinate System
The function NRpm.mreturns to solve power owin N-Ralgorithmwith polar coordinate method.
Power-ow Programming Steps
Step 1: Input raw data. Input the electrical grid data in the standard data structure and
estimate start points of the remaining undened bus magnitudes and phase angles.
Step 2: Data regeneration. Line data and bus data are specied to change along with bus
numbers simultaneously.
Step 3: Evaluate Y
bus
. Evaluate bus admittance matrix.
Step 4: Evaluate power mismatch. Evaluate P
i
and Q
is
respectively from real power mis-
match equation (6.12) and (6.13).
Step 5: Evaluate Jacobian elements. Evaluate Jacobian submatrix elements of H,N,K,L equa-
tions (6.18)(6.25).
Step 6: Evaluate increments. Evaluate increments of bus voltage magnitude U and incre-
ments of bus angle degree by power ow matrix (6.39) with Gauss Elimination method.
Step 7: Update variables. Update newbus voltage magnitude and newbus phase angle degree
by using equations as follows. And then returns to Step5 with new values to replace the precious
values.
U
(k+1)
i
= U
(k)
i
+U
(k)
i
(7.7)
(k+1)
i
=
(k)
i
+
(k)
i
(7.8)
Step 8: Examine reactive power at each PVbus. If the reactive power of each PV bus exceeds
the generations boundaries of secure limitations within the minimum and maximum, the con-
trolled voltage of the PV bus should drop voltage magnitude to balance reactive power in power
system.
Step 9: Termination conditions. The process is continued until the residuals P
(k)
i
and Q
(k)
i
are less than tolerance accuracy as follows.
max|P
(k)
i
| <
1
(7.9)
max|Q
(k)
i
| <
2
(7.10)
Note that
1
and
2
are the small positive constants, such as 0.001,0.00001, and the smaller num-
bers are pretty more accurate.
Step 10: Evaluate power of the swing bus and each PV bus. Evaluate reactive power of each
PV bus and evaluate active power and reactive power of the swing bus by (6.44)(6.46).
Step 11: Recongure bus numbers. Return each bus number to the original bus number in
the bus data matrix and the line data matrix.
Step 12: Evaluate line ow and loss. Evaluate real and reactive power ows in transmission
lines and transformers, as well as equipment losses.
Introduction to PFATB 39
Step 13: Output solution. Show the nal voltage magnitude and phase angle at each bus
under balanced three-phase steady-state conditions.
Power-ow Program Function
A complete pseudo-code M-le NRpm.m of N-R algorithm with polar coordinate method is
shown below.
function [bus_res,S_res,k] = NRpm(bus,line,EPS,kmax,option)
% NewtonRaphson Algorithm With Polar Coordinate Method
% [BUS_RES,S_RES,K] = NRpm(BUS,LINE,EPS,KMAX,OPTION) returns the final voltage
% magnitude, phase angle and line flow and loss.
%
% [bus_res,S_res,k] = NRpm(bus,line) returns voltage bus_res, line flow and loss S_res,
% iteration k at EPS=1.0e6 and kmax = 100 in default.
%
% NRpm uses option to change voltage magnitudes of PV bus to balance reactive power
% in power system:
% 'unchangePVpm' keep voltage magnitudes of PV bus;(default)
% 'changePVpm' drop voltage magnitudes of PV bus.
%
% See also sortbus,busAM,dPQpm,Jacpm,dAM,changePVpm,dPQSWPVpm,resetbus,lineAM,powerTSpm
% Author(s):Long,Chao Lei
% $Date:2010/06/24 15:22$
if nargin < 2
error('Please input 2 variables');
end
if nargin == 2
EPS = 1.0e6; % Tolerance Accuracy
kmax = 100; % Maximum iterations
option = 'unchangePVpm'; % Option default
elseif nargin == 3
kmax = 100; % Maximum iterations
option = 'unchangePVpm'; % Option default
elseif nargin == 4 || isempty(option)
option = 'unchangePVpm'; % Option default
end
format long
[bus,line,nPQ,nPV,nodenum] = sortbus(bus,line); % Step 2: Data Regeneration
n = nPV+nPQ+1;
Y = busAM(bus,line); % Step 3: Evaluate Ybus
% Sparse Symmetric Matrix Figure
clf;
figure(1)
spy(Y);
title('Ybus Sparse Symmetric Matrix')
nz = nnz(Y);
pct = 100 / numel(Y);
xlabel(sprintf('nonzeros=%d (%.3f%%)',nz,nz
*
pct));
grid on
40 Introduction to PFATB
k = 1;
while (k kmax)
[delta_P,delta_Q] = dPQpm(bus,nPQ,Y); % Step 4: Evaluate Power Mismatches
Jacobi = Jacpm(bus,Y,nPQ); % Step 5: Evaluate Jacobian Elements
[dU,dAng] = dAM(bus,nPQ,Jacobi,delta_P,delta_Q); % Step 6: Evaluate Increments
bus(1:nPQ,3) = bus(1:nPQ,3) + dU; % Step 7: Update Variables
bus(1:n1,4) = bus(1:n1,4) + dAng;
% Record the delta Magnitude and delta Angle
dUrd(k,:) = dU';
dAngrd(k,:) = dAng';
switch option
case 'unchangePVpm'
case 'changePVpm'
% Step 8: Examine Reactive Power of each PV Bus
bus_new = changePVpm(bus,Y,nPQ,k);
bus = bus_new;
end
% Step 9: Termination Conditions
if (max(abs(dU))<EPS) & (max(abs(dAng))<EPS);
break
end
% k equals kmax or not
if (k == kmax);
disp('Solution is not accurate.Please increase the maximum iterations in INPUT argument.')
break;
end
% Save increments at each iteration
bus_k = zeros(n1,6);
bus_k(1:nPQ,1) = bus(1:nPQ,3);
bus_k(:,2) = bus(1:n1,4);
bus_k(:,3) = dAng;
bus_k(1:nPQ,4) = dU;
bus_k(:,5) = delta_P;
bus_k(1:nPQ,6) = delta_Q;
[row,column] = size(bus_k);
for i = 1:column
cell_bus{k,i} = bus_k(:,i);
end
k = k+1; % Increase iterations
end
% Show the graph of algorithm convergence
xk = [1:k];
dUrd_sq = sqrt(sum(dUrd.^2,2));
dAngrd_sq = sqrt(sum(dAngrd.^2,2));
Introduction to PFATB 41
figure(2)
plot(xk,dUrd_sq,'k',xk,dAngrd_sq,'k','LineWidth',2)
title('The Convergence Speed of NewtonRaphson Algorithm')
xlabel('Iterations');
ylabel('Speed');
legend('Magnitude Changes','Angle Changes')
grid on
% Step 10: Evaluate Power of the swing bus and each PV bus
bus = dPQSWPVpm(bus,Y,nPQ);
% Step 11: Reconfigure Bus Numbers
[bus_temp,line_temp] = resetbus(bus,line,nodenum);
% Step 12: Evaluate line flow and loss
YtYm = lineAM(line_temp);
bus_res = bus_temp;
bus_res(:,4) = bus_temp(:,4)
*
180/pi;
S_res = powerTSpm(bus_temp,line_temp,YtYm);
% Step 13: Output Solution
format short
% Output Bus Solution
disp(' ')
disp(' Power Flow Solution by NR Algorithm With Polar Coordinate Method')
busout(bus_res,delta_P,delta_Q,n,k);
% Output Line Solution
disp(' ')
disp(' Transmission Line Flow and Loss')
lineflow(s_res,n);
% Display output at each iteration
disp(' ')
disp(' Display output at each iteration')
busiter(cell_bus,nodenum,n,k)
% Subfunction
function busout(bus_res,delta_P,delta_Q,n,k)
fprintf(' Maximum Active Power Mismatch = %g \n', max(abs(delta_P)))
fprintf(' Maximum Reactive Power Mismatch = %g \n', max(abs(delta_Q)))
fprintf(' No. of Iterations = %g \n\n', k)
head =[' Bus Voltage Angle Load Generation Injected'
' No. Mag. Degree MW Mvar MW Mvar Mvar '
' '];
disp(head)
for i = 1:n
fprintf(' %5g', bus_res(i,1)), fprintf(' %7.3f', bus_res(i,3)),
fprintf(' %8.3f', bus_res(i,4)), fprintf(' %9.3f', bus_res(i,5)),
fprintf(' %9.3f', bus_res(i,6)), fprintf(' %9.3f', bus_res(i,7)),
fprintf(' %9.3f ', bus_res(i,8)), fprintf(' %8.3f\n',bus_res(i,11))
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f', sum(bus_res(:,5))),
fprintf(' %9.3f', sum(bus_res(:,6))),
fprintf(' %9.3f', sum(bus_res(:,7))),
fprintf(' %9.3f', sum(bus_res(:,8))),
fprintf(' %9.3f\n\n',sum(bus_res(:,11)))
42 Introduction to PFATB
% Subfunction
function lineflow(s_res,n)
head =[' '
' Bus Bus Power Flow Power Flow Power Loss'
' nl. nr. nl to nr nr to nl MW Mvar '
' '];
disp(head)
for i = 1:n
fprintf(' %5g', s_res(i,1)), fprintf(' %5.0f', s_res(i,2)),
fprintf(' %9.3f+j%7.3f', real(s_res(i,3)),imag(s_res(i,3))),
fprintf(' %9.3f+j%7.3f', real(s_res(i,4)),imag(s_res(i,4))),
fprintf(' %9.3f', real(s_res(i,5))),
fprintf(' %9.3f\n', imag(s_res(i,5))),
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f+j%7.3f', sum(real(s_res(i,3))),sum(imag(s_res(i,3)))),
fprintf(' %9.3f+j%7.3f', sum(real(s_res(i,4))),sum(imag(s_res(i,4)))),
fprintf(' %9.3f', sum(real(s_res(:,5)))),
fprintf(' %9.3f\n\n', sum(imag(s_res(:,5))))
% Subfunction
function busiter(cell_bus,nodenum,n,k)
for i = 1:n1
disp(' ')
fprintf(' Display each iteration at bus %g \n\n', nodenum(i,2))
head =[' Iter Voltage Angle Delta Delta Delta Delta '
' No. Mag. Degree Angle Mag. P Q '
' '];
disp(head)
for j = 1:m1
fprintf(' %6.4g', m),
fprintf(' %10.5f', cell_bus{m,1}(i,:)),
fprintf(' %10.5f', cell_bus{m,2}(i,:)),
fprintf(' %9.5f', cell_bus{m,3}(i,:)),
fprintf(' %9.5f', cell_bus{m,4}(i,:)),
fprintf(' %9.5f', cell_bus{m,5}(i,:)),
fprintf(' %9.5f\n', cell_bus{m,6}(i,:))
end
end
Example 7.2
Obtain the power ow solution by Newton-Raphson algorithm. Lets use NRpm.m instead of
GS.m in ex7.2.m to solve this power ow problem.
Estimate start points of the remaining bus magnitude and phase angle as follows.
TABLE 7.2: The initial estimations of bus magnitude and phase angle
bus number 1 2 3
U
(0)
(0)
1.050
10
1.040
Let us evaluate this example by calling NRpm.m to output solutions. Try the following:
Introduction to PFATB 43
% ex7.2.m
clc;
clear all
%% Bus data
% Bus Bus Voltage Angle Load Generator Injected
% No Type Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar
bus = [1 3 1.05 0 0 0 0 0 3.5 3.5 0
2 1 1 0 4 2.5 0 0 0 0 0
3 2 1.04 0 0 0 2 0 3.5 3.5 0];
%% Line data
% Bus Bus R X 1/2 B Tr.tap Setting
% nl nr p.u. p.u. p.u. p.u.
line = [1 2 0.02 0.04 0 1
1 3 0.01 0.03 0 1
2 3 0.0125 0.025 0 1];
%% Newtonraphson With Polar Coorinate Method
[bus_res,s_res,k] = NRpm(bus,line)
Try it out and then it results in
Power Flow Solution by NR Algorithm With Polar Coordinate Method
Maximum Active Power Mismatch = 1.16762e009
Maximum Reactive Power Mismatch = 8.82984e010
No. of Iterations = 4
Bus Voltage Angle Load Generation Injected
No. Mag. Degree MW Mvar MW Mvar Mvar
1 1.050 0.000 0.000 0.000 2.184 1.409 0.000
2 0.972 2.696 4.000 2.500 0.000 0.000 0.000
3 1.040 0.499 0.000 0.000 2.000 1.462 0.000
Total 4.000 2.500 4.184 2.870 0.000
Transmission Line Flow and Loss
Bus Bus Power Flow Power Flow Power Loss
nl. nr. nl to nr nr to nl MW Mvar
1 2 1.794+j 1.187 1.710+j 1.019 0.084 0.168
1 3 0.391+j 0.221 0.389+j 0.216 0.002 0.005
2 3 2.290+j 1.481 2.389+j 1.677 0.098 0.197
Total 2.290+j 1.481 2.389+j 1.677 0.184 0.370
Display output at each iteration
Display each iteration at bus 2
Iter Voltage Angle Delta Delta Delta Delta
No. Mag. Degree Angle Mag. P Q
1 0.97345 0.04526 0.04526 0.02655 2.86000 0.22000
2 0.97168 0.04706 0.00180 0.00177 0.09922 0.05091
3 0.97168 0.04706 0.00000 0.00000 0.00022 0.00014
44 Introduction to PFATB
Display each iteration at bus 3
Iter Voltage Angle Delta Delta Delta Delta
No. Mag. Degree Angle Mag. P Q
1 0.00000 0.00772 0.00772 0.00000 1.43840 0.00000
2 0.00000 0.00870 0.00099 0.00000 0.02171 0.00000
3 0.00000 0.00871 0.00000 0.00000 0.00004 0.00000
Figure 7.3 shows the process of algorithm convergence until iterations are terminated.
1 1.5 2 2.5 3 3.5 4
0
0.005
0.01
0.015
0.02
0.025
0.03
0.035
0.04
0.045
0.05
The Convergence Graph of NewtonRaphson Algorithm
Iterations
S
p
e
e
d
Magnitude Increments
Angle Increments
FIGURE 7.3: The convergence speed of Newton-Raphson algorithm
Introduction to PFATB 45
7.3.2 N-R Algorithm With Rectangular Coordinate System
The function NRcm.m returns to solve power ow in N-R algorithm with rectangular(cartesian)
coordinate method.
Power-ow Programming Steps
Step 1: Input raw data. Input the electrical grid data in the standard data structure and
estimate start points of the remaining undened real part e and imaginary parts f of bus voltage.
Step 2: Data regeneration. Line data and bus data are specied to change along with bus
numbers simultaneously.
Step 3: Evaluate Y
bus
. Evaluate bus admittance matrix.
Step 4: Evaluate power mismatch. Evaluate P
i
and Q
is
respectively from real power mis-
match equations (6.14)(6.17).
Step 5: Evaluate Jacobian elements. Evaluate Jacobian submatrix elements of H,N,K,L,R,S
equations (6.26)-(6.36).
Step 6: Evaluate increments. Evaluate increments of bus voltage real part e and increments
of bus voltage imaginary part f by power ow matrix (6.40) with Gauss Elimination method.
Step 7: Update variables. Update new bus voltage real part e and new bus voltage imaginary
part f by using equations as follows. And then returns to Step5 with new values to replace the
precious values.
e
(k+1)
= e
(k)
+e
(k)
(7.11)
f
(k+1)
= f
(k)
+f
(k)
(7.12)
Step 8: Examine reactive power of each PVBus. If the reactive power of each PV bus exceeds
the generations boundaries of secure limitations within the minimum and maximum, the con-
trolled voltage of the PV bus should drop voltage magnitude to balance reactive power in power
system.
Step 9: Termination conditions. The process is continued until the residuals P
(k)
i
and Q
(k)
i
are less than tolerance accuracy as follows.
max|P
(k)
i
| <
1
(7.13)
max|Q
(k)
i
| <
2
(7.14)
Note that
1
and
2
are the small positive constant, such as 0.001,0.00001, and the smaller num-
bers are pretty more accurate.
Step 10: Evaluate power of the swing bus and each PV bus. Evaluate reactive power of each
PV bus and evaluate active power and reactive power of the swing bus by (6.47)(6.49).
Step 11: Recongure bus numbers. Return each bus number to the original bus number in
the bus data matrix and the line data matrix.
Step 12: Evaluate line ow and loss. Evaluate real and reactive power ows in transmission
lines and transformers, as well as equipment losses.
Step 13: Output solution. Show the nal bus voltage real part e and imaginary part f under
balanced three-phase steady-state conditions.
Power-ow Program Function
Acomplete pseudo-code M-le NRcm.m of N-R algorithmwith rectangular coordinate is shown
below.
46 Introduction to PFATB
function [bus_res,S_res,k] = NRcm(bus,line,EPS,kmax,option)
% NewtonRaphson Algorithm With Rectangular Coordinate Method
% [BUS_RES,S_RES,K] = NRcm(BUS,LINE,EPS,KMAX,OPTION) returns the final bus voltage
% real part e and imaginary part f and line flow and loss.
%
% [bus_res,S_res,k] = NRcm(bus,line) returns voltage bus_res, line flow and loss S_res,
% iteration k at EPS=1.0e6 and kmax = 100 in default.
%
% NRcm uses option to change voltage magnitudes of PV bus to balance reactive power
% in power system:
% 'unchangePVcm' keep voltage magnitudes of PV bus;(default)
% 'changePVcm' drop voltage magnitudes of PV bus.
%
% See also sortbus,busAM,dPQcm,Jaccm,dAM,changePVcm,dPQSWPVcm,resetbus,lineAM,powerTScm
% Author(s):Chao Lei
% $Date:2011/01/31 00:04$
if nargin < 2
error('Please input 2 variables');
end
if nargin == 2
EPS = 1.0e6; % Tolerance Accuracy
kmax = 100; % Maximum iterations
option = 'unchangePVcm'; % Option default
elseif nargin == 3
kmax = 100; % Maximum iterations
option = 'unchangePVcm'; % Option default
elseif nargin == 4 || isempty(option)
option = 'unchangePVcm'; % Option default
end
format long
[bus,line,nPQ,nPV,nodenum] = sortbus(bus,line); % Step 2: Data Regeneration
n = nPV+nPQ+1;
Y = busAM(bus,line); % Step 3: Evaluate Ybus
% Sparse Symmetric Matrix Figure
clf;
figure(1)
spy(Y);
title('Ybus Sparse Symmetric Matrix')
nz = nnz(Y);
pct = 100 / numel(Y);
xlabel(sprintf('nonzeros=%d (%.3f%%)',nz,nz
*
pct));
grid on
k=1;
% The Constant voltage magnitude of each PV bus
bus0 = zeros(nPV,1);
bus0 = bus(nPQ+1:n1,3).^2 + bus(nPQ+1:n1,4).^2;
while (k kmax)
[delta_P,delta_Q,delta_U] = dPQcm(bus,bus0,nPQ,Y); % Step 4: Evaluate Power Mismatches
Introduction to PFATB 47
Jacobi = Jaccm(bus,Y,nPQ); % Step 5: Evaluate Jacobian Elements
[df,de] = dPQU(bus,Jacobi,delta_P,delta_Q,delta_U);% Step 6: Evaluate Increments
bus(1:n1,3) = bus(1:n1,3) + de; % Step 7: Update Variables
bus(1:n1,4) = bus(1:n1,4) + df;
% Record the delta e and delta f
dfrd(k,:) = df';
derd(k,:) = de';
switch option
case 'unchangePVcm'
case 'changePVcm'
% Step 8: Examine Reactive Power of each PV Bus
bus0_new = changePVcm(bus,bus0,Y,nPQ,k);
bus0 = bus0_new;
end
% Step 9: Termination Conditions
if (max(abs(df))<EPS) & (max(abs(de))<EPS);
break
end
% k equals kmax or not
if (k == kmax);
disp('Solution is not accurate.Please increase the maximum iterations in INPUT argument.')
break;
end
% Save increments at each iteration
bus_k = zeros(n1,6);
bus_k(:,1) = bus(1:n1,3);
bus_k(:,2) = bus(1:n1,4);
bus_k(:,3) = de;
bus_k(:,4) = df;
bus_k(:,5) = delta_P;
bus_k(1:nPQ,6) = delta_Q;
[row,column] = size(bus_k);
for i = 1:column
cell_bus{k,i} = bus_k(:,i);
end
k = k+1; % Increase iterations
end
% Show the graph of algorithm convergence
xk = [1:k];
dfrd_sq = sqrt(sum(dfrd.^2,2));
derd_sq = sqrt(sum(derd.^2,2));
figure(2)
plot(xk,dfrd_sq,'k',xk,derd_sq,'k','LineWidth',2)
title('The Convergence Speed of NewtonRaphson Algorithm')
xlabel('Iterations');
ylabel('Speed');
48 Introduction to PFATB
legend('E Changes','F Changes')
grid on
% Step 10: Evaluate Power of the swing bus and each PV bus
bus = dPQSWPVcm(bus,Y,nPQ);
% Step 11: Reconfigure Bus Numbers
[bus_temp,line_temp] = resetbus(bus,line,nodenum);
% Step 12: Evaluate line flow and loss
YtYm = lineAM(line_temp);
S_res = powerTScm(bus_temp,line_temp,YtYm);
bus_res = bus_temp;
% Step 13: Output Solution
format short
% Output Bus Solution
disp(' ')
disp(' Power Flow Solution by NR Algorithm With Rectangular Coordinate Method')
busout(bus_res,delta_P,delta_Q,n,k);
% Output Line Solution
disp(' ')
disp(' Transmission Line Flow and Loss')
lineflow(s_res,n);
% Display output at each iteration
disp(' ')
disp(' Display output at each iteration')
busiter(cell_bus,nodenum,n,k)
% Subfunction
function busout(bus_res,delta_P,delta_Q,n,k)
fprintf(' Maximum Active Power Mismatch = %g \n', max(abs(delta_P)))
fprintf(' Maximum Reactive Power Mismatch = %g \n', max(abs(delta_Q)))
fprintf(' No. of Iterations = %g \n\n', k)
head =[' Bus Real Imaginary Load Generation Injected'
' No. E F MW Mvar MW Mvar Mvar '
' '];
disp(head)
for i = 1:n
fprintf(' %5g', bus_res(i,1)), fprintf(' %7.3f', bus_res(i,3)),
fprintf(' %8.3f', bus_res(i,4)), fprintf(' %9.3f', bus_res(i,5)),
fprintf(' %9.3f', bus_res(i,6)), fprintf(' %9.3f', bus_res(i,7)),
fprintf(' %9.3f ', bus_res(i,8)), fprintf(' %8.3f\n',bus_res(i,11))
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f', sum(bus_res(:,5))),
fprintf(' %9.3f', sum(bus_res(:,6))),
fprintf(' %9.3f', sum(bus_res(:,7))),
fprintf(' %9.3f', sum(bus_res(:,8))),
fprintf(' %9.3f\n\n',sum(bus_res(:,11)))
% Subfunction
function lineflow(s_res,n)
head =[' '
' Bus Bus Power Flow Power Flow Power Loss'
Introduction to PFATB 49
' nl. nr. nl to nr nr to nl MW Mvar '
' '];
disp(head)
for i = 1:n
fprintf(' %5g', s_res(i,1)), fprintf(' %5.0f', s_res(i,2)),
fprintf(' %9.3f+j%7.3f', real(s_res(i,3)),imag(s_res(i,3))),
fprintf(' %9.3f+j%7.3f', real(s_res(i,4)),imag(s_res(i,4))),
fprintf(' %9.3f', real(s_res(i,5))),
fprintf(' %9.3f\n', imag(s_res(i,5))),
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f+j%7.3f', sum(real(s_res(i,3))),sum(imag(s_res(i,3)))),
fprintf(' %9.3f+j%7.3f', sum(real(s_res(i,4))),sum(imag(s_res(i,4)))),
fprintf(' %9.3f', sum(real(s_res(:,5)))),
fprintf(' %9.3f\n\n', sum(imag(s_res(:,5))))
% Subfunction
function busiter(cell_bus,nodenum,n,k)
for i = 1:n1
disp(' ')
fprintf(' Display each iteration at bus %g \n\n', nodenum(i,2))
head =[' Iter Real Imaginary Delta Delta Delta Delta '
' No. E F E F P Q '
' '];
disp(head)
for m = 1:k1
fprintf(' %6.4g', m),
fprintf(' %10.5f', cell_bus{m,1}(i,:)),
fprintf(' %10.5f', cell_bus{m,2}(i,:)),
fprintf(' %9.5f', cell_bus{m,3}(i,:)),
fprintf(' %9.5f', cell_bus{m,4}(i,:)),
fprintf(' %9.5f', cell_bus{m,5}(i,:)),
fprintf(' %9.5f\n', cell_bus{m,6}(i,:))
end
end
Example 7.3
Obtain the power ow solution by N-R algorithm with rectangular coordinate method. Lets
use NRcm.m instead of NRpm.m in ex3.m to solve this power ow problem.
Estimate start points of the remaining bus magnitude and phase angle as follows.
TABLE 7.3: The initial estimations of real part e and imaginary part f
bus number 1 2 3
e
(0)
+j f
(0)
1 +j 0 1 +j 0 1 +j 0
Let us evaluate this example by calling NRcm.m to output solutions. Try the following:
% ex7.3.m
clc;
clear all
%% Bus data
% Bus Bus Real Imaginary Load Generator Injected
50 Introduction to PFATB
% No Type E F MW Mvar MW Mvar Qmin Qmax Mvar
bus = [1 3 1.05 0 0 0 0 0 3.5 3.5 0
2 1 1 0 4 2.5 0 0 0 0 0
3 2 1.04 0 0 0 2 0 3.5 3.5 0];
%% Line data
% Bus Bus R X 1/2 B Tr.tap Setting
% nl nr p.u. p.u. p.u. p.u.
line = [1 2 0.02 0.04 0 1
1 3 0.01 0.03 0 1
2 3 0.0125 0.025 0 1];
%% NewtonRaphson With Rectangular Coordinate Method
[bus_res,s_res,k] = NRcm(bus,line)
Try it out and then it results in
Power Flow Solution by NR Algorithm With Rectangular Coordinate Method
Maximum Active Power Mismatch = 1.6267e009
Maximum Reactive Power Mismatch = 4.70817e009
No. of Iterations = 4
Bus Real Imaginary Load Generation Injected
No. E F MW Mvar MW Mvar Mvar
1 1.050 0.000 0.000 0.000 2.184 1.409 0.000
2 0.971 0.046 4.000 2.500 0.000 0.000 0.000
3 1.040 0.009 0.000 0.000 2.000 1.462 0.000
Total 4.000 2.500 4.184 2.870 0.000
Transmission Line Flow and Loss
Bus Bus Power Flow Power Flow Power Loss
nl. nr. nl to nr nr to nl MW Mvar
1 2 1.794+j 1.187 1.710+j 1.019 0.084 0.168
1 3 0.391+j 0.221 0.389+j 0.216 0.002 0.005
2 3 2.290+j 1.481 2.389+j 1.677 0.098 0.197
Total 2.290+j 1.481 2.389+j 1.677 0.184 0.370
Display output at each iteration
Display each iteration at bus 2
Iter Real Imaginary Delta Delta Delta Delta
No. E F E F P Q
1 0.97345 0.04526 0.02655 0.04526 2.86000 0.22000
2 0.97061 0.04571 0.00284 0.00045 0.05896 0.13497
3 0.97060 0.04571 0.00001 0.00000 0.00011 0.00046
Display each iteration at bus 3
Iter Real Imaginary Delta Delta Delta Delta
No. E F E F P Q
Introduction to PFATB 51
1 1.04000 0.00803 0.00000 0.00803 1.43840 0.00000
2 1.03996 0.00905 0.00004 0.00102 0.00268 0.00000
3 1.03996 0.00905 0.00000 0.00000 0.00011 0.00000
Figure 7.4 shows the process of algorithm convergence until iterations are terminated.
1 1.5 2 2.5 3 3.5 4
0
0.005
0.01
0.015
0.02
0.025
0.03
0.035
0.04
0.045
0.05
The Convergence Graph of NewtonRaphson Algorithm
Iterations
S
p
e
e
d
E Increments
F Increments
FIGURE 7.4: The convergence speed of Newton-Raphson algorithm
52 Introduction to PFATB
7.4 P-Q Decoupling Algorithm
The function PQpm.m returns to solve power ow in P-Q fast decoupling algorithm with polar
coordinate method.
Power-ow Programming Steps
Step 1: Input raw data. Input the electrical grid data in the standard data structure and
estimate start points of the remaining undened bus magnitude and phase angle.
Step 2: Data regeneration. Line data and bus data are specied to change along with bus
numbers simultaneously.
Step 3: Evaluate Y
bus
. Evaluate bus admittance matrix.
Step 4: Evaluate power mismatch. Evaluate P
i
and Q
is
respectively from real power mis-
match equation (6.12) and (6.13).
Step 5: Evaluate Jacobian elements. Evaluate Jacobian submatrix elements of H,L equations
(6.18)(6.19) and (6.21)(6.25).
Step 6: Evaluate increments. Evaluate increments of bus voltage magnitude U and in-
crements of bus angle degree by power ow matrix (6.37)(6.38) with Gauss Elimination
method.
Step 7: Update variables. Update newbus voltage magnitude and newbus phase angle degree
by using equations as follows. And then returns to Step5 with new values to replace the precious
values.
U
(k+1)
= U
(k)
+U
(k)
(7.15)
(k+1)
=
(k)
+
(k)
(7.16)
Step 8: Examine reactive power of each PVBus. If the reactive power of each PV bus exceeds
the generations boundaries of secure limitations within the minimum and maximum, the con-
trolled voltage of the PV bus should drop voltage magnitude to balance reactive power in power
system.
Step 9: Termination conditions. The process is continued until the residuals P
(k)
i
and Q
(k)
i
are less than tolerance accuracy as follows.
max|P
(k)
i
| <
1
(7.17)
max|Q
(k)
i
| <
2
(7.18)
Note that
1
and
2
are the small positive constant, such as 0.001,0.00001, and the smaller num-
bers are pretty more accurate.
Step 10: Evaluate power of the swing bus and each PV bus. Evaluate reactive power of each
PV bus and evaluate active power and reactive power of the swing bus by (6.44)(6.46).
Step 11: Recongure bus numbers. Return each bus number to the original bus number in
the bus data matrix and the line data matrix.
Step 12: Evaluate line ow and loss. Evaluate real and reactive power ows in transmission
lines and transformers, as well as equipment losses.
Step 13: Output solution. Show the nal voltage magnitude and phase angle at each bus
under balanced three-phase steady-state conditions.
Power-ow Program Function
Acomplete pseudo-code M-le PQpm.m of P-Qfast decoupling algorithmwith polar coordinate
is shown below.
Introduction to PFATB 53
function [bus_res,s_res,k] = PQpm(bus,line,EPS,kmax,option)
% PQ Fast Decoupling Algorithm With Polar Coordinate Method
% [BUS_RES,S_RES,K] = PQpm(BUS,LINE,EPS,KMAX,OPTION) returns the final voltage
% magnitude,phase angle and line flow and loss.
%
% [bus_res,S_res,k] = PQpm(bus,line) returns voltage bus_res, line flow and loss S_res,
% iteration k at EPS=1.0e6 and kmax = 100 in default.
%
% PQpm uses option to change voltage magnitudes of PV bus to balance reactive power
% in power system:
% 'unchangePVpm' keep voltage magnitudes of PV bus;(default)
% 'changePVpm' drop voltage magnitudes of PV bus.
%
% See also sortbus,busAM,dPQpm,Jacpm,dAM,changePVpm,dPQSWPVpm,resetbus,lineAM,powerTSpm
% Author(s):Long,Chao Lei
% $Date:2010/06/24 15:22$
if nargin < 2
error('Please input 2 variables');
end
if nargin == 2
EPS = 1.0e6; % Tolerance Accuracy
kmax = 100; % Maximum iterations
option = 'unchangePVpm'; % Option default
elseif nargin == 3
kmax = 100; % Maximum iterations
option = 'unchangePVpm'; % Option default
elseif nargin == 4 || isempty(option)
option = 'unchangePVpm'; % Option default
end
format long
[bus,line,nPQ,nPV,nodenum] = sortbus(bus,line); % Step 2: Data Regeneration
n = nPV+nPQ+1;
[B1,B2,Y] = Bpq(bus,line,nPQ); % Step 3: Evaluate Ybus
% Sparse Symmetric Matrix Figure
clf;
figure(1)
spy(Y);
title('Ybus Sparse Symmetric Matrix')
nz = nnz(Y);
pct = 100 / numel(Y);
xlabel(sprintf('nonzeros=%d (%.3f%%)',nz,nz
*
pct));
grid on
k = 1;
while (k kmax)
[delta_P,delta_Q] = dPQpm(bus,nPQ,Y); % Step 4: Evaluate Power Mismatches
[H,L] = HLpq(bus,nPQ,B1,B2); % Step 5: Evaluate Jacobian Elements H,L
dAng = dApq(bus,H,delta_P); % Step 6: Evaluate Increments
dU = dMpq(bus,nPQ,L,delta_Q);
54 Introduction to PFATB
bus(1:nPQ,3) = bus(1:nPQ,3) + dU; % Step 7: Update Variables
bus(1:n1,4) = bus(1:n1,4) + dAng;
% Record the delta U and delta Angle
dUrd(k,:) = dU';
dAngrd(k,:) = dAng';
switch option
case 'unchangePVpm'
case 'changePVpm'
% Step 8: Examine Reactive Power of each PV Bus
bus_new = changePVpm(bus,Y,nPQ,k);
bus = bus_new;
end
% Step 9: Termination Conditions
if (max(abs(dU))<EPS) & (max(abs(dAng))<EPS)
break
end
% k equals kmax or not
if (k == kmax);
disp('Solution is not accurate.Please increase the maximum iterations in INPUT argument.')
break;
end
% Save increments at each iteration
bus_k = zeros(n1,6);
bus_k(1:nPQ,1) = bus(1:nPQ,3);
bus_k(:,2) = bus(1:n1,4);
bus_k(:,3) = dAng;
bus_k(1:nPQ,4) = dU;
bus_k(:,5) = delta_P;
bus_k(1:nPQ,6) = delta_Q;
[row,column] = size(bus_k);
for i = 1:column
cell_bus{k,i} = bus_k(:,i);
end
k = k+1; % Increase iterations
end
% Show the graph of algorithm convergence
xk = [1:k];
dUrd_sq = sqrt(sum(dUrd.^2,2));
dAngrd_sq = sqrt(sum(dAngrd.^2,2));
figure(2)
plot(xk,dUrd_sq,'k',xk,dAngrd_sq,'k','LineWidth',2)
title('The Convergence Speed of PQ Decoupling Algorithm')
xlabel('Iterations');
ylabel('Speed');
legend('Magnitude Increments','Angle Increments')
grid on
Introduction to PFATB 55
% Step 10: Evaluate power of the swing bus and each PV bus
bus = dPQSWPVpm(bus,Y,nPQ);
% Step 11: Reconfigure Bus Numbers
[bus_temp,line_temp] = resetbus(bus,line,nodenum);
% Step 12: Evaluate line flow and loss
YtYm = lineAM(line_temp);
bus_res = bus_temp;
bus_res(:,4) = bus_temp(:,4)
*
180/pi;
s_res = powerTSpm(bus_temp,line_temp,YtYm);
% Step 13: Output Solution
format short
% Output Bus Solution
disp('
')
disp(' Power Flow Solution by PQ Decoupling Algorithm With Polar Coordinate Method')
busout(bus_res,delta_P,delta_Q,n,k);
% Output Line Solution
disp(' ')
disp(' Transmission Line Flow and Loss')
lineflow(s_res,n);
% Display output at each iteration
disp(' ')
disp(' Display output at each iteration')
busiter(cell_bus,nodenum,n,k)
% Subfunction
function busout(bus_res,delta_P,delta_Q,n,k)
fprintf(' Maximum Active Power Mismatch = %g \n', max(abs(delta_P)))
fprintf(' Maximum Reactive Power Mismatch = %g \n', max(abs(delta_Q)))
fprintf(' No. of Iterations = %g \n\n', k)
head =[' Bus Voltage Angle Load Generation Injected'
' No. Mag. Degree MW Mvar MW Mvar Mvar '
' '];
disp(head)
for i = 1:n
fprintf(' %5g', bus_res(i,1)), fprintf(' %7.3f', bus_res(i,3)),
fprintf(' %8.3f', bus_res(i,4)), fprintf(' %9.3f', bus_res(i,5)),
fprintf(' %9.3f', bus_res(i,6)), fprintf(' %9.3f', bus_res(i,7)),
fprintf(' %9.3f ', bus_res(i,8)), fprintf(' %8.3f\n',bus_res(i,11))
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f', sum(bus_res(:,5))),
fprintf(' %9.3f', sum(bus_res(:,6))),
fprintf(' %9.3f', sum(bus_res(:,7))),
fprintf(' %9.3f', sum(bus_res(:,8))),
fprintf(' %9.3f\n\n',sum(bus_res(:,11)))
% Subfunction
function lineflow(s_res,n)
head =[' '
' Bus Bus Power Flow Power Flow Power Loss'
' nl. nr. nl to nr nr to nl MW Mvar '
56 Introduction to PFATB
' '];
disp(head)
for i = 1:n
fprintf(' %5g', s_res(i,1)), fprintf(' %5.0f', s_res(i,2)),
fprintf(' %9.3f+j%7.3f', real(s_res(i,3)),imag(s_res(i,3))),
fprintf(' %9.3f+j%7.3f', real(s_res(i,4)),imag(s_res(i,4))),
fprintf(' %9.3f', real(s_res(i,5))),
fprintf(' %9.3f\n', imag(s_res(i,5))),
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f+j%7.3f', sum(real(s_res(i,3))),sum(imag(s_res(i,3)))),
fprintf(' %9.3f+j%7.3f', sum(real(s_res(i,4))),sum(imag(s_res(i,4)))),
fprintf(' %9.3f', sum(real(s_res(:,5)))),
fprintf(' %9.3f\n\n', sum(imag(s_res(:,5))))
% Subfunction
function busiter(cell_bus,nodenum,n,k)
for i = 1:n1
disp(' ')
fprintf(' Display each iteration at bus %g \n\n', nodenum(i,2))
head =[' Iter Voltage Angle Delta Delta Delta Delta '
' No. Mag. Degree Angle Mag. P Q '
' '];
disp(head)
for j = 1:k1
fprintf(' %6.4g', j),
fprintf(' %10.5f', cell_bus{j,1}(i,:)),
fprintf(' %10.5f', cell_bus{j,2}(i,:)),
fprintf(' %9.5f', cell_bus{j,3}(i,:)),
fprintf(' %9.5f', cell_bus{j,4}(i,:)),
fprintf(' %9.5f', cell_bus{j,5}(i,:)),
fprintf(' %9.5f\n', cell_bus{j,6}(i,:))
end
end
Example 7.4
Obtain the power ow solution by P-Q decoupling algorithm with polar coordinate method.
Lets use PQpm.m instead of NRpm.m in ex3.m to solve this power ow problem.
Estimate start points of the remaining bus magnitude and phase angle as follows.
TABLE 7.4: The initial estimations of bus magnitude and phase angle
bus number 1 2 3
U
(0)
(0)
1.050
10
1.040
Let us evaluate this example through calling PQpm.m to output solutions. Try the following:
% ex7.4.m
clc;
clear all
%% Bus data
% Bus Bus Voltage Angle Load Generator Injected
% No Type Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar
Introduction to PFATB 57
bus = [1 3 1.05 0 0 0 0 0 3.5 3.5 0
2 1 1 0 4 2.5 0 0 0 0 0
3 2 1.04 0 0 0 2 0 3.5 3.5 0];
%% Line data
% Bus Bus R X 1/2 B Tr.tap Setting
% nl nr p.u. p.u. p.u. p.u.
line = [1 2 0.02 0.04 0 1
1 3 0.01 0.03 0 1
2 3 0.0125 0.025 0 1];
%% PQ Decoupling Algorithm
[bus_res,s_res,k] = PQpm(bus,line)
Try it out and then it results in
Power Flow Solution by PQ Decoupling Algorithm With Polar Coordinate Method
Maximum Active Power Mismatch = 2.89131e005
Maximum Reactive Power Mismatch = 4.7976e007
No. of Iterations = 17
Bus Voltage Angle Load Generation Injected
No. Mag. Degree MW Mvar MW Mvar Mvar
1 1.050 0.000 0.000 0.000 2.184 1.409 0.000
2 0.972 2.696 4.000 2.500 0.000 0.000 0.000
3 1.040 0.499 0.000 0.000 2.000 1.462 0.000
Total 4.000 2.500 4.184 2.870 0.000
Transmission Line Flow and Loss
Bus Bus Power Flow Power Flow Power Loss
nl. nr. nl to nr nr to nl MW Mvar
1 2 1.794+j 1.187 1.710+j 1.019 0.084 0.168
1 3 0.391+j 0.221 0.389+j 0.216 0.002 0.005
2 3 2.290+j 1.481 2.389+j 1.677 0.098 0.197
Total 2.290+j 1.481 2.389+j 1.677 0.184 0.370
Display output at each iteration
Display each iteration at bus 2
Iter Voltage Angle Delta Delta Delta Delta
No. Mag. Degree Angle Mag. P Q
1 0.99577 0.06048 0.06048 0.00423 2.86000 0.22000
2 0.96515 0.05649 0.00400 0.03062 0.18694 1.58530
3 0.96572 0.04370 0.01279 0.00057 0.64105 0.02866
4 0.97325 0.04487 0.00117 0.00753 0.04627 0.37815
5 0.97309 0.04785 0.00298 0.00016 0.15580 0.00813
6 0.97131 0.04759 0.00026 0.00179 0.01053 0.09034
7 0.97134 0.04687 0.00072 0.00003 0.03708 0.00162
8 0.97177 0.04694 0.00006 0.00043 0.00244 0.02158
9 0.97176 0.04711 0.00017 0.00001 0.00887 0.00034
10 0.97166 0.04709 0.00001 0.00010 0.00056 0.00515
58 Introduction to PFATB
11 0.97166 0.04705 0.00004 0.00000 0.00212 0.00007
12 0.97168 0.04705 0.00000 0.00002 0.00013 0.00123
13 0.97168 0.04706 0.00001 0.00000 0.00051 0.00001
14 0.97168 0.04706 0.00000 0.00001 0.00003 0.00029
15 0.97168 0.04706 0.00000 0.00000 0.00012 0.00000
16 0.97168 0.04706 0.00000 0.00000 0.00001 0.00007
Display each iteration at bus 3
Iter Voltage Angle Delta Delta Delta Delta
No. Mag. Degree Angle Mag. P Q
1 0.00000 0.00857 0.00857 0.00000 1.43840 0.00000
2 0.00000 0.00799 0.00058 0.00000 0.09378 0.00000
3 0.00000 0.00867 0.00068 0.00000 0.45604 0.00000
4 0.00000 0.00899 0.00032 0.00000 0.01594 0.00000
5 0.00000 0.00871 0.00028 0.00000 0.11504 0.00000
6 0.00000 0.00865 0.00007 0.00000 0.00381 0.00000
7 0.00000 0.00870 0.00006 0.00000 0.02712 0.00000
8 0.00000 0.00872 0.00002 0.00000 0.00083 0.00000
9 0.00000 0.00871 0.00001 0.00000 0.00650 0.00000
10 0.00000 0.00870 0.00000 0.00000 0.00019 0.00000
11 0.00000 0.00871 0.00000 0.00000 0.00155 0.00000
12 0.00000 0.00871 0.00000 0.00000 0.00004 0.00000
13 0.00000 0.00871 0.00000 0.00000 0.00037 0.00000
14 0.00000 0.00871 0.00000 0.00000 0.00001 0.00000
15 0.00000 0.00871 0.00000 0.00000 0.00009 0.00000
16 0.00000 0.00871 0.00000 0.00000 0.00000 0.00000
Figure 7.5 shows the process of algorithm convergence until iterations are terminated.
0 2 4 6 8 10 12 14 16 18
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
The Convergence Graph of PQ Decoupling Algorithm
Iterations
S
p
e
e
d
Magnitude Increments
Angle Increments
FIGURE 7.5: The convergence speed of P-Q decoupling algorithm
Introduction to PFATB 59
7.5 Algorithm Discussions
Gauss-Seidel algorithm is modied from Gauss algorithm by substituting new voltage into the
preceding equations. In Example 7.1, it can be seen that Gauss-Seidel algorithm needs many
iterations to achieve the desired accuracy, and there is no guarantee for the convergence. Because
Gauss-Seidel algorithm will not converge in a zigzag fashion to one of roots through iterations if
the initial estimation is not within a "boxed in" region, described in [2] Chapter 6. Therefore, a
test of convergence, especially for the n-dimension case, is dicult, and no general methods are
known.
Newton-Raphson algorithm is widespread considered as the better method to solve power
ows. The process of Newton-Raphson algorithm will converge only in less than ten iterations,
P-Q decoupling algorithm comes in secondary in less than 100 iterations, and Gauss-Seidel algo-
rithm may be converged for more 100 iterations or diverged.
60 Introduction to PFATB
8 IEEE 30-BUS TEST SYSTEM
In this section, we discuss how well PFATB works on IEEE 30-bus typical test system. The fol-
lowing system IEEE 30-bus diagram is part of the American Electric Power Service Corporation
network which is being made available to the electric utility industry as a standard test case for
evaluating various analytical methods. And its application is practical to be showed to help us to
understand PFATB programs better. In Figure 8.1, bus 1 is taken as the swing bus with its voltage
adjusted to 1.060