refactor(SymplecticRK): migrate drift-kick methods to generic Symplec…#3473
Merged
ChrisRackauckas merged 5 commits intoSciML:masterfrom Apr 20, 2026
Merged
Conversation
…ticTableau framework
Comment on lines
+153
to
+167
| # Mapping from algorithm to tableau constructor | ||
| _symplectic_tableau(::PseudoVerletLeapfrog, T, T2) = PseudoVerletLeapfrogConstantCache(T, T2) | ||
| _symplectic_tableau(::McAte2, T, T2) = McAte2ConstantCache(T, T2) | ||
| _symplectic_tableau(::Ruth3, T, T2) = Ruth3ConstantCache(T, T2) | ||
| _symplectic_tableau(::McAte3, T, T2) = McAte3ConstantCache(T, T2) | ||
| _symplectic_tableau(::CandyRoz4, T, T2) = CandyRoz4ConstantCache(T, T2) | ||
| _symplectic_tableau(::McAte4, T, T2) = McAte4ConstantCache(T, T2) | ||
| _symplectic_tableau(::CalvoSanz4, T, T2) = CalvoSanz4ConstantCache(T, T2) | ||
| _symplectic_tableau(::McAte42, T, T2) = McAte42ConstantCache(T, T2) | ||
| _symplectic_tableau(::McAte5, T, T2) = McAte5ConstantCache(T, T2) | ||
| _symplectic_tableau(::Yoshida6, T, T2) = Yoshida6ConstantCache(T, T2) | ||
| _symplectic_tableau(::KahanLi6, T, T2) = KahanLi6ConstantCache(T, T2) | ||
| _symplectic_tableau(::McAte8, T, T2) = McAte8ConstantCache(T, T2) | ||
| _symplectic_tableau(::KahanLi8, T, T2) = KahanLi8ConstantCache(T, T2) | ||
| _symplectic_tableau(::SofSpa10, T, T2) = SofSpa10ConstantCache(T, T2) |
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
Apr 21, 2026
Runs Runic.format_file on the 5 files flagged by the runic CI check. The formatting drift was introduced by recent merges (most notably the SymplecticRK refactor in SciML#3473) and now blocks format-check on every open PR. No semantic changes. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
ChrisRackauckas
added a commit
that referenced
this pull request
Apr 21, 2026
Runs Runic.format_file on the 5 files flagged by the runic CI check. The formatting drift was introduced by recent merges (most notably the SymplecticRK refactor in #3473) and now blocks format-check on every open PR. No semantic changes. Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
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.
🚀 SymplecticRK Refactor: Generic Tableau-Based Implementation
This PR introduces a major refactor of the Symplectic Runge-Kutta (SymplecticRK) implementation by replacing multiple per-method implementations with a generic, tableau-driven design.
The previous implementation had significant duplication across methods, with separate cache structs and perform_step! implementations for each algorithm. Since all symplectic methods follow the same drift–kick pattern, this refactor unifies them under a single abstraction.
At the core of this change is the introduction of a generic
SymplecticTableaustructure that stores method coefficients (a,b) as NTuples. This replaces all per-method constant cache structs while preserving the exact numerical behavior of each algorithm.The caching system has been simplified by replacing multiple cache types (like Symplectic2Cache, Symplectic3Cache, etc.) with a single
SymplecticGenericCache. This significantly reduces boilerplate and makes the system easier to maintain.The biggest improvement comes from replacing ~20 different
perform_step!implementations with just two generic versions (OOP and IIP). These implementations are fully driven by the tableau coefficients and follow a unified loop structure:This abstraction captures the exact structure shared by all symplectic integrators, making the code both mathematically clear and extensible.
Additionally, algorithm dispatch has been simplified using lightweight
_symplectic_tableaumappings, where each algorithm maps to its tableau in a single line.A bug in the CandyRoz4 implementation was also fixed, where it previously used an incorrect cache (McAte4 instead of CandyRoz4).
Impact
This results in a significant reduction in code duplication and improves readability, maintainability, and extensibility.
Testing
All tests pass successfully:
Pre-existing allocation test issues remain unchanged.
Summary
This refactor transforms the SymplecticRK implementation from a method-specific design into a fully generic, coefficient-driven system. It simplifies the codebase, removes redundancy, and aligns the implementation more closely with the mathematical structure of symplectic integrators.