Vous êtes sur la page 1sur 11

PROGRAM:

clear all;
clc
temp=0;
t=0;
alpa=input('enter hte acceleration factor');
err=1;
tol=5e-5;
iter=1;
n=input('enter the no of buses');
V=ones(n,1);
P=zeros(n,1);
Q=zeros(n,1);
for i=1:n
for j=1:n
fprintf('Y(%d %d)=',i,j)
ybus(i,j)=input('');
end
end
ybus
for i=1:n
for j=1:n
if i~=j
y(i,j)=-ybus(i,j);
else
y(i,j)=ybus(i,j);
end
end
end
i=1;
V(i)=input('enter the slack bus voltage:');
for i=2:n
fprintf('enter bus %d details:',i);
type(i)=input('enter the type of bus:1 forPQ 2 for PV:');
P(i)=input('P in pu=');
if type(i)==1
Q(i)=input('Q in pu=');
else
V(i)=input('V in pu=');
end
end
while((err>tol)&&(iter<10))
display('iter no.=');
iter
Vold=V;
for i=2:n
if type(i)==1
for j=1:n
if j~=i
temp=temp+V(j)*y(i,j);
t=t+y(i,j);
end
end
s(i)=complex(P(i),-Q(i));
V(i)=((-1*s(i)/conj(V(i)))+temp)/t;
temp=0;
t=0;
else
for j=1:n
if j~=i
temp=temp+V(j)*y(i,j);
t=t+y(i,j);
end
end
Q(i)=-imag(conj(V(i))*((V(i)*t)-temp));
temp=0;
t=0;
for j=1:n
if j~=i
temp=temp+V(j)*y(i,j);
t=t+y(i,j);
end
end
s(i)=complex(p(i),-Q(i));
CV=s(i)/conj(V(i));
Vang=(CV+temp)/t;
delta=angle(Vang);
Vreal=abs(V(i))*cos(delta);
Vimg=abs(V(i))*sin(delta);
V(i)=complex(Vreal,Vimg);
temp=0;
t=0;
end
end
fprintf('voltage after %d thiteration',iter);
V;
V=Vold+alpa*(V-Vold)
Vabs=abs(V-Vold);
err=max(Vabs);
fprintf('voltage after %d th iteration',iter);
iter=iter+1;
end
fprintf('convergence is reached in %d iterations',iter-1)
display('voltage after convergence=');
V
for i=1:n
for j=1:n
if i~=j
I(i,j)=y(i,j)*(V(i)-V(j));
SF(i,j)=V(i)*conj(I(i,j));
end
end
end
for i=1:n
for j=1:n
if i~=j
fprintf('current in the line %d %d ',i,j)
I(i,j)
end
end
end
for i=1:n
for j=1:n
if i~=j
fprintf('power flow in the line %d %d',i,j)
SF(i,j)
end
end
end
OUTPUT:

enter hte acceleration factor1

enter the no of buses3

Y(1 1)=20-50i

Y(1 2)=-10+20i

Y(1 3)=-10+30i

Y(2 1)=-10+20i

Y(2 2)=26-52i

Y(2 3)=-16+32i

Y(3 1)=-10+30i

Y(3 2)=-16+32i

Y(3 3)=26-62i

ybus =

20.0000 -50.0000i -10.0000 +20.0000i -10.0000 +30.0000i

-10.0000 +20.0000i 26.0000 -52.0000i -16.0000 +32.0000i

-10.0000 +30.0000i -16.0000 +32.0000i 26.0000 -62.0000i

enter the slack bus voltage:1.05

enter bus 2 details:enter the type of bus:1 forPQ 2 for PV:1

P in pu=2.566

Q in pu=1.102
enter bus 3 details:enter the type of bus:1 forPQ 2 for PV:1

P in pu=1.386

Q in pu=0.452

iter no.=

iter =

voltage after 1 thiteration

V=

1.0500 + 0.0000i

0.9825 - 0.0310i

1.0011 - 0.0353i

voltage after 1 th iterationiter no.=

iter =

voltage after 2 thiteration

V=
1.0500 + 0.0000i

0.9816 - 0.0520i

1.0008 - 0.0459i

voltage after 2 th iterationiter no.=

iter =

voltage after 3 thiteration

V=

1.0500 + 0.0000i

0.9808 - 0.0578i

1.0004 - 0.0488i

voltage after 3 th iterationiter no.=

iter =

voltage after 4 thiteration

V=
1.0500 + 0.0000i

0.9803 - 0.0594i

1.0002 - 0.0497i

voltage after 4 th iterationiter no.=

iter =

voltage after 5 thiteration

V=

1.0500 + 0.0000i

0.9801 - 0.0598i

1.0001 - 0.0499i

voltage after 5 th iterationiter no.=

iter =

voltage after 6 thiteration


V=

1.0500 + 0.0000i

0.9801 - 0.0599i

1.0000 - 0.0500i

voltage after 6 th iterationiter no.=

iter =

voltage after 7 thiteration

V=

1.0500 + 0.0000i

0.9800 - 0.0600i

1.0000 - 0.0500i

voltage after 7 th iterationiter no.=

iter =

8
voltage after 8 thiteration

V=

1.0500 + 0.0000i

0.9800 - 0.0600i

1.0000 - 0.0500i

voltage after 8 th iterationconvergence is reached in 8 iterationsvoltage after convergence=

V=

1.0500 + 0.0000i

0.9800 - 0.0600i

1.0000 - 0.0500i

current in the line 1 2

ans =

1.8998 - 0.7999i

current in the line 1 3

ans =

1.9998 - 0.9999i
current in the line 2 1

ans =

-1.8998 + 0.7999i

current in the line 2 3

ans =

-0.6398 + 0.4799i

current in the line 3 1

ans =

-1.9998 + 0.9999i

current in the line 3 2

ans =

0.6398 - 0.4799i

power flow in the line 1 2

ans =

1.9948 + 0.8399i
power flow in the line 1 3

ans =

2.0998 + 1.0499i

power flow in the line 2 1

ans =

-1.9098 - 0.6699i

power flow in the line 2 3

ans =

-0.6558 - 0.4319i

power flow in the line 3 1

ans =

-2.0498 - 0.8999i

power flow in the line 3 2

ans =

0.6638 + 0.4479i

Vous aimerez peut-être aussi