0% found this document useful (0 votes)
472 views14 pages

Ieee 14 Bus System Load Flow Using N

This document describes performing a load flow analysis of the IEEE 14 bus system using the Newton-Raphson method. It defines key parameters of the system such as the bus data, line data, and Y-bus matrix. It then outlines the load flow calculation process which involves initializing bus voltages and angles, calculating mismatch values, constructing the Jacobian matrix, and iterating to converge on a solution within a specified tolerance. Upon convergence, it outputs the results of the load flow analysis.

Uploaded by

Radak Rudu
Copyright
© © All Rights Reserved
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)
472 views14 pages

Ieee 14 Bus System Load Flow Using N

This document describes performing a load flow analysis of the IEEE 14 bus system using the Newton-Raphson method. It defines key parameters of the system such as the bus data, line data, and Y-bus matrix. It then outlines the load flow calculation process which involves initializing bus voltages and angles, calculating mismatch values, constructing the Jacobian matrix, and iterating to converge on a solution within a specified tolerance. Upon convergence, it outputs the results of the load flow analysis.

Uploaded by

Radak Rudu
Copyright
© © All Rights Reserved
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/ 14

IEEE 14 BUS SYSTEM LOAD FLOW USING N-R METHOD

% Program for Newton-Raphson Load Flow Analysis..

nbus = 14; % IEEE-14


Y = ybusppg(nbus); % Calling ybusppg.m to get Y-Bus Matrix..
busd = busdatas(nbus); % Calling busdatas..
BMva = 100; % Base MVA..
bus = busd(:,1); % Bus Number..
type = busd(:,2); % Type of Bus 1-Slack, 2-PV, 3-PQ..
V = busd(:,3); % Specified Voltage..
del = busd(:,4); % Voltage Angle..
Pg = busd(:,5)/BMva; % PGi..
Qg = busd(:,6)/BMva; % QGi..
Pl = busd(:,7)/BMva; % PLi..
Ql = busd(:,8)/BMva; % QLi..
Qmin = busd(:,9)/BMva; % Minimum Reactive Power Limit..
Qmax = busd(:,10)/BMva; % Maximum Reactive Power Limit..
P = Pg - Pl; % Pi = PGi - PLi..
Q = Qg - Ql; % Qi = QGi - QLi..
Psp = P; % P Specified..
Qsp = Q; % Q Specified..
G = real(Y); % Conductance matrix..
B = imag(Y); % Susceptance matrix..

pv = find(type == 2 | type == 1); % PV Buses..


pq = find(type == 3); % PQ Buses..
npv = length(pv); % No. of PV buses..
npq = length(pq); % No. of PQ buses..

Tol = 1;
Iter = 1;
while (Tol > 1e-5) % Iteration starting..

P = zeros(nbus,1);
Q = zeros(nbus,1);
% Calculate P and Q
for i = 1:nbus
for k = 1:nbus
P(i) = P(i) + V(i)* V(k)*(G(i,k)*cos(del(i)-del(k)) +
B(i,k)*sin(del(i)-del(k)));
Q(i) = Q(i) + V(i)* V(k)*(G(i,k)*sin(del(i)-del(k)) -
B(i,k)*cos(del(i)-del(k)));
end
end

% Checking Q-limit violations..


if Iter <= 7 && Iter > 2 % Only checked up to 7th iterations..
for n = 2:nbus
if type(n) == 2
QG = Q(n)+Ql(n);
if QG < Qmin(n)
V(n) = V(n) + 0.01;
elseif QG > Qmax(n)
V(n) = V(n) - 0.01;
end
end
end
end

% Calculate change from specified value


dPa = Psp-P;
dQa = Qsp-Q;
k = 1;
dQ = zeros(npq,1);
for i = 1:nbus
if type(i) == 3
dQ(k,1) = dQa(i);
k = k+1;
end
end
dP = dPa(2:nbus);
M = [dP; dQ]; % Mismatch Vector

% Jacobian
% J1 - Derivative of Real Power Injections with Angles..
J1 = zeros(nbus-1,nbus-1);
for i = 1:(nbus-1)
m = i+1;
for k = 1:(nbus-1)
n = k+1;
if n == m
for n = 1:nbus
J1(i,k) = J1(i,k) + V(m)* V(n)*(-G(m,n)*sin(del(m)-
del(n)) + B(m,n)*cos(del(m)-del(n)));
end
J1(i,k) = J1(i,k) - V(m)^2*B(m,m);
else
J1(i,k) = V(m)* V(n)*(G(m,n)*sin(del(m)-del(n)) -
B(m,n)*cos(del(m)-del(n)));
end
end
end

% J2 - Derivative of Real Power Injections with V..


J2 = zeros(nbus-1,npq);
for i = 1:(nbus-1)
m = i+1;
for k = 1:npq
n = pq(k);
if n == m
for n = 1:nbus
J2(i,k) = J2(i,k) + V(n)*(G(m,n)*cos(del(m)-del(n)) +
B(m,n)*sin(del(m)-del(n)));
end
J2(i,k) = J2(i,k) + V(m)*G(m,m);
else
J2(i,k) = V(m)*(G(m,n)*cos(del(m)-del(n)) +
B(m,n)*sin(del(m)-del(n)));
end
end
end

% J3 - Derivative of Reactive Power Injections with Angles..


J3 = zeros(npq,nbus-1);
for i = 1:npq
m = pq(i);
for k = 1:(nbus-1)
n = k+1;
if n == m
for n = 1:nbus
J3(i,k) = J3(i,k) + V(m)* V(n)*(G(m,n)*cos(del(m)-del(n))
+ B(m,n)*sin(del(m)-del(n)));
end
J3(i,k) = J3(i,k) - V(m)^2*G(m,m);
else
J3(i,k) = V(m)* V(n)*(-G(m,n)*cos(del(m)-del(n)) -
B(m,n)*sin(del(m)-del(n)));
end
end
end

% J4 - Derivative of Reactive Power Injections with V..


J4 = zeros(npq,npq);
for i = 1:npq
m = pq(i);
for k = 1:npq
n = pq(k);
if n == m
for n = 1:nbus
J4(i,k) = J4(i,k) + V(n)*(G(m,n)*sin(del(m)-del(n)) -
B(m,n)*cos(del(m)-del(n)));
end
J4(i,k) = J4(i,k) - V(m)*B(m,m);
else
J4(i,k) = V(m)*(G(m,n)*sin(del(m)-del(n)) -
B(m,n)*cos(del(m)-del(n)));
end
end
end

J = [J1 J2; J3 J4]; % Jacobian Matrix..

X = inv(J)*M; % Correction Vector


dTh = X(1:nbus-1); % Change in Voltage Angle..
dV = X(nbus:end); % Change in Voltage Magnitude..

% Updating State Vectors..


del(2:nbus) = dTh + del(2:nbus); % Voltage Angle..
k = 1;
for i = 2:nbus
if type(i) == 3
V(i) = dV(k) + V(i); % Voltage Magnitude..
k = k+1;
end
end

Iter = Iter + 1;
Tol = max(abs(M)); % Tolerance..

end
loadflow(nbus,V,del,BMva); % Calling Loadflow.m..

% Returns Initial Bus datas of the system...


function busdt = busdatas(num)
% Type.... % 1 - Slack Bus..% 2 - PV Bus..% 3 - PQ Bus..
% |Bus | Type | Vsp | theta | PGi | QGi | PLi | QLi | Qmin | Qmax |
busdat14 = [1 1 1.060 0 0 0 0 0 0 0;
2 2 1.045 0 40 42.4 21.7 12.7 -40 50;
3 2 1.010 0 0 23.4 94.2 19.0 0 40;
4 3 1.0 0 0 0 47.8 -3.9 0 0;
5 3 1.0 0 0 0 7.6 1.6 0 0;
6 2 1.070 0 0 12.2 11.2 7.5 -6 24;
7 3 1.0 0 0 0 0.0 0.0 0 0;
8 2 1.090 0 0 17.4 0.0 0.0 -6 24;
9 3 1.0 0 0 0 29.5 16.6 0 0;
10 3 1.0 0 0 0 9.0 5.8 0 0;
11 3 1.0 0 0 0 3.5 1.8 0 0;
12 3 1.0 0 0 0 6.1 1.6 0 0;
13 3 1.0 0 0 0 13.5 5.8 0 0;
14 3 1.0 0 0 0 14.9 5.0 0 0;];

