Analytic and Meep correctness suite
Eight small 2D/3D problems checked against closed-form solutions, against Meep on an identical grid, and GPU-vs-CPU on an RTX 4090.
This page covers the PSFDTD correctness suite: a set of small canonical problems (point dipoles in vacuum, a waveguide bend, dielectric cylinders, a dielectric slab, a dispersive Lorentz slab, a dipole next to a sphere). Each problem is checked three ways: against an analytic solution where one exists, against a local Meep run on exactly the same grid, time step and source, and, for the CUDA backend, against the PSFDTD CPU backend. Every check carries a threshold that was written into the case definition, and the runner exits non-zero if any check fails.
Two baselines exist and they are kept separate below:
- Apple M3 Max (CPU, with Meep): 7 cases, 82/82 checks passed. This is the run that contains the Meep comparison columns.
- RTX 4090 (CUDA, no Meep): 8 cases, 82/82 checks passed, of which 46 are GPU-vs-CPU checks. Meep is not installed on that machine, so the Meep comparisons were not re-run there.
Setup
Method. Each case is described once (Meep units, a = 1 µm) and adapters generate both the PSFDTD scene and the Meep simulation. Grid, time step (Courant 0.5, dt = 0.5/res), number of steps, source waveform and time centering are identical in both solvers, so remaining differences come from genuine implementation differences (PML formulation, sub-pixel geometry quadrature) and not from discretization. Both FP64 and FP32 are run: FP64 to push implementation differences to the visible limit, FP32 because it is the default run precision.
Cases.
| Case | What it exercises | Compared against |
|---|---|---|
dipole2d_vacuum | 2D TM Yee update, CPML, point-source normalization, time centering | Meep time traces sample by sample; 2D Green's function ratio |H0(k r2)/H0(k r1)| between r=2 and r=4 |
dipole3d_vacuum | 3D Yee update, six-plane flux box, DFT normalization | Meep time traces and flux spectrum; Larmor formula F(ω) = ω² |J(ω)|² / 6π |
wgbend2d | ε=12 waveguide of width 1, line source, 100-frequency flux spectra, 90° bend (Meep tutorial) | Meep transmission and raw flux spectra |
cylinder2d_tm | Curved interface, sub-pixel smoothing (diagonal tensor terms); cylinder r=1.13, ε=6.25 | Meep time traces, flux, point DFT |
cylinder2d_te | Same cylinder, TE: also exercises the off-diagonal tensor terms | Meep time traces, flux, point DFT |
slab3d_fresnel | 3D periodic x/y, PML z, plane source, n=1.5, d=1 slab; uniform 30/µm, coarse uniform 12/µm, and an automatic non-uniform grid (12/µm in vacuum, 30/µm in the slab) | Meep; analytic Fabry-Perot transmission |
lorentz_slab3d | Dispersive (lossy Lorentz) ADE: ε∞=2.25 plus one pole (f0=1.5, γ=0.05, σ=1) | Analytic complex-index Fabry-Perot at 60 cells/µm with default smoothing |
sphere3d_dipole | 3D sub-pixel smoothing with the full anisotropic tensor: Ez dipole 0.4 µm above an ε=4, r=0.55 sphere | Meep flux spectrum and time traces |
Hardware and software.
| Baseline | Machine | Meep |
|---|---|---|
| M3 Max | Apple M3 Max, 16 cores, Darwin 25.6.0 (arm64); run dated 2026-09-27 | 1.33.0-beta (serial: conda-forge nompi; MPI: conda-forge mpich) |
| RTX 4090 | AMD Ryzen 9 9950X 16-Core, 32 cores, Windows 11; GPU cuda:0 NVIDIA GeForce RTX 4090; run dated 2026-09-29 | none |
Results
All values are errors (lower is better).
Agreement with Meep and analytic solutions (Apple M3 Max, CPU)
| Case | Checks passed | Agreement with Meep (range over checks) | Analytic check |
|---|---|---|---|
dipole2d_vacuum | 16/16 | 3.3e-06 .. 2.5e-05 | 1.7e-05, 1.8e-05, 1.4e-05 |
dipole3d_vacuum | 12/12 | 2.8e-08 .. 7.3e-04 | 1.2e-02 |
wgbend2d | 8/8 | 5.8e-04 .. 5.7e-03 | - |
cylinder2d_tm | 14/14 | 2.7e-04 .. 4.0e-03 | - |
cylinder2d_te | 14/14 | 4.8e-04 .. 3.9e-03 | - |
slab3d_fresnel | 10/10 | 2.2e-06 .. 4.7e-06 | 3.6e-03, 7.1e-03 |
sphere3d_dipole | 8/8 | 1.3e-05 .. 1.2e-02 | - |
Selected individual checks from the same run (PSFDTD double / single precision, with the threshold):
| Case | Check | vs | FP64 | FP32 | Threshold |
|---|---|---|---|---|---|
dipole2d_vacuum | r4 time trace rel-L2 | Meep | 2.50e-05 | 2.50e-05 | 1e-03 |
dipole2d_vacuum | |E(r=4)/E(r=2)| vs Hankel at f=1.0 | analytic | 1.76e-05 | 1.76e-05 | 1e-02 |
dipole3d_vacuum | total flux spectrum max rel. diff | Meep | 7.30e-04 | 7.30e-04 | 1e-03 |
dipole3d_vacuum | flux vs Larmor (0.7 ≤ f ≤ 1.3) max rel. | analytic | 1.21e-02 | 1.21e-02 | 3e-02 |
wgbend2d | bend transmission max |dT| | Meep | 4.19e-03 | 4.19e-03 | 2e-02 |
cylinder2d_tm | tran flux max rel. diff | Meep | 3.98e-03 | 3.98e-03 | 6e-03 |
cylinder2d_te | point DFT max rel. diff | Meep | 3.89e-03 | 3.89e-03 | 6e-03 |
slab3d_fresnel | transmission vs Meep max |dT| | Meep | 2.19e-06 | 3.97e-06 | 2e-03 |
slab3d_fresnel | uniform 30/µm: max |T - T_FP| | analytic | 3.56e-03 | 3.56e-03 | 1e-02 |
sphere3d_dipole | total flux spectrum max rel. diff | Meep | 3.00e-03 | 3.00e-03 | 6e-03 |
sphere3d_dipole | below time trace rel-L2 | Meep | 1.19e-02 | 1.19e-02 | 2e-02 |

