Professional Documents
Culture Documents
Experiment 2 - Gauss Seidel
Experiment 2 - Gauss Seidel
GAUSS-SEIDEL METHOD
AIM:
APPARATUS:
1. MATLAB R2022a
ALGORITHM:
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:
𝐢−𝟏 𝐧
𝐏𝐢 − 𝐣𝐐𝐢 𝐘𝐢𝐤 𝐫+𝟏 𝐘𝐢𝐤 𝐫
𝐕𝐢 𝐫+𝟏 = 𝐫 ∗ − ∑ 𝐕𝐤 − ∑ 𝐕
(𝐕𝐢 ) 𝐘𝐢𝐢 𝐘𝐢𝐢 𝐤
𝐤=𝟏 𝐤=𝐢+𝟏
5. The line flows, line losses and power fed into line from bus 𝑖 are given by:
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:
∠𝛅𝐢 𝐫+𝟏 = ∠𝐕𝐢 𝐫+𝟏
𝐢−𝟏 𝐧
𝐏𝐢 − 𝐣𝐐𝐢 𝐘𝐢𝐤 𝐫+𝟏 𝐘𝐢𝐤 𝐫
𝐕𝐢 𝐫+𝟏 = − ∑ 𝐕 − ∑ 𝐕
(𝐕𝐢 𝐫 )∗ 𝐘𝐢𝐢 𝐤 𝐘𝐢𝐢 𝐤
𝐤=𝟏 𝐤=𝐢+𝟏
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];
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;
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
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
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
if(busdata(i,2) == 1)
sum = 0;
for k = 1:nbuses
if k~=i
sum = sum + (v(k).*YBus(i, k));
end
end
end
delta
v
busdata(:,6) = delta;
busdata
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
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 =
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 =
Ii =
lineflows =
losses =
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.