Skip to content

Comments

Move spin calculations to compute_constants#1304

Merged
ax3l merged 15 commits intoBLAST-ImpactX:developmentfrom
cemitch99:move_spin_constants
Feb 22, 2026
Merged

Move spin calculations to compute_constants#1304
ax3l merged 15 commits intoBLAST-ImpactX:developmentfrom
cemitch99:move_spin_constants

Conversation

@cemitch99
Copy link
Member

@cemitch99 cemitch99 commented Feb 15, 2026

This PR moves many computations for the spin push outside the particle loop into compute_constants, to improve performance.

  • Quad (note that a typo was fixed in the k < 0 case)
  • ChrQuad
  • Sbend
  • Sol
  • Add benchmark test

Close #1288

[
0.02,
0.02,
0.05,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a necessary change resulting from the typo fix in Quad.H for k < 0.

T_Real const delta1 = sqrt(1_prt - 2_prt*pt/m_beta + powi<2>(pt));

// compute particle relativistic gamma
T_Real const gamma = gamma_ref * (1_prt - beta_ref*gamma_ref*pt);
Copy link
Member Author

@cemitch99 cemitch99 Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should only be one factor of gamma_ref in line 345, which is fixed in the revised line below.

@cemitch99 cemitch99 requested review from ax3l and qianglbl February 18, 2026 00:52
@ax3l
Copy link
Member

ax3l commented Feb 20, 2026

@cemitch99 uh, I want to do a small PR for Python bindings and benchmarks first, so we can see first hand with the new CI #1309 how much this gains.

@ax3l
Copy link
Member

ax3l commented Feb 21, 2026

Let us merge #1313 and then once it has run on development we rebase this PR to run it again and see the impact of the changes.

@ax3l ax3l self-assigned this Feb 21, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 21, 2026

Merging this PR will improve performance by 31.53%

⚡ 3 improved benchmarks
✅ 33 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_Sol[spin] 1.2 s 1 s +14.65%
test_Quad[spin] 848.8 ms 645.4 ms +31.53%
test_Sbend[spin] 1,180.2 ms 914.6 ms +29.04%

Comparing cemitch99:move_spin_constants (785a235) with development (3ace399)

Open in CodSpeed

@ax3l ax3l force-pushed the move_spin_constants branch from 7479980 to 71f90ff Compare February 21, 2026 22:04
@ax3l
Copy link
Member

ax3l commented Feb 22, 2026

I think this captured all elements we have with spin support so far. The only other 3 are the drift models, which don't affect spin.

@ax3l ax3l merged commit b07ae0d into BLAST-ImpactX:development Feb 22, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spin Tracking: Pre-Calculate Constants

2 participants