Power Flow Program Using Matlab
Power Flow Program Using Matlab
Semester-07
− ( 400+ j250 )
Ssch
2 = =−4.0− j2.5 pu … … … … … … … … …(1)
100
200
Psch
3 = =2.0 pu … … … … … … … … …(2)
100
The slack bus voltage V1=1.05∠ 0 pu, and the bus3 voltage magnitude is |V 3|=1.04 pu .
Starting with initial estimate|V (0)
2 |=1.0 pu δ 2 ¿ 0.0
, (0) and δ (0)
3 =0.0,
% Type....
% 1 - Slack Bus..
% 2 - PV Bus..
% 3 - PQ Bus..
% |Bus| Type| Vsp| delta| PGi | QGi | PLi | QLi | Qmin | Qmax|
busdat3 = [1 1 1.05 0 0 0 0 0 0 0;
2 3 1.0 0 0 0 400 250 0 0;
3 2 1.04 0 200 0 0 0 -1000 +1000;];
busdt = busdat3;
C) Program to for Admittance And Impedance Bus Formation....
function YB = Admittance_Formation() % Returns Y
E) Program for Bus Power Injections, Line & Power flows (p.u)...
function [Pi Qi Pg Qg Pl Ql] = loadflow(nb,V,del,BMva)
Iij = zeros(nb,nb);
Sij = zeros(nb,nb);
Si = zeros(nb,1);
% 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);
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('#####################################################################################');
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
Continued…
% 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 a = 1:nbus
J1(i,k) = J1(i,k) + V(m)* V(a)*(-G(m,a)*sin(del(m)-
del(a)) + B(m,a)*cos(del(m)-del(a)));
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
Continued…
% 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;
Output:
>> Main_Program
Y =
The following power network which is being made available to the electrical utility industry
as a standard test case for evaluating various analytical methods and computer program.
Here Bus-1 is taken as the slack bus with its voltage adjusted to 1.06∠ 0 ° pu.
The data for the voltage controlled buses is: