Sie sind auf Seite 1von 5

Ybus Formation Code

Documentation

Castillo, Ma. Danica G.


2013- 09851
Code Overview

This code inputs the impedances from a Test Bus Case text file, perform calculations to
get the Ybus matrix and outputs the matrix to a csv file, which can be opened using Microsoft
Excel.

Input

For the input, the user has two options in putting the data for the code to process. First,
the user can change the file inside the code, which the code reads as the ‘input file’, or
preferably, the user can replace the contents of the text file used by the code as input and just
overwrite it so that the user doesn’t have to modify the code anymore.

Sample Input:

(Retrieved from: http://www2.ee.washington.edu/research/pstca/pf14/ieee14cdf.txt)

The sample input is a 14-bus system with 20 impedance connections. The filename is
‘Input.txt’ and it is located at the same folder location of the code.
Code Process

First, the input file is opened and its contents are stored in variable ‘data’. Using the
textscan function, the number of buses is obtained from the contents and is stored in variable
‘busno’.

A dummy impedance array is created to scan where the impedances are located. Using a
While loop, the code searches for a specific format, the format of the bus connections and the
impedances between them. Until the format is satisfied, the arrays remain empty. Once the
dummy impedance array is not empty anymore, the array is stored in variable ‘Imp’. Lastly, the
file is closed.

The real part of the impedance is in Imp {3} while the imaginary part is in Imp {4}. The
real and imaginary part of the impedance is added. The admittance equivalent is get by getting
the inverse of the impedance values. These admittance values are stored in array ‘Adm’.
The buses where these admittances are connected are in Imp{1} and Imp{2}. The
number of connections is obtained and stored in variable ‘z’. Since this number is 1 more than
the actual number of connections because of the file reading process, the zth entry of the
necessary arrays were set to zero.

The Ybus matrix is made by declaring a ‘busno’ by ‘busno’ matrix with the entries set to
zero. The matrix is filled by the cascaded For-loop code above.
For the diagonal entries, the bus numbers are compared for similarity. If they are similar,
the entries of the Adm array with the index corresponding to the index of the Bus arrays that the
bus number appeared, is added.
The off-diagonal elements are determined by the For-loop after ‘else’. If specific bus
array elements are equal to the desired bus numbers, the negated value of the Adm array entry
corresponding to the index of the bus array elements is put to the corresponding matrix element.
Finally, the resulting Ybus matrix is written to an excel file using the dlmwrite function.

Sample Output:
The Ybus matrix output is written to ‘Output.csv’, which is located at the same folder
where the input file and code is located.

Insights

Making the code can be really easy if one knows which functions are suitable to use for a
specific need. An example is the use of the textscan function. There are many functions available
for reading a file and the maker of this code chose the textscan function because it requires a
certain horizontal format in scanning the file. The input itself follows a certain format and this
makes it suitable for using textscan. Because of this, it is not necessary for the maker to produce
or search for string compare functions in scanning the file. This makes the code shorter, but still
accurate, given the input file with the proper format.

Limitations

There are some limitations that arise in using specific functions. If for any instance, the
horizontal format of the first sections of the file (sections that does not involve corresponding
impedances in bus connections) become similar to the format of the impedance and bus number
connections, the code is not functional anymore because it will mistakenly store these sets of
data to the array intended for the impedance parameters.

Das könnte Ihnen auch gefallen