Find Z-bus using Z building algorithm using MATLAB code

In summary, in order to add a new bus to the Z matrix, you would need to add a new row and column to the matrix, and keep the limits for b from 1 to 3. You would then need to calculate the last element of the matrix using the following equation: z+zz.
  • #1
Fatima Hasan
319
14
Homework Statement
Find the Z bus Matrix using Z building algorithm method, using MATLAB code; where the Line data matrix and Bus data are given.
Relevant Equations
-
I tried to write to the code, but I got confused in line 46 & 59.Every new added bus increases the dimension of the Z matrix, and since we have 3 busses, the dimension of Z should be [3x3]. I formed a for loop in case of adding a new bus to add a new row and new column (increases the dimension), I kept the limits of b from 1 to max. # of busses (Which is 3) to not add the 4th row and 4th column. However, I do not know how to get the last element of the matrix (which is element (3x3)). So, could someone please help me with?
Here's my code:
Matlab:
clc;
clear all;

         % | From | To | R | X | gsh | B | T|ysh
         % | Bus | Bus | pu | pu | pu | pu | ph-sh
LD= [ 1  2 0 0.8    0 0
             1  3 0 0.4 0 0
             2  3 0 0.4 0 0];
      
r=1.05;
angle=5*(pi/180);
[x,y]=pol2cart(angle,r) ;
t=x+i*y;

fbus=LD(:,1);             % Reading from bus
tbus=LD(:,2);             % Reading to bus
r = LD(:,3);              % Resistance, R...
x = LD(:,4);              % Reactance, X...
gsh=LD(:,5);
B = 1i*LD(:,6);           % Ground Admittance
%T=LD(:,7);
Zl=1/(r+(1i*x));     
%     fb tb Eg  Xg  Zd
BD = [1   0  0  inf 0.2i
      2   0  0  inf 0.4i
      3   1  0  inf 1]
fb=BD(:,1);
tb=BD(:,2);
Eg=BD(:,3);
Xg=1i*BD(:,4);
Zd=BD(:,5);     

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

busses=max(max(fbus),max(tbus));
mb=busses;
%zold=zeros(busses,busses)

%for b=1:busses
%    z(b,b) = Zd(b)  ; %diagonal matrix
%end

for b=1:busses
    z(b,b)=[Zd(b)] %diagonal elements
    %if the new bus isn't connected to GND
    if tb(b)~=0 && b==busses-1 %to not exceed 3 rows and 3 columns
        nrow=z(fb(b),:) %repeat row# (the old bus)
        ncol=nrow'      %new column
        ns=length(z)    %new size
        zz=zeros(ns,ns) %set a zero matrix [ns,ns]
        zz(ns,:)=nrow %add the new row to the zero matrix
        zz(:,ns)      %add the new col to the zero matrix
        z(ns,ns)=Zd(b)+ z(fb(b),fb(b))    %the last element of the modified matrix
                            %= the added Z (Zd) + Z(#of old Bus,#of old Bus)
        zz+z          %add zz matrix which has the new col and new row,
                      %with the diagonal matrix   
    end 
    %special case: the new bus is connected to GND
        if tb(b)==0 && b<busses     %b<busses -> to avoid adding the 4th row and col
        ncol=zeros(b+1,1);          %add a column of zero elements
        nrow=zeros(1,b+1);          %add a row of zero elements
        ns=length(z);               %to get the new size
        zz=zeros(ns,ns); %the last element of the modified matrix
        z(ns,ns)=Zd(b)  %if the bus is connected directly to GND,
                        %the last element is only Zdd (the added one)
        z+zz;
    end
end
z

The result:
1617157337452.png

However, element (3x3) should be 1+0.2 = 1.2 (Zd (3) + element (1,1) of z matrix = 0.2)
 
Physics news on Phys.org
  • #2
z =1.0000 + 0.2000i 0 00 1.0000 + 0.4000i 00 0 1.0000 + 0.2000i
 

1. What is the Z-bus and why is it important in power system analysis?

The Z-bus is a mathematical representation of the impedance of a power system network. It is important in power system analysis because it allows for the calculation of voltage and current values at each bus of the system, which is essential for analyzing system stability and power flow.

2. How does the Z building algorithm work?

The Z building algorithm is a method for constructing the Z-bus matrix using the admittance matrix of a power system network. It involves iteratively adding the admittance values of each branch to the corresponding position in the Z-bus matrix, while taking into account the direction of the current flow.

3. Why use MATLAB for implementing the Z building algorithm?

MATLAB is a powerful software tool for scientific computing and data analysis. It has built-in functions and tools that make it efficient and convenient for implementing complex algorithms, such as the Z building algorithm. It also allows for easy visualization and analysis of the results.

4. What are the inputs and outputs of the Z building algorithm in MATLAB?

The inputs of the Z building algorithm in MATLAB include the admittance matrix, bus data, and line data of the power system network. The output is a Z-bus matrix, which contains the impedance values for each bus of the network.

5. How accurate is the Z building algorithm in MATLAB?

The accuracy of the Z building algorithm depends on the accuracy of the input data and the assumptions made in the algorithm. In general, it is a reliable method for calculating the Z-bus matrix, but it is important to validate the results with other methods and real-world data to ensure accuracy.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
21
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
21
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
126
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Programming and Computer Science
Replies
1
Views
760
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
2K
Back
Top