Wednesday, August 10, 2016

Loop analysis

The last three releases of the circuit simulator were primarily dealing with errors in the loop manipulation technique used by the circuit solver. A brief background is that loop analysis is the backbone of the circuit simulator. Nodal analysis is also used but that is used to determine conducting paths in a non-linear circuit and to determine the currents through stiff branches. But the bulk of the simulator is the loop analysis.

The loops can be divided into stiff loops and non-stiff loops. The non-stiff loops are solved as ODEs while the stiff loops are mere static equations. After any event in the circuit, it is necessary to ensure that the non-stiff equations fully represent the circuit. This means that the if the circuit is divided into two parts - non-stiff branches and stiff branches - the number of loops formed by the non-stiff branches with their associated nodes should be included in the loop analysis. A failure to do so will cause the simulator to break as the simulator in that case is not solving all the equations that represent the circuit.

The first error was it was assumed that two loops could be manipulated and the result need only be checked to ensure all nodes occur twice. This meant there would be no stray branches or multiple loops. This is not entirely true. It is possible that manipulating two loops could result in multiple completely disjointed loops that satisfy the condition that all nodes occur only twice. So it became necessary to trace out the loop from an origin node back to this node. If more than one loop was found, the loop manipulation was not valid.

The second error was in assuming that after two loops are manipulated there is no need to check the directions. It is always possible to have conflicts in the directions of branches with two loops that are being manipulated. For example, say loops L1 and L2 are being manipulated. There loops have a branch (say B1) common between them and the branch is in the same direction of loops L1 and L2. It is also possible that the loops have another branch (say B2) common but the direction of this branch may be the opposite in loops L1 and L2. So, with such loops, computing sum or difference of the loops is not totally straightforward and after performing the loop manipulations, it becomes necessary to check the directions of the branches in the resultant loop to make sure no branch direction is wrong.

The third error was in how the number of non-stiff loops are ensured. The number of non-stiff loops can be determined by counting the non-stiff loops and the number of nodes that they map and the loops will be equal to B-N+1. However, what was done so far was to manipulate the stiff loops and try to triangularize the stiff branches in the loop map. This technique would work in the first attempt for smaller circuits but as the circuits became bigger, this didn't work. One reason, it is not necessary that two stiff loops are compatible. Therefore, two stiff loops may have the same stiff branch but there is no way to eliminate this stiff branch from one of the loops because the result of their manipulation is not a genuine loop. In such circumstances, it is necessary to continue the loop manipulations even with non-stiff loops if necessary until the stiff branches have been eliminated from a sufficient number of stiff loops. This is now being implemented as a boot strap technique, the loop manipulations are continuously repeated until the number of non-stiff loops in the loop map meet the expectations.

At this stage, the bugs have been fixed for a three-phase inverter with LCL filter connected to the grid and behaving as a VAR compensator. However, it is still not completely certain that all bugs have been fixed as it still appears from some loop maps that some stiff loops have stiff branches common between them. This may or may not be a problem. For now, the non-stiff loops are equal to the number expected. However, I expect another round of bug fixing coming up soon.

6 comments: