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

Contoh Program Matlab Gauss Seidel

The document contains Matlab code for load flow analysis of a 6 bus power system without and with injection at bus 4. It includes functions to define the bus data, line data, form the admittance matrix, and perform Gauss-Seidel load flow analysis. Without injection, the results show bus voltages, angles, currents, powers and losses. With injection of 52.46 MW at bus 4, the analysis is rerun and results will change due to the additional generation.

Uploaded by

Teguh Weda Angga
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
183 views

Contoh Program Matlab Gauss Seidel

The document contains Matlab code for load flow analysis of a 6 bus power system without and with injection at bus 4. It includes functions to define the bus data, line data, form the admittance matrix, and perform Gauss-Seidel load flow analysis. Without injection, the results show bus voltages, angles, currents, powers and losses. With injection of 52.46 MW at bus 4, the analysis is rerun and results will change due to the additional generation.

Uploaded by

Teguh Weda Angga
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Nama : Gede Teguh Adi Wedangga

Nim : 165060301111067

Listing Program Matlab Bus Tanpa Injeksi


% Bus data for Load Flow Analysis.
% Praviraj P G, MTech I Year, EE Dept., IIT Roorkee, India, Email
:[email protected]

function busdata = busdata6() % Returns busdata.


% |Bus | Type | Vsp | theta | PGi | QGi | PLi | QLi | Qmin | Qmax |
busdata = [ 1 1 100 0 0.0 0.0 0 0 0 0;
2 3 100 0 0.0 0 100 0 0 0;
3 3 100 0 0.0 0 100 0 0 0;
4 3 100 0 0.0 0 100 0 0 0;
5 3 100 0 0.0 0 100 0 0 0;
];

% Line Data for Y-Bus Formation.


% Praviraj P G, MTech I Year, EE Dept., IIT Roorkee, India, Email
:[email protected]

function linedata = linedata6() % Returns linedata. %C = -802.761

% | From | To | R | X | B/2 |
% | Bus | Bus | | | |
linedata = [ 1 2 2.5 5.843 0;
1 3 2.5 5.843 0;
2 4 2.5 5.843 0;
3 5 2.5 5.843 0;
2 5 2.5 5.843 0;
];

% Program to form Admittance And Impedance Bus Formation....


% Praviraj P G, MTech I Year, EE Dept., IIT Roorkee, India, Email :
[email protected]

function ybus = ybusppg(); % Returns ybus

linedata = linedata6(); % Calling "linedata6.m" for Line Data...


fb = linedata(:,1); % From bus number...
tb = linedata(:,2); % To bus number...
r = linedata(:,3); % Resistance, R...
x = linedata(:,4); % Reactance, X...
b = linedata(:,5); % Ground Admittance, B/2...
z = r + i*x; % Z matrix...
y = 1./z; % To get inverse of each element...
b = i*b; % Make B imaginary...

nbus = max(max(fb),max(tb)); % no. of buses...


nbranch = length(fb); % no. of branches...
ybus = zeros(nbus,nbus); % Initialise YBus...

% Formation of the Off Diagonal Elements...


for k=1:nbranch
ybus(fb(k),tb(k)) = -y(k);
ybus(tb(k),fb(k)) = ybus(fb(k),tb(k));
end
% Formation of Diagonal Elements....
for m=1:nbus
for n=1:nbranch
if fb(n) == m | tb(n) == m
ybus(m,m) = ybus(m,m) + y(n) + b(n);
end
end
end
ybus; % Bus Admittance Matrix
zbus = inv(ybus); % Bus Impedance Matrix
end

% Program for Gauss - Seidel Load Flow Analysis


% Praviraj P G, MTech I Year, EE Dept., IIT Roorkee, India, Email
:[email protected]

% Assumption, Bus 1 is considered as Slack bus.

ybus = ybusppg(); % Calling program "ybusppg.m" to get Y-Bus.


busdata = busdata6(); % Calling "busdata6.m" for bus data.

bus = busdata(:,1); % Bus number.


