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

EXPERIMENT NO: 5

AIM: Program to find load flow study using Newton Raphson method

1%
2% Load Flow Study
3%
4 % Program to find power flow s o l u tio n using
5 % Newton − Raphson I t e r a t i o n Method
6 %
7 %
8 clear
9 clc
10
11 Elements From To Impedance
12 Zdata = [ 1 1 2 0. 02 +j*0.2 ; j
13 2 2 3 0.02 +j*0.2 ;
14 3 3 4 0.02 +j*0.2 ;
15 4 4 5 0.02 +j*0.2 ;
16 5 3 5 0.02 * +j 0.2 ;
17 6 1 4 0.02 +j*0.2 ;
18 ];
19
20
21 % Bus No . Load Generation Voltage Vmax
Vmin Qmax Qmin
22 % Pd Qd Pg Qg Vpu
23 Bus data = [ 1 Inf Inf Inf Inf 1.2 Inf
Inf Inf Inf ;
24 2 0 0 0.5 Inf 1.1 Inf
Inf 0.3 0.1 ;
25 3 0.6 0.3 0 0 Inf Inf
Inf Inf Inf ;
26 4 0.6 0.3 0 0 Inf Inf
Inf Inf Inf ;
27 5 0.5 0. 2 0 0 Inf Inf
Inf Inf Inf ;
28 ];
29
30 Base = 1 ; % Base quantity in MVA i f not given than Base # 1 to keep
power and l o s s e s c a l c u l a t i o n in per unit
31 Elements= length ( Z data ( : , 1 ) ) ;
32 %Bus no = Bus data ( : , 1 ) ' ;
33 Pd = Bus data (: ,2 ) ;
34 Qd =Bus data ( : ,3 ) ;
35 Pg = Bus data ( : , 4 ) ;
36 Qg = Bus data ( : ,5 ) ;
37 V =Bus data ( : , 6 ) ;
38
39 %%%% Step 1 : Finding bus admitance matrix Ybus %%%%%%%%%%
40 Ybus = ybus s ing ( Zdata ( : , 1 ) , Zdata ( : , 2 ) , Zdata ( : , 3 ) , Zdata ( : , 4 ) ) ;
41 Sp = ( Pg − Pd) ; % Given data : Real and Imaginary power i n j e c t e d to
42 Sq = (Qg − Qd) ; % the bus
43
44 %%%% Check i f given bus i s PQ bus or PV bus .
45 Tbus = rows ( Bus data ) ; % Finding t o t a l number o f bus
46 bus type = z ero s ( Tbus ,1 ) ;
47 bus type ( 1 , 1 ) = 1 ; % Bus 1 i s s l ac k / r e f e r e n c e bus
48 Vbus = V ; % Keeping f i r s t row Vbus as per the
49 % given vo l tag e data and a f te r that i t
50 % w i l l be updated f o r each i t e r a t i o n
51 f o r bus = 2 : Tbus
52 i f i s i n f (V( bus ) ) == 1 | | i snan (V( bus ) ) == 1
53 bus type ( bus ) = 2 ; % Bus i s PQ bus as vo l tag e i s not known
54 % at t h i s bus
55 Vbus ( bus ) = 1 . 0 ; % I n i t i a l i s e u n s p e c i f i e d bus vo l tage with
56 % 1<0 ( Flat s t a r t )
57 else
58 bus type ( bus ) = 3 ; % Bus i s PV bus as vo l tag e i s given
59 end
60 end
61 bus vo l t = Vbus ;
62 iter=1 ;
63 while i t e r <= 1
64 Si = t ranspose ( Vbus '.*( t ranspose ( Vbus ) *Ybus ) ) ;
65 delta P = [ ] ;
66 deltaQ = [ ] ;
67 % Si = Si ( 2 :end ) ;
68 % delta P = Sp − r e a l ( Si ) ;
69 % delta P = delta P ( 2 , end ) ;
70 % deltaQ = Sq − (−imag ( Si ) ) ;
71
72 % Finding Jacobian Matrix
73 f o r rw = 2 : Tbus
74 delta P = [ deltaP , Sp( rw ) − r e a l ( Si ( rw) ) ] ;
75 i f bus type ( rw ) == 2
76 deltaQ = [ deltaQ , Sq ( rw ) − (−imag ( Si ( rw) )) ] ;
77 end
78
79 f o r c l = 1 :Tbus
80 Jxy ( rw− 1, cl ) = Vbus ( rw) * Vbus ( cl )*Ybus ( rw , cl ) ;
81
82 % Finding Jacobian J1 matrix
83 i f rw − c l == 0
84 J1 ( rw−1, cl −1) = −(−imag ( Si ( rw ) ) ) − imag ( Jxy ( rw −1, c l ) ) ;
85 e l s ei f c l > 1
86 J1 ( rw −1, cl −1) = −imag ( Jxy ( rw −1, c l ) ) ;
87 end
88
89 % Finding Jacobian J2 matrix
90 i f rw − c l == 0 && bus type ( c l ) == 2
91 J2 ( rw −1, cl −1) = r e a l ( Si ( rw ) ) + r e a l ( Jxy ( rw −1, c l ) ) ;
92 e l s e i f c l > 1 && bus type ( c l ) == 2
93 J2 ( rw−1, cl −1) = r eal ( Jxy ( rw−1, cl ) ) ;
94 end
95
96 % Finding Jacobian J3 matrix
97 i f rw − c l == 0 && bus type ( rw ) == 2
98 J3 ( rw −1, cl −1) = r e a l ( Si ( rw ) ) − r e a l ( Jxy ( rw −1, c l ) ) ;
99 e l s e i f c l > 1 && bus type ( rw ) == 2
100 J3 ( rw −1, cl −1) = −r e a l ( Jxy ( rw − 1, c l ) ) ;
101 end
102
103 % Finding Jacobian J4 matrix
i f rw − c l == 0 && bus type ( rw ) == 2 && bus type ( c l ) == 2
104
J4 ( rw−1, cl −1) = (−imag ( Si ( rw) ) ) − imag ( Jxy (rw−1, cl ) ) ;
105
106 J4 ( rw −1, c l −1) = J1 ( rw −1, c l −1) ;
107 end
108 end
109
110 end
111
112 J = [ J1 J2 ; J3 J4 ] % Jacobian matrix
113 de l ta = [ delta P deltaQ ] * inv ( J) ;
114 deltaD = de lta ( 1 : Tbus−1) ;
115 [ ang , mag ] = cart 2 po l ( r e a l ( Vbus ) , imag ( Vbus ) ) ;
116 deltaV = de lta ( Tbus : end ) .*mag( find ( bus type == 2) ) ;
117
118 ang ( 2 : end ) = ang ( 2 : end ) + t ranspose ( deltaD )
119 mag( f i nd ( bus type == 2 ) ) = mag( f i nd ( bus type == 2 ) ) + deltaV
120
121 [ xx , yy ] = po l 2 c art ( ang , mag) ;
122 bus vo l t ( : , i t e r+1) = xx + yy*i ;
123 Vbus = bus vo l t ( : , end ) ;
124
125 iter=iter+1 ;
126 end

You might also like