Professional Documents
Culture Documents
PRACTICAL FILE
SUBMITTED TO : SUBMITTED BY :
Mr. Kuldeep Singh Siddartha Aggarwal
Assistant professor 2K20/EE/266
Department of EE, DTU
INDEX
Aim: To compute the bus admittance matrix Ybus for the small power system network given
below using MATLAB.
The branch data / line data for the above network is given below:
1 2 0.004 0.0533 0
4 5 0.006 0.08 0
Theory:
In an AC power system network, the relationship between the injected node currents and the
node voltages is given by
I = Ybus V
Where,
I= vector of injected node currents, Ybus = Bus admittance matrix,
Procedure:
1. Using the method as explained, compute the Ybus for the given power system network
manually.
2. Write codes given below to build the Ybus from the line / branch data. Use the
following steps:
a. 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.
b. Type the code and save it in a MATLAB m file.
c. Debug and run the code to generate Ybus.
d. Check the program results with the manually calculated Ybus.
e. Manually computed matrix:
MATLAB Code:
14 BUS NETWORK
Line Charging
Line Number From Bus To Bus Resistance Reactance Susceptance
(p.u) (p.u) (p.u)
12 6 12 0.12291 0.25581 0
13 6 13 0.06615 0.13027 0
14 7 8 0 0.17615 0
15 7 9 0 0.11001 0
16 9 10 0.03181 0.0845 0
17 9 14 0.12711 0.27038 0
18 10 11 0.08205 0.19207 0
19 12 13 0.022092 0.19988 0
20 13 14 0.17093 0.34802 0
CODE
AIM: To carry out power-flow / load-flow of a given power system network using Gauss-Seidel
method.
CIRCUIT DIAGRAM:
THEORY:
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. Consider Case I of the power flow problem: given V1,S2,S3,...,Sn, find
S1,V2,V3,...,Vn.
Note: If we know V1,V2,...,Vn we can solve for S1 explicitly using (10.3a). Since we already do
know V1, it only remains to find V2,V3,...,Vn. These n-1 unknowns may be found from the n-1
equations of (10.3b). Thus, the heart of the problem is the solution of n-1 implicit equations in
the unknown V2,V3,...,Vn, where V1 and S2,S3,...,Sn are known. Equivalently, taking complex
conjugates we can get
We now rearrange (10.6) in a form in which a solution by iteration may be attempted. It should
be noted that there are alternative ways of setting up the problem.
CODE:
OUTPUT:
RESULT: The program was successfully executed in MATLAB for the given power system
network using Gauss-Seidel method.
EXPERIMENT-3
Siddartha Aggarwal (2K20/EE/266)
AIM: To compute the power-flow / load-flow solution of the given power system network using
Newton-Raphson method.
THEORY:
For the above network, all the transmission lines are identical. In the equivalent-pi representation
of each line, the series impedance equals zse = 0.1 while each of the shunt admittances (equal on
both sides) equal ysh = j0.01. This gives the bus admittance matrix Ybus as
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 𝝷2, 𝝷3 and V3 . Hence, the Newton-Raphson algorithm for power-flow of
the above three bus system is given by
where
RESULT: The program was successfully executed in MATLAB for the given power system
network using Newton-Raphson method.
EXPERIMENT- 4
Siddhartha Aggarwal (2K20/EE/266)
AIM: To compute the power-flow solution of the given power system network using the
fast-decoupled power-flow algorithm.
CIRCUIT DIAGRAM:
THEORY:
For the above network, all the transmission lines are identical. In the
equivalent-pi representation of each line, the series impedance equals zse = j0.1 while each of the
shunt admittances (equal on both sides) equal ysh = j0.01. This gives the bus admittance matrix
Ybus as
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
CODE:
OUTPUT:
RESULT: The program was successfully executed in MATLAB for the given power system
network using fast-decoupled power-flow method
EXPERIMENT-5
Siddartha Aggarwal (2K20/EE/266)
AIM: To compute the bus impedance matrix of a given power system network in MATLAB
using Z bus building algorithm.
THEORY:
For the above network, take z1 = j1.0, z2 = j1.25, z3 = j0.1, z4 = j0.2, z5 = j0.1
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 [Zbus] is described in terms of modifying an existing bus impedance matrix
designated as [Zbus]old. The modified matrix isdesignated as [Zbus]new. The network consists
of a reference bus and a number ofother 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 busp 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.
Type 3 Modification
In this modification, an impedance Zb is added between an 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 modificationsare 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
On solving the Equations (3) and (4), the system of equations can be rewritten as,
CODE:
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
3. existing bus to refernce bus \n
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
endend Zbus=[Zbus1]
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 end fprintf('Zbus after kron \n') Zbus=[Z]
if Case == 4
Z1 = input('Enter the value of impedance ='); j= input('Enter th evalue 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
end Zbus=[Z]
fprintf('Zbus after kron Reduction: \n')
Quit = input('do u want to quit= '); Zb1 = [Zbus];
end
OUTPUT:
RESULT: The bus impedance matrix using building algorithm for the given system was formed
and the results were verified using MATLAB program.
EXPERIMENT-6
Siddartha Aggarwal (2K20/EE/266)
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 subnetwork 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:
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.
CODE:
SINGLE LINE - GROUND FAULT
function done=slgfault(nb,ng,nl,nt)
%formation of positive sequence Ybus Yp=Ypositive(nb,ng,nl,nt);
%formation of zero sequence Ybus Yz=Yzero(nb,ng,nl,nt);
%formation of positive and negative sequence Zbus Zp=inv(Yp);
Zn=Zp;
%formation of zero sequence Zbus check=diag(Yz);
k=find(check==0) if length(k)==0
Zz=inv(Yz); end
if length(k)~=0 Zz=pinv(Yz);
end
%preparation of pre-fault voltage vectors xxx=ones(nb);
vp0=xxx(:,1); yyy=zeros(nb); vn0=yyy(:,1); vz0=vn0;
%calculation of fault current fid=fopen('faultdata.txt','r'); b=textread('faultdata.txt'); fclose(fid);
bus=b(1);
imp=b(3); ifp=vp0(bus)/((Zp(bus,bus)+Zn(bus,bus)+Zz(bus,bus)+3*imp)*j); ifn=ifp;
ifz=ifp;
%post fault voltage calculations for i=1:nb
vpf(i)=vp0(i)-Zp(i,bus)*ifp*j; vnf(i)=vn0(i)-Zn(i,bus)*ifn*j; vzf(i)=vz0(i)-Zz(i,bus)*ifz*j;
end vpf_mag=abs(vpf); vpf_phase=angle(vpf); vnf_mag=abs(vnf); vnf_phase=angle(vnf);
vzf_mag=abs(vzf); vzf_phase=angle(vzf);
else
status(i+nl)=3; end
end s=length(status); for i=1:nt
postransflowp(i)=(vpf_mag(x(i))(cos(vpf_phase(x(i)))+sin(vpf_phase(x(i)))*j)-
vpf_mag(y(i))(cos(vpf_phase(y(i)))+sin(vpf_phase(y(i)))*j))/(z(i)*j);
postransflown(i)=(vnf_mag(x(i))(cos(vnf_phase(x(i)))+sin(vnf_phase(x(i)))*j)-
vnf_mag(y(i))(cos(vnf_phase(y(i)))+sin(vnf_phase(y(i)))*j))/(z(i)*j);
postransflowz(i)=(vzf_mag(x(i))(cos(vzf_phase(x(i)))+sin(vzf_phase(x(i)))*j)-
vzf_mag(y(i))(cos(vzf_phase(y(i)))+sin(vzf_phase(y(i)))j))(-j)*Yz(x(i),y(i));
negtransflowp(i)=(vpf_mag(y(i))(cos(vpf_phase(y(i)))+sin(vpf_phase(y(i)))*j)-
vpf_mag(x(i))(cos(vpf_phase(x(i)))+sin(vpf_phase(x(i)))*j))/(z(i)*j);
negtransflown(i)=(vnf_mag(y(i))(cos(vnf_phase(y(i)))+sin(vnf_phase(y(i)))*j)-
vnf_mag(x(i))(cos(vnf_phase(x(i)))+sin(vnf_phase(x(i)))*j))/(z(i)*j);
negtransflowz(i)=(vzf_mag(y(i))(cos(vzf_phase(y(i)))+sin(vzf_phase(y(i)))*j)-
vzf_mag(x(i))(cos(vzf_phase(x(i)))+sin(vzf_phase(x(i)))j))(-j)*Yz(x(i),y(i));
end postransflowp_mag=abs(postransflowp); postransflowp_phase=angle(postransflowp);
postransflown_mag=abs(postransflown); postransflown_phase=angle(postransflown);
postransflowz_mag=abs(postransflowz); postransflowz_phase=angle(postransflowz);
negtransflowp_mag=abs(negtransflowp); negtransflowp_phase=angle(negtransflowp);
negtransflown_mag=abs(negtransflown); negtransflown_phase=angle(negtransflown);
negtransflowz_mag=abs(negtransflowz); negtransflowz_phase=angle(negtransflowz);
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
break; end
if length(kk)~=0
if k<=length(ele_num) continue;
end
if k>length(ele_num) k=1;
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
break; end
if length(kk)~=0
if k<=length(ele_num) continue;
end
if k>length(ele_num) k=1;
continue; end
end end
end
posflowa(i)=posflowz(i)+posflowp(i)+posflown(i);
posflowb(i)=posflowz(i)+asq*posflowp(i)+a*posflown(i);
posflowc(i)=posflowz(i)+a*posflowp(i)+asq*posflown(i);
end
for i=1:length(ele_num) negflowa(i)=negflowz(i)+negflowp(i)+negflown(i);
negflowb(i)=negflowz(i)+asq*negflowp(i)+a*negflown(i);
negflowc(i)=negflowz(i)+a*negflowp(i)+asq*negflown(i);
end
done=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']); start_bus=[start_bus x'];
for i=1:length(x) temp(i)=nb+1;
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_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
for i=1:(nb+1) M(i)=1000;
end
M(1)=0; k=1;
kk=find(M==1000); while length(kk)~=0
flag=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
break; end
if length(kk)~=0
if k<=length(ele_num) continue;
end
if k>length(ele_num) k=1;
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
break; end
if length(kk)~=0
if k<=length(ele_num) continue;
end
if k>length(ele_num) k=1;
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
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 fid=fopen('out.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;
LINE-LINE-GROUND FAULT
function done=llgfault(nb,ng,nl,nt)
%formation of positive sequence Ybus Yp=Ypositive(nb,ng,nl,nt);
%formation of zero sequence Ybus Yz=Yzero(nb,ng,nl,nt);
%formation of positive and negative sequence Zbus Zp=inv(Yp);
Zn=Zp;
%formation of zero sequence Zbus check=diag(Yz);
k=find(check==0) if length(k)==0
Zz=inv(Yz); end
if length(k)~=0 Zz=pinv(Yz);
end
%preparation of pre-fault voltage vectors xxx=ones(nb);
neglineflowp(i)=(vpf_mag(y(i))(cos(vpf_phase(y(i)))+sin(vpf_phase(y(i)))*j)-
vpf_mag(x(i))(cos(vpf_phase(x(i)))+sin(vpf_phase(x(i)))*j))/(zp(i)*j);
neglineflown(i)=(vnf_mag(y(i))(cos(vnf_phase(y(i)))+sin(vnf_phase(y(i)))*j)-
vnf_mag(x(i))(cos(vnf_phase(x(i)))+sin(vnf_phase(x(i)))*j))/(zp(i)*j);
neglineflowz(i)=(vzf_mag(y(i))(cos(vzf_phase(y(i)))+sin(vzf_phase(y(i)))*j)-
vzf_mag(x(i))(cos(vzf_phase(x(i)))+sin(vzf_phase(x(i)))*j))/(zz(i)*j);
end poslineflowp_mag=abs(poslineflowp); poslineflowp_phase=angle(poslineflowp);
poslineflown_mag=abs(poslineflown); poslineflown_phase=angle(poslineflown);
poslineflowz_mag=abs(poslineflowz); poslineflowz_phase=angle(poslineflowz);
neglineflowp_mag=abs(neglineflowp); neglineflowp_phase=angle(neglineflowp);
neglineflown_mag=abs(neglineflown); neglineflown_phase=angle(neglineflown);
neglineflowz_mag=abs(neglineflowz); neglineflowz_phase=angle(neglineflowz)
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
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
if value==30 vpf_phase(i)=vpf_phase(i)+M(i)*(value*pi/180);
vnf_phase(i)=vnf_phase(i)-M(i)*(value*pi/180);
end
if value==90
vpf_phase(i)=vpf_phase(i)-M(i)*(value*pi/180);
vnf_phase(i)=vnf_phase(i)+M(i)*(value*pi/180);
end end
for i=1:length(posflowp_phase) if value==30
posflowp_phase(i)=posflowp_phase(i)+M(start_bus(i))*(value*pi/180);
posflown_phase(i)=posflown_phase(i)-M(start_bus(i))*(value*pi/180);
end
if value==90
posflowp_phase(i)=posflowp_phase(i)-M(start_bus(i))*(value*pi/180);
posflown_phase(i)=posflown_phase(i)+M(start_bus(i))*(value*pi/180);
end
if value==30 negflowp_phase(i)=negflowp_phase(i)+M(end_bus(i))*(value*pi/180);
negflown_phase(i)=negflown_phase(i)-M(end_bus(i))*(value*pi/180);
end
if value==90
negflowp_phase(i)=negflowp_phase(i)-M(end_bus(i))*(value*pi/180);
negflown_phase(i)=negflown_phase(i)+M(end_bus(i))*(value*pi/180);
end end
fprintf(fid,'\n\n');
fprintf(fid,'This represents the J to I flows\n\n');
fprintf(fid,'Start-bus End-bus pos-Magnitude pos-Phase neg-mag neg-phase zero-mag
zero-phase\n'); kk=find(end_bus==(nb+1));
for i=1:length(negflowp) test=find(kk==i);
if length(test)==0
fprintf(fid,'%-10.3f %-10.3f %-10.3f %-10.3f %-10.3f %-10.3f %-10.3f %-
10.3f\n',end_bus(i),start_bus(i),abs(negflowp(i)),angle(negflowp(i)),abs(negflown(i)),angle(negfl
own(i)),ab s(negflowz(i)),angle(negflowz(i)));
end end
fprintf(fid,'\n\n');
done=1;
LINE-LINE FAULT
function done=llfault(nb,ng,nl,nt)
%formation of positive sequence Ybus Yp=Ypositive(nb,ng,nl,nt);
%formation of zero sequence Ybus Yz=Yzero(nb,ng,nl,nt);
%formation of positive and negative sequence Zbus Zp=inv(Yp);
Zn=Zp;
%formation of zero sequence Zbus check=diag(Yz);
k=find(check==0) if length(k)==0
Zz=inv(Yz); end
if length(k)~=0 Zz=pinv(Yz);
end
%preparation of pre-fault voltage vectors xxx=ones(nb);
vp0=xxx(:,1); yyy=zeros(nb); vn0=yyy(:,1); vz0=vn0;
%calculation of fault current fid=fopen('faultdata.txt','r'); b=textread('faultdata.txt'); fclose(fid);
bus=b(1);
imp=b(3); ifp=vp0(bus)/((Zp(bus,bus)+Zn(bus,bus)+imp)*j); ifn=-ifp;
ifz=0;
%post fault voltage calculations for i=1:nb
vpf(i)=vp0(i)-Zp(i,bus)*ifp*j; vnf(i)=vn0(i)-Zn(i,bus)*ifn*j; vzf(i)=vz0(i)-Zz(i,bus)*ifz*j;
end vpf_mag=abs(vpf); vpf_phase=angle(vpf); vnf_mag=abs(vnf); vnf_phase=angle(vnf);
vzf_mag=abs(vzf); vzf_phase=angle(vzf);
postransflowz(i)=(vzf_mag(x(i))(cos(vzf_phase(x(i)))+sin(vzf_phase(x(i)))*j)-
vzf_mag(y(i))(cos(vzf_phase(y(i)))+sin(vzf_phase(y(i)))j))(-j)*Yz(x(i),y(i));
negtransflowp(i)=(vpf_mag(y(i))(cos(vpf_phase(y(i)))+sin(vpf_phase(y(i)))*j)-
vpf_mag(x(i))(cos(vpf_phase(x(i)))+sin(vpf_phase(x(i)))*j))/(z(i)*j);
negtransflown(i)=(vnf_mag(y(i))(cos(vnf_phase(y(i)))+sin(vnf_phase(y(i)))*j)-
vnf_mag(x(i))(cos(vnf_phase(x(i)))+sin(vnf_phase(x(i)))*j))/(z(i)*j);
negtransflowz(i)=(vzf_mag(y(i))(cos(vzf_phase(y(i)))+sin(vzf_phase(y(i)))*j)-
vzf_mag(x(i))(cos(vzf_phase(x(i)))+sin(vzf_phase(x(i)))j))(-j)*Yz(x(i),y(i));
end postransflowp_mag=abs(postransflowp); postransflowp_phase=angle(postransflowp);
postransflown_mag=abs(postransflown); postransflown_phase=angle(postransflown);
postransflowz_mag=abs(postransflowz); postransflowz_phase=angle(postransflowz);
negtransflowp_mag=abs(negtransflowp); negtransflowp_phase=angle(negtransflowp);
negtransflown_mag=abs(negtransflown); negtransflown_phase=angle(negtransflown);
negtransflowz_mag=abs(negtransflowz); negtransflowz_phase=angle(negtransflowz);
neggenflowp_phase=angle(neggenflowp); neggenflown_mag=abs(neggenflown);
neggenflown_phase=angle(neggenflown);
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
posflowc(i)=posflowz(i)+a*posflowp(i)+asq*posflown(i); end
for i=1:length(ele_num) negflowa(i)=negflowz(i)+negflowp(i)+negflown(i);
negflowb(i)=negflowz(i)+asq*negflowp(i)+a*negflown(i);
negflowc(i)=negflowz(i)+a*negflowp(i)+asq*negflown(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 pos-Magnitude pos-Phase neg-mag neg-phase zero-mag
zero-phase\n'); fprintf(fid,'This represents the I to J flows\n\n');
for i=1:length(posflowp)
fprintf(fid,'%-10.3f %-10.3f %-10.3f %-10.3f %-10.3f %-10.3f %-10.3f %-
10.3f\n',start_bus(i),end_bus(i),abs(posflowp(i)),angle(posflowp(i)),abs(posflown(i)),angle(posfl
own(i)),abs (posflowz(i)),angle(posflowz(i)));
end fprintf(fid,'\n\n');
fprintf(fid,'This represents the J to I flows\n\n');
fprintf(fid,'Start-bus End-bus pos-Magnitude pos-Phase neg-mag neg-phase zero-mag
zero-phase\n'); kk=find(end_bus==(nb+1));
for i=1:length(negflowp) test=find(kk==i);
if length(test)==0
fprintf(fid,'%-10.3f %-10.3f %-10.3f %-10.3f %-10.3f %-10.3f %-10.3f %-
10.3f\n',end_bus(i),start_bus(i),abs(negflowp(i)),angle(negflowp(i)),abs(negflown(i)),angle(negfl
own(i)),ab s(negflowz(i)),angle(negflowz(i)));
end end
fprintf(fid,'\n\n');
INPUT:
Line data
1.00 2.00 0.10 0.30 1 0
2.00 3.00 0.10 0.30 1 0
3.00 1.00 0.10 0.30 1 0
Generator data
4.00 0.20 0.05 0.03
5.00 0.20 0.05 0.03
Transformer data
4.00 0.20 0.05 0.03
5.00 0.20 0.05 0.03
OUTPUT:
The positive sequence Ybus
Fault
current
Magnitude Angle(radians) I1
3.730 -1.571
I2
1.984 3.142
I0
1.746 3.142
RESULT: Symmetrical fault analysis in a given power system network was successfully carried
out using MATLAB.
Experiment-7
Siddartha Aggarwal (2K20/EE/266)
Aim: To compute the optimal dispatch in the three-generator system given below
(a) without and (b) with transmission losses.
Theory:
The fuel cost functions of the above three generators are given as : C1 = 0.001562Pg 2 + 7.92Pg +
561
C2 = 0.00194Pg 2 + 7.85Pg + 310 C3 = 0.00482Pg 2 + 7.92Pg + 78
The total active power demand is 850 MW. The transmission losses are given as
Ploss= 0.00003Pg12+0.00009Pg 2+ 0.00012Pg 2 MW
(a.) Without transmission loss, the optimal dispatch rule is given as:
(b.) With transmission losses, the optimal dispatch rule is given as:
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, wecan
choose the value of which was obtained in part (a) i.e., without transmission losses.
MATLAB Code:
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;
fprintf("Without transmission losses (Pg1,Pg2,Pg3):\n"); disp( x(1:3,1) );
fprintf("Incremental cost = %0.4f \n\n", x(4,1));
Output:
Conclusion
To compute the optimal dispatch in the three-generator system given below (a) without and (b)
with transmission losses.
Experiment-8
Siddartha Aggarwal (2K20/EE/266)
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.
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
At x=x0, t=t0 we can represent the curve representing the true solution by its tangent having slope
of
System modeling:
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.
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-1i*q)/conj(et); eb=et-1i*(xt+xleq)*i1;
edash=et+1i*xddash*i1;
t0=1;
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
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 xlabel('time') ylabel('del')
Output:
Conclusion
We determined the critical clearing time for the single machine infinite bus system given
to us.