Skip to content

Commit

Permalink
Merge pull request #121 from desy-ml/120-cavity-__repr__-is-printing-…
Browse files Browse the repository at this point in the history
…voltage-for-phase
  • Loading branch information
jank324 authored Feb 2, 2024
2 parents d9ddf03 + baf487a commit 398b123
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Fix error raised when tracking a `ParameterBeam` through an active `BPM` (see #101) (@jank324)
- Fix error in ASTRA beam import where the energy was set to `float64` instead of `float32` (see #111) (@jank324)
- Fix missing passing of `total_charge` in `ParameterBeam.transformed_to` (see #112) (@jank324)
- Fix `Cavitiy.__repr__` printing `voltage` value for `phase` property (see #121) (@jank324)

### 🐆 Other

Expand Down
6 changes: 2 additions & 4 deletions cheetah/accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
generate_unique_name = UniqueNameGenerator(prefix="unnamed_element")

rest_energy = torch.tensor(
constants.electron_mass
* constants.speed_of_light**2
/ constants.elementary_charge
constants.electron_mass * constants.speed_of_light**2 / constants.elementary_charge
) # electron mass
electron_mass_eV = torch.tensor(
physical_constants["electron mass energy equivalent in MeV"][0] * 1e6
Expand Down Expand Up @@ -1163,7 +1161,7 @@ def __repr__(self) -> str:
return (
f"{self.__class__.__name__}(length={repr(self.length)}, "
+ f"voltage={repr(self.voltage)}, "
+ f"phase={repr(self.voltage)}, "
+ f"phase={repr(self.phase)}, "
+ f"frequency={repr(self.frequency)}, "
+ f"name={repr(self.name)})"
)
Expand Down
4 changes: 1 addition & 3 deletions cheetah/track_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from scipy import constants

REST_ENERGY = torch.tensor(
constants.electron_mass
* constants.speed_of_light**2
/ constants.elementary_charge
constants.electron_mass * constants.speed_of_light**2 / constants.elementary_charge
) # Electron mass


Expand Down
1 change: 1 addition & 0 deletions tests/test_compare_beam_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests that ensure that both beam types produce (roughly) the same results.
"""

import torch

import cheetah
Expand Down

0 comments on commit 398b123

Please sign in to comment.