Electromagnetic waves carry energy and momentum through their electric and magnetic fields. A field solver should therefore produce a ledger, not merely snapshots. If total energy in a closed ideal domain changes, investigate the numerical method. If a wave reaches an open boundary, record the outgoing flux as a transfer rather than calling it unexplained loss.
For a linear vacuum field, local electromagnetic energy density is
\[u=\frac{1}{2}\left(\varepsilon_0|\mathbf E|^2+\frac{|\mathbf B|^2}{\mu_0}\right)\]The Poynting vector gives energy-flow direction and power per area:
\[\mathbf S=\frac{1}{\mu_0}\mathbf E\times\mathbf B\]For the earlier plane-wave fixture with E along y and B along z, S points along +x. A swapped field direction or sign reverses S, so this is a stronger test than confirming that the two arrays have sine-shaped values.
For a finite grid, keep a discrete ledger:
\[U^{n+1}-U^n\approx W_{\mathrm{sources}}-F_{\mathrm{boundary}}\Delta t+R_{\mathrm{numerical}}\]U is the summed cell energy, Wsources is energy added by modeled sources, Fboundary is outward flux through the boundary, and Rnumerical is the residual to report—not a term to silently discard. In a source-free periodic domain, the expected boundary flux is zero, so total energy drift measures the numerical method. In an absorbing or open domain, a falling interior total can be correct only when outward flux accounts for it.
const energyDensity = 0.5 * (permittivity * dot(electric, electric) + dot(magnetic, magnetic) / permeability);
const poynting = scaleVector(cross(electric, magnetic), 1 / permeability);
const conservationResidual = nextStoredEnergy - storedEnergy - sourceWork + boundaryOutflow * timeStep;
The exact vector and grid conventions differ by dimension, but the contract stays the same. Use a source-free plane wave to check transport direction. Use a closed boundary to check drift. Use an open boundary to check that the ledger balances. Report all three alongside resolution and time-step data.
Prediction: In a source-free open domain, energy leaving through a measured boundary should reduce stored interior energy without appearing as numerical dissipation.
Imagine a wave packet approaching the right boundary. Predict the signs ofstoredEnergy change and boundaryOutflow. Then compare an open boundary with a wrapping boundary and explain which ledger term changes.EM-wave simulations need an energy ledger. Derive energy density and Poynting flux from the evolved fields, account for source work and boundary transfer, and make the remaining conservation residual visible as a numerical diagnostic.
Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.
\[\text{observable output} = f(\text{inputs},\,\text{state})\]For Energy and Momentum in EM Waves, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Maxwell’s Equations and EM Waves, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.
Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.
This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.
Treat Energy and Momentum in EM Waves as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.
Add local field-energy and boundary-flux diagnostics to electromagnetic wave solvers.