You are on page 1of 128

# 1.

METHOD

## network by Direct Inspection Method.

THEORY:
Y-bus is known as the bus admittance matrix. Y-bus is often used in solving load flow
problems. It has wide spread application owing to its simplicity in data presentation, and the
ease with which it can be formed and modified for network changes. The diagonal element of
each node is the sum of admittances connected to it. It is known as self-admittance. The off-
diagonal element is equal to the negative of the admittance between the nodes.

In general, Y*V=I

Where Y-bus admittance matrix V-voltage at bus or I-current at the bus or node
Direct Inspection Method for Assembling Y matrix:

1. The diagonal element Yij of the matrix is equal to the sum of the admittance of all
elements connected to the ith node.
2. The off-diagonal element Yij of the matrix is equal to the negative of the sum of the
admittance of all elements connected between the nodes i and j.
ALGORITHM:
2. Form the Empty Y Bus Matrix
3. Add all the admittance connected to a single bus to form the diagonal
elements of the Y-bus

= ,
=0

## 4. The off-diagonal element is equal to the negative of the admittances between

the buses.
Yij =Yji=-yij
5. Display Y-bus matrix
6. Stop
%MATLAB program for building bus admitamce matrix (Y-
bus) by direct inspection method%
function[Y]=ybus(zdata)
nl=zdata(:,1);nr=zdata(:,2);R=zdata(:,3);X=zdata(:,4)
;
nbr=length(zdata(:,1));nbus=max(max(nl),max(nr));
Z=R+j*X;
y=ones(nbr,1)./Z;
Y=zeros(nbus,nbus);
for k=1:nbr;
if nl(k)>0 & nr(k)>0
Y(nl(k),nr(k))=Y(nl(k),nr(k))-y(k);
Y(nr(k),nl(k))=Y(nl(k),nr(k));
end
end
for n=1:nbus
for k=1:nbr
if nl(k)==n|nr(k)==n
Y(n,n)=Y(n,n)+y(k);
else,end
end
end

OUTPUT:

## Z=[0 1 0 1.0;0 2 0 0.8;1 2 0 0.4; 1 3 0 0.2;2 3 0 0.2;3 4 0 0.08]

Z=

0 1.0000 0 1.0000

0 2.0000 0 0.8000

>> Y=ybus(Z)

Y=

## 0 + 5.0000i 0 + 5.0000i 0 -22.5000i 0 +12.5000i

0 0 0 +12.5000i 0 -12.5000i

Result:
Thus, the MATLAB program has been written and executed to form the Bus
Admittance MatrixY of a given power network. Hence theoretically and practically
verified.
2. FORMATION OF Z BUS MATRIX BY BUS BUILDING
ALGORITHM METHOD
AIM: To develop a MATLAB program to form Bus Impedance matrix Z of a given power
network using Bus Building Algorithm Technique.
THEORY:
Rule 1: Addition of a tree branch to the reference
between a node q and the reference node o to the given matrix of order
(m*m), result in the matrix of order (m+1)*(m+1).

11 1 0
=[ ]
0 0

## Where, Z= impedance of an element. This matrix is diagonal with the impedance

values of the branches on the diagonal.
Rule 2: Addition of a tree branch from a new bus to an old bus
Continue with remaining branches of the tree connecting a new node to the existing
node. Addition of a branch Zpq between a new node q and the existing node p to
the given Z matrix of order (m*n), results in the Z matrix of order (m+1)*(m+1).

## Rule 3: Addition of a co-tree link between two existing buses

Where a link with impedance Zpq is added between two existing nodes p and q.
We augment the Z matrix with a new row and a new column.
Where Zll = Zpq + Zpp + Zqq ZZpq
The new row and column is eliminated using the relation

= -

Where Z is defined as

Rule 4: when bus q is the reference bus, Zqi = Ziq = 0 (for(i=1,m) ) and the above
matrix reduces to

Where
Zll=Zpq + Zpp and
ALGORITHM:

1. Start with the branches connected to the reference node using rule 1.
2. Continue with the remaining branches of the tree connecting a new node to
the existing node using rule 2.
3. Add the link with impedance Zpq between two existing nodes p and q
using rule 3.
4. Check whether all elements connected, it not go to step(1) and continue.
5. Print the Zbus Matrix.
6. Stop the program.
PROGRAM:
%formation of Zbus by building algorithm%
function[Zbus]=Zbuild(linedata);
nl=linedata(:,1);
nr=linedata(:,2);
R=linedata(:,3);
X=linedata(:,4);
ll=linedata(:,5);
nbr=length(nl);
nbus=max(max(nl),max(nr));
ZB=R+j*X;
%rule-1
for I=1:nbr;
if nl(I)==0||nr(I)==0;
if nl(I)==0
K=nr(I);
elseif nr(I)==0
K=nl(I);
end
Zbus(K,K)=ZB(I);
end
end
%rule-2
for J=1:nbr
if nl(J)>0&&nr(J)>0;
if ll(J)==0
Zbus(:,nr(J))=Zbus(:,nl(J));
Zbus(nr(J),:)=Zbus(nl(J),:);

Zbus(nr(J),nr(J))=Zbus(nr(J),nr(J))+ZB(J);
end
end
end
%rule-3
for J=1:nbr
if nl(J)>0&&nr(J)>0;
if ll(J)==1
delta_Z=Zbus(:,nr(J))-
Zbus(:,nl(J));

Zll=ZB(J)+Zbus(nr(J),nr(J))+Zbus(nl(J),nl(J))-
2*Zbus(nr(J),nl(J));
P=(delta_Z*(-delta_Z)')./Zll;
Zbus=Zbus-P;
end
end
end
OUTPUT:

linedata=[0 1 0 0.2 0;2 0 0 0.4 0;1 2 0 0.8 1;1 3 0 0.4 0;2 3 0 0.4 1];
>> Zbus=zbuild(linedata)

Zbus =

## 0 + 0.1600i 0 + 0.0800i 0 + 0.1200i

0 + 0.0800i 0 + 0.2400i 0 + 0.1600i
0 + 0.1200i 0 + 0.1600i 0 + 0.3400i

>> linedata=[0 1 0 0.2 0;2 0 0 0.4 0;1 2 0 0.8 1;1 3 0 0.4 0;2 3 0 0.4 1];
>> zbus=zbuild(linedata)

zbus =

## 0 + 0.1600i 0 + 0.0800i 0 + 0.1200i

0 + 0.0800i 0 + 0.2400i 0 + 0.1600i
0 + 0.1200i 0 + 0.1600i 0 + 0.3400i

RESULT:
Thus, the MATLAB program has written and executed to form the Zbus matrix by
Building Algorithm method. Hence theoretically and practically verified.
3. FORMATION OF Y BUS MATRIX BY SINGULAR
TRANSFORMATION METHOD

## Aim: To develop a MATLAB program to form bus admittance matrix Y of a

given power network by singular transformation method.

THEORY:

Y-bus is known as the bus admittance matrix. Y bus is often used in solving load flow
problem .It has wide spread application owing to its simplicity in data presentation and the ease
with which it can be formed and modified for network changes . In atypical power system
network, each bus is connected to only a few nearby buses.

Consequently many off diagonal elements are zero. Such a matrix is called spare and
efficient numerical techniques can be applied to compute its inverse. By means of an
appropriately ordered triangular decomposition, the inverse of a sparse matrix can be expressed
as a product of sparse matrix factors, thereby giving advantages of computational speed , storage
and reduction of round off errors.
Singular transformation method is a generalized method .It is applicable to all the
systems. Bus admittance matrix can be calculated when there is mutual corresponding coupling
between the elements. The matrix is rectangular, and therefore singular .Its elements are found as
per the following rules.

1. aik =1 If ith element is incident to and oriented away from the kth bus

2. aik =-1 If ith element is incident to but oriented towards the kth bus

ALGORITHM:

1. Start

## 8. Display Y-bus matrix

9. Stop

PROGRAM:
clear all;close all;clc;
disp('Formation of YBus Matrix by Singular
Trasformation Method')
nb=input('Enter the no of buses:');
nl=input('Enter the no of lines:');
for j=1:nl
sb(j)=input('Enter the starting bus:');
eb(j)=input('Enter the ending bus:');
z(j)=input('Enter the bus impedance value:');
b(j)=input('Enter the half line charging admittance
value:');
end
y=zeros(nl,nb);
for i=1:nl
k=sb(i);
m=eb(i);
y(i,k)=1;
y(i,m)=-1;
end
disp('Bus Incedence Matrix[A]:')
disp(y)
t=y';
disp('Transpose of Bus Incidence Matrix[At]:')
disp(t)
u=zeros(nl,nl);
for i=1:nl
u(i,i)=1/z(i)+b(i)/2;
end
disp(u)
disp('YBus=[At][y][A]')

Output
formation of Y bus matrix by singular transformation method

## enter the half line charging admittance value:0

enter the starting bus:4

OUTPUT:

1 -1 0 0 0

0 1 -1 0 0

0 0 1 -1 0

0 -1 0 1 0

1 0 0 0 -1

0 0 1 0 -1

## transpose of bus incidence matrix[A]:

1 0 0 0 1 0

-1 1 0 -1 0 0
0 -1 1 0 0 1

0 0 -1 1 0 0

0 0 0 0 -1 -1

0 - 4.0000i 0 0 0 0 0

0 0 - 2.5000i 0 0 0 0

0 0 0 - 5.0000i 0 0 0

0 0 0 0 - 8.0000i 0 0

0 0 0 0 0 - 0.8000i 0

0 0 0 0 0 0 - 0.8000i

Ybus=[At][Y][A]

## enter the bus impedance value:0.02+j*0.08

enter the half line charging admittance value:j*0.02

## bus incidence matrix[A]:

1 -1 0 0

1 0 0 -1

0 1 -1 0

0 0 1 -1

0 1 0 -1
transpose of bus incidence matrix[A]:

1 1 0 0 0

-1 0 1 0 1

0 0 -1 1 0

0 -1 0 -1 -1

10.0100 0 0 0 0

0 5.5756 0 0 0

0 0 3.8762 0 0

0 0 0 2.9812 0

0 0 0 0 2.4310

Ybus=[At][Y][A]

## -5.5756 -2.4310 -2.9812 10.9877

RESULT:
Thus the MATLAB program has written and executed to form Bus
Admittance matrix Y of a given power network by Singular
Transformation Method. Hence Theoretically and Practically Verified.
4. OPTIMAL GENERATOR SCHEDULING FOR THERMAL POWER
PLANTS

AIM:
To determine the optimal generator scheduling for thermal power plants for loss less
system with considering generator limit and not considering limits by -solution method

THEORY:
The output power of any generator should neither exceed its rotating nor should it be
below that necessary for the stable operation of a boiler. Thus the generation is restricted to tie
with in given minimum and maximum limits. The problem is to find the active power generation
of each bus such that the objective function is minimum subjected to the equality constraint and
the inequality constraints are
=1 Gi= PD & PGi(min) PGi PGi(max)

The solution algorithm for this case is as the above with minor modifications if any
generating unit violates the above inequality constraints set its generator and its respect as given
below. The load is shared b/w the remaining units on the basis of equal incremental cost .The
necessary condition for optimal dispatch when losses are neglected

= for PGi(min) PGi PGi(max)

for PGi = PGi(max)

for PGi = PGi(min)
ALGORITHM:
1. Guess the initial value of 0 with the use of cost -curve equations.
2. Calculate PGi0 according to equation i.e.,
PGi0 = i + i (i0) + i (i0)2 +........

3. Calculate =1 Gi0

## 5. If =1 Gi0 < PD , set a new value of i.e.,

' = 0 + and repeat from step (2) till the tolerance value is satisfied.

## 6. .If =1 Gi0 > PD , set a new value of i.e.,

' = 0 - and repeat from step () till the tolerance value is satisfied
7. Stop
Program

## a)%MATLAB PROGRAM FOR ECONOMIC LOAD DISPATCH NEGLECTING

LOSSES AND GENERATOR
%LIMITS(dispatch1.m)
clc;
clear;
% uno d b a
costdata=[1 400 8.4 0.006;
2 600 8.93 0.0042;
3 650 6.78 0.004];
ng=length(costdata(:,1));
for i=1:ng
uno(i)=costdata(i,1);
a(i)=costdata(i,2);
b(i)=costdata(i,3);
d(i)=costdata(i,4);
end
lambda=9.0;
pd=550;
delp=0.1;
dellambda=0;
iter=0;
while(abs(delp)>=0.001)
iter=iter+1;
lambda=lambda+dellambda;
sum=0;
totgam=0;
for i=1:ng
p(i)=(lambda-b(i))/(2*d(i));
sum=sum+p(i);
totgam=totgam+0.5*(1/d(i));
ifc(i)=lambda;
end
delp=pd-sum;
dellambda=delp/totgam;
end
totgencost=0;
for i=1:ng
totgencost=totgencost+(a(i)+b(i)*p(i)+d(i)*p(i)*p(i));
end
disp('OUTPUT OF MATLAB PROGRAM
dispatch1.m');
lambda
disp('GENERATING UNIT OPTIMAL
GENERATION(MW)');
[uno; p]'
disp('INCREMENTAL FUEL COST(Rs./MWhr)');
ifc(1)
disp('TOTAL GENERATION COST(Rs./hr.)');
totgencost

OUTPUT:

lambda = 9.6542

ans =

1.0000 104.5152
2.0000 86.2121
3.0000 359.2727

ans = 9.6542

## TOTAL GENERATION COST(Rs./hr.)

totgencost = 6.3467e+003
b)%MATLAB PROGRAM FOR ECONOMIC LOAD DISPATCH NEGLECTING
LOSSES AND INCLUDING
%GENERATOR LIMITS(dispatch2.m)
clc;
clear;
%uno a b d pmin pmax
costdata=[1 400 8.40 0.006 100 600;
2 600 8.93 0.0042 60 300;
3 650 6.78 0.004 300 650];
ng=length(costdata(:,1));
for i=1:ng
uno(i)=costdata(i,1);
a(i)=costdata(i,2);
b(i)=costdata(i,3);
d(i)=costdata(i,4);
pmin(i)=costdata(i,5);
pmax(i)=costdata(i,6);
end
lambda=9.0;
pd=550;
delp=0.1;
dellambda=0;
for i=1:ng
pv(i)=0;
pvfin(i)=0;
end
while(abs(delp)>=0.0001)
lambda=lambda+dellambda;
sum=0;
totgam=0;
for i=1:ng
p(i)=(lambda-b(i))/(2*d(i));
sum=sum+p(i);
totgam=totgam+0.5*(1/d(i));
end
delp=pd-sum;
dellambda=delp/totgam;
ifc=lambda;
end
limvio=0;
for i=1:ng
if(p(i)<pmin(i)|p(i)>pmax(i))
limvio=1;
break;
end
end
if limvio==0
disp('GENERATION IS WITHIN THE LIMITS');
end
if (limvio==1)
sum=0;
totgam=0;
delp=0.1;
loprep=1;
while(abs(delp)>=0.01&loprep==1)
disp('GENERATION IS NOT WITHIN LIMITS');
disp('VIOLATED GENERATOR NUMBER');
i
if p(i)<pmin(i)
disp('GENERATOR OF VIOALATED
UNIT(MW)');
p(i)
disp('CORRESPONDING VIOLATED LIMIT IS
pmin');
elseif p(i)>pmax(i)
disp('GENERATION OF VIOLATED
UNIT(MW)');
p(i)
disp('CORRESPONDING VIOLATED LIMIT IS
pmax');
end
sum=0;
totgam=0;
for i=1:ng
pv(i)=0;
end
for i=1:ng
if (p(i)<pmin(i)|p(i)>pmax(i))
if p(i)<pmin(i)
p(i)=pmin(i);
else
p(i)=pmax(i);
end
pv(i)=1;
pvfin(i)=1;
break;
end
end
for i=1:ng
sum=sum+p(i);
if (pvfin(i)~=1)
totgam=totgam+0.5*(1/d(i));
end
end
delp=pd-sum;
dellambda=delp/totgam;
lambda=lambda+dellambda;
ifc=lambda;
for i=1:ng
if pvfin(i)~=1
p(i)=(lambda-b(i))/(2*d(i));
end
sum=sum+p(i);
end
delp=pd-sum;
loprep=0;
for i=1:ng
if p(i)<pmin(i)|p(i)>pmax(i)
loprep=1;
break;
end
end
end
end
totgencost=0;
for i=1:ng

totgencost=totgencost+(a(i)+b(i)*p(i)+d(i)*p(i)*p(i));
end
disp('FINAL OUTPUT OF MATLAB PROGRAM
dispatch2.m');
lambda
disp('GENERATING UNIT OPTIMAL
GENERATION(MW)');
[uno; p]'
disp('INCREMENTAL FUEL COST(Rs./MWhr)');
ifc
disp('TOTAL GENERATION COST(Rs./hr.)');
totgencos
OUTPUT:

## GENERATION IS NOT WITHIN LIMITS

VIOLATED GENERATOR NUMBER

i=

ans =

431.6667

## CORRESPONDING VIOLATED LIMIT IS pmax

GENERATION IS NOT WITHIN LIMITS
VIOLATED GENERATOR NUMBER

i=

ans =

801

## CORRESPONDING VIOLATED LIMIT IS pmax

FINAL OUTPUT OF MATLAB PROGRAM dispatch2.m

lambda =
15

ans =

1 550
2 300
3 650

ifc =

15

## TOTAL GENERATION COST(Rs./hr.)

totgencost =

17239

RESULT:
MATLAB program for optimal generator scheduling for thermal power for loss less
system with considering generator limit and not considering generator limit has written and
executed in MATLAB .Hence theoretically and practically verified.
5. ECONOMIC LOAD DISPATCH BY - ITERATIVE SOLUTION
METHOD

AIM: To determine the economic load dispatch for loss system with considering generator limit
and not considering limits by -iterative method.

THEORY:
The purpose of economic load dispatch is t reduce costs for the power system of
economic scheduling , we mean to find the generation of the different generators or
plants , so that total fuel cost is minimum and at the same time the total demand and
losses at any instant must be met by the total generation.
The Economic Dispatch problem involves the solution for two different problems
.They are unit commitment and on-line Dispatch .Unit commitment is the optimum
allocation an each generating station at various station load levels.

FORMULAE:
Ci = i + i Pi + i Pi2
Pi(k) = k - i
/ ( i + k Bii)

PL = =1 ii Pi2

Pk = PD +PLk -=1 ik

= Pk / =1. (Pi /)k

=1 /
(K)
= =1.

i +Bii i / ( i +
k
Bii)2

k+1 = k +
Bii = Loss co-efficient
Bij = 0 for lossy system
B is NULL matrix for loss less system
ALGORITHM:
2. using PGi equation can solve for PGi( )
3.solve for PL( )
4. compute (PGi / ) for all i
5. compute P
6.compute ()
+1
7. = +
8. Go to step () till P
PROGRAM

## a)%MATLAB PROGRAM FOR ECONOMIC LOAD DISPATCH WITH

LOSSES AND NO GENERATOR LIMITS(dispatch3.m)
clc;
clear;
%uno d b a
costdata=[1 420 9.2 0.004;
2 350 8.5 0.0029];
ng=length(costdata(:,1));
for i=1:ng
uno(i)=costdata(i,1);
d(i)=costdata(i,2);
b(i)=costdata(i,3);
a(i)=costdata(i,4);
end
lambda=12;
pd=640.82;
delp=0.1;
dellambda=0;
lossdata=[0.0346 0.00643];
totgencost=0;
for i=1:ng
B(i)=lossdata(1,i);
end
iter=0;
disp('iter lambda pg1 pg2 ploss');
while(abs(delp)>=0.001)
iter=iter+1;
lambda=lambda+dellambda;
pl=0;
sum=0;
delpla=0;
for i=1:ng
den=2*(a(i)+lambda*B(i)*0.01);
p(i)=(lambda-b(i))/den;
pl=pl+(B(i)*0.01*p(i)*p(i));
sum=sum+p(i);
end
delp=pd+pl-sum;
for i=1:ng
den=2*(a(i)+lambda*B(i)*0.01)^2;
delpla=delpla+(a(i)+B(i)*0.01*b(i))/den;
end
dellambda=delp/delpla;
[iter;lambda;p(1);p(2);pl]'
end
for i=1:ng
den=1-(B(i)*p(i)*2*0.01);
l(i)=1/den;
end
totgencost=0;
for i=1:ng

totgencost=totgencost+(d(i)+b(i)*p(i)+a(i)*p(i)*p(i));
ifc(i)=2*a(i)*p(i)+b(i);
end
disp('FINAL OUTPUT OF MATLAB PROGRAM
dispatch3.m');
lambda
disp('GENERATING UNIT OPTIMAL GENERATION(MW)');
[uno; p]'
disp('INCREMENTAL FUEL COST AND PENALTY FECTORS
ARE');
disp('UNIT NO. IFC L');
[uno;ifc;l]'
disp('CHECK LAMBDA=IFC*L');
disp('UNIT NO. LAMBDA');
[uno;ifc.*l]'
disp('TOTAL GENERTION COST(Rs./hr)');
totgencost

Output:

ans =

ans =

ans =

ans =

ans =

lambda =

12.1034

ans =

1.0000 177.2999
2.0000 489.8232

UNIT NO. IFC L
ans =

## 1.0000 10.6184 1.1398

2.0000 11.3410 1.0672

CHECK LAMBDA=IFC*L
UNIT NO. LAMBDA

ans =

1.0000 12.1034
2.0000 12.1034

## TOTAL GENERTION COST(Rs./hr)

totgencost =

7.3862e+003
%MATLAB PROGRAM FOR ECONOMIC LOAD DISPATCH WITH LOSSES
AND GENERATOR
%LIMITS(dispatch4.m)
clc;
clear;
% uno d b a pmin pmax
costdata=[1 420 9.2 0.004 100 200;
2 350 8.5 0.0029 150 500];
ng=length(costdata(:,1));
for i=1:ng
uno(i)=costdata(i,1);
d(i)=costdata(i,2);
b(i)=costdata(i,3);
a(i)=costdata(i,4);
pmin(i)=costdata(i,5);
pmax(i)=costdata(i,6);
end
lambda=12;
pd=640.82;
delp=0.1;
dellambda=0;
lossdata=[0.0346 0.00643]; %NOT IN PU
totgencost=0;
for i=1:ng
B(i)=lossdata(1,i);
end
while abs(delp)>=0.001
lambda=lambda+dellambda;
pl=0;
sum=0;
delpla=0;
for i=1:ng
den=2*(a(i)+lambda*B(i)*0.01);
p(i)=(lambda-b(i))/den;
pl=pl+(B(i)*0.01*p(i)*p(i));
sum=sum+p(i);
end
delp=pd+pl-sum;
for i=1:ng
den=2*(a(i)+lambda*B(i)*0.01)^2;
delpla=delpla+(a(i)+B(i)*0.01*b(i))/den;
end
dellambda=delp/delpla;
end
dellambda=0;
for i=1:ng
pv(i)=0;
pvfin(i)=0;
end
limvio=0;
for i=1:ng
if p(i)<pmin(i)|p(i)>pmax(i)
limvio=1;
break;
end
end
if limvio==0
disp('GENERATION IS WITHIN THE LIMITS');
end
delp=0.1;
if limvio==1
while (abs(delp)>=0.01)
disp('GENERATION IS NOT WITHIN LIMITS');
disp('VIOLATED GENERATOR NUMBER');
i
if p(i)<pmin(i)
disp('GENERATION OF VIOLATED
UNIT(MW)');
p(i)
disp('CORRESPONDING VIOLATED LIMIT IS
pmin');
elseif p(i)>pmax(i)
disp('GENERATION OF VIOLATED
UNIT(MW)');
p(i)
disp('CORRESPONDING VIOLATED LIMIT IS
pmax');
end
pl=0;
sum=0;
delpla=0;
for i=1:ng
pv(i)=0;
end
for i=1:ng
if p(i)<pmin(i)|p(i)>pmax(i)
pv(i)=1;
pvfin(i)=1;
if p(i)<pmin(i)
p(i)=pmin(i);
end
if p(i)>pmax(i)
p(i)=pmax(i);
end
end
end
for i=1:ng
if pvfin(i) ~=1
den=2*(a(i)+lambda*B(i)*0.01)^2;

delpla=delpla+(a(i)+B(i)*0.01*b(i))/den;
end
sum=sum+p(i);
end
delp=pd+pl-sum;
dellambda=delp/delpla;
lambda=lambda+dellambda;
sum=0;
for i=1:ng
if pvfin(i) ~=1
den=2*(a(i)+lambda*B(i)*0.01);
p(i)=(lambda-b(i))/den;
end
pl=pl+(B(i)*0.01*p(i)*p(i));
sum=sum+p(i);
end
delp=pd+pl-sum;
end
end
for i=1:ng
den=1-(B(i)*p(i)*2*0.01);
l(i)=1/den;
end
for i=1:ng

totgencost=totgencost+(d(i)+b(i)*p(i)+a(i)*p(i)*p(i));
ifc(i)=2*a(i)*p(i)+b(i);
end
disp('FINAL OUTPUT OF MATLAB PROGRAM
dispatch4.m');
lambda
disp('GENERATING UNIT OPTIMAL GENERATION(MW)');
[uno; p]'
disp('INCREMENTAL FUEL COSTS AND PENALTY FACTORS
ARE');
disp('UNIT NO. IFC L');
[uno;ifc;l]'
disp('CHECK LAMBDA=IFC*L');
disp('UNIT NO. LAMBDA');
[uno; ifc.*l]'
disp('TOTAL GENERATION COST(Rs./hr)');
totgencost

Output:

## GENERATION IS WITHIN THE LIMITS

FINAL OUTPUT OF MATLAB PROGRAM dispatch4.m

lambda = 12.1034

## ans = 1.0000 177.2999

2.0000 489.8232
INCREMENTAL FUEL COSTS AND PENALTY FACTORS ARE
UNIT NO. IFC L

ans =

## 1.0000 10.6184 1.1398

2.0000 11.3410 1.0672

CHECK LAMBDA=IFC*L
UNIT NO. LAMBDA

ans =

1.0000 12.1034
2.0000 12.1034

## TOTAL GENERATION COST(Rs./hr)

totgencost =

7.3862e+003

RESULT :
MATLAB program for Economic load dispatch for lossy system with
considering generator limit and not considering limits by - iterative solution
method is executed . Hence theoretically & practically verified.
6. LOAD FLOW ANALYSIS USING GUASS -SEIDEL METHOD FOR
ONLY PQ BUS
AIM: To understand , in particular the mathematical formulation of power flow model in
complex form and a simple method f solving power flow problems of small sized system
using Gauss seidel iterative algorithm.
THEORY:
Gauss -seidel method is an iterative algorithm for solving a set of non-linear load flow
equations . the non-linear load flow equation is given by

=1 pq Vq
k+1
-= +1 q
k
]

## Qpk+1 = ( -1) Im [ ( Vpk) * ( 1

=1 pq . Vq
k+1
+= pq. Vqk ) ]

Theoretical calculation:
The one -line diagram of a simple three -bus power system with generation at bus1.The
magnitude of voltage at bus 1 is adjusted to 1.05pu. the scheduled loads at buses 2&3 are
no marked on the diagram line impedance are marked in P.U. on 100MVA base and the
line charging suspectance are neglected. Impedance in P.U on 100 MVA base
Line impedance are converted to admittances
y12= 1/0.02+j0.04 =10-j20
Similarly y13=10-j30 & y23=16-j32.
The admittances are marked on the network .At the P-Q buses , the complex loads
expressed in P.U are
s2sch = -(256.6 +j110.2 ) / 100 = -2.566-j1.102P.U
s3sch = -(138.6 +j45.2 ) / 100 = -1.386-j0.452P.U
V1 = 1.05 p.u.
since the actual admittance are readily available in Fig . for hand calculations bus 1
is taken as reference bus (slack bus ) starting from an initial estimate of
V2(0) = 1.0 +J 0.0 & V3(0) = 1.0 +j0.0
V2 and V3 are computed .
Program
6. LOAD FLOW ANALYSIS USING GAUSS-SEDIAL METHOD
%MATLAB PROGRAM FOR LOAD FLOW ANALYSIS USING GAUSS-
SEIDAL METHOD gauss-seidal%
clc;
data=[1 1 2 10-j*20
2 1 3 10-j*30
3 2 3 16-j*32]
elements=max(data(:,1));
bus=max(max(data(:,2)),max(data(:,3)));
y=zeros(bus,bus);
for p=1:bus,
for q=1:elements,
if(data(q,2)==p|data(q,3)==p)
y(p,p)=y(p,p)+data(q,4);
end
end
end
for p=1:bus,
for q=1:bus,
if(p~=q)
for r=1:elements

if((data(r,2)==p&data(r,3)==q)|(data(r,2)==data(r,3)==p
))
y(p,q)=-(data(r,4));
end
end
end
end
end
a1=input('enter p2 in MW:');
b1=input('enter q2 in MVAR:');
a2=input('enter p3 in MW:');
b2=input('enter q3 in MVAR:');
pu=input('enter the base value in MW:');
p2=(a1/pu);
q2=(b1/pu);
p3=(a2/pu);
q3=(b2/pu);
dx1=1+j*0;
dx2=1+j*0;
v1=1.05;
v2=1+j*0;
v3=1+j*0;
iter=0;
disp('iter v2 v3');
while(abs(dx1)&abs(dx2)>=0.00001)&iter<7
iter=iter+1;
g1=(((p2-
j*q2)/conj(v2))+(y(1,2)*v1)+(y(2,3)*v3))/(y(1,2)+y(2,3)
);
g2=(((p3-
j*q3)/conj(v3))+(y(1,3)*v1)+y(2,3)*g1)/(y(1,3)+y(2,3));
dx1=g1-v2;
dx2=g2-v3;
v2=v2+dx1;
v3=v3+dx2;
fprintf('%',iter),disp([v2,v3]);
end

OUTPUT:

data =

## 1.0000 1.0000 2.0000 10.0000 -20.0000i

2.0000 1.0000 3.0000 10.0000 -30.0000i
3.0000 2.0000 3.0000 16.0000 -32.0000i

enter p2 in MW:256.16
enter q2 in MVAR:110.2
enter p3 in MW:138.6
enter q3 in MVAR:45.2
enter the base value in MW:100
iter v2 v3
0.9826 - 0.0309i 1.0011 - 0.0352i

## 0.9804 - 0.0593i 1.0002 - 0.0496i

0.9802 - 0.0597i 1.0001 - 0.0498i

## RESULT : Hence the experiment on load flow analysis using GUASS-SIDEL

method was done by using MATLAB. Hence theoretically & practically
verified.
7. GAUSS-SEIDEL LOAD FLOW SOLUTION FOR BOTH PQ&PV
BUSES
Aim: To find the load flow solution by using gauss-seidel method for both PQ & PV buses.

ALGORITHM:
Step 1:

1. Assume the flat voltage (1+j0) for all busses except slack bus because for any iteration it does not
change.

## 6. Check for generator bus.

7. Set specified and phase of if the generator bus where generator voltage magnitude of voltage for
bus p.

## The calculation of reactive power of generator

8. For generator bus the magnitude of voltage doesnot change. The phase angle of the voltage

9. For the load bus the (k+1)th iteration value of load bus p voltage can be calculated.

## 11. Calculate change in bus-p voltage.

12. Find the largest among the largest change check whether this largest change if it is ok otherwise.

Start

## Read system data and form Ybus

Get the slack bus number, voltage, flat start voltage for PQ buses, and
convergence creation

## Check for slack

bus

+ +
Calculate = ( )- = - = +

+
Calculate = -

+
acceleration =

p = p+1

Is P = n

K = k+1 Is | |<

## Evaluate line fault and slack

bus power

\ stop
Theory:
The load flow studies involve the solution of the power system network under steady
state condition. The main information obtained from a load flow study are magnitude and
phase angle of the voltage at each bus and real and reactive powers flows in each line. It also
gives the initial conditions of the system when transient behaviour of the system is to be
studied. The load flow study of power system is essential to decide the best operation of
existing system and for planning the future expansion of the system. The Gauss-Seidel
method is an iterative algorithm for solving a self non-linear load flow equations.

1
= [ ]

= = +

## Where p=1 2 3 4 5 6 ................n

The variables in the equation obtained p=1 2 3 4 5 6 ........n are node voltages V1 V2 V3 V4
.......Vn
In Gauss-Seidel method the individual value of voltages are assumed they denoted by
.......
These are substituting in equation and taking p=2 then computed.
The value of is replaced by initial values p=2 then computed. This process is
completed until find the last voltage and p=n.
Reactive power:

+ +
= I( )* = + = I

## The value is in out of the limits then treated as GENERATOR BUS.

PROGRAM

clear
basemva = 100; accuracy = 0.001; accel = 1.8; maxiter = 100;

## % Bus Bus Voltage Angle ---Load---- -------Generator-----

Injected
% No code Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar
busdata=[1 1 1.04 0 0 0 0 0 0
0 0
2 2 1.04 0 50 0 100 0 20
100 0
3 0 1.00 0 100 0 0 -50 0 0
0
4 0 1.00 0 -30 0 0 10 0 0
0];

% 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 2 0.05 0.15 0.00
1
1 3 0.1 0.3 0.00
1
2 3 0.15 0.45 0.00
1
2 4 0.1 0.3 0.00
1
3 4 0.05 0.15 0.00
1];

## % form the bus admittance matrix

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
% Load flow solution by Gauss-Seidel method
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
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
end
Pgt = sum(Pg); Qgt = sum(Qg); Pdt = sum(Pd); Qdt = sum(Qd); Qsht =
sum(Qsh);
clear AcurBus DP DQ DV L Sc Vc VcI VcR YV converge delta

## % Prints the power flow solution on the screen

disp(tech)
fprintf(' Maximum Power Mismatch = %g \n', maxerror)
fprintf(' No. of Iterations = %g \n\n', iter)
Injected'
' No. Mag. Degree MW Mvar MW Mvar
Mvar '
'
'];
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)

## % Computes and displays the line flow and losses

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;
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

OUTPUT
Power Flow Solution by Gauss-Seidel Method
Maximum Power Mismatch = 0.000987805
No. of Iterations = 21
Bus Voltage Angle ------Load------ ---Generation--- Injected

## Total 120.000 0.000 124.510 13.673 0.000

LINE FLOW AND LOSSES
--Line-- Power at bus & line flow --Line loss-- Transformer

## Total loss 4.541 13.624

RESULT:
Thus the MATLAB program has written and executed the load flow solution using
Gauss seidel load flow solution for both PQ&PV buses
8. FAST DECOUPLED LOAD FLOW METHOD

AIM: To find the load flow solution using fast decoupled load flow method
PROGRAM
clear
basemva = 100; accuracy = 0.001; maxiter = 50;

## % Bus Bus Voltage Angle ---Load---- -------Generator----- Injected

% No code Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar
busdata=[1 1 1.04 0 0 0 0 0 0 0
0
2 2 1.04 0 50 0 100 0 20 100
0
3 0 1.00 0 100 0 0 -50 0 0
0
4 0 1.00 0 -30 0 0 10 0 0
0];

% 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 2 0.05 0.15 0.00
1
1 3 0.1 0.3 0.00
1
2 3 0.15 0.45 0.00
1
2 4 0.1 0.3 0.00
1
3 4 0.05 0.15 0.00
1];
% form the bus admittance matrix
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
% Load flow solution by fast decoupled method

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
if kb(n) == 1, ns = ns+1; else, end
nss(n) = ns;
end
Ym = abs(Ybus); t = angle(Ybus);
ii=0;
for ib=1:nbus
if kb(ib) == 0 | kb(ib) == 2
ii = ii+1;
jj=0;
for jb=1:nbus
if kb(jb) == 0 | kb(jb) == 2
jj = jj+1;
B1(ii,jj)=imag(Ybus(ib,jb));
else,end
end
else, end
end

ii=0;
for ib=1:nbus
if kb(ib) == 0
ii = ii+1;
jj=0;
for jb=1:nbus
if kb(jb) == 0
jj = jj+1;
B2(ii,jj)=imag(Ybus(ib,jb));
else,end
end
else, end
end
B1inv=inv(B1); B2inv = inv(B2);

maxerror = 1; converge = 1;
iter = 0;
% Start of iterations
while maxerror >= accuracy & iter <= maxiter % Test for max. power mismatch
iter = iter+1;
id=0; iv=0;
for n=1:nbus
nn=n-nss(n);
J11=0; J33=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));
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;
Qgc = Q(n)*basemva + Qd(n) - Qsh(n);
if Qmax(n) ~= 0
if iter <= 20 % Between the 1th & 6th iterations
if iter >= 10 % 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.05 pu to
elseif Qgc > Qmax(n), % bring the generator Mvar within
Vm(n) = Vm(n) - 0.005;end % the specified limits.
else, end
else,end
else,end
end
if kb(n) ~= 1
id = id+1;
DP(id) = P(n)-Pk;
DPV(id) = (P(n)-Pk)/Vm(n);
end
if kb(n) == 0
iv=iv+1;
DQ(iv) = Q(n)-Qk;
DQV(iv) = (Q(n)-Qk)/Vm(n);
end
end
Dd=-B1\DPV';
DV=-B2\DQV';
id=0;iv=0;
for n=1:nbus
if kb(n) ~= 1
id = id+1;
delta(n) = delta(n)+Dd(id); end
if kb(n) == 0
iv = iv+1;
Vm(n)=Vm(n)+DV(iv); end
end
maxerror=max(max(abs(DP)),max(abs(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 Fast Decoupled Method');
end
k=0;
V = Vm.*cos(delta)+j*Vm.*sin(delta);
clear A; clear DC; clear DX
i=sqrt(-1);
for n = 1:nbus
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
S(n)=P(n)+j*Q(n);
Qg(n) = Q(n)*basemva + Qd(n) - Qsh(n);
k=k+1;
Pgg(k)=Pg(n);
end
end
Pgt = sum(Pg); Qgt = sum(Qg); Pdt = sum(Pd); Qdt = sum(Qd); Qsht = sum(Qsh);
clear Pk Qk DP DQ J11 J33 B1 B1inv B2 B2inv DPV DQV Dd delta ib id ii iv jb
jj

## % Prints the power flow solution on the screen

disp(tech)
fprintf(' Maximum Power Mismatch = %g \n', maxerror)
fprintf(' No. of Iterations = %g \n\n', iter)
Injected'
' No. Mag. Degree MW Mvar MW Mvar
Mvar '
'
'];
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)

## % Computes and displays the line flow and losses

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;
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
OUTPUT:-

## Maximum Power Mismatch = 0.000530072

No. of Iterations = 7

## 4 -43.505 -17.451 46.874 1.250 3.749

4 30.000 10.000 31.623

## Total loss 4.555 13.666

RESULT:
Thus the MATLAB program has written and executed the load flow solution using FAST
9 NETWORK-RAPHSON LOAN FLOW METHOD FOR BOTH PQ&PV
BUSES

AIM: To find the load flow solution using Network-Raphson load flow method.
THEORY:
The number of iterations required to obtain a solution is independent of the system size but more
functional evaluations as required at each iteration.
= =
In polar form
= = | | | | +

The complex power at bus I is Pi-jQi = Ii

Pi-jQi=|Vi| = | | | | +
separating the real and imaginary terms in the above equation

Pi= = | || || | cos + )

Qi= - = | || || | sin + )

A set of non-linear algebraic equations in terms of independent variables, voltage magnitude in per unit
(p.u) and phase angle in radians.
2

2 2

2
2
.
2
.
.
.
. . .
.
. . .
.
.
.

2 2 .

=
2 2 2 2 2
. 2
2 2 .
. . .
. . .
.
. . .
.
.
[ ] .
[ 2 ] [. 2

] [| |]

In the above discussion bus 1 is assumed to be the slack bus. The Jacobian matrix gives the linearized
relationship between small changes in voltage angle & voltage magnitude | | with the small
changes inreal & reactive power and .

P
[ ][ ][ ]
Q =

## The diagonal matrix and off diagonal matrix (J1 )

= | || | | | sin - + )

= | || || | sin - + )

J2:

## =2| || | cos + | | | | cos +

| |

=| || | cos - + )
| |
J3:

= | || | | | cos +

= | || || | cos - + ) j

| |

=| || | sin +
| |

## The terms &

=
The new estimate for bus voltage are
+
= +

+
| |=| | + | |

Program
clear
basemva = 100; accuracy = 0.001; maxiter = 10;
% Bus Bus Voltage Angle ---Load---- -------Generator----- Injected
% No code Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar
busdata=[1 1 1.04 0 0 0 0 0 0 0
0
2 2 1.04 0 50 0 100 0 20 100
0
3 0 1.00 0 100 0 0 -50 0 0
0
4 0 1.00 0 -30 0 0 10 0 0
0];

% 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 2 0.05 0.15 0.00
1
1 3 0.1 0.3 0.00
1
2 3 0.15 0.45 0.00
1
2 4 0.1 0.3 0.00
1
3 4 0.05 0.15 0.00
1];
% form the bus admittance matrix
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
% Load flow solution by Newton-Raphson method
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
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);
i=sqrt(-1);
k=0;
for n = 1:nbus
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
end
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
% Prints the power flow solution on the screen
disp(tech)
fprintf(' Maximum Power Mismatch = %g \n', maxerror)
fprintf(' No. of Iterations = %g \n\n', iter)
Injected'
' No. Mag. Degree MW Mvar MW Mvar
Mvar '
'
'];
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)

## % Computes and displays the line flow and losses

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;
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

OUTPUT
Power Flow Solution by Newton-Raphson Method

## Maximum Power Mismatch = 2.75729e-007

No. of Iterations = 4

## Total 120.000 0.000 124.555 13.664 0.000

LINE FLOW AND LOSSES

## Total loss 4.555 13.664

10. UNSYMMETRICAL SHORT CIRUIT FAULT ANALYSIS BY Z BUS
MATRIX

Aim:
To developed a mat lab program to analyses the symmetrical fault of a given power
network by Using bus impedance matrix.
Start

## Read line data, fault impedance, positive, negative

zero sequence reactance of each elements

## Assume pre-fault voltage is 1 P.U

Draw the positive, negative, zero sequence works using sequence impedances of the power
system compute positive, negative, zero sequence bus impedance matrix [Z1 Z2 Z3]

Check case

## Symmetrical component Symmetrical component Symmetrical component

of current of current of current
= = = =0, = =

+
=
= + +
+ + +
Fault phase current
Fault phase current =
+3
+
[ ] = [ ] [ ] + +3
[ ] = [ ] [ ]
=
= = -j3
= = 3
= - , = 0 Fault phase current
= = 0
symmetrical voltages = , = +
symmetrical voltages
= = 3
=
= symmetrical voltages
=
= =
=
post fault voltage =
post fault voltage
=

[ ] = [ ] [ ] compute post fault
[ ] = [ ] [ ]
voltage using

transformation matrix
Theory:

## The fault which gives rise to unsymmetrical fault current is called an

unsymmetrical fault

## a) single line to ground (L-G) fault

b) line to line (L-L) fault
c) double line to ground (L-L-G) fault

## 2.series type fault (or) open circuit fault

Open conductor fault (one or two conductor) Most of the faults that occur
on power system are unsymmetrical faults, which may consist of
unsymmetrical short circuit, unsymmetrical faults through impedance, or
open conductor. Any unsymmetrical faults causes unbalanced current to
flow in the system, so the method of symmetrical components is very useful
in an analysis to determine the current and voltage in all parts of the system
after the fault occurrence of the fault.

Sequence Impedance:
Sequence impedance is the impedance of an equipment or component to
the current of different sequences. The impedance offered to flow of positive
sequence currents is known as the positive sequence impedance and denoted
by Z1. The impedance offered to the flow of (negative) zero sequence
current is known as the negative sequence impedance and denoted by Z2.
When zero sequence current flow, the impedance known as zero sequence
impedance and denoted by Z0.
Single line to ground fault:
single line to ground fault on phase `a at the terminals of an
The circuit diagram for single line to ground fault on an unloaded Y-connected generator with
its neutral grounded through a reactance is show, where phase `a is one on which the fault
occurs the relation to be developed for this type of fault will apply only when the fault.

The fault current is = 3 =
+ + +
Fig: Sequence network connections for single line to ground fault

## Line ton Line fault:

The circuit diagram for a line to line fault through impedance Zf between phase b and phase c on
an unbalanced , Y connected generator with its neutral ground through a reactance is shown, the
boundary condition at the point are
=
= , + = , =

## Then the symmetrical components of current are

[ ] = [ ][ ]
3

on phasw a, but this should cause no difficulty since the phase are labledarbitrarily and any phase
can be designated as phase a. the boundary conditions at the fault point are = . , = ,
=

## Then the symmetrical components of current are

[ ] = [ ][ ]
3

= =
3
Substituting , , in sequence network equation, we obtain

[ ]=[ ] [ ] [ ] (or) =

=

## phase a voltage in term of symmetrical components is

= + + = + = + +
= + + = + + = + +

=
( + + + 3 )
= , Hence LL fault calculation do not involve zero sequence network
= , = , =

[ ]= [ ] [ ] [ ] =

= + +

= + +
= =

[ + ]=

=
+ +

[ ] = [ ][ ]

## The fault current is = - = or = -j3 again the symmetrical components of

voltage are given by

[ ] = [ ] [ ] =

=
+3

=
+3
+ + +3

=

## Symmetrical components of voltage are

[ ] = [ ] [ ] [ ]

=
Program
function unsymmfault(zdata0,zdata1,zdata2,Zbus0,Zbus1,Zbus2)
nl=zdata1(:,1);nr=zdata1(:,2);
nbus=max(max(nl),max(nr));
V0=ones(nbus,1)+j*zeros(nbus,1);
ff=999;
while ff>0
fprintf('\n 1.L-G Fault');
fprintf('\n 2.L-L Fault');
fprintf('\n 3.L-L-G Fault');
c=input('\n enter the choice:');
if (c~=1 && c~=2 && c~=3)
fprintf('Invalid choice try again')
end
if (c==1)
fprintf('\n Line to ground Fault analysis\n')
nf=input('\n enter Faulted Bus No. ->');
while nf<=0 || nf>nbus
fprintf('\n Faulted bus No. must be between 1 & %g\n',nbus)
nf=input('\n enter Faulted Bus No.->');
end
fprintf('\n enter Fault Impedence Zf=R+j*X in')
Zf=input('complex form(for bolted fault enter 0). Zf=');
fprintf('\n')
fprintf('\n Single line to ground fault at bus no. %g\n',nf)
a=cos(2*pi/3)+j*sin(2*pi/3);
sctm=[1 1 1;1 a^2 a;1 a a^2]; %symmetrical component transformation
matrix

Ia0=V0(nf)/(Zbus1(nf,nf)+Zbus2(nf,nf)+Zbus0(nf,nf)+3*Zf);Ia1=Ia0;Ia2=Ia0;
I012=[Ia0;Ia1;Ia2];
Ifabc=sctm*I012;
Ifabcm=abs(Ifabc);
fprintf('\n TOTAL FAULT CURRENT=%9.4f per unit\n\n',Ifabcm(1))
fprintf('Bus voltages during the fault in per unit\n\n')
fprintf('Bus voltage magnitude \n')
fprintf('No. phase a phase b phase c \n')
for n=1:nbus
Vf0(n)=0-Zbus0(n,nf)*Ia0;
Vf1(n)=V0(n)-Zbus1(n,nf)*Ia1;
Vf2(n)=0-Zbus2(n,nf)*Ia2;
Vabc=sctm*[Vf0(n);Vf1(n);Vf2(n)];
Va(n)=Vabc(1);Vb(n)=Vabc(2);Vc(n)=Vabc(3);
fprintf('%5g ',n)
fprintf('%11.4f',abs(Va(n))),fprintf('%11.4f',abs(Vb(n)))
fprintf('%11.4f\n',abs(Vc(n)))
end
end
if (c==2)
fprintf('\n Line to Line Fault analysis\n')
nf=input('\n enter Faulted Bus No. ->');
while nf<=0 || nf>nbus
fprintf('\n Faulted bus No. must be between 1 & %g\n',nbus)
nf=input('\n enter Faulted Bus No.->');
end
fprintf('\n enter Fault Impedence Zf=R+j*X in')
Zf=input('complex form(for bolted fault enter 0). Zf=');
fprintf('\n')
fprintf('\n line to line fault at bus no. %g\n',nf)
a=cos(2*pi/3)+j*sin(2*pi/3);
sctm=[1 1 1;1 a^2 a;1 a a^2]; %symmetrical component transformation
matrix
Ia0=0;
Ia1=V0(nf)/(Zbus1(nf,nf)+Zbus2(nf,nf)+Zbus0(nf,nf)+3*Zf);Ia2=-Ia1;
I012=[Ia0;Ia1;Ia2];
Ifabc=sctm*I012;
Ifabcm=abs(Ifabc);
fprintf('\n TOTAL FAULT CURRENT=%9.4f per unit\n\n',Ifabcm(2))
fprintf('Bus voltages during the fault in per unit\n\n')
fprintf('No. phase a phase b phase c \n')
for n=1:nbus
Vf0(n)=0;
Vf1(n)=V0(n)-Zbus1(n,nf)*Ia1;
Vf2(n)=0-Zbus2(n,nf)*Ia2;
Vabc=sctm*[Vf0(n);Vf1(n);Vf2(n)];
Va(n)=Vabc(1);Vb(n)=Vabc(2);Vc(n)=Vabc(3);
fprintf('%5g ',n)
fprintf('%11.4f',abs(Va(n))),fprintf('%11.4f',abs(Vb(n)))
fprintf('%11.4f\n',abs(Vc(n)))
end
end
if (c==3)
fprintf('\n DoubleLine to ground Fault analysis\n')
nf=input('\n enter Faulted Bus No. ->');
while nf<=0 || nf>nbus
fprintf('\n Faulted bus No. must be between 1 & %g\n',nbus)
nf=input('\n enter Faulted Bus No.->');
end
fprintf('\n enter Fault Impedence Zf=R+j*X in')
Zf=input('complex form(for bolted fault enter 0). Zf=');
fprintf('\n')
fprintf('\n Doubleline to ground fault at bus no. %g\n',nf)
a=cos(2*pi/3)+j*sin(2*pi/3);
sctm=[1 1 1;1 a^2 a;1 a a^2]; %symmetrical component transformation
matrix

Z11=Zbus2(nf,nf)*(Zbus0(nf,nf)+3*Zf)/(Zbus2(nf,nf)+Zbus0(nf,nf)+3*Zf);
Ia1=V0(nf)/(Zbus1(nf,nf)+Z11);
Ia2=-(V0(nf)-Zbus1(nf,nf)*Ia1)/Zbus2(nf,nf);
Ia0=-(V0(nf)-Zbus1(nf,nf)*Ia1)/(Zbus0(nf,nf)+3*Zf);
Ia012=[Ia0;Ia1;Ia2];
Ifabc=sctm*I012;
Ifabcm=abs(Ifabc);
Ift=Ifabc(2)+Ifabc(3);
Iftm=abs(Ift);
fprintf('\n TOTAL FAULT CURRENT=%9.4f per unit\n\n',Iftm)
fprintf('Bus voltages during the fault in per unit\n\n')
fprintf('Bus voltage magnitude \n')
fprintf('No. phase a phase b phase c \n')
for n=1:nbus
Vf0(n)=0-Zbus0(n,nf)*Ia0;
Vf1(n)=V0(n)-Zbus1(n,nf)*Ia1;
Vf2(n)=0-Zbus2(n,nf)*Ia2;
Vabc=sctm*[Vf0(n);Vf1(n);Vf2(n)];
Va(n)=Vabc(1);Vb(n)=Vabc(2);Vc(n)=Vabc(3);
fprintf('%5g ',n)
fprintf('%11.4f',abs(Va(n))),fprintf('%11.4f',abs(Vb(n)))
fprintf('%11.4f\n',abs(Vc(n)))
end
end
fprintf('\n 0. Exit the program')
fprintf('\n 1. Continue the program for another Fault')
m=input('\n enter the choice:');
if (m==1)
ff=999;
else
ff=0;
end
end

Output
zdata0=[0 1 0 0.40;0 2 0 0.10;1 2 0 0.30;1 3 0 0.35;2 3 0
0.7125];
>> zdata1=[0 1 0 0.25;0 2 0 0.25;1 2 0 0.125;1 3 0 0.15;2 3 0
0.25];
>> zdata2=zdata1;
>> Zbus0=Zbus(zdata0)

Z =

0 + 0.4000i
0 + 0.1000i
0 + 0.3000i
0 + 0.3500i
0 + 0.7125i

Zbus0 =

## 0 + 0.1820i 0 + 0.0545i 0 + 0.1400i

0 + 0.0545i 0 + 0.0864i 0 + 0.0650i
0 + 0.1400i 0 + 0.0650i 0 + 0.3500i

>> Zbus1=Zbus(zdata1)

Z =

0 + 0.2500i
0 + 0.2500i
0 + 0.1250i
0 + 0.1500i
0 + 0.2500i

Zbus1 =

## 0 + 0.1450i 0 + 0.1050i 0 + 0.1300i

0 + 0.1050i 0 + 0.1450i 0 + 0.1200i
0 + 0.1300i 0 + 0.1200i 0 + 0.2200i

>> Zbus2=Zbus(zdata2)

Z =

0 + 0.2500i
0 + 0.2500i
0 + 0.1250i
0 + 0.1500i
0 + 0.2500i

Zbus2 =

## 0 + 0.1450i 0 + 0.1050i 0 + 0.1300i

0 + 0.1050i 0 + 0.1450i 0 + 0.1200i
0 + 0.1300i 0 + 0.1200i 0 + 0.2200i

>> un(zdata0,zdata1,zdata2,Zbus0,Zbus1,Zbus2)

1.L-G Fault
2.L-L Fault
3.L-L-G Fault
enter the choice:1

## enter Fault Impedence Zf=R+j*X incomplex form(for bolted fault

enter 0). Zf=j*0.1

## Bus voltages during the fault in per unit

Bus voltage magnitude
No. phase a phase b phase c
1 0.6330 1.0046 1.0046
2 0.7202 0.9757 0.9757
3 0.2752 1.0647 1.0647

## 0. Exit the program

1. Continue the program for another Fault
enter the choice:1

1.L-G Fault
2.L-L Fault
3.L-L-G Fault
enter the choice:3

## enter Fault Impedence Zf=R+j*X incomplex form(for bolted fault

enter 0). Zf=j*0.1

## Bus voltage magnitude

No. phase a phase b phase c
1 1.0066 0.5088 0.5088
2 0.9638 0.5740 0.5740
3 1.0855 0.1974 0.1974

Result
Hence a mat lab program to analyses the symmetrical fault of a given power network by
using bus impedance matrix is performed.