Professional Documents
Culture Documents
In power engineering, the power flow study (also known as load-flow study) is an
important tool involving numerical analysis applied to a power system. Unlike traditional circuit
analysis, a power flow study usually uses simplified notation such as a one-line diagram and per-
unit system, and focuses on various forms of AC power (ie: reactive, real, and apparent) rather
than voltage and current. It analyzes the power systems in normal steady-state operation. There
exist a number of software implementations of power flow studies.
In addition to a power flow study itself, sometimes called the base case, many software
implementations perform other types of analysis, such as short-circuit fault analysis and
economic analysis. In particular, some programs use linear programming to find the optimal
power flow, the conditions which give the lowest cost per kilowatt generated.
The great importance of power flow or load-flow studies is in the planning the future expansion
of power systems as well as in determining the best operation of existing systems. The principal
information obtained from the power flow study is the magnitude and phase angle of the voltage
at each bus and the real and reactive power flowing in each line.
Commercial power systems are usually too large to allow for hand solution of the power flow.
Special purpose network analyzers were built between 1929 and the early 1960's to provide
laboratory models of power systems; large-scale digital computers replaced the analog methods.
Contents
[hide]
The solution to the power flow problem begins with identifying the known and unknown
variables in the system. The known and unknown variables are dependent on the type of bus. A
bus without any generators connected to it is called a Load Bus. With one exception, a bus with
at least one generator connected to it is called a Generator Bus. The exception is one arbitrarily-
selected bus that has a generator. This bus is referred to as the Slack Bus.
In the power flow problem, it is assumed that the real power PD and reactive power QD at each
Load Bus are known. For this reason, Load Buses are also known as PQ Buses. For Generator
Buses, it is assumed that the real power generated PG and the voltage magnitude |V| is known.
For the Slack Bus, it is assumed that the voltage magnitude |V| and voltage phase Θ are known.
Therefore, for each Load Bus, both the voltage magnitude and angle are unknown and must be
solved for; for each Generator Bus, the voltage angle must be solved for; there are no variables
that must be solved for the Slack Bus. In a system with N buses and R generators, there are then
2(N − 1) − (R − 1) unknowns.
In order to solve for the 2(N − 1) − (R − 1) unknowns, there must be 2(N − 1) − (R − 1) equations
that do not introduce any new unknown variables. The possible equations to use are power
balance equations, which can be written for real and reactive power for each bus. The real power
balance equation is:
where Pi is the net power injected at bus i, Gik is the real part of the element in the
bus admittance matrix YBUS corresponding to the ith row and kth column, Bik is the imaginary
part of the element in the Y BUS corresponding to the ith row and kth column and θik is the
difference in voltage angle between the ith and kth buses. The reactive power balance equation
is:
Equations included are the real and reactive power balance equations for each Load Bus and the
real power balance equation for each Generator Bus. Only the real power balance equation is
written for a Generator Bus because the net reactive power injected is not assumed to be known
and therefore including the reactive power balance equation would result in an additional
unknown variable. For similar reasons, there are no equations written for the Slack Bus.
The linearized system of equations is solved to determine the next guess (m + 1) of voltage
magnitude and angles based on:
The process continues until a stopping condition is met. A common stopping condition is to
terminate if the norm of the mismatch equations are below a specified tolerance.
Newton's method:
In numerical analysis, Newton's method (also known as the Newton–Raphson method), named
after Isaac Newton and Joseph Raphson, is a method for finding successively better
approximations to the zeroes (or roots) of a real-valued function. The algorithm is first in the
class of Householder's methods, succeeded by Halley's method.
Given a function ƒ(x) and its derivative ƒ '(x), we begin with a first guess x0. Provided the
function is reasonably well-behaved a better approximation x1 is
Geometrically, x1 is the intersection point of the tangent line to the graph of f, with the x-axis.
The process is repeated until a sufficiently accurate value is reached:
Complex functions
When dealing with complex functions, Newton's method can be directly applied to find their
zeroes. Each zero has a basin of attraction, the set of all starting values that cause the method to
converge to that particular zero. These sets can be mapped as in the image shown. For many
complex functions, the boundary of the basins of attraction is a fractal. In some cases there are
regions in the complex plane which are not in any of these basins of attraction, meaning the
iterates do not converge.
One may use Newton's method also to solve systems of k (non-linear) equations, which amounts
to finding the zeroes of continuously differentiable functions F : Rk → Rk. In the formulation
given above, one then has to left multiply with the inverse of the k-by-k Jacobian matrix JF(xn)
instead of dividing by f '(xn).
Rather than actually computing the inverse of this matrix, one can save time by solving the
system of linear equations
The n-dimensional Newton's method can be used to solve systems of >k (non-linear) equations
as well. This is done by approximating the zeroes of continuously differentiable functions F : Rk
→ Rk.
As there are k variables and >k equations, unless every subset of k equations yields the same
solution with the above method, at least one equation is erroneous.
An approximation of the solution to a set of >k equations can be calculated by computing the
generalized least squares inverse of the non-square Jacobian matrix.
Assuming the errors in these equations are uncorrelated and normal, this method yields the best
approximation of the zero of the functions.
Like solving k equations for k variables, one could solve a system of linear equations to find the
next point. Solving for the generalized least squares inverse of a matrix is a computation best left
to a computer.
Source Code
Given k variables and k equations, the function returns the exact solution.
Given >k equations, the function returns a least squares estimate of the solution.
where F'(Xn) is the Fréchet derivative computed at Xn. One needs the Fréchet derivative to be
boundedly invertible at each Xn in order for the method to be applicable. A condition for
existence of and convergence to a root is given by the Newton–Kantorovich theorem.
Nptel data :
Classification of Buses
Preparation of Data for Load Flow
Load Flow by Gauss-Seidel Method
Updating Load Bus Voltage
Updating P-V Bus Voltages
Convergence of the Algorithm
Overview :
Load flow studies are one of the most important aspects of power system planning and
operation. The load flow gives us the sinusoidal steady state of the entire system - voltages,
real and reactive power generated and absorbed and line losses. Since the load is a static
quantity and it is the power that flows through transmission lines, the purists prefer to call
this Power Flow studies rather than load flow studies. We shall however stick to the
original nomenclature of load flow.
Through the load flow studies we can obtain the voltage magnitudes and angles at each bus
in the steady state. This is rather important as the magnitudes of the bus voltages are
required to be held within a specified limit. Once the bus voltage magnitudes and their
angles are computed using the load flow, the real and reactive power flow through each line
can be computed. Also based on the difference between power flow in the sending and
receiving ends, the losses in a particular line can also be computed. Furthermore, from the
line flow we can also determine the over and under load conditions.
The steady state power and reactive power supplied by a bus in a power network are
expressed in terms of nonlinear algebraic equations. We therefore would require iterative
methods for solving these equations. In this chapter we shall discuss two of the load flow
methods. We shall also delineate how to interpret the load flow results.
Section I: Real And Reactive Power Injected in a Bus
For the formulation of the real and reactive power entering a b us, we need to define the
following quantities. Let the voltage at the i th bus be denoted by
(4.1)
(4.2)
(4.3)
Let the power system contains a total number of n buses. The current injected at bus- i is
(4.4)
given as
It is to be noted we shall assume the current entering a bus to be positive and that leaving
the bus to be negative. As a consequence the power and reactive power entering a bus
will also be assumed to be positive. The complex power at bus- i is then given by
(4.5)
Note that
(4.6)
(4.7)
For load flow studies it is assumed that the loads are constant and they are defined by
their real and reactive power consumption. It is further assumed that the generator
terminal voltages are tightly regulated and therefore are constant. The main objective of
the load flow is to find the voltage magnitude of each bus and its angle when the powers
generated and loads are pre-specified. To facilitate this we classify the different buses of
the power system shown in the chart below.
Load Buses : In these buses no generators are connected and hence the generated real
power PGi and reactive power QGi are taken as zero. The load drawn by these buses are
defined by real power -PLi and reactive power -QLi in which the negative sign
accommodates for the power flowing out of the bus. This is why these buses are
sometimes referred to as P-Q bus. The objective of the load flow is to find the bus voltage
magnitude |Vi| and its angle δi.
Voltage Controlled Buses : These are the buses where generators are connected.
Therefore the power generation in such buses is controlled through a prime mover while
the terminal voltage is controlled through the generator excitation. Keeping the input power
constant through turbine-governor control and keeping the bus voltage constant using
automatic voltage regulator, we can specify constant PGi and | Vi | for these buses. This is
why such buses are also referred to as P-V buses. It is to be noted that the reactive power
supplied by the generator QGi depends on the system configuration and cannot be
specified in advance. Furthermore we have to find the unknown angle δi of the bus
voltage.
Slack or Swing Bus : Usually this bus is numbered 1 for the load flow studies. This bus
sets the angular reference for all the other buses. Since it is the angle difference between
two voltage sources that dictates the real and reactive power flow between them, the
particular angle of the slack bus is not important. However it sets the reference against
which angles of all the other bus voltages are measured. For this reason the angle of this
bus is usually chosen as 0° . Furthermore it is assumed that the magnitude of the voltage
of this bus is known.
Now consider a typical load flow problem in which all the load demands are known. Even if
the generation matches the sum total of these demands exactly, the mismatch between
generation and load will persist because of the line I 2R losses. Since the I 2R loss of a
line depends on the line current which, in turn, depends on the magnitudes and angles of
voltages of the two buses connected to the line, it is rather difficult to estimate the loss
without calculating the voltages and angles. For this reason a generator bus is usually
chosen as the slack bus without specifying its real power. It is assumed that the generator
connected to this bus will supply the balance of the real power required and the line
losses.
(4.8)
Let the injected power calculated by the load flow program be Pi, calc . Then the mismatch
between the actual injected and calculated values is given by
(4.9)
In a similar way the mismatch between the reactive power injected and calculated values
is given by
(4.10)
The purpose of the load flow is to minimize the above two mismatches. It is to be noted
that (4.6) and (4.7) are used for the calculation of real and reactive power in (4.9) and
(4.10). However since the magnitudes of all the voltages and their angles are not known a
priori, an iterative procedure must be used to estimate the bus voltages and their angles in
order to calculate the mismatches. It is expected that mismatches ΔPi and ΔQi reduce with
each iteration and the load flow is said to have converged when the mismatches of all the
buses become less than a very small number.
For the load flow studies we shall consider the system of Fig. 4.1, which has 2 generator
and 3 load buses. We define bus-1 as the slack bus while taking bus-5 as the P-V bus.
Buses 2, 3 and 4 are P-Q buses. The line impedances and the line charging admittances
are given in Table 4.1. Based on this data the Y bus matrix is given in Table 4.2. This
matrix is formed using the same procedure as given in Section 3.1.3. It is to be noted here
that the sources and their internal impedances are not considered while forming
the Ybus matrix for load flow studies which deal only with the bus voltages.
Fig. 4.1 The simple power system used for load flow studies.
Table 4.1 Line impedance and line charging data of the system of Fig. 4.1.
Impedance Line charging
Line (bus to bus) ( Y /2)
1-2 0.02 + j 0.10 j 0.030
1-5 0.05 + j 0.25 j 0.020
2-3 0.04 + j 0.20 j 0.025
2-5 0.05 + j 0.25 j 0.020
3-4 0.05 + j 0.25 j 0.020
3-5 0.08 + j 0.40 j 0.010
4-5 0.10 + j 0.50 j 0.075
1 2 3 4 5
1 2.6923 - 1.9231 0 0 - 0.7692
- j 13.4115 + j 9.6154 + j 3.8462
2- 1.9231 3.6538 - 0.9615 0 - 0.7692
+ j 9.6154 - j 18.1942 + j 4.8077 + j 3.8462
30 - 0.9615 2.2115 - 0.7692 - 0.4808
+ j 4.8077 - j 11.0027 + j 3.8462 + j 2.4038
40 0 - 0.7692 1.1538 - j 5.6742 - 0.3846
+ j 3.8462 + j 1.9231
5- 0.7692 - 0.7692 - 0.4808 - 0.3846 2.4038
+ j 3.8462 + j 3.8462 + j 2.4038 + j 1.9231 - j 11.8942
The bus voltage magnitudes, their angles, the power generated and consumed at each
bus are given in Table 4.3. In this table some of the voltages and their angles are given in
boldface letters. This indicates that these are initial data used for starting the load flow
program. The power and reactive power generated at the slack bus and the reactive
power generated at the P-V bus are unknown. Therefore each of these quantities are
indicated by a dash ( - ). Since we do not need these quantities for our load flow
calculations, their initial estimates are not required. Also note from Fig. 4.1 that the slack
bus does not contain any load while the P-V bus 5 has a local load and this is indicated in
the load column.
Table 4.3 Bus voltages, power generated and load - initial data.
In this section we shall discuss the solution of a set of nonlinear equations through Newton-
Raphson method. Let us consider that we have a set of n nonlinear equations of a total
(4.22)
(4.23)
where f1, ... , fn are functions of the variables x1 , x2 , ... , xn. We can then define another set of
functions g1 , ... , gn as given below
Let us assume that the initial estimates of the n variables are x1(0) , x2(0) , ... ,xn(0) . Let us add
(4.24)
corrections Δx1(0) , Δx2(0) , ... , Δxn(0) to these variables such that we get the correct solution of
these variables defined by
The functions in (4.23) then can be written in terms of the variables given in (4.24) as
(4.25)
We can then expand the above equation in Taylor 's series around the nominal values
of x1(0) , x2(0) , ... , xn(0) . Neglecting the second and higher order terms of the series, the
expansion of gk , k = 1, ... , n is given as
(4.26)
(4.27)
The square matrix of partial derivatives is called the Jacobian matrix J with J (1)indicating that
(4.28)
the matrix is evaluated for the initial values of x2(0) , ... , xn(0) . We can then write the solution of
(4.27) as
, k= 1, ....n
Since the Taylor 's series is truncated by neglecting the 2nd and higher order terms, we cannot
expect to find the correct solution at the end of first iteration. We shall then have
(4.29)
These are then used to find J (1) and Δgk (1) , k = 1, ... , n . We can then find Δx2(1) , ... ,
Δxn(1) from an equation like (4.28) and subsequently calculate x2(1) , ... , xn(1). The process
continues till Δgk , k = 1, ... , n becomes less than a small quantity.
Let us assume that an n -bus power system contains a total np number of P-Q buses while the
number of P-V (generator) buses be ng such that n = np + ng + 1. Bus-1 is assumed to be the
(4.30)
slack bus. We shall further use the mismatch equations of ΔPi and ΔQi given in (4.9) and
(4.10) respectively. The approach to Newton-Raphson load flow is similar to that of solving a
system of nonlinear equations using theNewton-Raphson method: At each iteration we have
to form a Jacobian matrix and solve for the corrections from an equation of the type given in
(4.27). For the load flow problem, this equation is of the form
(4.31)
(4.32)
(4.33)
(4.34)
(4.35)
It can be seen that the size of the Jacobian matrix is ( n + np − 1) x ( n + np −1). For example
for the 5-bus problem of Fig. 4.1 this matrix will be of the size (7 x 7). The dimensions of the
submatrices are as follows:
Step-1: Choose the initial values of the voltage magnitudes |V| (0) of all np load buses and n −
1 angles δ (0) of the voltages of all the buses except the slack bus.
Step-2: Use the estimated |V|(0) and δ (0) to calculate a total n − 1 number of injected real
power Pcalc(0) and equal number of real power mismatch ΔP (0) .
Step-3: Use the estimated |V| (0) and δ (0) to calculate a total np number of injected reactive
power Qcalc(0) and equal number of reactive power mismatch ΔQ (0) .
Step-3: Use the estimated |V| (0) and δ (0) to formulate the Jacobian matrix J (0) .
(4.36)
(4.37)
Step-6: Check if all the mismatches are below a small number. Terminate the process if yes.
Otherwise go back to step-1 to start the next iteration with the updates given by (4.36) and
(4.37).
(4.38)
(4.39)
We shall now discuss the formation of the submatrices of the Jacobian matrix. To do
that we shall use the real and reactive power equations of (4.6) and (4.7). Let us
rewrite them with the help of (4.2) as
A. Formation of J11
Let us define J11 as
(4.40)
It can be seen from (4.32) that Lik's are the partial derivatives of Pi with respect to δk.
The derivative Pi (4.38) with respect to k for i ≠ k is given by
(4.41)
(4.42)
B. Formation of J21
Let us define J21 as
(4.43)
From (4.34) it is evident that the elements of J21 are the partial derivative of Q with
respect to δ . From (4.39) we can write
(4.44)
(4.45)
C. Formation of J12
(4.46)
Let us define J12 as
(4.48)
For i = k we have
Formation of J22
(4.49)
(4.50)
The Newton-Raphson load flow program is tested on the system of Fig. 4.1 with the
system data and initial conditions given in Tables 4.1 to 4.3. From (4.41) we can write
In a similar way the rest of the components of the matrix J11(0) are calculated. This
matrix is given by
For forming the off diagonal elements of J21 we note from (4.44) that
Similarly the rest of the elements of the matrix J21 are calculated. This matrix is then
given as
For calculating the off diagonal elements of the matrix J12 we note from (4.47) that
they are negative of the off diagonal elements of J21 . However the size of J21 is (3 X
4) while the size of J12 is (4 X 3). Therefore to avoid this discrepancy we first compute
a matrix M that is given by
The elements of the above matrix are computed in accordance with (4.44) and (4.45).
We can then define
Furthermore the diagonal elements of J12 are overwritten in accordance with (4.48).
This matrix is then given by
Finally it can be noticed from (4.50) that J22 = J11 (1:3, 1:3). However the diagonal
elements of J22 are then overwritten in accordance with (4.51). This gives the
following matrix
From the initial conditions the power and reactive power are computed as
Then the updates at the end of the first iteration are given as
The load flow converges in 7 iterations when all the power and reactive power
mismatches are below 10−6 .
In this section we shall discuss the results of the load flow. It is to be noted here that both
Gauss-Seidel and Newton-Raphson methods yielded the same result. However the Newton-
Raphson method converged faster than the Gauss-Seidel method. The bus voltage
magnitudes, angles of each bus along with power generated and consumed at each bus are
given in Table 4.4. It can be seen from this table that the total power generated is 174.6 MW
whereas the total load is 171 MW. This indicates that there is a line loss of about 3.6 MW for
all the lines put together. It is to be noted that the real and reactive power of the slack bus and
the reactive power of the P-V bus are computed from (4.6) and (4.7) after the convergence of
the load flow.
Table 4.4 Bus voltages, power generated and load after load flow convergence.
2 0.9826 5.0124 0 0 96 62
3 0.9777 7.1322 0 0 35 14
4 0.9876 7.3705 0 0 16 8
(4.52)
(4.53)
(4.54)
(4.55)
The real power flow over different lines is listed in Table 4.5. This table also gives
the I2 R loss along various segments. It can be seen that all the losses add up to 3.6 MW,
which is the net difference between power generation and load. Finally we can compute the
line I2X drops in a similar fashion. This drop is given by
(4.56)
Consider the line segment 1-2. The voltage of bus-1 is V1 = 1.05 < 0° per unit while that of
bus-2 is V2 = 0.9826 < − 5.0124° per unit. From (4.52) we then have
per unit
Therefore the complex power dispatched from bus-1 is
where the negative signal indicates the power is leaving bus-1. The complex power
received at bus-2 is
MW
Therefore out of a total amount of 101.0395 MW of real power is dispatched from bus-1
over the line segment 1-2, 98.6494 MW reaches bus-2. This indicates that the drop in the
line segment is 2.3901 MW. Note that
MW
where R12 is resistance of the line segment 1-2. Therefore we can also use this method to
calculate the line loss.
MV Ar
We also get this quantity by subtracting the reactive power absorbed by bus-2 from that
supplied by bus-1. The above calculation however does not include the line charging.
Note that since the line is modeled by an equivalent- p , the voltage across the shunt
capacitor is the bus voltage to which the shunt capacitor is connected. Therefore the
current I 12 flowing through line segment is not the current leaving bus-1 or entering bus-
2 - it is the current flowing in between the two charging capacitors. Since the shunt
branches are purely reactive, the real power flow does not get affected by the charging
capacitors. Each charging capacitor is assumed to inject a reactive power that is the
product of the half line charging admittance and square of the magnitude of the voltage of
that at bus. The half line charging admittance of this line is 0.03. Therefore line charging
capacitor will inject
MV Ar
at bus-1. Similarly the reactive injected at bus-2 will be
MV Ar
The power flow through the line segments 1-2 and 1-5 are shown in Fig. 4.2.
(a)
(b)
Fig. 4.2 Real and reactive power flow through (a) line segment 1-2 and (b)
line segment 1-5. The thin lines indicate reactive power flow while the thick
lines indicate real power flow.
Section VIII: Load Flow Programs In Matlab:
The load flow programs are developed in MATLAB. Altogether there are 4 mfiles that are
attached with this chapter. The program listings and descriptions of these mfiles are given
below. It must however be emphasized that these are not general purpose programs and are
written only for the examples of this chapter.
Forming Ybus Matrix
Gauss- Seidel Load Flow
Solving Nonlinear Equations using Newton- Raphson
Newton - Raphson Load Flow
Forming Ybus Matrix:
This is a function that can be called by various programs. The function can be invoked by the
statement
[yb,ych]=ybus;
where 'yb' and 'ych' are respectively the Ybus matrix and a matrix containing the line charging
admittances. It is assumed that the system data of Table 4.1 are given in matrix form and the
matrix that contains line impedances is 'zz', while 'ych' contains the line charging information.
This program is stored in the file ybus.m. The program listing is given below.
% Function ybus
% THIS IS THE PROGRAM FOR CREATING Ybus MATRIX.
function [yb,ych]=ybus
for i=1:5
for j=1:5
if zz(i,j) == 0
yb(i,j)=0;
else
yb(i,j)=-1/zz(i,j);
end
end
end
for i=1:5
ysum=0;
csum=0;
for j=1:5
ysum=ysum+yb(i,j);
csum=csum+ych(i,j);
end
yb(i,i)=csum-ysum;
end
Gauss-Seidel Load Flow:
% Program loadflow_gs
% THIS IS A GAUSS-SEIDEL POWER FLOW PROGRAM
clear all
d2r=pi/180;w=100*pi;
[ybus,ych]=ybus;
g=real(ybus);b=imag(ybus);
p=[0;-0.96;-0.35;-0.16;0.24];
q=[0;-0.62;-0.14;-0.08;-0.35];
mv=[1.05;1;1;1;1.02];
th=[0;0;0;0;0];
v=[mv(1);mv(2);mv(3);mv(4);mv(5)];
while del>1e-6
% P-Q buses
for i=2:4
tmp1=(p(i)-j*q(i))/conj(v(i));
tmp2=0;
for k=1:5
if (i==k)
tmp2=tmp2+0;
else
tmp2=tmp2+ybus(i,k)*v(k);
end
end
vt=(tmp1-tmp2)/ybus(i,i);
v(i)=v(i)+acc*(vt-v(i));
end
% P-V bus
q5=0;
for i=1:5
q5=q5+ybus(5,i)*v(i);
end
q5=-imag(conj(v(5))*q5);
tmp1=(p(5)-j*q5)/conj(v(5));
tmp2=0;
for k=1:4
tmp2=tmp2+ybus(5,k)*v(k);
end
vt=(tmp1-tmp2)/ybus(5,5);
v(5)=abs(v(5))*vt/abs(vt);
% Calculate P and Q
for i=1:5
sm=0;
for k=1:5
sm=sm+ybus(i,k)*v(k);
end
s(i)=conj(v(i))*sm;
end
% The mismatch
delp=p-real(s)';
delq=q+imag(s)';
delpq=[delp(2:5);delq(2:4)];
del=max(abs(delpq));
indx=indx+1;
if indx==1
pause
end
end
% Program nwtraph
% THIS IS A NEWTON-RAPHSON PROGRAM
% We have to solve three nonlinear equations given by
%
% g1=x1^2-x2^2+x3^2-11=0
% g2=x1*x2+x2^2-3x3-3=0
% g3=x1-x1*x3+x2*x3-6=0
%
% Let us assume the initial conditions of x1=x2=x3=1
%
% The Jacobian matrix is
%
% J=[2x1 -2x2 2x3
% x2 x1+2x2 -3
% 1-x3 x3 -x1+x2];
clear all
x=[1;1;1];
del=1;
indx=0;
while del>1e-6
g=[x(1)^2-x(2)^2+x(3)^2-11;x(1)*x(2)+x(2)^2-3*x(3)-
3;x(1)-x(1)*x(3)+x(2)*x(3)-6];
J=[2*x(1) -2*x(2) 2*x(3);x(2) x(1)+2*x(2) -3;1-x(3)
x(3) -x(1)+x(2)];
delx=-inv(J)*g;
x=x+delx;
del=max(abs(g));
indx=indx+1;
end
The Newton-Raphson load flow program is stored in the files loadflow_nr.m. The outputs of the
program can be checked by typing
% Program loadflow_nr
% THIS IS THE NEWTON-RAPHSON POWER FLOW PROGRAM
clear all
d2r=pi/180;w=100*pi;
[ybus,ych]=ybus;
g=real(ybus);b=imag(ybus);
p=[0;-0.96;-0.35;-0.16;0.24];
q=[0;-0.62;-0.14;-0.08;-0.35];
mv=[1.05;1;1;1;1.02];
th=[0;0;0;0;0];
del=1;indx=0;
while del>1e-6
for i=1:5
temp=0;
for k=1:5
temp=temp+mv(i)*mv(k)*(g(i,k)-j*b(i,k))*exp(j*(th(i)-th(k)));
end
pcal(i)=real(temp);qcal(i)=imag(temp);
end
% The mismatches
delp=p-pcal';
delq=q-qcal';
for i=1:4
ii=i+1;
for k=1:4
kk=k+1;
j11(i,k)=mv(ii)*mv(kk)*(g(ii,kk)*sin(th(ii)-th(kk))-
b(ii,kk)*cos(th(ii)-th(kk)));
end
j11(i,i)=-qcal(ii)-b(ii,ii)*mv(ii)^2;
end
for i=1:4
ii=i+1;
for k=1:4
kk=k+1;
j211(i,k)=-mv(ii)*mv(kk)*(g(ii,kk)*cos(th(ii)-th(kk))-
b(ii,kk)*sin(th(ii)-th(kk)));
end
j211(i,i)=pcal(ii)-g(ii,ii)*mv(ii)^2;
end
j21=j211(1:3,1:4);
j12=-j211(1:4,1:3);
for i=1:3
j12(i,i)=pcal(i+1)+g(i+1,i+1)*mv(i+1)^2;
end
j22=j11(1:3,1:3);
for i=1:3
j22(i,i)=qcal(i+1)-b(i+1,i+1)*mv(i+1)^2;
end
delpq=[delp(2:5);delq(2:4)];
corr=inv(jacob)*delpq;
th=th+[0;corr(1:4)];
mv=mv+[0;mv(2:4).*corr(5:7);0];
del=max(abs(delpq));
indx=indx+1;
end
preal=(pcal+[0 0 0 0 0.24])*100;
preac=(qcal+[0 0 0 0 0.11])*100;
for i=1:5
v(i)=mv(i)*exp(j*th(i));
end
for i=1:4
for k=i+1:5
if (ybus(i,k)==0)
s(i,k)=0;s(k,i)=0;
c(i,k)=0;c(k,i)=0;
q(i,k)=0;q(k,i)=0;
cur(i,k)=0;cur(k,i)=0;
else
cu=-(v(i)-v(k))*ybus(i,k);
s(i,k)=-v(i)*cu'*100;
s(k,i)=v(k)*cu'*100;
c(i,k)=100*abs(ych(i,k))*abs(v(i))^2;
c(k,i)=100*abs(ych(k,i))*abs(v(k))^2;
cur(i,k)=cu;cur(k,i)=-cur(i,k);
end
end
end
pwr=real(s);
qwr=imag(s);
q=qwr-c;
% Power loss
ilin=abs(cur);
for i=1:4
for k=i+1:5
if (ybus(i,k)==0)
pl(i,k)=0;pl(k,i)=0;
ql(i,k)=0;ql(k,i)=0;
else
z=-1/ybus(i,k);
r=real(z);
x=imag(z);
pl(i,k)=100*r*ilin(i,k)^2;pl(k,i)=pl(i,k); ql(i,k
)=100*x*ilin(i,k)^2;ql(k,i)=ql(i,k);
end
end
end