You are on page 1of 8

EXP 2: POWER FLOW ANALYSIS USING

GAUSS-SEIDEL METHOD
AIM:

To develop a MATLAB program to perform power flow analysis for a given


system using Gauss-Seidel Method.

APPARATUS:

S.no Software Version

1. MATLAB R2022a

ALGORITHM:

CASE 1: ALL PQ BUSES:

1. Slack bus voltage magnitude and angle are assumed, usually 𝑉1 = 1∠0° 𝑝𝑢.

2. With the line impedance and shunt admittance values given, calculate the line
and shunt admittance, Y-Bus matrix Y, is formed using either Inspection
method or Singular transformation method.

3. Compute bus voltages using the equation below, assuming a flat start:

𝐢−𝟏 𝐧
𝐏𝐢 − 𝐣𝐐𝐢 𝐘𝐢𝐤 𝐫+𝟏 𝐘𝐢𝐤 𝐫
𝐕𝐢 𝐫+𝟏 = 𝐫 ∗ − ∑ 𝐕𝐤 − ∑ 𝐕
(𝐕𝐢 ) 𝐘𝐢𝐢 𝐘𝐢𝐢 𝐤
𝐤=𝟏 𝐤=𝐢+𝟏

where: 𝑃𝑖 and 𝑄𝑖 are real and reactive power injections at bus 𝑖.


4. The iterative process is continued till the change in magnitude of bus voltage,
|∆𝑉𝑖 |, between two consecutive iterations is less than a certain tolerance for all
bus voltages.

5. The line flows, line losses and power fed into line from bus 𝑖 are given by:

𝐈𝐢𝐤 = (𝐕𝐢 − 𝐕𝐤 )𝐲𝐢𝐤


𝐒𝐢𝐤 = 𝐏𝐢𝐤 + 𝐐𝐢𝐤 = 𝐕𝐢 𝐈𝐢𝐤 ∗
𝐒𝐤𝐢 = 𝐏𝐤𝐢 + 𝐐𝐤𝐢 = 𝐕𝐤 𝐈𝐤𝐢 ∗
𝐋𝐨𝐬𝐬𝐞𝐬 = 𝐒𝐢𝐤 + 𝐒𝐤𝐢

CASE 2: WITH PV ADJUSTMENT

1. At the PV buses, P and |V| are specified and Q and δ are unknowns to be
determined. Therefore, the values of Q and δ are to be updated in every GS
iteration through appropriate bus equations.

2. The revised value of the reactive power of the PV bus calculated by:

𝐢−𝟏 𝐧
𝐫+𝟏 𝐫 ∗ 𝐫+𝟏
𝐐𝐢 = (𝐕𝐢 ) ∑ 𝐘𝐢𝐤 𝐕𝐤 + (𝐕𝐢 ) ∑ 𝐘𝐢𝐤 𝐕𝐤 𝐫
𝐫 ∗

𝐤=𝟏 𝐤=𝐢

3. As voltage magnitude is fixed for PV buses, compute the angle for the voltage
as follows:
∠𝛅𝐢 𝐫+𝟏 = ∠𝐕𝐢 𝐫+𝟏

Where the voltage is given by:

𝐢−𝟏 𝐧
𝐏𝐢 − 𝐣𝐐𝐢 𝐘𝐢𝐤 𝐫+𝟏 𝐘𝐢𝐤 𝐫
𝐕𝐢 𝐫+𝟏 = − ∑ 𝐕 − ∑ 𝐕
(𝐕𝐢 𝐫 )∗ 𝐘𝐢𝐢 𝐤 𝐘𝐢𝐢 𝐤
𝐤=𝟏 𝐤=𝐢+𝟏

4. If there is a limit specified on the reactive power, check it and if at any point the
computed reactive power is out of bounds, set the reactive power to the
nearest bound and convert the bus into a PQ bus. The algorithm for PQ buses
should be followed once the conversion happens.

5. Compute the line flows, losses and slack bus power given by the
aforementioned equations after the desired number of iterations is completed.

MATLAB CODE:
clc;clear;

% SNO FB TB P+JQ
linedata=[1 1 2 0.03846+j*0.192 0;
2 1 3 0.0688+j*0.22936 0;
3 2 3 0.03077+j*0.246 0;
4 2 4 0.21113+j*0.384 0;
5 3 4 0.115+j*0.287 0];

% BNo Type P Q |V| Delta


busdata = [1 0 NaN NaN 1.06 0;
2 2 0.5 NaN 1.04 0;
3 1 -0.4 -0.3 1 0;
4 1 -0.2 -0.1 1 0];

nlines = length(linedata(:,1));
FB = linedata(:,2);
TB = linedata(:,3);
nbuses = max(max(FB),max(TB));
y = zeros(nbuses);

for k = 1 : nlines
l = linedata(k,2);
m = linedata(k,3);
y(l,l) = y(l,l) + 1/linedata(k,4) + linedata(k,5);
y(m,m) = y(m,m) + 1/linedata(k,4) + linedata(k,5);
y(m,l) = - 1/linedata(k,4);
y(l,m) = y(m,l);
end
YBus = y

v = busdata(:, 5);
magv = busdata(:, 5);
delta = busdata(:, 6);
p = busdata(:, 3);
q = busdata(:, 4);
iter = 1;
vprev = 0;
magvprev = 0;
deltaprev = 0;
qprev = 0;

for iter = 1:2


for i = 1:nbuses
vprev = v(i);
magvprev = magv(i);
deltaprev = delta(i);
qprev = q(i);

