[WIP] Compensated Sum for Global Coordinates#1195
Open
ax3l wants to merge 8 commits into
Open
Conversation
ax3l
force-pushed
the
s-compensated
branch
5 times, most recently
from
October 21, 2025 06:59
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()); |
Member
Author
There was a problem hiding this comment.
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
ax3l
force-pushed
the
s-compensated
branch
4 times, most recently
from
October 21, 2025 07:46
ad48adf to
cee4e07
Compare
| */ | ||
| AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE | ||
| bool operator==(CompensatedReal const& rhs) const { | ||
| return value() == rhs.value(); |
Check notice
Code scanning / CodeQL
Equality test on floating-point values Note
A high order Kahan sum implementation for integrating many values.
Use the compensated sum type to calculate `s`.
ax3l
commented
Oct 23, 2025
ax3l
force-pushed
the
development
branch
2 times, most recently
from
April 20, 2026 04:08
9a1e4af to
fa61eba
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.
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