Sub topic 8
From KCL to nodal equations
This chapter assumes you can state KCL, assign current reference directions, and apply Ohm's law to a resistor. You should also be able to solve a small linear system. Here you will turn KCL into a method that finds every node voltage in a circuit.
The idea
KCL at one node relates currents. Ohm's law relates each resistor current to the voltages at its two ends. Substitute Ohm's law into KCL and the currents disappear. What remains are equations whose only unknowns are node voltages. This is nodal analysis.
The procedure
- Pick a reference node (ground) and call its voltage 0 V. The node with the most connections is a common choice.
- Label the voltage of every other node: v1, v2, and so on.
- At each non-reference node, write KCL. A common choice is "sum of currents leaving the node equals the source current entering it."
- Write each resistor current as (voltage at the node minus voltage at the far end) divided by R. This choice of direction, leaving the node you are writing KCL for, keeps the signs consistent.
- Collect terms and solve the linear system.
Worked example
A 10 mA current source feeds node 1. R1 = 1 kΩ connects node 1 to ground. R2 = 2 kΩ connects node 1 to node 2. R3 = 2 kΩ connects node 2 to ground.
At node 1, the currents leaving through R1 and R2 equal the source current:
v1/R1 + (v1 − v2)/R2 = 0.010
At node 2, the only source is the current arriving through R2. It leaves through R3:
(v2 − v1)/R2 + v2/R3 = 0
Rewrite both with conductances, G = 1/R:
(G1 + G2) v1 − G2 v2 = 0.010
−G2 v1 + (G2 + G3) v2 = 0
The same equations in matrix form are G v = I. The matrix has a pattern worth noticing. Each diagonal entry is the sum of the conductances touching that node. Each off-diagonal entry is the negative of the conductance between the two nodes.
import numpy as np
R1, R2, R3 = 1000.0, 2000.0, 2000.0
G = np.array([
[1/R1 + 1/R2, -1/R2],
[-1/R2, 1/R2 + 1/R3],
])
I = np.array([0.010, 0.0]) # source current entering each node
v1, v2 = np.linalg.solve(G, I)
print(v1, v2) # 8.0 4.0 (volts)
i_r1 = v1 / R1
i_r2 = (v1 - v2) / R2
print(round(i_r1 + i_r2, 6)) # 0.01 (amperes)The solution is v1 = 8 V and v2 = 4 V. R1 carries 8 mA and R2 carries 2 mA. Together they equal the 10 mA source current, so KCL holds at node 1.
Common errors
- Mixed directions in one equation. If you write the R2 current as (v1 − v2)/R2 at node 1, you must write it as (v2 − v1)/R2 at node 2. Both are correct because each is the current leaving the node you are working on.
- Forgetting the source sign. A source current entering a node goes on the right side as a positive value. A source current leaving a node is negative.
- Writing an equation at ground. The reference node's equation is redundant. A circuit with N nodes needs N − 1 equations.
- Mixing units. Use ohms with amperes, or kilohms with milliamperes. Mixing kΩ with A gives results that are off by a factor of 1000.
Exercise
Exercise
Use the same circuit as the worked example, but change R3 to 1 kΩ. Write the nodal equations and find v1 and v2. Then check KCL at node 1.
Show answer
With R1 = 1 kΩ, R2 = 2 kΩ, R3 = 1 kΩ, the equations are 1.5 mS·v1 − 0.5 mS·v2 = 10 mA and −0.5 mS·v1 + 1.5 mS·v2 = 0. The second equation gives v1 = 3 v2. Substituting into the first: 4.5 mS·v2 − 0.5 mS·v2 = 10 mA, so v2 = 2.5 V and v1 = 7.5 V. Check at node 1: R1 carries 7.5 mA and R2 carries (7.5 − 2.5)/2000 = 2.5 mA. The sum is 10 mA, equal to the source current.