Sign in or create a free account to continue.

ELE-202 · Lesson 4 of 12 · 38 min

Nodal and mesh analysis

Series-parallel reduction works beautifully on simple circuits, but it soon runs out. A circuit with several sources, a bridge, or dependent sources cannot be reduced step by step, and writing KCL and KVL equations at random produces too many equations, some of them redundant. Engineers need a method that works on every circuit, produces exactly the right number of independent equations, and can be carried out by a computer.

Two such methods exist. Nodal analysis uses node voltages as the unknowns and writes KCL at each node. Mesh analysis uses mesh currents as the unknowns and writes KVL around each mesh. Both turn any linear circuit into a set of simultaneous linear equations, which is exactly what circuit simulators such as SPICE do internally, using an extension of nodal analysis. This chapter develops both methods, their special cases (supernodes and supermeshes) and their use with dependent sources, and shows how to solve the resulting equations with matrices.

Nodal analysis

Choose one node as the reference node (also called ground or datum), usually the one with the most branches connected, or the bottom of the diagram. Its voltage is defined as zero. Every other node gets a node voltage: the voltage of that node relative to the reference. In a circuit with \(n\) nodes there are \(n - 1\) node voltages.

Node voltages make KVL automatic. The voltage across any element connecting nodes \(j\) and \(k\) is simply \(v_j - v_k\), so the voltages around any loop sum to zero by construction. Only KCL remains to be written, once at each non-reference node. The procedure is:

  • Pick the reference node and label the node voltages \(v_1, v_2, \dots, v_{n-1}\).
  • At each non-reference node, write KCL, expressing every resistor current in terms of node voltages: the current leaving node \(j\) through a resistor \(R\) to node \(k\) is \((v_j - v_k)/R\).
  • Solve the \(n - 1\) equations. Then find any current or power from the node voltages.
A circuit with a reference node at the bottom and two nodes, v1 and v2, at the top. A 10 ampere source feeds node 1 from the reference. A 2 ohm resistor connects node 1 to the reference, a 4 ohm resistor connects node 1 to node 2, an 8 ohm resistor connects node 2 to the reference, and a 1 ampere source draws current from node 2 to the reference.
A two-node circuit for nodal analysis. Node voltages are measured from the reference node at the bottom.

Worked problem

Nodal analysis with current sources

In the circuit shown, a 10 A source feeds node 1, a 1 A source draws current from node 2 to the reference, and the resistors are 2 Ω (node 1 to reference), 4 Ω (node 1 to node 2) and 8 Ω (node 2 to reference). Find \(v_1\), \(v_2\) and the current in the 4 Ω resistor.

Show solution
  1. KCL at node 1 (currents leaving = currents entering): \(\dfrac{v_1}{2} + \dfrac{v_1 - v_2}{4} = 10\).
  2. KCL at node 2: \(\dfrac{v_2 - v_1}{4} + \dfrac{v_2}{8} + 1 = 0\).
  3. Multiply through to clear fractions: node 1 gives \(3v_1 - v_2 = 40\); node 2 gives \(-2v_1 + 3v_2 = -8\).
  4. From the first, \(v_2 = 3v_1 - 40\). Substitute: \(-2v_1 + 9v_1 - 120 = -8\), so \(7v_1 = 112\) and \(v_1 = 16\) V.
  5. \(v_2 = 48 - 40 = 8\) V.
  6. Current in the 4 Ω from node 1 to node 2: \((16 - 8)/4 = 2\) A. Check at node 2: 2 A in; \(8/8 = 1\) A and 1 A out. ✓

Answer: \(v_1 = 16\) V, \(v_2 = 8\) V, and 2 A flows from node 1 to node 2 through the 4 Ω resistor.

Writing the equations by inspection

For circuits with only resistors and independent current sources, the nodal equations have a pattern that can be written down directly in matrix form, \(\mathbf{G}\mathbf{v} = \mathbf{i}\):

  • The diagonal entry \(G_{jj}\) is the sum of the conductances connected to node \(j\).
  • The off-diagonal entry \(G_{jk}\) is minus the sum of the conductances connecting nodes \(j\) and \(k\).
  • The right-hand entry \(i_j\) is the total source current entering node \(j\).

For the example above:

