Sie sind auf Seite 1von 79

Introduction to

Power Flow Analysis Toolbox


Version 1.0a
Revision: February, 2011
Chao Lei
Sichuan Agricultural University
advancedMcode.org
This edition rst published 2011
Copyright 2010-2011 by Chao Lei. All Rights Reserved.
Power Flow Analysis Toolbox(M-les), and the accompanying document Introduction to Power
Flow Analysis Toolbox, are facilitated to practice, educate and research. It can not be altered
in any way, or be used as part of other documents without written permission consented by the
author.
Dedicated to my mother, Yurong Wang,
who practiced ingenuity,
and to my friend, Biwei Su,
who raised me up to more than I can be
This page intentionally left blank
Preface and Acknowledgements
This introduction, a partner of Power Flow Analysis Toolbox(PFATB), has been organized to take
the power ow analysis combination with MATLAB programming codes in stages. It is written
for whoever might possibly use this toolbox to research power owanalysis. However, the biggest
addition is including the specic basics of power ows, which is combined to explain program-
ming functions. But I continue to emphasize the programming part of this introductionit is
written for the practicing scientist, engineer, and so forth. The reader who wishes to know more
about power ow in more detail is highly recommended to read two publications: Optimization
of Power System Operation by Jizhong Zhu(Wiley & IEEE Press,2009) and Power System Analysis
by Hadi Saadat(McGraw-Hill,2002). I make no claims of this toolbox including latest research on
algorithms applied on power ow problems; instead, I refer the reader to use these routines to
testify your new thoughts. To be frank, I think all the routines in the toolbox are not best to facil-
itate in solving power ow problems, but its most biggest feature is to visualize computations in
steps. Because they are remarkably concise and lucid to be applied and then to be revised forward
users decisions. I hope readers nd these a useful start to their own applications and wish them
well in their own forays into using with advanced algorithms such as genetic algorithm, particle
swarm optimization algorithm and so forth to slove economical dispatch and optimal power ow
in large-scale power system.
I am indebted to serval engineers and friends for their kind help. First, my thanks goes to
a Long at Zhejiang University for arising my tremendous interests to implement this toolbox
and making contributions to provide the initial prototype for this toolbox. Without his hard-
working eorts, the toolbox would have not been born. Subsequently, I am also deeply grateful
to Principal Engineer Jizhong Zhu at AREVA T&D Incorporation for encouraging me to go on
my job instantly half a year ago. Likewise, the idea for writing this partner introduction and
the encouragement to write it, I owe to my friend Yuanyuan Jiang at Lancaster University and
Lab Technical Engineer Hong Wen at Sichuan Agricultural University. Additionally, thanks also
for Luigi Giaccari providing me a webpage and a link to my toolbox in the main webpage of
advancedMcode.org. Finally, the excellent reviews by postgraduate Simon Catmull at Loughbor-
ough University in UK were invaluable in the writing of this manuscript.
While acknowledging the help I have received from individuals referred to above, the respon-
sibility for the work is mine alone, so corrections and/or constructive criticisms would be warmly
welcome.
Chao Lei
Chongqing,China
Spring,2011
This page intentionally left blank
Contents
1 INTRODUCTION 1
1.1 An Overview of PFATB 1
1.2 PFATB-Interface 2
2 ABOUT AUTHOR 3
3 INSTALLATION 4
4 TOOLBOX DESIGN 5
4.1 Toolbox Design Process 5
4.2 MATLAB Programming Style 6
5 STANDARD DATA STRUCTURES 7
5.1 Bus Data 7
5.2 Transmission Line Data and Transformer Data 7
5.3 Transmission Line Admittance Data 8
5.4 Transmission Line Flow and Loss Data 9
6 TOOLBOX FUNCTIONS 13
6.1 Data Pre-processing 13
6.2 Execute Algorithms 17
6.3 Data Reconguration 26
6.4 Output Solution 26
7 POWER FLOW ALGORITHMS 29
7.1 Algorithm Convergence Speed 29
7.2 Gauss-Seidel Algorithm 30
7.3 Newton-Raphson Algorithm 38
7.3.1 N-R Algorithm With Polar Coordinate System 38
7.3.2 N-R Algorithm With Rectangular Coordinate System 45
7.4 P-Q Decoupling Algorithm 52
7.5 Algorithm Discussions 59
8 IEEE 30-BUS TEST SYSTEM 60
9 FURTHER REVERSIONS 65
A APPENDIX IEEE 30-BUS SOLUTIONS 67
This page intentionally left blank
Introduction to PFATB 1
1 INTRODUCTION
1.1 An Overview of PFATB
PFATB, which stands for Power Flow Analysis Toolbox, is a package of MATLAB M-les. It is a
collection of routines, written mostly in m-les, which implement the most important functions
to compute and analysis in the applications of power ow. The PFATB is much useful for power
ow analysis practitioner and those wishing to experiment with the power ow algorithm for the
rst time. It is intended as a simulation tool and computing tool for researchers and educators
that is easy to use and modify under the uniform MATLAB programming environment. I sin-
cerely hope that this toolbox will make it possible for you to do more complex computations just
as easily.
PFATB is made up with three main algorithms within Gauss-Seidel, Newton-Raphson and P-Q
decoupling methods. Figure 1.1 shows the relationship tree between PFATB tool with visualized
computations and other interactions with Simpower and GUI Interface.
Gauss-Seidel
Algorithm
Newton-Raphson
Algorithm
P-Q Decoupling
Algorithm
PFATB
MATLAB
Environment
Visualized
Computation
Simpower
GUI Interface
Backbone
Roots
Branches
FIGURE 1.1: Diagram of PFATB tree
Before getting started, the basic theory of power ow in the whole manuscript is drawn from
the power ow literatures, which are listed in a separate section(REFERENCES). Any questions
about basics, please trace the literature source for further reading. I believed that with an inter-
active environment like PFATB, you would be able to pick up the basics quickly, and begin using
it condently in just a few hours. Additionally, the cases presented in this manuscript are almost
2 Introduction to PFATB
derived from Optimization of Power System Control by Jizhong Zhu(Wiley & IEEE Press,2009) and
Power System Analysis by Hadi Saadat(McGraw-Hill,2002).
Let us begin this brief introduction, and hope it will be helpful for enhancing codes readability
in PFATB.
1.2 PFATB-Interface
A bridge between PFATB and MATLAB allows using sophisticated nonlinear computation tools
with the visualization capabilities provided by MATLAB.
The existing GUI interface, located in the toolbox le, has been used as the main reference
for creating the PFATB-Interface. The PFATB-Interface software is developed as a simple GUI
application based on PFATB. The Figure 1.2 depicts the scheme of the PFATB-Interface. The
resulting software is a rather innovative tool able to set up large scale power system test cases,
solve power ow problems and nally visualize results by means of a user-friendly GUI.
PFATB Network
Graphic
Visualization
Toolbox
PFATB
Interface
MATLAB
PFATB
Interface
Input Data Output Solution
FIGURE 1.2: Structure of PFATB-Interface
Introduction to PFATB 3
2 ABOUT AUTHOR
PFATB was developed by Chao Lei, at Electronics Lab of Sichuan Agricultural University(SICAU).
I graduated from Sichuan Agricultural University in 2010 with a Bachelor of Engineer degree
in Agro-machinery Engineering. My interesting research areas of expertise are Optimization of
Power System Operation, Reliability of Power System Distribution, Electricity Markets, and Power
System State Estimation.
The original thoughts for developing PFATB toolbox are intending for fun and ready for grad-
uate career. Nevertheless, that the core codes are born at Electronics Engineering Lab of SICAU
makes me somewhat relaxed and feel kind of easy since I will have a chance to enjoy life again.
4 Introduction to PFATB
3 INSTALLATION
I authorize advancedMcode(See http://www.advancedmcode.org) to release PFATB for the user
to download. It is available from PFATB Home Page
http://www.advancedmcode.org/power-flow-analysis-toolboxpfatb.html
For another, its duplicate copy and latest version is uploaded and released on Mathworks Cen-
tral File Exchange and search PFATB
1
to download as well.
Please follow the download instructions. And then place the les in a location in your own
path. It is highly recommended that the les for this toolbox are stored in a directory named
PFATB o the main MATLAB toolbox directory.
A number of demonstrations are available in the le DOC which include some simple typ-
ical problems of power ow and users documentations. The codes of examples illustrated in
this manuscript are located in TEST_FUNC document. It is certain that these test examples are
demonstrated and discussed in detail in Toolbox Functions Section and in IEEE 30-Bus Test System
Section.
In addition, PFATB can be obtained freely and anyone can use it. Because PFATB is free toolbox
you are encouraged to help make PFATB more useful by writing and contributing additional
functions for it, and by reporting any problems you may have. But any publications derived from
PFATB must be consented by the author in written permission. If you have any questions, please
send an email to contact me via honolulushing@gmail.com. Also you can contact me via Google
Voice:+1-315-220-0696. I hope itll help our communications.
1
See http://www.mathworks.com/matlabcentral/fileexchange/30272
Introduction to PFATB 5
4 TOOLBOX DESIGN
4.1 Toolbox Design Process
The power ow problem is the computation of voltage magnitude and phase angle at each bus
in a power system under balanced three-phase steady-state conditions. The designs of useful
utilities translated into the MATLAB language are the primary and most useful goals of users
to make it as tools. I have been eager to nd a valid way to solute power ow, which should be
useful in a separable, clearly and understandable way to visualize its computations. Subtasks or
subprograms can do some specic part of the main mask. It is much easier to read subprograms
that have fewer lines, than main task, and thus it is certain to help you enhance codes readability
in Gauss-Seidel algorithm, Newton-Raphson algorithm and P-Q decoupling algorithm.
The gaols of this toolbox tool design are that it rapidly works, easily be read and clearly un-
derstood. Firstly, set up a ow chart in steps as a draft; secondly, add the programming essen-
tial steps into the ow chart; thirdly, try to translate the ow chart into programming language.
Overall, the owchart, interpreted as programming design outline, is one of the most key body of
programming. This is why I always write programming in steps in each section as preliminaries
before introducing algorithm functions(which are described later in Section 7).
Observe the following approaches to prepare this toolbox global design and its main process
are outlined below.
Input Raw Data
Data
Pre-processing
Execute
Algorithms
Converged?
Data
Reconfiguration
Output Solution
N
Y
FIGURE 4.1: Flowchart for toolbox design
Step1: Input Raw Data. Input the electrical grid data, with containing varieties of infor-
6 Introduction to PFATB
mation: bus data, transmission line data and transformer data. To make the computation more
signicant, we must adopt one data structure to be used as standard(which we will describe input
data structure later).
Step2: Data Pre-processing. This step consists of two small steps. First, Sort Bus Numbers.
Observing from bus data and line data, we nd that the bus numbers arent in sequence of bus
type, and that may result in reducing eciency in solving problems, and augmenting the number
of iterations, computation time, and memory space. So, its necessary to predene the order of
bus numbers in the data. Second, Data Regeneration. Along with all the changes in bus numbers,
line data and bus data should be specied to change simultaneously.
Step3: Execute Algorithms. The power ow algorithms are normally including Gauss-Seidel
algorithm, Newton-Raphson algorithm, P-Q Decoupling algorithm and so forth will be discussed
step by step in Section 7.
Step4: Data Reconguration. Due to variation in order of bus numbers happened in Step 2,
another reconguration must be performed to reset each bus number and its counterpart param-
eters in its original order.
Step5: Output Solution. After the power ow evaluation, we can get the results, that is to
say, the nal voltage magnitude and phase angle at each bus under balanced three-phase steady-
state conditions. Additionally, as a by-product of this solution, real and reactive power ows in
equipments such as transmission lines and transformers, as well as equipment losses, can also be
computed.
4.2 MATLAB Programming Style
In this part, I want to give some advice for readers about writing MATLAB programming codes.
These suggestions, I think, every programmer should notice as guidelines to help produce code
that are more likely to be readable, understandable, sharable and maintainable. However, this
part isnt include how to address eciency concerns, with recommendations such asDont use
loops. Instead, it is all about writing programming style. The reader wishes to learn about
this toolbox design and style writing in more detail will be highly encouraged to study MATLAB
Programming Style Guidelines by Richard Johnson, which is complied in another document on
Datatool. In a word, as Brian Kernighan, one of the world renowned authors of The Practice
of Programming, writes, Well-written programs are better than badly-written onesthey have
fewer errors and are easier to debug and to modifyso it is important to think about style from
the beginning.
Introduction to PFATB 7
5 STANDARD DATA STRUCTURES
The data les importing to PFATB are in a specic structure by using MATLAB M-les or MAT-
les which is inspired by Hadi Saadat in Chapter 6(DATA PREPARATION) of [2] so that to con-
tinue its input data format with brevity and clarity.
The input data includes bus data, line data and transformer data. The format of the data is sim-
ilar to IEEE format described in "Common Format for Exchange of Solved Load Flow Data",IEEE
TRANS on PAS, Vol-92, No.6, Nov./Dec., 1973, pp. 1916-1925. Additionally, it is pointed out the
general base MVA is at 100MVA.
5.1 Bus Data
The format for the bus entry is chosen to facilitate the required data for each bus in a single row.
The information in bus data shown in Table 5.1 and Table 5.2 which are considered as the format
of the input matrix. Column 1 contains bus numbers. Column 2 contains bus types. Columns 3
and 4 contain voltage magnitude in per unit and phase angle in degrees. Columns 5 and 6 are
load MW and Mvar. Column 7 through 10 contain MW, Mvar, minimum Mvar and maximum
Mvar of generation, in that order. The last column is the injected Mvar of shunt capacitors. The
bus type entered in column 2 is used for identifying load, voltage-controlled, and slack buses as
outlined below.
TABLE 5.1: Bus Data Structure In Polar Coordinate
Bus Bus Voltage Angle -Load- -Generator- Injected
No Type Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar
TABLE 5.2: Bus Data Structure In Rectangular Coordinate
Bus Bus Real Imaginary -Load- -Generator- Injected
No Type e f MW Mvar MW Mvar Qmin Qmax Mvar
1-PQ This type means to be used for load buses. The loads are entered positive in inputting
megawatts and megavars; negative in outputting megawatts and megavars by the power
system. For this bus, initial voltage estimations must be specied. This is usually 1 and 0
for voltage magnitude and phase angle, respectively.
2-PV This type means to be used for voltage-controlled buses. For this bus, voltage mag-
nitude, real power generation in megawatts, and the minimum and maximum limits of the
megavar demand must be specied.
3-Swing bus This type means to be used for swing bus, or called slack bus, or called ref-
erence bus. The swing bus is general only one in the power system. The only necessary
information for this bus is the voltage magnitude and its phase angle. At the swing bus,
voltage magnitude and its phase angle must be specied. Generally speaking, the phase
angle degree is zero.
5.2 Transmission Line Data and Transformer Data
The format for line data is designed to facilitate the required data for each line in a single row
as shown in Table 5.3. Columns 1 and 2 contain bus numbers. Columns 3 through 5 contain the
8 Introduction to PFATB
line resistance, reactance, and one-half of the total line charging susceptance in per unit on the
specied MVA base. The last column is for the transformers tap setting. It will be described and
discussed in the following.
TABLE 5.3: Line Data Structure
Bus Bus R X 1/2 B Tr.Tap Setting
nl nr p.u. p.u. p.u. p.u.
Transformer Data
Two-winding transformer or three-winding transformer data is included in last column of
line data structure. At each line, 1 must be entered in this column due to no transformers on this
transmission line. The lines may be entered in any sequence or order with the only restriction
being that if the entry is a transformer, the left bus number is dened as the tap side of the
transformer.
Let us discuss a two-winding transformer, which is the also basic component of three-winding
transformer, represented by the equivalent PI circuit as shown in Figure 5.1. The transformer tap
ratio is setting as 1:k

. The branch admittance elements can be calculated from its PI equivalent


circuit.
i
j
1: k
*
Y
T
i
j
Y
T
/k
*
k
*
-1
k
*
Y
T
k
*
-1
k
*
Y
T
2
FIGURE 5.1: Diagram of a two-winding transformer circuit
The branch self-admittance of bus i is obtained by the following equation.
Y
i
= Y
T
k

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

is on the same side of


the high-voltage rating. We know that bus 2 is the tap side of the T-L transformer, so the left bus
number is 2. Therefore, the tap ratio equals 1.05, when bus 2 to bus 4 is lled in the tabulated
blank. And about T-R transformer, vice versa. Table 5.11 is listed line standard data for PFATB.
12 Introduction to PFATB
TABLE 5.9: Bus Data Structure In Polar Coordinate
Bus Bus Voltage Angle -Load- -Generator- Injected
No Type Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar
1 1 1 0 -1.6 -0.8 0 0 0 0 0
2 1 1 0 -2 -1 0 0 0 0 0
3 1 1 0 -3.7 -1.3 0 0 0 0 0
4 2 1.05 0 0 0 5 0 -50 50 0
5 3 1.05 0 0 0 0 0 -50 50 0
TABLE 5.10: Bus Data Structure In Rectangular Coordinate
Bus Bus Real Imaginary -Load- -Generator- Injected
No Type e f MW Mvar MW Mvar Qmin Qmax Mvar
1 1 1 0 -1.6 -0.8 0 0 0 0 0
2 1 1 0 -2 -1 0 0 0 0 0
3 1 1 0 -3.7 -1.3 0 0 0 0 0
4 2 1.05 0 0 0 5 0 -50 50 0
5 3 1.05 0 0 0 0 0 -50 50 0
TABLE 5.11: Line Data Structure
Bus Bus R X 1/2 B Tr.Tap Setting
nl nr p.u. p.u. p.u. p.u.
1 2 0.04 0.25 0.25 1
1 3 0.01 0.35 0 1
2 3 0.08 0.30 0.25 1
2 4 0 0.015 0 1.05
3 5 0 0.030 0 1.05
Introduction to PFATB 13
6 TOOLBOX FUNCTIONS
In this section, we start to introduce PFATB toolbox functions. It begins with a list of functions
categorized by steps in toolbox design process. Each functions will be described in a sequence of
its utility intention, function syntax and its description. Information about individual functions
is also available through the function help facility in MATLAB command window.
6.1 Data Pre-processing
sortbus returns the bus data matrix in the required sequence of bus type(PQ-PV-Swing).
Syntax
[bus,line,nPQ,nPV,nodenum] = sortbus(bus,line)
Description
[bus,line,nPQ,nPV,nodenum] = sortbus(bus,line) returns the standard bus data and standard
line data in the required sequence of bus type(PQ-PV-Swing), described in Section 5; nPQ and
nPV are the counts of the PQ & PV bus numbers; nodenum is the matrix to record which bus
number is to be changed.
Example 6.1
As shown in Figure 6.1, the 3-bus sample system is tested for processing standard data. The
M-le ex1.m is the program codes to exemplify how to present solutions of the sorting process.
Try the following:
1 3
2
0.01+j0.04
-j3.03 y
30
0.05+j0.20
FIGURE 6.1: 3-bus sample system
% ex1.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 0 0 0 0 0 0 0 0
2 1 1 0 0.8 0.6 0 0 0 0 0
14 Introduction to PFATB
3 2 1.1 0 0 0 0.4 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 3 0.05 0.20 0 1
2 1 0.01 0.04 0 1
3 0 0 0 3.03 1];
[bus,line,nPQ,nPV,nodenum] = sortbus(bus,line)
format bank
The ex1.m results in
bus =
1.00 1.00 1.00 0 0.80 0.60 0 0 0 0 0
2.00 2.00 1.10 0 0 0 0.40 0 0.5 0.5 0
3.00 3.00 1.00 0 0 0 0 0 0.5 0.5 0
line =
3.00 2.00 0.05 0.20 0 1.00
1.00 3.00 0.01 0.04 0 1.00
2.00 0 0 0 3.03 1.00
nPQ =
1.00
nPV =
1.00
nodenum =
1.00 2.00
2.00 3.00
3.00 1.00
busAM returns the bus admittance matrix.
Syntax
Y = busAM(bus,line)
Description
Y = busAM(bus,line) returns bus admittance matrix. Its diagonal element Y
ii
is known as
the self-admittance or driving point admittance of bus i, which equals the sum of all branch
admittances connecting to bus i. The o-diagonal element of the bus admittance matrix Y
ij
is
known as the mutual admittance or transfer admittance, which equals the negative of branch
admittance connecting bus i to bus j. If theres no line between the nodes, the term of admittance
is zero.
Bpq returns the bus admittance matrix B

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

only contain the imagination part of bus admittance matrix.


If the model is omitted, simplied is set in default.
[B1,B2,Y] = Bpq(bus,line,nPQ,XB) returns the bus admittance 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

p.u. The data for the voltage-controlled buses is


TABLE 8.1: Regulated Bus Data
Bus Voltage Min.Mvar Max.Mvar
No. Magnitude Capacity Capacity
2 1.043 -40 50
5 1.010 -40 40
8 1.010 -10 40
11 1.082 -6 24
13 1.071 -6 24
Transformer tap setting are given in Table 8.2 below. The left bus number is assumed to be the
tap side of the transformer. The data for the injected Q due to shunt capacitors is in Table 8.3.
TABLE 8.2: Transformers Data
Transformer Tap Setting
Designation p.u.
4-12 0.932
6-9 0.978
6-10 0.969
28-27 0.968
TABLE 8.3: Shunt Capacitors Data
Bus No. Mvar
10 19
24 4.3
The load data and generation parameters are given in the toolbox le named TEST_IEEE30BUS.m.
And the general base MVA is at 100MVA.
Introduction to PFATB 61
FIGURE 8.1: IEEE 30-Bus Test System
The following program is prompted to be run with Gauss-Seidel algorithm, Newton-Raphson
algorithm and P-Q decoupling algorithm. Let us try the following:
% TEST_IEEE30BUS.m
clc;
clear all
basemva = 100;
%% IEEE 30BUS TEST SYSTEM DATA
% IEEE 30BUS TEST SYSTEM (American Electric Power)
% Bus Bus Voltage Angle Load Generator Static Mvar
% No Type Mag. Degree MW Mvar MW Mvar Qmin Qmax +Qc/Ql
62 Introduction to PFATB
bus = [1 3 1.06 0 0.0 0.0 0 0 0 0 0
2 2 1.043 0 21.70 12.7 40 0 40 50 0
3 1 1.0 0 2.4 1.2 0 0 0 0 0
4 1 1.06 0 7.6 1.6 0 0 0 0 0
5 2 1.01 0 94.2 19.0 0 0 40 40 0
6 1 1.0 0 0.0 0.0 0 0 0 0 0
7 1 1.0 0 22.8 10.9 0 0 0 0 0
8 2 1.01 0 30.0 30.0 0 0 10 40 0
9 1 1.0 0 0.0 0.0 0 0 0 0 0
10 1 1.0 0 5.8 2.0 0 0 0 0 19
11 2 1.082 0 0.0 0.0 0 0 6 24 0
12 1 1.0 0 11.2 7.5 0 0 0 0 0
13 2 1.071 0 0 0.0 0 0 6 24 0
14 1 1 0 6.2 1.6 0 0 0 0 0
15 1 1 0 8.2 2.5 0 0 0 0 0
16 1 1 0 3.5 1.8 0 0 0 0 0
17 1 1 0 9.0 5.8 0 0 0 0 0
18 1 1 0 3.2 0.9 0 0 0 0 0
19 1 1 0 9.5 3.4 0 0 0 0 0
20 1 1 0 2.2 0.7 0 0 0 0 0
21 1 1 0 17.5 11.2 0 0 0 0 0
22 1 1 0 0 0.0 0 0 0 0 0
23 1 1 0 3.2 1.6 0 0 0 0 0
24 1 1 0 8.7 6.7 0 0 0 0 4.3
25 1 1 0 0 0.0 0 0 0 0 0
26 1 1 0 3.5 2.3 0 0 0 0 0
27 1 1 0 0 0.0 0 0 0 0 0
28 1 1 0 0 0.0 0 0 0 0 0
29 1 1 0 2.4 0.9 0 0 0 0 0
30 1 1 0 10.6 1.9 0 0 0 0 0];
% Bus Data Preprocessing
bus(:,5:6) = bus(:,5:6) ./ basemva;
bus(:,7:11) = bus(:,7:11) ./ basemva;
% Line code
% Bus Bus R X 1/2 B Tr.Tap Setting
% nl nr p.u. p.u. p.u. p.u.
line = [1 2 0.0192 0.0575 0.02640 1
1 3 0.0452 0.1852 0.02040 1
2 4 0.0570 0.1737 0.01840 1
3 4 0.0132 0.0379 0.00420 1
2 5 0.0472 0.1983 0.02090 1
2 6 0.0581 0.1763 0.01870 1
4 6 0.0119 0.0414 0.00450 1
5 7 0.0460 0.1160 0.01020 1
6 7 0.0267 0.0820 0.00850 1
6 8 0.0120 0.0420 0.00450 1
6 9 0 0.2080 0 0.978
6 10 0 0.5560 0 0.969
9 11 0 0.2080 0 1
9 10 0 0.1100 0 1
4 12 0 0.2560 0 0.932
12 13 0 0.1400 0 1
12 14 0.1231 0.2559 0 1
12 15 0.0662 0.1304 0 1
12 16 0.0945 0.1987 0 1
14 15 0.2210 0.1997 0 1
16 17 0.0824 0.1923 0 1
15 18 0.1073 0.2185 0 1
Introduction to PFATB 63
18 19 0.0639 0.1292 0 1
19 20 0.0340 0.0680 0 1
10 20 0.0936 0.2090 0 1
10 17 0.0324 0.0845 0 1
10 21 0.0348 0.0749 0 1
10 22 0.0727 0.1499 0 1
21 22 0.0116 0.0236 0 1
15 23 0.1000 0.2020 0 1
22 24 0.1150 0.1790 0 1
23 24 0.1320 0.2700 0 1
24 25 0.1885 0.3292 0 1
25 26 0.2544 0.3800 0 1
25 27 0.1093 0.2087 0 1
28 27 0 0.3960 0 0.968
27 29 0.2198 0.4153 0 1
27 30 0.3202 0.6027 0 1
29 30 0.2399 0.4533 0 1
8 28 0.0636 0.2000 0.0214 1
6 28 0.0169 0.0599 0.065 1];
%% GaussSeidel
[bus_res,s_res,k] = GS(bus,line,10e4,200);
%% NewtonRaphson With Polar Coordinate Method
[bus_res,s_res,k] = NRpm(bus,line);
%% NewtonRaphson With Rectangualr Coordinate Method
[bus_res,s_res,k] = NRcm(bus,line);
%% PQ Decoupling With Polar Coordinate Method
[bus_res,s_res,k] = PQpm(bus,line);
Let us visualize power ow analysis of IEEE 30-bus Test System in Figure 8.2 Figure 8.5. Figure
8.2 shows the sparsity pattern of the Ybus matrix .
0 5 10 15 20 25 30
0
5
10
15
20
25
30
nonzeros=112 (12.444%)
Y Sparse Symmetric Matrix
FIGURE 8.2: Ybus Sparse Symmetric Matrix
64 Introduction to PFATB
Figure 8.3 shows 2D-visualization of each bus magnitude and Figure 8.4 shows 3D-visualization
of each bus magnitude.
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29
0.98
1
1.02
1.04
1.06
1.08
1.1
2Dvisualization of bus voltage magnitude
FIGURE 8.3: 2D-visualization of each bus magni-
tude
FIGURE 8.4: 3D-visualization of each bus magni-
tude
The solution data solved in N-R algorithms and P-Q decoupling algorithm is attached as Ap-
pendix Ain detail. Meantime, Figure 8.5 Figure 8.8 generated by evaluating the above command
statements show the graphs of algorithm convergence.
0 20 40 60 80 100 120
0
1
2
3
4
5
6
The Convergence Graph of GaussSeidel Algorithm
Iterations
S
p
e
e
d


E Increments
F Increments
FIGURE 8.5: The convergence speed of Gauss-
Seidel algorithm
1 1.5 2 2.5 3 3.5 4
0
0.2
0.4
0.6
0.8
1
1.2
1.4
The Convergence Graph of NewtonRaphson Algorithm
Iterations
S
p
e
e
d


Magnitude Increments
Angle Increments
FIGURE 8.6: The convergence speed of Newton-
Raphson with polar coordinate method
1 1.5 2 2.5 3 3.5 4 4.5 5
0
0.2
0.4
0.6
0.8
1
1.2
1.4
The Convergence Graph of NewtonRaphson Algorithm
Iterations
S
p
e
e
d


E Increments
F Increments
FIGURE 8.7: The convergence speed of Newton-
Raphson with rectangular coordinate method
0 5 10 15 20 25 30 35 40
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
The Convergence Graph of PQ Decoupling Algorithm
Iterations
S
p
e
e
d


Magnitude Increments
Angle Increments
FIGURE 8.8: The convergence speed of P-Q decou-
pling algorithm
Introduction to PFATB 65
9 FURTHER REVERSIONS
Owing to the limitation of time and ability, I acclaim PFATB is now only a courseware package
with limited utility beyond the classroom clearly. Nevertheless, I will be very glad to receive
corrections and/or constructive criticisms from you through sending me emails. Kind under-
standing and cooperation will be much appreciated.
66 Introduction to PFATB
REFERENCES
[1] Jizhong Zhu, Optimization of Power System Operation, Wiley & IEEE Press,2009.
[2] Hadi Saadat, Power System Analysis(2nd Edition), New York:McGraw-Hill,2002.
[3] J.Duncan Glover,Mulukutla S.Sarma,Thomas J.Overbye, Power System Analysis and De-
sign(4th Edition), Canada:Thomson Learning,2008.
[4] Brain Hahn,Daniel T.Valentine, Essential MATLAB For Engineers and Scientists(3rd Edi-
tion), Elsevier Butterworth Heinemann,2007.
[5] Richard Johnson, MATLAB Programming Style Guidelines,
Online: http://www.datatool.com/downloads/matlab_style_guidelines.pdf
Introduction to PFATB 67
A APPENDIX IEEE 30-BUS SOLUTIONS
In order to show how well PFATB works, the power ow solution of IEEE 30-Bus Test System has
been tabulated as key answers for practice. Ive listed 3 solutions mentioned in Section 8 in this
appendix.
Solution 1: Power Flow Solution by N-R Algorithm With Polar Coordinate Method
Power Flow Solution by NR Algorithm With Polar Coordinate Method
Maximum Active Power Mismatch = 5.59723e007
Maximum Reactive Power Mismatch = 7.54898e007
No. of Iterations = 4
Bus Voltage Angle Load Generation Injected
No. Mag. Degree MW Mvar MW Mvar Mvar
1 1.060 0.000 0.000 0.000 2.610 0.170 0.000
2 1.043 5.497 0.217 0.127 0.400 0.488 0.000
3 1.022 8.004 0.024 0.012 0.000 0.000 0.000
4 1.013 9.661 0.076 0.016 0.000 0.000 0.000
5 1.010 14.381 0.942 0.190 0.000 0.360 0.000
6 1.012 11.398 0.000 0.000 0.000 0.000 0.000
7 1.003 13.150 0.228 0.109 0.000 0.000 0.000
8 1.010 12.115 0.300 0.300 0.000 0.308 0.000
9 1.051 14.434 0.000 0.000 0.000 0.000 0.000
10 1.044 16.024 0.058 0.020 0.000 0.000 0.190
11 1.082 14.434 0.000 0.000 0.000 0.161 0.000
12 1.057 15.302 0.112 0.075 0.000 0.000 0.000
13 1.071 15.302 0.000 0.000 0.000 0.104 0.000
14 1.042 16.191 0.062 0.016 0.000 0.000 0.000
15 1.038 16.278 0.082 0.025 0.000 0.000 0.000
16 1.045 15.880 0.035 0.018 0.000 0.000 0.000
17 1.039 16.188 0.090 0.058 0.000 0.000 0.000
18 1.028 16.884 0.032 0.009 0.000 0.000 0.000
19 1.025 17.052 0.095 0.034 0.000 0.000 0.000
20 1.029 16.852 0.022 0.007 0.000 0.000 0.000
21 1.032 16.468 0.175 0.112 0.000 0.000 0.000
22 1.033 16.455 0.000 0.000 0.000 0.000 0.000
23 1.027 16.662 0.032 0.016 0.000 0.000 0.000
24 1.022 16.830 0.087 0.067 0.000 0.000 0.043
25 1.019 16.424 0.000 0.000 0.000 0.000 0.000
26 1.001 16.842 0.035 0.023 0.000 0.000 0.000
27 1.026 15.912 0.000 0.000 0.000 0.000 0.000
28 1.011 12.057 0.000 0.000 0.000 0.000 0.000
29 1.006 17.136 0.024 0.009 0.000 0.000 0.000
30 0.995 18.015 0.106 0.019 0.000 0.000 0.000
Total 2.834 1.262 3.010 1.251 0.233
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.778+j 0.221 1.723+j 0.327 0.055 0.105
1 3 0.832+j 0.051 0.804+j 0.020 0.028 0.071
2 4 0.457+j 0.027 0.446+j 0.032 0.011 0.005
68 Introduction to PFATB
3 4 0.780+j 0.032 0.772+j 0.045 0.008 0.013
2 5 0.830+j 0.017 0.800+j 0.065 0.030 0.082
2 6 0.619+j 0.010 0.599+j 0.032 0.020 0.023
4 6 0.701+j 0.175 0.695+j 0.187 0.006 0.012
5 7 0.142+j 0.105 0.144+j 0.122 0.002 0.017
6 7 0.375+j 0.019 0.372+j 0.013 0.004 0.006
6 8 0.295+j 0.038 0.294+j 0.032 0.001 0.006
6 9 0.277+j 0.297 0.277+j 0.331 0.000 0.034
6 10 0.158+j 0.113 0.158+j 0.134 0.000 0.021
9 11 0.000+j 0.157 0.000+j 0.161 0.000 0.005
9 10 0.277+j 0.067 0.277+j 0.059 0.000 0.008
4 12 0.441+j 0.460 0.441+j 0.561 0.000 0.101
12 13 0.000+j 0.103 0.000+j 0.104 0.000 0.001
12 14 0.079+j 0.024 0.078+j 0.023 0.001 0.002
12 15 0.179+j 0.069 0.176+j 0.065 0.002 0.004
12 16 0.072+j 0.034 0.072+j 0.033 0.001 0.001
14 15 0.016+j 0.007 0.016+j 0.007 0.000 0.000
16 17 0.037+j 0.015 0.036+j 0.014 0.000 0.000
15 18 0.060+j 0.017 0.060+j 0.017 0.000 0.001
18 19 0.028+j 0.008 0.028+j 0.008 0.000 0.000
19 20 0.067+j 0.026 0.067+j 0.027 0.000 0.000
10 20 0.090+j 0.036 0.089+j 0.034 0.001 0.002
10 17 0.054+j 0.044 0.054+j 0.044 0.000 0.000
10 21 0.157+j 0.098 0.156+j 0.096 0.001 0.002
10 22 0.076+j 0.045 0.075+j 0.044 0.001 0.001
21 22 0.019+j 0.016 0.019+j 0.016 0.000 0.000
15 23 0.050+j 0.030 0.050+j 0.029 0.000 0.001
Total 0.050+j 0.030 0.050+j 0.029 0.176 0.307
Solution 2: Power Flow Solution by N-R Algorithm With Rectangular Coordinate Method
Power Flow Solution by NR Algorithm With Rectangular Coordinate Method
Maximum Active Power Mismatch = 2.96612e011
Maximum Reactive Power Mismatch = 8.25393e011
No. of Iterations = 5
Bus Real Imaginary Load Generation Injected
No. E F MW Mvar MW Mvar Mvar
1 1.060 0.000 0.000 0.000 2.610 0.170 0.000
2 1.038 0.100 0.217 0.127 0.400 0.488 0.000
3 1.012 0.142 0.024 0.012 0.000 0.000 0.000
4 0.998 0.170 0.076 0.016 0.000 0.000 0.000
5 0.978 0.251 0.942 0.190 0.000 0.360 0.000
6 0.992 0.200 0.000 0.000 0.000 0.000 0.000
7 0.977 0.228 0.228 0.109 0.000 0.000 0.000
8 0.988 0.212 0.300 0.300 0.000 0.308 0.000
9 1.018 0.262 0.000 0.000 0.000 0.000 0.000
10 1.004 0.288 0.058 0.020 0.000 0.000 0.190
11 1.048 0.270 0.000 0.000 0.000 0.161 0.000
12 1.020 0.279 0.112 0.075 0.000 0.000 0.000
13 1.033 0.283 0.000 0.000 0.000 0.104 0.000
14 1.001 0.291 0.062 0.016 0.000 0.000 0.000
15 0.996 0.291 0.082 0.025 0.000 0.000 0.000
16 1.005 0.286 0.035 0.018 0.000 0.000 0.000
17 0.998 0.290 0.090 0.058 0.000 0.000 0.000
18 0.984 0.299 0.032 0.009 0.000 0.000 0.000
19 0.980 0.301 0.095 0.034 0.000 0.000 0.000
Introduction to PFATB 69
20 0.985 0.298 0.022 0.007 0.000 0.000 0.000
21 0.990 0.293 0.175 0.112 0.000 0.000 0.000
22 0.990 0.293 0.000 0.000 0.000 0.000 0.000
23 0.984 0.295 0.032 0.016 0.000 0.000 0.000
24 0.978 0.296 0.087 0.067 0.000 0.000 0.043
25 0.977 0.288 0.000 0.000 0.000 0.000 0.000
26 0.958 0.290 0.035 0.023 0.000 0.000 0.000
27 0.986 0.281 0.000 0.000 0.000 0.000 0.000
28 0.988 0.211 0.000 0.000 0.000 0.000 0.000
29 0.961 0.296 0.024 0.009 0.000 0.000 0.000
30 0.946 0.308 0.106 0.019 0.000 0.000 0.000
Total 2.834 1.262 3.010 1.251 0.233
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.778+j 0.221 1.723+j 0.327 0.055 0.105
1 3 0.832+j 0.051 0.804+j 0.020 0.028 0.071
2 4 0.457+j 0.027 0.446+j 0.032 0.011 0.005
3 4 0.780+j 0.032 0.772+j 0.045 0.008 0.013
2 5 0.830+j 0.017 0.800+j 0.065 0.030 0.082
2 6 0.619+j 0.010 0.599+j 0.032 0.020 0.023
4 6 0.701+j 0.175 0.695+j 0.187 0.006 0.012
5 7 0.142+j 0.105 0.144+j 0.122 0.002 0.017
6 7 0.375+j 0.019 0.372+j 0.013 0.004 0.006
6 8 0.295+j 0.038 0.294+j 0.032 0.001 0.006
6 9 0.277+j 0.297 0.277+j 0.331 0.000 0.034
6 10 0.158+j 0.113 0.158+j 0.134 0.000 0.021
9 11 0.000+j 0.157 0.000+j 0.161 0.000 0.005
9 10 0.277+j 0.067 0.277+j 0.059 0.000 0.008
4 12 0.441+j 0.460 0.441+j 0.561 0.000 0.101
12 13 0.000+j 0.103 0.000+j 0.104 0.000 0.001
12 14 0.079+j 0.024 0.078+j 0.023 0.001 0.002
12 15 0.179+j 0.069 0.176+j 0.065 0.002 0.004
12 16 0.072+j 0.034 0.072+j 0.033 0.001 0.001
14 15 0.016+j 0.007 0.016+j 0.007 0.000 0.000
16 17 0.037+j 0.015 0.036+j 0.014 0.000 0.000
15 18 0.060+j 0.017 0.060+j 0.017 0.000 0.001
18 19 0.028+j 0.008 0.028+j 0.008 0.000 0.000
19 20 0.067+j 0.026 0.067+j 0.027 0.000 0.000
10 20 0.090+j 0.036 0.089+j 0.034 0.001 0.002
10 17 0.054+j 0.044 0.054+j 0.044 0.000 0.000
10 21 0.157+j 0.098 0.156+j 0.096 0.001 0.002
10 22 0.076+j 0.045 0.075+j 0.044 0.001 0.001
21 22 0.019+j 0.016 0.019+j 0.016 0.000 0.000
15 23 0.050+j 0.030 0.050+j 0.029 0.000 0.001
Total 0.050+j 0.030 0.050+j 0.029 0.176 0.307
Solution 3: Power FlowSolution by P-QDecoupling AlgorithmWith Polar Coordinate Method
Power Flow Solution by PQ Decoupling Algorithm With Polar Coordinate Method
Maximum Active Power Mismatch = 5.85519e006
Maximum Reactive Power Mismatch = 2.98278e006
No. of Iterations = 37
70 Introduction to PFATB
Bus Voltage Angle Load Generation Injected
No. Mag. Degree MW Mvar MW Mvar Mvar
1 1.060 0.000 0.000 0.000 2.610 0.170 0.000
2 1.043 5.497 0.217 0.127 0.400 0.488 0.000
3 1.022 8.004 0.024 0.012 0.000 0.000 0.000
4 1.013 9.661 0.076 0.016 0.000 0.000 0.000
5 1.010 14.381 0.942 0.190 0.000 0.360 0.000
6 1.012 11.398 0.000 0.000 0.000 0.000 0.000
7 1.003 13.150 0.228 0.109 0.000 0.000 0.000
8 1.010 12.115 0.300 0.300 0.000 0.308 0.000
9 1.051 14.434 0.000 0.000 0.000 0.000 0.000
10 1.044 16.024 0.058 0.020 0.000 0.000 0.190
11 1.082 14.434 0.000 0.000 0.000 0.161 0.000
12 1.057 15.302 0.112 0.075 0.000 0.000 0.000
13 1.071 15.302 0.000 0.000 0.000 0.104 0.000
14 1.042 16.191 0.062 0.016 0.000 0.000 0.000
15 1.038 16.278 0.082 0.025 0.000 0.000 0.000
16 1.045 15.880 0.035 0.018 0.000 0.000 0.000
17 1.039 16.188 0.090 0.058 0.000 0.000 0.000
18 1.028 16.884 0.032 0.009 0.000 0.000 0.000
19 1.025 17.052 0.095 0.034 0.000 0.000 0.000
20 1.029 16.852 0.022 0.007 0.000 0.000 0.000
21 1.032 16.468 0.175 0.112 0.000 0.000 0.000
22 1.033 16.455 0.000 0.000 0.000 0.000 0.000
23 1.027 16.662 0.032 0.016 0.000 0.000 0.000
24 1.022 16.830 0.087 0.067 0.000 0.000 0.043
25 1.019 16.424 0.000 0.000 0.000 0.000 0.000
26 1.001 16.842 0.035 0.023 0.000 0.000 0.000
27 1.026 15.912 0.000 0.000 0.000 0.000 0.000
28 1.011 12.057 0.000 0.000 0.000 0.000 0.000
29 1.006 17.136 0.024 0.009 0.000 0.000 0.000
30 0.995 18.015 0.106 0.019 0.000 0.000 0.000
Total 2.834 1.262 3.010 1.251 0.233
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.778+j 0.221 1.723+j 0.327 0.055 0.105
1 3 0.832+j 0.051 0.804+j 0.020 0.028 0.071
2 4 0.457+j 0.027 0.446+j 0.032 0.011 0.005
3 4 0.780+j 0.032 0.772+j 0.045 0.008 0.013
2 5 0.830+j 0.017 0.800+j 0.065 0.030 0.082
2 6 0.619+j 0.010 0.599+j 0.032 0.020 0.023
4 6 0.701+j 0.175 0.695+j 0.187 0.006 0.012
5 7 0.142+j 0.105 0.144+j 0.122 0.002 0.017
6 7 0.375+j 0.019 0.372+j 0.013 0.004 0.006
6 8 0.295+j 0.038 0.294+j 0.032 0.001 0.006
6 9 0.277+j 0.297 0.277+j 0.331 0.000 0.034
6 10 0.158+j 0.113 0.158+j 0.134 0.000 0.021
9 11 0.000+j 0.157 0.000+j 0.161 0.000 0.005
9 10 0.277+j 0.067 0.277+j 0.059 0.000 0.008
4 12 0.441+j 0.460 0.441+j 0.561 0.000 0.101
12 13 0.000+j 0.103 0.000+j 0.104 0.000 0.001
12 14 0.079+j 0.024 0.078+j 0.023 0.001 0.002
Introduction to PFATB 71
12 15 0.179+j 0.069 0.176+j 0.065 0.002 0.004
12 16 0.072+j 0.034 0.072+j 0.033 0.001 0.001
14 15 0.016+j 0.007 0.016+j 0.007 0.000 0.000
16 17 0.037+j 0.015 0.036+j 0.014 0.000 0.000
15 18 0.060+j 0.017 0.060+j 0.017 0.000 0.001
18 19 0.028+j 0.008 0.028+j 0.008 0.000 0.000
19 20 0.067+j 0.026 0.067+j 0.027 0.000 0.000
10 20 0.090+j 0.036 0.089+j 0.034 0.001 0.002
10 17 0.054+j 0.044 0.054+j 0.044 0.000 0.000
10 21 0.157+j 0.098 0.156+j 0.096 0.001 0.002
10 22 0.076+j 0.045 0.075+j 0.044 0.001 0.001
21 22 0.019+j 0.016 0.019+j 0.016 0.000 0.000
15 23 0.050+j 0.030 0.050+j 0.029 0.000 0.001
Total 0.050+j 0.030 0.050+j 0.029 0.176 0.307

Das könnte Ihnen auch gefallen