Skip to content

Conversation

@cemitch99
Copy link
Member

@cemitch99 cemitch99 commented Nov 18, 2025

This PR adds the update of the spin vector in a (linear) Quad element.

  • add spin helper class
  • add spin push operator in Quad.H
  • add benchmark example
  • set benchmark values
  • tighten benchmark tolerance
  • update Python bindings
  • update documentation
  • initialize gyromagnetic anomaly value
  • add user-facing option to turn spin tracking on or off
  • update particle push to include optional spin push

This relies on PR #1226.

@cemitch99 cemitch99 requested review from ax3l and qianglbl November 18, 2025 01:01
@cemitch99
Copy link
Member Author

It remains to choose the best location to apply the spin push. Below are a few options:

  1. src/tracking/particles.cpp - add a function call immediately following the call to push() (external fields)
  2. src/particles/PushAll.H - add a function call immediately following the line element(pti, ref_part);
  3. src/elements/Quad.H - add a function call to update the spin variables inside the main element push operator

Since this will impact the future structure of the spin tracking, it would be good to have some discussion.

@ax3l
Copy link
Member

ax3l commented Jan 8, 2026

Discussed today: let us put it as a separate, conditional spin push (kernel) in PushAll for now, which works for all linear elements (2)

We later on must reside to 3., when we integrate higher order elements where external field and spin update are integrated. For that, we will fuse the kernels, but must build machinery that keeps it cost-neutral for non-spin simulations.

@cemitch99
Copy link
Member Author

I tried naively to access the function spin_push inside the PushAll.H using element.spin_push(pti, ref_part), and this yields:

/Users/cemitch/src/impactx/src/particles/PushAll.H:67:25: error: no member named 'spin_push' in 'impactx::elements::Programmable'
67 | element.spin_push(pti, ref_part);
| ~~~~~~~ ^
/Users/cemitch/src/impactx/src/elements/Programmable.cpp:28:13: note: in instantiation of function template specialization 'impactx::push_all' requested here
28 | push_all(pc, *this, step, period, m_threadsafe);
| ^

There must be a template that needs to be modified to do this call correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants