Last active
February 20, 2018 23:29
-
-
Save swanav/63beac881aea91bd798a278e92b08dc9 to your computer and use it in GitHub Desktop.
Y Bus Assembly (Direct Method)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function yBus = Y_Bus_Assembly_Direct() | |
% 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; | |
% Store the shunt admittance in a separate matrix | |
shuntAdmittance = lineData(:,5); | |
% Initialize a Ybus matrix of dimension buses X buses with all zeros | |
yBus = zeros(buses,buses); | |
% k variable traverses the lineData matrix | |
for k = 1:lines | |
sendingBus = lineData(k,2); | |
receivingBus = lineData(k,3); | |
% i and j traverse the Ybus matrix | |
for i = 1:buses | |
for j = 1:buses | |
% For Diagonal Elements | |
% i == j -> Checks that the element is a diagonal element | |
% sendingBus==i||receivingBus==i -> Checks if the line is connected to either sending or receiving bus | |
if(sendingBus==i||receivingBus==i)&&(i==j) | |
yBus(i,j) = yBus(i,j) + lineAdmittance(k) + shuntAdmittance(k); | |
end | |
% For Off Diagonal Elements | |
% sendingBus==i&&receivingBus==j -> Checks if the line is connected between sensing and reciving bus | |
if sendingBus==i&&receivingBus==j | |
yBus(i,j) = - lineAdmittance(k); | |
yBus(j,i) = - lineAdmittance(k); | |
end | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
line | sending_node | receiving_node | line_impedance | shunt_admittance | |
---|---|---|---|---|---|
1 | 1 | 2 | 0.02+0.060i | 0.00+0.060i | |
2 | 1 | 3 | 0.08+0.240i | 0.00+0.025i | |
3 | 2 | 3 | 0.06+0.250i | 0.00+0.020i | |
4 | 2 | 4 | 0.06+0.180i | 0.00+0.020i | |
5 | 2 | 5 | 0.04+0.120i | 0.00+0.015i | |
6 | 3 | 4 | 0.01+0.030i | 0.00+0.010i | |
7 | 4 | 5 | 0.08+0.240i | 0.00+0.025i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment