• No results found

LU decomposition is based on the ability to write matrix A as the product of two matrices L and U as shown in Equation 6.3.

L.U = A (6.3)

L is lower triangular, which means it has elements only on the diagonal and above, while U is upper triangular, having elements only on the diagonal and below. For a 4*4 matrix A, Equation 6.3 would look like this:

Equation 6.3 can be used to solve the linear set

A.x = (L.U).x = L.(U.x) = b (6.4)

by first solving for vector y such that

L.y = b (6.5)

and then solving

U.x = y (6.6)

The advantage of breaking up one linear set into two successive ones is that the solution of a triangular set of equations is quite trivial [26]. In a divide and conquer type strategy, solving a set of triangular equations is much easier than solving a single standard matrix equation. This is the essence of the LU decomposition algorithm.

The LU decomposition algorithm is well known and well documented. As such it is easy to find an implementation of the algorithm written in the C programming language. On the advice of this project’s supervisor, the decision was made to take advantage of this fact and utilise LU decomposition procedures as found in [26], rather than creating them from scratch. While the procedures provide the basic functionality, they have been modified to work with the data structures used within the circuit analysis system as can be seen in the code listings in Appendix G.

6.7 Iterative Circuit Analysis Algorithm

The iterative circuit analysis algorithm aims to quickly recalculate the nodal voltages for a circuit design in response to a change in the resistance of a branch (resistor). A change of resistance will be caused by the user thinning or fattening a wire in the design. When this is done, a flag is set on the resistor to indicate that a change has been made.

At the start of the iterative algorithm, the first thing performed is a search through the resistors in the resistor table to determine whether a resistor has been modified. If not, the algorithm ends here as there is nothing to recalculate.

Having found a modified resistor, the algorithm proper begins. The first iteration revolves around recalculating the new nodal voltages of the nodes at either end of the resistor. The two nodes are stored in a linked list, with each list element containing a node id and a pointer to the next element in the list.

For each node in the list the following process occurs:

Firstly, the resistors connected to the node are looked up in the resistor table and their resistances added up to give the total resistance connected to the node.

Secondly, the current through each of the resistors is calculated and added to-gether. According to Kirchhoff’s current law, the sum of currents at a node should be zero, but since the resistor has been changed, the equilibrium of the node has moved and so the total current will be a positive or negative value. This is the amount of current that needs to be added or removed from the node to regain equilibrium through changing the node’s voltage. The change of voltage required is calculated using Ohm’s law as shown in Equation 6.7.

voltageChange = currentDif f erence × totalResistance (6.7)

This voltage can then be added to the node’s old voltage value to give it a new value. However, only fifty percent of this voltage change is added rather than the whole amount. Scaling to a correction factor in this way is known as relaxation.

Taking a factor of fifty percent as done here is known as under-relaxation since the scaling factor is less than 1. Doing this will ensure that the algorithm iterates more quickly to a final solution.

After a node has been analysed, the nodes that are connected to it by resistors are added to a new list, if not already present. This new list contains all the nodes to be analysed in the next iteration.

This process is performed on both initial nodes at the end of which the new voltage values are stored in place of the old ones. The process is then repeated iteratively on the nodes in the new list, until the stop condition is reached, as explained here:

After the new voltage value has been found for a node, it is checked to see if the difference in voltage for that node is more than 0.01 percent of the largest voltage source value. This is a circuit-wide margin of error - if the change in voltage is greater than this margin for any node that is analysed, the analysis continues for another iteration. Once the changes made are smaller than this margin for all nodes analysed, an acceptable level of accuracy has been met and the outer bounds of the iteration have been found. Further iterations will contract the nodal voltages toward their true values as changes become smaller and smaller

until the original two nodes register a change in voltage which is less than the error margin and the analysis is complete.

In this way, the analysis computation is localised to an area around the modified resistor, so that the whole circuit does not have to be recalculated as in the MNA algorithm.

Related documents