dipole3d_vacuum on the M3 Max: total flux through the enclosing box compared with Meep and with the Larmor formula.

wgbend2d on the M3 Max: bend transmission spectrum, PSFDTD against Meep (max |dT| 4.19e-03).

cylinder2d_te on the M3 Max: transmitted and reflected flux for the curved-interface case that exercises the off-diagonal smoothing terms.

sphere3d_dipole on the M3 Max: flux spectrum for a curved 3D interface, PSFDTD against Meep (max relative difference 3.00e-03).
GPU backend (RTX 4090, CUDA)
The CPU backend is the reference validated above. On the RTX 4090 the same physics cases are re-run on cuda:0; analytic checks are evaluated as usual and GPU-vs-CPU checks are added (probe-trace rel-L2, flux spectra, point DFT values). GPU-vs-CPU thresholds are 1e-09 (FP64) and 1e-04 (FP32).
| Case | Checks passed | Analytic check | Largest GPU-vs-CPU difference (FP64 / FP32) |
|---|---|---|---|
dipole2d_vacuum | 14/14 | 1.7e-05, 1.8e-05, 1.4e-05 | 1.5e-15 / 1.2e-06 |
dipole3d_vacuum | 8/8 | 1.2e-02 | 5.8e-15 / 4.1e-06 |
wgbend2d | 8/8 | - | 1.2e-15 / 2.2e-07 |
cylinder2d_tm | 6/6 | - | 2.0e-15 / 9.8e-07 |
cylinder2d_te | 6/6 | - | 6.5e-16 / 3.7e-07 |
slab3d_fresnel | 24/24 | 3.6e-03, 9.7e-03 | 4.7e-15 / 1.1e-07 |
lorentz_slab3d | 12/12 | 7.1e-03 | 1.6e-14 / 5.1e-07 |
sphere3d_dipole | 4/4 | - | 6.0e-15 / 3.7e-06 |
Across all cases the largest GPU-vs-CPU difference is 1.6e-14 in FP64 and 4.1e-06 in FP32.

slab3d_fresnel on the RTX 4090: transmission against the analytic Fabry-Perot formula for the fine uniform, coarse uniform and non-uniform grids.

