Fix/alp time loop termination#224
Merged
tobre1 merged 2 commits intoApr 10, 2026
Merged
Conversation
The pulse-time loop in ALPStrategy used an absolute difference and hardcoded absolute epsilon (std::fabs(time - pulseTime) > 1e-6) as its termination guard, which does not brake if the time increment is not a whole fraction of pulseTime (or very close). Replace with a scaled epsilon (coverageTimeStep * 1e-4) and changed termination guard.
Clamp dt = min(coverageTimeStep, pulseTime - time) and push it to the surface model via a new setTimeStep hook to non-const dt_ so the final iteration integrates over the actual remaining pulse time instead of overshooting with the full coverageTimeStep.
philipphaslhofer
force-pushed
the
fix/alp-time-loop-termination
branch
from
April 10, 2026 10:58
acc1f4f to
ed84ffc
Compare
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
The ALP pulse-time loop had two bugs:
while (std::fabs(time - pulseTime) > 1e-6)only exitswhen
timelands within 1e-6 ofpulseTime. For anypulseTime / coverageTimeStepthatis not an exact integer,
timeovershoots and the fabs keeps growing — the loop neverexits. Only the "neatly divisible" case worked.
coverage updates with the full
coverageTimeStep, so the physics integrates over more timethan actually remains in the pulse.
Changes
time < pulseTime - coverageTimeStep * 1e-4check so the loop terminates for arbitrarypulseTime / coverageTimeStepratios and is invariant of the time scale.dt = min(coverageTimeStep, pulseTime - time)and push it to thesurface model via a new
setTimeStephook onSurfaceModel, so the final iterationintegrates over the actual remaining time.
SingleParticleALDSurfaceModeloverrides thehook to update its (now non-const)
dt_; base-class default is a no-op so other models areunaffected.