Pss Lab Programs
Pss Lab Programs
Date:
AIM:
To write the MATLAB program to find the Y bus matrix for the given power system network.
PROCEDURE:-
1. Open MATLAB 2. Open new script 3. Type the program 4. Save in current directory 5. Compile and
Run the program 6. For the output see command window\ Figure window
PROGRAM:
clc;
clear all;
n=input('Enter number of buses');
l=input('Number of lines');
s=input('1.Impedance or 2:Admittance');
ybus=zeros(n,n);
lc=zeros(n,n);
for i=1:l
a=input('Starting bus:');
b=input('Ending bus:');
t=input('Admittance or Impedance of line:');
lca=input('Line charging admittance:');
if(s==1)
y(a,b)=1/t;
else
y(a,b)=t;
end
y(b,a)=y(a,b);
lc(a,b)=lca;
lc(b,a)=lc(a,b);
end
for i=1:n
for j=1:n
if i==j
for k=1:n
ybus(i,j)=ybus(i,j)+y(i,k)+lc(i,k)/2;
end
else
ybus(i,j)=-y(i,j);
end
ybus(j,i)=ybus(i,j);
end
end
disp(ybus)
1
OUTPUT:
Enter number of buses3
Number of lines3
1.Impedance or 2:Admittance1
Starting bus:1
Ending bus:2
Admittance or Impedance of line:0.1+0.3i
Line charging admittance:0.02i
Starting bus:2
Ending bus:3
Admittance or Impedance of line:0.15+0.5i
Line charging admittance:0.0125i
Starting bus:3
Ending bus:1
Admittance or Impedance of line:0.2+0.6i
Line charging admittance:0.028i
1.5000 - 4.4760i -1.0000 + 3.0000i -0.5000 + 1.5000i
-1.0000 + 3.0000i 1.5505 - 4.8186i -0.5505 + 1.8349i
-0.5000 + 1.5000i -0.5505 + 1.8349i 1.0505 - 3.3146i
EXERCISE:
Develop a program to obtain bus admittance matrix Y-bus of the given power system.
2
Manual Calculation:
3
RESULT:
Thus the formation of Y-BUS matrix using MATLAB Program was implemented.
4
Ex. No:8
DATE:
LOAD FLOW ANALYSIS USING GAUSS SIEDAL METHOD
AIM:
To write a Mat Lab program to determine the power flow solution by gauss Seidal method
for given bus system.
ALGORITHM:
STEP2: Read the line admittance, real power, reactive power & line voltage values.
STEP6: Calculate line current, line flow & line loss value.
5
FORMULA:
Pi jQi n n
1. Vi Yij YijVj
Vi j 0 j 1
6
PROGRAM:
clearall
clc
v1=1.05+0i
v2=1+0i
v3=1.04+0i
vp3=v3
P2=-4
P3=2
Q2=-2.5i
Z12=0.02+0.04i
Z13=0.01+0.03i
Z23=0.0125+0.025i
Y12=(1/Z12)
Y13=(1/Z13)
Y23=(1/Z23)
iter=0;
fori=1:8
disp('--------------------------------------------------------')
iter=iter+1;
formatlong
fprintf('%dth iteration',iter)
v2=(((P2-Q2)/conj(v2))+(Y12*v1)+(v3*Y23))/(Y12+Y23)
q3=-((conj(v3))*((v3*(Y13+Y23))-(Y13*v1)-(Y23*v2)))
Q3=q3-(real(q3))
vc3=(((P3-Q3)/conj(v3))+(Y13*v1)+(v2*Y23))/(Y13+Y23)
e3=((vp3)^2-(imag(vc3)^2))^0.5
7
v3=e3-(real(vc3)-vc3)
disp('------------------------------------------------------------')
end
format short
S1=abs(v1)*((v1*(Y12+Y13))+(Y12*v2+Y13*v3))
P1=real(S1)
Q1=imag(S1)
S2=P2+Q2
S3=P3+Q3
P3=real(S3)
Q3=imag(S3)
disp('line current values')
I12=Y12*(v1-v2)
I21=-I12
I13=Y13*(v1-v3)
I31=-I13
I23=Y23*(v2-v3)
I32=-I23
disp('line flow values')
s12=v1*conj(I12)
s21=v2*conj(I21)
s13=v1*conj(I13)
s31=v3*conj(I31)
s23=v2*conj(I23)
s32=v3*conj(I32)
disp('line loss values')
sL12=s12+s21
sL13=s13+s31
8
sL23=s23+s32
OUTPUT:
v1 = 1.050000000000000
v2 = 1
v3 = 1.040000000000000
vp3 = 1.040000000000000
P2 =-4
P3 =2
Q2 =0 - 2.500000000000000i
Z12 =0.020000000000000 + 0.040000000000000i
Z13 =0.010000000000000 + 0.030000000000000i
Z23 = 0.012500000000000 + 0.025000000000000i
Y12 = 10.000000000000000 -20.000000000000000i
Y13 = 10.000000000000002 -30.000000000000000i
Y23 =16.000000000000000 -32.000000000000000i
--------------------------------------------------------
1th iteration
v2 =0.974615384615385 - 0.042307692307692i
q3 = -2.391999999999999 + 1.160000000000002i
Q3 = 0 + 1.160000000000002i
vc3 =1.037831858407080 - 0.005170183798502i
e3 = 1.039987148574197
v3 = 1.039987148574197 - 0.005170183798502i
------------------------------------------------------------
--------------------------------------------------------
2th iteration
v2 = 0.971057059512953 - 0.043431876337850i
q3 =-2.161829131078501 + 1.387957731052817i
Q3 =0 + 1.387957731052817i
vc3 = 1.039081476179431 - 0.007300111679686i
e3 =1.039974378708180
v3 = 1.039974378708180 - 0.007300111679686i
9
-----------------------------------------------------------
--------------------------------------------------------
3th iteration
v2 = 0.970733708554698 - 0.044791724463619i
q3 =-2.077937787847589 + 1.429040300785471i
Q3 =0 + 1.429040300785471i
vc3 = 1.039536102030377 - 0.008325001047174i
e3 = 1.039966679445820
v3 = 1.039966679445820 - 0.008325001047174i
------------------------------------------------------------
--------------------------------------------------------
4th iteration
v2 = 0.970652437281433 - 0.045329920732880i
q3 = -2.032484899896599 + 1.448333275594840i
Q3 = 0 + 1.448333275594840i
vc3 = 1.039783582412907 - 0.008752000354604i
e3 = 1.039963173621928
v3 = 1.039963173621928 - 0.008752000354604i
------------------------------------------------------------
--------------------------------------------------------
5th iteration
v2 =0.970623655331095 - 0.045554240372625i
q3 = -2.013468584357726 + 1.456209166612119i
Q3 = 0 + 1.456209166612119i
vc3 = 1.039887186964488 - 0.008929007616053i
e3 = 1.039961668920058
v3 = 1.039961668920058 - 0.008929007616053i
------------------------------------------------------------
--------------------------------------------------------
6th iteration
v2 =0.970612037114234 - 0.045646940090561i
q3 = -2.005571305796307 + 1.459469889628077i
Q3 = 0 + 1.459469889628077i
10
vc3 = 1.039930224431334 - 0.009002221658867i
e3 =1.039961037734205
v3 =1.039961037734205 - 0.009002221658867i
------------------------------------------------------------
--------------------------------------------------------
7th iteration
v2 =0.970607253520093 - 0.045685276728252i
q3 = -2.002304349063438 + 1.460818201396914i
Q3 = 0 + 1.460818201396914i
vc3 =1.039948029840190 - 0.009032502820155i
e3 = 1.039960775170297
v3 = 1.039960775170297 - 0.009032502820155i
------------------------------------------------------------
--------------------------------------------------------
8th iteration
v2 = 0.970605276281561 - 0.045701131870879i
q3 =-2.000953112341006 + 1.461375872168914i
Q3 =0 + 1.461375872168914i
vc3 =1.039955394551153 - 0.009045027392915i
e3 = 1.039960666313617
v3 = 1.039960666313617 - 0.009045027392915i
S1 = 4.1916e+001 -1.0884e+002i
P1 = 41.9163
Q1 =-108.8413
S2 = -4.0000 - 2.5000i
S3 = 2.0000 + 1.4614i
P3 = 2
Q3 =1.4614
line current values
I12 = 1.7080 - 1.1309i
I21 =-1.7080 + 1.1309i
I13 =0.3717 - 0.2107i
I31 =-0.3717 + 0.2107i
11
I23 = -2.2827 + 1.6329i
I32 = 2.2827 - 1.6329i
12
EXERCISE;
1. Figure shows the one line diagram of simple three bus power system with generators at buses
at 1 and 3. The magnitude of voltage at bus 1 is adjusted to1.05pu. Voltage magnitude at bus 3 is
fixed at 1.04 pu with a real power generation of 200 MW. A load consisting of 400 MW and 250
Mvar is taken from bus 2. Line impedances are marked on per unit on a 100 MVA base, and the
line charging susceptances are neglected. Obtain the power flow solution by Gauss Seidel
method including line flows and line losses.
1 2
0.02+j0.04
400MW
3
Slack bus
V1=1.05
200
MW |v3|=1.04
13
RESULT:
Thus the power flow solution of the given power system wasdetermined by using Mat
Lab program.
14
Ex. No:09
DATE:
LOAD FLOW ANALYSIS USING FAST DECOUPLED METHOD
AIM:
To write a Mat lab program to determine the load flow solution of the given bus
condition using Fast decoupled method.
THEORY:
Due to the weak coupling between PV and q-δ half of the elements of jacobian matrix are
neglected further the assumptions made are
Cos δij = 1
Sin δij = 0
Qi <<Bij |V|2
One iteration implies one solution for [∆δ] to update [δ] and one solution for [∆P/|V|] to update [|
V|] and is termed as 1-δ and 1-V iteration. The convergence for the real and reactive power is
achieved when max[∆P] < ∑P; max[∆Q]<=∑Q.
The main advantage of the decoupled load flow as compared to Newton Raphson method is its
reduced memory is storing Jacobian.
15
ALGORITHM:
Step1: Start the program.
Step2: Get the values of the Ybus matrix and the variables.
Step3: Calculate the magnitude and Angles of the Ybus.
Step4: Form B’ matrix by imaginary part of Ybus matrix eliminating row & column
of Slack bus.
Step5:Form B’’ matrix by imaginary part of Ybus matrix eliminating row & column of
Slack bus and generator bus.
Step6: Get the values of Real & reactive power, voltage and magnitude of all the three
buses. Intialize iterative value as zero and pwrctr value as 0.00025
Set PQ matrix as[1;1;1]
Step7:Check whether the PQ matrix elements are greater than the pwrctr value. If yes
proceed with calculating values of P2,Q2 and P3.Also calculate the DV and PQ matrices
using relevant formulae.
Step8: If the condition is not satisfied, then continue calculating the values of P1,Q1 and
Q3 with the available input values.
FORMULA:
n
1.Pi ViVjYij cos(ij i j )
j 1
n
2.Qi ViVjYij sin(ij i j )
j 1
3.Pi (k ) Pisch Pi (k )
4.Qi (k ) Qisch Qi (k )
1 Pi (k )
5.[i ](k )
[ B ' ] Vi
1 Qi (k )
6.[Vi ](k )
B ' ' Vi
7.i (k 1) i (k ) i (k )
8.Vi (k 1) Vi (k ) Vi (k )
16
ROGRAM:
clearall;
clc;
Y=abs(y)
th=angle(y)
B11=[-52]
p2s=-4;
q2s=-2.50;
p3s=2;
v1=1.05;
v2=1;
v3=1.04;
del1=0;
del2=0;
del3=0;
iter=0
PQ=[1;1;1]
pwrctr=0.00025;
while(max(abs(PQ))>pwrctr)
17
iter=iter+1
p2=abs(v2)*abs(v1)*Y(2,1)*cos(th(2,1)-
del2+del1)+abs(v2^2)*Y(2,2)*cos(th(2,2))+abs(v2)*abs(v3)*Y(2,3)*cos(th(2,3)-
del2+del3);
p3=abs(v3)*abs(v1)*Y(3,1)*cos(th(3,1)-
del3+del1)+abs(v3^2)*Y(3,3)*cos(th(3,3))+abs(v3)*abs(v2)*Y(3,2)*cos(th(3,2)-
del3+del2);
q2=-(abs(v2)*abs(v1)*Y(2,1)*sin(th(2,1)-del2+del1))-
(abs(v2^2)*Y(2,2)*sin(th(2,2)))-(abs(v2)*abs(v3)*Y(2,3)*sin(th(2,3)-del2+del3));
Dp2v=(p2s-p2)/v2;
Dp3v=(p3s-p3)/v3;
Dq2v=(q2s-q2)/v2;
Ddel=-inv(B1)*[Dp2v;Dp3v]
DV=-inv(B11)*[Dq2v]
PQ=[Dp2v;Dp3v;Dq2v]
del2=del2+Ddel(1,1)
del3=del3+Ddel(2,1)
v2=v2+DV
end
p1=(abs(v1^2)*Y(1,1)*cos(th(1,1)))+(abs(v1)*abs(v2)*Y(1,2)*cos(th(1,2)-
del1+del2))+(abs(v1)*abs(v3)*Y(1,3)*cos(th(1,3)-del1+del3))
18
q1=-(abs(v1^2)*Y(1,1)*sin(th(1,1)))-(abs(v1)*abs(v2)*Y(1,2)*sin(th(1,2)-
del1+del2))-(abs(v1)*abs(v3)*Y(1,3)*sin(th(1,3)-del1+del3))
q3=-(abs(v3)*abs(v1)*Y(3,1)*sin(th(3,1)-del3+del1))-
(abs(v3)*abs(v2)*Y(3,2)*sin(th(3,2)-del3+del2))-(abs(v3^2)*Y(3,3)*sin(th(3,3)))
19
OUTPUT:
y=
Y=
th =
B1 =
-52 32
32 -62
B11 = -52
iter = 0
PQ =
1
1
1
iter = 1
Ddel =
-0.0605
-0.0089
DV = -0.0042
PQ =
-2.8600
1.3831
-0.2200
del2 = -0.0605
20
del3 = -0.0089
v2 = 0.9958
iter = 2
Ddel =
0.0040
0.0010
DV =
-0.0305
PQ =
0.1766
-0.0682
-1.5858
del2 = -0.0565
del3 = -0.0080
v2 = 0.9653
iter = 3
Ddel =
0.0123
-0.0007
DV = 4.3728e-004
21
PQ =
0.6633
-0.4395
0.0227
del2 = -0.0442
del3 = -0.0087
v2 = 0.9657
iter =
Ddel =
1.0e-003 *
-0.6076
-0.2951
DV =
0.0073
PQ =
-0.0222
0.0011
0.3782
del2 = -0.0448
del3 = -0.0090
v2 =
22
0.9730
iter = 5
Ddel =
-0.0029
0.0003
DV =
1.3157e-004
PQ =
-0.1576
0.1086
0.0068
del2 =
-0.0477
del3 =
-0.0087
v2 =0.9731
iter =
Ddel =
1.0e-004 *
0.5160
0.6712
23
DV =
-0.0017
PQ =
0.0005
0.0025
-0.0885
del2 =
-0.0476
del3 =
-0.0086
v2 =
0.9714
iter =
Ddel =
1.0e-003 *
0.6776
-0.0565
DV =
-8.0523e-005
PQ =
0.0370
24
-0.0252
-0.0042
del2 =
-0.0469
del3 =
-0.0087
v2 =
0.9713
iter =
Ddel =
1.0e-004 *
0.0778
-0.1788
DV =
3.9833e-004
PQ =
0.0010
-0.0014
0.0207
del2 =
-0.0469
25
del3 =
-0.0087
v2 =
0.9717
iter =
Ddel =
1.0e-003 *
-0.1591
0.0130
DV =
3.0840e-005
PQ =
-0.0087
0.0059
0.0016
del2 =
-0.0471
del3 =
-0.0087
v2 =
0.9718
26
iter =
10
Ddel =
1.0e-005 *
-0.6563
0.4581
DV =
-9.2778e-005
PQ =
-0.0005
0.0005
-0.0048
del2 =
-0.0471
del3 =
-0.0087
v2 =
0.9717
iter =
11
Ddel =
1.0e-004 *
27
0.3723
-0.0292
DV =
-1.0009e-005
PQ =
0.0020
-0.0014
-0.0005
del2 =
-0.0471
del3 =
-0.0087
v2 =0.9717
iter = 12
Ddel =
1.0e-005 *
0.2651
-0.1164
DV =
2.1530e-005
PQ =
0.0002
28
-0.0002
0.0011
del2 =
-0.0471
del3 =
-0.0087
v2 =
0.9717
iter =
13
Ddel =
1.0e-005 *
-0.8679
0.0652
DV =
2.9948e-006
PQ =
1.0e-003 *
-0.4722
0.3182
0.1557
del2 =
-0.0471
29
del3 =
-0.0087
v2 =
0.9717
iter =
14
Ddel =
1.0e-006 *
-0.8815
0.2934
DV =
-4.9759e-006
PQ =
1.0e-003 *
-0.0552
0.0464
-0.2587
del2 =
-0.0471
del3 =
-0.0087
v2 = 0.9717
30
iter =15
Ddel =
1.0e-005 *
0.2016
-0.0145
DV =
-8.5243e-007
PQ =
1.0e-003 *
0.1094
-0.0735
-0.0443
del2 = -0.0471
del3 =-0.0087
v2 = 0.9717
p1 =
2.1842
q1 =
1.4085
q3 =
1.4618
>>
31
EXERCISE;
1. Figure shows the one line diagram of simple three bus power system with generators at buses
at 1 and 3. The magnitude of voltage at bus 1 is adjusted to1.05pu. Voltage magnitude at bus 3 is
fixed at 1.04 pu with a real power generation of 200 MW. A load consisting of 400 MW and 250
Mvar is taken from bus 2. Line impedances are marked on per unit on a 100 MVA base, and the
line charging susceptances are neglected. Obtain the power flow solution by fast decoupled
method including line flows and line losses.
1 2
0.02+j0.04
400MW
3
Slack bus
V1=1.05
200
MW |v3|=1.04
32
RESULT:
Thus the power flow solution is obtained by fast decoupled method with one slack bus,
To write a Mat Lab program for forming the bus impedance matrix for a given network using
building algorithm.
THEORY:
Start with the branches connected to the reference connected to the reference node ‘q’ and the reference
node ‘o’ to the given znewbusmatrix of order (m*m), results in the znewbusmatrix of order (m+1)*(m+1).
Z11 …… Z1m 0
.…. 0 0
znewbus= 0 …… Zmm 0
0 …… 0 Zq0
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 busContinue with the remaining branches
of the tree connecting a new node to the existing node. Addition of a branch Zpqbetween a node ‘q’ and
the existing node ’p’ to the given Zoldbus matrix of order (m*m), results in the Znewbus matrix of order
(m+1)*(m+1).
Znewbus=
34
Zp1 Zpp … Zpm Zpp
When a link with impedance Zpq is added between two existing nodes and a new column.
Where,
Z//=zpq+Zpp+Zqq-2Zpq
Znewbus=Zoldbus-ΔZΔZT/Zll
Z1q – Z1p
35
ΔZ= Zpq - Zpp
Zqq - Zqp
Zmq - Zmp
When bus ‘q’,is the reference bus, Zqi=Ziq=0 (for i=1,m) and the above matrix reduces to,
-Z1p
ΔZ= -Zpp
-Zmp
ALGORITHM:
36
1. Start with the branches connected to the reference node using rule1.
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.
PROGRAM:
37
clc;
clearall;
warningoff;
linedata=[0 1 0 0.2 0;
1 2 0 0.8 1;
1 3 0 0.4 0;
0 2 0 0.4 0;
2 3 0 0.4 1];
n1=linedata(:,1);
nr=linedata(:,2);
R=linedata(:,3);
X=linedata(:,4);
ll=linedata(:,5);
nbr=length(n1);
nbus=max(max(n1),max(nr));
ZB=R+j*X;
Zbus=zeros(nbus,nbus);
%Rule-1
for I=1:nbr
if n1(I)==0 | nr(I)==0
if n1(I)==0
k=nr(I);
elseif nr(I)==0
k=n1(i);
end
Zbus(k,k)=ZB(I);
end
end
%Rule -2
for J=1:nbr
if n1(J)>0 & nr(J) >0
ifll(J) == 0
Zbus(:,nr(J))=Zbus(:,n1(J));
Zbus(nr(J),:)=Zbus(:,n1(J),:);
Zbus(nr(J),nr(J))=Zbus(n1(J),n1(J))+ZB(J);
end
end
end
%rule-3
for J=1:nbr
if n1(J)>0&nr(J)>0
ifll(J)==1
38
delta_Z=Zbus(:,nr(J))-Zbus(:,n1(J));
Zll=ZB(J)+Zbus(nr(J),nr(J))+Zbus(n1(J),n1(J))-2*Zbus(n1(J),nr(J));
p=(delta_Z*(-delta_Z)')/Zll;
Zbus=Zbus-p;
end
end
end
Zbus
39
OUTPUT:
Zbus =
40
EXERCISE:
41
RESULT:
Thus the MATLAB program has been written to form the bus impedance matrix for
given network using building algorithm.
42