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

Fix is_active check issue in cavity and dipole #198

Merged
merged 2 commits into from
Jun 27, 2024
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 @@ -4,7 +4,7 @@

### 🚨 Breaking Changes

- Cheetah is now vectorised. This means that you can run multiple simulations in parallel by passing a batch of beams and settings, resulting a number of interfaces being changed. For Cheetah developers this means that you now have to account for an arbitrary-dimensional tensor of most of the properties of you element, rather than a single value, vector or whatever else a property was before. (see #116, #157, #170, #172, #173) (@jank324, @cr-xu)
- Cheetah is now vectorised. This means that you can run multiple simulations in parallel by passing a batch of beams and settings, resulting a number of interfaces being changed. For Cheetah developers this means that you now have to account for an arbitrary-dimensional tensor of most of the properties of you element, rather than a single value, vector or whatever else a property was before. (see #116, #157, #170, #172, #173, #198) (@jank324, @cr-xu)

### 🚀 Features

Expand Down
2 changes: 1 addition & 1 deletion cheetah/accelerator/cavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(

@property
def is_active(self) -> bool:
return any(self.voltage != 0)
return torch.any(self.voltage != 0)

@property
def is_skippable(self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions cheetah/accelerator/dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def is_skippable(self) -> bool:

@property
def is_active(self):
return any(self.angle != 0)
return torch.any(self.angle != 0)

def transfer_map(self, energy: torch.Tensor) -> torch.Tensor:
device = self.length.device
Expand All @@ -108,7 +108,7 @@ def transfer_map(self, energy: torch.Tensor) -> torch.Tensor:
R_enter = self._transfer_map_enter()
R_exit = self._transfer_map_exit()

if any(self.length != 0.0): # Bending magnet with finite length
if torch.any(self.length != 0.0): # Bending magnet with finite length
R = base_rmatrix(
length=self.length,
k1=torch.zeros_like(self.length),
Expand Down