0% found this document useful (0 votes)
41 views3 pages

Shailesh Fast Decouple

This document contains MATLAB code to perform a power flow analysis on an electrical distribution system using the fast decoupled method. It defines matrices containing line and bus data, generates the Ybus matrix, initializes variables, and runs an iterative process to calculate bus voltages and angles until mismatches converge within a specified tolerance. The results of the power flow solution are then displayed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

Shailesh Fast Decouple

This document contains MATLAB code to perform a power flow analysis on an electrical distribution system using the fast decoupled method. It defines matrices containing line and bus data, generates the Ybus matrix, initializes variables, and runs an iterative process to calculate bus voltages and angles until mismatches converge within a specified tolerance. The results of the power flow solution are then displayed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

clc

clear all

% | Start | End |Resistance| X |Succeptance/2|Tap Ratios|

line_info = [ 1 2 0.1 0.20 0.02 1.0;


1 4 0.05 0.20 0.02 1.0;
1 5 0.08 0.30 0.03 1.0;
2 3 0.05 0.25 0.03 1.0;
2 4 0.05 0.10 0.01 1.0;
2 5 0.10 0.30 0.02 1.0;
2 6 0.07 0.20 0.025 1.0;
3 5 0.12 0.26 0.025 1.0;
3 6 0.02 0.10 0.01 1.0;
4 5 0.20 0.40 0.04 1.0;
5 6 0.10 0.30 0.03 1.0;];

% |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

n_bus=max(max(from_bus),max(to_bus));%Total Buses in System

%%
%Generating Ybus from data given

%Initializing Ybus with zeros to save computation time


Y=zeros(n_bus,n_bus);

%Off Diagonal Elements of Y bus


for i=1:nl
Y(from_bus(i),to_bus(i))=Y(from_bus(i),to_bus(i))-y(i)/a(i);
%Since Y matrix will be symmetrical , all tap ratios taken as 1 ie
%a(i)=1 always
Y(to_bus(i),from_bus(i))=Y(from_bus(i),to_bus(i));

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);

%Main Decouple Formulas


for m=1:n_bus
for n=1:n_bus
P(m)=P(m)+V(m)*V(n)*(G(m,n)*cos(delta(m)-delta(n))+B(m,n)*sin(delta(m)-delta(n)));
Q(m)=Q(m)+V(m)*V(n)*(G(m,n)*sin(delta(m)-delta(n))-B(m,n)*cos(delta(m)-delta(n)));
end
end

%Calculating Mismatches in each Iteration


delta_p=Pspecified-P;
delta_q=Qspecified-Q;
dmp=delta_p;
dmq=delta_q;
dmp(sl,:)=[];
dmq(pv_buses(1:number_pv),:)=[];
dP=delta_p./V;
dQ=delta_q./V;
dP(sl,:)=[];
dQ(pv_buses(1:number_pv),:)=[];
x=-B1\dP;
del_V=-B2\dQ;
delta(2:n_bus)=delta(2:n_bus)+x;

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

You might also like