-
Notifications
You must be signed in to change notification settings - Fork 29
[WIP] Compensated Sum for Global Coordinates #1195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ax3l
wants to merge
8
commits into
BLAST-ImpactX:development
Choose a base branch
from
ax3l:s-compensated
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
9204323 to
f4e9203
Compare
ax3l
commented
Oct 21, 2025
|
|
||
| // openPMD 1.* needs "seconds" here, but we fake it as "s" | ||
| iteration.setTime(ref_part.s); | ||
| iteration.setTime(ref_part.s.value()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Should we just use
Suggested change
| iteration.setTime(ref_part.s.value()); | |
| iteration.setTime(ref_part.t.value()); |
?
(Should be a separate PR, just noticed here...)
ax3l
commented
Oct 21, 2025
ax3l
commented
Oct 21, 2025
ad48adf to
cee4e07
Compare
A high order Kahan sum implementation for integrating many values.
Use the compensated sum type to calculate `s`.
ax3l
commented
Oct 23, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Long sums, e.g.,
sof the reference particle, suffer dramatically from floating point precision errors as large and small terms are added in succession thousands to millions of times. Using a compensated sum can keep these numerical errors in check.This implements, with some vibe coding assistance, the 2nd-order method of Klein (2006) that is linked on Wikipedia. The cost is that
sis now of the size of 3 instead of 1 double, e.g., when copying to kernels. We could also use a first order method, which only needs 2 doubles (e.g., Neumaier (1974)).The latter might be worth considering if we need to use compensated sums for further properties, e.g., x,y,z,t(,px,py,pz,pt) of the reference particle...?
Originally inspired by #1183, but needed at many locations in ImpactX, e.g., existing survey plots #1040, inserting elements #877 #1095 etc. Exposed to Python and used there, too.
To Do
s,x,pt,t, etc. of the reference particle -- .e.g, LHC size and beam lifetime