Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add traveling-wave cavity model #286

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

zihan-zh
Copy link

@zihan-zh zihan-zh commented Oct 25, 2024

Description

  1. Added a cavity_type parameter to the Cheetah Cavity element.
  2. Updated the traveling-wave cavity model in the Cavity._cavity_rmatrix method to accommodate the new parameter.
  3. Modified the Bmad converter function to retrieve the cavity_type property.

Motivation and Context

This change is required to provide users with more versatility when configuring RF cavities in Cheetah.

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Checklist

  • I have updated the changelog accordingly (required).
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have reformatted the code and checked that formatting passes (required).
  • I have have fixed all issues found by flake8 (required).
  • I have ensured that all pytest tests pass (required).
  • I have run pytest on a machine with a CUDA GPU and made sure all tests pass (required).
  • I have checked that the documentation builds (required).

Note: We are using a maximum length of 88 characters per line.

@jank324 jank324 added the enhancement New feature or request label Nov 7, 2024
@jank324 jank324 self-requested a review January 14, 2025 10:09
@jank324
Copy link
Member

jank324 commented Jan 14, 2025

Just to keep some notes:

  • Removing the vector dimension in ParticleBeam.from_ocelot is not the cause of the mismatch between Ocelot and Cheetah in the tests
  • Does the new travelling wave implementation work in a vectorised scenario?

@jank324 jank324 requested a review from cr-xu January 14, 2025 11:31
@@ -116,6 +116,7 @@ def convert_element_to_cheetah(
voltage=torch.tensor(element.v, dtype=torch.float32) * 1e9,
frequency=torch.tensor(element.freq, dtype=torch.float32),
phase=torch.tensor(element.phi, dtype=torch.float32),
cavity_type="standing_wave",
name=element.id,
device=device,
dtype=dtype,
Copy link
Member

Choose a reason for hiding this comment

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

I think here we should also include the conversion for ocelot.TWCacity as it's implemented now

Copy link
Member

Choose a reason for hiding this comment

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

@cr-xu like this?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, exactly.

I think the proper test for TWCavity is still missing though. It would be nice to have a benchmark against both OCELOT and Bmad tracking results.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. There is a test for the standing wave already that I think can just be parameterised to cover travelling wave as well.

Copy link
Member

Choose a reason for hiding this comment

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

I just added the test, comparing the results to Ocelot. Weirdly, it seems the TWCavity implementation in Ocelot is broken. 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Well... indeed the OCELOT TWCavity seems to be broken, both for the stable 22.12.0 version and the unreleased one in the master branch now 24.12.0. I already opened an Issue there: ocelot-collab/ocelot#268

Let's see if that can be resolved soon. Otherwise I would suggest to have a static bmad test case and compare the result, so that we can have the PR merged soon-ish.

Copy link
Member

Choose a reason for hiding this comment

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

On a side note, the Ocelot master branch did merge my PR, so now we can also point to its official master instead of my fork for the CI/CD.

Copy link
Member

Choose a reason for hiding this comment

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

I asked @zihan-zh to provide results from a Bmad tracking, so we can use those for a static comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants