When a circuit has more than one loop
In Circuits and Ohm's law every circuit was a single loop: one battery, one or two resistors, one current. Ohm's law, , was enough. But open almost any electronic device and the circuit is a network. A phone's charging port feeds the battery and the processor at the same time. A car's lighting has the alternator and the battery both connected to the same wires. Even a humble sensor board has a reference voltage shared by several resistors, each carrying a different current.
Ohm's law describes one component. It says nothing about how components connect. For that we need two more laws, published in 1845 by Gustav Kirchhoff, then a 21-year-old student in Königsberg:
- Kirchhoff's current law (KCL): the currents flowing into any junction add up to zero. What flows in must flow out.
- Kirchhoff's voltage law (KVL): the voltages around any closed loop add up to zero. Go round a loop and you come back to the potential you started from.
These two sentences, together with one law per component such as Ohm's law, are enough to work out every current and every voltage in any circuit of resistors and sources, however tangled. Every method in the rest of this level, and every circuit simulator, is a way of organising them efficiently. This lesson is about the laws themselves: what they say, why they are true, and how to use them without sign mistakes.
Nodes, branches and loops
To apply the laws we need words for the parts of a circuit's shape.
Definition— Branch, node, loop, mesh
A branch is a single two-terminal element: a resistor, a source, a wire with a component in it. A node is a point where two or more branches meet; all the wire joining those terminals is part of the same node, because an ideal wire has no resistance and so no voltage across it. A loop is any closed path through the circuit that passes through no node twice. A mesh is a loop that has no other branch inside it, like a window pane in a drawing of a flat circuit.
Count the figure's parts. There are nodes (a, b, c and ground) and branches. There are three loops: the left window (V1, R1, R3), the right window (R3, R2, V2) and the outer rim (V1, R1, R2, V2). The two windows are the meshes.
How many independent equations do the laws give? For a connected circuit:
- KCL can be written at every node, but only of those equations are independent. The last one is the sum of the others (every branch current enters one node and leaves another, so adding all equations gives ).
- KVL can be written round every loop, but only are independent. For a flat circuit the meshes are a convenient independent set; the outer loop of the figure is the sum of the two meshes.
Here that is equations, one for each of the five branches. That is no coincidence: once Ohm's law ties each resistor's voltage to its current, there are exactly as many independent Kirchhoff equations as unknown branch currents.
Many nodes in the figure are not very interesting: node a only joins V1 to R1, so whatever flows through one flows through the other. Engineers often count essential nodes (where three or more branches meet: b and ground) and essential branches (paths between essential nodes: left, middle, right). The counting works with those too: three essential branches and two essential nodes give independent loops and KCL equation (at b), three equations for three unknown branch currents.
Signs: reference directions and the passive sign convention
Most errors in circuit analysis are sign errors, so it pays to be fussy from the start.
Before solving, you choose a direction for each unknown current (an arrow) and a polarity for each unknown voltage (a and a ). These are reference directions. They are bookkeeping, not predictions. If the true current flows the other way, the algebra simply returns a negative number. A negative answer is never a mistake in itself; it is information.
Definition— Passive sign convention
For a two-terminal element with voltage (measured from its terminal to its terminal) and current , the passive sign convention chooses the current's reference arrow to enter the terminal. Then
is the power absorbed by the element. If the element takes energy from the circuit (a resistor heating, a battery being charged); if it delivers energy to the circuit (a battery discharging).
A resistor obeys Ohm's law in the form only when its labels follow the passive convention; with the arrow entering the terminal you must write . So the habit is: label each resistor's voltage with where its current arrow enters. A source is different: its voltage is given, and its current arrow is usually drawn leaving its terminal, the way a source normally pushes current. That arrow enters the terminal, so the source absorbs , which is negative when it delivers power.
Example— Is it delivering or absorbing?
A 9 V battery has a current of 50 mA entering its terminal. With the passive convention, W absorbed: the battery is being charged. If instead the measured current entering the terminal is mA (that is, 50 mA leaving it), then W: the battery delivers 0.45 W to the circuit. Same element, same arithmetic, and the sign tells you which way the energy flows.
Kirchhoff's current law: conservation of charge
Definition— Kirchhoff's current law (KCL)
At any node, at every instant, the algebraic sum of the branch currents is zero:
counting currents whose arrows point into the node as positive and those pointing out as negative (or the other way round, consistently). Equivalently, the total current in equals the total current out.
Why it is true. Charge is conserved: it is never created or destroyed, only moved. If more current flowed into a node than out, charge would pile up there, at a rate equal to the difference. In a circuit drawing, a node is just a bit of ideal wire, and we assume it can hold no net charge. So whatever arrives must leave at once.
Analogy, not a formal construction
Think of a junction of water pipes, completely full and with rigid walls. Water cannot be squeezed, so the litres per second flowing in through some pipes must equal the litres per second flowing out through the others. If two pipes bring in 3 and 2 litres per second and a third carries 4 away, the fourth must carry away 1 litre per second. The analogy has limits (water pressure is not exactly voltage), but for junctions it is a good one.
At node b of the figure, the arrows of and point in and the arrow of points out, so KCL says
KCL also holds for a whole region. Draw a closed curve round any part of a circuit, a supernode, and the net current crossing it is zero, for the same reason. A whole circuit board connected to the rest of the world by two wires carries the same current in one wire as out of the other, whatever is happening inside.
Kirchhoff's voltage law: conservation of energy
Definition— Kirchhoff's voltage law (KVL)
Around any closed loop, at every instant, the algebraic sum of the voltages across the branches is zero:
Walk round the loop in one direction; add a branch voltage when you enter at its terminal (a drop) and subtract it when you enter at its terminal (a rise).
Why it is true. A voltage is a difference in electric potential, the energy per coulomb that a charge has at a point. Every node has one potential. Walk round a loop, adding up the differences between successive nodes, and you end where you started, at the same potential, so the differences must sum to zero. In energy terms: a coulomb carried once round the loop gains energy in the sources and gives it up in the resistors, and it returns with exactly the energy it started with. If it came back with more, you could circulate charge forever and extract free energy.
Choose the clockwise direction round the left window of the figure, starting at the bottom of V1. We enter V1 at its terminal (a rise of 12 V), then R1 at the end where enters (a drop of ), then R3 at the top where enters (a drop of ):
Round the right window, anticlockwise from the bottom of V2: a rise of 5 V through V2, then drops across R2 and R3:
Any direction of travel works, as long as you keep it all the way round.
Note
Voltages are always between two points. "The voltage at node b" is shorthand for the voltage of b relative to a chosen reference node, usually called ground and given the potential 0 V. The reference is a choice too: change it and every node voltage shifts by the same constant, while every branch voltage, every current and every power stays the same.
Series, parallel and dividers, derived
The rules for combining resistors that you may have memorised are not separate laws. They are consequences of KCL, KVL and Ohm's law, and deriving them shows exactly when they apply.
Theorem— Series and parallel resistors
(a) Resistors in series (connected end to end, so that every node between them joins exactly two of them and nothing else) behave, as seen from the two ends, like one resistor .
(b) Resistors in parallel (all connected between the same two nodes) behave like one resistor with . Equivalently, conductances add: .
Proof
(a) KCL at each node between two neighbouring resistors, where only those two branches meet, says the same current flows through every resistor. By Ohm's law, resistor has voltage . KVL round the loop formed by the chain and the two end nodes gives the total voltage , which is Ohm's law for a single resistance .
(b) All the resistors connect the same two nodes, so KVL (round the loop through any two of them) says they share one voltage . Resistor carries . KCL at either node gives the total current , which is Ohm's law for .
∎
Two consequences are used every day.
The voltage divider. Two resistors in series across a voltage share it in proportion to their resistances. The current is , so the voltage across is
The current divider. Two resistors in parallel share a current in inverse proportion to their resistances, because they share a voltage :
The smaller resistor takes the larger share. A current of 10 mA entering 1 kΩ in parallel with 4 kΩ splits as 8 mA through the 1 kΩ and 2 mA through the 4 kΩ; both have 8 V across them, and KCL checks: .
Example— A divider under load
Two 10 kΩ resistors across a 9 V battery give V. Now connect a 10 kΩ load from to ground. The divider rule assumed that the same current flows through and ; the load breaks that assumption, because some current now leaves the middle node through . Combine first: kΩ. Then the divider rule applies to in series with 5 kΩ:
A third low. The lesson: a divider's formula is only as good as the claim that nothing else draws current from its middle. The computation section shows how big the load must be before you can ignore it.
Worked example: two sources, three resistors
Now the network of the first figure, which no series-parallel trick can simplify, because the two sources sit in different branches. We solve it with the branch-current method: one unknown current per essential branch, KCL at the essential nodes, KVL round the meshes.
Example— Branch currents of the two-source network
Unknowns. (right through R1), (left through R2), (down through R3), with the arrows of the figure. Working in kΩ and mA keeps the numbers small: a kΩ times a mA is a volt.
Equations. From the previous sections:
Solve. Substitute into the two loop equations: and . Multiply the first by 4 and the second by 3 and subtract: , so mA. Then , so mA, and mA.
Interpret. is negative: 1 mA flows from b through R2 into the terminal of V2. The 12 V source is pushing current backwards through the 5 V source, as a charger pushes current into a battery. Node b sits at V.
Check with a power balance. With the passive convention, each source absorbs for a current arrow leaving its terminal:
| Element | Absorbed power |
|---|---|
| V1 | mW (delivers 36 mW) |
| V2 | mW (absorbs 5 mW) |
| R1 | mW |
| R2 | mW |
| R3 | mW |
| Total |
The total is zero, as it must be: every milliwatt V1 delivers is absorbed somewhere. A non-zero total would mean an error, almost always a sign.
The power balance is not a separate law. It follows from KCL and KVL alone: for any circuit, whatever its components, over all branches (a result called Tellegen's theorem). That is what makes it such a good check: it catches mistakes in either law, and it costs one line.
Solving the equations with NumPy
The branch equations are linear, so they form a matrix equation , and the computer can solve them however large the circuit. Lumenary Math's Linear algebra explains why a unique solution exists when the equations are independent. Here we write the three equations of the worked example row by row, in SI units, and let numpy.linalg.solve do the elimination.
import numpy as np
# The two-source network: V1 = 12 V, V2 = 5 V, R1 = 2 kΩ, R2 = 1 kΩ, R3 = 3 kΩ.
V1, V2 = 12.0, 5.0
R1, R2, R3 = 2e3, 1e3, 3e3
# Unknowns: branch currents [I1, I2, I3], with the reference directions of the figure.
A = np.array([
[1.0, 1.0, -1.0], # KCL at node b: I1 + I2 - I3 = 0
[R1, 0.0, R3], # KVL, left mesh: R1 I1 + R3 I3 = V1
[0.0, R2, R3], # KVL, right mesh: R2 I2 + R3 I3 = V2
])
b = np.array([0.0, V1, V2])
I1, I2, I3 = np.linalg.solve(A, b)
print(f"I1 = {I1*1e3:+.3f} mA I2 = {I2*1e3:+.3f} mA I3 = {I3*1e3:+.3f} mA")
print(f"node b sits at {R3*I3:.3f} V")
# Power absorbed by each element (passive sign convention). Each source's current
# arrow leaves its + terminal, so the source absorbs -V*I.
absorbed = {"V1": -V1 * I1, "V2": -V2 * I2, "R1": R1 * I1**2, "R2": R2 * I2**2, "R3": R3 * I3**2}
for name, p in absorbed.items():
role = "absorbs " if p > 0 else "delivers"
print(f"{name}: {role} {abs(p)*1e3:6.3f} mW")
print(f"|sum of absorbed powers| = {abs(sum(absorbed.values()))*1e3:.9f} mW")
# An independent check: KVL round the outer loop, V1 -> R1 -> R2 -> V2.
outer = -V1 + R1*I1 - R2*I2 + V2
print(f"outer loop: |-V1 + R1 I1 - R2 I2 + V2| = {abs(outer):.9f} V")The outer loop was not one of the equations we gave the solver, so its coming out zero is a genuine check: it is the sum of the two mesh equations, exactly as the counting argument predicted.
Next, the loaded divider. The script sweeps the load from 1 kΩ to 10 MΩ, combining with the load in parallel and applying the divider rule, and draws a bar for each output voltage.
# A 9 V battery and two 10 kΩ resistors make a "4.5 V" divider. What happens when we load it?
Vs, Ra, Rb = 9.0, 10e3, 10e3
def parallel(*rs):
return 1 / sum(1 / r for r in rs)
print(f"unloaded: Vout = {Vs * Rb / (Ra + Rb):.3f} V")
print(f"{'load':>8} {'Vout':>8} {'error':>8}")
for RL in [1e3, 3.3e3, 10e3, 47e3, 100e3, 470e3, 1e6, 10e6]:
Rlow = parallel(Rb, RL) # Rb and the load share the same two nodes
vout = Vs * Rlow / (Ra + Rlow) # divider rule with the combined lower resistance
err = (vout - 4.5) / 4.5 * 100
bar = "#" * round(vout / 4.5 * 30)
label = f"{RL/1e3:g} k" if RL < 1e6 else f"{RL/1e6:g} M"
print(f"{label:>7}Ω {vout:7.3f} V {err:7.2f} % {bar}")Finally, the same network in SPICE, the circuit simulator engineers use for exactly this kind of check. A netlist lists each element with the nodes it connects (node 0 is ground) and its value; the .control block runs an operating-point analysis (op, the DC solution) and prints the results.
Two sources, three resistors: Kirchhoff check
* nodes: a = top of V1, b = middle, c = top of V2, 0 = ground
V1 a 0 DC 12
V2 c 0 DC 5
R1 a b 2k
R2 c b 1k
R3 b 0 3k
.control
op
print v(b)
* SPICE reports the current flowing into a source's + terminal,
* so a source that delivers power shows a negative current
print i(V1) i(V2)
let p_sources = -(v(a)*i(V1) + v(c)*i(V2))
let p_resistors = (v(a)-v(b))^2/2k + (v(c)-v(b))^2/1k + v(b)^2/3k
print p_sources p_resistors
.endc
.endngspice prints v(b) = 6.000000e+00, i(v1) = -3.00000e-03 and i(v2) = 1.000000e-03, and both power totals as 3.100000e-02: the sources together deliver 31 mW (36 from V1, less the 5 that V2 absorbs) and the resistors absorb 31 mW. SPICE's sign for source current is the passive convention, so V1's mA means 3 mA leaving its terminal, and V2's mA means 1 mA entering it: the same answer as our hand solution.
Kirchhoff at the bench and in industry
Measuring. A voltmeter measures the voltage between two nodes, so it is connected across an element, in parallel; an ideal voltmeter draws no current, so KCL is undisturbed. An ammeter measures the current in a branch, so the branch must be broken and the meter inserted in series; an ideal ammeter has no voltage across it, so KVL is undisturbed. Real meters approach these ideals but do not reach them, as the divider table showed. On a real board engineers rarely break a branch to measure current. They design in a small current-sense resistor (often a few milliohms to an ohm) and measure the voltage across it.
Checking. KCL and KVL are the first tools of debugging. If the currents you measure into a node do not sum to roughly zero, one of your measurements is wrong or the circuit is not wired as drawn. If a supply's current is larger than the sum of what its loads should draw, some current is going somewhere it should not: a short circuit, a damaged part, a leaky capacitor.
Budgeting. Battery-powered products, from hearing aids to soil-moisture sensors in a field, are designed around a power budget: a table of every load's current in every mode, summed by KCL into the battery current. A sensor that wakes once a minute may draw tens of milliamps for a few milliseconds and a few microamps the rest of the time; KCL plus a time average tells you whether the battery lasts a week or five years. Real-time and low-power design returns to this.
Simulating. Every circuit simulator, from SPICE to the tools that check the power wiring of a chip with billions of nodes, is at heart a machine for writing KCL at every node and solving the result. Nodal and mesh analysis, the next lesson, shows how to write those equations systematically, and how SPICE does it.
Note
Trying it safely. Everything in this lesson can be built with a 9 V battery or a pack of AA cells, a breadboard and resistors of 1 kΩ and up, which keep currents to a few milliamps; a current-limited bench supply set to 20 mA or less is better still. Never connect a battery's terminals directly together: even a small cell can drive amps through a short circuit and get hot. And never experiment with mains electricity; the same laws hold there, but the currents can kill.
Common misconceptions
Misconception
"Current gets used up as it goes round the circuit." Current is a flow of charge, and charge is conserved: the same current that leaves a battery's terminal returns to its terminal (KCL round the whole circuit). What gets used is energy: each coulomb arrives at the resistor carrying more energy than it leaves with, and the difference becomes heat.
Misconception
"I got a negative current, so I made a mistake." A negative result means the current flows opposite to the arrow you drew, nothing more. The arrows were your choice. Change a sign in your equations to make the answer positive and you really will have made a mistake.
Misconception
"A source always delivers power." Our 5 V source absorbed 5 mW, because the 12 V source drove current into its terminal. Batteries being charged, and motors driven backwards by their load, absorb power. Only the passive sign convention and the arithmetic tell you which way the energy flows.
Misconception
"Resistors in parallel share the current equally." Only if they are equal. They share the voltage equally; the current divides in inverse proportion to resistance, so most of it goes through the smallest resistor.
Misconception
"Two resistors that are next to each other in the drawing are in series." Series means that the same current must flow through both, which needs a node joining just those two branches. In the first figure, R1 and R3 touch at node b but are not in series, because R2 joins b too.
A short history
Georg Simon Ohm published his law in 1827, from careful measurements with thermocouples as steady sources. Gustav Kirchhoff, studying in Königsberg under Franz Neumann, stated the two laws in 1845 in a paper on how current spreads through a flat conducting plate, and in 1847 he showed how to choose an independent set of equations for any network and solve them. That second paper, written decades before anyone spoke of graph theory, counted independent loops using trees, and contains the first form of what is now called the matrix-tree theorem. Kirchhoff went on to develop spectral analysis of the elements with Robert Bunsen and to state the law of thermal radiation that also bears his name. His circuit laws were later understood as low-frequency consequences of Maxwell's equations of the 1860s, which is why they hold so well in a lumped circuit and break down in an antenna.
Exercises
1. Kirchhoff's laws
Warm-upHumanA connected circuit has 6 nodes and 9 branches. How many independent KVL equations does it give?
2. Kirchhoff's laws
Warm-upHumanFour branches meet at a node. The reference arrows of mA and point into the node; the arrows of mA and mA point out of it. What is , in mA?
3. Kirchhoff's laws
CoreHumanYou walk clockwise round a loop of four elements. You meet, in order:
- a 9 V source, which you enter at its terminal;
- a resistor with 4 V across it, which you enter at its terminal;
- a resistor with 2 V across it, which you enter at its terminal;
- an element X with voltage , which you enter at its terminal.
What is , in volts?
4. Kirchhoff's laws
CoreHumanA current of 12 mA enters a node and flows down through three resistors in parallel, 2 kΩ, 6 kΩ and 3 kΩ, to ground. How much current, in mA, flows through the 3 kΩ resistor?
5. Kirchhoff's laws
Warm-upHumanAn element is labelled with the passive sign convention: its voltage is V and the reference arrow for its current enters its terminal. You solve the circuit and find mA. What is the element doing?
6. Kirchhoff's laws
CoreHumanA divider made of kΩ (top) and kΩ (bottom) is connected across a 12 V supply. A 10 kΩ load is connected from the output (the node between them) to ground, in parallel with . What is the output voltage, in millivolts?
7. Kirchhoff's laws
CoreComputationalWrite branch_currents(V1, V2, R1, R2, R3) for the two-source network of the lesson's first figure (V1 on the left, V2 on the right, R1 from V1's terminal to node b, R2 from V2's terminal to node b, R3 from b to ground). Return the tuple (I1, I2, I3) in amperes, with the figure's reference directions: rightwards through R1 into b, leftwards through R2 into b, down through R3.
The tests check the lesson's example, other values, KCL, KVL and the power balance.
8. Kirchhoff's laws
StretchComputationalA ladder network is built in sections. Looking into the input, each section is a series resistor followed by a shunt resistor to ground; behind the last shunt the ladder is terminated by a resistor to ground. With no sections at all, the input resistance is just .
Write ladder_resistance(Rs, Rp, Rt, n) returning the input resistance of a ladder of n sections, using only the series and parallel rules.
(When Ω, watch what happens as n grows.)
Further reading and resources
- Ueber den Durchgang eines elektrischen Stromes durch eine Ebene, insbesondere durch eine kreisförmige · Gustav Kirchhoff · 1845The student paper in Annalen der Physik in which the two laws first appear.
- Ueber die Auflösung der Gleichungen, auf welche man bei der Untersuchung der linearen Vertheilung galvanischer Ströme geführt wird · Gustav Kirchhoff · 1847How many equations a network needs and how to choose them, the first use of what graph theory now calls spanning trees.
- MIT OpenCourseWare 6.002: Circuits and ElectronicsA free university course whose first weeks cover the lumped-circuit abstraction and Kirchhoff's laws.
- ngspiceThe open-source circuit simulator used for the SPICE checks in Lumenary EE.