Skip to content

Spin push for TaperedPL#1433

Merged
cemitch99 merged 5 commits into
BLAST-ImpactX:developmentfrom
cemitch99:add_tapered_pl_spin
May 7, 2026
Merged

Spin push for TaperedPL#1433
cemitch99 merged 5 commits into
BLAST-ImpactX:developmentfrom
cemitch99:add_tapered_pl_spin

Conversation

@cemitch99
Copy link
Copy Markdown
Member

@cemitch99 cemitch99 commented Apr 24, 2026

This PR adds the spin push for the thin tapered plasma lens element. Close #1154

  • add spin push

Follow-up: add spin push for ChrPlasmaLens and benchmark against TaperedPL (with taper=0) for consistency check

@cemitch99 cemitch99 requested a review from ax3l April 24, 2026 18:55
@ax3l ax3l added component: elements Elements/maps/external fields component: spin tracking Spin tracking labels Apr 24, 2026
Comment thread src/elements/TaperedPL.H Fixed
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 24, 2026

Merging this PR will not alter performance

✅ 37 untouched benchmarks


Comparing cemitch99:add_tapered_pl_spin (58421f9) with development (0ec7570)

Open in CodSpeed

@ax3l ax3l mentioned this pull request Apr 24, 2026
5 tasks
Comment thread src/elements/TaperedPL.H Outdated
Comment thread src/elements/TaperedPL.H Outdated
Comment thread src/elements/TaperedPL.H Outdated
Comment thread src/elements/TaperedPL.H Outdated
Comment thread src/elements/TaperedPL.H Outdated
Comment thread src/elements/TaperedPL.H Outdated
Comment thread src/elements/TaperedPL.H Outdated
Comment thread src/elements/TaperedPL.H Outdated
@ax3l ax3l requested a review from carlandreaslindstrom May 4, 2026 21:38
Copy link
Copy Markdown

@carlandreaslindstrom carlandreaslindstrom left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@cemitch99
Copy link
Copy Markdown
Member Author

Thanks @carlandreaslindstrom . This one is just awaiting a benchmark test, which is almost ready and being finalized now.

@cemitch99
Copy link
Copy Markdown
Member Author

@ax3l Actually, the benchmark that I had in mind requires implementing the spin push in ChrPlasmaLens first, which is not quite ready, and outside this PR. I propose merging this one first, and adding a follow-up PR with ChrPlasmaLens + a benchmark consistency check against TaperedPL.

@cemitch99 cemitch99 mentioned this pull request May 4, 2026
3 tasks
ax3l
ax3l previously approved these changes May 6, 2026
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.

Sounds good!

@ax3l ax3l dismissed their stale review May 6, 2026 21:23

There are a few bugs

@ax3l ax3l mentioned this pull request May 6, 2026
Comment thread src/elements/TaperedPL.H Outdated
Comment thread src/elements/TaperedPL.H
Comment on lines +218 to +222
// compute multipole magnetic field normalized by q/mc:
amrex::ParticleReal gamma_ref = refpart.gamma();
T_Real const Bx = m_g * ( y + m_taper * x * y ) * gamma_ref * m_beta;
T_Real const By = -m_g * ( x + m_taper*0.5_prt * (powi<2>(x) + powi<2>(y)) ) * gamma_ref * m_beta;
T_Real const Bz = 0_prt;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Codex:

The magnetic field signs look opposite to the phase-space kick. The
ordinary push applies:

dpx = -g * A;

dpy = -g * B;

Following the convention used in Multipole.H, the normalized fields should
be proportional to Bx = dpy * beta*gamma and By = -dpx * beta*gamma, so I’d
expect:

Bx = -m_g * (y + m_taper * x * y) * gamma_ref * m_beta;
By =  m_g * (x + 0.5_prt * m_taper * (powi<2>(x) + powi<2>(y))) * gamma_ref * m_beta;

As written, the spin precession for taper=0 corresponds to the field sign
of a defocusing plasma lens while the particle kick is focusing for m_g >
0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fix coming via #1452

Comment thread src/elements/TaperedPL.H
Comment thread src/elements/TaperedPL.H Outdated
@ax3l ax3l self-assigned this May 6, 2026
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
@ax3l
Copy link
Copy Markdown
Member

ax3l commented May 7, 2026

I see CI is failing. Merging #1454 now which will fix it.

@cemitch99 cemitch99 merged commit cf4c20b into BLAST-ImpactX:development May 7, 2026
14 of 17 checks passed
@cemitch99
Copy link
Copy Markdown
Member Author

This PR will be tested using #1452

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.

Spin Tracking for Plasma Staging

4 participants