Skip to content

Solvers#21

Merged
jordanplanders merged 3 commits into
mainfrom
solvers
Jun 2, 2026
Merged

Solvers#21
jordanplanders merged 3 commits into
mainfrom
solvers

Conversation

@jordanplanders

Copy link
Copy Markdown
Collaborator

This pull request adds two new stochastic differential equation (SDE) solvers, Heun-Maruyama and Milstein, to the PaleoBeasts modeling framework. These solvers offer improved accuracy for SDE integration, especially for models with additive or multiplicative noise. The integration interface and documentation are updated accordingly, and comprehensive tests are included to ensure correctness, reproducibility, and convergence.

New SDE solvers and integration support:

  • Added heun_maruyama_method and milstein_method to paleobeasts/utils/solver.py, providing higher-order strong convergence for SDEs. Heun-Maruyama achieves strong order 1.0 for additive noise, and Milstein achieves strong order 1.0 for multiplicative noise using a finite-difference approximation, requiring no analytic Jacobian. Both methods include detailed docstrings and error handling.
  • Updated PBModel.integrate in paleobeasts/core/pbmodel.py to support the new methods via the method argument, with improved documentation explaining solver selection and requirements. [1] [2] [3]

Testing and validation:

  • Added a comprehensive test suite test_utils_solver_sde.py covering structural correctness, reproducibility (random seed behavior), and convergence order of the new SDE solvers. Tests verify output shapes, error handling, and that the new solvers outperform Euler-Maruyama as expected.

Documentation improvements:

  • Updated module-level and function-level docstrings in paleobeasts/utils/solver.py to reflect the new solvers and their mathematical properties, including guidance for modelers on when to use each method. [1] [2]

These changes significantly enhance the modeling capabilities for stochastic systems, particularly in climate and paleobiological applications.

Introduce heun_maruyama_method: a fixed-step predictor-corrector integrator for SDEs (Heun–Maruyama) with shared Wiener increments, offering improved strong/weak convergence for additive noise. The function builds a time grid, handles RNG defaulting to numpy's default_rng, validates noise_func output shape against the state, and returns a Solution(t, y). Also update the module docstring to list Heun-Maruyama among available integrators.
Introduce a Milstein fixed-step integrator for SDEs (paleobeasts.utils.solver.milstein_method) with element-wise finite-difference approximation of ∂g/∂y, RNG handling, and Milstein correction for diagonal diffusion. Wire the new solver into PBModel (accept 'milstein' as a method, validate dt for fixed-step methods, create RNG from random_seed, and call milstein_method with sde_noise fallback). Update docstring guidance to describe SDE solver choices and when to prefer Milstein (multiplicative noise). Add comprehensive tests (paleobeasts/tests/test_utils_solver_sde.py) covering structural behavior, reproducibility, and convergence comparisons against Euler-Maruyama and Heun-Maruyama.
@jordanplanders jordanplanders merged commit ab7f619 into main Jun 2, 2026
2 checks passed
@jordanplanders jordanplanders deleted the solvers branch June 2, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant