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

Loadflowfinal Kad Matlab Code

Uploaded by

sdmrnmist
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Loadflowfinal Kad Matlab Code

Uploaded by

sdmrnmist
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

6/24/23, 7:51 AM loadflowfinal_kad

Contents
Formation of Y matrix from the given data

Solution using Gauss-Seidel Method


Calculation of voltage and phase angle of slack, generator and load buses
Calculation of real and reactive power of Slack Bus

%{
EECE 305 Open Ended Lab
Group Members:
202116029 : K. M. Taskin Zaman Kafi
202116034 : Mahmuda Akter
202116029 : MD Abrar Shahriar Kabir
%}

clc
clear all
close all

% Given Bus Data


bus_data = [ 1 1.06 0.0 0 0 0 0
2 1.0 0.0 20 20 40 30
3 1.0 0.0 -45 -15 0 0
4 1.0 0.0 -40 -5 0 0
5 1.0 0.0 -60 -10 0 0 ];

% Given Transmission Line Data


tldata = [ 1 2 0.02 0.06 0.03
1 3 0.08 0.24 0.025
2 3 0.06 0.25 0.02
2 4 0.06 0.18 0.02
2 5 0.04 0.12 0.015
3 4 0.01 0.03 0.01
4 5 0.08 0.24 0.025];

Formation of Y matrix from the given data

b1 = tldata(:,1); %starting bus


b2 = tldata(:,2); %ending bus
R = tldata(:,3); %resistance between lines
X = tldata(:,4); %impedance between lines
j = sqrt(-1);
B = j*tldata(:,5); %susceptance
n = length(b1);
bus = max(max(b1),max(b2)); %number of bus
Z = R + j*X; %Impedance Matrix
y = ones(n,1)./Z ; %admittance

Ymat = zeros(bus,bus);
%Finding OFF DIAGONAl elements
for m = 1:n
Ymat(b1(m),b2(m)) = Ymat(b1(m),b2(m)) - y(m);
Ymat(b2(m),b1(m)) = Ymat(b1(m),b2(m));
end
file:///G:/Anonno/MIST Documents/L3, T1/EECE 306/loadflowfinal_kad.html 1/5
6/24/23, 7:51 AM loadflowfinal_kad
%Finding the diagonal elements
for m=1:bus
for k=1:n
if b1(k)== m
Ymat(m,m) = Ymat(m,m)+y(k)+ B(k);
elseif b2(k)== m
Ymat(m,m)= Ymat(m,m)+y(k)+ B(k);
else
end
end
end
Ymat

Ymat =

Columns 1 through 4

6.2500 -18.6950i -5.0000 +15.0000i -1.2500 + 3.7500i 0.0000 + 0.0000i


-5.0000 +15.0000i 10.0744 -31.1971i -0.9077 + 3.7821i -1.6667 + 5.0000i
-1.2500 + 3.7500i -0.9077 + 3.7821i 12.1577 -37.4771i -10.0000 +30.0000i
0.0000 + 0.0000i -1.6667 + 5.0000i -10.0000 +30.0000i 12.9167 -38.6950i
0.0000 + 0.0000i -2.5000 + 7.5000i 0.0000 + 0.0000i -1.2500 + 3.7500i

Column 5

0.0000 + 0.0000i
-2.5000 + 7.5000i
0.0000 + 0.0000i
-1.2500 + 3.7500i
3.7500 -11.2100i

Solution using Gauss-Seidel Method


Given Base = 100MVA

base=100;
VB = bus_data(:,2); %Bus Voltage in p.u.
PB = bus_data(:,3); %Bus Phase
P = bus_data(:,4); %Real Power of Bus
Q = bus_data(:,5); %Reactive Power of Bus
bus_n = length(bus_data(:,1));
VR = zeros(bus_n,1); %Resultant Voltage
VR = VB;

V_NEW= VR;
for jk= 1:200
for i=2:bus_n
SUM=0;
for j=1:bus_n
if i~=j
SUM= SUM+Ymat(i,j)*V_NEW(j);
end
end
VR(i) = (((((P(i)-1j*Q(i)))/base)/conj(V_NEW(i)))-SUM)/Ymat(i,i);

file:///G:/Anonno/MIST Documents/L3, T1/EECE 306/loadflowfinal_kad.html 2/5


6/24/23, 7:51 AM loadflowfinal_kad
V_NEW(i) = VR(i);
end
end
V_NEW
VR = V_NEW

imaginary_part = zeros(bus_n,1);
for ph=1:bus_n
imaginary_part(ph,1)= imag(VR(ph,1));
end
real_part = zeros(bus_n,1);
for re = 1:bus_n
real_part(re,1) = real(VR(re,1));
end

V_NEW =

1.0600 + 0.0000i
1.0464 - 0.0503i
1.0187 - 0.0929i
1.0179 - 0.0978i
1.0118 - 0.1093i

VR =

1.0600 + 0.0000i
1.0464 - 0.0503i
1.0187 - 0.0929i
1.0179 - 0.0978i
1.0118 - 0.1093i

Calculation of voltage and phase angle of slack, generator and load buses

theta= zeros(bus_n,1);
for th =1:bus_n

theta(th,1) = atand(imaginary_part(th,1)/real_part(th,1));

end
fprintf('The column matrix containg Voltage Magnitude:')
magg = abs(VR);
magg
fprintf('The column matrix containg Phase:')
theta

for print=1:bus_n
fprintf('The voltage of BUS %d is %f \n ',print,magg(print,1))
end
fprintf('\n \n \n')
for print=1:bus_n
fprintf('The phase of BUS %d is %f \n ',print,theta(print,1))
end
fprintf('\n \n \n')

file:///G:/Anonno/MIST Documents/L3, T1/EECE 306/loadflowfinal_kad.html 3/5


6/24/23, 7:51 AM loadflowfinal_kad

The column matrix containg Voltage Magnitude:


magg =

1.0600
1.0476
1.0229
1.0225
1.0176

The column matrix containg Phase:


theta =

0
-2.7529
-5.2086
-5.4879
-6.1672

The voltage of BUS 1 is 1.060000


The voltage of BUS 2 is 1.047578
The voltage of BUS 3 is 1.022892
The voltage of BUS 4 is 1.022541
The voltage of BUS 5 is 1.017641

The phase of BUS 1 is 0.000000


The phase of BUS 2 is -2.752888
The phase of BUS 3 is -5.208649
The phase of BUS 4 is -5.487914
The phase of BUS 5 is -6.167155

Calculation of real and reactive power of Slack Bus

S=0;
slack=1;
SUM=0;
for j=2:bus_n
SUM=SUM+Ymat(slack,j)*VR(j,1);
end
S=VR(slack,1)*(VR(slack,1)*Ymat(slack,slack)+SUM);
S;
P_slack= real(S)*100;
fprintf('Real power of slack bus is P= %d \n' ,P_slack)
Q_slack = imag(S)*100;
fprintf('Reactive power of slack bus is Q= %d \n' ,Q_slack)

Real power of slack bus is P= 1.296117e+02


Reactive power of slack bus is Q= 7.047667e+00

file:///G:/Anonno/MIST Documents/L3, T1/EECE 306/loadflowfinal_kad.html 4/5

You might also like