Maxwell on a Yee grid#
FDTD replaces spatial curls with finite differences and advances electric and magnetic fields in a leapfrog sequence. For linear media, the continuous equations are
with constitutive relations \(\mathbf D=\boldsymbol\varepsilon\mathbf E\) and \(\mathbf B=\boldsymbol\mu\mathbf H\). FDTDX stores the three vector components on offset locations in each cell so a discrete curl naturally connects neighboring samples.
Electric components live on edges; magnetic components occupy complementary staggered locations. Material values are mapped onto the corresponding component locations.#
Leapfrog update#
Ignoring conductivity and PML terms for the moment, one time step is conceptually
FDTDX represents inverse material tensors because those are applied directly in the update. Conductivity, dispersive-pole state, and PML auxiliary fields add local terms but preserve the same rhythm.
Stability is necessary, not sufficient#
For a uniform 3D grid, a familiar Courant bound is
Staying below it prevents the ordinary Yee scheme from diverging. It does not guarantee accuracy: numerical phase velocity depends on direction and cells per wavelength. Interfaces introduce staircasing error, and resonances demand enough runtime to resolve narrow spectral structure.
Why FDTD suits JAX#
Each time step is a regular stencil over dense arrays. JAX compiles that array program for GPU, CPU, or TPU; lax.scan/loop constructs avoid Python overhead; and the same program participates in automatic differentiation. Static shapes are important: changing a grid dimension causes recompilation.
Precision and scaling#
Most benchmarks use float32, which is efficient on consumer GPUs and accurate enough when discretization error dominates. Use nondimensional diagnostics—relative energy decay, normalized mode power, \(R+T\), convergence with resolution—rather than judging raw array magnitudes alone.