\[\begin{bmatrix} \tfrac12 + \tfrac14 & -\tfrac14 \ -\tfrac14 & \tfrac14 + \tfrac18 \end{bmatrix} \begin{bmatrix} v_1 \ v_2 \end{bmatrix} = \begin{bmatrix} 10 \ -1 \end{bmatrix}\]

The conductance matrix is symmetric, which is a quick check on hand-written equations. Large circuits are solved this way by computer. The program below uses NumPy (introduced in AI-110) to find the resistance of the unbalanced bridge from Lesson 2 by injecting a 1 A test current and solving for the node voltages.

Solving nodal equations with a matrix
import numpy as np

# Bridge from Lesson 2: nodes a, b, c (d is the reference). Inject a 1 A test current at a.
G = lambda r: 1 / r
A = np.array([[G(30) + G(90), -G(30),                -G(90)],
              [-G(30),         G(30) + G(60) + G(20), -G(60)],
              [-G(90),        -G(60),                 G(90) + G(60) + G(40)]])
i = np.array([1.0, 0.0, 0.0])
v = np.linalg.solve(A, i)
print("node voltages (V):", v.round(3))
print("R_ad =", round(v[0] / 1.0, 3), "ohms")
Output
node voltages (V): [36. 14. 12.]
R_ad = 36.0 ohms

The result, 36 Ω, matches the wye-delta calculation of Lesson 2. The test-source idea used here (apply 1 A, measure the voltage) returns in Lesson 6 for finding Thévenin resistances.

Voltage sources in nodal analysis

A voltage source connected between a node and the reference simply fixes that node's voltage: one unknown fewer, and no KCL equation is needed at that node. A voltage source between two non-reference nodes is harder, because its current is unknown and cannot be written from Ohm's law. The solution is a supernode: enclose the voltage source and its two nodes in a boundary, and write KCL for the whole boundary (by the generalized KCL of Lesson 2). The source supplies the second equation, a constraint between the two node voltages.

Worked problem

A supernode

A 6 V source connects node 1 (+) to node 2 (−). A 6 A current source feeds node 1 from the reference. A 2 Ω resistor connects node 1 to the reference and a 4 Ω resistor connects node 2 to the reference. Find \(v_1\) and \(v_2\).

Show solution
  1. Supernode around nodes 1 and 2: the current entering the boundary (6 A) equals the current leaving through the resistors: \(\dfrac{v_1}{2} + \dfrac{v_2}{4} = 6\).
  2. Constraint from the source: \(v_1 - v_2 = 6\).
  3. Substitute \(v_1 = v_2 + 6\): \(\dfrac{v_2 + 6}{2} + \dfrac{v_2}{4} = 6\), so \(0.75v_2 = 3\) and \(v_2 = 4\) V.
  4. \(v_1 = 10\) V.
  5. Check: 2 Ω carries 5 A and 4 Ω carries 1 A, total 6 A. ✓ The voltage source carries the 1 A that flows from node 1 to node 2.

Answer: \(v_1 = 10\) V and \(v_2 = 4\) V.

Circuit with a 6 volt source connected between node 1 and node 2, enclosed by a dashed boundary labeled supernode. A 6 ampere source feeds node 1 from the reference. A 2 ohm resistor goes from node 1 to the reference and a 4 ohm resistor from node 2 to the reference.
A supernode encloses a voltage source between two non-reference nodes; KCL is written for the whole boundary.

Dependent sources in nodal analysis

Dependent sources are handled like independent ones, with one extra step: express the controlling variable in terms of the node voltages and substitute.

Worked problem

Nodal analysis with a VCCS

A 2 A source feeds node 1. Resistors: 2 Ω from node 1 to the reference, 2 Ω from node 1 to node 2, 4 Ω from node 2 to the reference. A voltage-controlled current source injects \(0.5v_1\) amperes into node 2 from the reference. Find the node voltages.

Show solution
  1. Node 1: \(\dfrac{v_1}{2} + \dfrac{v_1 - v_2}{2} = 2\), i.e. \(v_1 - 0.5v_2 = 2\).
  2. Node 2: \(\dfrac{v_2 - v_1}{2} + \dfrac{v_2}{4} = 0.5v_1\), i.e. \(-v_1 + 0.75v_2 = 0\).
  3. From node 2: \(v_1 = 0.75v_2\). Substitute: \(0.75v_2 - 0.5v_2 = 2\), so \(v_2 = 8\) V and \(v_1 = 6\) V.
  4. Check node 2: the dependent source injects \(0.5 \times 6 = 3\) A; leaving: \((8 - 6)/2 + 8/4 = 1 + 2 = 3\) A. ✓

