Unify ode/sde_determine_initdt into single implementation#3137
Merged
ChrisRackauckas merged 3 commits intoSciML:masterfrom Mar 17, 2026
Merged
Conversation
Move the SDE initial timestep determination algorithm (stochastic
Hairer-Wanner with diffusion terms) from StochasticDiffEq into
OrdinaryDiffEqCore's initdt.jl. This adds two methods dispatching on
AbstractRODEProblem{uType,tType,true/false} that handle both in-place
and out-of-place SDE problems.
The _determine_initdt hook remains extensible — SDE overrides it to
call sde_determine_initdt with the correct alg_order.
Bump version to 3.22.0.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Replace separate sde_determine_initdt with unified internal functions _ode_initdt_iip and _ode_initdt_oop that conditionally fold diffusion terms into the Hairer-Wanner initial timestep estimate when g !== nothing. - d₁ uses max(|f₀±3g₀|)/sk instead of f₀/sk when noise present - d₂ uses max(|Δf±ΔgMax|)/sk instead of Δf/sk when noise present - Order correction (+1/2) applied via entry point dispatch - Fixes bug in old iip SDE code: f₁/g₁ were evaluated at (u0,t) instead of (u₁,t+dt₀) - RODE/SDE entry points handle jump shortcut (P !== nothing → dtmax/1e6) - ODE SIMD optimizations preserved in no-noise path - Net -55 lines: 2 separate SDE functions → conditional branches in shared code Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
5 tasks
JET's typo mode flagged g₀ as potentially undefined because it was assigned inside one `if g !== nothing` block and used in a separate `if g !== nothing` block. Pre-initialize to nothing so JET can see the variable is always defined. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Details
The stochastic Hairer-Wanner initial timestep algorithm adds noise terms to the standard ODE estimate:
Also fixes a bug in the original SDE iip code where d2 was computed at (u0, t) instead of (u1, t + dt0).
Net: -55 lines (131 insertions, 186 deletions).
Companion PR: SciML/StochasticDiffEq.jl#697
Part of Phase 15 SDE/ODE unification.
Test plan