Bus Admittance Impedance. Matrix Algorithm. Matlab
Bus Admittance Impedance. Matrix Algorithm. Matlab
For those of you who are interested in automating your power / load flow calculations. This might provide an initial step. When invoked in Matlab workspace, This algorithm asks for the total number of busses in your system, followed by prompts asking for impedances between busses. It generates a Bus Impedance Matrix (called ZMAT here) and a Bus admittance Matrix ( called YMAT here). A dummy variable ( a ) is used as input to the algo. While being invoked. You can assign any integer value, the operation is regardless of it. Paste this in an M.file and save with the function name Please follow the Matlab syntax when calling function in Main
>>[ZMAT,YMAT]=admittmat(1)
function[ZMAT,YMAT]=admittmat(a) %ANY NUMBER OF BUSSES WITH ANY IMPEDANCE BETWEEN THEM n=input('indicate the total number of busses .n. ='); ZMAT=zeros(n,n); YMAT=zeros(n,n); %initializing matrix %initializing matrix
%..Input Algo... %possib=n^2 ;%total elements rw=1 ; col=1; for(rw = 1:n) for(col =rw:n) if(col == rw) ZMAT(rw,col) = 0; %this calculated later on else str=['Impedance between bus',num2str(rw),'&','bus',num2str(col)]; %output display string disp(str)% %IMPEDANCE MATRIX ENTRIES ZMAT(rw,col) = input('entry =')*(-1); ZMAT(col,rw) = ZMAT(rw,col); %corresponding in lower diagonal %ADMITTANCE MATRIX ENTRIES YMAT(rw,col) = inversion(ZMAT(rw,col)); YMAT(col,rw) = YMAT(rw,col); %corresponding in lower diagonal end end end clc; %calculating the Bus Admittance and Impedances YMATdiag=(-1)*sum(YMAT,2,'double'); %adding row wise ZMATdiag=(-1)*sum(ZMAT,2,'double'); %adding row wise for(cntr = 1:n) YMAT(cntr,cntr) = YMATdiag(cntr,1); ZMAT(cntr,cntr) = ZMATdiag(cntr,1); end %----INVERSION-------------------------function[inverse]= inversion(value); if( value == 0) inverse = 0; else inverse = inv(value); end
Y12 gives the admittance Busses 1 and 2 share Y13.. the admittance Busses 1 ad 3 share and so on.
Whereas Y11 gives the self admittance of the Bus 1 i.e. the sum of impedances connected to bus 1 Note that: Y11 =Y12 + Y13 ZMAT and YMAT (n by n) matrices are initialized with zeroes ZMAT= YMAT=
Elements in the Diagonal are omitted as zeros. Whereas, only the upper diagonal elements are prompted for and multiplied by (-1). These form corresponding elements ZMAT= The algorithm reflects these in the lower diagonal of the matrix ZMAT= Partially, Admittance matrix is generated by inversing each of these elements YMAT= Adding the rows we get the diagonal elements ZMATdiagonal = Similarly for the Admittance diagonal elements YMATdiagonal = These are placed in the diagonals respectively
ZMAT= Similarly,
YMAT= .