Skip to content

Instantly share code, notes, and snippets.

@swanav
Last active February 20, 2018 23:34
Show Gist options
  • Save swanav/85e5578aeec0c3e8b0f2a993b9d028ad to your computer and use it in GitHub Desktop.
Save swanav/85e5578aeec0c3e8b0f2a993b9d028ad to your computer and use it in GitHub Desktop.
Y Bus Assembly (Using Singular Transformation technique)
function yBus = Y_Bus_Assembly_Singular()
% Data from IEEE 5-bus Data
% "http://shodhganga.inflibnet.ac.in/bitstream/10603/26549/14/14_appendix.pdf""
lineData = csvread('Y_Bus_Data.csv', 1, 0);
% Calculate the number of lines in the line data
lines = length(lineData);
% Calculate the number of buses in the line data
buses = max(max(lineData(:,2)),max(lineData(:,3)));
% Calculate the line admittance by taking element by element inverse
lineAdmittance = lineData(:,4).^-1;
% Transform the lineAdmittance array into a diagonal matrix
y = diag(lineAdmittance);
% Initialize the admittance matrix with dimensions (lines X buses)
admittanceMatrix = zeros(lines,buses);
% Fill the Admittance Matrix by reading the lineData
for k = 1:lines
sendingBus = lineData(k,2);
receivingBus = lineData(k,3);
% Fill in the sending nodes
if sendingBus ~= 0 % condition used to remove reference node
admittanceMatrix(k, sendingBus) = 1;
end
% Fill in the receiving nodes
if receivingBus ~= 0 % condition used to remove reference node
admittanceMatrix(k, receivingBus) = -1;
end
end
% Calculate the Y Bus
yBus = admittanceMatrix'*y*admittanceMatrix;
end
line sending_node receiving_node line_impedance shunt_admittance
1 1 2 0.02+0.060i 0.00+0.060j
2 1 3 0.08+0.240i 0.00+0.025j
3 2 3 0.06+0.250i 0.00+0.020j
4 2 4 0.06+0.180i 0.00+0.020j
5 2 5 0.04+0.120i 0.00+0.015j
6 3 4 0.01+0.030i 0.00+0.010j
7 4 5 0.08+0.240i 0.00+0.025j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment