Skip to content

Numerical methods ​

PRISM discretizes the equations of the physical models by the method of lines: a spatial operator gives the residual dq/dt=R(q) at every cell, and a Runge–Kutta scheme advances it. The spatial scheme is [numerics] scheme_space (input).

Space discretization ​

Centred finite differences (fd_centered) ​

The state lives at the cell centres. Every derivative is the centred first derivative of order 2s, $s = $ [fdv] fdv_order/2 (orders 2, 4, 6, 8, 10):

∂q∂x|i≈1Δx∑m=1sam(s)(qi+m−qi−m),

with a(1)=12, a(2)=(8,−1)/12, a(3)=(45,−9,1)/60, a(4)=(672,−168,32,−3)/840 (FD1_CC, adam_fdv_operators_library). The residual is evaluated directly from the curls:

RD=∇h×Bμ0−J,RB=−∇h×Dε0,

plus, with GLM cleaning, −∇hφ, −∇hψ and the scalars' residuals −ch2(∇h⋅D−ρ)−αφ, −ch2∇h⋅B−αψ. ngc >= s is checked at initialization.

The discrete curl and divergence ​

The curl, the divergence and the gradient are all built from the same one-dimensional stencil, so on a uniform grid the discrete operators commute exactly as their continuous counterparts:

∇h⋅(∇h×F)≡0.

Hence ∂t(∇h⋅B)=−∇h⋅∇h×(D/ε0)=0: a field that starts divergence-free stays so to round-off, with no cleaning (a mimetic identity of the centred operators). The same holds for ∇h⋅D with a divergence-free J. The identity fails across a 2:1 AMR face (hazards).

Centred finite volumes (fv_centered) ​

The fluxes Fd(q) are evaluated at the cell centres (ghosts included), reconstructed at the faces by the centred FV reconstruction of order 2s, and differenced:

Rv=−∑dFv,i+1/2d−Fv,i−1/2dΔxd+Sv.

On a uniform grid the centred FV derivative reduces to the FD stencil. The FV path carries the face fluxes, so its 2:1 faces are refluxed (#38). The coils' current density is stamped with the operator of the chosen family ([fdv] fdv_scheme), so an FV run evolves an FV-built source.

WENO flux splitting (weno, CPU only) ​

A global Lax–Friedrichs splitting in characteristic (reconstruction_variables = characteristics) or conservative variables: with the left eigenvectors L of the Maxwell system, w=Lq, g=LF,

f±=12(g±λmaxw),λmax=max(1,χ)c0,

each split flux is reconstructed at the faces by SETH's upwind WENO-JS kernel of the width [weno] scheme names (seth_weno<2S-1>_js, with SETH's descaler for weights = si; one kernel per width, compiled with S a constant, #139 S5, the same results as ADAM's former kernel bit for bit), projected back with the right eigenvectors, and differenced. ngc >= [weno] S is checked. The centred names weno-c-* stop at initialization (they used to run the upwind kernel at that S under a centred name). The FNL backend refuses weno.

Time integration ​

[numerics] scheme_time = runge_kutta is the only scheme that runs; leapfrog, blanes_moan and commutator_free_magnus are refused at initialization on both backends (#55). The Runge–Kutta scheme is [runge_kutta] scheme (library reference):

SchemeCPUFNL
SSP 11, 22, 33, 54yesyes
low-storage 1, 2, 3yesyes
Yoshida (4-stage symplectic)yes (EM)refused

PIC runs, the PML, the charge-conserving current and the staged path (2:1 faces, forests) need an SSP scheme (PIC: any runge-kutta-ssp-*; PIC itself runs on the fused path only, see PIC). At every stage the coils' current is evaluated at the stage time t+csΔt (the stepper's stage_time(s), the tableau's abscissa).

The integrator is SELAH's, on both backends, through the library adapter adam_stepper_object (#132 phase 4): the SSP schemes in the Butcher form (every stage on the stepper's own state register), the low-storage ones in the two-register form (every stage on q), Yoshida as SELAH's yoshida-4 splitting of the partitions B (advanced first) and D, seven sub-flows, a residual each, interior cells. The coefficients are ADAM's former ones, bit for bit, except Yoshida's (SELAH's triple-jump weights, exact to the last bit; ADAM's were 16-digit literals). The PML auxiliary fields and the PIC particles keep their own stage storage, advanced in step with the same tableau. On the CPU the SSP update sums the stages in the FNL order, so CPU runs moved at round-off.

Time step. Δt=CFL(Δxmin/2)/λmax, with Δxmin the smallest cell size over every block and rank and λmax=max(1,χ)c0: both backends halve the smallest cell size before dividing (at CFL 0.5, Δt=Δxmin/(4c0)). The step is capped by 1/α (GLM damping) and by Cγ/γmax (the PML). [time] it_max > 0 runs that many steps; otherwise the run ends at time_max, the last step shortened to reach it.

Plasma-frequency cap (PIC models). With ΔtCFL the step above and ωmax the highest plasma characteristic frequency of the previous step (or t0), the step stays ΔtCFL while ωmaxΔtCFL< [PIC] omega_dt_max (default 0.05). Otherwise Δt=min(omega_dt_max/ωmax, (ΔtCFL−2+ωmax2/βI2)−1/2), with βI the imaginary-axis stability bound of the Runge–Kutta scheme (3.278 for SSP-54, 3 for SSP-33). ωmax is the R cutoff, which bounds ωUH, ωpe and Ωce, from the global maxima of ωp (per cell, NGP) and of the cyclotron frequency at the particles. Every step prints the step source (CFL or plasma_frequencies). A step in which a particle crosses more than one cell (max|vd|Δt/Δxd>1) stops the run.

Adaptive mesh refinement ​

The grid is the library's octree or quadtree of Cartesian blocks (concepts). PRISM refines at initialization only: [initial_conditions] amr_iterations passes each set the initial condition and run the markers of [amr_marker_N]:

  • mode 1 primitive-box: refine the blocks inside a box to target_level;
  • mode 3 (AMR_TV): refine on the total variation of the coils' current density.

The other markers do nothing in PRISM (input). [amr] frequency is read and unused: there is no runtime regrid.

At a 2:1 face the coarse ghosts are restricted from the fine cells and the fine ghosts interpolated from the coarse ones (the library's seam machinery, octrees and quadtrees, #46); the stages then run on the staged path of the forest, which needs an SSP scheme.

Across a 2:1 face the centred operators no longer commute, and the seam injects a ∇⋅B source that converges under refinement and does not decay at fixed h: its measurements, the [IO] seam_divB_tol monitor and the mitigation are in the hazards.

Multi-realm runs ​

A forest manifest glues several PRISM realms through seams. Both backends implement the realm contract of the forest, fast and staged paths and the seam exchange. A seam fills its ghosts once per step (coupling_cadence = end_of_step, α, the default) or at every Runge–Kutta stage (stage_coincident, β). Under α every stage reads the peer state of the step's fill: each stage state takes the seam ghosts of q when it opens (#116, #132 rule 1; before, PRISM's stages read stale seam ghosts). A 1:1 same-resolution seam needs β to stay divergence-free (hazards). The divergence diagnostic refills the inter-realm seam on the committed state before it measures. Worked cases: src/tests/prism/regression/rmf-2realm*/; the cadences are explained on the forest page.

t0 elliptic solves ​

When the initial state has a charge or a current, PRISM solves for the fields they generate before the first step (impose_pic_fields_time_zero), with FLAIL, the library's elliptic solver (#84):

  • Electric field (PIC models, [PIC] electric_field_elliptic_initialization, default on): D(G)φ=−ρ/ε0, then D←D−ε0Gφ.
  • Magnetic field (when J≠0 at t0: PIC currents, or coils with time_delay <= 0; under PIC also magnetic_field_elliptic_initialization): D(G)Ad=−μ0Jd per component, then B←B+∇h×A.

D(G) is PRISM's own operator, the centred first derivative of order fdv_order composed with itself on each axis, so the corrected field satisfies ∇h⋅D=ρ to round-off with PRISM's own divergence. Every centred first derivative annihilates the checkerboard mode, so this wide operator has a second null branch at θ=π, which the solver drops exactly. The face kinds come from the boundary map:

  • periodic and PEC faces: a direct FFT solve (FFTW on the CPU, cuFFT on FNL);
  • zero-ghost (Dirichlet) faces: a preconditioned CG on rank 0, to 10−12;
  • exact/open faces (Neumann, Silver–Müller): the free-space potential of the whole source in the ghosts, then the same CG.

On a singular problem (no Dirichlet face) the mean of the forcing is removed per component; for A that mean is the uniform current, which by periodicity carries no magnetostatic field. A refined grid is refused at the solve (the wide operator across a 2:1 face is not defined), and so is fdv_order = 10 (FLAIL accepts 2 to 8).

Mean fields between PEC walls ([PIC] elliptic_initialization_closure). With one axis n closed by PEC faces and the others periodic (or null), the transverse mean (k⊥=0) of the fields is a 1-D problem, and the PEC cavity leaves two of its invariants free: the potential difference between the walls, ⟨Dn⟩, and the trapped magnetic flux, ⟨Bt⟩. The solves set both to zero (grounded, the default). isolated sets them to the values of the same sources in open space along n, where the 1-D field is half the difference of the source integrated from either side:

⟨Dn⟩=−1V∑ρ(xn−xmid)dV,⟨Bt⟩=μ0n^×1V∑J(xn−xmid)dV,

with xmid the domain centre and V its volume (a net charge or current included). The mean of the field the solve adds is shifted to these values; the initial-condition field keeps its own mean. A uniform field has no divergence nor curl and is even about a PEC face for Dn and Bt, as PRISM's PEC ghosts reflect them, so the boundary cells stay consistent with the evolution exactly as under grounded. Only the mean mode is open: the modes k⊥≠0 keep their images in the walls, off open space by about e−k⊥d at a distance d from the sources, so the walls must be far from them for the whole field to match open space. An exact/open face (Neumann, Silver–Müller) is not the same closure: its ghosts hold the free-space potential of the sources alone, without their periodic images, and do not match the hyperbolic ghosts of that face.