Fix convergence issues in split ODE methods #2861
Closed
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
Fixes convergence test failures in split ODE methods (AlgConvergence_III and others) by ensuring caches are properly initialized.
Background
After DiffEqBase.jl PR #1188 changed
promote_f
to no longer replaceLazyBufferCache
with a zero-initialized array, split ODE methods started failing convergence tests. The issue was that uninitialized memory in the cache contained random values that would accumulate into the solution, causing unpredictable errors that broke convergence rate tests.Solution
This PR uses the standard
fill!
function to zero out the cache forSplitFunction
objects during integrator initialization. It adds PreallocationTools as a dependency and requires version 0.4.34+ which includesfill!
overloads for cache types.Changes
fill!(cache, 0)
to zero out SplitFunction caches during initializationfill!
is applicable before calling it, ensuring backward compatibilityTest Results
Created a test that verifies convergence rates for
SplitEuler
with aLazyBufferCache
. The test shows correct first-order convergence (rates ≈ 1.0) with this fix applied.Dependencies
fill!
overloads for cache typesRelated Issues
🤖 Generated with Claude Code