You are on page 1of 4

PROGRAM:

%Gauss Seidel Load Flow method

clear all;
clc;
j=sqrt(-1);

r=input('enter the no of buses');


l=input('enter the no of lines');
ybus=zeros(r,r);
for r=1:l
sb(r)=input('sending bus');
eb(r)=input('ending bus');
a=input('enter the tap ratio');
res(r)=input('enter the resistance');
x(r)=input('enter the inductance');
hlc1(r)=input('enter the half line charging admittance');

z(r)=res(r)+(j*x(r));
hlc(r)=j*hlc1(r);
y(r)=1/z(r);

%y bus formation

m=sb(r);
n=eb(r);

if a==0
ybus(m,m)=ybus(m,m)+y(r)+hlc(r);
ybus(n,n)=ybus(n,n)+y(r)+hlc(r);
ybus(m,n)=ybus(m,n)-y(r);
ybus(n,m)=ybus(m,n);
else
ybus(m,m)=ybus(m,m)+(y(r)/a)+((y(r)/a)*((1/a)-1));
ybus(n,n)=ybus(n,n)+(y(r)/a)+((y(r))*(1-(1/a)));
ybus(m,n)=ybus(m,n)-(y(r)/a);
ybus(n,m)=ybus(m,n);
end
end
disp(ybus);
r=input('enter the no of buses');
pv=input('enter the no of p-v buses');
vold(1)=input('enter the voltage of slack bus');
vnew(1)=vold(1);

for i=2:pv
vold(i)=input('enter the voltage of pv bus');
qlimiti(i)=input('enter the initial value of Q for pv bus ');
qlimitf(i)=input('enter the final value of Q for pv bus');
end

for i=(1+pv):r
vold(i)=1;
end
for i=pv:r
p(i)=input('enter the real power in pu');
end
for i=(pv+1):r
qcal(i)=input('enter the reactive power in pu');
end

for i=2:pv
qcal1(i)=0;
for k=1:r

qcal1(i)=(qcal1(i)+((vold(i)*ybus(i,k)*vold(k))));
end
qcal2(i)=-(imag(qcal1(i)));
if qlimiti(i)<qcal2(i) && qcal2(i)<qlimitf(i)
qcal(i)=qcal2(i);
else
qcal(i)=qlimiti(i);
end
end
disp(qcal)
for i=2:pv
j=sqrt(-1);
a(i)=1/(ybus(i,i));
b(i)=(((p(i)-(j*qcal(i))))/vold(i));
c=0;
for k=1:i-1
c=c+(ybus(i,k)*vnew(k));
end
d=0;
for k=i+1:r
d=d+(ybus(i,k)*vold(k));
end

vnew1(i)=a(i)*(b(i)-c-d);
[ang(i) mag(i)]=cart2pol(real(vnew1(i)),imag(vnew1(i)));
[a(i),b(i)]=pol2cart(ang(i),vold(i));
vnew(i)=complex(a(i),b(i));
disp(vnew(i));

end
for i=(pv+1):r
j=sqrt(-1);
a(i)=1/(ybus(i,i));
b(i)=(((p(i)-(j*qcal(i))))/vold(i));
c=0;
for k=1:i-1
c=c+(ybus(i,k)*vnew(k));
end
d=0;
for k=i+1:r
d=d+(ybus(i,k)*vold(k));
end
vnew(i)=a(i)*(b(i)-c-d);
disp(vnew(i));
end
OUTPUT:

enter the no of buses6


enter the no of lines7
sending bus1
ending bus6
enter the tap ratio0
enter the resistance.123
enter the inductance.518
enter the half line charging admittance0
sending bus1
ending bus4
enter the tap ratio0
enter the resistance.080
enter the inductance.370
enter the half line charging admittance0
sending bus4
ending bus6
enter the tap ratio0
enter the resistance.087
enter the inductance.407
enter the half line charging admittance0
sending bus5
ending bus2
enter the tap ratio0
enter the resistance.282
enter the inductance.640
enter the half line charging admittance0
sending bus2
ending bus3
enter the tap ratio0
enter the resistance.723
enter the inductance1.050
enter the half line charging admittance0
sending bus6
ending bus5
enter the tap ratio1
enter the resistance0
enter the inductance.3
enter the half line charging admittance0
sending bus4
ending bus3
enter the tap ratio1
enter the resistance0
enter the inductance.133
enter the half line charging admittance0
Columns 1 through 5

0.9922 - 4.4095i 0 0 -0.5583 + 2.5820i 0


0 1.0214 - 1.9545i -0.4449 + 0.6461i 0 -0.5765 + 1.3085i
0 -0.4449 + 0.6461i 0.4449 - 8.1649i 0 + 7.5188i 0
-0.5583 + 2.5820i 0 0 + 7.5188i 1.0605 -12.4504i 0
0 -0.5765 + 1.3085i 0 0 0.5765 - 4.6418i
-0.4339 + 1.8275i 0 0 -0.5023 + 2.3496i 0 + 3.3333i

Column 6

-0.4339 + 1.8275i
0
0
-0.5023 + 2.3496i
0 + 3.3333i
0.9362 - 7.5104i

enter the no of buses6


enter the no of p-v buses2
enter the voltage of slack bus1.02
enter the voltage of pv bus1.02
enter the initial value of Q for pv bus -.25
enter the final value of Q for pv bus.50
enter the real power in pu.50
enter the real power in pu.55
enter the real power in pu0
enter the real power in pu.30
enter the real power in pu.50
enter the reactive power in pu.13
enter the reactive power in pu0
enter the reactive power in pu.18
enter the reactive power in pu.05
0 0.0399 0.1300 0 0.1800 0.0500

1.0058 + 0.1697i

1.0115 + 0.0805i

1.0152 + 0.0482i

1.0329 + 0.1091i

1.0435 + 0.1268i

You might also like