type = busdata(:,2); % Type of Bus 1-Slack, 2-PV, 3-PQ.
V = busdata(:,3); % Initial Bus Voltages.
th = busdata(:,4); % Initial Bus Voltage Angles.
GenMW = busdata(:,5); % PGi, Real Power injected into the buses.
GenMVAR = busdata(:,6); % QGi, Reactive Power injected into the buses.
LoadMW = busdata(:,7); % PLi, Real Power Drawn from the buses.
LoadMVAR = busdata(:,8); % QLi, Reactive Power Drawn from the buses.
Qmin = busdata(:,9); % Minimum Reactive Power Limit
Qmax = busdata(:,10); % Maximum Reactive Power Limit
nbus = max(bus); % To get no. of buses
P = GenMW - LoadMW; % Pi = PGi - PLi, Real Power at the buses.
Q = GenMVAR - LoadMVAR; % Qi = QGi - QLi, Reactive Power at the buses.
Vprev = V;
toler = 1; % Tolerence.
iteration = 1; % iteration starting
while (toler > 0.00001) % Start of while loop
for i = 2:nbus
sumyv = 0;
for k = 1:nbus
if i ~= k
sumyv = sumyv + ybus(i,k)* V(k); % Vk * Yik
end
end
if type(i) == 2 % Computing Qi for PV bus
Q(i) = -imag(conj(V(i))*(sumyv + ybus(i,i)*V(i)));
if (Q(i) > Qmax(i)) || (Q(i) < Qmin(i)) % Checking for Qi Violation.
if Q(i) < Qmin(i) % Whether violated the lower limit.
Q(i) = Qmin(i);
else % No, violated the upper limit.
Q(i) = Qmax(i);
end
type(i) = 3; % If Violated, change PV bus to PQ bus.
end
end
V(i) = (1/ybus(i,i))*((P(i)-j*Q(i))/conj(V(i)) - sumyv); % Compute Bus
Voltages.
if type(i) == 2 % For PV Buses, Voltage Magnitude remains same, but Angle
changes.
V(i) = pol2rect(abs(Vprev(i)), angle(V(i)));
end
end
iteration = iteration + 1; % Increment iteration count.
toler = max(abs(abs(V) - abs(Vprev))); % Calculate tolerance.
Vprev = V; % Vprev is required for next iteration, V(i) =
pol2rect(abs(Vprev(i)), angle(V(i)));
end % End of while loop / Iteration

iteration % Total iterations.


V % Bus Voltages in Complex form.
Vmag = abs(V) % Final Bus Voltages.
Ang = 180/pi*angle(V) % Final Bus Voltage Angles in Degree.
Ibus = ybus*V % Ibus
Sbus = diag(V)*conj(Ibus)
Smag = abs(Sbus)
SudutDaya = 180/pi*angle(Sbus)
Srugi = transpose(V)*conj(Ibus)

Hasil Bus Tanpa Injeksi


>> busdata6
ans =
1 1 100 0 0 0 0 0 0 0
2 3 100 0 0 0 100 0 0 0
3 3 100 0 0 0 100 0 0 0
4 3 100 0 0 0 100 0 0 0
5 3 100 0 0 0 100 0 0 0

>> linedata6
ans =
1.0000 2.0000 2.5000 5.8430 0
1.0000 3.0000 2.5000 5.8430 0
2.0000 4.0000 2.5000 5.8430 0
3.0000 5.0000 2.5000 5.8430 0
2.0000 5.0000 2.5000 5.8430 0
>> ybusppg
ans =
0.1238 - 0.2893i -0.0619 + 0.1447i -0.0619 + 0.1447i 0.0000 + 0.0000i 0.0000 + 0.0000i
-0.0619 + 0.1447i 0.1857 - 0.4340i 0.0000 + 0.0000i -0.0619 + 0.1447i -0.0619 + 0.1447i
-0.0619 + 0.1447i 0.0000 + 0.0000i 0.1238 - 0.2893i 0.0000 + 0.0000i -0.0619 + 0.1447i
0.0000 + 0.0000i -0.0619 + 0.1447i 0.0000 + 0.0000i 0.0619 - 0.1447i 0.0000 + 0.0000i
0.0000 + 0.0000i -0.0619 + 0.1447i -0.0619 + 0.1447i 0.0000 + 0.0000i 0.1238 - 0.2893i

>> gaussppg
iteration =
38

V=
1.0e+02 *
1.0000 + 0.0000i
0.9156 - 0.1313i
0.9375 - 0.1024i
0.8745 - 0.1892i
0.9081 - 0.1461i

Vmag =
100.0000
92.5009
94.3094
89.4760
91.9788
Ang =
0
-8.1625
-6.2326
-12.2107
-9.1372

Ibus =
4.2899 - 0.6776i
-1.0701 + 0.1535i
-1.0541 + 0.1151i
-1.0923 + 0.2364i
-1.0734 + 0.1726i

Sbus =
1.0e+02 *
4.2899 + 0.6776i
-1.0000 + 0.0000i
-1.0000 + 0.0000i
-1.0000 + 0.0000i
-1.0000 + 0.0000i

Smag =
434.3122
99.9998
99.9999
100.0000
100.0000

SudutDaya =
8.9762
179.9999
180.0000
180.0000
180.0000

Srugi =
28.9936 +67.7638i

Listing Program Matlab Injeksi di Bus 4


% Bus data for Load Flow Analysis.
% Praviraj P G, MTech I Year, EE Dept., IIT Roorkee, India, Email
:[email protected]

function busdata = busdata6() % Returns busdata.


% |Bus | Type | Vsp | theta | PGi | QGi | PLi | QLi | Qmin | Qmax |
busdata = [ 1 1 100 0 0.0 0.0 0 0 0 0;
2 3 100 0 0.0 0 100 0 0 0;
3 3 100 0 0.0 0 100 0 0 0;
4 3 100 0 52.46 0 100 0 0 0;
5 3 100 0 0.0 0 100 0 0 0;
];

% Line Data for Y-Bus Formation.


% Praviraj P G, MTech I Year, EE Dept., IIT Roorkee, India, Email
:[email protected]

function linedata = linedata6() % Returns linedata. %C = -802.761

% | From | To | R | X | B/2 |
% | Bus | Bus | | | |
linedata = [ 1 2 2.5 5.843 0;
1 3 2.5 5.843 0;
2 4 2.5 5.843 0;
3 5 2.5 5.843 0;
2 5 2.5 5.843 0;
];

% Program to form Admittance And Impedance Bus Formation....


% Praviraj P G, MTech I Year, EE Dept., IIT Roorkee, India, Email :
[email protected]

function ybus = ybusppg(); % Returns ybus

linedata = linedata6(); % Calling "linedata6.m" for Line Data...


fb = linedata(:,1); % From bus number...
tb = linedata(:,2); % To bus number...
r = linedata(:,3); % Resistance, R...
x = linedata(:,4); % Reactance, X...
b = linedata(:,5); % Ground Admittance, B/2...
z = r + i*x; % Z matrix...
y = 1./z; % To get inverse of each element...
b = i*b; % Make B imaginary...

nbus = max(max(fb),max(tb)); % no. of buses...


nbranch = length(fb); % no. of branches...
ybus = zeros(nbus,nbus); % Initialise YBus...

% Formation of the Off Diagonal Elements...


for k=1:nbranch
ybus(fb(k),tb(k)) = -y(k);
ybus(tb(k),fb(k)) = ybus(fb(k),tb(k));
end

% Formation of Diagonal Elements....


for m=1:nbus
for n=1:nbranch
if fb(n) == m | tb(n) == m
ybus(m,m) = ybus(m,m) + y(n) + b(n);
end
end
end
ybus; % Bus Admittance Matrix
zbus = inv(ybus); % Bus Impedance Matrix
end

% Program for Gauss - Seidel Load Flow Analysis


% Praviraj P G, MTech I Year, EE Dept., IIT Roorkee, India, Email
:[email protected]

% Assumption, Bus 1 is considered as Slack bus.

ybus = ybusppg(); % Calling program "ybusppg.m" to get Y-Bus.


busdata = busdata6(); % Calling "busdata6.m" for bus data.

bus = busdata(:,1); % Bus number.


type = busdata(:,2); % Type of Bus 1-Slack, 2-PV, 3-PQ.
V = busdata(:,3); % Initial Bus Voltages.
th = busdata(:,4); % Initial Bus Voltage Angles.
GenMW = busdata(:,5); % PGi, Real Power injected into the buses.
GenMVAR = busdata(:,6); % QGi, Reactive Power injected into the buses.
LoadMW = busdata(:,7); % PLi, Real Power Drawn from the buses.
LoadMVAR = busdata(:,8); % QLi, Reactive Power Drawn from the buses.
Qmin = busdata(:,9); % Minimum Reactive Power Limit
Qmax = busdata(:,10); % Maximum Reactive Power Limit
nbus = max(bus); % To get no. of buses
P = GenMW - LoadMW; % Pi = PGi - PLi, Real Power at the buses.
Q = GenMVAR - LoadMVAR; % Qi = QGi - QLi, Reactive Power at the buses.
Vprev = V;
toler = 1; % Tolerence.
iteration = 1; % iteration starting
while (toler > 0.00001) % Start of while loop
for i = 2:nbus
sumyv = 0;
for k = 1:nbus
if i ~= k
sumyv = sumyv + ybus(i,k)* V(k); % Vk * Yik
end
end
if type(i) == 2 % Computing Qi for PV bus
Q(i) = -imag(conj(V(i))*(sumyv + ybus(i,i)*V(i)));
if (Q(i) > Qmax(i)) || (Q(i) < Qmin(i)) % Checking for Qi Violation.
if Q(i) < Qmin(i) % Whether violated the lower limit.
Q(i) = Qmin(i);
else % No, violated the upper limit.
Q(i) = Qmax(i);
end
type(i) = 3; % If Violated, change PV bus to PQ bus.
end
end
V(i) = (1/ybus(i,i))*((P(i)-j*Q(i))/conj(V(i)) - sumyv); % Compute Bus
Voltages.
if type(i) == 2 % For PV Buses, Voltage Magnitude remains same, but Angle
changes.
V(i) = pol2rect(abs(Vprev(i)), angle(V(i)));
end
end
iteration = iteration + 1; % Increment iteration count.
toler = max(abs(abs(V) - abs(Vprev))); % Calculate tolerance.
Vprev = V; % Vprev is required for next iteration, V(i) =
pol2rect(abs(Vprev(i)), angle(V(i)));
end % End of while loop / Iteration

iteration % Total iterations.


V % Bus Voltages in Complex form.
Vmag = abs(V) % Final Bus Voltages.
Ang = 180/pi*angle(V) % Final Bus Voltage Angles in Degree.
Ibus = ybus*V % Ibus
Sbus = diag(V)*conj(Ibus)
Smag = abs(Sbus)
SudutDaya = 180/pi*angle(Sbus)
Srugi = transpose(V)*conj(Ibus)

Hasil Bus Injeksi di Bus 4

>> busdata6
ans =
1.0000 1.0000 100.0000 0 0 0 0 0 0 0
2.0000 3.0000 100.0000 0 0 0 100.0000 0 0 0
3.0000 3.0000 100.0000 0 0 0 100.0000 0 0 0
4.0000 3.0000 100.0000 0 52.4600 0 100.0000 0 0 0
5.0000 3.0000 100.0000 0 0 0 100.0000 0 0 0
>> linedata6
ans =

1.0000 2.0000 2.5000 5.8430 0


1.0000 3.0000 2.5000 5.8430 0
2.0000 4.0000 2.5000 5.8430 0
3.0000 5.0000 2.5000 5.8430 0
2.0000 5.0000 2.5000 5.8430 0

>> ybusppg
ans =
0.1238 - 0.2893i -0.0619 + 0.1447i -0.0619 + 0.1447i 0.0000 + 0.0000i 0.0000 + 0.0000i
-0.0619 + 0.1447i 0.1857 - 0.4340i 0.0000 + 0.0000i -0.0619 + 0.1447i -0.0619 + 0.1447i
-0.0619 + 0.1447i 0.0000 + 0.0000i 0.1238 - 0.2893i 0.0000 + 0.0000i -0.0619 + 0.1447i
0.0000 + 0.0000i -0.0619 + 0.1447i 0.0000 + 0.0000i 0.0619 - 0.1447i 0.0000 + 0.0000i
0.0000 + 0.0000i -0.0619 + 0.1447i -0.0619 + 0.1447i 0.0000 + 0.0000i 0.1238 - 0.2893i

>> gaussppg

iteration =
35

V=
1.0e+02 *
1.0000 + 0.0000i
0.9364 - 0.1084i
0.9455 - 0.0946i
0.9194 - 0.1361i
0.9233 - 0.1307i
Vmag =
100.0000
94.2641
95.0206
92.9379
93.2471

Ang =
0
-6.6062
-5.7150
-8.4232
-8.0560

Ibus =
3.6688 - 0.4521i
-1.0538 + 0.1220i
-1.0472 + 0.1048i
-0.5060 + 0.0749i
-1.0618 + 0.1503i

Sbus =
1.0e+02 *
3.6688 + 0.4521i
-1.0000 + 0.0000i
-1.0000 + 0.0000i
-0.4754 + 0.0000i
-1.0000 + 0.0000i
Smag =
369.6562
99.9997
99.9999
47.5400
100.0000

SudutDaya =
7.0244
179.9999
180.0000
180.0000
180.0000

Srugi =
19.3420 +45.2062i

You might also like