Skip to content

Commit

Permalink
Temporary fix for bug that broke inactive TDC in Segment
Browse files Browse the repository at this point in the history
  • Loading branch information
jank324 committed Nov 22, 2024
1 parent 8f33959 commit 9a154e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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)

0 comments on commit 9a154e2

Please sign in to comment.