Professional Documents
Culture Documents
Experiment 4 - Contingency Analysis
Experiment 4 - Contingency Analysis
APPARATUS:
1. MATLAB R2022a
ALGORITHM:
3. Eliminate the 4th row and 4th column of the B-1 matrix, as bus 4 is the slack
bus. This is done because for slack bus, 𝜃4 = 0, by definition.
𝛉𝟏 𝐏𝟏
−𝟏
[𝛉𝟐 ] = 𝐁 [𝐏𝟐 ]
𝛉𝟑 𝐏𝟑
5. Calculate the initial power flows in the lines using the angles using the below
equation:
𝛉𝐢 − 𝛉𝐣
𝐏𝐢𝐣 =
𝐱 𝐢𝐣
where 𝑙 is a line connected between buses 𝑁 and 𝑀 and 𝑖 is the bus to which
the tripped generator is connected.
where ∆𝐏𝐢 = −𝐏𝐢 is the change in generation at bus 𝑖 and 𝐏𝐥,𝐨𝐥𝐝 is the power
flow through line 𝑙 before the generator on bus 𝑖 fails.
8. Compute Line Outage Distribution Factor (LODF) and revised power flow by
using LODF for the remaining buses. Assume lines 1-2 and 1-4 undergo an
outage.
𝟏
− 𝐗 𝐣𝐧 + 𝐗 𝐣𝐦 − 𝐗 𝐢𝐦 )
𝐱 𝐢𝐣 (𝐗 𝐢𝐧
𝐝𝐥,𝐤 =
𝟏
𝟏− (𝐗 − 𝟐𝐗 𝐧𝐦 + 𝐗 𝐦𝐦 )
𝐱 𝐧𝐦 𝐧𝐧
MATLAB CODE:
clc;clear;
format shortG; format compact;
linedata=[1 1 2 0.5;
2 2 3 0.75;
3 3 4 0.4;
4 4 1 0.9;];
P=[ 0.75;
-0.5;
-1.1 ];
nlines=length(linedata(:,1));
FrontBus=linedata(:,2);
ToBus=linedata(:,3);
nbuses=max(max(FrontBus),max(ToBus));
B_total=zeros(nbuses);
B=zeros(nbuses-1);
theta=zeros(nbuses,1);
P_initial=zeros(nbuses,1);
%susceptance
for k=1:nlines
l=linedata(k,2);
m=linedata(k,3);
B_total(l,l)=B_total(l,l)+1/linedata(k,4);
B_total(m,m)=B_total(m,m)+1/linedata(k,4);
B_total(m,l)=-1/linedata(k,4);
B_total(l,m)=B_total(m,l);
end
% 4x4 to 3x3
for i=1:nbuses-1
for j=1:nbuses-1
B(i,j)=B_total(i,j);
end
end
B;
B_inverse=inv(B);
theta=B_inverse*P;
theta(4,1)=0; % slack bus
A=zeros(nbuses,1);
B_inverse1=B_inverse;
% GSF
i=0;
j=1;
while(1)
i=i+1;
j=j+1;
A(i)=(B_inverse1(i,1)-B_inverse1(j,1))/linedata(i,4);
j=mod(j,nbuses); % brings j from 4 to 1
if (i==nbuses && j==1)
break;
end
end
A;
DelP1=-0.75;
for i=1:4
P_rev(i)=P_initial(i)+(A(i)*DelP1);
end
P_rev
% Line 1-2 is tripped
X=B_inverse1;
% LODF
i=1;
j=2;
denom=1-((1/linedata(1,4))*(X(1,1)-2*X(1,2)+X(2,2)));
while(1)
i=i+1;
j=j+1;
D(i-1)=((1/linedata(i,4))*(X(i,1)-X(j,1)+X(j,2)-
X(i,2)))/denom;
j=mod(j,nbuses); % brings j from 4 to 1
if (i==nbuses && j==1)
break;
end
end
D;
RESULT:
Thus, contingency analysis using generation shift factor and LODF was
carried out using MATLAB and the results were verified.