Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

Department of Electrical Engineering

Delhi Technological University,


Delhi-110042

Power System Analysis


Laboratory Manual
List of Experiments

1. To compute the bus admittance matrix (Ybus) for a given power


system network.

2. To compute the power-flow solution of a given power system


network using the Gauss-Siedel method.

3. To compute the power-flow solution of a given power system


network using the Newton-Raphson algorithm.

4. To compute the power-flow solution of a given power system


network using the fast-decoupled power-flow algorithm.

5. To compute the optimal dispatch in a given three-generator


system (a) without and (b) with transmission losses.

6. Formation of bus impedance matrix (Zbus) for a given power


system network from scratch.

7. Computation of symmetrical fault analysis in a given power


system network.

8. Determine the critical clearing time for a given single machine


infinite bus system.
EXPERIMENT 1

Aim: To compute the bus admittance matrix Ybus for the small power
system network given below using MATLAB mfile/Python/C++

The branch data / line data for the above network is given below:
From To R X B
bus no. bus no. (p.u) (p.u) (p.u)
1 2 0.02 0.1 0.03
1 3 0.02 0.1 0.03
1 4 0.02 0.1 0.03
2 4 0.02 0.1 0.03
3 4 0.02 0.1 0.03

Theory: In an AC power system network, the relationship between the


injected node currents and the node voltages is given by
Procedure:
(a) Using the method as explained, compute the Ybus for the given power
system network manually.
(b) Write codes given below to build the Ybus from the line / branch data.
Use the following steps:
Step1: Type in the branch data (i.e. R, X and B as given) in a matrix
‘D’. ‘D’ should contain five columns and as many rows as that
in the given
branch data / line data of the given network. The five
columns correspond to „From bus number‟, „To bus number‟, R,
X and B, respectively.
Check if data of B corresponds to Btotal or B1/2.
Step 2: Type the code given below and save it in a MATLAB mfile.
Save the code as amit1 if Amit is your first name (no blank spaces in
between).
Step 3: Debug and run the code to generate Ybus.
Step 4: Check the programme results with the manually calculated
Ybus.

Code in MATLAB mfile:

clc
clear all
nb=4; % nb is number of buses in the network
z=inf(nb,nb);
D=[1 2 0.02 0.1 0.03;1 3 0.02 0.1 0.03;1 4 0.02 0.1 0.03;2 4 0.02 0.1 0.03;3
4 0.02 0.1 0.03]; % Five columns are for ‘From bus’, ‘To bus’, ‘R’, ‘X’
and ‘B’
r=size(D);
rows=r(1);
for i=1:rows
z(D(i,1),D(i,2))=D(i,3)+j*D(i,4);
z(D(i,2),D(i,1))=z(D(i,1),D(i,2));
b(D(i,1),D(i,2))=D(i,5);
b(D(i,2),D(i,1))=b(D(i,1),D(i,2));
end
for i=1:nb
y0(i)=j*sum(b(i,:))/2;
end
for i=1:nb
for m=1:nb
if i~=m
Y(i,m)=-1/z(i,m);
else
Y(i,m)=y0(i)+sum(1./z(i,:));
end
end
end
EXPERIMENT 2

Aim: To carry out power-flow / load-flow of a given power system


network using Gauss-Siedel method

In the above network, all the transmission lines are identical. For each
line, the shunt element is a capacitor with an admittance of ysh=j 0.01
while each series element is an inductor with an impedance of zse=j 0.1.

1. Theory:
2. Procedure: First compute the bus admittance matrix. Check that
Type the code given below for the Gauss-Siedel algorithm in a MATLAB
mfile. Save the code as amit2 if Amit is your first name (no blank spaces in
between). Debug the code and run it to get the final results as:

[ ] [ ]

Code in MATLAB mfile:


clc
clear all
%Data%
slb=1;pvb=1;pqb=1;nb=slb+pvb+pqb;
Y=[-j*19.98 j*10 j*10;j*10 -j*19.98 j*10;j*10 j*10 -j*19.98];
y=abs(Y);phi=angle(Y);
v(1)=1.0;th(1)=0;v(2)=1.05;
Psp(2)=0.6661;Psp(3)=-2.8653;Qsp(3)=-1.2244;
%initial guess for unknown theta and v %
th(2)=0;v(3)=1.0;th(3)=0;
m=180/pi;
%Program for Gauss Siedel algorithm%
err=1.0; t=0; % 't' is the number of iterations of the algorithm
while err>1e-4
for i=2:3
Px(i)=0;Qx(i)=0;
for k=1:3
Px(i)=Px(i)+v(i)*v(k)*y(i,k)*cos(th(i)-th(k)-phi(i,k));
Qx(i)=Qx(i)+v(i)*v(k)*y(i,k)*sin(th(i)-th(k)-phi(i,k));
end
end
for i=1:3
V(i)=v(i)*(cos(th(i))+j*sin(th(i)));
end
for i=2:3
vint(i)=0;
for k=1:3
if k~=i
vint(i)=vint(i)+Y(i,k)*V(k);
else
end
end
end
for i=2:nb
if i<=(slb+pvb)
V(i)=(((Psp(i)-j*Qx(i))/conj(V(i))-vint(i))/Y(i,i));
else
V(i)=(((Psp(i)-j*Qsp(i))/conj(V(i))-vint(i))/Y(i,i));
end
end
for i=2:nb
if i<=(slb+pvb)
th(i)=angle(V(i));
else
v(i)=abs(V(i));
th(i)=angle(V(i));
end
end
delp=Psp-Px;
delq=Qsp-Qx;
delpqx=[delp'; delq'];
err=abs(max(delpqx));
t=t+1;
end
[v' m*th']
EXPERIMENT 3

Aim: To compute the power-flow solution of the given power system


network using the Newton-Raphson algorithm.

For the above network, all the transmission lines are identical. In the
equivalent-pi representation of each line, the series impedance equals zse =
j 0.1 while each of the shunt admittances (equal on both sides) equal ysh = j
0.01. This gives the bus admittance matrix Ybus as

Theory: In the above 3-bus system, there are three buses – the first bus is
the slack bus, the second bus is a PV bus and the third bus is a PQ bus.
Hence the unknown variables to be computed are and . Hence, the
Newton-Raphson algorithm for power-flow of the above three bus system
is given by

where

and ∆f on the right-hand side is given by

Procedure: Type the code given below for the Newton-Raphson algorithm
in a MATLAB mfile. Save the code as amit3 if Amit is your first name (no
blank spaces in between). Debug the code and run it to get the final results
as:

[ ] [ ]
Code in MATLAB mfile:
clc
clear all
%Data%
slb=1;pvb=1;pqb=1;nb=slb+pvb+pqb;
Y=[-j*19.98 j*10 j*10;j*10 -j*19.98 j*10;j*10 j*10 -j*19.98];
y=abs(Y);phi=angle(Y);
v(1)=1.0;th(1)=0;v(2)=1.05;
Psp(2)=0.6661;Psp(3)=-2.8653;Qsp(3)=-1.2244;
%initial guess for unknown theta and v %
th(2)=0;v(3)=1.0;th(3)=0;
cc=180/pi;
THV=[0;0;1];
%Program for Newton-Raphson algorithm%
err=1.0; t=0; % ‘t’ is number of iterations of the algorithm
while err>1e-4
for i=(slb+1):nb
Px(i)=0;Qx(i)=0;
for k=1:3
Px(i)=Px(i)+v(i)*v(k)*y(i,k)*cos(th(i)-th(k)-phi(i,k));
Qx(i)=Qx(i)+v(i)*v(k)*y(i,k)*sin(th(i)-th(k)-phi(i,k));
end
end
% formation of Jacobian 'J' %
% P-theta jacobian %
JPth(1,1)=-Qx(2)-(((v(2))^2)*abs(Y(2,2))*sin(angle(Y(2,2))));
JPth(1,2)=v(2)*v(3)*abs(Y(2,3))*sin(th(2)-th(3)-(angle(Y(2,3))));
JPth(2,1)=v(3)*v(2)*abs(Y(3,2))*sin(th(3)-th(2)-(angle(Y(3,2))));
JPth(2,2)=-Qx(3)-(((v(3))^2)*abs(Y(3,3))*sin(angle(Y(3,3))));
% P-v jacobian %
JPv(1,1)=v(2)*abs(Y(2,3))*cos(th(2)-th(3)-(angle(Y(2,3))));
JPv(2,1)=(Px(3)/v(3))+(v(3)*abs(Y(3,3))*cos(angle(Y(3,3))));
% Q-theta jacobian %
JQth(1,1)=-v(3)*v(2)*abs(Y(3,2))*cos(th(3)-th(2)-(angle(Y(3,2))));
JQth(1,2)=Px(3)-(((v(3))^2)*abs(Y(3,3))*cos(angle(Y(3,3))));
% Q-v jacobian %
JQv(1,1)=(Qx(3)/v(3))-(v(3)*abs(Y(3,3))*sin(angle(Y(3,3))));
J=[JQth JQv;JPth JPv];
for p=1:pqb
delq(p)=Qsp(p+slb+pvb)-Qx(p+slb+pvb);
end
for p=1:(pvb+pqb)
delp(p)=Psp(p+slb)-Px(p+slb);
end
delPQ=[delq';delp'];
delthv=THV+(inv(J)*delPQ);
for p=(slb+1):nb
th(p)=delthv(p-1);
end
for p=(slb+pvb+1):nb
v(p)=delthv(p+pqb-slb);
end
THV=delthv;
err=max(abs(delPQ))
t=t+1;
end
[v' cc*th']
EXPERIMENT 4

Aim: To compute the power-flow solution of the given power system


network using the fast-decoupled power-flow algorithm.

For the above network, all the transmission lines are identical. In the
equivalent-pi representation of each line, the series impedance equals zse =
j 0.1 while each of the shunt admittances (equal on both sides) equal ysh = j
0.01. This gives the bus admittance matrix Ybus as

Theory: The advantage of the fast-decoupled power-flow algorithm is that


the Jacobian matrices are constants. Hence, their inverses are precalculated
and stored before the iterative loop starts. Since the usually large Jacobian
matrices are not required to be inverted in every iteration, time taken by
each iteration is very less. The form of the fast-decoupled power-flow
algorithm is given by

where

In the above 3-bus system, there are three buses – the first bus is the slack
bus, the second bus is a PV bus and the third bus is a PQ bus. Hence the
unknown variables to be computed are and . Hence, the fast-
decoupled power-flow algorithm for the above three bus system is given by

And

Procedure: Type the code given below for the fast-decoupled power-
flow algorithm in a MATLAB mfile. Save the code as amit4 if Amit is
your first name (no blank spaces in between). Debug the code and run it
to get the final results as
[ ] and

Code in MATLAB mfile:


clc
clear all
%Data%
slb=1;pvb=1;pqb=1;nb=slb+pvb+pqb;
Y=[-j*19.98 j*10 j*10;j*10 -j*19.98 j*10;j*10 j*10 -j*19.98];
y=abs(Y);phi=angle(Y);
B=imag(Y);
v(1)=1.0;th(1)=0;v(2)=1.05;
Psp(2)=0.6661;Psp(3)=-2.8653;Qsp(3)=-1.2244;
%initial guess for unknown theta and v %
th(2)=0;v(3)=1.0;th(3)=0;
cc=180/pi;
TH=[0;0];
V=1;
%jacobian for P-theta %
Jpth_old=-B(slb+1:end,slb+1:end);Jpth=inv(Jpth_old); % inverse of matrix
precalculated and stored before iteration loop starts
%jacobian for Q-v %
Jqv_old=-B(slb+pvb+1:end,slb+pvb+1:end);Jqv=inv(Jqv_old); % inverse of
matrix precalculated and stored before iteration loop starts
%Program for Newton-Raphson algorithm%
err=1.0; t=0; % ‘t’ is number of iterations of the algorithm
while err>1e-4
for i=(slb+1):nb
Px(i)=0;
for k=1:nb
Px(i)=Px(i)+v(i)*v(k)*y(i,k)*cos(th(i)-th(k)-phi(i,k));
end
end
% P-theta loop %
for p=1:(pvb+pqb)
delp(p)=(Psp(p+slb)-Px(p+slb))/v(p+slb);
end
TH=TH+(Jpth*delp');
for p=(slb+1):nb
th(p)=TH(p-1);
end
% Q-v loop %
for i=(slb+pvb+1):nb
Qx(i)=0;
for k=1:nb
Qx(i)=Qx(i)+v(i)*v(k)*y(i,k)*sin(th(i)-th(k)-
phi(i,k));
end
end
for p=1:pqb
delq(p)=(Qsp(p+slb+pvb)-Qx(p+slb+pvb))/v(p+slb+pvb);
end
V=V+(Jqv*delq');
for p=1:pqb
v(slb+pvb+p)=V(p);
end
delPQ=[delp';delq'];
err=max(abs(delq))
t=t+1;
end
[v' cc*th']
EXPERIMENT 5

Aim: To compute the optimal dispatch in the three-generator system


given below (a) without and (b) with transmission losses.

The fuel cost functions of the above three generators are given as
$/hr
$/hr
$/hr
The total active power demand is 850 MW.
The transmission losses are given as
MW.
Theory: (a) Without transmission loss, the optimal dispatch rule is given
as

where

From the three generators‟ fuel cost functions, the above equations can
be written in matrix form as

[ ][ ] [ ]

The above equations are linear, of the form and can be


solved very easily using .

(b) With transmission losses, the optimal dispatch rule is given as


where , i = 1, 2…3.

Thus, after putting values of the parameters given for the system, the
first equation becomes i.e. , which can be

written as

or, .
The above equation pertains to generating unit 1. Similarly, the
equations for generating units 2 and 3 can be written. After putting all
three equations in the matrix form, we get,
[ ][ ]

[ ]

It can be observed that with transmission losses included, the above


equations have become nonlinear, unlike in part (a). They have now to
be iteratively solved after assuming an initial value of . This method is
known as the lambda iteration method. As a good approximation, we can
choose the value of which was obtained in part (a) i.e. without
transmission losses.
Procedure: Type the code given below in a MATLAB mfile. Save the
code as amit5 if Amit is your first name (no blank spaces in between).
Debug the code and run it to get the final results.
Code in MATLAB mfile:
clc
clear all
a=[0.003124 0 0 -1;0 .00388 0 -1;0 0 .00964 -1;1 1 1 0];
pd=850; % pd stands for total demand
b=[-7.92;-7.85;-7.97;pd];
x=inv(a)*b;
lam=x(end); % lam stands for lambda
err=100;t=0;
while err>=1e-1
a1=[0.003124+0.00006*lam 0 0;0 0.00388+0.00018*lam 0;0 0
0.00964+0.00024*lam];
b1=[lam-7.92;lam-7.85;lam-7.97];
pg=inv(a1)*b1;
ploss=0.00003*(pg(1)^2)+0.00009*(pg(2)^2)+0.00012*(pg(3)^2);
if sum(pg)-ploss-pd>=0
lam=lam-0.01;
else
lam=lam+0.01;
end
err=abs(sum(pg)-ploss-pd)
t=t+1
end
EXPERIMENT 6

Aim: To compute the bus impedance matrix from scratch for the power
system network given below.

For the above network, take , , ,


, .

Theory:
The Ybus /Zbus matrix constitutes the models of the passive portions of
the power network. The impedance matrix is a full matrix and is most
useful for short circuit studies. An algorithm for formulating [Z bus] is
described in terms of modifying an existing bus impedance matrix
designated as [Zbus]old. The modified matrix is designated as [Zbus]new.
The network consists of a reference bus and a number of other buses.
When a new element having self impedance Zb is added, a new bus may
be created (if the new element is a tree branch) or a new bus may not be
created (if the new element is a link). Each of these two cases can be
subdivided into two cases so that Zb may be added in the following ways
or modifications:
1. Adding Zb from a new bus to reference bus.
2. Adding Zb from a new bus to an existing bus.
3. Adding Zb from an existing bus to reference bus.
4. Adding Zb between two existing buses.

Type 1 modification:

In type 1 modification, an impedance Zb is added between a new bus p


and reference bus as shown in Figure 1

Figure 1. Type 1 modification of Zbus


Let the current through bus p be Ip, then the voltage across the bus p is

given by, Vp = Ip Zb

The potential at other buses remains unaltered and the system equations
can be written as,
Type 2 modification:
In type 2 modification, an impedance Zb is added between a new bus p
and an existing bus k as shown in Figure 2. The voltages across the bus k
and p can be expressed as,
Vk(new) = Vk + Ip Zkk
Vp = Vk(new) + Ip Zp
= Vk + Ip(Zb + Zkk)
where, Vk is the voltage across bus k before the addition of impedance
Zb
Zkk is the sum of all impedance connected to bus k.

Figure 2.Type 2 Modification of Zbus


The system of equations can be expressed as,
Type 3 Modification:

In this modification, an impedance Zb is added between a existing bus k


and a reference bus. Then the following steps are to be followed:
1. Add Zb between a new bus p and the existing bus k and the
modifications are done as in type 2.
2. Connect bus p to the reference bus by letting Vp = 0.
3. To retain the symmetry of the Bus Impedance Matrix, network
reduction technique can be used to remove the excess row or
column.

Type 4 Modification:

In this type of modification, an impedance Zb is added between two


existing buses j and k as shown in Figure 3. From Figure 3, the relation
between the voltages of bus k and j can be written as,
Vk – Vj = IbZb (3)

Figure 3.Type 4 Modification of Zbus


The voltages across all the buses connected to the network changes due
to the addition of impedance Zb and they can be expressed as,

On solving the Equations (3) and (4), the system of equations can be
rewritten as,

Where Zbb = Zjj + Zkk – 2 Zjk + Zb

Procedure for formation of Zbus matrix:


Step1: Number the nodes of the given network, starting with those nodes
at the ends of branches connected to the reference node.
Step2: Start with a network composed of all those
branches connected to the reference node.
Step3: Add a new node to the ith node of the existing network.
Step4: Add a branch between ith and jth nodes.
Continue until all the remaining branches are
connected.

Procedure: Type the code given below for the Z bus formation in a
MATLAB mfile. Save the code as amit6 if Amit is your first name (no
blank spaces in between).

Sample problem:
Form bus impedance matrix using building algorithm:

Solution:
Step1: Add an element between ref (0) bus and a new bus (1)

Z = [j0.2]
Step2: Add an element between existing bus (1) to a new bus (2).

Step3: Add an element between existing (2) Bus to a ref (0) Bus.

Result:
The bus impedance matrix using building algorithm for the given
system was formed and the results were verified using MATLAB
program.
Matlab Code (With Kron’s Reduction)
clear all
Zbus = [0];
Quit = 0;
i = 0;
while Quit==0

Case = input('Which case is to be implemented \n 1. New bus to


reference bus \n 2. Existing bus to new bus \n existing bus to reference
bus 4. between two existing buses\n');
if Case == 1
if i == 0
Zb = input('Enter the value of impedance = ');
Zbus = [Zb]
i=i+1;

else if i>0
Zb = input('Enter the value of impedance = ');
ord = length(Zb1);
for d = 1:ord+1
for e = i:ord+1
if d<=ord && e<=ord
Zbus1(d,e) = Zb1(d,e);
end
if d==ord+1 && e==ord+1
Zbus1(d,e)=Zb;
end
if d==ord+1 && d~=e || e==ord+1 && d~=e
Zbus1(d,e)= 0;
end

end
end
end
Zbus = [Zbus1]
end
end
if Case == 2
Z_new = input('Enter the value of impedance for new bus = ');
m = length(Zbus);
for a=1:m
for b=1:m
Z_temp(a,b) = Zbus(a,b);
end
end
for c = 1:m
Z_temp(c,m+1) = Zbus(c,m);
Z_temp(m+1,c) = Zbus(c,m);
Z_temp(m+1,m+1) = Zbus(m,m)+Z_new;
end
Zbus = [Z_temp]
i = i+1;
end
if Case == 3
Z_new = input('Enter the value of impedance for new bus = ');
m = length(Zbus);
for a=1:m
for b=1:m
Z_temp(a,b) = Zbus(a,b);
end
end
for c = 1:m
Z_temp(c,m+1) = Zbus(c,m);
Z_temp(m+1,c) = Zbus(c,m);
Z_temp(m+1,m+1) = Zbus(m,m)+Z_new;
end
fprintf('Zbus before Kron Reduction:\n')
Zbus = [Z_temp]
m = length(Zbus);
for i=1:m-1
for k = 1:m-1
Z(i,k) = Zbus(i,k) - Zbus(i,m)*Zbus(m,k))/Zbus(m,m));
end
end
fprintf('Zbus after Kron Reduction:\n')
Zbus = [Z]
end
if Case == 4
Z1 = input('Enter the value of impedance = ');
j = input('Enter the value of bus j = ');
k = input('Enter the value of bus k = ');
m = length(Zbus);
for a=1:m
for b=1:m
Z_temp(a,b) = Zbus(a,b);
end
end
for c = 1:m
Z_temp(c,m+1) = Zbus(c,j)-Zbus(c,k);
Z_temp(m+1,c) = Z_temp(c,m+1);
end
Z_temp(m+1,m+1) = Z1+Zbus(j,j)+Zbus(k,k)-2*Zbus(j,k);
fprintf('Zbus before Kron Reduction:\n')
Zbus = [Z_temp]
m = length(Zbus);
for i=1:m-1
for k = 1:m-1
Z(i,k) = Zbus(i,k) - Zbus(i,m)*Zbus(m,k))/Zbus(m,m));
end
end
fprintf('Zbus after Kron Reduction:\n')
Zbus = [Z]
end
Quit = input('Do u want to quit = ');
Zb1 = [Zbus];
end
EXPERIMENT 7

Aim: To carry out symmetrical fault analysis in a given power system


network using MATLAB.

THEORY:
The short circuit problem essentially consists of determining the
steady state solution of a linear network with a balanced three-phase
sinusoidal excitation. The linear network comprises of a major sub
network fault. The transmission network and the generator network
consist of an interconnection of a three-phase balanced component. If
the lines are assumed to be completely transposed the impedance
matrix for a three-phase transmission line is of form
Zs Zm Zm 
Z Zs Z m 
 m
 Z m Zm Z s 

This type of symmetry is called complete symmetry. For symmetrical


fault two types of faults are there three-phase to ground fault and
three-phase fault. In this type of network we have a three-phase
network with balanced three-phase components and balanced
excitation. Both negative and zero sequence networks are not needed
for symmetrical fault calculation.

Procedure: Type the code given below for the Symmetrical Fault
analysis in a MATLAB mfile. Save the code as amit7 if Amit is your
first name (no blank spaces in between).
MATLAB mfile code

For Three-phase fault.


Clear all

function done=threephfault(nb,ng,nl,nt)
%formation of positive sequence Ybus
Yp=Ypositive(nb,ng,nl,nt);
%formation of Zbus
Zbus=inv(Yp);
%initialisation of all voltage to 1 pu at an angle zero asuming no loading
v0_matrix=ones(nb);
v0=v0_matrix(:,1); %creates a coulumn vector of voltages with 1 pu voltage
%calculation of fault current
fid=fopen('faultdata.txt','r');
b=textread('faultdata.txt');
fclose(fid);
bus=b(1);
imp=b(3);
fault_current=v0(bus)/((Zbus(bus,bus)+imp)*j);
%post fault voltage calculations
for i=1:length(v0)
vf(i)=v0(i)-Zbus(i,bus)*fault_current*j;
end
vf_mag=abs(vf);
vf_phase=angle(vf);

%calculation of post fault flows in generators, transformers and line


%reading of elements and classifying them as lines, transformers or
%generators
%the convention for the status of elements is as follows
% 1=lines
% 2=generators
% 3=transformers without phase shift
% 0=transformers with phase shift
fid=fopen('linedata.txt','r');
bb=textread('linedata.txt');
fclose(fid);
x=bb(:,1);
y=bb(:,2);
zp=bb(:,3);
ele_num=1:length(x);
start_bus=x;
end_bus=y;
for i=1:length(x)
status(i)=1;
end
for i=1:nl

poslineflow(i)=(vf_mag(x(i))*(cos(vf_phase(x(i)))+sin(vf_phase(x(i)))*j)-
vf_mag(y(i))*(cos(vf_phase(y(i)))+sin(vf_phase(y(i)))*j))/(zp(i)*j);
neglineflow(i)=(vf_mag(y(i))*(cos(vf_phase(y(i)))+sin(vf_phase(y(i)))*j)-
vf_mag(x(i))*(cos(vf_phase(x(i)))+sin(vf_phase(x(i)))*j))/(zp(i)*j);
end
poslineflow_mag=abs(poslineflow);
poslineflow_phase=angle(poslineflow);
neglineflow_mag=abs(neglineflow);
neglineflow_phase=angle(neglineflow);

fid=fopen('transformerdata.txt','r');
bb=textread('transformerdata.txt');
fclose(fid);
x=bb(:,1);
y=bb(:,3);
z=bb(:,5);
hv=bb(:,2);
lv=bb(:,4);
hvbuses=x;
ele_num=1:length([ele_num y']);
start_bus=[start_bus' x'];
end_bus=[end_bus' y'];
for i=1:length(x)
if (hv(i)==1 & lv(i)==2) | (hv(i)==2 & lv(i)==1) | (hv(i)==0 &
lv(i)==2) | (hv(i)==2 & lv(i)==0)
status(i+nl)=0;
else
status(i+nl)=3;
end
end
s=length(status);
for i=1:nt

postransflow(i)=(vf_mag(x(i))*(cos(vf_phase(x(i)))+sin(vf_phase(x(i)))*j)-
vf_mag(y(i))*(cos(vf_phase(y(i)))+sin(vf_phase(y(i)))*j))/(z(i)*j);

negtransflow(i)=(vf_mag(y(i))*(cos(vf_phase(y(i)))+sin(vf_phase(y(i)))*j)-
vf_mag(x(i))*(cos(vf_phase(x(i)))+sin(vf_phase(x(i)))*j))/(z(i)*j);
end
postransflow_mag=abs(postransflow);
postransflow_phase=angle(postransflow);
negtransflow_mag=abs(negtransflow);
negtransflow_phase=angle(negtransflow);

fid=fopen('gendata.txt','r');
bb=textread('gendata.txt');
fclose(fid);
x=bb(:,1);
z=bb(:,2);
ele_num=1:length([ele_num y']);
%length(ele_num)
start_bus=[start_bus x'];
for i=1:length(x)
temp(i)=nb+1; %nb+1 is taken as the code for the reference bus i.e
ground
end
end_bus=[end_bus temp];
for i=1:ng
status(s+i)=2;
end
for i=1:ng

posgenflow(i)=(vf_mag(x(i))*(cos(vf_phase(x(i)))+sin(vf_phase(x(i)))*j)-
1)/(z(i)*j);
neggenflow(i)=-
(vf_mag(x(i))*(cos(vf_phase(x(i)))+sin(vf_phase(x(i)))*j)-1)/(z(i)*j);
end
%posgenflow
%neggenflow
posgenflow_mag=abs(posgenflow);
posgenflow_phase=angle(posgenflow);
neggenflow_mag=abs(neggenflow);
neggenflow_phase=angle(neggenflow);

posflow_mag=[poslineflow_mag postransflow_mag posgenflow_mag];


posflow_phase=[poslineflow_phase postransflow_phase posgenflow_phase];
negflow_mag=[neglineflow_mag negtransflow_mag neggenflow_mag];
negflow_phase=[neglineflow_phase negtransflow_phase neggenflow_phase];
status
%correction for star-delta connected transformers
for i=1:(nb+1)
M(i)=1000; %phase adjusting parameter of each bus
end
M(1)=0;
k=1; %running variable for element number
kk=find(M==1000);
while length(kk)~=0
flag=k;
%k
ib=start_bus(k);
jb=end_bus(k);

if M(ib)==1000
if M(jb)==1000
k=k+1;
end
if M(jb)~=1000
if status(k)~=0
M(ib)=M(jb);
k=k+1;
end
temp=find(hvbuses==ib);
if k<=(length(ele_num))& k==flag
if status(k)==0
if (length(temp)==0)
M(ib)=M(jb)-1;
k=k+1;
else
M(ib)=M(jb)+1;
k=k+1;
end
end
end
end
kk=find(M==1000);
if length(kk)==0
%M
break;
end
if length(kk)~=0
if k<=length(ele_num)
%k=k+1;
%M
continue;
end
if k>length(ele_num)
k=1;
%M
continue;
end
end
end

if M(ib)~=1000
if M(jb)~=1000
k=k+1;
end
if M(jb)==1000
if status(k)~=0
M(jb)=M(ib);
k=k+1;
end
temp=find(hvbuses==jb);
if k<=(length(ele_num)) & k==flag
if status(k)==0
if (length(temp)==0)
M(jb)=M(ib)-1;
k=k+1;
else
M(jb)=M(ib)+1;
k=k+1;
end
end
end
end
kk=find(M==1000);
if length(kk)==0
%M
break;
end
if length(kk)~=0
if k<=length(ele_num)
%k=k+1;
%M
continue;
end
if k>length(ele_num)
k=1;
%M
continue;
end
end
end
end

fid=fopen('faultdata.txt','r');
b=textread('faultdata.txt');
fclose(fid);
FB=b(1);
flag=M(FB);
for i=1:(nb+1)
M(i)=M(i)-flag;
end
M
%correction of voltage and flows
value=input('Enter the phase shift that you desire in degrees. The choice
that you have are 30 and 90 degrees.');
for i=1:nb
vf_phase(i)=vf_phase(i)+M(i)*(value*pi/180);
end
for i=1:length(posflow_phase)
posflow_phase(i)=posflow_phase(i)+M(start_bus(i))*(value*pi/180);
negflow_phase(i)=negflow_phase(i)+M(end_bus(i))*(value*pi/180);
end
%negflow_mag
%negflow_phase

%data entry into output file


fid=fopen('output.txt','w');
fprintf(fid,'The Ybus\n\n');
for i=1:nb
for k=1:nb
fprintf(fid,'%-10.3f\t',Yp(i,k));
end
fprintf(fid,'\n\n');
end
fprintf(fid,'The Zbus\n\n');
for i=1:nb
for k=1:nb
fprintf(fid,'%-10.3f\t',Zbus(i,k));
end
fprintf(fid,'\n\n');
end
fprintf(fid,'Fault current\n\n');
fprintf(fid,'Magnitude Angle(radians)\n');
fprintf(fid,'%-10.3f %-10.3f\n\n',abs(fault_current),angle(fault_current));
fprintf(fid,'Post Fault Voltages\n\n');
fprintf(fid,'Bus-number Magnitude Angle(radians)\n');
for i=1:length(vf)
fprintf(fid,'%-10.3f %-10.3f %-10.3f\n',i,vf_mag(i),vf_phase(i));
end
fprintf(fid,'\n\n');
fprintf(fid,'Post fault flows\n\n');
fprintf(fid,'The extra bus represents the reference bus\n');
fprintf(fid,'Start-bus End-bus Magnitude Phase\n');
fprintf(fid,'This represents the I to J flows\n\n');
for i=1:length(posflow_mag)
fprintf(fid,'%-10.3f %-10.3f %-10.3f %-
10.3f\n',start_bus(i),end_bus(i),posflow_mag(i),posflow_phase(i));
end
fprintf(fid,'\n\n');
fprintf(fid,'This represents the J to I flows\n\n');
fprintf(fid,'Start-bus End-bus Magnitude Phase\n');
kk=find(end_bus==(nb+1));
for i=1:length(negflow_mag)
test=find(kk==i);
if length(test)==0
fprintf(fid,'%-10.3f %-10.3f %-10.3f %-
10.3f\n',end_bus(i),start_bus(i),negflow_mag(i),negflow_phase(i));
end
end
fprintf(fid,'\n\n');
fclose(fid);

done=1;
EXPERIMENT 8

Aim: To determine the critical clearing time for the single machine
infinite bus system given below.

The above system comprises a thermal generating station consisting


of four 555 MVA, 24 kV, 60 Hz generating units supplying power to
an infinite bus through two transmission circuits. All network
reactances shown in the diagram are in per unit on 2220 MVA, 24 kV
base.
The initial system operating condition is: P = 0.9 p.u, Q = 0.436,
| | p.u.
Generators are modelled as a single equivalent generator represented
by the classical model with parameters as:
p.u, H = 3.5 secs.
Circuit 2 (transmission line 2) experiences a bolted three-phase fault
at „F‟, with the fault cleared by isolating Circuit 2.

Theory: The dynamic equation relating the rotor angle and the
accelerating power is given by the nonlinear differential equation
(swing equation) given as
For numerical solution of the swing equation, the above second order
differential equation is resolved into two first order differential
equations given as

Numerical solution of differential equation by Euler method:

A first order differential equation of the form with


at can be solved using the Euler method. We should
take | | seconds for numerical accuracy.
System modelling:

With the generator represented by the classical model, the system


equivalent is given as

The reduced equivalent circuits representing the three system


conditions (i) prefault (before fault), (ii) during fault and (iii) postfault
are shown below in diagrams (a), (b) and (c), respectively.
Thus, we will be solving the two first order simultaneous differential
equations again given below

during the two time periods (i) t0 to t0+tc and (ii) t0+tc to tf where
„t0' is the time instant at which the fault occurs, „tc‟ is the time at
which the fault is cleared (clearing time) and „tf‟ is the final time
instant up to which we are interested in finding the solution.
However, during the time interval (i) t0 to t0+tc, Pmax = 0 while
during (ii) t0+tc to tf, Pmax = 1.1024 p.u, as observed from diagrams
(b) and (c), respectively.
Procedure: Type the code given below for the fast-decoupled power-
flow algorithm in a MATLAB mfile. Save the code as amit8 if Amit
is your first name (no blank spaces in between). Debug the code and
run it (by varying „tc‟) to get the critical clearing time tcrit =0.087 secs.

MATLAB CODE:
clc
clear all
p=0.9;q=0.436;et=1;pm=p;
xddash=0.3;xt=0.15;xl1=0.5;xl2=0.93;xleq=(xl1*xl2)/(xl1+xl2);
alpha=160*pi/180;
i1=(p-j*q)/conj(et);
eb=et-j*(xt+xleq)*i1;
edash=et+j*xddash*i1;
% pre fault analysis
del0=angle(edash)-angle(eb) % intial or prefault value of delta
xlbf=xleq+xt+xddash;xldf=xt+xddash;xlaf=xl1+xt+xddash;
tc=0.088;t0=1;tfinal=5;delt=0.001;
n0=t0/delt;arr1=linspace(t0,t0+tc,100);n1=length(arr1);delt1=tc/100;
arr2=linspace(t0+tc,tfinal,10000);n2=length(arr2);delt2=(tfinal-t0-
tc)/10000;
%initial conditions for differential equations
del1(1)=del0;delw1(1)=0;H=3.5;
for i=1:n1-1
del1(i+1)=del1(i)+377*delw1(i)*delt1;
delw1(i+1)=delw1(i)+(pm/(2*H))*delt1;
% during fault from t0 to t0+tc, pe=0
end
del2(1)=del1(end);delw2(1)=delw1(end);
for i=1:n2-1
del2(i+1)=del2(i)+377*delw2(i)*delt2;
peaf=abs(edash)*abs(eb)*sin(del2(i+1))/xlaf;
delw2(i+1)=delw2(i)+((pm-peaf)/(2*H))*delt2;
% during fault from t0+tc to t0+tc+5, pe≠0
end
delin=del0*ones(1,n0);
del=[delin del1 del2]*180/pi;
t1=(0:n0-1)*delt;t2=t1(end)+(0:n1-1)*delt1;t3=t2(end)+(0:n2-1)*delt2;
t=[t1 t2 t3];
plot(t,del),grid
References
1. Power System Analysis by “Bergen and Vittal”, Pearson.
2. Power System Analysis (McGraw-Hill Series in Electrical and
Computer Engineering) by “Stevenson and Grainger”.
3. Power System Analysis and design by “Glover and Sarma”,
Cengage.
4. Power Generation Operation and Control by “Wood and
Wollenberg”, John Wiley.
5. Power System Stability and Control by “Prabha Kundur”, TMH
5. Modern Power System Analysis by “D.P. Kothari and I Nagrath”,
TMH

You might also like