Expand description
Stochastic Partial Differential Equation (SPDE) solvers for Numra.
This crate provides solvers for SPDEs of the form:
∂u/∂t = L[u] + σ(u) ξ(x,t)where L is a spatial differential operator, σ(u) is the diffusion coefficient, and ξ(x,t) is space-time white noise.
§Method
We use the Method of Lines (MOL) approach:
- Discretize the spatial operator L using finite differences
- Convert to a system of SDEs
- Solve using SDE solvers from
numra-sde
§Example: Stochastic Heat Equation
use numra_spde::{SpdeSystem, SpdeSolver, SpdeOptions, SpdeResult};
use numra_pde::Grid1D;
use numra_core::Scalar;
// Stochastic heat equation: ∂T/∂t = α ∂²T/∂x² + σ dW(x,t)
struct StochasticHeat {
alpha: f64, // Thermal diffusivity
sigma: f64, // Noise intensity
}
impl SpdeSystem<f64> for StochasticHeat {
fn dim(&self) -> usize { 1 } // 1D spatial
fn drift(&self, _t: f64, u: &[f64], du: &mut [f64], grid: &Grid1D<f64>) {
let dx = grid.dx_uniform();
let n = u.len();
for i in 0..n {
let u_left = if i == 0 { 0.0 } else { u[i - 1] }; // Dirichlet BC
let u_right = if i == n - 1 { 0.0 } else { u[i + 1] }; // Dirichlet BC
du[i] = self.alpha * (u_left - 2.0 * u[i] + u_right) / (dx * dx);
}
}
fn diffusion(&self, _t: f64, u: &[f64], sigma: &mut [f64], _grid: &Grid1D<f64>) {
for i in 0..u.len() {
sigma[i] = self.sigma; // Additive noise
}
}
}Author: Moussa Leblouba Date: 3 February 2026 Modified: 2 May 2026
Structs§
- Colored
Noise - Spatially colored (correlated) noise.
- Colored
Noise Generator - Spatially correlated Gaussian noise generator.
- Grid1D
- 1D uniform or non-uniform grid.
- MolSde
Solver - Method of Lines SPDE solver.
- Spde
Ensemble - Ensemble solver for SPDE Monte Carlo simulations.
- Spde
Options - Options for SPDE solver.
- Spde
Result - Result of SPDE solve.
- Spde
Stats - Statistics for SPDE solve.
- White
Noise - Spatially white (uncorrelated) space-time noise.
Enums§
- Noise
Correlation - Noise correlation structure.
- Spde
Method - SDE integration method for the spatially-discretized system.
Traits§
- Scalar
- A real scalar type suitable for numerical computation.
- Space
Time Noise - Trait for space-time noise processes.
- Spde
Solver - Trait for SPDE solvers.
- Spde
System - Trait for Stochastic Partial Differential Equation systems.