Particle Swarm Optimization Based Reactive Power Dispatch For Pow
Particle Swarm Optimization Based Reactive Power Dispatch For Pow
Digital Commons @ DU
1-1-2015
Recommended Citation
Kou, Xiao, "Particle Swarm Optimization Based Reactive Power Dispatch for Power Networks with
Distributed Generation" (2015). Electronic Theses and Dissertations. 1035.
https://digitalcommons.du.edu/etd/1035
This Thesis is brought to you for free and open access by the Graduate Studies at Digital Commons @ DU. It has
been accepted for inclusion in Electronic Theses and Dissertations by an authorized administrator of Digital
Commons @ DU. For more information, please contact jennifer.cox@du.edu,dig-commons@du.edu.
PARTICLE SWARM OPTIMIZATION BASED REACTIVE POWER DISPATCH
FOR POWER NETWORKS WITH DISTRIBUTED GENERATION
__________
A Thesis
Presented to
The Faculty of Daniel Felix Ritchie School of Engineering and Computer Science
University of Denver
__________
In Partial Fulfillment
Master of Science
__________
by
Xiao Kou
August 2015
Abstract
Reactive power is critical to the operation of the power networks on both safety
aspects and economic aspects. Unreasonable distribution of the reactive power would
severely affect the power quality of the power networks and increases the transmission
loss. Currently, the most economical and practical approach to minimizing the real power
Reactive power dispatch problem is nonlinear and has both equality constraints
and inequality constraints. In this thesis, PSO algorithm and MATPOWER 5.1 toolbox
are applied to solve the reactive power dispatch problem. PSO is a global optimization
technique that is equipped with excellent searching capability. The biggest advantage of
PSO is that the efficiency of PSO is less sensitive to the complexity of the objective
function. MATPOWER 5.1 is an open source MATLAB toolbox focusing on solving the
power flow problems. The benefit of MATPOWER is that its code can be easily used and
modified.
The proposed method in this thesis minimizes the real power loss in a practical
power system and determines the optimal placement of a new installed DG. IEEE 14 bus
system is used to evaluate the performance. Test results show the effectiveness of the
proposed method.
ii
Acknowledgements
Gao, for his selfless support during my two years study at the University of Denver. Dr.
Gao’s rigorous attitude towards scholarship and humility deeply impressed me and will
members, Prof. Jason Jun Zhang, and Prof. Amin Khodaei. Thank you for your time in
My thanks also go to all my lab mates in the Renewable Energy and Power
Electronics Lab at the University of Denver. Your help and support are greatly
appreciated.
Last but not least, I would like to thank my family, for your unconditional love
iii
Table of Contents
References ......................................................................................................................... 71
Appendix A MATLAB Code for Reactive Power Dispatch without New DGs ............ 76
Appendix B MATLAB Code for Reactive Power Dispatch with a New DG Installed on
PQ Bus .............................................................................................................................. 82
v
List of Tables
Table 4.4 IEEE 14 Bus System Reactive Power Injection Parameter ...................... 39
Table 4.5 Comparison of the Real Power Loss at Each Branch ............................... 41
Table 4.6 Optimization Results with a New DG Installed on Different Buses ........ 56
Table 4.8 Optimization Results when DG Deliver 25% Rated Power ..................... 62
Table 4.9 Optimization Results when DG Deliver 50% Rated Power ..................... 64
Table 4.10 Optimization Results when DG Deliver 75% Rated Power ................... 66
vi
List of Figures
Figure 1.1 Five Bus System without Power Factor Correction .................................. 3
Figure 2.1 Local Minimum Value versus Global Minimum Value .......................... 13
Figure 3.1 Canonical Form of the IEEE 14 Bus System Generator Data ................. 29
Figure 3.2 Canonical Form of the IEEE 14 Bus System Branch Data ..................... 31
Figure 3.3 Canonical Form of the IEEE 14 Bus System Bus Data........................... 32
Figure 3.4 Flow Chart of the PSO Based Reactive Power Dispatch ........................ 35
Figure 4.4 Reactive Power Capacity of Enercon E82 (2010 FACTS-WT) .............. 43
Figure 4.6 Generator Data of the Modified System when the DG is Installed on Bus
2......................................................................................................................... 44
Figure 4.7 Generator Data of the Modified System when the DG is Installed on Bus
3......................................................................................................................... 44
vii
Figure 4.8 Generator Data of the Modified System when the DG is Installed on Bus
6......................................................................................................................... 45
Figure 4.9 Generator Data of the Modified System when the DG is Installed on Bus
8......................................................................................................................... 45
Figure 4.10 Coordinates of the Particle when the New DG is connected to a PV Bus
........................................................................................................................... 45
Figure 4.11 Coordinates of the Particle when the New DG is on a PQ Bus ............. 46
Figure 4.12 Bus Data of the Modified System when the DG is Installed on Bus 4 . 46
Figure 4.13 Generator Data of the Modified System when the DG is Installed on Bus
4......................................................................................................................... 47
Figure 4.14 Bus Data of the Modified System when the DG is Installed on Bus 5 . 47
Figure 4.15 Generator Data of the Modified System when the DG is Installed on Bus
5......................................................................................................................... 48
Figure 4.16 Bus Data of the Modified System when the DG is Installed on Bus 7 . 48
Figure 4.17 Generator Data of the Modified System when the DG is Installed on Bus
7......................................................................................................................... 49
Figure 4.18 Bus Data of the Modified System when the DG is Installed on Bus 9 . 49
Figure 4.19 Generator Data of the Modified System when the DG is Installed on Bus
9......................................................................................................................... 50
Figure 4.20 Bus Data of the Modified System when the DG is Installed on Bus 10 50
Figure 4.21 Generator Data of the Modified System when the DG is Installed on Bus
10....................................................................................................................... 51
Figure 4.22 Bus Data of the Modified System when the DG is Installed on bus 11 51
Figure 4.23 Generator Data of the Modified System when the DG is Installed on Bus
11....................................................................................................................... 52
Figure 4.24 Bus Data of the Modified System when the DG is Installed on Bus 12 52
Figure 4.25 Generator Data of the Modified System when the DG is Installed on Bus
12....................................................................................................................... 53
Figure 4.26 Bus Data of the Modified System when the DG is Installed on Bus 13 53
viii
Figure 4.27 Generator Data of the Modified System when the DG is Installed on Bus
13....................................................................................................................... 54
Figure 4.28 Bus Data of the Modified System when the DG is Installed on Bus 14 54
Figure 4.29 Generator Data of the Modified System when the DG is Installed on Bus
14....................................................................................................................... 55
Figure 4.31 Loss Reduction Process when the new DG is Installed on Bus 3 ......... 60
Figure 4.33 Generators Data when the New Installed DG Delivers 25% Rated Power
........................................................................................................................... 61
Figure 4.34 Loss Reduction Process when DG Delivers 25% Rated Power ............ 62
Figure 4.35 Generators Data when the New Installed DG Delivers 50% Rated Power
........................................................................................................................... 63
Figure 4.36 Loss Reduction Process when DG Delivers 50% Rated Power ............ 64
Figure 4.37 Generators Data when the New Installed DG Delivers 75% Rated Power
........................................................................................................................... 65
Figure 4.38 Loss Reduction Process when DG Delivers 75% Rated Power ............ 66
ix
Chapter One: Introduction
Reactive power is critical to the operation of the power networks on both safety
aspects and economic aspects. Rational reactive power dispatch scheme can improve the
power quality as well as reduce the real power loss. On the contrary, if the reactive power
is unreasonably allocated, then it will bring great economic losses and might even
It has been proved that the New York Blackout in 1977 and the Tokyo Blackout
in 1987 were both caused by the deficiency of reactive power during the peak load hours
[1]. These blackouts brought social disruptions and hundreds of millions of dollars in loss.
On August 14, 2003, the Northeast Blackout affected about 55 million people in the mid-
western part of the United States and Ontario province in Canada. One of the main
reasons that causing this blackout is also due to the reactive power shortage [2-3].
Reactive power also plays a prominent role in minimizing the real power loss of
the power networks. Reactive power dispatch approach can significantly reduce the
power factor angle of each bus, thus cutting the overall energy losses. Each year, a large
amount of electricity is wasted on the transmission or distribution lines around the world.
According to the estimations from the U.S. Energy Information Administration, the
annual transmission and distribution losses in the United States can reach as much as 6%
[4]. Moreover, most of this loss occurs at the distribution level. This real power loss not
1
only causes energy waste and produces extra carbon emission, but also increases the
generation cost.
Along with the development of the economic, the scale of the power grid also
keeps growing. In some areas, however, the construction and upgrading of the power grid
did not keep pace with the growth of the loads. Then a severe shortage of the reactive
power would appear. For the purpose of minimizing the real power loss, utility
companies can either change the structure of the power grid or replace the old wiring
with lower impedance lines. However, both of these methods requires investing large
amounts of money. The simplest and most economical way remains reactive power
dispatch method. In the early days, the starting point of reactive power dispatch is to
improve the power factor at each end user by installing reactive power compensators.
This approach, of course, can reduce the total power loss. But in order to get the
maximum profit, electricity grid designers have to take a more holistic view and calculate
There are many reactive compensation techniques. Fig. 1.1 shows a simple five
bus system without using any reactive power compensators. This model is developed in
PowerWorld Simulator 17 [5]. The real and reactive power output of the generators are
304 MW and 129 MVar, respectively. Since there is no capacitor in this system, the
generator will take the whole burden of both real power loads and reactive power loads.
2
Running the simulation, a 4.27 MW real power loss and 8.55 MVar reactive power loss
can be achieved.
In order to reduce the power loss, reactive power dispatch techniques can be
employed. The easiest way to compensate the reactive power is to connect the capacitors
in parallel with the loads. This approach can be further divided into single power factor
correction, group power factor correction, and bulk power factor correction [6].
In single power factor correction model, each load has a shunt capacitor. The
capacitor and the load it serves share the same switch, so no extra control devices are
needed in this scheme. When the capacitors inject reactive power, both transmission loss
and voltage drop will decrease. In this case, the real power loss is 3.84 MW and the
reactive power loss is 7.67 MVar. The disadvantage of this method is that the shunt
3
capacitors are not fully utilized all the time. Since the load and its shunt capacitor use the
same switch, the capacitor will not compensate reactive power if the load is turned off.
effective way called group power factor correction was proposed. The PowerWorld
model for group power factor correction method is shown in Fig. 1.3.
In this method, instead of just compensating only one load, one capacitor could
handle a group of loads. Also, the reactive power injection are controlled by a
microprocessor based on the real-time reactive power demand. In the PowerWorld model,
the active power loss is 3.96 MW and the reactive power loss is 7.91 MVar, which are
slightly higher than those in single power factor correction method. However, the
4
Figure 1.3 Group Power Factor Correction
The third power factor correction method is called bulk power factor correction,
as depicted in Fig. 1.4. The shunt capacitor bank is in charge of the whole system, and it
5
Since most of the loads in the electric power systems are inductive loads, they
will consume large amounts of reactive power. The reactive power has to be obtained
from somewhere in the network. If all the reactive power is produced from one place,
then the real power loss will be enormous. This conclusion is demonstrated in Fig. 1.4,
both real power loss and reactive power loss is much greater than the previous two
In this thesis, the approach of reactive power dispatch is to adjust the values of
control variables and find the optimal placement of new installed DG. Since both
objective function and equality constraints are nonlinear, the main emphasis is on
managing the nonlinear function problem with mixed discrete control variables.
The first reactive power dispatch method was suggested by N. M. Neagle and D.
R. Samson in 1956. In [7], Neagle and Samson analyzed two types of load models. In the
first model, the loads are equally distributed along the feeders. However, this type of
system is an idealized model, and it does not exist in real life. So in their second model,
they assume the magnitudes of the loads in a feeder are proportional to their distances
from the substation. The shortcoming of this method is that there is only one generator in
their models. Thus, this method is not suitable for those power grids with distributed
generation.
6
After that, interior-point method (or barrier method) is introduced to solve the
and constraints into Taylor’s series expansions. Only the first-order terms and the
programming theory is mature and the computation time is short. Nonetheless, since the
objective function of reactive power dispatch problem is not convex, many local optima
exist. Therefore, the linear programming method is very likely to get trapped into one of
these local optima and cannot achieve a global optimal solution. Moreover, linear
programming ignores the higher-order terms, so the accuracy of the results can also be
affected.
The quadratic programming method is another method that can be used to solve
the reactive power dispatch problem [8]. Quadratic programming is more adaptable to the
Furthermore, its nice convergence characteristic is also helpful. The disadvantage is that
quadratic programming does not work very well for the high dimensional problems. As
Since the 1990s, heuristic methods like Simulated Annealing (SA) and Genetic
Algorithm (GA) are getting more and more capable and grab plenty of attentions [9].
Simulated annealing imitates the heating and cooling process of the metal, and it
was suggested by Metropolis in 1953. SA use random search and iteration methods to
obtain the optimal solution. In metallurgy, the goal of annealing is to get the best metallic
7
crystal. When the cooling process is finished, the energy of the material becomes lowest.
This process is similar to optimizing the reactive power. The goal of reactive power
dispatch in this thesis is to get the minimum real power loss. The power loss will be
would greatly increase the computation time. T. Sousa et.al put forward a modified
simulated annealing method to search for the optimal size and placement of compensators
The genetic algorithm is based on mimicking the evolutionary process, and it was
presented by J. Howard in 1975. Genetic algorithm is totally different from the traditional
Selection, crossover and mutation operation are repeatedly conducted to propagate better
individuals in the next generation. GA provides a framework for solving the nonlinear
multi-objective complex problems, and it has already been used in many areas, such as
control, signal processing, robotics, and economics. The advantages of GA are its
University and posted for free online. The disadvantage of GA is its prematurity and
diversity problems. In [12], GA was proposed to solve the reactive power devices
8
The artificial neural network is an algorithm based on the neural networks of
animals [14]. The biggest advantage of artificial neural networks is its self-teaching
ability. For instance, given a certain amount of data, artificial neural networks algorithm
can gradually identify similar data through self-teaching. This benefit has important
significance on forecasting. Paper [15] presents a combined artificial neural networks and
fuzzy sets to solve the optimal reactive power control problems. In [16], the artificial
neural network algorithm is used on the online optimal shunt capacitors dispatch to
To sum up, each algorithm has its advantages and disadvantages. Therefore, local
conditions need to be considered in choosing the appropriate algorithm for solving the
This thesis summarizes the status of reactive power dispatch and compares
swarm optimization algorithm is developed to solve the reactive power dispatch problem
The expected contribution of this thesis mainly includes the following aspects:
variables (voltage magnitudes, tap positions, and shunt capacitance) in the power
9
2. Identifying the optimal placement of a new installed distributed generator in an
3. Introducing MATPOWER 5.1 toolbox to calculate the power flow and manage
10
Chapter Two: Global Optimization Methods
In most cases, the objective functions in nonlinear optimization problems are not
find local optimal values. Moreover, the results from traditional optimization methods
often have strong connections with the initial guess. To overcome these problems, global
Usually, finding the global optimal results will take plenty of time and resources.
probably a bad deal to take the time to find the global optimal solution. Therefore, if the
result is very close to the global optimal solution, it can be viewed as an acceptable
solution.
increasing their objective function values in some iterations) to allow potential solutions
to escape from the local optimum. Most of the time, there is no way to determine if a
global optimal value is already achieved or not, so global optimization methods usually
need to take plenty of iterations without bias. This requirement will in turn force the
In the following sections of this chapter, three of the most representative heuristic
global optimization methods (simulated annealing, genetic algorithm, and particle swarm
11
optimization) are introduced. These three global optimization methods can be easily
programmed and are well suited for solving reactive power dispatch problems.
change the physical properties of the metal materials and increase the ductility, the metal
is first heated to its melting temperature and then cooled down [17]. The optimization
2.1 lists some technical terms of simulated annealing and their corresponding annealing
Cost Energy
The initial design vectors of simulated annealing are randomly selected. Uphill
moves are occasionally allowed in order to escape from the local optimum value. For
example, searching for the minimum value in the curve of f(x) = x ∙ sin(x) within the
range of xϵ[−6, 6], as portrayed in Fig. 2.1. Suppose the initial guess position is at B.
Since traditional optimization methods only permit downhill moves, the next step may be
C, then D, and finally converges at A. While in simulated annealing, uphill moves are
12
allowed in some iterations, so the solution is possible to jump from C to F and eventually
find the another local optimal value at E. This sequence of event is repeated until SA
x sin(x)
F
2 B
1
D C
0
A
-1
-2
-3
-4
-5
E
-6 -4 -2 0 2 4 6
x
The stopping criteria of SA vary for different problems. The optimization process
could be stopped if a given minimum value is obtained, a certain number of iterations are
A flow chart of the simulated annealing is shown in Fig. 2.2. The selection of
parameter β is the crux of the simulated annealing algorithm. β determines the acceptance
rate of uphill steps and it is related to the Boltzmann probability distribution and the
13
temperature. If the value of β is too big, the potential solution may not have enough
energy to escape from the local optimum. Conversely, if β is too small, the solution will
Calculate △f=f1-f0
No
p=e^(-β×△f)
r=rand()
14
2.2 Genetic Algorithm
The idea of genetic algorithm (GA) comes from imitating natural evolutionary
corresponds to the initial design vectors of the first generation, and the fitness value
represents the evaluation of the solutions. Two types of genetic operators, crossover, and
mutation, define the methods of generating new populations. Immigrants are randomly
Three of the most crucial operations in the genetic algorithm are selection,
crossover, and mutation. The details of these three operations are introduced as below.
15
2.2.1 Selection
The goal of the selection is to select the “well-behaved” individuals from the
current population and to give them more opportunities to reproduce their children.
The selection operation is based on the fitness value of the individuals with
specific standards. The standards vary from different problems. Those solutions that are
more accord with the standards will have a higher probability to be selected, but not
decisive. The theory of selection reflects the principle of Darwin's survival of the fittest.
2.2.2 Crossover
individuals in the next generation are generated through crossover operation. The child
+
Figure 2.4 Crossover Operation
16
Every individual has a chance to randomly crossover with other individuals
within a population. For a single individual, the probability of exchanging part of its
chromosome with other individuals is called crossover rate. Papers [20-21] suggest that
using more than two parent chromosomes to participate in crossover operation would
achieve a better solution. Crossover operation embodies the idea of information exchange.
2.2.3 Mutation
the search. The selected individuals would have a certain probability of changing one or
more gene values in its chromosome. The mutation rate is tiny. However, it is crucial to
Since the “well-behaved” chromosomes have more chance to breed their children
chromosomes, the chromosomes in the new generations are expected to move towards
the best solutions [22]. Although the relatively “bad-behaved” chromosomes may be less
accord with the standards, they still contribute to the diversity of the groups. A flow chart
17
Initial population
Chromosome coding
Yes
Decoding
Eberhart in 1995 [23]. It was originally used for solving continuous nonlinear functions.
The idea of PSO comes from a simplified social system like bird flocking or fish
schooling.
18
Imagine a group of birds is searching for food in an n-dimension area (n equals
the number of control variables). None of these birds knows where the food is. However,
they know which bird is nearest to the food (assume the closest bird to the food is Bird A).
The best strategy for the rest of birds to find the food is following Bird A and searching
In PSO, each single solution (particle) can be viewed as a "bird". The position of
each particle can be expressed as 𝑥𝑥𝑖𝑖 = (𝑥𝑥𝑖𝑖1 , 𝑥𝑥𝑖𝑖2 , … , 𝑥𝑥𝑖𝑖𝑖𝑖 ). The initial solutions in PSO are
randomly selected and then PSO will continually search for optimal value by updating
the solutions in each iteration. The fitness value of the particle is related to the objective
function. And the velocity of the particles 𝑣𝑣𝑖𝑖 = (𝑣𝑣𝑖𝑖1 , 𝑣𝑣𝑖𝑖2 , … , 𝑣𝑣𝑖𝑖𝑖𝑖 ) is related to its pervious
velocity, global best known position, and local best known position. The velocity
indicates the directions of all the particles in the next iteration. The local best known
position is the best solution that achieved by each particle so far. The global best known
position is the best solution among all the achieved solutions. The inertia velocity part,
local best known position part, and global best known position part of the velocity reflect
Similar to GA, PSO also starts with a group of randomly generated solutions and
updates the solutions in each iteration. However, PSO uses historical data rather than
does crossover and mutation operations. The behavior of all the particles appears to be
managed by a control center. However, in reality, as formula 2.1 and formula 2.2
19
x d +1 = x d + v d +1 (2.2)
The acceleration factors handle the step sizes of the particles in the next iteration.
If the acceleration factors are too small, the particles may not have enough velocity to
reach the target regions. If the acceleration factors are too big, the particles may fly over
the optimal value. Appropriate selection of acceleration factors could avoid trapping into
Vmax limits the maximum velocity of each particle. If the velocity of a particle is
greater than maximum allowable velocity, then the velocity of that particle will be limited
to Vmax. Otherwise, the particle may also fly over the optimal solution. The maximum
objective functions.
No
Xd+1=Xd+Vd
No
No
Gbest=min(Pibest)
Yes
Results
could share information with each other. However, the communication scheme is one-
way in PSO. Only the global best-known position could send its information to the other
particles. Another difference is that the concepts in PSO are very clear. PSO does not
need to do encoding and transform the original solution into binaries, and then do
decoding at the end of the search, thus making it much easier to understand.
The selection of the PSO parameters for general problems is listed in Table 2.3.
Domains of the particles Depends on the upper bound and lower bound constraints
Acceleration factor 2 ≤ ϕ1 = ϕ2 ≤ 4
Iteration number
22
Chapter Three: Reactive Power Dispatch Problem Formulation
The loads in the power system keep changing all the time. In order to maintain the
power system operating at the timely optimum state, the reactive power optimization
not feasible in the practical application. These operations will not only bring extra
workload to the operator of the network, but also accelerate the aging of the equipment in
the power systems. Sometimes the frequent switching operations may even threaten the
safety operation of the network. Therefore, the number of switching operations and tap
Most of the existing models convert the dynamic model into the static model. [25-
26] suggest to divide a whole day into several intervals and then further divide each
interval into several periods. Within each of these periods, the discrete control variables
remain constant. Only the continuous control variables keep changing to reduce the
power loss. The minimum real power loss during a day is set as the optimization object.
The advantage of this method is that it can reduce the total power loss of the system
Relying on the load forecasting and wind speed prediction information, grid
operators can obtain the solutions of the reactive power dispatch at different wind
conditions in advance, and then match these solutions with the real situations to minimize
23
3.1 Objective Function
Reactive power dispatch in power systems may have different goals. It can be
minimizing the real power loss, getting the best voltage quality, using minimum
capacitors or achieving maximum economic profit. In this thesis, the goal of the reactive
The real power loss of the system equals the sum of the real power loss on each
( )
N
f : Ploss = ∑ g ij Vi 2 + V j2 − 2ViV j cos θ ij (3.1)
k =1
where N is the number of the branches,
3.2 Constraints
Reactive power dispatch problem has both equality constraints and inequality
constraints to process.
The equality constraints are the power balance equations, which can be described
24
where 𝑃𝑃𝑔𝑔𝑔𝑔 is the real power generation at bus i,
The inequality functions are the ranges of the voltage magnitudes, tap positions of
the transformers, and reactive power injection. Some of the parameters are continuous, as
the voltage magnitudes. While some are discrete, like the tap positions of the
transformers and reactive power injection. The commonly used method to manage the
discrete values is viewing them as continuous values at the beginning of the optimization
and then mapping the continuous values back to the discrete values in the end. In this
thesis, the discrete variables are seen as continuous variables initially and then keep three
Based on the original parameters in IEEE 14 bus system, the range of voltage
magnitude in this thesis is set from 0.95 p.u. to 1.10 p.u. The range of the tap position is
set from 0.975 to 1.025. The reactive power injection of the compensators is set between
0 MVar to 20 MVar.
25
3.3 Exterior Penalty Function (EPF) Method
constrained problems are usually converted into unconstrained problems for convenience.
One of the commonly used methods to convert the constrained problem is adding exterior
penalty function terms to the objective function [27], which is also known as exterior
(
F = Ploss + ∑ rgi Vi − Vi lim ) + ∑ r (T
2
Ti i ) ( )
− Ti lim + ∑ rQi Qi − Q ilim ,
2
(3.9)
where
Vi ;Vi > Vi
max max
Vi = min
lim
(3.10)
Vi ;Vi < Vi min
Ti max ;Ti > Ti max
Ti = min
lim
(3.11)
Ti ;Ti < Ti min
Qimax ; Qi > Qimax
QGi = min
lim
(3.12)
Qi ; Qi < Qimin
26
In EPF, if all the control variables are within the limits, the penalty function terms
would be zero. On the contrary, if the control variables exceed the limits, then the penalty
function terms would be added to the objective function to penalize the violation. The
penalty multipliers are always assigned big numbers in programming. When the penalty
multipliers keep increasing until approaching infinity, the constrained problem will
variables exceed the voltage limit, significant damages to the power systems would occur.
So the voltage magnitudes, tap positions, and reactive power injection have to be
carefully examined.
3.4 MATPOWER
In this thesis, MATPOWER 5.1 toolbox is introduced to calculate the power flow
requirement. The biggest advantages of MATPOWER is its easiness to use and modify
the original code. Furthermore, MATPOWER is open source and posted for free, users
http://www.pserc.cornell.edu/matpower/
In this section, several useful input and output MATPOWER functions related to
27
3.4.1 The loadcase Function
The loadcase function can load the case information from the struct, M-file or
MAT-file. The imported information is then saved in a struct. Users can change the
The savecase function can save the information of the network to M-file or MAT-
file. These files can also be overwritten in case of need. In MATLAB 7.10 environment,
if the case file needs to be overwritten more than once in a single run, users need to
choose saving the case information in MAT-format. Otherwise, an error message would
The runpf function can calculate the power flow of the network. When calculating
the power flow, the runpf function has several different options. ‘NR’ refers to using
Newton’s method, ‘FDXB’ is the fast decoupled method, and ‘GS’ means using Gauss-
Seidel method. ‘AC’ is calculating the AC power flow of the system, and ‘DC’ is
calculating the DC power flow of the system. By default, runpf works at the AC power
flow mode and uses Newton Raphson’s method to compute the power flow.
28
3.4.4 The get_losses Function
The get_losses function can calculate the reactive power injection and power loss
𝑣𝑣𝑓𝑓 𝑏𝑏𝑐𝑐
𝑓𝑓𝑐𝑐ℎ𝑔𝑔 = | 𝜏𝜏𝑒𝑒 𝑗𝑗𝑗𝑗 𝑠𝑠ℎ𝑖𝑖𝑖𝑖𝑖𝑖 |2 (3.14)
2
𝑏𝑏𝑐𝑐
𝑡𝑡𝑐𝑐ℎ𝑔𝑔 = |𝑣𝑣𝑡𝑡 |2 (3.15)
2
[gen_bus, Pg, Qg, Qmax, Qmin, Vg, Mbase, status, Pmax, Pmin, pc1, pc2, qc1min,
qc1max, qc2min, qc2max, ramp_agc, ramp_10, ramp_30, ramp_q, apf]. The parameters
settings of the generator data in IEEE 14 bus system are presented in fig. 3.1, and some of
the most important generator name columns and their corresponding meanings are listed
in Table 3.1.
Figure 3.1 Canonical Form of the IEEE 14 Bus System Generator Data
29
Table 3.1 Explanation of the Generator Name Columns
Name Meaning
The canonical form of the branch information in MATPOWER 5.1 is: [f_bus,
t_bus, br_r, br_x, br_b, rate_a, rate_b, rate_c, ratio, angle, angmin, angmax]. The
parameters settings of the branch data in the IEEE 14 bus system are presented in fig. 3.2.
Some of the most important branch name columns and their corresponding meanings are
30
Figure 3.2 Canonical Form of the IEEE 14 Bus System Branch Data
Name Meaning
31
Ratio Tap ratio of the transformer
bus_type, Pd, Qd, gs, bs, area, Vm, Va, base_kv, zone, Vmax, Vmin]. The parameters
settings of the bus data in the IEEE 14 bus system are presented in fig. 3.3. Some of the
most important bus name columns and their corresponding meanings are listed in Table
3.3.
Figure 3.3 Canonical Form of the IEEE 14 Bus System Bus Data
32
Table 3.3 Explanation of the Bus Name Columns
Name Meaning
Gs Shunt conductance
Bs Shunt susceptance
To conclude, the main optimization steps of the PSO based reactive power
case14.m file. Users can also create their personalized case by following the
2 Initialization: set the total iteration number, particle number, and initial velocity,
randomly assign the position of each particle in the design space. Then evaluate
33
the fitness of each particle and save the global best-known position, and the local
3 Update the positions and velocities: updating the position and velocity of each
particle by using formula 2.1 and formula 2.2. Then check whether the solution
violates the limit or not. If the solution exceeds the limits, use the EPF method to
4 Evaluate each particle: substitute the position of each particle into the objective
5 Update local best-known position: if the current fitness value is smaller than the
7 Decide stopping criterion: determine if the iteration has reached the maximum
iteration number. If so, stop the optimization process and print the result;
The flow chart of the PSO based reactive power dispatch is illustrated in the Fig.
3.4.
34
Randomly generate the location of each particle
No
Wd+1=Wd+Vd
No
Evaluate the objective function value at each
particle
Control variable
Penalize No
within limit
Yes
No
Gbest=min(Pibest)
Yes
Results
Figure 3.4 Flow Chart of the PSO Based Reactive Power Dispatch
35
Chapter Four: Case Studies
The performance of the proposed method is verified on IEEE 14 bus system. The
There are two generators in the IEEE 14 bus system. One is at the slack bus; the
other one is at bus 2. Three synchronous condensers are located at bus 3, bus 6, and bus 8,
respectively. There are also three transformers and one shunt reactive power compensator
in this system. The total real power load is 259 MW and the total reactive power load is
2 2 21.7 12.7
3 3 94.2 19.0
4 4 47.8 -3.9
5 5 7.6 1.6
6 6 11.2 7.5
9 9 29.5 16.6
10 10 9.0 5.8
11 11 3.5 1.8
12 12 6.1 1.6
13 13 13.5 5.8
14 14 14.9 5.0
3 3 PV 1.010 0 23.4 40 0
37
4 6 PV 1.070 0 12.2 24 -6
5 8 PV 1.090 0 17.4 24 -6
Tap
From Bus To Bus R X B
Position
4 5 0.01335 0.04211 0
4 7 0 0.20912 0 0.978
4 9 0 0.55618 0 0.969
5 6 0 0.25202 0 0.932
6 11 0.09498 0.19890 0
6 12 0.12291 0.25581 0
6 13 0.06615 0.13027 0
7 8 0 0.17615 0
7 9 0 0.11001 0
9 10 0.03181 0.08450 0
38
9 14 0.12711 0.27038 0
10 11 0.08205 0.19207 0
12 13 0.22092 0.19988 0
13 14 0.17093 0.34802 0
9 19
The MATLAB code for the reactive power dispatch without adding new DGs is
the optimization result after conducting one hundred iterations. But in order to give the
particles enough opportunities to reach the global minimum, the stopping criteria of the
optimization process is set as the iteration number reaching two hundred. The size of the
swarm is fifty. The initial weight inertia is set as 0.9, and the final weight inertia is set as
0.4. As the iterations go on, the weight value will drop from 0.9 to 0.4. The position of
V1 V2 V3 V6 V8 T1 T2 T3 S9
In Fig. 4.2, V represents the voltage magnitudes at the slack bus or PV bus, T is
for the tap position of the transformer, and S9 is the reactive power injection at bus 9.
39
When the optimization process starts, the position of each particle will be continuously
Fig. 4.3 shows the optimization process of reactive power dispatch without
installing new DG. At the beginning of the optimization process, the positions of the
particles are randomly selected. The global optimal real power loss is about 13.5 MW at
that time. As the particles continually update their positions towards the best solution, the
real power loss keeps decreasing. After 100 iterations, no obvious improvement can be
13.6
13.4
Real Power Loss (MW)
13.2
13
12.8
12.6
12.4
12.2
0 20 40 60 80 100 120 140 160 180 200
Iteration
40
Table 4.5 shows the real power loss on each branch before and after the particle
swarm optimization. Even though the active power loss in some branches are slightly
increased, (for instance, branch 6-12, 6-13, 9-14), the overall real power loss of the 14
4-7 0 0
4-9 0 0
5-6 0 0
7-8 0 0
7-9 0 0
41
9-10 0.013 0.013
The second case study is about adding a new DG to the IEEE 14 bus system and
then optimizes the reactive power of the system by using PSO. Wind generator, solar
panels, and micro-turbine can all be chosen as an alternative of DG. In this thesis,
Enercon E82 wind turbine is selected as the new DG. Enercon E82 is a direct-drive
synchronous generator. Its rated power is 2000 kW. The wind generator is assumed to
In the next page, the shaded area in Fig. 4.4 describes reactive power capability of
Enercon E82 [31]. When the real power output is 0 MW, the wind generator can still
deliver as much as 1.2 MVar or absorb -1.0 MVar reactive power. Since 2007, some
commercial wind turbines have already been equipped with this kind of full reactive
power capability, which can produce full reactive power regardless of the wind
conditions. While the reactive power capacity of the early products is usually related to
42
Figure 4.4 Reactive Power Capacity of Enercon E82 (2010 FACTS-WT)
If the wind turbine is installed on a PV bus (e.g. bus 2), then both real and reactive
power capacity of the generator need to be changed. In Fig. 4.6, note that the active
power output of the generator at bus 2 is increased from 40 to 42.2, the range of reactive
Figure 4.6 Generator Data of the Modified System when the DG is Installed on Bus 2
Similar changes will also be performed in other cases, as shown in the graphs
Figure 4.7 Generator Data of the Modified System when the DG is Installed on Bus 3
44
Figure 4.8 Generator Data of the Modified System when the DG is Installed on Bus 6
Figure 4.9 Generator Data of the Modified System when the DG is Installed on Bus 8
The position of each particle, in this case, will remain the same as in the previous
section. The MATLAB code in Appendix A can still be used to solve the optimal reactive
V1 V2 V3 V6 V8 T1 T2 T3 S9
Figure 4.10 Coordinates of the Particle when the New DG is connected to a PV Bus
If the wind turbine is installed on PQ bus (e.g. bus 4), in addition to modifying the
capacity of the real and reactive power to new parameters, the voltage magnitude of the
new installed DG bus should also be treated as a new control variable, as illustrated in the
fig. 4.11.
45
V1 V2 V3 V6 V8 Vr T1 T2 T3 S9
The MATLAB code in Appendix A will not be fit for this case. So the MATLAB
code in Appendix B is used for solving the reactive power dispatch problem. The
differences between the two codes are highlighted in the Appendix B. Other changes on
the bus data and generator data are presented in the graphs from fig. 4.12 to fig. 4.29.
Figure 4.12 Bus Data of the Modified System when the DG is Installed on Bus 4
In the generator data section of the modified 14 bus system, the parameters of the
46
Figure 4.13 Generator Data of the Modified System when the DG is Installed on Bus 4
Similar changes are needed before executing the MATLAB code to calculate the
Figure 4.14 Bus Data of the Modified System when the DG is Installed on Bus 5
47
Figure 4.15 Generator Data of the Modified System when the DG is Installed on Bus 5
Figure 4.16 Bus Data of the Modified System when the DG is Installed on Bus 7
48
Figure 4.17 Generator Data of the Modified System when the DG is Installed on Bus 7
Figure 4.18 Bus Data of the Modified System when the DG is Installed on Bus 9
49
Figure 4.19 Generator Data of the Modified System when the DG is Installed on Bus 9
Figure 4.20 Bus Data of the Modified System when the DG is Installed on Bus 10
50
Figure 4.21 Generator Data of the Modified System when the DG is Installed on Bus 10
Figure 4.22 Bus Data of the Modified System when the DG is Installed on bus 11
51
Figure 4.23 Generator Data of the Modified System when the DG is Installed on Bus 11
Figure 4.24 Bus Data of the Modified System when the DG is Installed on Bus 12
52
Figure 4.25 Generator Data of the Modified System when the DG is Installed on Bus 12
Figure 4.26 Bus Data of the Modified System when the DG is Installed on Bus 13
53
Figure 4.27 Generator Data of the Modified System when the DG is Installed on Bus 13
Figure 4.28 Bus Data of the Modified System when the DG is Installed on Bus 14
54
Figure 4.29 Generator Data of the Modified System when the DG is Installed on Bus 14
After running the MATLAB code, the real power loss of the system, when DG is
From the table, we can learn that the real power loss can be reduced by 7.89% by
simply applying PSO algorithm. After adding a new DG to the system and using PSO
algorithm to further adjusting the values of control variables, the real power loss can be
55
Table 4.6 Optimization Results with a New DG Installed on Different Buses
With
DG DG DG DG DG DG DG DG DG DG DG DG DG
-out With
Control at at at at at at at at at at at at at
DG -out
Variables Bus Bus Bus Bus Bus Bus Bus Bus Bus Bus Bus Bus Bus
and DG
2 3 4 5 6 7 8 9 10 11 12 13 14
PSO
Voltage at 1.06 1.10 1.10 1.10 1.10 1.10 1.10 1.10 1.10 1.10 1.10 1.10 1.10 1.10 1.10
Bus 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Voltage at 1.04 1.08 1.08 1.08 1.08 1.08 1.08 1.08 1.08 1.08 1.08 1.08 1.08 1.08 1.08
Bus 2 5 3 7 6 7 7 7 7 6 7 7 4 4 2 4
Voltage at 1.01 1.05 1.05 1.05 1.05 1.05 1.05 1.05 1.05 1.05 1.05 1.05 1.05 1.04 1.05
Bus 3 0 2 7 6 8 8 7 7 6 8 8 3 3 7 2
Voltage at 1.06
56
Bus 4 7
Voltage at 1.07
Bus 5 4
Voltage at 1.07 1.06 1.08 1.07 1.06 1.07 1.08 1.79 1.07 1.10 1.07 1.07 1.05 1.07 1.05
Bus 6 0 4 5 6 4 2 7 0 4 0 7 2 4 6 1
Voltage at 1.08
Bus 7 6
Voltage at 1.09 1.06 1.10 1.10 1.04 1.10 1.10 1.01 1.10 1.04 1.10 1.09 1.10 1.08 1.04
Bus 8 0 4 0 0 5 0 0 7 0 6 0 8 0 6 6
Voltage at 1.09
Bus 9 5
Voltage at 1.06
Bus 10 7
Voltage at 1.06
Bus 11 6
Voltage at 1.04
Bus 12 5
Voltage at 1.06
Bus 13 4
Voltage at 1.02
Bus 14 5
0.97 1.01 0.98 1.00 0.97 0.99 0.97 0.99 0.99 0.98 1.01 0.98 0.99 0.98 0.99
Tap1
8 8 6 8 4 6 4 1 6 1 5 9 5 9 8
0.96 0.99 0.97 1.00 0.98 0.99 1.00 1.01 0.99 1.01 1.00 0.99 1.01 1.00 1.00
Tap2
9 4 3 0 9 4 2 6 4 9 5 0 1 4 9
0.93 1.00 1.02 1.01 1.01 0.99 1.03 1.00 1.03 1.00 1.01 1.00 0.99 0.98 1.00
Tap3
2 6 4 6 2 6 3 5 3 1 2 4 3 5 8
Shunt 9 19 16.9 15.2 20.0 14.4 10.1 19.4 17.9 16.3 10.3 15.4 8.9 10.9 9.3 19.0
57
13.3 12.3 12.1 12.0 12.0 12.0 12.0 12.0 12.0 12.0 12.0 12.0 12.0 12.1 12.0
Loss (MW)
93 36 53 17 84 97 81 62 64 33 49 96 80 12 88
Loss
10.2 10.1 10.0
Reduction 0 7.89 9.26 9.77 9.68 9.80 9.94 9.92 9.68 9.80 9.56 9.74
7 5 4
(%)
Loss reduction
12.00%
10.00%
8.00%
6.00%
4.00%
2.00%
0.00%
Table 4.7 shows the comparison of the real power loss of the original network,
optimization without new DG, and optimization with new DG. We can learn that the real
58
4-5 0.514 0.462 0.461
4-7 0 0 0
4-9 0 0 0
5-6 0 0 0
7-8 0 0 0
7-9 0 0 0
Fig. 4.31 shows the optimization process of the proposed method when the new
wind turbine is installed on bus 3. The initial real power loss of the system is at about
12.45 MW. The particles start to converge after conducting eighty iterations. Finally, the
59
Minimum Real Power Loss
12.45
12.4
12.35
Real Power Loss (MW)
12.3
12.25
12.2
12.15
12.1
12.05
12
0 20 40 60 80 100 120 140 160 180 200
Iteration
Figure 4.31 Loss Reduction Process when the new DG is Installed on Bus 3
In order to evaluate the performance of the proposed method at the various wind
speed conditions, the third case study compares the power loss of the modified 14 bus
system when the wind turbine delivers 25%, 50%, and 75% of its rated power,
respectively.
The real power output curve of Enercon E82 wind turbine is presented in Fig. 4.32
[32]. When the wind speed is at 7 m/s, the output of the wind turbine is 532 W, which is
about 25% of its rated power output. When the wind speed is about 9 m/s, the output of
wind generator is 1.18 kW, approximately 50% of its rated power output. Finally, when
60
the wind speed is about 10 m/s, the output of the wind generator is 1.58 kW, about 75%
2000
1800
1600
Real Power Output (W)
1400
1200
1000
800
600
400
200
0
0 5 10 15 20 25
wind speed (m/s)
When the wind speed is 7 m/s, the value of Pg at bus 9 is changed to 532 W, as
Figure 4.33 Generators Data when the New Installed DG Delivers 25% Rated Power
61
The process of reactive power optimization, when DG produce 25% of its rated
power output, is shown in fig. 4.34. Finally, the real power loss of the system converges
at 12.1845 MW.
12.7
12.6
Real Power Loss (MW)
12.5
12.4
12.3
12.2
Figure 4.34 Loss Reduction Process when DG Delivers 25% Rated Power
62
Voltage at bus 8 1.006
Shunt 9 10.118
When the wind speed is 9 m/s, the value of Pg at bus 9 is changed to 1180 W, as
Figure 4.35 Generators Data when the New Installed DG Delivers 50% Rated Power
The process of reactive power optimization, when DG produce 50% of its rated
power output, is shown in fig. 4.36. Finally, the real power loss of the system converges
on 12.1221 MW.
63
Minimum Real Power Loss
12.7
12.6
Real Power Loss (MW)
12.5
12.4
12.3
12.2
Figure 4.36 Loss Reduction Process when DG Delivers 50% Rated Power
64
Turn ratio 1 1.009
Shunt 9 10.478
When the wind speed is 10 m/s, the value of Pg at bus 9 is changed to 1580 W, as
Figure 4.37 Generators Data when the New Installed DG Delivers 75% Rated Power
The process of reactive power optimization, when DG produce 75% of its rated
power output, is shown in fig. 4.38. Finally, the real power loss of the system is 12.0793
MW.
65
Minimum Real Power Loss
12.7
12.6
12.5
Real Power Loss (MW)
12.4
12.3
12.2
12.1
12
0 20 40 60 80 100 120 140 160 180 200
Iteration
Figure 4.38 Loss Reduction Process when DG Delivers 75% Rated Power
66
Turn ratio 2 0.9740
Shunt 9 11.0650
The phase angle shifts at the different real power output conditions are also
compared in Table 4.11. When the output increases, the phase angle shift declines.
Bus
25% rated power 50% rated power 75% rated power Rated power
number
1 0 0 0 0
67
4.5 Discussion
By analyzing the results of the three case studies, the following conclusions can
be obtained:
1 Before the reactive power optimization, the reactive power in IEEE 14 bus system
real power loss of the system and improve the power quality.
reflects the excellent searching ability of PSO algorithm for solving nonlinear
problems.
3 When a small capacity DG is added into the system, the real power loss would be
further reduced. As the output of the DG increases, the real power loss of the
system decreases.
68
Chapter Five: Conclusion and Future Work
5.1 Conclusion
algorithm that possess of high efficiency and robustness. PSO is less sensitive to the
complexity of the objective functions. Therefore, it shows enormous potential for solving
This thesis uses the IEEE 14 bus system as the test system. Both PSO algorithm
and MATPOWER 5.1 toolbox are applied to reduce the real power loss in the power
networks. In order to avoid the control variables exceeding the limits, exterior penalty
function method is also employed. The main contribution of this thesis is as follows:
1 Reactive power dispatch approach can significantly reduce the power loss in
power systems, and this method is both cost-effective and can be easily employed
in real life.
benefits.
69
3 The mature MATPOWER 5.1 toolbox are introduced to calculate the power flow
and manage the equality constraints in PSO based reactive power dispatch. The
accuracy of the results and the robustness of the code get improved.
This thesis solves the reactive power dispatch problem and determines the optimal
1 PSO algorithm has excellent searching capability, but it is apt to plunge into local
minimum solutions. Further research needs to think about how to avoid premature
problems.
2 The running time of the code is five minutes on the laptop. Future work includes
3 The modified test system only considers one DG. If more DGs are added to the
needs to simplify the power system model to reduce the computation time.
4 Due to the computation time limitation, this thesis only calculates the reactive
power dispatch problems when the wind generator operates at 7 m/s, 9 m/s, and
10 m/s. In the future research, the performance of the proposed method at other
70
References
Distribution, 1992.
Toomey, “Markets for reactive power and reliability: A white paper,” Eng. Econ.
http://www.energycentral.com/articles/article/529
http://www.eia.gov/tools/faqs/faq.cfm?id=105&t=3
purchase/demo-software
71
[8] J. A. Momoh, S. X, Guo, E. C. Ogbuobiri, and R. Adapa, “The quadratic interior
[9] R. Dubey, S. Dixit, G. Agnihotri, “Optimal Placement of Shunt Facts Devices Using
[10] T. Sousa, J. Soares, Z.A. Vale, H. Morais and P. Faria,, “Simulated Annealing
metaheuristic to solve the optimal power flow,” IEEE Power and Energy Society
[11] M. Gitizadeh, M. Kalanar, “Multi-objective fuzzy based reactive power and voltage
[12] Padhy, N.P.; Abdel-Moamen, M.A.; Praveen Kumar, B.J., “Optimal location and
initial parameter settings of multiple TCSCs for reactive power planning using
72
[14] “Artificial neural network,” Available: https://en.wikipedia.org/wiki/Artificial_neura
l_network
VAR control with fuzzy reactive loads,” IEEE Transactions on Power Systems,
[16] Chao-Rong Chen, Hang-Sheng Lee, Wenta Tsai, “On-line Optimal Shunt Capacitors
urgy)
s/understanding-simulated-annealing-terminology.html
ome-genetic-algorithm-terminology.html
[21] Ting, Chuan-Kang, "On the Mean Convergence Time of Multi-parent Genetic
[25] S.S. Sharif, J.H. Taylor, “Dynamic optimal reactive power flow,” Proceedings of the
[26] M.M.A. Salama, N. Manojlovic, V.H. Quintana, A.Y. Chikhani, “Real-time optimal
reactive power control for distribution networks,” Electrical Power and Energy
System, 1996.
Steady-State Operations, Planning and Analysis Tools for Power Systems Research
and Education," Power Systems, IEEE Transactions on, vol. 26, no. 1, pp. 12-19, Feb.
2011.
74
[30] Iraj Dabbagchi and Rich Christie, 14 Bus Power Flow Test Case, Available:
https://www.ee.washington.edu/research/pstca/pf14/pg_tca14bus.htm
[31] T. Ackermann, “Wind Power in Power Systems,” 2nd ed. John Wiley & Sons, Inc.,
http://www.enercon.de/p/downloads/EN_Productoverview_0710.pdf
75
Appendix A MATLAB Code for Reactive Power Dispatch without New DGs
%Inertia Weight
w_max=0.9;
w_min=0.4;
w_temp=w_max;
w_step=(w_max-w_min)/iteration;
for i=1:particlenumber
v1=Swarm(i,1); %v1
bus(1,8)=v1; %Vm, 8 is voltage magnitude (p.u.)
gen(1,6)=v1; %Vg, 6 is voltage magnitude setpoint (p.u.)
v2=Swarm(i,2); %v2
bus(2,8)=v2;
gen(2,6)=v2;
76
v3=Swarm(i,3); %v3
bus(3,8)=v3;
gen(3,6)=v3;
v6=Swarm(i,4); %v6
bus(6,8)=v6;
gen(4,6)=v6;
v8=Swarm(i,5); %v8
bus(8,8)=v8;
gen(5,6)=v8;
77
end
penalty_gen_violation=sum(penalty_gen);
%Penalty function
losses(i)=eval(['losses',num2str(i)]);
Obj_fun_initial(i)=losses(i)+penalty_bus_violation+penalty_gen_violation+penalty_brch
_violation;
end
[Val_Gbest,m]=min(Val_Pbest);
Gbest=Swarm(m,:);
Gbest_calc=repmat(Swarm(m,:),particlenumber,1);
for iter=1:iteration
78
R1=rand(particlenumber,9);
R2=rand(particlenumber,9);
%2.05+2.05=4.1;
%2/abs(2-4.1-sqrt(4.1*4.1-4*4.1))=0.729
Velocity=0.729*(w_temp*Velocity+2.05*R1.*(Pbest-Swarm)+2.05*R2.*(Gbest_calc-
Swarm));
Swarm=Swarm+Velocity;
for k=1:particlenumber
v1=Swarm(k,1); %v1
bus(1,8)=v1; %Vm, 8 is voltage magnitude (p.u.)
gen(1,6)=v1; %Vg, 6 is voltage magnitude setpoint (p.u.)
v2=Swarm(k,2); %v2
bus(2,8)=v2;
gen(2,6)=v2;
v3=Swarm(k,3); %v3
bus(3,8)=v3;
gen(3,6)=v3;
v6=Swarm(k,4); %v6
bus(6,8)=v6;
gen(4,6)=v6;
v8=Swarm(k,5); %v8
bus(8,8)=v8;
gen(5,6)=v8;
79
branch(10,9)=Swarm(k,8); %tp3 5-6
80
end
end
penalty_brch_violation=sum(penalty_brch);
%Penalty function
losses_temp(k)=eval(['losses',num2str(k)]);
Obj_fun_temp(k)=losses_temp(k)+penalty_bus_violation+penalty_gen_violation+penalt
y_brch_violation;
if Obj_fun_temp(k)<Val_Pbest(k)
losses(k)=losses_temp(k);
Val_Pbest(k)=Obj_fun_temp(k);
Pbest(k,:)=Swarm(k,:);
end
end
[Val_Gbest_temp,n]=min(Val_Pbest);
if Val_Gbest_temp<Val_Gbest
Val_Gbest=Val_Gbest_temp;
Gbest=Swarm(n,:);
Gbest_calc=repmat(Swarm(n,:),particlenumber,1);
end
w_temp=w_temp-w_step;
Val_Gbest_rec(iter)=Val_Gbest;
plot(Val_Gbest_rec);
drawnow;
end
81
Appendix B MATLAB Code for Reactive Power Dispatch with a New DG Installed
on PQ Bus
%Inertia Weight
w_max=0.9;
w_min=0.4;
w_temp=w_max;
w_step=(w_max-w_min)/iteration;
for i=1:particlenumber
v1=Swarm(i,1); %v1
bus(1,8)=v1; %Vm, 8 is voltage magnitude (p.u.)
gen(1,6)=v1; %Vg, 6 is voltage magnitude setpoint (p.u.)
v2=Swarm(i,2); %v2
82
bus(2,8)=v2;
gen(2,6)=v2;
v3=Swarm(i,3); %v3
bus(3,8)=v3;
gen(3,6)=v3;
v6=Swarm(i,4); %v6
bus(6,8)=v6;
gen(4,6)=v6;
v8=Swarm(i,5); %v8
bus(8,8)=v8;
gen(5,6)=v8;
v4=Swarm(i,6); %v4
bus(4,8)=v4;
gen(6,6)=v4;
83
else
penalty_gen(gen_num)=0;
end
end
penalty_gen_violation=sum(penalty_gen);
%Penalty function
losses(i)=eval(['losses',num2str(i)]);
Obj_fun_initial(i)=losses(i)+penalty_bus_violation+penalty_gen_violation;
end
[Val_Gbest,m]=min(Val_Pbest);
Gbest=Swarm(m,:);
Gbest_calc=repmat(Swarm(m,:),particlenumber,1);
for iter=1:iteration
R1=rand(particlenumber,10);
R2=rand(particlenumber,10);
%2.05+2.05=4.1;
%2/abs(2-4.1-sqrt(4.1*4.1-4*4.1))=0.729
Velocity=0.729*(w_temp*Velocity+2.05*R1.*(Pbest-Swarm)+2.05*R2.*(Gbest_calc-
Swarm));
84
Outstep=Velocity(:,v_iter)<-0.1;
Velocity(find(Outstep),v_iter)=-0.1;
else
Outstep=Velocity(:,v_iter)>0.003;
Velocity(find(Outstep),v_iter)=0.003;
Outstep=Velocity(:,v_iter)<-0.003;
Velocity(find(Outstep),v_iter)=-0.003;
end
end
Swarm=Swarm+Velocity;
for k=1:particlenumber
v1=Swarm(k,1); %v1
bus(1,8)=v1; %Vm, 8 is voltage magnitude (p.u.)
gen(1,6)=v1; %Vg, 6 is voltage magnitude setpoint (p.u.)
v2=Swarm(k,2); %v2
bus(2,8)=v2;
gen(2,6)=v2;
v3=Swarm(k,3); %v3
bus(3,8)=v3;
gen(3,6)=v3;
v6=Swarm(k,4); %v6
bus(6,8)=v6;
gen(4,6)=v6;
v8=Swarm(k,5); %v8
bus(8,8)=v8;
gen(5,6)=v8;
v4=Swarm(k,6); %v4
bus(4,8)=v4;
gen(6,6)=v4;
85
bus_inf=bus(:,8);
for bus_num=1:14
if bus_inf(bus_num)>vol_max
penalty_bus(bus_num)=10000*(bus_inf(bus_num)-vol_max)^2;
elseif bus_inf(bus_num)<vol_min
penalty_bus(bus_num)=10000*(bus_inf(bus_num)-vol_min)^2;
else
penalty_bus(bus_num)=0;
end
end
penalty_bus_violation=sum(penalty_bus);
%Penalty function
losses_temp(k)=eval(['losses',num2str(k)]);
Obj_fun_temp(k)=losses_temp(k)+penalty_bus_violation+penalty_gen_violation;
if Obj_fun_temp(k)<Val_Pbest(k)
losses(k)=losses_temp(k);
Val_Pbest(k)=Obj_fun_temp(k);
Pbest(k,:)=Swarm(k,:);
end
end
[Val_Gbest_temp,n]=min(Val_Pbest);
if Val_Gbest_temp<Val_Gbest
Val_Gbest=Val_Gbest_temp;
Gbest=Swarm(n,:);
Gbest_calc=repmat(Swarm(n,:),particlenumber,1);
end
w_temp=w_temp-w_step;
86
Val_Gbest_rec(iter)=Val_Gbest;
plot(Val_Gbest_rec);
drawnow;
end
87