Answer: \(v_1 = 6\) V and \(v_2 = 8\) V. Node 2 is higher than node 1, so 1 A flows backwards through the middle resistor, from node 2 to node 1: the dependent source is pushing energy into the circuit. Note that with a dependent source the matrix is no longer symmetric.

Mesh analysis

Mesh analysis is the dual of nodal analysis. It applies to planar circuits (those that can be drawn without crossing wires). Assign a mesh current to each mesh, conventionally circulating clockwise. A mesh current is a fictitious loop current; the actual current in a branch is the mesh current if the branch belongs to only one mesh, or the difference of two mesh currents if it is shared between meshes. Mesh currents satisfy KCL automatically, since each one enters and leaves every node it passes through. Only KVL remains, written around each mesh.

The procedure:

  • Assign clockwise mesh currents \(i_1, i_2, \dots\) to the \(b - n + 1\) meshes.
  • Around each mesh, write KVL. For a resistor shared by meshes \(j\) and \(k\), the voltage drop in the direction of \(i_j\) is \(R(i_j - i_k)\).
  • Solve, then find branch currents as mesh currents or their differences.
Two-mesh circuit. Left mesh: a 42 volt source and a 4 ohm resistor. A 6 ohm resistor is shared between the meshes. Right mesh: a 2 ohm resistor and a 12 volt source whose plus terminal is met first by the clockwise mesh current. Clockwise arrows mark mesh currents i1 and i2.
A two-mesh circuit with clockwise mesh currents. The 6 Ω resistor carries \(i_1 - i_2\).

Worked problem

Mesh analysis

Mesh 1 contains a 42 V source (rising in the clockwise direction) and a 4 Ω resistor; a 6 Ω resistor is shared with mesh 2; mesh 2 also contains a 2 Ω resistor and a 12 V source that the clockwise current enters at its + terminal. Find the mesh currents, the current in the 6 Ω resistor, and check the power balance.

Show solution
  1. Mesh 1: \(42 = 4i_1 + 6(i_1 - i_2)\), i.e. \(10i_1 - 6i_2 = 42\).
  2. Mesh 2: \(0 = 6(i_2 - i_1) + 2i_2 + 12\), i.e. \(-6i_1 + 8i_2 = -12\).
  3. In matrix form: \(\begin{bmatrix} 10 & -6 \ -6 & 8 \end{bmatrix}\begin{bmatrix} i_1 \ i_2 \end{bmatrix} = \begin{bmatrix} 42 \ -12 \end{bmatrix}\). The determinant is \(80 - 36 = 44\).
  4. \(i_1 = (42 \times 8 - 6 \times 12)/44 = 264/44 = 6\) A; \(i_2 = (10 \times (-12) + 6 \times 42)/44 = 132/44 = 3\) A.
  5. 6 Ω current: \(i_1 - i_2 = 3\) A, downward in the direction of \(i_1\).
  6. Powers: 42 V source supplies \(42 \times 6 = 252\) W. Absorbed: 4 Ω 144 W, 6 Ω 54 W, 2 Ω 18 W, and the 12 V source \(12 \times 3 = 36\) W (it is being charged). Total absorbed 252 W. ✓

Answer: \(i_1 = 6\) A, \(i_2 = 3\) A, and 3 A in the shared 6 Ω resistor. The 12 V source absorbs 36 W, like a battery on charge.

As with nodal analysis, a resistive circuit with only independent voltage sources gives a symmetric matrix by inspection: each diagonal entry is the total resistance around the mesh, each off-diagonal entry is minus the resistance shared by the two meshes, and the right-hand side is the net source voltage rise around each mesh.

Current sources in mesh analysis

A current source on the outer edge of a circuit, belonging to one mesh only, fixes that mesh current: one unknown fewer. A current source shared between two meshes fixes the difference of their mesh currents, but its voltage is unknown, so KVL cannot be written around either mesh directly. The answer is a supermesh: write KVL around the larger loop formed by the two meshes with the shared current source removed, and use the source as the constraint equation.

