Refactor Boris solvers - #541
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the OrdinaryDiffEqBoris package, which implements the Boris method and its multistep/hyper variants (orders 2, 4, and 6) for particle pushing in electric and magnetic fields. The implementation includes support for both constant and mutable caches, as well as adaptive time-stepping based on the gyroperiod. Feedback was provided regarding potential division-by-zero errors in the adaptive step size calculation when the particle charge-to-mass ratio or the magnetic field magnitude is zero, which could lead to numerical instability or NaN values.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #541 +/- ##
==========================================
- Coverage 90.45% 90.08% -0.38%
==========================================
Files 18 17 -1
Lines 2075 1977 -98
==========================================
- Hits 1877 1781 -96
+ Misses 198 196 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the OrdinaryDiffEqBoris package, which provides OrdinaryDiffEq-compatible implementations of standard and multistep Boris solvers. It also refactors the existing AdaptiveBoris into a unified Boris algorithm with an optional safety parameter for adaptive time-stepping across the library. The review feedback identifies several critical issues in the new implementation, specifically the need to incorporate the integration direction (tdir) into adaptive time-step calculations to support backward integration. Additionally, the reviewer noted that adaptive logic was omitted from the mutable cache version of the solver and suggested adding validation to ensure a time step is provided when running in fixed-step mode.
…d tracing in OrdinaryDiffEqBoris
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
This is the first attempt to develop a subpackage
OrdinaryDiffEqBorisas a substitute to the native implementation in TestParticle.jl. To handle the saving logic and in consideration for efficiency, we are using a Position-Verlet (Drift-Kick-Drift) leapfrog structure instead of a Velocity-Verlet (Kick-Drift-Kick) style in TestParticle's original implementation.