When the circuit gets more complex than two or three loops, doing KVL by hand becomes error-prone. Mesh analysis is a systematic procedure for KVL.
3.1 The procedure
- Identify all the independent meshes (a mesh is the smallest closed loop with no other loops inside; a planar circuit with branches and nodes has meshes).
- Assign a mesh current to each mesh, all in the same direction (typically clockwise).
- Write KVL around each mesh, expressing voltage drops in terms of mesh currents. A shared branch carries the difference of the two mesh currents.
- Solve the resulting equations in unknowns.
- Recover branch currents from mesh currents.
The key conceptual move is treating each mesh's "circulating current" as a single variable. The actual current in any branch is the sum or difference of the mesh currents through it.
3.2 Worked example: two meshes, fully solved
Consider this two-mesh circuit, with a 12 V source on the left, a 6 V source on the right, and three resistors:
+────[R1=2Ω]─────●─────[R2=4Ω]────+
│ │ │
12 V [R3=6Ω] 6 V
│ I1 → │ ← I2 │
+─────────────────●─────────────────+
GNDLet circulate clockwise in the left mesh and circulate clockwise in the right mesh. Resistor is shared between them. The actual current going down through is (positive if wins, negative otherwise).
KVL around mesh 1, walking clockwise from the bottom-left corner: rise of 12 V across the source, drop of across , drop of across , back to the start.
KVL around mesh 2, walking clockwise from the bottom of : rise of across (we are walking against the assumed direction of from the perspective of mesh 2, so the sign flips), drop of across , drop of 6 V across the source (we are walking from the - to the + terminal backwards, so this is a rise; let's be careful).
Let me redo mesh 2 carefully. In mesh 2 walking clockwise, we go up through (against the direction we defined for ), so the voltage rises by . Then we cross in the direction of , so the voltage drops by . Then we cross the 6 V source. Suppose its + terminal is on top; then walking down from + to - is a drop of 6 V.
So we have a 2×2 system:
Solve. The determinant is .
So A clockwise in the left mesh, A clockwise in the right mesh, and the current through (downward) is A. The voltage across is V, with the top of being the higher potential.
You can sanity-check by computing power balance. Power delivered by the 12 V source: W. Power absorbed by the 6 V source (it is being charged because current flows into its + terminal): W. Power dissipated in resistors: W. Total absorbed: W. Matches the source. Good.
3.3 Mesh in matrix form
For an -mesh circuit, the result is always of the form , where is an symmetric resistance matrix (assuming all sources are independent and the circuit has no dependent sources or controlled sources). The diagonal entry equals the sum of all resistances in mesh . The off-diagonal entry equals the negative sum of resistances shared between mesh and mesh . The right-hand side collects net source voltages around each mesh.
This pattern, "fill the matrix from the topology, fill the vector from the sources, solve," is exactly what SPICE simulators automate. Numpy can do the same:
import numpy as np
R = np.array([[8.0, -6.0],
[6.0, -10.0]])
V = np.array([12.0, 6.0])
i = np.linalg.solve(R, V)
print(f"I1 = {i[0]:.3f} A, I2 = {i[1]:.3f} A")
print(f"Current through R3 (downward) = {i[0]-i[1]:.3f} A")For practice, write the same matrix for a four-mesh circuit and let numpy solve it. You will see how the topology of the circuit translates directly into the structure of the matrix.
3.4 Special cases
- Current sources between meshes fix the difference of mesh currents. Use a "supermesh" treating both as one for KVL, then add as a constraint.
- Dependent sources require an extra constraint equation for the controlling variable.
- Non-planar circuits are awkward for mesh analysis; use nodal instead.
Mesh is rarely used in practice today; almost every modern simulator uses nodal analysis under the hood, because nodal scales better. But the mesh viewpoint shines for switching converters, where each "mesh" corresponds to one stage of energy storage and release. A buck converter has two meshes alternately closed by the transistor switch: one phase ramps current up through the inductor; the other phase rings the stored current out into the load. Mesh-style analysis sizes the inductor and capacitor for the desired ripple. We return to this in Chapter 4 (Pulse and Digital Circuits).