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

Temporary fix for broken inactiveTransverseDeflectingCavity in Segment #296

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This is a major release with significant upgrades under the hood of Cheetah. Des
- Moving `Element`s and `Beam`s to a different `device` and changing their `dtype` like with any `torch.nn.Module` is now possible (see #209) (@jank324)
- `Quadrupole` now supports tracking with Cheetah's matrix-based method or with Bmad's more accurate method (see #153) (@jp-ga, @jank324)
- Port Bmad-X tracking methods to Cheetah for `Quadrupole`, `Drift`, and `Dipole` (see #153, #240) (@jp-ga, @jank324)
- Add `TransverseDeflectingCavity` element (following the Bmad-X implementation) (see #240, #278) (@jp-ga, @cr-xu, @jank324)
- Add `TransverseDeflectingCavity` element (following the Bmad-X implementation) (see #240, #278 #296) (@jp-ga, @cr-xu, @jank324)
- `Dipole` and `RBend` now take a focusing moment `k1` (see #235, #247) (@hespe)
- Implement a converter for lattice files imported from Elegant (see #222, #251, #273, #281) (@hespe, @jank324)

Expand Down
3 changes: 2 additions & 1 deletion cheetah/accelerator/transverse_deflecting_cavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def is_active(self) -> bool:

@property
def is_skippable(self) -> bool:
return not self.is_active
# TODO: Implement drrift-like `transfer_map` and set to `self.is_active`
return False

def track(self, incoming: Beam) -> Beam:
"""
Expand Down
13 changes: 13 additions & 0 deletions tests/test_transverse_deflecting_cavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,16 @@ def test_transverse_deflecting_cavity_all_parameters_vectorization():
outgoing_beam = tdc.track(incoming_beam)

assert outgoing_beam.particles.shape[:-2] == torch.Size([4, 3, 2, 2])


def test_tracking_inactive_in_segment():
"""
Test that tracking through a `Segment` that contains an inactive
`TransverseDeflectingCavity` does not throw an exception. This was an issue in #290.
"""
segment = cheetah.Segment(
elements=[cheetah.TransverseDeflectingCavity(length=torch.tensor(1.0))]
)
beam = cheetah.ParticleBeam.from_parameters()

segment.track(beam)