0% found this document useful (0 votes)
82 views

% Program Loadflow - Gs % This Is A Gauss-Seidel Power Flow Program

The document describes a Gauss-Seidel load flow program that is used to calculate bus voltages and power flows in a power system network. The program calls a function to build the bus admittance matrix and performs Gauss-Seidel iterations to calculate bus voltages until results converge within a specified tolerance. The program outputs include the number of iterations to converge, final bus voltages and voltage magnitudes, bus angles in degrees, and real and reactive power flows.

Uploaded by

Vidhi Bansal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

% Program Loadflow - Gs % This Is A Gauss-Seidel Power Flow Program

The document describes a Gauss-Seidel load flow program that is used to calculate bus voltages and power flows in a power system network. The program calls a function to build the bus admittance matrix and performs Gauss-Seidel iterations to calculate bus voltages until results converge within a specified tolerance. The program outputs include the number of iterations to converge, final bus voltages and voltage magnitudes, bus angles in degrees, and real and reactive power flows.

Uploaded by

Vidhi Bansal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Gauss-Seidel Load Flow

The Gauss-Seidel program is stored in the file loadflow_gs.m. This calls the ybus.m function discussed
above. The program allows the selection of the acceleration factor. The program lists the number of
iterations required to converge, bus voltages and their magnitudes and real and reactive power. The
program listing is given below.
% Program loadflow_gs
% THIS IS A GAUSS-SEIDEL POWER FLOW PROGRAM
clear all
d2r=pi/180;w=100*pi;
% The Y_bus matrix is
[ybus,ych]=ybus;
g=real(ybus);b=imag(ybus);
% The given parameters and initial conditions are
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)];
acc=input('Enter the acceleration constant: ');
del=1;indx=0;
% The Gauss-Seidel iterations starts here
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
'GS LOAD FLOW CONVERGES IN ITERATIONS',indx,pause
'FINAL VOLTAGE MAGNITUDES ARE',abs(v)',pause
'FINAL ANGLES IN DEGREE ARE',angle(v)'/d2r,pause
'THE REAL POWERS IN EACH BUS IN MW ARE',(real(s)+[0 0 0 0
0.24])*100,pause
'THE REACTIVE POWERS IN EACH BUS IN MVar ARE',(-imag(s)+[0 0 0 0
0.11])*100

Or
% IMPLEMENTATION OF GAUSS SEIDEL METHOD IN MATLAB
% DESIGNED BY:
%
HAFIZ KASHIF KHALEEL B-12588
%
CREATED: 19-Dec-2009
%
SEMESTER # 7, EE(POWER)
%
SUBJECT: POWER SYSTEM OPERATION AND CONTROL
%
University of South Asia. Lahore. PAKISTAN
format short g
disp (' TABLE 9.2 PAGE # 337
LINE
linedata=[1
2
0.01008,
0.05125;
1
3
0.00744,
0.03875;
2
4
0.00744,
0.03875;
3
4
0.01272,
0.06375]

DATA FOR EXAMPLE 9.2 ')


0.05040,
3.815629,

-19.078144,

10.25,

0.03720,

5.169561,

-25.847809,

7.75,

0.03720,

5.169561,

-25.847809,

7.75,

0.06360,

3.023705,

-15.118528,

12.75,

disp (' TABLE 9.3 PAGE # 338


BUS DATA FOR EXAMPLE
busdata=[1
0,
0, 50,
30.99, 1.00,
0
2
0,
0, 170,
105.35, 1.00,
0
3
0,
0, 200,
123.94, 1.00,
0
4
318,
0 , 80,
49.58, 1.02,
0
% Bus Type: 1.Slack Bus
2.PQ Bus
3.PV Bus

9.2 ')
1;
2;
2;
3]

ss=i*linedata(:,8);
y=linedata(:,5)+i*linedata(:,6);
totalbuses = max(max(linedata(:,1)),max(linedata(:,2)));
totalbranches = length(linedata(:,1));
ybus = zeros(totalbuses,totalbuses);

% total buses
% no. of branches

for b=1:totalbranches
ybus((linedata(b,1)),(linedata(b,2)))=-y(b);
ybus((linedata(b,2)),(linedata(b,1))) =ybus((linedata(b,1)),(linedata(b,2)));
end
for c=1:totalbuses
for d=1:totalbranches
if linedata(d,1) == c || linedata(d,2) == c
ybus(c,c) = ybus(c,c) + y(d) + ss(d);
end
end
end
disp('TABLE 9.3 PAGE # 338
BUS ADMITTANCE MATRIX FOR EXAMPLE 9.2')
ybus
z=zeros(totalbuses,4);
busnumber=busdata(:,1);
PG=busdata(:,2);
QG=busdata(:,3);

PL=busdata(:,4);
QL=busdata(:,5);
V=busdata(:,6);
VV=V;
ANG=busdata(:,7);
type = busdata(:,8);
P = (PG-PL)./100;
% per unit active power at buses
Q = (QG-QL)./100;
% per unit reactive power at buses
tol=1;
iter=0;
kk=input('Enter the tolerance for iteration ');
%alfa=input('Enter the value of ALPHA ');
alfa=1.6
while tol > kk
for i = 2:totalbuses
YV = 0;
for k = 1:totalbuses
if i~=k
YV = YV + ybus(i,k)* V(k); % multiplying admittance & voltage
end
YV;
end
if busdata(i,8) == 3
%Calculating Qi for PV bus
%Q(i) = -imag(conj(V(i))*(YV + ybus(i,i)*V(i)));
Q(i) = -imag(conj(V(i))*(YV + ybus(i,i)*V(i)));
busdata(i,3)=Q(i);
end
% end
V(i) = (1/ybus(i,i))*((P(i)-j*Q(i))/conj(V(i)) - YV); % Compute Bus Voltages.
% Calculating Corrected Voltage for PV bus
if busdata(i,8) == 3
vc(i)=abs(VV(i))*(V(i)/abs(V(i)));
busdata(i,6)=vc(i);
V(i)=vc(i);
end

% Calculating Accelerated Voltage for PQ bus


if busdata(i,8) == 2
VACC(i)= VV(i)+alfa*(V(i)-VV(i));
busdata(i,6)=VACC(i);
V(i)=VACC(i);
end
%V(i)=V;
end
iter = iter + 1;
% Increment iteration count.
tol = max(abs(abs(V) - abs(VV)));
% Calculate tolerance.

VV = V;
end
Q;
iter
YV;
V;
%real(VACC')
z(1:totalbuses,1)=busdata(:,1);
z(1:totalbuses,2)=busdata(:,8);
z(1:totalbuses,3)=abs(busdata(:,6));
z(1:totalbuses,4)=radtodeg(angle(V));
disp('
z

Bus No.

Bus Type

Voltage

Angle

');

You might also like