This blog is about Python Power Electronics - a free and open source software for power electronics and power systems professionals. Aimed at providing education about power electronics application specifically to renewable energy and smart grids, the software will be accompanied by simulation examples, short reports and presentations. The software can found on the website http://www.pythonpowerelectronics.com/.

Wednesday, January 2, 2013

Branch identification

The previous program was to find the number of nodes in the circuit. A node was defined as a junction of three or four nodes. The next step is to be able to identify the branches between these nodes.

The method I have used is a search routine that starts from a node and continues until another node has reached. This is because of one major constraint imposed on the spreadsheet. Connections have to be made either vertical or horizontal and can't be made diagonal. So if you need a diagonal connection you have to go along a column and then a row.

So when starting from a node, there are certain search directions depending on the number of branches at that node - if is a +, all four search directions (up, down, right and left) are possible while if it is a T junction, three search directions may be possible (for example, up, right and left).

If the next element in the search direction is not a node, there can be two directions of searching - forward or backward. To ensure forward search, check if the new element has already been encountered. If so, that is the wrong direction.

1. One thing I could do to speed up the result is take advantage of the symmetry of the matrix. If node 1 is connected to node 3, node 3 is connected to node 1. No need to do the search again. So I need to to do the search for node i and node k if k>i. Then just take the lower triangular part to be equal to the upper triangular part.

2. The diagonal elements are null. What will happen if there is a self loop - a loop originating and terminating at a node? But will something like that happen in practical electrical circuits?

More issues will be examined with other circuits. Probably will be at least two more versions of this code.

Here, I need to stop and comment about Python. The fact that an embedded objects are possible and that too of any dimension is fantastic. In the above code, we have an array with the elements being lists of lists! And add to that, the lists are not of the same length. Anything goes! Makes like a whole lot simpler.