Skip to content

Support harmonic number-based cavity definitions in RF sweep#190

Merged
freddieknets merged 2 commits intoxsuite:release/v0.9.11from
gbrogginess:rfsweep_patch
Mar 9, 2026
Merged

Support harmonic number-based cavity definitions in RF sweep#190
freddieknets merged 2 commits intoxsuite:release/v0.9.11from
gbrogginess:rfsweep_patch

Conversation

@gbrogginess
Copy link
Copy Markdown
Contributor

Description

This PR generalizes the RF sweep to support cavities defined with frequency == 0 and harmonic != 0.

Changes
A new private method _resolve_cavity_frequency() is introduced in RFSweep. It is called at the start of _get_cavity_data(), before any frequency values are read, and iterates over all cavities. For each cavity with frequency=0, it computes the RF frequency as:

f = harmonic * beta0 * c / L

then zeros out harmonic and writes the computed value back to frequency.
This is necessary because xtrack does not allow both attributes to be nonzero simultaneously.
From this point on, the rest of the sweep logic can assume frequency is always set, with no further changes required.

Testing
An existing test has been adapted to cover the changes.

Checklist

Mandatory:

  • I have added tests to cover my changes
  • All the tests are passing, including my new ones
  • I described my changes in this PR description

Optional:

  • The code I wrote follows good style practices (see PEP 8 and PEP 20).
  • I have updated the docs in relation to my changes, if applicable
  • I have tested also GPU contexts

@freddieknets freddieknets changed the base branch from main to release/v0.9.11 March 9, 2026 18:19
@freddieknets freddieknets merged commit 0d71b5f into xsuite:release/v0.9.11 Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants