Experimental¶
Hybrid SSA–SPDE scaffold
The SSA half-steps call Python. Each hybrid step returns to the host and the full time loop cannot be JIT-compiled. The spectral substep can be compiled separately.
This scaffold composes compartment updates with a spectral PDE step. For exact reaction and diffusion substeps within Allen–Cahn, select the Allen–Cahn splitting scheme.
exponax_spde.strang_split_step ¶
strang_split_step(
spectral_stepper: Module,
ssa_step_fn: Callable,
u: Float[Array, "1 * N"],
ssa_state: dict,
dt: float,
key: PRNGKeyArray,
*,
domain_extent: float | None = None,
num_points: int,
mollifier_cutoff: float = 0.5
) -> tuple[Float[Array, "1 * N"], dict]
One Strang-split hybrid spectral / SSA step.
Implements the pattern: half-SSA(Δt/2) → full-spectral(Δt) → half-SSA(Δt/2), which is second-order accurate in Δt for operator splitting (Strang, 1968).
The SSA half-steps call Python on the host, so the split time loop cannot be JIT-compiled. On accelerators each split step round-trips to the host for SSA and sends the resulting increments to the device. The spectral step can be compiled separately.
This SSA–SPDE scaffold differs from the reaction splitting selected by
StochasticAllenCahn(scheme="strang").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectral_stepper
|
Module
|
A |
required |
ssa_step_fn
|
Callable
|
Function of the SSA state and half-step size.
new_ssa_state = ssa_step_fn(ssa_state, dt_half)
Must update the SSA compartment counts and return the updated
state dict including a |
required |
u
|
Float[Array, '1 * N']
|
Current PDE field, shape |
required |
ssa_state
|
dict
|
Current SSA state dictionary (Python-level, not JAX). |
required |
dt
|
float
|
Full time step; the SSA steps use |
required |
key
|
PRNGKeyArray
|
PRNGKey for the spectral noise increment. |
required |
domain_extent
|
float | None
|
Deprecated and ignored. Passing a domain length
emits |
None
|
num_points
|
int
|
Grid points N per dimension. |
required |
mollifier_cutoff
|
float
|
Fraction of Fourier modes retained by the
band-limited mollifier that converts discrete SSA outcomes to a
smooth field perturbation. Default |
0.5
|
Returns:
| Type | Description |
|---|---|
tuple[Float[Array, '1 * N'], dict]
|
|
Usage notes¶
Gibbs artefacts from injecting discrete SSA outcomes into the spectral field are suppressed by a sharp Fourier truncation mollifier. A smoother Gaussian window is straightforward to substitute.
The papers below provide context for PDE–compartment coupling and the two-regime method. This scaffold is limited to Strang composition and Fourier mollification. The complete algorithms from both papers are outside its scope.
References¶
-
Harrison, J. U., & Yates, C. A. (2016). A hybrid algorithm for coupling partial differential equation and compartment-based dynamics. Journal of the Royal Society Interface, 13(122), 20160335. DOI (PDE–compartment coupling.)
-
Flegg, M. B., Chapman, S. J., & Erban, R. (2012). The two-regime method for optimizing stochastic reaction–diffusion simulations. Journal of the Royal Society Interface, 9(70), 859–868. DOI (The two-regime method.)
-
Strang, G. (1968). On the construction and comparison of difference schemes. SIAM Journal on Numerical Analysis, 5(3), 506-517. DOI (Second-order operator splitting.)
-
Gillespie, D. T. (1977). Exact stochastic simulation of coupled chemical reactions. The Journal of Physical Chemistry, 81(25), 2340-2361. DOI (Stochastic simulation algorithm.)