Skip to content

The Divergence Constraint

Source: PHY653B Ch. 5

Intuition

\(\nabla\cdot\mathbf{B} = 0\) is not an equation of motion — it is a constraint, satisfied for all time if it holds initially, because the induction equation preserves it analytically. The trouble is that discretely it does not. Truncation error accumulates a small \(\nabla\cdot\mathbf{B}\), and unlike most numerical errors this one does not merely reduce accuracy: it produces an unphysical force.

Why it is worse than an ordinary error

Write the Lorentz force using \(\nabla\cdot\mathbf{B}\) explicitly:

\[\mathbf{J}\times\mathbf{B} = \frac{(\mathbf{B}\cdot\nabla)\mathbf{B}}{\mu_0} - \nabla\!\left(\frac{B^2}{2\mu_0}\right) - \frac{\mathbf{B}\,(\nabla\cdot\mathbf{B})}{\mu_0}\]

The last term vanishes analytically. Discretely it does not, and it is a force parallel to \(\mathbf{B}\) — a direction in which the magnetic field should exert no force at all. Plasma gets accelerated along field lines by nothing, momentum conservation breaks, and in strongly magnetised regions the error can dominate the real dynamics. Magnetic monopoles, numerically realised, and behaving exactly as badly as you would expect.

Four cures

Approach Idea Cost
Constrained transport (CT) Store \(\mathbf{B}\) on faces, \(\mathbf{E}\) on edges; update by Stokes' theorem so \(\nabla\cdot\mathbf{B}\) is conserved to round-off Staggered grids; awkward with AMR
Divergence cleaning (Dedner) Add a scalar field that advects and damps divergence away Cheap, easy to retrofit; does not eliminate, only disperses and damps
Projection Solve a Poisson equation each step and subtract the gradient Exact; an elliptic solve per step is expensive
Powell / 8-wave Add source terms so the divergence error advects with the flow Simple; non-conservative, which can shift shock positions

Constrained transport is the gold standard. The insight is that if \(\mathbf{B}\) lives on cell faces and the electric field on cell edges, then the discrete curl of a discrete gradient is identically zero — the same reason \(\nabla\cdot\nabla\times = 0\) in the continuum. The constraint is preserved by the structure of the discretisation rather than by arithmetic accuracy. This is a general and beautiful idea (mimetic / structure-preserving discretisation) that recurs throughout computational electromagnetics, including FDTD.

What to monitor

Track a dimensionless divergence error every run:

\[\varepsilon_{\rm div} = \frac{\Delta x\,|\nabla\cdot\mathbf{B}|}{|\mathbf{B}|}\]

With CT it sits at round-off. With cleaning it should stay small and not grow. A rising \(\varepsilon_{\rm div}\) is an early warning that arrives well before the run visibly misbehaves — one of the most useful cheap diagnostics in MHD.

Common mistakes

  • Assuming a divergence-free initial condition is enough. It is, analytically. Discretely the error is generated afresh every step.
  • Cleaning and then not checking. Dedner damps divergence; it does not guarantee it is small.
  • Using a non-conservative fix on a shock problem. Powell's source terms can move shock positions — visible immediately in Brio–Wu.

Knowledge graph position

Prerequisites: Godunov MHD, Maxwell's equations, induction equation. Leads to: constrained transport, structure-preserving discretisation, production MHD codes.

Quiz

Q1 (conceptual). Why is a small \(\nabla\cdot\mathbf{B}\) error qualitatively worse than a comparable error in, say, density?

Answer

It produces a spurious force \(-\mathbf{B}(\nabla\cdot\mathbf{B})/\mu_0\) parallel to \(\mathbf{B}\) — a direction in which magnetic forces should be identically zero. It therefore creates dynamics that has no physical counterpart at all, rather than getting existing dynamics slightly wrong, and it breaks momentum conservation.

Q2 (conceptual). How does constrained transport preserve the constraint to round-off?

Answer

By staggering: \(\mathbf{B}\) on faces, \(\mathbf{E}\) on edges, updated via Stokes' theorem. The discrete divergence of a discrete curl is then identically zero as an algebraic identity — the constraint is built into the structure of the discretisation, not achieved by accuracy.

Q3 (MCQ). Dedner divergence cleaning works by:

  • (a) solving a Poisson equation each step
  • (b) introducing an auxiliary scalar that advects and damps the divergence error away
  • (c) staggering the fields onto faces and edges
  • (d) reducing the time step
Answer

(b). It is cheap and retrofits easily onto an existing solver, but it disperses and damps the error rather than eliminating it — so it still needs monitoring.