Skip to content

Add spin to ExactQuad.#1323

Merged
ax3l merged 34 commits intoBLAST-ImpactX:developmentfrom
cemitch99:add_spin_exact_quad
Mar 26, 2026
Merged

Add spin to ExactQuad.#1323
ax3l merged 34 commits intoBLAST-ImpactX:developmentfrom
cemitch99:add_spin_exact_quad

Conversation

@cemitch99
Copy link
Copy Markdown
Member

@cemitch99 cemitch99 commented Feb 25, 2026

This PR adds spin tracking to the ExactQuad element, which requires combining the Thomas-BMT equation s-push with the orbit symplectic integration, to the correct order in stepsize h. The basic framework will be reused for the ExactMultipole and ExactCFbend elements.

  • add basic spin structure for ExactQuad
  • add Thomas-BMT precession vector evaluation
  • add 2nd-order symplectic integration in the presence of spin
  • add 4th-6th-order symplectic integration in the presence of spin
  • move Thomas-BMT precession vector to mixin/spin_transport class
  • add a benchmark (e.g. comparison against a linear Quad as a limiting case)
  • fix failing CI tests (all works locally)
  • fix inline comment on bunch charge in particle container

Follow-up: Investigate alternative 4th and 6th-order symplectic integration algorithms with spin to improve performance (by reducing the number of required map evaluations). See Issue #1341

Comment thread src/elements/ExactQuad.H Fixed
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Feb 25, 2026

Merging this PR will not alter performance

✅ 37 untouched benchmarks


Comparing cemitch99:add_spin_exact_quad (3d70b36) with development (a375136)

Open in CodSpeed

@ax3l ax3l added component: elements Elements/maps/external fields component: spin tracking Spin tracking labels Feb 25, 2026
@ax3l ax3l self-requested a review February 26, 2026 21:36
Comment thread src/elements/ExactQuad.H Outdated
Comment thread src/elements/ExactQuad.H Fixed
@cemitch99 cemitch99 requested a review from qianglbl February 27, 2026 23:38
@cemitch99
Copy link
Copy Markdown
Member Author

I tried initializing the OpenMP / GCC w/SIMD w/o MPI w/ Python runner three times, and each time it fails to build with the error:

ninja: build stopped: interrupted by user.

@ax3l
Copy link
Copy Markdown
Member

ax3l commented Mar 8, 2026

Maybe uses too many resources, try to lower from -j4 to -j3 in CI script of the GH action?

Comment thread src/particles/ImpactXParticleContainer.cpp Fixed
Copy link
Copy Markdown
Member Author

@cemitch99 cemitch99 left a comment

Choose a reason for hiding this comment

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

Corrected filename in CMakeList...

@ax3l ax3l mentioned this pull request Mar 18, 2026
4 tasks
Comment thread examples/spin_tracking/run_exact_quad_spin_scaling.py Outdated
@ax3l
Copy link
Copy Markdown
Member

ax3l commented Mar 20, 2026

I wonder if #1351 can help with the spike of resource usage that fails one of the builds: OpenMP / GCC w/ SIMD w/o MPI w/ Python

@ax3l
Copy link
Copy Markdown
Member

ax3l commented Mar 23, 2026

Great, #1351 helped to lower the peak resource usage of the compiler (by splitting over multiple translation units / .cpp files).

Comment thread examples/spin_tracking/README.rst Outdated
Comment thread src/elements/mixin/spintransport.H Outdated
Comment thread src/elements/mixin/spintransport.H Outdated
Comment thread src/elements/mixin/spintransport.H Outdated
Comment thread src/elements/mixin/spintransport.H Outdated
Comment thread src/elements/ExactQuad.H
Comment thread src/elements/ExactQuad.H
Comment thread src/elements/ExactQuad.H
Comment thread src/particles/integrators/Integrators.H Outdated
Comment thread src/particles/integrators/Integrators.H Outdated
Comment thread src/elements/ExactQuad.H Outdated
ax3l added 3 commits March 23, 2026 16:38
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Use some intermediate constants for common terms.
Comment thread examples/spin_tracking/run_exact_quad_spin_scaling.py Outdated
Comment thread src/elements/ExactQuad.H Outdated
Comment thread src/particles/integrators/Integrators.H Outdated
@ax3l ax3l force-pushed the add_spin_exact_quad branch from 4f8ae5d to fbd4c40 Compare March 25, 2026 17:44
amrex::ParticleReal const alpha = 1_prt - std::pow(2_prt,1_prt/3_prt);
amrex::ParticleReal const tau2 = dz/(1_prt + alpha);
amrex::ParticleReal const dz = (zout - zin) / static_cast<amrex::ParticleReal>(nsteps);
constexpr amrex::ParticleReal alpha = -0.2599210498948732; // C++26: 1_prt - std::pow(2_prt,1_prt/3_prt);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
amrex::ParticleReal const dz = (zout-zin)/nsteps;
amrex::ParticleReal const alpha = 1_prt - std::pow(2_prt,1_prt/3_prt);
amrex::ParticleReal const dz = (zout - zin) / static_cast<amrex::ParticleReal>(nsteps);
constexpr amrex::ParticleReal alpha = -0.2599210498948732; // C++26: 1_prt - std::pow(2_prt,1_prt/3_prt);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Copy link
Copy Markdown
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

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

🎉

@ax3l ax3l enabled auto-merge (squash) March 26, 2026 20:56
@ax3l ax3l self-assigned this Mar 26, 2026
@ax3l ax3l merged commit 4aadf29 into BLAST-ImpactX:development Mar 26, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: elements Elements/maps/external fields component: spin tracking Spin tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants