26/11/23 10:32 PM C:/Users/Best Buy/Desktop... /fast - DC.M 1 of 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

26/11/23 10:32 PM C:\Users\Best Buy\Desktop...\fast_dc.

m 1 of 2

%%2023MELEP009
%SANA RASOOL
%%Fast Decoupled program
tic
global nbus npvs
% FB TB R X B/2
linedata = [1 2 0.042 0.168 0.041;
1 5 0.031 0.126 0.031;
2 3 0.031 0.126 0.031;
3 4 0.024 0.136 0.082;
3 5 0.053 0.210 0.051;
4 5 0.063 0.252 0.061];
% linedata= [1 2 0.0180 0.0540 0.0045
% 1 4 0.0150 0.0450 0.0038
% 2 3 0.0180 0.0560 0
% 3 9 0.0200 0.0600 0
% 4 5 0.0130 0.0360 0.0030
% 4 6 0.0200 0.0660 0
% 5 6 0.0600 0.030 0.0028
% 5 7 0.0140 0.0360 0.0030
% 6 9 0.0100 0.0500 0
% 7 8 0.0320 0.0760 0
% 8 9 0.0220 0.0650 0];

%% Bus type 1 slack bus, 2 PV, 3 PQ


% No. Type |v| d Pg Qg Pl Ql Qmin Qmax

busdata= [1 1 1 0 0 0 0 0 0 0;
2 2 1 0 50 0 0 0 -50 50;
3 2 1 0 100 0 0 0 -50 50;
4 3 1 0 0 0 115 60 0 0;
5 3 1 0 0 0 85 40 0 0];
% busdata=[1, 1, 1.03, 0, 0, 0, 0, 0;
% 2, 3, 1, 0, 0, 0, 10, 5;
% 3, 3, 1, 0, 0, 0, 25, 15;
% 4, 3, 1, 0, 0, 0, 60, 40;
% 5, 2, 1.06, 0, 80, 0, 10, 5;
% 6, 3, 1, 0, 0, 0, 100,80;
% 7, 3, 1, 0, 0, 0, 80, 60;
% 8, 2, 1.01, 0, 120, 0, 40, 20;
% 9, 3, 1, 0, 0, 0, 20, 10];

%% Extracting the available information


[nbus, nbranch, Ybus, Yb, theta, G, B]=Y_bus(linedata);
[bus type V del P Q Qmin Qmax]=busdatafn_withlimits(busdata);
%%
Psp=P;
Qsp=Q;
iter=1;
error=1;
while error>1e-10
Pcal=zeros(nbus,1);
Qcal=zeros(nbus,1);
for i=1:nbus
for j=1:nbus
26/11/23 10:32 PM C:\Users\Best Buy\Desktop...\fast_dc.m 2 of 2

Pcal(i)=Pcal(i)+V(i)*V(j)*Yb(i,j)*cos(del(i)-del(j)-theta(i,j));
Qcal(i)=Qcal(i)+V(i)*V(j)*Yb(i,j)*sin(del(i)-del(j)-theta(i,j));
end
end
PV=find(type==1|type==2);
PQ= find(type==3);
npvs=length(PV);
npq=length(PQ);
%MISMATCH:
dp=Psp-Pcal;
dq=Qsp-Qcal;
% mismatch=[dp ; dq];
dpa=dp(2:nbus); %corresponding to all buses
dqa=dq(npvs+1:nbus); %corresponding to PQ buses
M1=dpa./V(2:nbus);
M2=dqa./V(npvs+1:nbus);
M=[M1;M2];
error=max(abs(M));
B1=B(2:nbus,2:nbus);
B2=B(npvs+1:nbus,npvs+1:nbus);
Ddel=-B1\M1;
DV=-B2\M2;
del(2:nbus)=del(2:nbus)+Ddel;
V(npvs+1:nbus)=V(npvs+1:nbus)+DV;
iter=iter+1;
end
%DISPLAY RESULTS:
disp('RESULTS')
disp('The total no of iterations is')
iter %Display the number of iterations.
disp('Final V and del are:')
Vanddelta=[V del]
type
toc

You might also like