% Returns Line datas of the system...

function linedt = linedatas(num)

% | From | To | R | X | B/2 | X'mer |


% | Bus | Bus | pu | pu | pu | TAP (a) |
linedat14 = [1 2 0.01938 0.05917 0.0264 1
1 5 0.05403 0.22304 0.0246 1
2 3 0.04699 0.19797 0.0219 1
2 4 0.05811 0.17632 0.0170 1
2 5 0.05695 0.17388 0.0173 1
3 4 0.06701 0.17103 0.0064 1
4 5 0.01335 0.04211 0.0 1
4 7 0.0 0.20912 0.0 0.978
4 9 0.0 0.55618 0.0 0.969
5 6 0.0 0.25202 0.0 0.932
6 11 0.09498 0.19890 0.0 1
6 12 0.12291 0.25581 0.0 1
6 13 0.06615 0.13027 0.0 1
7 8 0.0 0.17615 0.0 1
7 9 0.0 0.11001 0.0 1
9 10 0.03181 0.08450 0.0 1
9 14 0.12711 0.27038 0.0 1
10 11 0.08205 0.19207 0.0 1
12 13 0.22092 0.19988 0.0 1
13 14 0.17093 0.34802 0.0 1 ];

%%%% Program for Bus Power Injections, Line & Power flows (p.u)...
function [Pi Qi Pg Qg Pl Ql] = loadflow(nb,V,del,BMva)

Y = ybusppg(nb); % Calling Ybus program..


lined = linedatas(nb); % Get linedats..
busd = busdatas(nb); % Get busdatas..
Vm = pol2rect(V,del); % Converting polar to rectangular..
Del = 180/pi*del; % Bus Voltage Angles in Degree...
fb = lined(:,1); % From bus number...
tb = lined(:,2); % To bus number...
nl = length(fb); % No. of Branches..
Pl = busd(:,7); % PLi..
Ql = busd(:,8); % QLi..

Iij = zeros(nb,nb);
Sij = zeros(nb,nb);
Si = zeros(nb,1);

% Bus Current Injections..


I = Y*Vm;
Im = abs(I);
Ia = angle(I);

%Line Current Flows..


for m = 1:nl
p = fb(m); q = tb(m);
Iij(p,q) = -(Vm(p) - Vm(q))*Y(p,q); % Y(m,n) = -y(m,n)..
Iij(q,p) = -Iij(p,q);
end
Iij = sparse(Iij);
Iijm = abs(Iij);
Iija = angle(Iij);

% Line Power Flows..


for m = 1:nb
for n = 1:nb
if m ~= n
Sij(m,n) = Vm(m)*conj(Iij(m,n))*BMva;
end
end
end
Sij = sparse(Sij);
Pij = real(Sij);
Qij = imag(Sij);

% Line Losses..
Lij = zeros(nl,1);
for m = 1:nl
p = fb(m); q = tb(m);
Lij(m) = Sij(p,q) + Sij(q,p);
end
Lpij = real(Lij);
Lqij = imag(Lij);

% Bus Power Injections..


for i = 1:nb
for k = 1:nb
Si(i) = Si(i) + conj(Vm(i))* Vm(k)*Y(i,k)*BMva;
end
end
Pi = real(Si);
Qi = -imag(Si);
Pg = Pi+Pl;
Qg = Qi+Ql;

