Skip to content

Conversation

@juan-g-bonilla
Copy link
Contributor

@juan-g-bonilla juan-g-bonilla commented May 28, 2025

Description

This PR introduces support for stochastic differential equations (SDEs) in the Basilisk simulation framework. The main changes include:

  • State Diffusion Support: The state machinery (StateData, DynParamManager, ExtendedStateVector, etc.) is extended to support setting and propagating the diffusion term (g_i) for multiple noise sources, in addition to the deterministic drift (f).
  • Stochastic Integrators: Implements weak second-order stochastic Runge-Kutta (SRK) integrators, specifically the methods described by Tang & Xiao (2017), including both W2-Ito1 and W2-Ito2 schemes. These are available as svStochIntegratorW2Ito1 and svStochIntegratorW2Ito2. Also implements the Euler-Mayurama integrator (available in svStochIntegratorMayurama.
  • Noise Source Management: Adds machinery to register and share noise sources between states, allowing for correlated stochastic processes across different states.
  • DynamicObject Interface: Adds equationsOfMotionDiffusion to DynamicObject and relevant subclasses, enabling models to compute the diffusion term.
  • MuJoCo Integration: Updates the MuJoCo scene and state classes to support stochastic integration, including proper propagation of diffusions.
  • spacecraft Integration: equationsOfMotionDiffusion calls the regular equationsOfMotion so that stateEffectors can set the diffusion of states.
  • Python Bindings: Updates SWIG interfaces and Python helper functions to expose the new stochastic integrators and noise management features.
  • Unit Test: Adds a new test (test_stochasticIntegrators.py) that demonstrates and validates the new stochastic integration capabilities.
  • Scenario: Adds a new scenario scenarioStochasticDrag.

Commits are organized by subsystem: core state machinery, integrator implementation, MuJoCo support, Python bindings, and tests.

Verification

  • Automated Tests: Added a new unit test (test_stochasticIntegrators.py) that exercises the stochastic integrator on a simple exponential system and an example from the reference paper. The test compares Basilisk's results to a pure Python implementation.
  • Backwards Compatibility: Existing deterministic integrators and state propagation remain unaffected.

Documentation

  • Code Documentation: All new classes and methods are documented inline with Doxygen-style comments. Python methods have docstrings.
  • Scenario: scenarioStochasticDrag illustrates how to use a stochastic state.

Future work

  • Additional Integrators: Implement strong-order stochastic integrators, support for adaptive time-stepping, Stratonovich noise integrators...

@juan-g-bonilla juan-g-bonilla self-assigned this May 28, 2025
@juan-g-bonilla juan-g-bonilla requested a review from a team as a code owner May 28, 2025 13:50
@juan-g-bonilla juan-g-bonilla added enhancement New feature or request dont merge Waiting on other changes before merging labels May 28, 2025
@juan-g-bonilla juan-g-bonilla moved this to 🏗 In progress in Basilisk May 28, 2025
@juan-g-bonilla juan-g-bonilla force-pushed the feature/1004-stochastic-dynamics branch from 49fb9e9 to c1474a0 Compare June 1, 2025 06:16
@juan-g-bonilla juan-g-bonilla moved this from 🏗 In progress to 👀 In review in Basilisk Jun 1, 2025
@juan-g-bonilla juan-g-bonilla changed the title Feature/1004 stochastic dynamics [DRAFT] Feature/1004 stochastic dynamics Jun 1, 2025
@juan-g-bonilla juan-g-bonilla force-pushed the feature/1004-stochastic-dynamics branch from c1474a0 to 1a49412 Compare June 1, 2025 07:03
@juan-g-bonilla juan-g-bonilla removed the dont merge Waiting on other changes before merging label Jun 1, 2025
@juan-g-bonilla juan-g-bonilla requested a review from schaubh July 7, 2025 15:12

/// @cond DOXYGEN_IGNORE
template <typename T, typename... Rest>
void hash_combine(std::size_t& seed, const T& v, const Rest&... rest)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

@juan-g-bonilla juan-g-bonilla force-pushed the feature/1004-stochastic-dynamics branch from 1a49412 to 632127a Compare November 22, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Support Stochastic Integration

2 participants