lorentz_slab3d on the RTX 4090: transmission of the dispersive slab against complex-index Fabry-Perot (max |T - T_FP| 7.14e-03).
The GPU backend is additionally compared with the CPU backend at lower levels (RTX 4090):
| Level | Content | Threshold | Measured |
|---|---|---|---|
| Operators | 10 operators × FP32/FP64 × 3D/TM/TE, odd sizes, asymmetric CPML, DFT boxes wrapping a periodic boundary, random sparse terms; all mutable arrays compared | FP64 1e-12, FP32 2e-6 (relative to array maximum) | FP64 ≤ 3e-16, FP32 ≤ 1.5e-7 |
| Time loop | 20 consecutive steps in engine order | 10× the single-operator threshold | FP64 ≤ 3e-15, FP32 ≤ 1.7e-6 |
| End to end | 2D TM/TE dielectric cylinder, 3D dielectric sphere + Lorentz block + dipole, CPML on all sides | FP64 1e-12, FP32 2e-5 | FP64 ≤ 3e-15, FP32 ≤ 1.3e-6 |
Comparison
- Against Meep 1.33.0-beta (local runs, Apple M3 Max, same grid and time step). Vacuum cases agree to about 1e-5 in the time traces (3.3e-06 to 2.5e-05 in 2D; 2.8e-08 at the source point in 3D). Cases with curved dielectric interfaces agree at the 1e-3 level (2.7e-04 to 4.0e-03 for the cylinders, up to 1.2e-02 for a time trace below the sphere). The slab transmission agrees with Meep to 2.19e-06.
- Against analytic solutions. 2D Green's function ratio: 1.4e-05 to 1.8e-05. Larmor radiated power: 1.21e-02 (threshold 3e-02). Fabry-Perot transmission on the uniform 30/µm grid: 3.56e-03. Lorentz slab against complex-index Fabry-Perot: 7.14e-03.
- GPU against CPU (RTX 4090). Differences are at rounding level: FP64 ≤ 1.6e-14, FP32 ≤ 4.1e-06. In FP64 the analytic errors on the GPU are identical to the CPU values to the printed digits.
The remaining differences from Meep have identified causes:
- PML formulation. Meep uses a UPML-style stretched-coordinate PML with D/B auxiliary fields; PSFDTD uses CFS-CPML. Late reflections differ at the 1e-5 level, which is the source of the roughly 1e-5 differences in the vacuum cases.
- Sub-pixel quadrature. Meep uses adaptive cubature on the exact geometry with analytic normals; PSFDTD uses a planar signed-distance approximation and falls back to supersampling at edges and corners. For the ε=6.25 cylinder the final fields differ at the 1e-3 level.
Limitations
- Meep was not run on the RTX 4090 machine. The Meep columns exist only for the M3 Max CPU run. The claim that the GPU backend agrees with Meep is indirect: GPU matches CPU to rounding, and CPU matches Meep as tabulated above.
lorentz_slab3dhas no Meep comparison in either baseline report. It is absent from the M3 Max baseline (7 cases) and the RTX 4090 run has no Meep. Only the analytic check (7.14e-03) is backed by a baseline report on this page.- The non-uniform-grid slab error differs between the two baselines. The non-uniform grid gives max |T - T_FP| = 7.07e-03 in the M3 Max report (ratio to the coarse-uniform error 2.87e-01) and 9.75e-03 in the RTX 4090 report (ratio 3.95e-01), on both the CPU and the GPU columns of that report. The two runs were made on different dates, so this is a difference between runs and not a CPU/GPU difference. The 9.75e-03 value is close to the 1e-02 threshold. The coarse uniform 12/µm grid gives 0.0247 in both.
- Sources inside the PML are not comparable with Meep. When a current is injected inside the PML the two solvers radiate different fields (measured 4% to 27%), so the suite ends line sources at the PML interface.
- The Larmor check is the loosest analytic check (1.21e-02 against a 3e-02 threshold).
- Both baseline reports record the commit as
uncommitted.
Reproduce
# all cases, FP64 + FP32, with Meep comparison (requires a local Meep)
python -m bench.run correctness
# a single case / precision
python -m bench.run correctness --cases wgbend2d --precision single
# GPU run without Meep: analytic checks plus GPU-vs-CPU checks
python -m bench.run correctness --no-meep --gpu cuda:0
# operator-level and end-to-end GPU-vs-CPU tests
cargo test --release -p psfdtd-kernels --features cuda --test backend_equivalence
cargo test --release -p psfdtd-core --features psfdtd-kernels/cuda --test gpu_backendSee also the Meep test suite port and GPU performance.
Liu & Poon six-device suite
The six silicon-photonics devices of Liu & Poon (arXiv:2506.16665) re-simulated in 3D with PSFDTD on one RTX 4090 and compared with the Tidy3D and Lumerical results reported in the paper.
Meep test suite ported to PSFDTD
18 of Meep's own end-to-end tests rewritten for PSFDTD and judged with Meep's reference values and error metrics; 16 of 18 pass.