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

Ps II Practicals

The document discusses writing a MATLAB program to calculate the admittance and impedance bus formation matrices for a power system with a given number of buses. It takes the admittance values as input, calculates the admittance matrix, and then converts it to the impedance matrix. The code is presented along with an example run for a 3 bus system.

Uploaded by

Shilpi Yadav
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)
9 views

Ps II Practicals

The document discusses writing a MATLAB program to calculate the admittance and impedance bus formation matrices for a power system with a given number of buses. It takes the admittance values as input, calculates the admittance matrix, and then converts it to the impedance matrix. The code is presented along with an example run for a 3 bus system.

Uploaded by

Shilpi Yadav
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/ 6

% write a program to form Admittance And Impedance Bus Formation....

clear all;
clc;
n=input("enter no of buses=");
for i=1:n
for j=1:n
fprintf("enter the element of %d,%d =",i,j);
z(i,j)=input('=');
y(i,j)=1/z(i,j);
end
end
Zmatrix=z
ymatrix=y
Y(n,n)=0;
for i=1:n
for j=1:n
if i==j
for k=1:n
Y(i,j)=Y(i,j)+y(i,k);
end
else
Y(i,j)=-y(i,j);
end
end
end
Ybus=Y
Results :

enter no of buses=3
enter the element of 1,1 ==1
enter the element of 1,2 ==2
enter the element of 1,3 ==3
enter the element of 2,1 ==2
enter the element of 2,2 ==2
enter the element of 2,3 ==3
enter the element of 3,1 ==3
enter the element of 3,2 ==3
enter the element of 3,3 ==4
Zmatrix =
1 2 3
2 2 3
3 3 4
ymatrix =
1.0000 0.5000 0.3333
0.5000 0.5000 0.3333
0.3333 0.3333 0.2500
Ybus =

1.8333 -0.5000 -0.3333


-0.5000 1.3333 -0.3333
-0.3333 -0.3333 0.9167
% write a program for Y-bus matrix calculation in MATLAB

% Number of buses in the power system

numBuses = 3;

% Admittance matrix Y_bus initialization

Y_bus = zeros(numBuses, numBuses);

% Admittance values of transmission lines (between buses)

% Format: [From Bus, To Bus, Admittance]

transmissionLines = [

1, 2, 0.1 + 0.2i; % Example values, change as needed

2, 3, 0.05 + 0.15i;

1, 3, 0.15 + 0.3i

];

% Shunt admittance values of buses

% Format: [Bus Number, Shunt Admittance]

shuntAdmittance = [

1, 0.02 + 0.05i; % Example values, change as needed

2, 0.03 + 0.07i;

3, 0.01 + 0.03i

];

% Build Y-bus matrix

for i = 1:size(transmissionLines, 1)
fromBus = transmissionLines(i, 1);

toBus = transmissionLines(i, 2);

admittance = transmissionLines(i, 3);

Y_bus(fromBus, toBus) = Y_bus(fromBus, toBus) - admittance;

Y_bus(toBus, fromBus) = Y_bus(toBus, fromBus) - admittance;

Y_bus(fromBus, fromBus) = Y_bus(fromBus, fromBus) + admittance;

Y_bus(toBus, toBus) = Y_bus(toBus, toBus) + admittance;

end

% Add shunt admittances to Y-bus matrix

for i = 1:size(shuntAdmittance, 1)

bus = shuntAdmittance(i, 1);

admittance = shuntAdmittance(i, 2);

Y_bus(bus, bus) = Y_bus(bus, bus) + admittance;

end

% Display Y-bus matrix

disp('Y-bus matrix:');

disp(Y_bus);

results:

Y-bus matrix:

0.2700 + 0.5500i -0.1000 - 0.2000i -0.1500 - 0.3000i

-0.1000 - 0.2000i 0.1800 + 0.4200i -0.0500 - 0.1500i

-0.1500 - 0.3000i -0.0500 - 0.1500i 0.2100 + 0.4800i


% write a program for Z-bus matrix calculation in MATLAB

% Y-bus matrix obtained from the previous code


Y_bus = [
0.12-0.4i, -0.1+0.2i, -0.02+0.2i;
-0.1+0.2i, 0.2-0.65i, -0.1+0.45i;
-0.02+0.2i, -0.1+0.45i, 0.12-0.65i
];

% Number of buses
numBuses = size(Y_bus, 1);

% Z-bus matrix initialization


Z_bus = zeros(numBuses);

% Calculate Z-bus matrix


for i = 1:numBuses
for j = 1:numBuses
if i == j
Z_bus(i, j) = 1 / Y_bus(i, j);
else
Z_bus(i, j) = -1 / Y_bus(i, j);
end
end
end

% Display Z-bus matrix


disp('Z-bus matrix:');
disp(Z_bus);

Results :

Z-bus matrix:

0.6881 + 2.2936i 2.0000 + 4.0000i 0.4950 + 4.9505i

2.0000 + 4.0000i 0.4324 + 1.4054i 0.4706 + 2.1176i

0.4950 + 4.9505i 0.4706 + 2.1176i 0.2747 + 1.4878i


% write a program for Load Flow Analysis using Gauss-Seidel Method for a
Three-Bus System

% Given Data
S_load = [50 + 20i; 40 + 10i; 30 + 5i]; % Complex power demand at each bus
Y_bus = [0.12-0.4i, -0.1+0.2i, -0.02+0.2i;
-0.1+0.2i, 0.2-0.65i, -0.1+0.45i;
-0.02+0.2i, -0.1+0.45i, 0.12-0.65i]; % Y-bus matrix

% Initialize variables
V = ones(3, 1); % Initial guess for voltage magnitudes
delta = zeros(3, 1); % Initial guess for voltage phase angles
max_iter = 100; % Maximum number of iterations
tolerance = 1e-6; % Tolerance for convergence

% Gauss-Seidel Iteration
for iter = 1:max_iter
V_old = V;
delta_old = delta;

% Update voltage magnitudes and phase angles for each bus


for i = 1:3
sum_V = 0;
for j = 1:3
if j ~= i
sum_V = sum_V + abs(V(j)) * abs(Y_bus(i, j)) * cos(delta(j) -
angle(Y_bus(i, j)));
end
end
V(i) = abs(S_load(i)) / abs(Y_bus(i, i)) - sum_V;
delta(i) = angle(S_load(i)) - angle(Y_bus(i, i) * V(i)) +
sum(delta_old);
end

% Check for convergence


if max(abs(V - V_old)) < tolerance && max(abs(delta - delta_old)) <
tolerance
disp('Convergence achieved.');
break;
end
end

% Display results
disp('Voltage Magnitudes:');
disp(V);
disp('Voltage Phase Angles (in radians):');
disp(delta);
RESULTS:

Voltage Magnitudes:

120.1196

75.2452

88.5233

Voltage Phase Angles (in radians):

1.0e+47 *

4.0632

4.0632

4.0632

>>

You might also like