Shailesh Fast Decouple
Shailesh Fast Decouple
clear all
% |Bus | Type | Vsp | theta | PGi | QGi | PLi | QLi | Qmin | Qmax | B_shunt |
bus_info =[ 1 1 1.05 0 0.0 0 0 0 0 0 0.0;
2 2 1.05 0 0.5 0 0 0 -0.75 0.75 0.0;
3 2 1.07 0 0.6 0 0 0 -0.90 0.90 0.0;
4 3 1.0 0 0.0 0 0.7 0.7 0 0 0.0;
5 3 1.0 0 0.0 0 0.7 0.7 0 0 0.0;
6 3 1.0 0 0.0 0 0.7 0.7 0 0 0.0;];
%%
from_bus=line_info(:,1);
to_bus=line_info(:,2);
r=line_info(:,3);
x=line_info(:,4);
b=line_info(:,5);
a=line_info(:,6);
z=r+1i*x;
y=1./z;
b=1i*b;
nl=length(from_bus); %Number of Transmission Lines
%%
%Generating Ybus from data given
end
%Diagonal Elements
for j=1:n_bus
for k=1:nl
if from_bus(k)==j
Y(j,j)=Y(j,j)+y(k)/a(k)^2+b(k);
elseif to_bus(k)==j
Y(j,j)=Y(j,j)+y(k)+b(k);
end
end
end
%Printing Y bus
Y
%%
G=real(Y);
B=imag(Y);
BMVA=100;
type=bus_info(:,2);
sl=find(type==1);%slack bus
pq_buses=find(type==3);%load bus
number_pq=length(pq_buses);
pv_buses=find(type==1|type==2)%gen bus
number_pv=length(pv_buses);
B1=imag(Y);
B1(sl,:)=[];
B1(:,sl)=[];
B2=imag(Y);
B2(:,pv_buses(1:number_pv))=[];
B2(pv_buses(1:number_pv),:)=[];
V=bus_info(:,3);
delta=bus_info(:,4);
Pgenerated=bus_info(:,5)/BMVA;
Qgenerated=bus_info(:,6)/BMVA;
Pload=bus_info(:,7)/BMVA;
Qload=bus_info(:,8)/BMVA;
Qc=bus_info(:,9)/BMVA;
Qmin=bus_info(:,9)/BMVA;
Qmax=bus_info(:,10)/BMVA;
Pspecified=Pgenerated-Pload;
Qspecified=Qgenerated-Qload;
Tolerance=1;
Iteration=1;
while Tolerance>1e-4
P=zeros(n_bus,1);
Q=zeros(n_bus,1);
k=1;
for i=1:n_bus
if type(i)==3
V(i)=V(i)+del_V(k);
k=k+1;
end
end
M=[dmp;dmq];
Iteration=Iteration+1;
Tolerance=max(abs(M));
end
%%
%Showing Resulting values of V ,Tolerance taken = 1e-4
disp('--------********--------********--------********--------');
disp(' Fast De-Coupled Method Final V Values ');
disp('********************************************************');
disp(' |Bus | |Voltage| |Angle |')
for m=1:n_bus
fprintf(' %g ' ,m);
fprintf(' %.4f ' ,V(m));
fprintf(' %.4f ',delta(m));
fprintf('\n');
end