0% found this document useful (0 votes)
6 views

Mpse Record

The document outlines a MATLAB program designed to perform power flow analysis using the Newton Raphson method, focusing on the calculation of reactive power support needed for voltage maintenance in a PQ bus. It includes detailed formulas for real and reactive power at buses, power mismatch, and the Jacobian matrix, along with an algorithm for the load flow analysis. Additionally, it provides system and line data, as well as the program code for implementing the analysis.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Mpse Record

The document outlines a MATLAB program designed to perform power flow analysis using the Newton Raphson method, focusing on the calculation of reactive power support needed for voltage maintenance in a PQ bus. It includes detailed formulas for real and reactive power at buses, power mismatch, and the Jacobian matrix, along with an algorithm for the load flow analysis. Additionally, it provides system and line data, as well as the program code for implementing the analysis.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 71

Ex .No.

1 DATE: 10-02-2022

POWER FLOW ANALYSIS BY NEWTON RAPHSON METHOD

AIM: To write MATLAB code to solve load flow problem using Newton Raphson method
and to determine amount of reactive power support needed to maintain voltage profile in a
PQ bus.

FORMULAE:
1. Real power at bus ‘i’:
n
Pi=∑ |V j|∗|V i|∗|Y ij|∗cos(θ ij +δ j −δ i )
j=1

2. Reactive power at bus ‘i’:


n
Qi=−∑ |V j|∗|V i|∗|Y ij|∗sin(θij +δ j−δ i )
j=1

3. Real and Reactive Power mismatch:

∆ Pi =P schd −P i, calc

∆ Qi =Qschd −Q i ,calc

4. Correction Matrix:

[ ][ ] [ ]
−1
∆δ J J ∆P
= 1 2 ∗
∆|V | J 3 J 4 ∆Q

5. Jacobian:

5.1 J 1:

Diagonal:
n
∂ Pi
= ∑ |V |∗|V i|∗|Y ij|∗sin ⁡(θij + δ j−δ i)
∂ δ i j=1 ; j
j≠1

Non-Diagonal:
∂ Pi
=−|V j|∗|V i|∗|Y ij|∗sin ⁡(θ ij +δ j −δ i )
∂δj

5.2 J 2:

1
Diagonal:

n
∂ Pi
=( 2∗|V i|∗|Y ij|∗cos θ ii ) + ∑ |V j|∗|Y ij|∗cos (θij +δ j−δ i )
∂Vi j=1 ;
j≠1

Non-Diagonal:
∂ Pi
=|V i|∗|Y ij|∗cos(θ ij + δ j−δ i)
∂V j

5.3 J 3:

Diagonal:
n
∂ Qi
= ∑ |V |∗|V i|∗|Y ij|∗cos ⁡(θij +δ j−δ i )
∂ δ i j=1 ; j
j≠ 1

Non-Diagonal:
∂ Qi
=−|V j|∗|V i|∗|Y ij|∗cos ⁡(θij + δ j−δ i)
∂δj

5.4 J 4 :

Diagonal:
n
∂ Qi
=( −2∗|V i|∗|Y ii|∗sin θii )− ∑ |V j|∗|Y ij|∗sin(θij + δ j−δ i)
∂Vi j=1 ;
j≠1

Non-Diagonal:

∂Qi
=−|V i|∗|Y ij|∗sin ⁡(θ ij + δ j −δ i)
∂V j

6. Line Flows:
¿ ¿
S L, ij=S ij + S ji Sij =V i∗I ij S ji=V j∗I ji

I ij =( V i−V ij )∗Y ij I ji =−I ij

ALGORITHM:

2
Step 1: Start.

Step 2: Read the bus and line data.

Step 3: Compute the Y Bus using the given line data.

Step 4: Set the iteration count ‘k’ to 0 and initialize the bus voltage to 1for PQ bus and
voltage angle (δ ) to 0 for PV bus.

Step 5: Compute power mismatch vector using the appropriate formulae.

Step 6: Check for convergence. If converged, go to step -12

[ ]
k
∆P
≤ε
∆ Qk

Step 7: Compute Qi for all PV buses

Step 8: Check for Q limit violation. If there is a violation, convert those PV buses to PQ
buses.

Step 9: Calculate Jacobian matrix.

Step 10: Determine the corrected values


k +1 k k
V i =V i +∆ V i

Step 11: Set k=k+1 and go to step-5

Step 12: Compute the power loss, reactive power generation and line flows.

System Data: Base MVA=100MVA

LINE DETAILS:

3
1 0+0.1j 2

Slack bus 0+0.2j 0+0.2j

BUS DETAILS:

LINE DATA:

Line Start End Resistance Reactance HC_admittance


number bus bus
1 1 2 0 0.1 0
2 2 3 0 0.2 0
3 1 3 0 0.2 0

BUS DATA:
Bus no Type P Q |V | δ Qmin Qmax
Pg Pd Qg Qd
1 Slack - - 0 0 1 0 - -
2 PV 1.8184 - 0 - 1.1 - 0 3.5
3 PQ 0 1.251 - 1.2574 1 - - -
7

PROGRAM:
%%formation of ybus
line_data = xlsread('nr_method_line.xlsx');
bus_data = xlsread('nr_method_bus.xlsx');
no_buses = size(bus_data);
no_of_buses = no_buses(1);
no_lines = size(line_data);

4
no_of_lines=no_lines(1);
Y_Bus = zeros(no_of_buses);
tolerance = 0.001;
iter_count=0;
for i=1:no_of_lines
start_bus = line_data(i,2);
end_bus = line_data(i,3);
R = line_data(i,4);
X = line_data(i,5);
HC_Admitatnce = line_data(i,6);
ith_admittance = 1/(R + (1i*X));
Y_Bus(start_bus,start_bus)=Y_Bus(start_bus,start_bus)+ith_admittance+HC_Admitatnce;
Y_Bus(end_bus,end_bus)=Y_Bus(end_bus,end_bus)+ith_admittance+HC_Admitatnce;
Y_Bus(end_bus,start_bus)=Y_Bus(end_bus,start_bus)-ith_admittance;
Y_Bus(start_bus,end_bus)=Y_Bus(end_bus,start_bus);
end
mag_Y=abs(Y_Bus);
theta_Y=angle(Y_Bus);
G = real(Y_Bus);
B = imag(Y_Bus);
%%reading bus data
for i=1:no_of_buses
bus_no = bus_data(:,1);
bus_type = bus_data(:,2);
slack_bus = find(bus_type==1);
PV_bus = find(bus_type==2);
PQ_bus = find(bus_type==3);
Pg = bus_data(:,3);
Qg = bus_data(:,4);

5
Pd = bus_data(:,5);
Qd = bus_data(:,6);
mag_V = bus_data(:,7);
del = bus_data(:,8);
Qmin = bus_data(:,9);
Qmax = bus_data(:,10);
Psch = Pg - Pd;
Qsch = Qg - Qd;
end
PV_buses = size(PV_bus);
no_PV_bus = PV_buses(1);
PQ_buses = size(PQ_bus);
no_PQ_bus = PQ_buses(1);
%% Newton Raphson Load Flow
while(1==1)
P=zeros(no_of_buses,1);
Q=zeros(no_of_buses,1);
for i=1:no_of_buses
for j=1:no_of_buses
P(i)=P(i)+(mag_V(i)*mag_V(j)*mag_Y(i,j)*cos(theta_Y(i,j)+del(j)-del(i)));
Q(i)=Q(i)-(mag_V(i)*mag_V(j)*mag_Y(i,j)*sin(theta_Y(i,j)+del(j)-del(i)));
end
end
%%checking for Q limit violation
for n=2:no_of_buses
if bus_type(n)==2;
Qg=Q(n)+Qd(n);
if Qg > Qmax(n)
V(n)=V(n)-0.01;

6
elseif Qg < Qmin(n)
V(n)=V(n)+0.01;
end
end
end
dPa=Psch-P;
dQa=Qsch-Q;
dP=dPa(2:no_of_buses);
k=1;
dQ=zeros(no_PQ_bus,1);
for i=1:no_of_buses
if bus_type(i)==3
dQ(k,1)=dQa(i);
k=k+1;
end
end
M=[dP;dQ];
if(all(abs(M)<tolerance)) % || iter_count>=1)
break;
end
iter_count=iter_count+1;
%%Formation of Jacobian matrix
%%formation of J1 (H)
J1 = zeros(no_of_buses-1,no_of_buses-1);
for i=1:no_of_buses-1
m=i+1;
for j=1:no_of_buses-1
n=j+1;
if m==n

7
for n=1:no_of_buses
J1(i,j)=J1(i,j)+mag_V(m)*mag_V(n)*(-G(m,n)*sind(del(m)-del(n))+
B(m,n)*cosd(del(m)-del(n)));
end
J1(i,j)=J1(i,j)-mag_V(m)^2*B(m,m);
else
J1(i,j)=mag_V(m)*mag_V(n)*(G(m,n)*sind(del(m)-del(n))-
B(m,n)*cosd(del(m)-del(n)));
end
end
end
%%formation of J2 (N)
J2=zeros(no_of_buses-1,no_PQ_bus);
for i=1:no_of_buses-1
m=i+1;
for j=1:no_PQ_bus
n=PQ_bus(j);
if m==n
for n=1:no_of_buses
J2(i,j)=J2(i,j)+mag_V(n)*(G(m,n)*cos(del(m)-del(n))+B(m,n)*sin(del(m)-del(n)));
end
J2(i,j)=J2(i,j)+mag_V(m)*G(m,m);
else
J2(i,j)=mag_V(m)*(G(m,n)*cos(del(m)-del(n))+B(m,n)*sin(del(m)-del(n)));
end
end
end
%%formation of J3 (M)
J3=zeros(no_PQ_bus,no_of_buses-1);