Worked problem

A supermesh

Mesh 1 contains a 42 V source (rising clockwise) and a 2 Ω resistor. A 3 A current source on the shared branch forces \(i_2 - i_1 = 3\) A. Mesh 2 contains 4 Ω and 6 Ω resistors. Find \(i_1\) and \(i_2\).

Show solution
  1. Supermesh KVL around the outside loop (avoiding the current source): \(42 = 2i_1 + 4i_2 + 6i_2\).
  2. Constraint: \(i_2 = i_1 + 3\).
  3. Substitute: \(42 = 2i_1 + 10(i_1 + 3)\), so \(12i_1 = 12\) and \(i_1 = 1\) A.
  4. \(i_2 = 4\) A.
  5. Check: \(2 \times 1 + 10 \times 4 = 42\) V. ✓

Answer: \(i_1 = 1\) A and \(i_2 = 4\) A.

Choosing a method

Both methods work on any planar circuit; nodal analysis also works on non-planar circuits. The usual rule is to choose the method with fewer equations, after accounting for sources that fix unknowns (Lesson 5 shows how computers solve either form as a matrix equation):

  • Nodal analysis needs \(n - 1\) equations, minus one for each voltage source (each removes an unknown, directly or through a supernode).
  • Mesh analysis needs \(b - n + 1\) equations, minus one for each current source.

Circuits with many parallel branches and current sources favor nodal analysis; circuits with many series elements and voltage sources favor mesh analysis. Nodal analysis also fits the way voltages are measured in practice (relative to a common ground), and it is the basis of computer simulation, using a formulation called modified nodal analysis that adds the currents of voltage sources as extra unknowns.

Worked problem

Counting equations

A planar circuit has 9 branches and 6 nodes, including two independent voltage sources (one connected to the reference node) and one current source on an outer branch. How many equations does each method need?

Show solution
  1. Nodal: \(n - 1 = 5\) node voltages; each voltage source removes one unknown: \(5 - 2 = 3\) equations.
  2. Mesh: \(b - n + 1 = 4\) mesh currents; the outer current source fixes one: \(4 - 1 = 3\) equations.

Answer: Three equations either way, so choose whichever makes the unknowns you actually need easiest to reach: node voltages if voltages are wanted, mesh currents if branch currents are.

Checking answers

Three habits catch nearly every error in nodal and mesh analysis. First, check that the conductance or resistance matrix is symmetric when the circuit has no dependent sources. Second, substitute the solution back into an equation you did not use, for example KCL at the reference node or KVL around an outer loop. Third, check the power balance. Each takes a minute and saves hours of chasing a sign error later.

Common mistakes

  • MistakeWriting KCL at the reference node in addition to the others.

    InsteadUse \(n - 1\) equations; the reference-node equation is dependent (but useful as a check).

  • MistakeWriting a resistor current as \(v_1/R\) when it connects two non-reference nodes.

    InsteadUse the difference: \((v_1 - v_2)/R\).

  • MistakeWriting KVL around a mesh that contains a current source.

    InsteadThe current source's voltage is unknown; use a supermesh, or let it fix the mesh current if it is on an outer branch.

  • MistakeForgetting to express a dependent source's controlling variable in terms of the unknowns.

    InsteadWrite the controlling variable as a node-voltage or mesh-current expression and substitute.

  • MistakeTreating a shared resistor as carrying just one mesh current.

    InsteadA shared resistor carries the difference of the two mesh currents.

Summary and key terms

  • Nodal analysis: choose a reference, label \(n - 1\) node voltages, write KCL at each non-reference node, solve.
  • Resistor current from node \(j\) to node \(k\) is \((v_j - v_k)/R\).
  • By inspection, \(\mathbf{G}\mathbf{v} = \mathbf{i}\) with sums of conductances on the diagonal and negative shared conductances off it.
  • A voltage source to the reference fixes a node voltage; one between two nodes forms a supernode (KCL for the boundary plus a constraint).
  • Mesh analysis: assign clockwise mesh currents to the \(b - n + 1\) meshes, write KVL around each, solve.
  • A shared resistor carries the difference of its two mesh currents; a shared current source forms a supermesh.
  • Dependent sources need their controlling variable written in terms of the unknowns; the matrix is then not symmetric.
  • Choose the method with fewer equations, and check by symmetry, back-substitution and power balance.
Reference node
The node chosen as zero volts, from which all node voltages are measured.
Node voltage
The voltage of a node relative to the reference node.
Nodal analysis
Solving a circuit by writing KCL at each non-reference node in terms of node voltages.
Conductance matrix
The matrix of coefficients in nodal equations, symmetric for resistive circuits without dependent sources.
Supernode
A boundary enclosing a voltage source between two non-reference nodes, used to write one combined KCL equation.
Mesh current
A fictitious current circulating around a mesh, used as an unknown in mesh analysis.
Mesh analysis
Solving a planar circuit by writing KVL around each mesh in terms of mesh currents.
Supermesh
A loop formed by two meshes sharing a current source, used to write one combined KVL equation.
Planar circuit
A circuit that can be drawn on a flat surface with no crossing branches.
Constraint equation
An extra equation linking unknowns, supplied by a source inside a supernode or supermesh.
Modified nodal analysis
An extension of nodal analysis, used by circuit simulators, that adds voltage-source currents as unknowns.
SPICE
A widely used family of circuit simulation programs based on nodal analysis.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. A circuit has 5 nodes and 8 branches. How many equations do nodal and mesh analysis each need, before accounting for sources?

    Show answer

    Nodal: 4. Mesh: 8 − 5 + 1 = 4.

  2. A 4 A source feeds node 1, which connects to the reference through 5 Ω and 20 Ω in parallel. Find \(v_1\).

    Show answer

    G = 0.2 + 0.05 = 0.25 S; v₁ = 4/0.25 = 16 V.

  3. Write the nodal matrix for: 1 Ω from node 1 to the reference, 2 Ω between nodes 1 and 2, 2 Ω from node 2 to the reference, with 3 A into node 1. Then solve.

    Show answer

    [[1.5, −0.5], [−0.5, 1.0]] v = [3, 0]. v₂ = 0.5v₁; 1.5v₁ − 0.25v₁ = 3, so v₁ = 2.4 V, v₂ = 1.2 V.

  4. A 12 V source connects node 1 to the reference. Node 1 connects through 3 Ω to node 2, and node 2 to the reference through 6 Ω. Find \(v_2\) by nodal analysis.

    Show answer

    v₁ = 12 (fixed). Node 2: (v₂ − 12)/3 + v₂/6 = 0, so 2v₂ − 24 + v₂ = 0 and v₂ = 8 V.

  5. In a supernode, a 10 V source connects node 1 (+) and node 2 (−). Node 1 has 5 Ω and node 2 has 10 Ω to the reference, and a 4 A source feeds the supernode. Find both node voltages.

    Show answer

    v₁/5 + v₂/10 = 4 and v₁ = v₂ + 10: (v₂ + 10)/5 + v₂/10 = 4, so 0.3v₂ = 2 and v₂ = 6.67 V, v₁ = 16.67 V.

  6. Two meshes share a 4 Ω resistor. Mesh 1 has a 24 V source and 2 Ω; mesh 2 has 6 Ω and no source. Find the mesh currents.

    Show answer

    6i₁ − 4i₂ = 24 and −4i₁ + 10i₂ = 0, so i₁ = 2.5i₂; 15i₂ − 4i₂ = 24, i₂ = 2.18 A, i₁ = 5.45 A.

  7. In the previous problem, what current flows in the shared 4 Ω resistor?

    Show answer

    i₁ − i₂ = 5.45 − 2.18 = 3.27 A.

  8. A 2 A current source sits on the outer branch of mesh 1, directed with \(i_1\). What does that tell you, and how many equations remain in a two-mesh circuit?

    Show answer

    i₁ = 2 A directly; only one KVL equation, for mesh 2, remains.

  9. A CCVS of value \(5i_x\) appears in a mesh, where \(i_x\) is the current in a resistor shared by meshes 1 and 2 (in the direction of \(i_1\)). How do you express \(i_x\)?

    Show answer

    i_x = i₁ − i₂, so the source voltage is 5(i₁ − i₂), substituted into the KVL equations.

  10. Why does SPICE use nodal rather than mesh analysis?

    Show answer

    Nodal analysis works for any circuit, planar or not, the equations are easy to assemble automatically from the element list, and node voltages are what engineers usually want to see.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz