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

Matlab Programs For Psa All Experiments

Uploaded by

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

Matlab Programs For Psa All Experiments

Uploaded by

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

FORMATION OF BUS ADMITTANCE & IMPEDANCE MATRIX

Expt. No.:
Date:

AIM:

To develop a program to obtain a bus admittance matrix for a given power system
network

ALGORITHM:

1. Initialize [Y BUS ] matrix , that is replace all entries by zeroes.


Yij= - Yij

2.

3. Print the results.

Flow chart

1
Program
linedata =[ 1 2 0.0185 0.0789 0.0286 1
1 3 0.0852 0.1852 0.0264 1
2 4 0.0789 0.1738 0.0176 1
3 4 0.0152 0.0389 0.0052 1
];

j=sqrt(-1); i=sqrt(-1);
nl=linedata(:,1);nr=linedata(:,2);R=linedata(:,3);
X=linedata(:,4);Bc=j*linedata(:,5);a=linedata(:,6);
nbr=length(linedata(:,1));nbus=max(max(nl),max(nr));
Z=R+j*X;y=ones(nbr,1)./Z;
for n=1:nbr
if a(n)<=0 a(n)=1;else end
Ybus=zeros(nbus,nbus);
for k=1:nbr
Ybus(nl(k),nr(k))=Ybus(nl(k),nr(k))-y(k)/a(k);

Ybus(nr(k))=Ybus(nl(k),nr(k));
end
end

for n=1:nbus
for k=1:nbr
if nl(k)==n
Ybus(n,n)=Ybus(n,n)+y(k)/(a(k)^2)+Bc(k);
elseif nr(k)==n
Ybus(n,n)=Ybus(n,n)+y(k)+Bc(k);
else end
end
end
Ybus
Zbus=inv(Ybus);
Zbus
VIVA QUESTIONS:

1. What are the methods to form Y Bus


2. Give the applications of Y Bus
3. Give the applications of Z Bus
4. Define Y Bus and Z Bus
5. Compare Y Bus and Z Bus

RESULT :

The bus admittance matrix is obtained for a given power system network.

2
LOAD FLOW ANALYSIS BY
GAUSS - SIEDEL ITERATIVE TECHNIQUE

Expt. No.:
Date:

AIM:

To carry out load flow analysis on the given power system network by GausSeidel
Method.

ALGORITHM:
1. Read line data, specified powers, specified voltages, reactive power limits,
number of buses, number of lines and tolerance for convergence.
2. Compute [ Y BUS] matrix.
3. Initialise all the bus voltages.
4. Set iteration = 1.
5. Consider bus number is equal to 2.
6. Check whether this is P – V bus or P – Q bus. If it is P – Q bus go to step ( 8 ).
Otherwise go to next step.
7. Compute Q and check for Q – limit violation.

8. Calculate the new value of the bus voltage using Gauss formula

If Q of the lines are not violated then adjust voltage magnitude of the bus to the specified
magnitude.
9. If all the buses are considered, go to ( 11 ), otherwise, increment the bus number i= i +1 and
go to ( 6 ).
10. Check for convergence. If convergence is not obtained go to( 11 ). otherwise, go to ( 12 ).
11. Update the bus voltages using the formula,

Increment the iteration count, ITER = ITER + 1 and go to step ( 5 )


12. . Calculate slack bus power, Q at P – V buses, real and reactive line flows, real and reactive
line losses.
13. Print all the results including all the complex bus voltages and all the bus angles.
14. STOP
Flow chart:

3
4
5
6
Program

% GAUSS SEIDEL:-

clear
basemva = 100; accuracy = 0.001; maxiter = 100;
% Bus Bus Voltage Angle ---Load---- -------Generator----- Static
Mvar
% No code Mag. Degree MW Mvar MW Mvar Qmin Qmax +Qc/-Ql
busdata=[1 1 1.05 0 0 0 0 0 -50 100 0
2 2 1.05 0 0 0 50 0 -25 50 0
3 0 1.0 0 55 13 0 0 0 0 0
4 0 1.0 0 0 0 0 0 0 0 5
5 0 1.0 0 30 18 0 0 0 0 0
6 0 1.0 0 50 5 0 0 0 0 5.5];

% Line code
% Bus bus R X 1/2 B = 1 for lines
% nl nr p.u. p.u. p.u. > 1 or < 1 tr. tap at bus nl
linedata=[1 6 0.123 0.518 0.0 1.0
1 4 0.080 0.370 0.0 1.0
4 6 0.087 0.407 0.0 1.0
5 2 0.282 0.640 0.0 1.0
2 3 0.723 1.050 0.0 1.0
6 5 0.0 0.300 0.0 0.956
4 3 0.0 0.133 0.0 0.981];

% This program obtains th Bus Admittance Matrix for power flow solution
% Copyright (c) 1998 by H. Saadat
j=sqrt(-1); i = sqrt(-1);
nl = linedata(:,1); nr = linedata(:,2); R = linedata(:,3);
X = linedata(:,4); Bc = j*linedata(:,5); a = linedata(:, 6);
nbr=length(linedata(:,1)); nbus = max(max(nl), max(nr));
Z = R + j*X; y= ones(nbr,1)./Z; %branch admittance
for n = 1:nbr
if a(n) <= 0 a(n) = 1; else end
Ybus=zeros(nbus,nbus); % initialize Ybus to zero
% formation of the off diagonal elements
for k=1:nbr;
Ybus(nl(k),nr(k))=Ybus(nl(k),nr(k))-y(k)/a(k);
Ybus(nr(k),nl(k))=Ybus(nl(k),nr(k));
end
end
% formation of the diagonal elements
for n=1:nbus
for k=1:nbr
if nl(k)==n
Ybus(n,n) = Ybus(n,n)+y(k)/(a(k)^2) + Bc(k);
elseif nr(k)==n
Ybus(n,n) = Ybus(n,n)+y(k) +Bc(k);
else, end
end
end
clear Pgg
% Power flow solution by Gauss-Seidel method

7
% Copyright (c) 1998 by H. Saadat
Vm=0; delta=0; yload=0; deltad =0;
nbus = length(busdata(:,1));
for k=1:nbus
n=busdata(k,1);
kb(n)=busdata(k,2); Vm(n)=busdata(k,3); delta(n)=busdata(k, 4);
Pd(n)=busdata(k,5); Qd(n)=busdata(k,6); Pg(n)=busdata(k,7); Qg(n) =
busdata(k,8);
Qmin(n)=busdata(k, 9); Qmax(n)=busdata(k, 10);
Qsh(n)=busdata(k, 11);
if Vm(n) <= 0 Vm(n) = 1.0; V(n) = 1 + j*0;
else delta(n) = pi/180*delta(n);
V(n) = Vm(n)*(cos(delta(n)) + j*sin(delta(n)));
P(n)=(Pg(n)-Pd(n))/basemva;
Q(n)=(Qg(n)-Qd(n)+ Qsh(n))/basemva;
S(n) = P(n) + j*Q(n);
end
DV(n)=0;
end
num = 0; AcurBus = 0; converge = 1;
Vc = zeros(nbus,1)+j*zeros(nbus,1); Sc = zeros(nbus,1)+j*zeros(nbus,1);
while exist('accel')~=1
accel = 1.3;
end
while exist('accuracy')~=1
accuracy = 0.001;
end
while exist('basemva')~=1
basemva= 100;
end
while exist('maxiter')~=1
maxiter = 100;
end
iter=0;
maxerror=10;
while maxerror >= accuracy & iter <= maxiter
iter=iter+1;
for n = 1:nbus;
YV = 0+j*0;
for L = 1:nbr;
if nl(L) == n, k=nr(L);
YV = YV + Ybus(n,k)*V(k);
elseif nr(L) == n, k=nl(L);
YV = YV + Ybus(n,k)*V(k);
end
end
Sc = conj(V(n))*(Ybus(n,n)*V(n) + YV) ;
Sc = conj(Sc);
DP(n) = P(n) - real(Sc);
DQ(n) = Q(n) - imag(Sc);
if kb(n) == 1
S(n) =Sc; P(n) = real(Sc); Q(n) = imag(Sc); DP(n) =0; DQ(n)=0;
Vc(n) = V(n);
elseif kb(n) == 2
Q(n) = imag(Sc); S(n) = P(n) + j*Q(n);
if Qmax(n) ~= 0
Qgc = Q(n)*basemva + Qd(n) - Qsh(n);
if abs(DQ(n)) <= .005 & iter >= 10 % After 10 iterations

8
if DV(n) <= 0.045 % the Mvar of generator buses
are
if Qgc < Qmin(n), % tested. If not within limits
Vm(n)
Vm(n) = Vm(n) + 0.005; % is changed in steps of 0.005
pu
DV(n) = DV(n)+.005; % up to .05 pu in order to
bring
elseif Qgc > Qmax(n), % the generator Mvar within
the
Vm(n) = Vm(n) - 0.005; % specified limits.
DV(n)=DV(n)+.005; end
else, end
else,end
else,end
end
if kb(n) ~= 1
Vc(n) = (conj(S(n))/conj(V(n)) - YV )/ Ybus(n,n);
else, end
if kb(n) == 0
V(n) = V(n) + accel*(Vc(n)-V(n));
elseif kb(n) == 2
VcI = imag(Vc(n));
VcR = sqrt(Vm(n)^2 - VcI^2);
Vc(n) = VcR + j*VcI;
V(n) = V(n) + accel*(Vc(n) -V(n));
end
end
maxerror=max( max(abs(real(DP))), max(abs(imag(DQ))) );
if iter == maxiter & maxerror > accuracy
fprintf('\nWARNING: Iterative solution did not converged after ')
fprintf('%g', iter), fprintf(' iterations.\n\n')
fprintf('Press Enter to terminate the iterations and print the results \n')
converge = 0; pause, else, end
end
if converge ~= 1
tech= (' ITERATIVE SOLUTION DID NOT CONVERGE'); else,
tech=(' Power Flow Solution by Gauss-Seidel Method');
end
k=0;
for n = 1:nbus
Vm(n) = abs(V(n)); deltad(n) = angle(V(n))*180/pi;
if kb(n) == 1
S(n)=P(n)+j*Q(n);
Pg(n) = P(n)*basemva + Pd(n);
Qg(n) = Q(n)*basemva + Qd(n) - Qsh(n);
k=k+1;
Pgg(k)=Pg(n);
elseif kb(n) ==2
k=k+1;
Pgg(k)=Pg(n);
S(n)=P(n)+j*Q(n);
Qg(n) = Q(n)*basemva + Qd(n) - Qsh(n);
end
yload(n) = (Pd(n)- j*Qd(n)+j*Qsh(n))/(basemva*Vm(n)^2);
end
Pgt = sum(Pg); Qgt = sum(Qg); Pdt = sum(Pd); Qdt = sum(Qd); Qsht = sum(Qsh);
busdata(:,3)=Vm'; busdata(:,4)=deltad';
clear AcurBus DP DQ DV L Sc Vc VcI VcR YV converge delta

9
% This program prints the power flow solution in a tabulated form
% on the screen.
%
% Copyright (C) 1998 by H. Saadat.
%clc
disp(tech)
fprintf(' Maximum Power Mismatch = %g \n', maxerror)
fprintf(' No. of Iterations = %g \n\n', iter)
head =[' Bus Voltage Angle ------Load------ ---Generation---
Injected'
' No. Mag. Degree MW Mvar MW Mvar
Mvar '
'
'];
disp(head)
for n=1:nbus
fprintf(' %5g', n), fprintf(' %7.3f', Vm(n)),
fprintf(' %8.3f', deltad(n)), fprintf(' %9.3f', Pd(n)),
fprintf(' %9.3f', Qd(n)), fprintf(' %9.3f', Pg(n)),
fprintf(' %9.3f ', Qg(n)), fprintf(' %8.3f\n', Qsh(n))
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f', Pdt), fprintf(' %9.3f', Qdt),
fprintf(' %9.3f', Pgt), fprintf(' %9.3f', Qgt), fprintf(' %9.3f\n\n',
Qsht)

% This program is used in conjunction with lfgauss or lf Newton


% for the computation of line flow and line losses.
%
% Copyright (c) 1998 H. Saadat
SLT = 0;
fprintf('\n')
fprintf(' Line Flow and Losses \n\n')
fprintf(' --Line-- Power at bus & line flow --Line loss--
Transformer\n')
fprintf(' from to MW Mvar MVA MW Mvar tap\n')
for n = 1:nbus
busprt = 0;
for L = 1:nbr;
if busprt == 0
fprintf(' \n'), fprintf('%6g', n), fprintf(' %9.3f',
P(n)*basemva)
fprintf('%9.3f', Q(n)*basemva), fprintf('%9.3f\n', abs(S(n)*basemva))
busprt = 1;
else, end
if nl(L)==n k = nr(L);
In = (V(n) - a(L)*V(k))*y(L)/a(L)^2 + Bc(L)/a(L)^2*V(n);
Ik = (V(k) - V(n)/a(L))*y(L) + Bc(L)*V(k);
Snk = V(n)*conj(In)*basemva;
Skn = V(k)*conj(Ik)*basemva;
SL = Snk + Skn;
SLT = SLT + SL;
elseif nr(L)==n k = nl(L);
In = (V(n) - V(k)/a(L))*y(L) + Bc(L)*V(n);
Ik = (V(k) - a(L)*V(n))*y(L)/a(L)^2 + Bc(L)/a(L)^2*V(k);
Snk = V(n)*conj(In)*basemva;
Skn = V(k)*conj(Ik)*basemva;
SL = Snk + Skn;
SLT = SLT + SL;

10
else, end
if nl(L)==n | nr(L)==n
fprintf('%12g', k),
fprintf('%9.3f', real(Snk)), fprintf('%9.3f', imag(Snk))
fprintf('%9.3f', abs(Snk)),
fprintf('%9.3f', real(SL)),
if nl(L) ==n & a(L) ~= 1
fprintf('%9.3f', imag(SL)), fprintf('%9.3f\n', a(L))
else, fprintf('%9.3f\n', imag(SL))
end
else, end
end
end
SLT = SLT/2;
fprintf(' \n'), fprintf(' Total loss ')
fprintf('%9.3f', real(SLT)), fprintf('%9.3f\n', imag(SLT))
clear Ik In SL SLT Skn Snk

Viva Questions:
1. Define Acceleration Factor
2. Give the application of GS method
3. Write the formula to find slack bus power
4. Give the comparision of load flow analysis
5. Write the formula to find out the transmission line losses

RESULT:

The load flow analysis is done for the given power system network by Gauss - Seidel
Method.

LOAD FLOW ANALYSIS BY

11
NEWTON RAPHSON TECHNIQUE

Expt. No.:
Date:

AIM:

To carry out load flow analysis on the given power system network by Newton – Raphson
Method.

ALGORITHM:

1. Read line data, specified powers, specified voltages, reactive power limits,
number of buses, number of lines and tolerance for convergence.

2. Compute [ Y BUS] matrix.

3. Initialise all the bus voltages and angles

4. Calculate mismatch real powers [ ∆P ] of all buses except slack buses.

5. Calculate mismatch reactive powers [∆Q ] for all load buses.

6. If converged , go to ( 10 ).

7. Form the Jacobian matrix

8. Solve the equation for [∆ ] and [∆V] and update vectors [∆] and [∆ V ] .

9. Go to step ( 4 )

10. Calculate slack bus power, real and reactive line flows, real and reactive line losses.

11. Print all the results including all the complex bus voltages and all the bus angles.

12. STOP.

Flow chart
12
13
14
PROGRAM:
clear
basemva = 100; accuracy = 0.001; maxiter = 100;

% Bus Bus Voltage Angle ---Load---- -------Generator----- Static


Mvar
% No code Mag. Degree MW Mvar MW Mvar Qmin Qmax +Qc/-Ql
busdata=[1 1 1.05 0 0 0 0 0 -50 100 0
2 2 1.05 0 0 0 50 0 -25 50 0
3 0 1.0 0 55 13 0 0 0 0 0
4 0 1.0 0 0 0 0 0 0 0 5
5 0 1.0 0 30 18 0 0 0 0 0
6 0 1.0 0 50 5 0 0 0 0 5.5];

% Line code
% Bus bus R X 1/2 B = 1 for lines
% nl nr p.u. p.u. p.u. > 1 or < 1 tr. tap at bus nl
linedata=[1 6 0.123 0.518 0.0 1.0
1 4 0.080 0.370 0.0 1.0
4 6 0.087 0.407 0.0 1.0
5 2 0.282 0.640 0.0 1.0
2 3 0.723 1.050 0.0 1.0
6 5 0.0 0.300 0.0 0.956
4 3 0.0 0.133 0.0 0.981];

% This program obtains th Bus Admittance Matrix for power flow solution
% Copyright (c) 1998 by H. Saadat
j=sqrt(-1); i = sqrt(-1);
nl = linedata(:,1); nr = linedata(:,2); R = linedata(:,3);
X = linedata(:,4); Bc = j*linedata(:,5); a = linedata(:, 6);
nbr=length(linedata(:,1)); nbus = max(max(nl), max(nr));
Z = R + j*X; y= ones(nbr,1)./Z; %branch admittance
for n = 1:nbr
if a(n) <= 0 a(n) = 1; else end
Ybus=zeros(nbus,nbus); % initialize Ybus to zero
% formation of the off diagonal elements
for k=1:nbr;
Ybus(nl(k),nr(k))=Ybus(nl(k),nr(k))-y(k)/a(k);
Ybus(nr(k),nl(k))=Ybus(nl(k),nr(k));
end
end
% formation of the diagonal elements
for n=1:nbus
for k=1:nbr
if nl(k)==n
Ybus(n,n) = Ybus(n,n)+y(k)/(a(k)^2) + Bc(k);
elseif nr(k)==n
Ybus(n,n) = Ybus(n,n)+y(k) +Bc(k);
else, end
end
end
clear Pgg

% Power flow solution by Newton-Raphson method


% Copyright (c) 1998 by H. Saadat

15
ns=0; ng=0; Vm=0; delta=0; yload=0; deltad=0;
nbus = length(busdata(:,1));
for k=1:nbus
n=busdata(k,1);
kb(n)=busdata(k,2); Vm(n)=busdata(k,3); delta(n)=busdata(k, 4);
Pd(n)=busdata(k,5); Qd(n)=busdata(k,6); Pg(n)=busdata(k,7); Qg(n) =
busdata(k,8);
Qmin(n)=busdata(k, 9); Qmax(n)=busdata(k, 10);
Qsh(n)=busdata(k, 11);
if Vm(n) <= 0 Vm(n) = 1.0; V(n) = 1 + j*0;
else delta(n) = pi/180*delta(n);
V(n) = Vm(n)*(cos(delta(n)) + j*sin(delta(n)));
P(n)=(Pg(n)-Pd(n))/basemva;
Q(n)=(Qg(n)-Qd(n)+ Qsh(n))/basemva;
S(n) = P(n) + j*Q(n);
end
end
for k=1:nbus
if kb(k) == 1, ns = ns+1; else, end
if kb(k) == 2 ng = ng+1; else, end
ngs(k) = ng;
nss(k) = ns;
end
Ym=abs(Ybus); t = angle(Ybus);
m=2*nbus-ng-2*ns;
maxerror = 1; converge=1;
iter = 0;
% Start of iterations
clear A DC J DX
while maxerror >= accuracy & iter <= maxiter % Test for max. power mismatch
for i=1:m
for k=1:m
A(i,k)=0; %Initializing Jacobian matrix
end, end
iter = iter+1;
for n=1:nbus
nn=n-nss(n);
lm=nbus+n-ngs(n)-nss(n)-ns;
J11=0; J22=0; J33=0; J44=0;
for i=1:nbr
if nl(i) == n | nr(i) == n
if nl(i) == n, l = nr(i); end
if nr(i) == n, l = nl(i); end
J11=J11+ Vm(n)*Vm(l)*Ym(n,l)*sin(t(n,l)- delta(n) + delta(l));
J33=J33+ Vm(n)*Vm(l)*Ym(n,l)*cos(t(n,l)- delta(n) + delta(l));
if kb(n)~=1
J22=J22+ Vm(l)*Ym(n,l)*cos(t(n,l)- delta(n) + delta(l));
J44=J44+ Vm(l)*Ym(n,l)*sin(t(n,l)- delta(n) + delta(l));
else, end
if kb(n) ~= 1 & kb(l) ~=1
lk = nbus+l-ngs(l)-nss(l)-ns;
ll = l -nss(l);
% off diagonalelements of J1
A(nn, ll) =-Vm(n)*Vm(l)*Ym(n,l)*sin(t(n,l)- delta(n) + delta(l));
if kb(l) == 0 % off diagonal elements of J2
A(nn, lk) =Vm(n)*Ym(n,l)*cos(t(n,l)- delta(n) + delta(l));end
if kb(n) == 0 % off diagonal elements of J3
A(lm, ll) =-Vm(n)*Vm(l)*Ym(n,l)*cos(t(n,l)- delta(n)+delta(l));
end

16
if kb(n) == 0 & kb(l) == 0 % off diagonal elements of J4
A(lm, lk) =-Vm(n)*Ym(n,l)*sin(t(n,l)- delta(n) + delta(l));end
else end
else , end
end
Pk = Vm(n)^2*Ym(n,n)*cos(t(n,n))+J33;
Qk = -Vm(n)^2*Ym(n,n)*sin(t(n,n))-J11;
if kb(n) == 1 P(n)=Pk; Q(n) = Qk; end % Swing bus P
if kb(n) == 2 Q(n)=Qk;
if Qmax(n) ~= 0
Qgc = Q(n)*basemva + Qd(n) - Qsh(n);
if iter <= 7 % Between the 2th & 6th iterations
if iter > 2 % the Mvar of generator buses are
if Qgc < Qmin(n), % tested. If not within limits Vm(n)
Vm(n) = Vm(n) + 0.01; % is changed in steps of 0.01 pu to
elseif Qgc > Qmax(n), % bring the generator Mvar within
Vm(n) = Vm(n) - 0.01;end % the specified limits.
else, end
else,end
else,end
end
if kb(n) ~= 1
A(nn,nn) = J11; %diagonal elements of J1
DC(nn) = P(n)-Pk;
end
if kb(n) == 0
A(nn,lm) = 2*Vm(n)*Ym(n,n)*cos(t(n,n))+J22; %diagonal elements of J2
A(lm,nn)= J33; %diagonal elements of J3
A(lm,lm) =-2*Vm(n)*Ym(n,n)*sin(t(n,n))-J44; %diagonal of elements of J4
DC(lm) = Q(n)-Qk;
end
end
DX=A\DC';
for n=1:nbus
nn=n-nss(n);
lm=nbus+n-ngs(n)-nss(n)-ns;
if kb(n) ~= 1
delta(n) = delta(n)+DX(nn); end
if kb(n) == 0
Vm(n)=Vm(n)+DX(lm); end
end
maxerror=max(abs(DC));
if iter == maxiter & maxerror > accuracy
fprintf('\nWARNING: Iterative solution did not converged after ')
fprintf('%g', iter), fprintf(' iterations.\n\n')
fprintf('Press Enter to terminate the iterations and print the results \n')
converge = 0; pause, else, end

end

if converge ~= 1
tech= (' ITERATIVE SOLUTION DID NOT CONVERGE'); else,
tech=(' Power Flow Solution by Newton-Raphson Method');
end
V = Vm.*cos(delta)+j*Vm.*sin(delta);
deltad=180/pi*delta;
i=sqrt(-1);
k=0;
for n = 1:nbus

17
if kb(n) == 1
k=k+1;
S(n)= P(n)+j*Q(n);
Pg(n) = P(n)*basemva + Pd(n);
Qg(n) = Q(n)*basemva + Qd(n) - Qsh(n);
Pgg(k)=Pg(n);
Qgg(k)=Qg(n); %june 97
elseif kb(n) ==2
k=k+1;
S(n)=P(n)+j*Q(n);
Qg(n) = Q(n)*basemva + Qd(n) - Qsh(n);
Pgg(k)=Pg(n);
Qgg(k)=Qg(n); % June 1997
end
yload(n) = (Pd(n)- j*Qd(n)+j*Qsh(n))/(basemva*Vm(n)^2);
end
busdata(:,3)=Vm'; busdata(:,4)=deltad';
Pgt = sum(Pg); Qgt = sum(Qg); Pdt = sum(Pd); Qdt = sum(Qd); Qsht = sum(Qsh);

%clear A DC DX J11 J22 J33 J44 Qk delta lk ll lm


%clear A DC DX J11 J22 J33 Qk delta lk ll lm

% This program prints the power flow solution in a tabulated form


% on the screen.
%
% Copyright (C) 1998 by H. Saadat.

%clc
disp(tech)
fprintf(' Maximum Power Mismatch = %g \n', maxerror)
fprintf(' No. of Iterations = %g \n\n', iter)
head =[' Bus Voltage Angle ------Load------ ---Generation---
Injected'
' No. Mag. Degree MW Mvar MW Mvar
Mvar '
'
'];
disp(head)
for n=1:nbus
fprintf(' %5g', n), fprintf(' %7.3f', Vm(n)),
fprintf(' %8.3f', deltad(n)), fprintf(' %9.3f', Pd(n)),
fprintf(' %9.3f', Qd(n)), fprintf(' %9.3f', Pg(n)),
fprintf(' %9.3f ', Qg(n)), fprintf(' %8.3f\n', Qsh(n))
end
fprintf(' \n'), fprintf(' Total ')
fprintf(' %9.3f', Pdt), fprintf(' %9.3f', Qdt),
fprintf(' %9.3f', Pgt), fprintf(' %9.3f', Qgt), fprintf(' %9.3f\n\n',
Qsht)

% This program is used in conjunction with lfgauss or lf Newton


% for the computation of line flow and line losses.
%
% Copyright (c) 1998 H. Saadat
SLT = 0;
fprintf('\n')
fprintf(' Line Flow and Losses \n\n')

18
fprintf(' --Line-- Power at bus & line flow --Line loss--
Transformer\n')
fprintf(' from to MW Mvar MVA MW Mvar tap\n')

for n = 1:nbus
busprt = 0;
for L = 1:nbr;
if busprt == 0
fprintf(' \n'), fprintf('%6g', n), fprintf(' %9.3f',
P(n)*basemva)
fprintf('%9.3f', Q(n)*basemva), fprintf('%9.3f\n', abs(S(n)*basemva))

busprt = 1;
else, end
if nl(L)==n k = nr(L);
In = (V(n) - a(L)*V(k))*y(L)/a(L)^2 + Bc(L)/a(L)^2*V(n);
Ik = (V(k) - V(n)/a(L))*y(L) + Bc(L)*V(k);
Snk = V(n)*conj(In)*basemva;
Skn = V(k)*conj(Ik)*basemva;
SL = Snk + Skn;
SLT = SLT + SL;
elseif nr(L)==n k = nl(L);
In = (V(n) - V(k)/a(L))*y(L) + Bc(L)*V(n);
Ik = (V(k) - a(L)*V(n))*y(L)/a(L)^2 + Bc(L)/a(L)^2*V(k);
Snk = V(n)*conj(In)*basemva;
Skn = V(k)*conj(Ik)*basemva;
SL = Snk + Skn;
SLT = SLT + SL;
else, end
if nl(L)==n | nr(L)==n
fprintf('%12g', k),
fprintf('%9.3f', real(Snk)), fprintf('%9.3f', imag(Snk))
fprintf('%9.3f', abs(Snk)),
fprintf('%9.3f', real(SL)),
if nl(L) ==n & a(L) ~= 1
fprintf('%9.3f', imag(SL)), fprintf('%9.3f\n', a(L))
else, fprintf('%9.3f\n', imag(SL))
end
else, end
end
end
SLT = SLT/2;
fprintf(' \n'), fprintf(' Total loss ')
fprintf('%9.3f', real(SLT)), fprintf('%9.3f\n', imag(SLT))
clear Ik In SL SLT Skn Snk

Viva Questions:
1. Define Jacobian Matrix
2. Give the application of NR Method
3. Compare the GS and NR method

19
4. Write the procedure for the NR Method
5. Write the power flow equation

RESULT:
The load flow analysis is done for the given power system network by Newton - Raphson
Method

20
TRANSIENT AND SMALL SIGNAL ANALYSIS OF SINGLE MACHINE INFINITE BUS

Expt. No.:
Date:

AIM:
To perform small signal analysis of single machine infinite bus.

PROGRAM:

E = 1.35, V= 1.0; H= 9.94; X=0.65; Pm=0.6; D=0.138; f0 = 60;


Pmax = E*V/X, d0 = asin(Pm/Pmax) % Max. power
Ps = Pmax*cos(d0) % Synchronizing power coefficient
wn = sqrt(pi*60/H*Ps) % Undamped frequency of oscillation
z = D/2*sqrt(pi*60/(H*Ps)) % Damping ratio
wd = wn*sqrt(1-z^2), fd = wd/(2*pi) %Damped frequency oscill.
tau = 1/(z*wn) % Time constant
th = acos(z) % Phase angle theta
Dd0 = 10*pi/180; % Initial angle in radian
t = 0:.01:3;
Dd = Dd0/sqrt(1-z^2)*exp(-z*wn*t).*sin(wd*t + th);
d = (d0+Dd)*180/pi; % Load angle in degree
Dw = -wn*Dd0/sqrt(1-z^2)*exp(-z*wn*t).*sin(wd*t);
f = f0 + Dw/(2*pi); % Frequency in Hz
figure(1), subplot(2,1,1), plot(t, d), grid
xlabel('t, sec'), ylabel('Delta, degree')
subplot(2,1,2), plot(t,f), grid
xlabel('t, sec'), ylabel('f, Hz')

% Example 11.2 using initial function


A = [0 1; -wn^2 -2*z*wn]; % wn, z and t are defined earlier
B = [0; 0]; % Column B zero-input
C = [1 0; 0 1]; % Unity matrix defining output y as x1 and x2
D = [0; 0];
Dx0 = [Dd0; 0]; % Zero initial cond., Dd0 is defined earlier
[y,x]= initial(A, B, C, D, Dx0, t);
Dd = x(:, 1); Dw = x(:, 2); % State variables x1 and x2
d = (d0 + Dd)*180/pi; % Load angle in degree
f = f0 + Dw/(2*pi); % Frequency in Hz
figure(2), subplot(2,1,1), plot(t, d), grid
xlabel('t, sec'), ylabel('Delta, degree')
subplot(2,1,2), plot(t, f), grid
xlabel('t, sec'), ylabel('f, Hz'), subplot(111)

21
Viva Questions:
1. Define Stability
2. Define SMIB system
3. Give the classification of system stability
4. Define small signal stability
5. Define Transient stability

RESULT:

Thus transient and small signal analysis of single machine infinite bus is performed.

22
23

You might also like