You are on page 1of 35

# c

c c

ô 
x  



P  

 
 P   

c

x  
   

   
 
 c
c c c c
c c  
c  c
c
c  c  
c c ^    c  c c c    c c c
  c cc  c  c c c c c cc   c  c
 
c c c c c cc c c c c cc  c c
 c 
c c cc c  c c c cc   
c  
c c   c  c
c c c  c c  !c c c cc  c   c c"  c
# c c\$ c c  c c c c c c

## c  c c c  c c  c  

c  c  c c À c  
c  c   c
 c   c   c c  c  
c  c c     c  c  c c
c  c c  
c c   c c  c   c c c c  c

 c 

## c c c  cc c c c c c c

" c  c c c c c c  c ccc c c c   c# c
 c c c cc cc  c c\$ c c c# c c" c  c
   c\$ c c c c c cc c  c c c c c c c
c  c\$c c c  c c   c c cc  cc

  c c c c c c c c c  c c c c c c c
% c  c   c  ! c  c \$ c \$ c &'('c c c  c &')*+c c  c
 \$  cc c c ,c  c c  c  c c  c c

[  
 -c

## 6c &c. c c \$c   c

6c (c/ 0  c c c
6c c. c c c
6c ]c0  c


c
" c c c c c c cc c\$ c c c c c  c   c
 c   c \$c c c  c  c  c  c  c c   c  c  c c  c
 c &-c1c c    c c
c  c c   c c cc  c \$  c c
c c   c   c  c   c  c \$c    c   c 2c c c  c
  c  c c  \$
c   c  c c c c\$ c c  c c c  c c
 \$c  c

" c  c c c  c c  \$c \$c  c   c c c c c
  \$cc c c" cc cc  \$c c cc c c c\$cc
\$c  c c  c c c cc c c3 c4c cc# 
c c\$c c
c  cc  c c c cc c c5  c4c" c# ccc \$ 
 c\$c c c c  c" c\$cc   c c c c% c4c

## c c c c \$

c cc c c c  c c c c   c c c c  c
3 c4c cc c c  
c3 c4c c cc c.6c4c c5  c
4
c  c c c c c  c c cc c c  c   c77c cc
 c c% c4
c cc c c c c  c77c c c cc cc
"    
c  c  c3 c4
c\$ c c c  c c c cc c c\$c
c  ,c  c  c5  c4
c c c c c\$cc  ,c  c cc  \$c
c c\$cc  c c% c4cc c c cc\$c cc  
c  c c c
(c8c&c8cc8c&cc

## c  c cc  c c(c8c&c8cc8c&c

c  c c\$c(c8c&c8cc8c&c9 c
c c  c  c c c c   \$c " c \$c 9 c c c c  c
\$  c9 
c  c c\$c  c  c  c c   c c  c  c\$c" c  c c
\$  c9 cc

##   c c c c  c  c : c c \$c 

c  c c c  c  c  c c  c c cccccccccccccccccccc
\$c  c  #c ;4%c  c c c  c c c c 
c  c c c   c
 c  c c  c c c ;4%c  c c c  c c c c c c < c c c
  cc c c\$ c c c c c\$c" c   c c\$  c9 c
c

## =9 cc c c  c c   c c\$  c9 c  c  c3 c4c c c

 c  c \$  c 9 c  c   c 5  c 4c 1c c  c  c \$  c 9 c c
  c  c c5  c4c\$ c c c   c c: cc c c c\$cc
c    c c c   c  c \$  c 9 c c  c c c   c
c  \$c c c  
c  c cc9 c  c  c c% c4c

##  ^  

 c
"  c c c   c c cc c  c c c c9 c" c
 c ccc c c/ 0  c> c" c c\$c c  cc
 c c c   \$c  c   c c c c 3 c 4c c  c c c
5  c4c/#
c c"  c% cc  
c c c   c  c  c 
c  c  c
 c c c\$  c9 ccc c c c9 cc" c  cc c c c
 c9 c c c\$c# c c

## ccc c #c c  c  cc c c \$ c c

" c  !c  c  c 9 c c c c   c c # c c c @c &c  c  c
  c c c\$ cc

" c  c  c  c c  c  c c  c c c  c  c c c
  c c c c c c  c9 c c\$c c c  c

## c  c c c c c c c c \$cc

&c > c c  cc c cc c  c c c ccc cc
cA  c Acc  c c c c c c c! c c c c  c c c
c&*cc
(c %c c  c \$  c 9 c c c  c  c  c c c   c
 c
c 3 !c c c c c c  c c c c  c c
]c %c  c c cc c c c  c
Bc  c c c  c c c
)c c c c 
c c c c   
ccc c c(c

   
c
 c
c c c c
0  c c/ C0  c c
c c  
c  c

c  c  
c    c cc c c  ^  
c c
 c  c / c c  c 0  
c c c  c  c c c \$  c
 # c c c ! c  c  c  c c   c  c " c   c c   c c c
 c cD  +c 
cc\$cD +c c

 
 c

## 5c c  c ´ c c  c   c ´c+ 

c c \$c  c c   c c *c . c c
 cc   \$c\$ c c\$  c  # c &cc

5  
c #&c c c    c c c c  c c c c  c c
c c c # #c
" c cc  c c c  c  c cc   c

c
[ 


c
c
4 c c  c  c#Bc8c&cEc*,c  c c c  c c c
> c c/ c  c

##  c  c  c #c  

c / +c  c  c \$c   c c c c  c
! c=  c! c c c\$ c c  
c c c c c c c c c c c c
 c c c   c ! c " c  c  c \$c  c c c c  c  c  c  c
#c  
c c\$ c c c\$ c c  cc c  ccc c  c c
c c c #c  c   c c  c c c  c c \$ c  c  
c  c c
  cc c c

       
Ú  Ú
 

1c cc/ +c c c cc c c c c9 
c  c  c
c c c ! c  c  c     \$c  c cc  c ĺc  c c c   c
c \$
cc c c c c c c c c c c \$ c \$ c #c c
  c cc\$c c+ c

## 0  c c   c  c c  c  c c  #

c c  c  c c \$c c c
 c c c9 c

##  c cc @&c8c c

Ú   Ú   

" c c/ +c c c\$cc cc c c> c c9 c
cc" ccc\$c  # c c! c c c    \$c  ccc c

ĺc c
c  c c c   \$c c Fc 9 
c c  c \$ c  c c 9 c c c  c
 c c c \$c 
c c  cc9 cc c

c  # c  c c  c c c  c c Fc 9 c  c \$c   c \$c  c c
 !c  c9 c c c c9 c \$ c #c

## c c  cc c9 c c  c c  

c c cc c\$ c
 # c c c! c c c  c

## 3ccc9 c  cc  \$

cccc c c c c9 c c c c
# c c%c  c c !c  c9 c c c c #cc c c\$ c c
c c  c

{   

## 5cc  \$c cc9 

c c  c   c c#  c c

5cFc9 
c c  c   c c  c9 c  c c c c

>  \$cc2 c

     
 


  c ! cc/ +c c c c c  c c c   cc cc c4   c
 cc c c c   cc

  c +c c c  G  c   c  c c c 1c c c  G  c   c c \$c
\$c  \$c c   c c c   c  c c  c c \$c  \$c c  c  c
# c c c c c c  ccc\$c c/ CH    c  c

c
/ c cc
c
c P P
  
  c

c
c

[ 
    c

##   ! "   c

6c c c
c c
6c c c
c  c
c 6c  c cc c

## 6c  c c c

6c   c cc cc
c 6c   c c! " c c c

 P  c

##   \$  "  c

6c  c#c cc
6c \$ c c c c
6c c! c%&   c c! c" c
6c ! cc" c c c

m %

 c  c   c c c c c  c  c   c c  c ' c c c
 (c)c c c c cc  c 'c c ccc ' cc  *c
ccc ccc ccc  (c cc c cc c
& 'c c c  c c c c  c  c    c  *c c    c c  c c
 c      cc c  c  c   (c +c c  c ,c  c c
c  c c c (c

## ) cc c c   ccc cc c  cc ccc c

c c c 'c (c ) c  c c  c  c c   c c c  c   c c
& c  c c c c c c (c -c c  c  c   c c c
 cc  c cc c *ccccc c c ccc
c c   (c  c  c c c c c  c  c c c c c
c *cc  ccc ccc cc  (c  *c cc
c ccc ccc cc c c   (c

)c 'c c  c c c  c c 'c c  c c c  c  ,c c
 c c  c c  c c &   (c+c  c  c & c c
  c c c  c&   (c .c  c c c c   c c c c  c c
  (c+c c cc c ccc c c  (c


!
%P& P
  
  

 c c   c c c c c c  c cc c *c c c  c c c
  c&  (ccc cccî   cc c'c

ÿ (01c
c

ÿ (21c
c

## 'cc  cccc  cî c ccc c

ÿ (31c
c

c c  c ' c   c c  c  c c   (c )c  c /c c  cî  c
c c

ÿ ( 1c
c

## .c c cc cc c cc ccc c cc cccc

c c cc(c cc  & cc ccc ccc cc
 cc c cc (c)c c cc cî  ccc'c

ÿ (41c

! cc

c
c
c

## ) c   ccÿ (41ccccccc c c

c

ÿ (51c
c

ÿ (61c
c

!
%[ 
 m  

 c  c  c   c c  c  c c c   c c   c c 'c c c 'c
c c c c  c    (c .c  c  c  c c c  c
c   cc 'c  c c  c c   (c )c c /c c
c c c c ccc c c cc cc cccc  c
cc  cc (c) cc cc 'ccc  c c
c c ' c  cccc (c

## .ccc c7c  ccc (c

[ 
 m  
  £c.c c  c c  cc cccccc
 c î cc c îcc,c c8 (c)c cc'c c  cc
c 'c c  cîcc c  c îcc c c c c
   c  c c  c  c c c c  (c ) c  c 'c  c   c c
 cc c c9c (c)c /c cc c c c ccc c c
 c:î:cc ccî(c

§  \$ [     £c ) c c c   c c   c c  (c
) cc c cc c  c c  c ccc cc
cc c c  c cc c (c;cc c c
  c  c    c   c c ,c c  c  c   c c
  c c  *ccc 'c  c îcc:cî  c c  (c) c c
'c c  cc cc c c c  (c.c c cc cccc c
c 'c c  c îc c c c ' c    c c  c c
c c (c   c c c  c c c , c cîc c c  c
 (c

!
' ! \$ £c 'c c c c c0c cc c c   (c) c c
 cc cc ccc c  (c cc ccccc
 c  c  c c  c c c c c  c  c c *c c
 c c c c ,c  c  c  c  (c < c c  c c c  c
c c ccc c c  cc (c c c ccc c c
c c 'c c c=>c(c  cc c ccc c cc c
c c c c, (c

## ! c  cc'c c c ccccc c cc, (c%cc

c  c  c c c  c c  c  c '*c c  c c
 c c  c c   c  c c c cè P   (c c cè Pc c c c
c c ccc c*cc *c c cc  cc c c
  c c c  c   c  c  c c *c c  c c  c  c  c c  c
 c  c c   c c  (c  c  c  c c  c  c  c 'c
 c cc ,c c c 'c cc (c.c c ccc c
 c  c  c  c c 'c c c c c c  c & c c c c
  (c

!
% m    

## cccc ccc cî c c'c î c îc '(c c


c c  c c c c c  c   c c cî c  c
'cîccî '(c)cccc c/cc cî  c

c
ÿ (?1c
c

c c /c  c  c 'c c  c  c  c cî
(c )c c  c
cc c/cc c  c cc'c

c
ÿ (@1c
c

## .cc c'cc cccc c/cc c  c c

c'c

ÿ (0=1c
c
c

)c  c cc c c c c8cc c c  (c.c c cc cc
ÿ (51c c ÿ (61c c c  c c   c c c c c  c c ÿ (@1c c ÿ (0=1(c
< c cc  c ccc  ccc cc c, cc *cc
c  c cc c c cc c  ccc cc c c
 c c   (c .c  c c c   c Aî c Aîc c c c
 ccc c c c c cc ccc  c ccc  c
 c ccc'c c (c

 c c  c c   c c c   c c ' c c (c (0*c c  c 2c c
c 3c  c   (c +c c  0c  c c ,c  c c ,c  4c  c c  c  (c

 c 2*c 3cc c c 9c   (c )c c  cc c cc  c
ccc)c (0(c
 c c ccc  c ccc)c (2(c) cc
 c c cc c  c ccc  c3(0(3(c.c c cc cccc
 c c c c  c c c   c c cc c c
 c c   ccc 'ccc c  (c

## \$()(*+           (

+)(*  
  
\$ \$       \$()(*(

## ,   -c 

c  
\$ \$,? J -c
&(c **(c@c~c*&*c ~c***c
&Bc **Bc@c~c*(Bc ~c**(*c
(c **]c@c~c*(*c ~c**(Bc
(Bc **Bc@c~c*(Bc ~c**(*c
]c **Bc@c~c*(Bc ~c**(*c
Bc **Ic@c~c*]*c ~c**&*c
]Bc *&*c@c~c*B*c ~c**JBc

## +)( ?         \$()(*(

c "c c c c c
"c()'(c  c &'(&c*c *c c *J)'(c
c~c&]&&Bc @c~c')&B]c @c~cI])(c
cc &'(&c)BIc  c *')&Bc*c c *J)'(c
@c~c')&B]c c~c&I&'](c @c~c]I*JJc @c~cI])(c
c*c c *')&Bc((&&Bc  c *J)'(cc *]I*Ic
@c~c]I*JJc c~c&&**(Jc @c~cI])(c @c~c(]*Ic
c*c *c c *J)'(c&&BIcc~cB)J](c c *I])c
@c~cI])(c @c~c&'(&c
cc *J)'(cc *J)'(cc *]I*Icc *I])c(]*Ic
@c~cI])(c @c~cI])(c @c~c(]*Ic @c~c&'(&c c~c&&I'](c

## )c c c  *cc *cc ccc  ccc c

c c c )c (3(c .c  c c c c c   c c c  c c c c
c  (c ) c  c c  c c c c c  c c c  c  c
 (c)c ccc cccc ,c cccc c
ccc c cc , (c) cc c c&  ccc'c
c cÿcc1(c cc c cc c&  c c c c c   *ccc
  cc c& (c c c c(c (0ccc ,c c  c c c'c
 ccc c c4c cc c cc c cccc c  (c

+)(.   \$ / \$       (

## 4cc 4c c . c c 3 c

c  cÿ 1c cÿ1c cÿ+-c 9cÿ 1c cÿ+1c cÿ 1c
&c &*Bc *c c c *c *c
(c "c c *c *c ')c )(c
c "c c *c *c Bc &]c
]c "c c *c *c &)c Ic
c
Bc &*(c c ]Ic c (]c &&c

!
 §%!     !      #  
P "  

.c c  cc c  cc   c cc c c c&   c c! 
" c  (c c c   c c c c c c c  c &   c c c  c
 c c  c *cc*c(((c*c(cc c&   ccc'c
ÿ (221c

## c*c(((c*ccc   c cc c *cc*c(((c*c(c+cccc c c c

   c

  cc c

ÿ (231c

## c c cccc  c cc  cc *cc*c(((c*c(cc cc

   cA *cc*c(((c*cc c c c ccccc c   c c
 c cc'c

ÿ (2 1c

## )c   ccÿ (231cccccc c cc cccÿ (2 1c c

c
ÿ (241c
c

+c c c c c  c &  c c )' c 7 c  c  c c  c   c
c *cc*c (((c *cc(c !c c  c c c c  c c c  *c c
  c c *c Bc0*c(((c*c  cc c

ÿ (251c
c

ÿ (261c

## )c & cc cc c ccc cc c cc

cc c c ccc  c c *c(((c*cc(c+ccccc   c c
ÿ (261c c

ÿ (2?1c

ccc,Bc0*c((((c c
c

## cc)' c7 c  c c c'ccc2ccc c *cc c

c ccc c   cccc c c (c+c ccc

ÿ (2@1c

) c c c c  c c  c A ÿ01c*c Bc 0*c (((c *c (c +c c c c A *c (((c *c
Ac c c &  c ,c ÿ (2?1c c  & 'c  c *c (((c *c(c )c   c
   ccA *c Bc0*c(((c*c   c ccc c& '(c
c

c


c
!
§%   P "  %

##  &\$  c

6c     0
 "  c
6c !    P   c

c c ccc  c c ' c  cc cc c c9c  ccc
 c c cÿ 1c  ccc cc BccCccCc0(c
0c c c ccc
,c  (c +c c  c c c  c &   c cîccîcc c ÿ (@1c c
ÿ (0=1c '(c)c c c! " c c c c c cc c cc
' c c c&   c c P   £ccc ccc
 c cc ccc c cc   c cc&  c cc'ccc
ÿ (261(c cc c c *c c&  c c cc c

ÿ (3=1c

## cc cc cc c  c c

ÿ (301c
c

.ccc ccc 8c cc cc cÿc Cc Dc01ccÿc Cc D01(c cc
 cc4 c c c(c (0c cccc cc 8cÿ6cc61(c)c   c cc
 cc c   £c

&&cc±c&c cc±c&
c&(cc±c&c c
c(&cc cc±c&c c((cc cc

c

ÿ (321c

ÿ (331c

ÿ (3 1c

ÿ (341c

## !  *%c ccc  c cc c  c::cÿ=1c cc  c  cc Dc

0c c  cc  c ccc  ccc ,c (c

!  %c c c  c ::ÿ=1cc c c  c c  c Dc 0c  c c /c c
 c  c& c c cc c cA ÿ=1c(c

!  .%c c c  c ::cÿ=1cc c c  c c  cc c c /c c
 c cc& c c cc c cA ÿ=1c(c

## !  .%c cc c::cÿ=1cc c c  cc cc  (c

!  )%c cÿ (3=1c c ccAc::cÿ=1cEc::cÿ=1(c

c
ÿ (351c
c

ÿ (361c
c

## !  2%c,cccc  cc cc c (c)cc  cc' (c

- c  c ,c  c 0c c c cc  c c c  cc 'c ÿ (351c c
ÿ (361(c

   0
 "  
+c c c  cc  c cc  c cc c(c) c cc
   
   ,)(2- ,)(3-(cc ccc
ccc cÿ (21c c

ÿ (3?1c
c

ÿ (3@1c
c

## &(   0**

c cc  c

ÿ ( =1c

.c c c c c ÿ (321c cî7 c c c c  c cî c  c  c(c )c
cî ÿ (3?1cc c c  cî Èc  cc'c

ÿ ( 01c
c
c

c
c

ÿ ( 21c
c

## (   0ô c

c ccc c

ÿ ( 31c

##  cÿ (3 1cc cccc c cccccc c c c

 c (c cÿ (3@1cccc

ÿ ( 1c
c

ÿ ( 41c
c

## [(   0* c

c cc ôc c

ÿ ( 51c

 c c  c ÿ (331*c c  c cô c c c  c c c  c c
 c c c c c c::c(c cî Èc *cccc cÿ (3?1c

ÿ ( 61c
c

ÿ ( ?1c

  0 c

##  cc  c c c cc

ÿ ( @1c

c
 cî Èc ccc cÿ (3@1c

ÿ (4=1c
c

## 'c cî Bc cc

ÿ (401c

+c c cc cc  c c c  *cc  c cc
  c  c 'c  (c  c c ' c  c c  c c
c
  c ccc   c(c
c

## !    P   

)c! " c c c c c c cc ' c c(c (0ccc ' c
ccc   ccc) c (0c c (3(c cÿ ( 01cccc

c
c

c
c

c
c

c'c

c
c

c
c

c
c

 c

c
c

c
c

##  c cc c c c ccc c c cÿ ( 61cc'cc

c cc c c c c (c< cc 8c c  cÿ3cFc 1ccc 8c
c  cÿ cFc31(c) c c c c 'cc c  ccc c cc
'c

## )c c cc ccc  cc ccÿ ( 1ccÿ ( 41(c+c

ccc

  c c  c  c c c c c  c c ÿ ( ?1(c ) c
c ccc'c

## 'cccc c cÿ (4=1cc Bc ÿ0£3*c0£31(c< cc c c

c cc cc ccÿ (401(c) c cc  cc

c
c

c
c

##   & 'cc  cc c cc

c
c
)cc  cccc cc c ccc c

## )c c c  cc6c  cccc ccc c  c

c
c c0=D5c(c

c
!
§%  P  

.c  c  c c c   c c   c cc  c (c .c  c  c c  c c c  c
\$  cc! " c  c'cc c (c< cc! 
" c  c  c  c c c \$  c  (c )c  c  c
  *c c cc c cc ccc  ccc cc
cc)c ( (c.ccc c c cccc c cc c06 (5c+c
 cc c c c060c+(c) c ccc ccc c c c3(5c+c c
cc c c (c.c c cc cccccc c cc ,c cc
cc c cc c cc  c cÿ (51ccÿ (61ccc c c
c c (c

+)()   \$ / \$       
\$
(

##    \$c  \$  c  c

 
(c >  cc cc .c>c 6c>K c .c>c .c>K c

c
ÿ (421c
c

c
ÿ (431c
c

c
ÿ (4 1c
c

c
ÿ (441c
c

## )cc c c cc c c cc)c (4(c) cc c ccè P  c

 c c  (c.ccc cccc  cc c c3(5c+*cc ccc
cc c cc (c'ccc  cccè   ccc
c  (c) c c cc'c

c
ÿ (451c
c

## +)(1P       (

  
c  
 c
 ,"4-c
c\$c  c>c c\$c  c>c
&c &*&*'Bc (c 'I)]']c ('*&c
&c (BBB)&c Bc (B(('Jc *()]c
(c &J)&J*c c &J]II(c *&(IIc
c *J'J)c ]c *JIIIc ***I'c
Bc &B&B(*c (c &]')J)c *&I]]c
Bc &I)(&(c c &I*'Bc *&&Jc
Bc &B]B))c ]c &B(&&(c *(]B]c
c


[      (((  P  
  ccc c02(c)c c c 0c c Bc0(=4cGc=>cc ccc c
2c c Bc=(@?25cGcDc4(=02 >cc (c cÿ (421cccc

c c c

## ) cc c c c c 0c c

c c c c  c c  c  c c  0(c )c  c  c
cc 2c c

+ c c

) c c cc c c c0=0(=3@4c+c cc c c c c 0c
ccc c02*c@?(5 @ c+c c 2(c) c ccc ccc
c c c2(3@=0c+(c! cc

+ c c

## cP  c  c ccc c02(c) ccc c c c c c

 ccc (c

cc c

## +c cc c& 'c'c ccc c c'c 2c cc

c 'c  0(c )c  c   c  c   c  c  c c c (c
! c c c c c  c  c 'c c & c c *c c  c  c c  c
 c  c c  c  c  c c c  c  c  c  (c ) c c
 cè 02c c cc c c cc cc 0c cc 
2c c c  c c  c  c c c c  c c   (c c c  c
 c c  'c *c c c c c   c  c cc'c c c
  (c %c c  c  c  c  c /c c c  c c  c c
  c ccccccc & c cc c cc c c
cc (c)ccccc c cc c=(=3(c) ccc
 cc/c

cc c
c 0(c 'ccc/cc 2ccc

cc c

## )c c c ccc  c02cc04cc  cc(c (2(c

ÿ c

ÿc

  ô  
          ô 

       
          
c
c
 
    
!
§%   \$  " %

## )c  c  c   c c  c c )

(c  c c c c  c c c
c c  c (c )c  c   c c    c c  c  c c c
 (c.c c cc 8cc cc cc  c  ccc
c 'c cc c c c(c

6c   \$5 "  c
6c  !   c
6c !  \$  #  \$ P c
6c   P   c

##  \$? "  %

) c cc  ccccc'c c  (c)c  ccc ,c'cc
c
/
67 8c

c 7'7c c 7'7c c  'c ccc c c c  c c c c
 (c.c c ccc ' cc c)c (0ccccc ccc
c c   c c  c  c 7887*c c 7'7c   c c c c   (c
) c c c  cccc ((c)c c c cc (c

% Function ybus
% THIS IS THE PROGRAM FOR CREATING Ybus MATRIX.c

function [yb,ych]=ybus

## zz=[0 0.02+0.1i 0 0 0.05+0.25i

0.02+0.1i 0 0.04+0.2i 0 0.05+0.25i
0 0.04+0.2i 0 0.05+0.25i 0.08+0.4i
0 0 0.05+0.25i 0 0.1+0.5i
0.05+0.25i 0.05+0.25i 0.08+0.4i 0.1+0.5i 0];c

## ych=j*[0 0.03 0 0 0.02

0.03 0 0.025 0 0.020
0 0.025 0 0.02 0.01
0 0 0.02 0 0.075
0.02 0.02 0.01 0.075 0];c

## % The Ybus matrix is formed herec

for i=1:5
for j=1:5
if zz(i,j) == 0
yb(i,j)=0;
else
yb(i,j)=-1/zz(i,j);
end
end
endc

for i=1:5
ysum=0;
csum=0;
for j=1:5
ysum=ysum+yb(i,j);
csum=csum+ych(i,j);
end
yb(i,i)=csum-ysum;
c
endc
 !   %

## + !  \$       9\$ ((+ 

 
 (

  (+ \$    

  

  
( +  \$       
  
\$/     \$      \$       

 (+ \$ \$ \$   (
% THIS IS A GAUSS-SEIDEL POWER FLOW PROGRAMc

clear allc

d2r=pi/180;w=100*pi;c

## % The Y_bus matrix isc

[ybus,ych]=ybus;
g=real(ybus);b=imag(ybus);c

## % The given parameters and initial conditions arec

p=[0;-0.96;-0.35;-0.16;0.24];
q=[0;-0.62;-0.14;-0.08;-0.35];
mv=[1.05;1;1;1;1.02];
th=[0;0;0;0;0];
v=[mv(1);mv(2);mv(3);mv(4);mv(5)];c

del=1;indx=0;c

## % The Gauss-Seidel iterations starts herec

while del>1e-6c

% P-Q busesc

for i=2:4c

tmp1=(p(i)-j*q(i))/conj(v(i));
tmp2=0;
for k=1:5
if (i==k)
tmp2=tmp2+0;
else
tmp2=tmp2+ybus(i,k)*v(k);
end
endc

vt=(tmp1-tmp2)/ybus(i,i);
v(i)=v(i)+acc*(vt-v(i));c

endc

% P-V busc

q5=0;
for i=1:5
q5=q5+ybus(5,i)*v(i);
end
q5=-imag(conj(v(5))*q5);
tmp1=(p(5)-j*q5)/conj(v(5));
tmp2=0;
for k=1:4
tmp2=tmp2+ybus(5,k)*v(k);
endc

vt=(tmp1-tmp2)/ybus(5,5);
v(5)=abs(v(5))*vt/abs(vt);c

% Calculate P and Qc

for i=1:5
sm=0;
for k=1:5
sm=sm+ybus(i,k)*v(k);
end
s(i)=conj(v(i))*sm;
endc

% The mismatchc

delp=p-real(s)';
delq=q+imag(s)';

delpq=[delp(2:5);delq(2:4)];
del=max(abs(delpq));
indx=indx+1;
if indx==1
pause
endc

endc

## 'GS LOAD FLOW CONVERGES IN ITERATIONS',indx,pause

'FINAL VOLTAGE MAGNITUDES ARE',abs(v)',pause

## 'FINAL ANGLES IN DEGREE ARE',angle(v)'/d2r,pause

'THE REAL POWERS IN EACH BUS IN MW ARE',(real(s)+[0 0 0 0
0.24])*100,pausec


0.11])*100c


## +   \$ \$             #

)(* \$  P   (+   0
 
  
    \$ (+ \$\$   
        */  .(+ \$
 \$ \$   (
% Program nwtraph
% THIS IS A NEWTON-RAPHSON PROGRAM
% We have to solve three nonlinear equations given by
%
% g1=x1^2-x2^2+x3^2-11=0
% g2=x1*x2+x2^2-3x3-3=0
% g3=x1-x1*x3+x2*x3-6=0
%
% Let us assume the initial conditions of x1=x2=x3=1
%
% The Jacobian matrix is
%
% J=[2x1 -2x2 2x3
% x2 x1+2x2 -3
% 1-x3 x3 -x1+x2];c

clear allc

x=[1;1;1];c

## % The Newton-Raphson iterations starts herec

del=1;
indx=0;
while del>1e-6c

g=[x(1)^2-x(2)^2+x(3)^2-11;x(1)*x(2)+x(2)^2-3*x(3)-
3;x(1)-x(1)*x(3)+x(2)*x(3)-6];
J=[2*x(1) -2*x(2) 2*x(3);x(2) x(1)+2*x(2) -3;1-x(3)
x(3) -x(1)+x(2)];
delx=-inv(J)*g;
x=x+delx;c

del=max(abs(g));
indx=indx+1;c

endc

## 'NEWTON-RAPHSON SOLUTION CONVERGES IN

ITERATIONS',indx,pausec

'FINAL VALUES OF x ARE',xc


##  P   

)c! " c c c c c  ccc c  H((c)c   c cc
 ccc,c'c'c

## ÿ1I2cccccc c c ccc

ccccccccccccccccc cc+c

## .c c cc ccc cc ccc cc   ccc c

cc c c cccc ccc(c)c c c cc
! " c c c cc (c

% THIS IS THE NEWTON-RAPHSON POWER FLOW PROGRAMc

clear allc

d2r=pi/180;w=100*pi;c

## % The Ybus matrix isc

[ybus,ych]=ybus;c

g=real(ybus);b=imag(ybus);c

## % The given parameters and initial conditions arec

p=[0;-0.96;-0.35;-0.16;0.24];
q=[0;-0.62;-0.14;-0.08;-0.35];
mv=[1.05;1;1;1;1.02];
th=[0;0;0;0;0];c

del=1;indx=0;c

## % The Newton-Raphson iterations starts herec

while del>1e-6
for i=1:5
temp=0;
for k=1:5
temp=temp+mv(i)*mv(k)*(g(i,k)-j*b(i,k))*exp(j*(th(i)-th(k)));
end
pcal(i)=real(temp);qcal(i)=imag(temp);
endc

% The mismatchesc

delp=p-pcal';
delq=q-qcal';c

## % The Jacobian matrixc

for i=1:4
ii=i+1;
for k=1:4
kk=k+1;
j11(i,k)=mv(ii)*mv(kk)*(g(ii,kk)*sin(th(ii)-th(kk))-
b(ii,kk)*cos(th(ii)-th(kk)));
end
j11(i,i)=-qcal(ii)-b(ii,ii)*mv(ii)^2;
endc

for i=1:4
ii=i+1;
for k=1:4
kk=k+1;
j211(i,k)=-mv(ii)*mv(kk)*(g(ii,kk)*cos(th(ii)-th(kk))-
b(ii,kk)*sin(th(ii)-th(kk)));
end
j211(i,i)=pcal(ii)-g(ii,ii)*mv(ii)^2;
end
j21=j211(1:3,1:4);

j12=-j211(1:4,1:3);
for i=1:3
j12(i,i)=pcal(i+1)+g(i+1,i+1)*mv(i+1)^2;
end

j22=j11(1:3,1:3);
for i=1:3
j22(i,i)=qcal(i+1)-b(i+1,i+1)*mv(i+1)^2;
end
jacob=[j11 j12;j21 j22];c

delpq=[delp(2:5);delq(2:4)];c

corr=inv(jacob)*delpq;c

th=th+[0;corr(1:4)];c

mv=mv+[0;mv(2:4).*corr(5:7);0];c

del=max(abs(delpq));c

indx=indx+1;c

endc

preal=(pcal+[0 0 0 0 0.24])*100;c

preac=(qcal+[0 0 0 0 0.11])*100;c

## % Power flow calculationsc

for i=1:5
v(i)=mv(i)*exp(j*th(i));
endc

for i=1:4
for k=i+1:5
if (ybus(i,k)==0)
s(i,k)=0;s(k,i)=0;
c(i,k)=0;c(k,i)=0;
q(i,k)=0;q(k,i)=0;
cur(i,k)=0;cur(k,i)=0;
else
cu=-(v(i)-v(k))*ybus(i,k);
s(i,k)=-v(i)*cu'*100;
s(k,i)=v(k)*cu'*100;
c(i,k)=100*abs(ych(i,k))*abs(v(i))^2;
c(k,i)=100*abs(ych(k,i))*abs(v(k))^2;
cur(i,k)=cu;cur(k,i)=-cur(i,k);
end
end
endc

pwr=real(s);
qwr=imag(s);c

q=qwr-c;c

% Power lossc
ilin=abs(cur);c

for i=1:4
for k=i+1:5
if (ybus(i,k)==0)
pl(i,k)=0;pl(k,i)=0;
ql(i,k)=0;ql(k,i)=0;
else
z=-1/ybus(i,k);
r=real(z);
x=imag(z);
pl(i,k)=100*r*ilin(i,k)^2;pl(k,i)=pl(i,k); ql(i,k
)=100*x*ilin(i,k)^2;ql(k,i)=ql(i,k);
end
end
c
endc