if(busdata(i,2) == 2)
sum = 0;
for k = 1:nbuses
sum = sum + (v(k).*YBus(i, k));
end

q(i) = -imag(conj(v(i)).*sum);
if(q(i) >= 0.1 && q(i) <= 2)

sum = 0;
for k = 1:nbuses
if k~=i
sum = sum + (v(k).*YBus(i, k));
end
end

v(i) = (1./YBus(i, i)).*(((p(i) -


1j.*q(i))./(conj(vprev)))-sum);
delta(i) = angle(v(i));
v(i) = magv(i).*exp(1i.*delta(i));

elseif(q(i)<0.1)
q(i) = 0.1;
busdata(i,2) = 1;
sum = 0;

for k = 1:nbuses
if k~=i
sum = sum + (v(k).*YBus(i, k));
end
end

v(i) = (1./YBus(i, i)).*(((p(i) -


1j.*q(i))./(conj(vprev)))-sum);
magv(i) = abs(v(i));
delta(i) = angle(v(i));

elseif(q(i)>2)
q(i) = 2;
busdata(i,2) = 1;
sum = 0;
for k = 1:nbuses
if k~=i
sum = sum + (v(k).*YBus(i, k));
end
end

v(i) = (1./YBus(i, i)).*(((p(i) -


1j.*q(i))./(conj(vprev)))-sum);
magv(i) = abs(v(i));
delta(i) = angle(v(i));
end
end

if(busdata(i,2) == 1)
sum = 0;
for k = 1:nbuses
if k~=i
sum = sum + (v(k).*YBus(i, k));
end
end

v(i) = (1./YBus(i, i)).*(((p(i) -


1j.*q(i))./(conj(vprev)))-sum);
magv(i) = abs(v(i));
delta(i) = angle(v(i));
end
end

end
delta
v

busdata(:,6) = delta;
busdata

% finding line flows

Ii = zeros(nbuses,nbuses);
nbranch = length(busdata(:,1));
fb = linedata(:,2);
tb = linedata(:,3);

Vnew = v;

% lineflows
for i = 1 : nbranch
Ii(fb(i),tb(i)) = (Vnew(fb(i)) - Vnew(tb(i))) * (-
YBus(fb(i),tb(i)));
Ii(tb(i),fb(i)) = -Ii(fb(i),tb(i));
end
Ii
lineflows = zeros(nbuses,nbuses);
for i = 1 : nbranch
lineflows(fb(i),tb(i)) = (Vnew(fb(i))) *
conj(Ii(fb(i),tb(i)));
lineflows(tb(i),fb(i)) = (Vnew(tb(i))) *
conj(Ii(tb(i),fb(i)));
end
lineflows

% losses

for i = 1:nbranch
losses(i) = lineflows(fb(i),tb(i)) +
lineflows(tb(i),fb(i));
end

losses

% power injected at each bus


I_inj = zeros(nbuses,1);
S_inj = zeros(nbuses,1);

for i = 1: nbuses
for j = 1 : nbuses
I_inj(i) = I_inj(i) + (YBus(i,j) * Vnew(j));
end
S_inj(i) = Vnew(i) * conj(I_inj(i));
end

I_inj
S_inj

OUTPUT:

YBus =

2.2029 - 9.0074i -1.003 + 5.0074i -1.1999 + 4i 0 +


0i
-1.003 + 5.0074i 2.6031 - 11.009i -0.50063 + 4.0024i -
1.0995 + 1.9997i
-1.1999 + 4i -0.50063 + 4.0024i 2.9035 - 1.005i -
1.203 + 3.0023i
0 + 0i -1.0995 + 1.9997i -1.203 + 3.0023i
2.3025 - 5.0019i

delta =
0
0.028054
-0.023207
-0.025899

v =

1.06 + 0i
1.0422 + 0.029247i
0.99982 - 0.023207i
0.98318 - 0.025469i

busdata =

1 0 NaN NaN 1.06 0


2 1 0.5 NaN 1.04 0.028054
3 1 -0.4 -0.3 1 -0.023207
4 1 -0.2 -0.1 1 -0.025899

Ii =

0 + 0i -0.12864 - 0.11827i 0.16504 - 0.21287i 0


+ 0i
0.12864 + 0.11827i 0 + 0i 0.23118 - 0.14351i
0.17435-0.057946i
-0.16504 + 0.21287i -0.23118 + 0.14351i 0 +0i 0 + 0i
0 + 0i -0.17435 + 0.057946i 0 + 0i 0 + 0i

lineflows =

0 + 0i -0.13635 + 0.12537i 0.17494 + 0.22564i 0


+ 0i
0.13753 -0.11951i 0 + 0i 0.23675 + 0.15633i
0.18002 + 0.065492i
-0.16995 - 0.209i -0.23447 - 0.13812i 0 + 0i 0
+ 0i
0 + 0i -0.17289 - 0.05253i 0 + 0i 0
+ 0i

losses =

0.0011744 + 0.0058628i 0.0049914 + 0.01664i 0.0022782 +


0.018213i 0.0071267 + 0.012962i

I_inj =

0.036399 - 0.33114i
0.53416 - 0.083182i
-0.3694 + 0.30913i
-0.20116 + 0.1052i
S_inj =

0.038583 + 0.35101i
0.55429 + 0.10232i
-0.37651 - 0.3005i
-0.20046 - 0.098304i

RESULT:

Thus, the power flow analysis for the given system was carried out using
Gauss-Seidel method in MATLAB and the results were verified.

You might also like