8
for i=1:no_PQ_bus
m=PQ_bus(i);
for j=1:no_of_buses-1
n=j+1;
if m==n
for n=1:no_of_buses
J3(i,j)=J3(i,j)+mag_V(m)*mag_V(n)*(G(m,n)*cos(del(m)-
del(n))+B(m,n)*sin(del(m)-del(n)));
end
J3(i,j)=J3(i,j)-mag_V(m)^2*G(m,m);
else
J3(i,j)=mag_V(m)*mag_V(n)*(-G(m,n)*cos(del(m)-del(n))-B(m,n)*sin(del(m)-
del(n)));
end
end
end
%% Formation Of J4(L)
J4=zeros(no_PQ_bus,no_PQ_bus);
for i=1:no_PQ_bus
m=PQ_bus(i);
for j=1:no_PQ_bus
n=PQ_bus(j);
if m==n
for n=1:no_of_buses
J4(i,j)=J4(i,j)+mag_V(n)*(G(m,n)*sin(del(m)-del(n))-B(m,n)*cos(del(m)-del(n)));
end
J4(i,j)=J4(i,j)-mag_V(m)*B(m,m);
else
J4(i,j)=mag_V(m)*(G(m,n)*sin(del(m)-del(n))-B(m,n)*cos(del(m)-del(n)));

9
end
end
end
J=[J1 J2;J3 J4];
X=inv(J)*M;
% Change in angle
dTheta=(X(1:no_of_buses-1));

% change in volatge magnitude


dV=X(no_of_buses:end);
del(2:no_of_buses)=del(2:no_of_buses)+dTheta;
k=1;
for n=2:no_of_buses
if bus_type(n)==3
mag_V(n)=mag_V(n)+dV(k);
k=k+1;
end
end
end
for a=1:no_of_buses
[x,y]=pol2cart(del(a),mag_V(a));
V(a) = complex(x,y);
end
for m=1:no_of_buses
fprintf('\n voltage in the bus %d is %f angle%f(degree)',m,abs(V(m)),rad2deg(angle(V(m))));
end
%% calculating slack bus power
S1 = P(1) + (1i*Q(1));
fprintf('\n slack bus power is %f',S1);

10
%% calculating line flows
S=zeros(no_of_lines);
I=zeros(no_of_lines);
for i=1:no_of_lines
for j=1:no_of_lines
if i~=j
I(i,j) = I(i,j) + (V(i) - V(j))* (-Y_Bus(i,j));
%I(j,i) = I(j,i) - I(i,j);
S(i,j) = S(i,j) + ( V(i)* conj(I(i,j)));
%S(j,i) = S(j,i) + ( V(j)* conj(I(j,i)));
end
end
end
%% calculating line losses
Total_loss = 0;
Power_Loss = zeros(no_of_lines);
for i=1:no_of_lines
for j=1:no_of_lines
if (i~=j)
Power_Loss(i,j) =Power_Loss(i,j)+ S(i,j) + S(j,i);
Total_loss = Total_loss + Power_Loss(i,j);
end
end
end
base_MVA = 100;
fprintf('\n slack bus power is %f MW %f MVAR',real(S1)*base_MVA,imag(S1)*
base_MVA);
for i=1:no_of_lines
for j=1:no_of_lines
if (i~=j)

11
fprintf('\n IL%d%d = %f + %fi ',i,j,real(I(i,j)),imag(I(i,j)));
fprintf('\nS%d%d=%fMW%fMVAR',i,j,real(S(i,j))*base_MVA,imag(S(i,j))*base_MVA);
fprintf('\nSL%d%d=%fMW
%fMVAR',i,j,real(Power_Loss(i,j))*base_MVA,imag(Power_Loss(i,j))*base_MVA);
end
end
end
fprintf('\n The total power loss in the system is %f MW %f MVAR',real(Total_loss)*
base_MVA/2,imag(Total_loss)*base_MVA/2);

OUTPUT:

Y_Bus:

[ 0.0000 -15.0000i 0.0000 +10.0000i 0.0000 + 5.0000i

0.0000 +10.0000i 0.0000 -15.0000i 0.0000 + 5.0000i

0.0000 + 5.0000i 0.0000 + 5.0000i 0.0000 -10.0000i]

Iteration 1 Iteration 2 Iteration 3


delP2 0.0747 0.0026 4.3770e-05
delP3 -0.1036 -0.0039 -5.1320e-05
delQ3 -0.1409 -0.0043 -4.9919e-06
del2 0.0854 0.0872 0.0873
del3 -0.0745 -0.0868 -0.0872
V3 0.9203 0.9007 0.9000

No. of iterations = 3

Bus voltages:

voltage in the bus 1 is 1.000000 angle 0.000000 (degree)

voltage in the bus 2 is 1.100000 angle 5.000574 (degree)

voltage in the bus 3 is 0.900039 angle -4.998688 (degree)

SLACK BUS POWER:


P1 = -560670755 MW

Q1 = -44.121345 MVAR

12
SYSTEM LINE FLOWS:
From To IL
1 2 -0.958823+0.958132i
2 3 0.871527-0.995985i
1 3 0.392115-0.516919i
2 1 0.958823-0.958132i
3 2 -0.871527+0.995985i
3 1 -0.392115+0.516919i

POWER FLOWS:
From To Real Power MW Reactive Power MVAR
1 2 95.88 95.81
1 3 -39.22 -51.67
2 1 -95.88 -114.19
2 3 -85.96 -117.48
3 1 39.22 43.26
3 2 85.96 82.45

TOTAL POWER LOSS:


Ploss = 0.0000000 MW

Qloss =61.823660 MVAR

RESULT:
MATLAB code to solve load flow problem using Newton Raphson Method has been
successfully executed and slack bus power, system line flows and total system losses is also
determined.

13
Ex.No.2 DATE:24-02-2022

POWER FLOW ANALYSIS BY FAST DECOUPLED POWER


FLOW METHOD

AIM: To write MATLAB Code to solve load flow problem using Fast Decoupled Method.

FORMULAE:
1. Real Power bus at ‘i’:
P=V ∗|V |∗Y ∗cos ⁡(θ+δ−δ)
2. Reactive Power at bus ‘i’:

Q=−V∗|V |∗Y ∗sin(θ+ δ−δ)

3. Real and Reactive Power Mismatch:


∆ P=P−P , ∆ Q=Q−Q
4. Correction Matrix:
[ ∆ δ ] =[ B' ]∗[ ∆ P /|V|]

[ ∆ V ]= [ B' ' ]∗[ ∆ Q /|V|]

' ''
B corresponds to suceptances of all buses except slack bus. B corresponds
to suceptances of PQ buses.
5. Line Flows:
S=S +S S=V∗I ¿ S=V∗I ¿
I =V −V ∗Y I =−I

14
ALGORITHM:
Step 1: Start

Step 2: Read the bus and line data

Step 3: Compute the Y bus using the given line data

Step 4: Compute the B' and B' ' matrix from Y bus

Step 5: Set the iteration count ‘k’ to 0 and initialize the bus voltages to 1∠0 for PQ

bus and voltage angle (δ) to 0 for PV bus

Step 6: Compute power mismatch vector using the appropriate formulae

Step 7: Check for convergence. If converged go to step 12


∆P
∆Q ≤ε

Step 8: Compute Qi for all PV buses

Step 9: Check for Q limit violation. If there is violation, convert those PV buses to

PQ buses.

Step 10: Determine the correlated values

V=V+∆V

δ=δ+δV

Step 11: Set k=k+1 and go to step-5

Step 12: Compute the power loss, reactive power generation and line flows.

SYSTEM DATA:

15
0+0.1j 2
1

Slack bus 0+0.2j 0+0.2j

BUS DATA:
Bus no Type P Q |V | Δ Qmin Qmax
Pg Pd Qg Qd
1 Slack - - 0 0 1 0 - -
2 PV 1.8184 - 0 - 1.1 - 0 3.5
3 PQ 0 1.2517 - 1.2574 1 - - -

LINE DATA:

Line Start End Resistance Reactance HC_admittance


number bus bus
1 1 2 0 0.1 0
2 2 3 0 0.2 0
3 1 3 0 0.2 0

PROGRAM:
%%formation of ybus
line_data = xlsread('nr_method_line2.xlsx');
bus_data = xlsread('nr_method_bus2.xlsx');
no_buses = size(bus_data);
no_of_buses = no_buses(1);
no_lines = size(line_data);
no_of_lines=no_lines(1);

Y_Bus = zeros(no_of_buses);
tolerance = 0.001;
iter_count=0;

16
for i=1:no_of_lines
start_bus = line_data(i,2);
end_bus = line_data(i,3);
R = line_data(i,4);
X = line_data(i,5);
HC_Admitatnce = line_data(i,6);

ith_admittance = 1/(R + (1i*X));

Y_Bus(start_bus,start_bus)=Y_Bus(start_bus,start_bus)+ith_admittance+HC_Admitatnce;
Y_Bus(end_bus,end_bus)=Y_Bus(end_bus,end_bus)+ith_admittance+HC_Admitatnce;

Y_Bus(end_bus,start_bus)=Y_Bus(end_bus,start_bus)-ith_admittance;
Y_Bus(start_bus,end_bus)=Y_Bus(end_bus,start_bus);
end
mag_Y=abs(Y_Bus);
theta_Y=angle(Y_Bus);
G = real(Y_Bus);
B = imag(Y_Bus);
%%reading bus data
for i=1:no_of_buses
bus_no = bus_data(:,1);
bus_type = bus_data(:,2);
slack_bus = find(bus_type==1);
PV_bus = find(bus_type==2);
PQ_bus = find(bus_type==3);

Pg = bus_data(:,3);
Qg = bus_data(:,4);
Pd = bus_data(:,5);
Qd = bus_data(:,6);
mag_V = bus_data(:,7);
del = bus_data(:,8);
Qmin = bus_data(:,9);
Qmax = bus_data(:,10);
Psch = Pg - Pd;
Qsch = Qg - Qd;
end
PV_buses = size(PV_bus);
no_PV_bus = PV_buses(1);
PQ_buses = size(PQ_bus);
no_PQ_bus = PQ_buses(1);

17
while(1==1)
P=zeros(no_of_buses,1);
Q=zeros(no_of_buses,1);
for i=1:no_of_buses
for j=1:no_of_buses

P(i)=P(i)+(mag_V(i)*mag_V(j)*mag_Y(i,j)*cos(theta_Y(i,j)+del(j)-del(i)));

end
end

%%checking for Q limit violation


for n=2:no_of_buses
if bus_type(n)==2;
Qg=Q(n)+Qd(n);
if Qg > Qmax(n)
V(n)=V(n)-0.01;
elseif Qg < Qmin(n)
V(n)=V(n)+0.01;
end
end
end
dPa=Psch-P;
dP=dPa(2:no_of_buses);
%%formation of B' matrix
B_d = zeros(no_of_buses-1,no_of_buses-1);
for i=1:no_of_buses-1
m=i+1;
for j=1:no_of_buses-1
n=j+1;
B_d(i,j) = B_d(i,j) - B(m,n);
end
end
%%formation of B'' matrix
B_dd = zeros(no_PQ_bus,no_PQ_bus);
for i=1:no_PQ_bus
m=PQ_bus(i);
for j=1:no_PQ_bus
n=PQ_bus(j);
B_dd(i,j) = B_dd(i,j) - B(m,n);
end
end

18
%% Change in angle
A = zeros(no_of_buses-1,1);
for i=1:no_of_buses-1
A(i) = A(i) + (dP(i)/mag_V(i+1));
dTheta = inv(B_d)*A;
end
del(2:no_of_buses)=del(2:no_of_buses)+dTheta;
for a=1:no_of_buses
[x,y]=pol2cart(del(a),mag_V(a));
V(a) = complex(x,y);
end
%% change in volatge magnitude
for i=1:no_of_buses
for j=1:no_of_buses
Q(i)=Q(i)-(mag_V(i)*mag_V(j)*mag_Y(i,j)*sin(theta_Y(i,j)+del(j)-del(i)));
end
end
dQa=Qsch-Q;
dQ=zeros(no_PQ_bus,1);
k=1;
for i=1:no_of_buses
if bus_type(i)==3
dQ(k,1)=dQa(i);
k=k+1;
end
end

C = zeros(no_PQ_bus,1);
for i=1:no_PQ_bus
m=PQ_bus(i);
C(i) = C(i) + (dQ(i)/mag_V(m));
end

dV= inv(B_dd)*C;
k=1;
for n=2:no_of_buses
if bus_type(n)==3
mag_V(n)=mag_V(n)+dV(k);
k=k+1;
end
end
if(all((abs(A))<tolerance) & all(abs(C)<tolerance)) %|| iter_count>=1)
break;
end

19
iter_count=iter_count+1;
end
for a=1:no_of_buses
[x,y]=pol2cart(del(a),mag_V(a));
V(a) = complex(x,y);
end

for m=1:no_of_buses
fprintf('\nvoltageinthebus%dis%fangle%f(degree)',m,abs(V(m)),rad2deg(angle(V(m))));
end
%% calculating slack bus power
S1 = P(1) + (1i*Q(1));
fprintf('\n slack bus power is %f',S1);
%% calculating line flows
S=zeros(no_of_lines);
I=zeros(no_of_lines);
for i=1:no_of_lines
for j=1:no_of_lines
if i~=j
I(i,j) = I(i,j) + (V(i) - V(j))* (-Y_Bus(i,j));
%I(j,i) = I(j,i) - I(i,j);

S(i,j) = S(i,j) + ( V(i)* conj(I(i,j)));


%S(j,i) = S(j,i) + ( V(j)* conj(I(j,i)));
end
end
end
%% calculating line losses
Total_loss = 0;
Power_Loss = zeros(no_of_lines);
for i=1:no_of_lines
for j=1:no_of_lines
if (i~=j)
Power_Loss(i,j) =Power_Loss(i,j)+ S(i,j) + S(j,i);
Total_loss = Total_loss + Power_Loss(i,j);
end
end
end
base_MVA = 100;
fprintf('\n slack bus power is %f MW%fMVAR',real(S1)*base_MVA,imag(S1)*base_MVA);
for i=1:no_of_lines
for j=1:no_of_lines
if (i~=j)
fprintf('\n IL%d%d = %f + %fi ',i,j,real(I(i,j)),imag(I(i,j)));

20
fprintf('\n S%d%d = %f MW %f MVAR
',i,j,real(S(i,j))*base_MVA,imag(S(i,j))*base_MVA);
fprintf('\n SL%d%d = %f MW %f MVAR
',i,j,real(Power_Loss(i,j))*base_MVA,imag(Power_Loss(i,j))*base_MVA);
end
end
end
fprintf('\nThetotalpowerlossinthesystemis%fMW%fMVAR',real(Total_loss)*base_MVA/
2,imag(Total_loss)*base_MVA/2);

OUTPUT:

Y_Bus:

[ 0.0000 -15.0000i 0.0000 +10.0000i 0.0000 + 5.0000i

0.0000 +10.0000i 0.0000 -15.0000i 0.0000 + 5.0000i

0.0000 + 5.0000i 0.0000 + 5.0000i 0.0000 -10.0000i]

Iteration 1 Iteration 2 Iteration 3 Iteration 4


delP2 0.0827 0.0151 0.0032 5.4970e-04
delP3 -0.0348 -0.0146 -0.0023 -3.9180e-04
delQ3 -0.1127 -0.0190 -0.0033 -5.6895e-04
del2 0.0867 0.0871 0.0873 0.0873
del3 -0.0856 -0.0870 -0.0872 -0.0872
V3 0.9206 0.9005 0.9001 0.9001

No. of iterations = 4

voltage in the bus 1 is 1.000000 angle 0.000000 (degree)

voltage in the bus 2 is 1.100000 angle 5.000376 (degree)

voltage in the bus 3 is 0.900051 angle -4.998590 (degree)


SLACK BUS POWER: -0.5665-0.4416i

SYSTEM LINE FLOWS:


21
From To Real Power Reactive power
1 2 -0.9585 -0.9582
1 3 0.3920 0.5165
2 1 0.9585 1.1418
2 3 0.8593 1.1745
3 1 -0.3920 -0.4324
3 2 -0.8593 -0.8245

TOTAL SYSTEM LOSSES: 0.0000+0.6178i

RESULT:
MATLAB code to solve load flow problem using Fast decoupled has been successfully
executed and slack bus power, system line flows, total system losses were also
determined.

Ex.No.3 DATE: 3-03-2022

DISTRIBUTED LOAD FLOW ANALYSIS BY LADDER ITERATIVE


METHOD

AIM: To write MATLAB code to solve distributed load flow problem using ladder iterative
method.

FORMULAE:
 Backward sweep:

Node Current:
¿ ¿ ¿
I =S/V
 Forward sweep:
Line drop
V L = I L x ZL

Receiving end voltage


V R = Vs - V L
ALGORITHM:

Step 1 : Start
Step 2 : Set the iteration count 'k' equal to 0.Initialize the initial current to zero and Initial
22
voltage to 1+j0.

Step 3 : Compute the Node current using the appropriate formulae


Step 4 : Compute the Branch current Ib using Kirchhoff current law
Step 5 : Calculate the Line drop
Step 6 : Compute the Bus voltages based on the line drop
Step 7 : Check for convergence: if V≤ 𝜀,if converged got to next step or set k=k+1 and
go to step-3

SYSTEM DATA:
LINE DATA:

Line Starting Ending Resistance Reactance Length(feet)


number bus bus
1 1 2 0.3 0.6 3000
2 2 3 0.3 0.6 4000
BUS DATA:
Bus No Voltage Delta Pg(KW) Q(KVAR)
1 7200 0 0 0
2 7200 0 1500 750
3 7200 0 900 500

PROGRAM:
%%Reading line data
linedata = xlsread('linedata_ladder.xlsx');
busdata = xlsread('busdata_ladder.xlsx');
lines = size(linedata);
no_lines = lines(1);
line_num = linedata(:,1);
start_bus = linedata(:,2);
end_bus = linedata(:,3);
R = linedata(:,4);
X = linedata(:,5);
len = linedata(:,6);
Z = (R+(1i*X)).*(len/5280);
%%Reading bus data

23
buses = size(busdata);
no_buses = buses(1);
bus_num = busdata(:,1);
mag_V = busdata(:,2);
del = busdata(:,3);
V = complex(mag_V,del);
P = busdata(:,4);%kW
Q = busdata(:,5);%kVar
S = (P + (1i*Q));
tolerance = 0.0001;
iter = 0;
while(1==1)
I = zeros(no_buses,1);
Il = zeros(no_lines,1);
for i = no_buses:-1:1
I(i) = I(i)+(conj(S(i)/V(i))*1000);
end
for i=no_lines:-1:1
c=[];
e=[];
[c e] = find(linedata(:,2:3)==linedata(i,3));
if size(c,1)==1
Il(line_num) = I(end_bus(line_num(i)));
else
Il(line_num(i))=I(end_bus(line_num(i))) + sum(Il(linedata(c,1)))-Il(line_num(i));
end
end
%%forward sweep calc voltages
for i =1:no_buses
V_new(1) = V(1);
if (i>=2)
V_new(i) = V(i-1)-(Il(i-1)*Z(i-1));
end
end
error = [];
for i=2:no_buses
error = (V_new(i) - V(i))/V(i);
end
if(all(error)<tolerance)
break
end
iter = iter+1;
V = V_new;
end

24
Sline = zeros(no_buses);
for i=1:no_lines
p = start_bus(i);
q = end_bus(i);
Sline(p,q) = Sline(p,q) + (V(p)*conj(Il(p)));
end

OUTPUT:
Bus Current
Iteration I2 I3 I4
1 0.5102 - 0.2041i 0.3061 - 0.1020i 0.5102 - 0.2041i
2 0.5676 - 0.2572i 0.3544 - 0.1456i 0.6140 - 0.3072i
3 0.5879 - 0.2646i 0.3715 - 0.1521i 0.6579 - 0.3279i
4 0.5932 - 0.2691i 0.3758 - 0.1560i 0.6697 - 0.3400i

Branch Current
Iteration I 12
1 1.3265 - 0.5102i
2 1.5361 - 0.7099i
3 1.6173 - 0.7446i
4 1.6387 - 0.7650i

Voltage Magnitude
Iteration V2 V3 V4
1 0.8633 - 0.0388i 0.8235 - 0.0561i 0.7816 - 0.0653i
2 0.8345 - 0.0354i 0.7860 - 0.0527i 0.7301 - 0.0599i
3 0.8259 - 0.0375i 0.7751 - 0.0557i 0.7142 - 0.0639i
4 0.8230 - 0.0371i 0.7714 - 0.0553i 0.7086 - 0.0633i

Line Power Flow


S12 S23 S24 S21 S32 S42
1.6387 + 0.3151 + 0.5638 + 0.2549i -1.3770 - -0.2985 - -0.4961 -
0.7650i 0.1145i 0.5688i 0.0996i 0.1985i

Line Losses
L12 L23 L24
0.2616 + 0.1962i 0.0166 + 0.0149i 0.0677 + 0.0564i

25
RESULT:
The distribution load flow analysis of a given network is performed using Ladder iterative
method in MATLAB.
1) The Bus voltages.
2) Line flows.
3) Line losses are determined.

Ex. No.4 DATE: 10-03-2022

CONTINGENCY ANALYSIS: GENERATION SHIFT FACTORS AND


LINE OUTAGE DISTRIBUTION FACTORS

AIM: To perform contingency analysis for Generator shift factors and line outage
distribution factor.

FORMULAE:
1. Basic required matrices:

[X]=[B’]-1
θ= XP
2. PTDF:

3. LODF:

4. Change in power flow:

5. Required change to
reduce outage.
For Generator Outage:

26
For Transmission Line Outage:

∆ f l = [ PTDF i , j ,l + PTDF i , j ,k LODF l ,k ] ΔP i , j

ALGORITHM:
Step 1 : Set system model to initial conditions
Step 2 : Set i=1
Step 3 : Simulate an outage of generator i using the system model.
Step 4 : Check any line flows exceed limits, if yes display alarm message and go to Step 5. Or
else go to Step 5 directly.
Step 5 : Check any bus voltages outside limit, if yes display alarm message and go to Step 6.
Or else go to Step 6 directly.
Step 6 : Check last generator done. If no go to Step 3. If yes go to Step 7
Step 7 : Set l=1.
Step 8 : Simulate an outage of line l using the system model.
Step 9: Check any line flows exceeds limit. If yes display alarm message and go to Step
10. Or else go to Step 10 directly.

Step 10: Check any bus voltage outside limit. If yes end the process. If no set l=l+1 and go
to Step 8.

SYSTEM DATA:

LINE DATA:

Line number From bus To bus Reactance Max capacity


1 1 2 0.20 35
2 1 3 0.30 35
3 1 4 0.30 25
4 2 3 0.30 40

27
5 3 4 0.40 25
BUS DATA:
Pg Pd Bus Generator Power
nmber change Shift
30 0 1 0 1
30 0 2 1 0
0 30 3 0 0
0 30 4 0 0

PROGRAM:
%%contingency analysis
%%dc power flow method
line_data = xlsread('dcloadfl_line.xlsx');
busdata = xlsread('dcloadfl.xlsx');
no_buses = size(busdata);
no_of_buses = no_buses(1);
no_lines = size(line_data);
no_of_lines=no_lines(1);

Y_Bus = zeros(no_of_buses);
for i=1:no_of_lines
line_no = line_data(i,1);
start_bus = line_data(i, 2);
end_bus = line_data(i,3);
Xline(i)= line_data(i,4)
max_capacity(i)= line_data(i,5);

Y(i) = 1/(1i*Xline(i));
Y_Bus(start_bus,start_bus)=Y_Bus(start_bus,start_bus)+Y(i);
Y_Bus(end_bus,end_bus)=Y_Bus(end_bus,end_bus)+Y(i);

Y_Bus(end_bus,start_bus)=Y_Bus(end_bus,start_bus)-Y(i);
Y_Bus(start_bus,end_bus)=Y_Bus(end_bus,start_bus);
end
B = imag(Y_Bus);
%%formation of B' matrix
B_d = zeros(no_of_buses-1,no_of_buses-1);
for i=1:no_of_buses-1
m=i+1;
for j=1:no_of_buses-1

28
n=j+1;
B_d(i,j) = B_d(i,j) - B(m,n);
end
end
Xr = inv(B_d);
%%reading bus data
for i=1:no_of_buses
bus_no = busdata(:,1);
Pg = busdata(:,2);
Pd = busdata(:,3);
ne=length(busdata(:,1));%number of branches in system
Pa = Pg - Pd;
end
%%initial flows
P = Pa(2:end);
theta = inv(B_d)*P;
theta_a = [0;theta];
Pflow = zeros(no_of_lines);
for i = 1:no_of_lines
for j = 1:no_of_lines
if (i~=j)
Pflow(i,j) = Pflow(i,j) + (B(i,j)*(theta_a(i) - theta_a(j)));
end
end
end
Xd=zeros(no_of_buses,no_of_buses);
for i=2:no_of_buses
for k=2:no_of_buses
Xd(i,k)=Xd(i,k)+Xr(i-1,k-1);
end
end
Xd

ptdf=zeros(ne,ne); %PTDF
for i=1:ne
for k=1:ne
ptdf(i,k)=(1/(Xline(i)))*((Xd(start_bus,start_bus)- Xd(start_bus,end_bus))-
(Xd(end_bus,start_bus)-Xd(end_bus,end_bus)));

end
end
ptdf

lodf=zeros(ne,ne); %LODF

29
for i=1:ne
for k=1:ne
lodf(i,k) = ptdf(i,k)/(1-1/(Xline(k))*((Xd(start_bus,start_bus)-Xd(start_bus,end_bus))-
(Xd(end_bus,start_bus))-Xd(end_bus,end_bus)));
end
end
%change in flow with outage of line 1-2
Pn = Pa(2:end);
Pn(1) = 0; %outage in gen 2
theta = inv(B_d)*Pn;
theta_a = [0;theta];
Pflown = zeros(no_of_lines);
for i = 1:no_of_lines
for j = 1:no_of_lines
if (i~=j)
Pflown(i,j) = Pflown(i,j) + (B(i,j)*(theta_a(i) - theta_a(j)));
end
end
end
cif= zeros(ne,1);
cif= Pflown(1,1)*lodf(:,1);
net_flow= zeros(ne,1);
net_flow(1,1)=0;
net_flow(2,1)=Pflown(1,2)+cif(2,1);
net_flow(3,1)=Pflown(1,3)+cif(3,1);
net_flow

if (any(net_flow'>max_capacity))
fprintf('There is a limit violation');
else
fprintf('There is no limit violation');
end

% %Limit violation in the line 1-3


df=max_capacity(3)-net_flow(3,1);
dP13=df/1000*(-ptdf(3,1))+ptdf(3,1)*lodf(3,1)
fprintf('amount of generation to be reduced in gen 1 is %f MW',dP13);

OUTPUT:

Ybus

30
0.0000 -11.6667i 0.0000 + 5.0000i 0.0000 + 3.3333i 0.0000 + 3.3333i
0.0000 + 5.0000i 0.0000 - 8.3333i 0.0000 + 3.3333i 0.0000 + 0.0000i
0.0000 + 3.3333i 0.0000 + 3.3333i 0.0000 - 9.1667i 0.0000 + 2.5000i
0.0000 + 3.3333i 0.0000 + 0.0000i 0.0000 + 2.5000i 0.0000 - 5.8333i

B Prime

8.3333 -3.3333 0.0000

-3.3333 9.1667 -2.5000

0.0000 -2.5000 5.8333

0.1437 0.0592 0.0254

0.0592 0.1479 0.0634

0.0254 0.0634 0.1986

Del

0.0177

-0.0456

-0.0710

Pline =

-8.8500 15.2000 23.6667 21.1000 6.3500

PTDF

1-2 1-3 1-4 2-3 3-4

1-2 0.7183 0.2958 0.1268 -0.4225 -0.1690

1-3 0.1972 0.4930 0.2113 0.2958 -0.2817

1-4 0.0845 0.2113 0.6620 0.1268 0.4507

2-3 -0.2817 0.2958 0.1268 0.5775 -0.1690

31
3-4 -0.0845 -0.2113 0.3380 -0.1268 0.5493

LODF

1-2 1-3 1-4 2-3 3-4

1-2 0.0000 0.5833 0.3750 -1.0000 -0.3750

1-3 0.7000 0.0000 0.6250 0.7000 -0.6250

1-4 0.3000 0.4167 0.0000 0.3000 1.0000

2-3 -1.0000 0.5833 0.3750 0.0000 -0.3750

3-4 -0.3000 -0.4167 1.0000 -0.3000 0.0000

Net Flow

0.0000

9.0050

21.0117

29.9500

9.0050

dP14 = -47.2805

amount of gen reduced= 3.3558

RESULT:
A MATLAB program to perform contingency analysis for Generator shift factors and
line outage distribution factor is coded and output is verified.

32
Ex. No. 5 DATE: 24-03-2022

STATE ESTIMATION BY WEIGHTED LEAST SQUARE METHOD

AIM: To create a MATLAB program to find the state estimation of a network

FORMULA USED:

ΔX=

ALGORITHM:

33
SYSTEM DATA:
LINE DATA:

Line From To Resistance Reactance Susceptance to


bus
1 1 2 0.01 0.03 0
2 1 3 0.02 0.05 0
3 2 3 0.03 0.08 0

BUS DATA:

Bus no V Del
1 1 0
2 1 0
3 1 0

METER DATA:

S.No Type Value (p.u) SD Start bus End bus


1 P12 0.888 0.008 1 2
2 P13 1.173 0.008 1 3
3 P2 -0.501 0.010 2 2
4 Q12 0.562 0.008 1 2
5 Q13 0.663 0.008 1 3
6 Q2 -0.286 0.010 2 2
7 V1 1.006 0.004 1 1

34
8 V2 0.968 0.004 2 2

PROGRAM:

%%reading line details


line_data = xlsread('state_est_line.xlsx');
lines = size(line_data);
no_lines = lines(1);
%%reading bus details
bus_data = xlsread('state_est_bus.xlsx');
buses = size(bus_data);
no_buses = buses(1);
bus_num = bus_data(:,1);
V = bus_data(:,2);
del = bus_data(:,3);
%formation of Ybus
Y_bus = zeros(no_buses);
for i=1:no_lines
line_num = line_data(i,1);
start_bus = line_data(i,2);
end_bus = line_data(i,3);
R = line_data(i,4);
X = line_data(i,5);
b = line_data(i,6);
ith_admittance = 1/(R + (1i*X));

Y_bus(start_bus,start_bus)=Y_bus(start_bus,start_bus)+ith_admittance+b;
Y_bus(end_bus,end_bus)=Y_bus(end_bus,end_bus)+ith_admittance+b;

Y_bus(end_bus,start_bus)=Y_bus(end_bus,start_bus)-ith_admittance;
Y_bus(start_bus,end_bus)=Y_bus(end_bus,start_bus);
end
G = -1 * real(Y_bus);
B = -1 * imag(Y_bus);
theta = angle(Y_bus);
%reading measurement data
meas_data = xlsread('state_est_meas.xlsx');
meas = size(meas_data);
no_meas = meas(1);
for i = 1:no_meas
meas_num = meas_data(:,1);
meas_type = meas_data(:,3);

35
value = meas_data(:,4);
root_Rii = meas_data(:,5);
start_m = meas_data(:,6);
end_m = meas_data(:,7);
pflow = find(meas_type ==1);
pbus = find(meas_type == 2);
qflow = find(meas_type ==3);
qbus = find(meas_type == 4);
Vmeas = find(meas_type == 5);
end
npflow = size(pflow);
no_pflow = npflow(1);
npbus = size(pbus);
no_pbus = npbus(1);
nqflow = size(qflow);
no_qflow = nqflow(1);
nqbus = size(qbus);
no_qbus = nqbus(1);
nVmeas = size(Vmeas);
no_Vmeas = nVmeas(1);
%%initial state vector
dels = del(2:no_buses);
X = [dels;V];
%%formulation of h matrix
h1 = zeros(no_pflow,no_buses-1);
for i = 1:no_pflow
m = start_m(pflow(i));
for j=1:no_buses-1
n = end_m(pflow(i));
if i==j
h1(i,j) = h1(i,j) - (V(m)*V(n)*(G(m,n)*sin(del(m)-del(n)) - B(m,n)*cos(del(m)-
del(n))));
end
end
end
h2 = zeros(no_pflow,no_buses);
for i= 1:no_pflow
m = start_m(pflow(i));
n= end_m(pflow(i));
for j=1:no_buses
if (m==j)
h2(i,j) = h2(i,j) + 2*V(m)*G(m,n) - V(n)*(G(m,n)*cos(del(m)-del(n)) +
B(m,n)*sin(del(m)-del(n)));
elseif (n==j)

36
h2(i,j) = h2(i,j) - V(n)*(G(m,n)*cos(del(m)-del(n)) + B(m,n)*sin(del(m)-del(n)));

end
end
end
h3 = zeros(no_pbus,no_buses-1);
for i=1:no_pbus
m=i+1;
for j=1:no_buses-1
n=j+1;
if m==n
for n=1:no_buses
h3(i,j)=h3(i,j)+V(m)*V(n)*(-G(m,n)*sin(del(m)-del(n))+B(m,n)*cos(del(m)-
del(n)));
end
h3(i,j)=h3(i,j)+V(m)^2*B(m,m);
else
h3(i,j)=-V(m)*V(n)*(G(m,n)*sin(del(m)-del(n))-B(m,n)*cos(del(m)-del(n)));
end

end
end
h4 = zeros(no_pbus,no_buses);
for i=1:no_pbus
m=i+1;
for j=1:no_buses
n=j;
if m==n
for n=1:no_buses
h4(i,j)=h4(i,j)-V(n)*(G(m,n)*cos(del(m)-del(n))+B(m,n)*sin(del(m)-del(n)));
end
h4(i,j)=h4(i,j)-V(m)*G(m,m);
else
h4(i,j)=-V(m)*(G(m,n)*cos(del(m)-del(n))+B(m,n)*sin(del(m)-del(n)));
end
end
end
h5 = zeros(no_qflow,no_buses-1);
for i=1:no_qflow
m = start_m(qflow(i));
n= end_m(qflow(i));
for j=1:no_buses-1
if(i==j)
h5(i,j) =h5(i,j) + V(m)*V(n)*(G(m,n)*cos(del(m)-del(n)) + B(m,n)*sin(del(m)-del(n)));

37
end
end
end
h6 = zeros(no_qflow,no_buses);
for i=1:no_qflow
m= start_m(qflow(i));
n=end_m(qflow(i));
for j=1:no_buses
if (m==j)
h6(i,j) = h6(i,j) - V(n)*(G(m,n)*sin(del(m)-del(n)) + B(m,n)*cos(del(m)-del(n)));
elseif (n==j)
h6(i,j) = h6(i,j) + V(n)*(G(m,n)*sin(del(m)-del(n)) + B(m,n)*cos(del(m)-del(n)));
end
end
end
h7 = zeros(no_qbus,no_buses-1);
for i=1:no_qbus
m=i+1;
for j=1:no_buses-1
n=j+1;
if m==n
for n=1:no_buses
h7(i,j)=h7(i,j)-V(m)*V(n)*(G(m,n)*cos(del(m)-del(n))+B(m,n)*sin(del(m)-
del(n)));
end
h7(i,j)=h7(i,j)+V(m)^2*G(m,m);
else
h7(i,j)=-V(m)*V(n)*(-G(m,n)*cos(del(m)-del(n))-B(m,n)*sin(del(m)-del(n)));
end
end
end
h8 = zeros(no_qbus,no_buses);
for i=1:no_qbus
m=i+1;
for j=1:no_buses
n=j;
if m==n
for n=1:no_buses
h8(i,j)=h8(i,j)-V(n)*(G(m,n)*sin(del(m)-del(n))-B(m,n)*cos(del(m)-del(n)));
end
h8(i,j)=h8(i,j)+V(m)*B(m,m);
else
h8(i,j)=-V(m)*(G(m,n)*sin(del(m)-del(n))-B(m,n)*cos(del(m)-del(n)));
end

38
end
h9 = zeros(no_Vmeas,no_buses-1);

h10 = zeros(no_Vmeas,no_buses);
for i=1:no_Vmeas
for j=1:(no_buses)
if (i==j)
h10(i,j) = h10(i,j) + V(i);
end
end
end
end
H = [h1 h2;h3 h4;h5 h6;h7 h8;h9 h10];
Ri = root_Rii.^2;
R = diag(Ri);
G_X = H' * inv(R) * H;
%%calculating f(x)
%%pflows
pf = zeros(no_pflow,1);
for i=1:no_pflow
m = start_m(pflow(i));
n = end_m(pflow(i));
pf(i) = pf(i) + V(m)^2*G(m,n) - V(m)*V(n)*((G(m,n)*cos(del(m)-del(n)))+
(B(m,n)*sin(del(m)-del(n))));
end
pb = zeros(no_pbus,1);
j=1;
for i=1:no_pbus
for j=1:no_buses
m=i+1;
n=j;
pb(i) = pb(i) + (V(m)*V(n)*(G(m,n)*cos(del(m)-del(n))+(B(m,n)*sin(del(m)-del(n)))));
end
end
qf = zeros(no_qflow,1);
for i=1:no_qflow
m = start_m(qflow(i));
n= end_m(qflow(i));
qf(i) = qf(i) + V(m)^2*B(m,n) + (V(m)*V(n)*((G(m,n)*sin(del(m)-del(n)))-
(B(m,n)*cos(del(m)-del(n)))));
end
qb = zeros(no_qbus,1);
for i=1:no_qbus
m=i+1;

39
for j=1:no_buses
n=j;
qb(i) = qb(i) + V(m)*V(n)*(G(m,n)*sin(del(m)-del(n))-(B(m,n)*cos(del(m)-del(n))));
end
end
Vcal = V(2:end);
fx = [pf;pb;qf;qb;Vcal];
%%calculating residue
residue = value - fx;
%%calculating t matrix
t = H' * inv(R) * residue;

%%calculating delx
delX = inv(G_X) * t;
X = X + delX;
del(2:no_buses) = X(1:no_buses-1);
V = X(no_buses:end);
%%printing voltages and angles
for i=1:no_buses
fprintf('\n voltage in bus %d is %f %f deg',i,V(i),rad2deg(del(i)));
end

OUTPUT:
Ybus Matrix

16.8966 -47.2414i -10.0000 +30.0000i -6.8966 +17.2414i

-10.0000 +30.0000i 14.1096 -40.9589i -4.1096 +10.9589i

-6.8966 +17.2414i -4.1096 +10.9589i 11.0061 -28.2003i

Iteration 1:

40
G
7
10

3.4392 -0.5068 0.0137 0.0000 -0.0137

-0.5068 0.6736 -0.0137 0.0137 0.0000

0.0137 -0.0137 3.1054 -2.9324 -0.1668

0.0000 0.0137 -2.9324 3.4455 -0.5068

-0.0137 0.0000 -0.1668 -0.5068 0.6736

T
5
10

-4.9489

-1.9987

8.4052

-5.8746

-2.5469

∆x

-0.0213

-0.0452

-0.0004

-0.0256

-0.0576

X (STATE VARIABLE)

-0.0213

-0.0452

0.9996

0.9744

0.9424

41
Iteration 2:
G
7
10

3.1770 -0.4423 0.0161 -0.0039 -0.0114

-0.4423 0.5917 -0.0123 0.0119 0.0000

0.0161 -0.0123 3.1965 -2.8883 -0.2159

-0.0039 0.0119 -2.8883 3.3133 -0.4763

-0.0114 0.0000 -0.2159 -0.4763 0.6663

T
5
10

-3.7776

-2.1627

2.3973

-3.2546

0.8903

∆x

-0.0189

-0.0505

0.0048

-0.0038

0.0119

42
X (STATE VARIABLE)

-0.0189

-0.0505

1.0048

0.9962

1.0119

Iteration 3:
G
7
10

3.4179 -0.5076 0.0180 -0.0061 -0.0119

-0.5076 0.6939 -0.0138 0.0136 0.0000

0.0180 -0.0138 3.1373 -2.9360 -0.1709

-0.0061 0.0136 -2.9360 3.4071 -0.4977

-0.0119 0.0000 -0.1709 -0.4977 0.6777

T
5
10

-3.7231

-2.3780

8.5902

-6.0304

-2.5426

∆x

-0.0181

-0.0470

-0.0004

-0.0263

43
-0.0572

X (STATE VARIABLE)

-0.0181

-0.0470

0.9996

0.9737

0.9428

RESULT:
A MATLAB program for state estimation has been coded and the residual and X est
value is obtained

Ex.No.6 DATE: 31-03-2022

VOLTAGE STABILITY: PV AND VQ CURVES

AIM:
To analysis the voltage stability by obtaining the PV and QV curves using MATLAB
programming.

THEORY:
Voltage stability in the power system is defined as the ability of a power system to
maintain acceptable voltages at all bus in the system under normal condition and after
being subjected to a disturbance. Voltage instability stems from the attempt of load
dynamics to restore power consumption beyond the capability of the combined

transmission and generation system. Loads are the driving force of voltage instability,
and for this reason this phenomenon has also been called load instability.

a. Power-Voltage Relationships

PV CURVES OR NOSE CURVES

44
For a given load power below the maximum, there are two solutions: one with higher voltage
and lower current, the other with lower voltage and higher current. The former corresponds to
"normal" operating conditions, with voltage V closer to the generator voltage E. Permanent
operation at the lower solutions is unacceptable. As the load is more and more compensated
(which corresponds to smaller tan φ), the maximum power increases. However, the voltage at
which this maximum occurs also increases. This situation is dangerous in the sense that
maximum transfer capability may be reached at voltages close to normal operation values.
Also, for a high degree of compensation and a load power close to the maximum, the two
voltage solutions are close to each other and without further analysis it may be difficult to
decide if a given solution is the "normal" one. For over-compensated loads (tan φ < 0), there
is a portion of the upper PV curve along which the voltage increases with the load power. The
explanation is that under negative tan φ, when more active power is consumed, more reactive
power is produced by the load. At low load, the voltage drop due to the former is offset by the
voltage increase due to the latter. The more negative tan φ is, the larger is the portion of the
PV curve where this takes place.

b. Generator Reactive Power Requirement

45
Generators are treated as voltage sources of constant magnitude. The main defect of this
assumption lies in the limited reactive power capability of generators. It is therefore of
interest to determine how the reactive generation increases with load.

In the lossless case R = 0, the generator reactive production as the sum of the load and the
network losses:
Normal operating points – lower side

These curves are similar to the PV curves, except that normal operating points now lie on the
lower part of the curves. Starting from open-circuit conditions (P = 0, Q g = 0) and increasing
the load, the reactive generation increases nonlinearly with P up to the maximum power.
Beyond this point, P decreases while reactive losses continue to increase, up to the point (P =
The line current I relates to the generator apparent power Sg through:

In the absence of real power losses:

Short circuit

0, Q g = E2/x) which corresponds to a short circuit at the load bus. Note finally that all the
maximum power points are characterized by:

The reactive power to be absorbed or inject to reach the operating point should be calculated.

46
MATLAB CODE:

PV curve program

%%PV curve
clear all
X=0.8;
E=1;
tanpf=-0.2;
temp=1;
temp1=54;
for i=1:1
for P=0:0.03:0.78
Q=P* tanpf;
Vx =sqrt((E^2/4) -(P*X)^2-(X*Q*E^2));
Vhv=sqrt((E^2/2) -(Q* X)+Vx);
Vlv =sqrt((E^2/2) -(Q*X)-Vx);
x1(temp)=P*X/(E^2);
x1(temp1)=P*X/(E^2);
y1(temp)=Vhv/E;
y1(temp1)= Vlv /E;
temp=temp+1;
temp1=temp1 -1;
end
tanpf=tanpf+0.2;
end
plot(x1,y1) ;
legend(" Real Power ");
ylabel("Voltage");
xlabel("Power");

VQ curve program

%VQ curve

clc

clear all

P=0;

E=1;

47
X=0.1;

V=0.0001;

for j=1:3

P=P+2;

Q=P*tan((25.84*3.1416/180));

V=0.0001;

for i=1:22

theta=asin(P*X/E*V);

Qc=Q+(V*V/X)-(E*V/X)*cos(theta);

V=V+0.05;

x1(j,i)=V/E;

y1(j,i)=Qc*X/(E*E);

yy(i)=0;

end

end

plot(x1(1,:),yy,x1(1,:),y1(1,:),x1(2,:),y1(2,:),x1(3,:),y1(3,:));

legend('Reactive Power','V1','V2','V3')

ylabel("Voltage")

xlabel("Reactive Power")

OUTPUT:
OUTPUT GRAPH FOR PV CURVE

48
OUTPUT GRAPH FOR VQ CURVE

RESULT:
A MATLAB program for analysing voltage stability is coded and the following graphs
are obtained.
1. P-V Curve.
2. Q-V Curve.

Ex.No.7 DATE: 07-04-2022

CHARACTERISTICS OF SOLAR PV SYSTEM


49
AIM: To simulate and obtain VI and PV Characteristics of solar cell using MATLAB.

THEORY:

a. INTRODUCTION
The extraction of electrical energy directly from the sun without any intermediate process
is known as solar energy. A solar cell is a semiconductor device used to capture the light
from sun. The working of solar cell depends on photovoltaic effect, hence a solar cell is
known as photovoltaic cell. It is independent of incident light striking on it but the current
capacity is almost proportional to the intensity of incident light as well as to the area of
the cell that is exposed to the light.

b. EQUIVALENT CIRCUIT OF SOLAR CELL

The equivalent circuit of a PV cell consists of a diode in parallel with an ideal current
source along with shunt and series resistors to account for the loss.
I L = current from the ideal current source
I D = diode current
I sh = shunt current
I = output current
R sh = shunt resistor
R s = series resistor
I = I L - I D - I sh

The ideal current source delivers current proportional to amount of solar light falling on
the cell. There are two conditions for the actual PV cell and for the equivalent circuit
working, which are:
a. Current that flows when the terminals are short circuited (short circuit current, I sc )
b. Voltage across the terminals when the terminals are left open (open-circuit voltage,
V OC )

Short Circuit Current ( I sc)

The maximum current that a solar cell can deliver when short circuiting the output
terminals at the most optimised condition for producing maximum output. The optimised
condition here means the maximum amount of light a cell can capture at a particular
position and angle, as the current production depends on the surface area of the cell
exposed to light. This current is known as Maximum Current Density expressed by

J sc = I sc / A

50
Where A, is the area of the solar cell.

Open-circuit Voltage (V OC )

The open-circuit voltage is measured by measuring the voltage at the terminals when no
load is connected across it. The voltage doesn’t depend on the intensity of the light and
the area of the cell. Normally the open-circuit voltage of a solar cell is approximately 0.5
to 0.6V.

c. I-V AND P-V CHARACTERISTICS OF SOLAR CELL

The solar cell I-V characteristics are plotted by first noting the open-circuit voltage ( V OC ). A
load is then connected and gradually increased, hence some amount of current starts flowing.
Load voltage is noted down for each load current. Then the cell is short circuited and
corresponding short circuit voltage is noted. P-V characteristics are obtained multiplying each
value of PV cell voltage with corresponding current flowing through it.

Maximum Power Point of solar cell

From the characteristics, the maximum power occurs for one particular value of terminal
voltage and current. It will occur at the bend point of the characteristic curve.

Fill Factor of solar cell

Fill Factor is defined as the ratio of product of current and voltage at maximum power point
to the product of short circuit current and open-circuit voltage.

Fill Factor = (V mp x I mp) / (V OC x I sc )

Efficiency of solar cell

The efficiency of solar cell is defined as ratio of maximum electrical power output to the
radiation power input in the cell. The radiation power is considered as 1000 watt/square
51
meter. If the exposed area of the cell is A, then total radiation power of the cell will be 1000
A watts.

Efficiency = ( Pm / 1000 A) * 100

MATLAB MODEL

OUTPUT
I-V Characteristics:

P-V Characteristics:

52
RESULT:

Solar Cell has been modelled and the I-V, P-V characteristics are obtained through simulation
in MATLAB.

Ex.No.8 DATE: 21-04-2022

CHARACTERISTICS OF WIND ENERGY CONVERSION SYSTEM


53
AIM:
To simulate and obtain Characteristics of Wind Energy Conversion System using
MATLAB.

THEORY:
c. Introduction
The kinetic energy available in wind is captured and converted in rotational mechanical
energy by wind turbine. This mechanical energy of wind turbine is given to generator
which converts the mechanical energy into electrical energy.

Where,
ρair(kg/m3) is the density of air,
Rblade (m) is the radius of the blade,
Ablade (m2) is the area covered by the blade,
Cp is the coefficient of performance of turbine,
β (degree) is the pitch angle,
λ is the tip speed ratio, ωw (rad/s) is the wind speed,
ωr(rad/s) is the turbine rotor speed.

d. Types of WECS
1. Based on operational speed:
a. Fixed speed WECS
b. Variable speed WECS
2. Based on Axis:
c. Horizontal Axis
d. Vertical Axis
3. Based on type of Generator:
e. Squirrel Cage (suitable for Fixed speed type)
f. Doubly Fed Induction Generator (DFIG)
g. Permanent Magnet Synchronous Generator (PMSG)

e. Parts of WECS
1. Rotor Blade
2. Rotor Hub
3. Nacelle
4. Generator
5. Pitch Control
6. Yaw Control
7. Anemometer
8. Gear Box

f. Definitions
1. Cut-in Speed: This is the minimum wind speed required for the wind turbine to
start rotating for power production.

54
2. Cut-Out Speed: This is the maximum wind speed above which the turbine is
completely stopped so that the turbine is within safe operating conditions.
3. Betz's coefficient: This is the theoretical maximum ratio of power that can be
extracted from the wind energy by wind turbine. Theoretically this value is 16/27
(59.3%).
4. Tip Speed Ratio: It is the ratio of tangential velocity of tip of wind turbine blade to
the wind speed. It is denoted by lambda.
5. Pitch Angle: It is the angle at which wind contacts the blades of the wind turbine.
It is denoted by beta.
6. Co-efficient of Performance: It is the ratio of power output of the unit to the power
available in the wind. It is a function of tip-speed ratio and pitch angle.

g. Variable Speed WECS


To extract maximum power from wind, the wind turbine should run at optimal value
of coefficient of performance. This optimal value of coefficient of performance is
obtained at optimal tip speed ratio which in turn depends on rotor speed for a
particular wind speed. This optimal tip speed ratio is constant for all wind speeds for a
given turbine. So, for a particular wind speed the rotor must rotate at a particular
optimal value. Thus rotor speed must be varied continuously for each wind speed so
that Cp is always at its optimal maximum value.

Since the generator's rotor speed is varied, the frequency of the AC output varies. So it
cannot be interfaced directly to grid. For this reason, a back to back converter is
employed to convert variable frequency AC to DC and then inverting this DC to AC
of grid frequency.

h. Wind Turbine Power Characteristics

55
MATLAB MODEL:

56
OUTPUT:
Rotor Speed, Rotor angle and Torque characteristics

V abc and I abc characteristics

V abc and I abc characteristics


inv inv

57
Wind Turbine Characteristics

Generator Characteristics

RESULT:
MATLAB-SIMULINK is used to create a Permanent Magnet Synchronous Generator
based Wind Energy Conversion System model and the results are obtained.

58
Ex.No.9 DATE: 28-04-2022

CHARACTERISTICS OF FUEL CELL BASED ENERGY SOURCES

AIM:
To simulate and obtain Characteristics of Fuel Cell based Energy Sources using
MATLAB.

THEORY:
a. Introduction
Fuel cells are electrochemical cells which convert chemical energy into electrical energy.
The raw material used is H 2 and the base product is water and heat. The efficiency of
conversion in fuel cells is around 70%.

b. Parts of Fuel Cell

1. Anode: The negative terminal of the fuel cell where oxidation takes place is called
as Anode. It conducts the electrons that are freed from hydrogen molecules so that
they can be used in an external circuit.

2. Cathode: The positive terminal of the fuel cell is called Cathode. It distributes the
oxygen to the surface of the catalyst. Not only that, it conducts electrons back
from the external circuit to the catalyst, where they can recombine with the
hydrogen ions and oxygen to form water.

3. Catalyst: A chemical substance which increases the rate of reaction. It is made of


platinum powder very thinly coated onto carbon paper or cloth.

4. Electrolyte: It is otherwise known as Proton Exchange Membrane. A substance


that conducts charged ions from one electrode to the other in a fuel cell. It
conducts only positively charged ions.

c. Working of Fuel Cell


A fuel cell consists of two electrodes namely anode and cathode. Hydrogen and
Oxygen are fed into the cell. The catalyst at anode causes hydrogen atoms to give up
electrons leaving only the protons. Oxygen ions at cathode attract the hydrogen
protons. The protons then pass through electrolyte membrane. The electrons are
redirected to cathode through external circuit thus producing electric current.

d. Types of Fuel Cell

1. PAFC: Phosphoric Acid Fuel Cell


2. PEMFC: Proton Exchange Membrane Fuel Cell
3. AFC: Alkaline Fuel Cell
4. MCFC: Molten Carbonate Fuel Cell
5. SOFC: Solid Oxide Fuel Cell

59
e. Losses in Fuel Cell
1. Activation Losses
2. Ohmic Losses
3. Concentration Losses

f. Fuel Cell Characteristic Curve

As shown, fuel cell I-V characteristic curve is divided into three regions: R-1, R-2,
and R-3. The point at the boundary of regions R-2 and R-3 is known as maximum
power density point or knee/optimum point. Loading the fuel cells above the
maximum power point (MPP) current will shift the operating point right of the
optimum point (region R-3) causing a sudden collapse of the fuel cell voltage to zero.
Therefore, no power could be drawn from the cell. Extended operation in region R-3
may damage the fuel cell. Fuel cells are generally operated in the region R-2 of the
characteristics shown in the figure.

MATLAB MODEL:

60
OUTPUT:

Voltage-Current characteristics of fuel cell:

RESULT:
Thus the Characteristics of Fuel Cell based Energy Sources using MATLAB/Simulink
is simulated and obtained.

61
Ex.No.10 DATE: 05-05-2022

POWER MANAGEMENT IN HYBRID POWER SYSTEM

AIM:
To simulate and obtain Characteristics of Hybrid Power System using MATLAB.

THEORY:

A hybrid system is a dynamical system that exhibits both continuous and discrete
dynamic behaviour – a system that can both flow (described by a differential
equation) and jump (described by a state machine or automaton). Often, the term
"hybrid dynamical system" is used, to distinguish over hybrid systems such as those
that combine neural nets and fuzzy logic, or electrical and mechanical drivelines. A
hybrid system has the benefit of encompassing a larger class of systems within its
structure, allowing for more flexibility in modelling dynamic phenomena.

In general, the state of a hybrid system is defined by the values of the continuous
variables and a discrete mode. The state changes either continuously, according to a
flow condition, or discretely according to a control graph. Continuous flow is
permitted as long as so-called invariants hold, while discrete transitions can occur as
soon as given jump conditions are satisfied. Discrete transitions may be associated
with events.

With the rapid increase in demand of energy due to the increasing of load, it is very
difficult for the electrical grid to fulfil the energy demand. For supplying the power
and to avoid the failure of grid, the grid system does the load shedding and fulfils the
energy demand. But this process is obvious and fails to fulfil the energy demand of
each and every customer. By doing so, the electrical grid system will be free from the
stress of fulfilling the energy demand by performing the load shedding. This hybrid
system is connected with the electrical grid near the load to fulfil the load demand by
supplying the power from the electrical grid to the load.

The hybrid power solution allows for the integration of one or more renewable power
generation assets with tailored energy storage systems. When there is a high demand
in load and generation is not sufficient, this storage system can deliver power to the
load thus maintaining stability. Also when there is high generation and demand is
low, the same storage system can absorb excess generated power.

62
MATLAB MODEL:

Subsystem:

63
OUTPUT:

Battery SOC, Voltage and Current

VSC Voltage and Current

Grid Voltage and Current

64
Load Voltage and Current

Load, Grid and VSC Power

RESULT:
MATLAB-SIMULINK is used to model a Hybrid Power System and the required
output is obtained.

65
EX.No 11 DATE: 05-05-2022

DIGITAL OVER CURRENT RELAY SETTING AND RELAY


COORDINATION
AIM:
To study about over current relay setting and relay co-ordination using MATLAB software.

SOFTWARE USED:
MATLAB

THEORY:
In an over current relay or o/c relay the actuating quantity is only current. There is only one
current operated element in the relay, no voltage coil etc. are required to construct this
protective relay.
WORKING PRINCIPLE OF OVER CURRENT RELAY:
In an over current relay, there would be essentially a current coil. When normal current flows
through this coil, the magnetic effect generated by the coil is not sufficient to move the
moving element of the relay, as in this condition the restraining force is greater than
deflecting force. But when the current through the coil increases, the magnetic effect
increases, and after a certain level of current, the deflecting force generated by the magnetic
effect of the coil, crosses the restraining force. As a result, the moving element starts moving
to change the contact position in the relay. Although there are different types of overcurrent
relays but basic working principle of overcurrent relay is more or less same for all.
TYPES OF OVER CURRENT RELAY:
Depending upon time of operation, there are various types of Over Current relays, such as,
1. Instantaneous over current relay.
2. Definite time over current relay.
3. Inverse time over current relay.

Inverse time over current relay or simply inverse OC relay is again subdivided as inverse
definite minimum time (IDMT), very inverse time, extremely inverse time over current relay
or OC relay.
INSTANTANEOUS OVER CURRENT RELAY:
Construction and working principle of instantaneous over current relay is quite simple. Here
generally a magnetic core is wound by a current coil. A piece of iron is so fitted by hinge
support and restraining spring in the relay, that when there is not sufficient current in the coil,
the NO contacts remain open. When the current in the coil crosses a pre-set value, the

66
attractive force becomes enough to pull the iron piece towards the magnetic core, and
consequently, the no contacts get closed.
We refer the pre-set value of current in the relay coil as pickup setting current. This relay is
referred as instantaneous over current relay, as ideally, the relay operates as soon as the
current in the coil gets higher than pick upsetting current. There is no intentional time delay
applied. But there is always an inherent time delay 60

which we cannot avoid practically. In practice, the operating time of an instantaneous relay is
of the order of a few milliseconds.
DEFINITE TIME OVER CURRENT RELAY:
This relay is created by applying intentional time delay after crossing pick up the value of the
current. A definite time overcurrent relay can be adjusted to issue a trip output at an exact
amount of time after it picks up. Thus, it has a time setting adjustment and pickup adjustment.
INVERSE TIME OVER CURRENT RELAY:
Inverse time is a natural character of any induction type rotating device. Here, the speed of
rotation of rotating part of the device is faster if the input current is more. In other words,
time of operation inversely varies with input current. This natural characteristic of
electromechanical induction disc relay is very suitable for overcurrent protection. If the fault
is severe, it will clear the fault faster. Although time inverse characteristic is inherent to
electromechanical induction disc relay, the same characteristic can be achieved in
microprocessor-based relay also by proper programming.
RELAY CO-ORDINATION:
The relay co-ordination is nothing but a tripping of protecting relay in a sequence or order in
electrical power system. Relay coordination is very difficult task for relay engineers. Relay
co- ordination is required to isolate the faulty part with minimized relay & circuit breaker
operation.

67
Consider four number of substations, Substation A, Substation B, Substation C, Substation D.
Here Substation A is generation station and B, C and D are distribution stations. In this, if the
fault (short circuit or earth fault) occurs in Substation D means, the substation D relay has to
operate, instead of that, the substation A relay operated means such system said to be poor
relay coordinated power system. It causes the total power system shutdown or unnecessary
zone trips. Because, there is no fault on substation A, B and C but the substation operates
unnecessarily. In order to avoid such relay operation, we have to set co- ordination between
all 4 substations.
RELAY CO-ORDINATION PROCEDURE FOR EARTH FAULT:
All the substation relays current, voltage setting and time setting values will be noted and
tabulated. Check the current setting and operating time of the relay which is associated with
the fault. i.e. if you are coordinating for earth fault means, you should consider all the earth
fault setting. Adjust the setting i.e. the substation D should have minimum operating time and
current or voltage setting. Then only substation D operates. If the value is higher than the
remaining substation, the substation D relay does not operate under fault 61

condition. The coordinated setting values would be substation A > Substation B > substation
C > Substation D. Also, the setting value of substation should not be exceeded its safe limit.
PROGRAM:
clear all; clc;
No_of_relays= 2;
primary_of_ct= 1000;
secondary_of_ct= 5;
plug_setting_R1= 1;

68
plug_setting_R2= 1.25;
TSM_R1= 0.3;
TSM_R2= 1;
Time_margin=0.5;
fault_current= 5000;
Relay_current_setting_R1= plug_setting_R1*secondary_of_ct;
Relay_current_setting_R2= plug_setting_R2*secondary_of_ct;
CT_secondary_current= fault_current*(secondary_of_ct/primary_of_ct);
PSM_R1=(CT_secondary_current/Relay_current_setting_R1);
PSM_R2=(CT_secondary_current/Relay_current_setting_R2);
a=input( 'enter no') if a==1 fprintf('IEC STANDARD INVERSE')
T1=TSM_R1*(0.14/((PSM_R1)^0.02-1)) t2=TSM_R2*(0.14/((PSM_R2)^0.02-1));
T2=T1+Time_margin TMS_R2= T2/t2 end
if a==2
fprintf('VERY INVERSE') T1=TSM_R1*(13.5/(PSM_R1-1)) t2=TSM_R2*(13.5/(PSM_R2-
1));
T2=T1+Time_margin TMS_R2= T2/t2
end
if a==3
fprintf('EXTREMELY INVERSE')
T1= TSM_R1*(80/((PSM_R1)^2-1))
t2= TSM_R2*(80/((PSM_R2)^2-1));
T2=T1+Time_margin TMS_R2= T2/t2
end
if a==4
fprintf('LONG TIME EARTH FAULT')
T1=TSM_R1*(120/(PSM_R1-1))
t2=TSM_R2*(120/(PSM_R2-1));
T2=T1+Time_margin TMS_R2= T2/t2 end

69
OUTPUT:
enter no1
IEC STANDARD INVERSE
T1 = 1.2839
T2 =1.7839
TMS_R2 = 0.3582
enter no2
VERY INVERSE
T1 = 1.0125
T2 = 1.5125
TMS_R2 = 0.3361
enter no3
EXTREMELY INVERSE
T1 = 1
T2 =1.5000
TMS_R2 = 0.2813
enter no4
LONG TIME EARTH FAULT
T1 =9 63
T2 = 9.5000
TMS_R2 = 0.2375

RESULT: MATLAB software is used to design and study over current relay setting and
relay coordination

70
71

You might also like