Académique Documents
Professionnel Documents
Culture Documents
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:
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 =
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 =
V=
1.0500 + 0.0000i
0.9825 - 0.0310i
1.0011 - 0.0353i
iter =
V=
1.0500 + 0.0000i
0.9816 - 0.0520i
1.0008 - 0.0459i
iter =
V=
1.0500 + 0.0000i
0.9808 - 0.0578i
1.0004 - 0.0488i
iter =
V=
1.0500 + 0.0000i
0.9803 - 0.0594i
1.0002 - 0.0497i
iter =
V=
1.0500 + 0.0000i
0.9801 - 0.0598i
1.0001 - 0.0499i
iter =
1.0500 + 0.0000i
0.9801 - 0.0599i
1.0000 - 0.0500i
iter =
V=
1.0500 + 0.0000i
0.9800 - 0.0600i
1.0000 - 0.0500i
iter =
8
voltage after 8 thiteration
V=
1.0500 + 0.0000i
0.9800 - 0.0600i
1.0000 - 0.0500i
V=
1.0500 + 0.0000i
0.9800 - 0.0600i
1.0000 - 0.0500i
ans =
1.8998 - 0.7999i
ans =
1.9998 - 0.9999i
current in the line 2 1
ans =
-1.8998 + 0.7999i
ans =
-0.6398 + 0.4799i
ans =
-1.9998 + 0.9999i
ans =
0.6398 - 0.4799i
ans =
1.9948 + 0.8399i
power flow in the line 1 3
ans =
2.0998 + 1.0499i
ans =
-1.9098 - 0.6699i
ans =
-0.6558 - 0.4319i
ans =
-2.0498 - 0.8999i
ans =
0.6638 + 0.4479i