An Algorithm for Modified Nodal Analysis


This document describes an algorithmic method for generating MNA equations.  It consists of several parts:.


Many of the ideas and notation from this page are from Litovski, though the discussion here is quite simpler because only independent voltage and current sources are considered.


Review

Recall from the previous document:

MNA applied to a circuit with only passive elements (resistors) and independent current and voltage sources results in a matrix equation of the form:

For a circuit with n nodes and m independent voltage sources:

The circuit is solved by a simple matrix manipulation:

Though this may be difficult by hand, it is straightforward and so is easily done by computer.


Notational Convention

Obviously, the notation used does not change the solution.  However the convention described below will make it quite easy to develop the matrices necessary for solution of the circuit.  

These rules are somewhat restrictive (more so than they need to be) but they make development of the algorithm easier while still allowing quite a bit of freedom.

These rules are easily explained with an example (Example 3 from previous page):

This circuit is labeled according to the guidelines above.  Ground is node 0 and the other two nodes are labeled 1 and 2.  The voltage and current sources have labels with no underscores and the current through the voltage source Vs1 is labeled I_Vs1.  We will discuss how to use this diagram (with these labels) to generate the MNA equations below.


Generating the MNA matrices

There are three matrices we need to generate, the A matrix, the x matrix and the z matrix.  Each of these will be created by combining several individual sub-matrices.  To motivate the rules for generating the matrices we will consider the two sample circuits below (example 2 and example 3 from previous web page, with Notational Convention as above).  I simply state the resulting MNA equations, but in the following text we will show how to generate each one.

Case 1

Circuit Diagram


Case 2

Circuit Diagram


The A matrix

The A matrix will be developed as the combination of 4 smaller matrices, G, B, C, and D.  

The A matrix is (m+n)x(m+n) (n is the number of nodes, and m is the number of independent voltage sources) and:

Rules for making the G matrix

The G matrix is an nxn matrix formed in two steps

  1. Each element in the diagonal matrix is equal to the sum of the conductance (one over the resistance) of each element connected to the corresponding node.  So the first diagonal element is the sum of conductances connected to node 1, the second diagonal element is the sum of conductances connected to node 2, and so on.
  2. The off diagonal elements are the negative conductance of the element connected to the pair of corresponding node.  Therefore a resistor between nodes 1 and 2 goes into the G matrix at location (1,2) and locations (2,1).

Demonstrations

Case 1

Circuit Diagram MNA Equations


Case 2

Circuit Diagram MNA Equations


If an element is grounded, it will only have contribute to one entry in the G matrix -- at the appropriate location on the diagonal.  If it is ungrounded it will contribute to four entries in the matrix -- two diagonal entries (corresponding to the two nodes) and two off-diagonal entries.

Rules for making the B matrix

The B matrix is an nxm matrix with only 0, 1 and -1 elements.  Each location in the matrix corresponds to a particular voltage source (first dimension) or a node (second dimension).  If the positive terminal of the ith voltage source is connected to node k, then the element (i,k) in the B matrix is a 1.  If the negative terminal of the ith voltage source is connected to node k, then the element (i,k) in the B matrix is a -1.  Otherwise, elements of the B matrix are zero.

Demonstrations

Case 1

Circuit Diagram MNA Equations

Case 2

Circuit Diagram MNA Equations

If a voltage source is ungrounded, it will have two elements in the B matrix (a 1 and a -1 in the same column).  If it is grounded it will only have one element in the matrix.

Rules for making the C matrix

The C matrix is an mxn matrix with only 0, 1 and -1 elements.  Each location in the matrix corresponds to a particular node (first dimension) or voltage source (second dimension).  If the positive terminal of the ith voltage source is connected to node k, then the element (k,i) in the C matrix is a 1.  If the negative terminal of the ith voltage source is connected to node k, then the element (k,i) in the C matrix is a -1.  Otherwise, elements of the C matrix are zero.

In other words, the C matrix is the transpose of the B matrix.  (This is not the case when dependent sources are present.)

Case 1:

Case 2:

Rules for making the D matrix

The D matrix is an mxm matrix that is composed entirely of zeros.  (It can be non-zero if dependent sources are considered.)

Case 1:

Case 2:

The x matrix

The x matrix holds our unknown quantities and will be developed as the combination of 2 smaller matrices v and j.  It is considerably easier to define than the A matrix.

The x matrix is (m+n)x1 (n is the number of nodes, and m is the number of independent voltage sources) and:

Rules for making the v matrix

The v matrix is an nx1 matrix formed of the node voltages.  Each element in v corresponds to the voltage at the equivalent node in the circuit (there is no entry for ground -- node 0).  

For example if a circuit has three nodes, the v matrix is

For a circuit with n nodes we get

and so on.

Rules for making the j matrix

The j matrix is an mx1 matrix, with one entry for the current through each voltage source.  So if there are two voltage sources V1 and V2, the j matrix will be:

Demonstrations for the x matrix.

Case 1

Circuit Diagram MNA Equations


Case 2

Circuit Diagram MNA Equations

The z matrix

The z matrix holds our independent voltage and current sources and will be developed as the combination of 2 smaller matrices i and e.  It is quite easy to formulate.

The z matrix is (m+n)x1 (n is the number of nodes, and m is the number of independent voltage sources) and:

Rules for making the i matrix

The i matrix is an nx1 matrix with each element of the matrix corresponding to a particular node.  The value of each element of i is determined by the sum of current sources into the corresponding node.  If there are no current sources connected to the node, the value is zero.

Rules for making the e matrix

The e matrix is an mx1 matrix with each element of the matrix equal in value to the corresponding independent voltage source.

Demonstrations for the z matrix.

Case 1

Circuit Diagram MNA Equations


Case 2

Circuit Diagram MNA Equations

Putting it Together

We can now write out the full matrix solutions for both cases that we have been developing.

Case 1

Circuit Diagram MNA Equations


Case 2

Circuit Diagram MNA Equations

If you are still unsure about the application of the algorithm, some more examples are available.


So far we have only dealt with resistors and independent voltage and current sources.  The next document will show that adding capacitors and inductors is trivial, and adding op-amps only adds minimally to the difficulty.


Back

Erik Cheever's Home Page

Next

Please email me with any comments or suggestions