Code covered by the BSD License  

Highlights from
Y-bus

Y-bus

by

 

admittance matrix

ybus_final.m
% Program to form Admittance Bus Formation with Transformer Tap setting..

clc
clear all
nbranch=input('enter total no. of lines in network');
disp('enter line data')
for p=1:1:nbranch
    fb=input('from bus no. :');
    tb=input('to bus no. :');
    r=input('resistance of line =');
    x=input('reactance of line =');
    B=input('line charging admittance"b/2"=');
    T=input('tap=');
    z = r + i*x;            % Z matrix...
    y = 1./z;               % To get inverse of each element...
    Ldata(p,:)=[fb tb r x B T y];
end
fb = Ldata(:,1);     % From bus number...
tb = Ldata(:,2);     % To bus number...
r = Ldata(:,3);      % Resistance, R...
x = Ldata(:,4);      % Reactance, X...
b = Ldata(:,5);      % Ground Admittance, B/2...
a = Ldata(:,6);      % Tap setting value..
y = Ldata(:,7);
b = i*b;                % Make B imaginary...

nbus = max(max(fb),max(tb));    % no. of buses...
Y = zeros(nbus,nbus);        % Initialise YBus...
 
 % Formation of the Off Diagonal Elements...
 for k=1:nbranch
     Y(fb(k),tb(k)) = Y(fb(k),tb(k))-y(k);
     Y(tb(k),fb(k)) = Y(fb(k),tb(k));
 end
 
 % Formation of Diagonal Elements....
 for m =1:nbus
     for n =1:nbranch
         if fb(n) == m
             Y(m,m) = Y(m,m) + y(n) + b(n);
         elseif tb(n) == m
             Y(m,m) = Y(m,m) + y(n) + b(n);
         end
     end
 end
 Y                   % Bus Admittance Matrix..
 
 

Contact us