Skip to content

Commit 398b123

Browse files
authored
Merge pull request #121 from desy-ml/120-cavity-__repr__-is-printing-voltage-for-phase
2 parents d9ddf03 + baf487a commit 398b123

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Fix error raised when tracking a `ParameterBeam` through an active `BPM` (see #101) (@jank324)
2020
- Fix error in ASTRA beam import where the energy was set to `float64` instead of `float32` (see #111) (@jank324)
2121
- Fix missing passing of `total_charge` in `ParameterBeam.transformed_to` (see #112) (@jank324)
22+
- Fix `Cavitiy.__repr__` printing `voltage` value for `phase` property (see #121) (@jank324)
2223

2324
### 🐆 Other
2425

cheetah/accelerator.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
generate_unique_name = UniqueNameGenerator(prefix="unnamed_element")
2424

2525
rest_energy = torch.tensor(
26-
constants.electron_mass
27-
* constants.speed_of_light**2
28-
/ constants.elementary_charge
26+
constants.electron_mass * constants.speed_of_light**2 / constants.elementary_charge
2927
) # electron mass
3028
electron_mass_eV = torch.tensor(
3129
physical_constants["electron mass energy equivalent in MeV"][0] * 1e6
@@ -1163,7 +1161,7 @@ def __repr__(self) -> str:
11631161
return (
11641162
f"{self.__class__.__name__}(length={repr(self.length)}, "
11651163
+ f"voltage={repr(self.voltage)}, "
1166-
+ f"phase={repr(self.voltage)}, "
1164+
+ f"phase={repr(self.phase)}, "
11671165
+ f"frequency={repr(self.frequency)}, "
11681166
+ f"name={repr(self.name)})"
11691167
)

cheetah/track_methods.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
from scipy import constants
77

88
REST_ENERGY = torch.tensor(
9-
constants.electron_mass
10-
* constants.speed_of_light**2
11-
/ constants.elementary_charge
9+
constants.electron_mass * constants.speed_of_light**2 / constants.elementary_charge
1210
) # Electron mass
1311

1412

tests/test_compare_beam_type.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Tests that ensure that both beam types produce (roughly) the same results.
33
"""
4+
45
import torch
56

67
import cheetah

0 commit comments

Comments
 (0)