Line, Surface and Volume Integrals; the Divergence and Stokes Theorems
Engineers measure integrals, not fields at a point. A voltmeter reads the line integral of between its probes; a current probe reads the flux of through a wire's cross-section; a coulomb meter reads the volume integral of charge density. Maxwell's equations are usually stated first in integral form for exactly that reason. This lesson sets up the three kinds of integral and the two theorems that let you swap between the integral form (what you measure) and the point form (what solvers use). The maths is in Line Integrals, Surface Integrals, The Divergence Theorem and Stokes' Theorem.
Three integrals, three measurements
Line integral along a path : add up the component of a field along each small step .
The first is the work the field does on a charge moved from to , the second the voltage a voltmeter would read with its red probe at , the third the EMF around a closed loop. (Note the order: is the integral from to of , because points downhill.)
Surface integral over a surface : add up the component of a field through each small area . This is a flux: (coulombs), (amperes), (webers), (watts). On a closed surface points outward; on an open surface you choose it, and the choice fixes the direction around its edge.
Volume integral of a scalar: is the charge in a region, the stored energy.
The two theorems
The divergence theorem says that what flows out through a closed surface equals the total of what is produced inside it:
Stokes' theorem says that the circulation around a closed curve equals the flux of the curl through any surface that has as its edge, with traversed anticlockwise when seen from the side points to (right-hand rule):
They turn every Maxwell equation from one form into the other. Gauss's law becomes ; Ampère's law becomes (Maxwell's Equations in Integral and Differential Form).
Conservative fields. If everywhere in a region, Stokes' theorem gives for every loop, so the line integral from to does not depend on the path, and a potential exists. In a circuit, that is Kirchhoff's voltage law. When a changing magnetic flux threads the loop, the curl of is no longer zero and KVL fails by exactly the induced EMF (Faraday's and Lenz's Laws).
Worked example
Given: (a) (coordinates in metres) and the unit cube ; (b) and a circle of radius in the -plane.
Find: (a) the charge in the cube both ways; (b) the circulation of both ways, and what it means.
Solve:
Check: in (b) the curl is the current density, so this belongs to a uniform current density of along ; the circle encloses , as Ampère's law says. On the faces , , the outward normal is negative but the normal component of is zero there, so they add nothing.
In Python
SciPy integrates each side numerically. The last part integrates the electrostatic field of the previous lesson, , along two different paths between the same points.
import numpy as np
from scipy import integrate
# (a) divergence theorem for D = (xy, yz, zx) nC/m^2 on the unit cube
vol, _ = integrate.tplquad(lambda z, y, x: x + y + z, 0, 1, 0, 1, 0, 1)
face = lambda f: integrate.dblquad(f, 0, 1, 0, 1)[0]
flux = face(lambda z, y: 1*y) + face(lambda z, x: 1*z) + face(lambda y, x: x*1) # faces x=1, y=1, z=1
print(f"volume integral of div D = {vol:.4f} nC, flux out of the faces = {flux:.4f} nC")
# (b) Stokes for H = (-y, x, 0) A/m around a circle of radius 0.1 m
a = 0.1
circ, _ = integrate.quad(lambda p: (-a*np.sin(p))*(-a*np.sin(p)) + (a*np.cos(p))*(a*np.cos(p)), 0, 2*np.pi)
print(f"circulation = {circ*1e3:.2f} mA, curl flux = {2*np.pi*a**2*1e3:.2f} mA")
# path independence of a conservative field
def E(x, y, z):
return np.array([-100*x*y, -50*x**2, -20.0])
def line_integral(path, n=2001):
t = np.linspace(0, 1, n)
pts = np.array([path(s) for s in t])
dl = np.gradient(pts, t, axis=0)
f = np.array([E(*p) @ d for p, d in zip(pts, dl)])
return float(integrate.trapezoid(f, t))
straight = lambda s: np.array([s, -s, 2*s])
wiggly = lambda s: np.array([s**2, -np.sin(np.pi*s/2), 2*s + 0.5*np.sin(np.pi*s)])
V = lambda x, y, z: 50*x**2*y + 20*z
print(f"integral of E.dl: straight {line_integral(straight):.4f} V, wiggly {line_integral(wiggly):.4f} V")
print(f"V(start) - V(end) = {V(0, 0, 0) - V(1, -1, 2):.4f} V")volume integral of div D = 1.5000 nC, flux out of the faces = 1.5000 nC
circulation = 62.83 mA, curl flux = 62.83 mA
integral of E.dl: straight 10.0000 V, wiggly 10.0000 V
V(start) - V(end) = 10.0000 V
Guided lab: Kirchhoff's voltage law as a line integral
Hand calculation. A battery drives four resistors in series, , , and (total , current ). The drops are , , and . Going round the loop, the line integral of through the resistors () cancels the integral through the battery (), because a static field has no curl.
Simulation. Change one resistor in the netlist lab and watch the node voltages shift while the sum of the drops stays equal to the source.
What you would measure. With a multimeter, read each drop going round the loop in the same direction (black probe on the node you came from), and the battery. A -digit meter on the range reads to with about accuracy, so the five readings should add to zero within about . The sum is zero because the meter leads and the circuit enclose almost no changing magnetic flux. In a loop that does enclose changing flux the sum is not zero, and the "missing" volts are the EMF of Faraday's and Lenz's Laws.
Hazards and safe setup. A battery and resistors only; the largest resistor dissipates about .
Pitfalls
- The order in . , with no minus sign; the minus appears in .
- Normals on closed surfaces. Always outward. A flux "into" a surface counts negative.
- Orientation in Stokes. Reverse the direction around and you must reverse , or the sign flips.
- Path independence assumed where it fails. Only fields with zero curl over the whole region give a unique voltage between two points; with changing magnetic flux, the reading depends on where the leads run.
Practice
- Find the flux of through a disk of radius in the plane with , and through a closed cylinder of radius from to .
- Verify the divergence theorem for on a sphere of radius .
- For , find with at and at .
Answer
- Disk: . Closed cylinder: zero (what enters the bottom leaves the top; ).
- Surface: . Volume: , times gives .
- : is above .
Test yourself
The divergence theorem relates…
- a line integral to a surface integral
- the flux through a closed surface to the volume integral of the divergence inside
- the circulation around a curve to the flux of the curl
- a volume integral to a line integral
A field . The circulation around a circle of radius centred on the origin in the -plane (anticlockwise from ) is…
Why does Kirchhoff's voltage law hold in a DC circuit?
- because charge is conserved
- because the static electric field has zero curl, so its integral around any closed loop is zero
- because the wires have no resistance
- because the current is the same everywhere
is defined as . Which expression equals it?