TExcelTAD
Home › Electromagnetic Theory: Maxwell's Equations to Waves › Line, Surface and Volume Integrals; the Divergence and Stokes Theorems

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 E\mathbf{E} between its probes; a current probe reads the flux of J\mathbf{J} 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 LL: add up the component of a field along each small step dld\mathbf{l}.

W=Q∫ABE⋅dl,VAB=VA−VB=∫ABE⋅dl,E=∮LE⋅dlW = Q\int_A^B \mathbf{E} \cdot d\mathbf{l}, \qquad V_{AB} = V_A - V_B = \int_A^B \mathbf{E} \cdot d\mathbf{l}, \qquad \mathcal{E} = \oint_L \mathbf{E} \cdot d\mathbf{l}

The first is the work the field does on a charge QQ moved from AA to BB, the second the voltage a voltmeter would read with its red probe at AA, the third the EMF around a closed loop. (Note the order: VAB=VA−VBV_{AB} = V_A - V_B is the integral from AA to BB of E\mathbf{E}, because E\mathbf{E} points downhill.)

Surface integral over a surface SS: add up the component of a field through each small area dS=n^ dSd\mathbf{S} = \hat{\mathbf{n}}\,dS. This is a flux: Ψ=∫SD⋅dS\Psi = \int_S \mathbf{D} \cdot d\mathbf{S} (coulombs), I=∫SJ⋅dSI = \int_S \mathbf{J} \cdot d\mathbf{S} (amperes), Φ=∫SB⋅dS\Phi = \int_S \mathbf{B} \cdot d\mathbf{S} (webers), P=∫S(E×H)⋅dSP = \int_S (\mathbf{E} \times \mathbf{H}) \cdot d\mathbf{S} (watts). On a closed surface n^\hat{\mathbf{n}} points outward; on an open surface you choose it, and the choice fixes the direction around its edge.

Volume integral of a scalar: Q=∫vρv dvQ = \int_v \rho_v\,dv is the charge in a region, WE=∫v12εE2 dvW_E = \int_v \frac{1}{2}\varepsilon E^2\,dv the stored energy.

The two theorems

volume v div D = rho_v dS closed S: flux out = integral of div D dv C dS (right-hand rule) S open S, edge C: circulation = flux of curl

The divergence theorem says that what flows out through a closed surface equals the total of what is produced inside it:

∮SA⋅dS=∫v∇⋅A dv\oint_S \mathbf{A} \cdot d\mathbf{S} = \int_v \nabla \cdot \mathbf{A}\,dv

Stokes' theorem says that the circulation around a closed curve CC equals the flux of the curl through any surface SS that has CC as its edge, with CC traversed anticlockwise when seen from the side dSd\mathbf{S} points to (right-hand rule):

∮CA⋅dl=∫S(∇×A)⋅dS\oint_C \mathbf{A} \cdot d\mathbf{l} = \int_S (\nabla \times \mathbf{A}) \cdot d\mathbf{S}

They turn every Maxwell equation from one form into the other. Gauss's law ∮D⋅dS=Qenc\oint \mathbf{D} \cdot d\mathbf{S} = Q_\text{enc} becomes ∇⋅D=ρv\nabla \cdot \mathbf{D} = \rho_v; Ampère's law ∮H⋅dl=Ienc\oint \mathbf{H} \cdot d\mathbf{l} = I_\text{enc} becomes ∇×H=J\nabla \times \mathbf{H} = \mathbf{J} (Maxwell's Equations in Integral and Differential Form).

Conservative fields. If ∇×E=0\nabla \times \mathbf{E} = 0 everywhere in a region, Stokes' theorem gives ∮E⋅dl=0\oint \mathbf{E} \cdot d\mathbf{l} = 0 for every loop, so the line integral from AA to BB does not depend on the path, and a potential VV exists. In a circuit, that is Kirchhoff's voltage law. When a changing magnetic flux threads the loop, the curl of E\mathbf{E} is no longer zero and KVL fails by exactly the induced EMF (Faraday's and Lenz's Laws).

Worked example

Given: (a) D=xy x^+yz y^+zx z^ nC/m2\mathbf{D} = xy\,\hat{\mathbf{x}} + yz\,\hat{\mathbf{y}} + zx\,\hat{\mathbf{z}}\ \text{nC/m}^2 (coordinates in metres) and the unit cube 0≤x,y,z≤1 m0 \le x, y, z \le 1\ \text{m}; (b) H=−y x^+x y^ A/m\mathbf{H} = -y\,\hat{\mathbf{x}} + x\,\hat{\mathbf{y}}\ \text{A/m} and a circle of radius a=0.1 ma = 0.1\ \text{m} in the xyxy-plane.

Find: (a) the charge in the cube both ways; (b) the circulation of H\mathbf{H} both ways, and what it means.

Solve:

(a)∇⋅D=y+z+x,∫v(x+y+z) dv=3⋅12=1.5 nCfaces:x=1:∫01 ⁣ ⁣∫01y dy dz=0.5;x=0:Dx=0;same for y,z  ⇒  3⋅0.5=1.5 nC(b)∇×H=(1+1)z^=2z^ A/m2,∫S2 dS=2πa2=0.0628 A∮H⋅dl=∫02π(a2sin⁡2ϕ+a2cos⁡2ϕ) dϕ=2πa2=0.0628 A\begin{aligned} \text{(a)}\quad \nabla \cdot \mathbf{D} &= y + z + x, \qquad \int_v (x + y + z)\,dv = 3 \cdot \tfrac{1}{2} = 1.5\ \text{nC} \\ \text{faces:}\quad &x = 1: \int_0^1\!\!\int_0^1 y\,dy\,dz = 0.5; \quad x = 0: D_x = 0; \quad \text{same for } y, z \;\Rightarrow\; 3 \cdot 0.5 = 1.5\ \text{nC} \\ \text{(b)}\quad \nabla \times \mathbf{H} &= (1 + 1)\hat{\mathbf{z}} = 2\hat{\mathbf{z}}\ \text{A/m}^2, \qquad \int_S 2\,dS = 2\pi a^2 = 0.0628\ \text{A} \\ \oint \mathbf{H} \cdot d\mathbf{l} &= \int_0^{2\pi} (a^2\sin^2\phi + a^2\cos^2\phi)\,d\phi = 2\pi a^2 = 0.0628\ \text{A} \end{aligned}

Check: in (b) the curl is the current density, so this H\mathbf{H} belongs to a uniform current density of 2 A/m22\ \text{A/m}^2 along zz; the circle encloses 62.8 mA62.8\ \text{mA}, as Ampère's law says. On the faces x=0x = 0, y=0y = 0, z=0z = 0 the outward normal is negative but the normal component of D\mathbf{D} 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, E=−∇(50x2y+20z)\mathbf{E} = -\nabla(50x^2y + 20z), along two different paths between the same points.

python · try it yourself
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 9 V9\ \text{V} battery drives four resistors in series, 1 kΩ1\ \text{k}\Omega, 2.2 kΩ2.2\ \text{k}\Omega, 3.3 kΩ3.3\ \text{k}\Omega and 4.7 kΩ4.7\ \text{k}\Omega (total 11.2 kΩ11.2\ \text{k}\Omega, current 0.804 mA0.804\ \text{mA}). The drops are 0.8040.804, 1.7681.768, 2.6522.652 and 3.777 V3.777\ \text{V}. Going round the loop, the line integral of E\mathbf{E} through the resistors (+9 V+9\ \text{V}) cancels the integral through the battery (−9 V-9\ \text{V}), 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.

node voltages (to ground 0)a9.000 Vb8.196 Vc6.429 Vd3.777 VnetlistV1 a 0 9R1 a b 1kR2 b c 2.2kR3 c d 3.3kR4 d 0 4.7kelement currents (node 1 to node 2 through it)V1a>0-804 uAR1a>b804 uAR2b>c804 uAR3c>d804 uAR4d>0804 uA

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 3123\tfrac{1}{2}-digit meter on the 20 V20\ \text{V} range reads to 10 mV10\ \text{mV} with about ±0.5 %\pm 0.5\ \% accuracy, so the five readings should add to zero within about ±0.05 V\pm 0.05\ \text{V}. 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 9 V9\ \text{V} battery and resistors only; the largest resistor dissipates about 3 mW3\ \text{mW}.

Pitfalls

  • The order in VABV_{AB}. VA−VB=∫ABE⋅dlV_A - V_B = \int_A^B \mathbf{E} \cdot d\mathbf{l}, with no minus sign; the minus appears in VB−VA=−∫ABE⋅dlV_B - V_A = -\int_A^B \mathbf{E} \cdot d\mathbf{l}.
  • Normals on closed surfaces. Always outward. A flux "into" a surface counts negative.
  • Orientation in Stokes. Reverse the direction around CC and you must reverse dSd\mathbf{S}, 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

  1. Find the flux of D=5z^ nC/m2\mathbf{D} = 5\hat{\mathbf{z}}\ \text{nC/m}^2 through a disk of radius 2 m2\ \text{m} in the plane z=0z = 0 with n^=z^\hat{\mathbf{n}} = \hat{\mathbf{z}}, and through a closed cylinder of radius 2 m2\ \text{m} from z=0z = 0 to z=1 mz = 1\ \text{m}.
  2. Verify the divergence theorem for A=r r^\mathbf{A} = r\,\hat{\mathbf{r}} on a sphere of radius RR.
  3. For E=2x x^ V/m\mathbf{E} = 2x\,\hat{\mathbf{x}}\ \text{V/m}, find VABV_{AB} with AA at x=0x = 0 and BB at x=3 mx = 3\ \text{m}.
Answer
  1. Disk: 5⋅π⋅22=62.8 nC5 \cdot \pi \cdot 2^2 = 62.8\ \text{nC}. Closed cylinder: zero (what enters the bottom leaves the top; ∇⋅D=0\nabla \cdot \mathbf{D} = 0).
  2. Surface: R⋅4πR2=4πR3R \cdot 4\pi R^2 = 4\pi R^3. Volume: ∇⋅A=1r2ddr(r3)=3\nabla \cdot \mathbf{A} = \frac{1}{r^2}\frac{d}{dr}(r^3) = 3, times 43πR3\frac{4}{3}\pi R^3 gives 4πR34\pi R^3.
  3. VAB=∫032x dx=9 VV_{AB} = \int_0^3 2x\,dx = 9\ \text{V}: AA is 9 V9\ \text{V} above BB.

Test yourself

The divergence theorem relates…

  1. a line integral to a surface integral
  2. the flux through a closed surface to the volume integral of the divergence inside
  3. the circulation around a curve to the flux of the curl
  4. a volume integral to a line integral

A field H=−yx^+xy^ A/m\mathbf{H} = -y\hat{\mathbf{x}} + x\hat{\mathbf{y}}\ \text{A/m}. The circulation around a circle of radius 0.1 m0.1\ \text{m} centred on the origin in the xyxy-plane (anticlockwise from +z+z) is…

  1. 00
  2. 31.4 mA31.4\ \text{mA}
  3. 62.8 mA62.8\ \text{mA}
  4. 0.628 A0.628\ \text{A}

Why does Kirchhoff's voltage law hold in a DC circuit?

  1. because charge is conserved
  2. because the static electric field has zero curl, so its integral around any closed loop is zero
  3. because the wires have no resistance
  4. because the current is the same everywhere

VABV_{AB} is defined as VA−VBV_A - V_B. Which expression equals it?

  1. ∫ABE⋅dl\int_A^B \mathbf{E} \cdot d\mathbf{l}
  2. −∫ABE⋅dl-\int_A^B \mathbf{E} \cdot d\mathbf{l}
  3. ∫BAE⋅dl\int_B^A \mathbf{E} \cdot d\mathbf{l}
  4. ∮E⋅dl\oint \mathbf{E} \cdot d\mathbf{l}