disp('#######################################################################
##################');
disp('-----------------------------------------------------------------------
------------------');
disp(' Newton Raphson Loadflow Analysis ');
disp('-----------------------------------------------------------------------
------------------');
disp('| Bus | V | Angle | Injection | Generation |
Load |');
disp('| No | pu | Degree | MW | MVar | MW | Mvar |
MW | MVar | ');
for m = 1:nb
disp('-------------------------------------------------------------------
----------------------');
fprintf('%3g', m); fprintf(' %8.4f', V(m)); fprintf(' %8.4f', Del(m));
fprintf(' %8.3f', Pi(m)); fprintf(' %8.3f', Qi(m));
fprintf(' %8.3f', Pg(m)); fprintf(' %8.3f', Qg(m));
fprintf(' %8.3f', Pl(m)); fprintf(' %8.3f', Ql(m)); fprintf('\n');
end
disp('-----------------------------------------------------------------------
------------------');
fprintf(' Total ');fprintf(' %8.3f', sum(Pi)); fprintf('
%8.3f', sum(Qi));
fprintf(' %8.3f', sum(Pi+Pl)); fprintf(' %8.3f', sum(Qi+Ql));
fprintf(' %8.3f', sum(Pl)); fprintf(' %8.3f', sum(Ql)); fprintf('\n');
disp('-----------------------------------------------------------------------
------------------');
disp('#######################################################################
##################');

disp('-----------------------------------------------------------------------
--------------');
disp(' Line FLow and Losses ');
disp('-----------------------------------------------------------------------
--------------');
disp('|From|To | P | Q | From| To | P | Q |
Line Loss |');
disp('|Bus |Bus| MW | MVar | Bus | Bus| MW | MVar | MW
| MVar |');
for m = 1:nl
p = fb(m); q = tb(m);
disp('-------------------------------------------------------------------
------------------');
fprintf('%4g', p); fprintf('%4g', q); fprintf(' %8.3f', Pij(p,q));
fprintf(' %8.3f', Qij(p,q));
fprintf(' %4g', q); fprintf('%4g', p); fprintf(' %8.3f', Pij(q,p));
fprintf(' %8.3f', Qij(q,p));
fprintf(' %8.3f', Lpij(m)); fprintf(' %8.3f', Lqij(m));
fprintf('\n');
end
disp('-----------------------------------------------------------------------
--------------');
fprintf(' Total Loss ');
fprintf(' %8.3f', sum(Lpij)); fprintf(' %8.3f', sum(Lqij));
fprintf('\n');
disp('-----------------------------------------------------------------------
--------------');
disp('#######################################################################
##############');

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

function Y = ybusppg(num) % Returns Y

linedata = linedatas(num); % Calling Linedatas...


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...
a = linedata(:,6); % Tap setting value..
z = r + i*x; % z matrix...
y = 1./z; % To get inverse of each element...
b = i*b; % Make B imaginary...

nb = max(max(fb),max(tb)); % No. of buses...


nl = length(fb); % No. of branches...
Y = zeros(nb,nb); % Initialise YBus...

% Formation of the Off Diagonal Elements...


for k = 1:nl
Y(fb(k),tb(k)) = Y(fb(k),tb(k)) - y(k)/a(k);
Y(tb(k),fb(k)) = Y(fb(k),tb(k));
end

% Formation of Diagonal Elements....


for m = 1:nb
for n = 1:nl
if fb(n) == m
Y(m,m) = Y(m,m) + y(n)/(a(n)^2) + b(n);
elseif tb(n) == m
Y(m,m) = Y(m,m) + y(n) + b(n);
end
end
end
%Y; % Bus Admittance Matrix
%Z = inv(Y); % Bus Impedance Matrix

% Polar to Rectangular Conversion


% [RECT] = RECT2POL(RHO, THETA)
% RECT - Complex matrix or number, RECT = A + jB, A = Real, B = Imaginary
% RHO - Magnitude
% THETA - Angle in radians

function rect = pol2rect(rho,theta)


rect = rho.*cos(theta) + j*rho.*sin(theta);

OUTPUT:-

################################################################
#########################
----------------------------------------------------------------
-------------------------
Newton Raphson Loadflow Analysis
----------------------------------------------------------------
-------------------------
| Bus | V | Angle | Injection | Generation
| Load |
| No | pu | Degree | MW | MVar | MW | Mvar
| MW | MVar |
----------------------------------------------------------------
-------------------------
1 1.0600 0.0000 232.593 -15.233 232.593 -
15.233 0.000 0.000
----------------------------------------------------------------
-------------------------
2 1.0450 -4.9891 18.300 35.228 40.000
47.928 21.700 12.700
----------------------------------------------------------------
-------------------------
3 1.0100 -12.7492 -94.200 8.758 0.000
27.758 94.200 19.000
----------------------------------------------------------------
-------------------------
4 1.0132 -10.2420 -47.800 3.900 0.000 -
0.000 47.800 -3.900
----------------------------------------------------------------
-------------------------
5 1.0166 -8.7601 -7.600 -1.600 -0.000 -
0.000 7.600 1.600
----------------------------------------------------------------
-------------------------
6 1.0700 -14.4469 -11.200 15.526 -0.000
23.026 11.200 7.500
----------------------------------------------------------------
-------------------------
7 1.0457 -13.2368 -0.000 0.000 -0.000
0.000 0.000 0.000
----------------------------------------------------------------
-------------------------
8 1.0800 -13.2368 0.000 21.030 0.000
21.030 0.000 0.000
----------------------------------------------------------------
-------------------------
9 1.0305 -14.8201 -29.500 -16.600 0.000 -
0.000 29.500 16.600
----------------------------------------------------------------
-------------------------
10 1.0299 -15.0360 -9.000 -5.800 -0.000
0.000 9.000 5.800
----------------------------------------------------------------
-------------------------
11 1.0461 -14.8581 -3.500 -1.800 0.000
0.000 3.500 1.800
----------------------------------------------------------------
-------------------------
12 1.0533 -15.2973 -6.100 -1.600 0.000
0.000 6.100 1.600
----------------------------------------------------------------
-------------------------
13 1.0466 -15.3313 -13.500 -5.800 0.000
0.000 13.500 5.800
----------------------------------------------------------------
-------------------------
14 1.0193 -16.0717 -14.900 -5.000 -0.000
0.000 14.900 5.000
----------------------------------------------------------------
-------------------------
Total 13.593 31.009 272.593
104.509 259.000 73.500
----------------------------------------------------------------
-------------------------

################################################################
#########################
----------------------------------------------------------------
---------------------
Line FLow and Losses
----------------------------------------------------------------
---------------------
|From|To | P | Q | From| To | P | Q |
Line Loss |
|Bus |Bus| MW | MVar | Bus | Bus| MW | MVar |
MW | MVar |
----------------------------------------------------------------
---------------------
1 2 157.080 -17.484 2 1 -152.772 30.639
4.309 13.155
----------------------------------------------------------------
---------------------
1 5 75.513 7.981 5 1 -72.740 3.464
2.773 11.445
----------------------------------------------------------------
---------------------
2 3 73.396 5.936 3 2 -71.063 3.894
2.333 9.830
----------------------------------------------------------------
---------------------
2 4 55.943 2.935 4 2 -54.273 2.132
1.670 5.067
----------------------------------------------------------------
---------------------
2 5 41.733 4.738 5 2 -40.813 -1.929
0.920 2.809
----------------------------------------------------------------
---------------------
3 4 -23.137 7.752 4 3 23.528 -6.753
0.391 0.998
----------------------------------------------------------------
---------------------
4 5 -59.585 11.574 5 4 60.064 -10.063
0.479 1.511
----------------------------------------------------------------
---------------------
4 7 27.066 -15.396 7 4 -27.066 17.327
0.000 1.932
----------------------------------------------------------------
---------------------
4 9 15.464 -2.640 9 4 -15.464 3.932
-0.000 1.292
----------------------------------------------------------------
---------------------
5 6 45.889 -20.843 6 5 -45.889 26.617
0.000 5.774
----------------------------------------------------------------
---------------------
6 11 8.287 8.898 11 6 -8.165 -8.641
0.123 0.257
----------------------------------------------------------------
---------------------
6 12 8.064 3.176 12 6 -7.984 -3.008
0.081 0.168
----------------------------------------------------------------
---------------------
6 13 18.337 9.981 13 6 -18.085 -9.485
0.252 0.496
----------------------------------------------------------------
---------------------
7 8 -0.000 -20.362 8 7 0.000 21.030
0.000 0.668
----------------------------------------------------------------
---------------------
7 9 27.066 14.798 9 7 -27.066 -13.840
-0.000 0.957
----------------------------------------------------------------
---------------------
9 10 4.393 -0.904 10 9 -4.387 0.920
0.006 0.016
----------------------------------------------------------------
---------------------
9 14 8.637 0.321 14 9 -8.547 -0.131
0.089 0.190
----------------------------------------------------------------
---------------------
10 11 -4.613 -6.720 11 10 4.665 6.841
0.051 0.120
----------------------------------------------------------------
---------------------
12 13 1.884 1.408 13 12 -1.873 -1.398
0.011 0.010
----------------------------------------------------------------
---------------------
13 14 6.458 5.083 14 13 -6.353 -4.869
0.105 0.215
----------------------------------------------------------------
---------------------
Total Loss
13.593 56.910
----------------------------------------------------------------
---------------------
################################################################
#####################

DC LOAD FLOW SOLUTION:


For each bus,

MATLAB CODE:
clear all;
clc;
tstart=cputime;
disp([' '])
disp(['*****DC Power Flow Solution - 3 Bus system*****'])

Nbus=3;Nele=3;
%line data
Edata=[1 1 2 10i;
2 2 3 5i;
3 1 3 10i];
%bus data bus 3 as slack
Bdata=[1 0 2000;
2 0 1000;
3 3000 0];
% Formation of Ybus matrix
Ybus = zeros(Nbus,Nbus);
for k = 1:Nele
p = Edata(k,2);
q = Edata(k,3);
yele = 1/Edata(k,4);
Ybus(p,p) = Ybus(p,p) + yele ;
Ybus(q,q) = Ybus(q,q) + yele;
Ybus(p,q) = Ybus(p,q) - yele;
Ybus(q,p) = Ybus(q,p) - yele;
end

Ybus
%%basemva=100;
ref_bus=3;
B1=imag(Ybus)
B=B1;
B(ref_bus,:)=[];
B(:,ref_bus)=[];
BB=-B
delPbus=((Bdata(:, 3)) - (Bdata(:, 2)));
delPbus(ref_bus,:)=[];
delPbus
theta=inv(BB)*delPbus
theta(ref_bus,1)=0;
theta
for i=1:Nbus
for j=1:Nbus
P(i,j)=(theta(i)-theta(j))*B1(i,j);
end
end
P
disp('Line Flows');
for i=1:Nbus
for j=1:Nbus
if (i~=j && i<j)
P(i,j);
X = sprintf('P%d%d %d.',i,j,P(i,j));
disp(X);
end
end
end

OUTPUT:

*****DC Power Flow Solution - 3 Bus system*****

Ybus =

0 - 0.2000i 0 + 0.1000i 0 + 0.1000i


0 + 0.1000i 0 - 0.3000i 0 + 0.2000i
0 + 0.1000i 0 + 0.2000i 0 - 0.3000i

B1 =

-0.2000 0.1000 0.1000


0.1000 -0.3000 0.2000
0.1000 0.2000 -0.3000

BB =

0.2000 -0.1000
-0.1000 0.3000

delPbus =

2000
1000

theta =

1.0e+004 *
1.4000
0.8000

theta =

1.0e+004 *

1.4000
0.8000
0

P =

1.0e+003 *

0 0.6000 1.4000
-0.6000 0 1.6000
-1.4000 -1.6000 0

Line Flows
P12 6.000000e+002.
P13 1400.
P23 1.600000e+003.

You might also like