Skip to content

Commit 2ce6e31

Browse files
committed
Merge branch '100-batched-execution' of github.com:desy-ml/cheetah into 100-batched-execution
2 parents 25b9ead + 2a0a8e0 commit 2ce6e31

10 files changed

+109
-63
lines changed

.flake8

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ exclude =
77
.ipynb_checkpoints
88
max-line-length = 88
99
extend-ignore = E203, W503
10-
ignore = BLK100
10+
ignore = BLK100

CHANGELOG.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Changelog
22

3-
## v0.6.2 [🚧 Work in Progress]
3+
## v0.7.0 [🚧 Work in Progress]
4+
5+
### 🚨 Breaking Changes
6+
7+
### 🚀 Features
8+
9+
### 🐛 Bug fixes
10+
11+
### 🐆 Other
12+
13+
## [v0.6.2](https://github.com/desy-ml/cheetah/releases/tag/v0.6.2) (2024-02-13)
414

515
### 🚨 Breaking Changes
616

@@ -19,12 +29,16 @@
1929
- Fix error raised when tracking a `ParameterBeam` through an active `BPM` (see #101) (@jank324)
2030
- Fix error in ASTRA beam import where the energy was set to `float64` instead of `float32` (see #111) (@jank324)
2131
- Fix missing passing of `total_charge` in `ParameterBeam.transformed_to` (see #112) (@jank324)
32+
- Fix `Cavitiy.__repr__` printing `voltage` value for `phase` property (see #121) (@jank324)
2233

2334
### 🐆 Other
2435

2536
- Add pull request template (see #97) (@jank324)
2637
- Add _Acknowledgements_ section to README (see #103) (@jank324)
2738
- `benchmark` directory was moved to `desy-ml/cheetah-demos` repository (see #108) (@jank324)
39+
- Update citations to new arXiv preprint (see #117) (@jank324)
40+
- Improve the docstring with proper units for the phase space dimensions (see #122) (@cr-xu)
41+
- Link to the new paper (on arXiv) in the documentation (see #125) (@jank324)
2842

2943
## [v0.6.1](https://github.com/desy-ml/cheetah/releases/tag/v0.6.1) (2023-09-17)
3044

CITATION.bib

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@misc{kaiser2024cheetah,
2+
title = {Cheetah: Bridging the Gap Between Machine Learning and Particle Accelerator Physics with High-Speed, Differentiable Simulations},
3+
author = {Kaiser, Jan and Xu, Chenran and Eichler, Annika and {Santamaria Garcia}, Andrea},
4+
year = {2024},
5+
eprint = {2401.05815},
6+
archiveprefix = {arXiv},
7+
primaryclass = {physics.acc-ph}
8+
}
9+
@inproceedings{stein2022accelerating,
10+
title = {Accelerating Linear Beam Dynamics Simulations for Machine Learning Applications},
11+
author = {Stein, Oliver and Kaiser, Jan and Eichler, Annika},
12+
year = {2022},
13+
booktitle = {Proceedings of the 13th International Particle Accelerator Conference}
14+
}

README.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,22 @@ where the optional keyword argument `beam` is the incoming beam represented by t
8585

8686
## Cite Cheetah
8787

88-
To cite Cheetah in publications:
88+
If you use Cheetah, please cite the following two papers:
8989

9090
```bibtex
91+
@misc{kaiser2024cheetah,
92+
title = {Cheetah: Bridging the Gap Between Machine Learning and Particle Accelerator Physics with High-Speed, Differentiable Simulations},
93+
author = {Kaiser, Jan and Xu, Chenran and Eichler, Annika and {Santamaria Garcia}, Andrea},
94+
year = {2024},
95+
eprint = {2401.05815},
96+
archiveprefix = {arXiv},
97+
primaryclass = {physics.acc-ph}
98+
}
9199
@inproceedings{stein2022accelerating,
92-
title = {Accelerating Linear Beam Dynamics Simulations for Machine Learning Applications},
93-
author = {Stein, Oliver and Kaiser, Jan and Eichler, Annika},
94-
year = 2022,
95-
booktitle = {Proceedings of the 13th International Particle Accelerator Conference},
96-
url = {https://github.com/desy-ml/cheetah}
100+
title = {Accelerating Linear Beam Dynamics Simulations for Machine Learning Applications},
101+
author = {Stein, Oliver and Kaiser, Jan and Eichler, Annika},
102+
year = {2022},
103+
booktitle = {Proceedings of the 13th International Particle Accelerator Conference}
97104
}
98105
```
99106

cheetah/accelerator.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
rest_energy = torch.tensor(
2626
constants.electron_mass
2727
* constants.speed_of_light**2
28-
/ constants.elementary_charge
29-
) # electron mass
28+
/ constants.elementary_charge # electron mass
29+
)
3030
electron_mass_eV = torch.tensor(
3131
physical_constants["electron mass energy equivalent in MeV"][0] * 1e6
3232
)
@@ -45,21 +45,25 @@ def __init__(self, name: Optional[str] = None) -> None:
4545
self.name = name if name is not None else generate_unique_name()
4646

4747
def transfer_map(self, energy: torch.Tensor) -> torch.Tensor:
48-
"""
48+
r"""
4949
Generates the element's transfer map that describes how the beam and its
50-
particles are transformed when traveling through the element. The state vector
51-
consists of 6 values with a physical meaning:
50+
particles are transformed when traveling through the element.
51+
The state vector consists of 6 values with a physical meaning:
52+
(in the trace space notation)
53+
5254
- x: Position in x direction
53-
- xp: Momentum in x direction
55+
- xp: Angle in x direction
5456
- y: Position in y direction
55-
- yp: Momentum in y direction
56-
- s: Position in z direction, the zero value is set to the middle of the pulse
57-
- sp: Momentum in s direction
57+
- yp: Angle in y direction
58+
- s: Position in longitudinal direction, the zero value is set to the
59+
reference position (usually the center of the pulse)
60+
- p: Relative energy deviation from the reference particle
61+
:math:`p = \frac{\Delta E}{p_0 C}`
5862
As well as a seventh value used to add constants to some of the prior values if
5963
necessary. Through this seventh state, the addition of constants can be
6064
represented using a matrix multiplication.
6165
62-
:param energy: Energy of the Beam. Read from the fed-in Cheetah Beam.
66+
:param energy: Reference energy of the Beam. Read from the fed-in Cheetah Beam.
6367
:return: A 7x7 Matrix for further calculations.
6468
"""
6569
raise NotImplementedError
@@ -1237,7 +1241,7 @@ def __repr__(self) -> str:
12371241
return (
12381242
f"{self.__class__.__name__}(length={repr(self.length)}, "
12391243
+ f"voltage={repr(self.voltage)}, "
1240-
+ f"phase={repr(self.voltage)}, "
1244+
+ f"phase={repr(self.phase)}, "
12411245
+ f"frequency={repr(self.frequency)}, "
12421246
+ f"name={repr(self.name)})"
12431247
)

cheetah/converters/dontbmad.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def validate_understood_properties(understood: list[str], properties: dict) -> N
426426
assert property in understood, (
427427
f"Property {property} with value {properties[property]} for element type"
428428
f" {properties['element_type']} is currently not understood. Other values"
429-
f" in properties are {properties.keys()}."
429+
f" in properties are {properties.keys()}." # noqa: B038
430430
)
431431

432432

cheetah/particles.py

+34-31
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def from_twiss(
6969
Create a beam from twiss parameters.
7070
7171
:param beta_x: Beta function in x direction in meters.
72-
:param alpha_x: Alpha function in x direction in meters.
73-
:param emittance_x: Emittance in x direction.
72+
:param alpha_x: Alpha function in x direction in rad.
73+
:param emittance_x: Emittance in x direction in m*rad.
7474
:param beta_y: Beta function in y direction in meters.
75-
:param alpha_y: Alpha function in y direction in meters.
76-
:param emittance_y: Emittance in y direction.
75+
:param alpha_y: Alpha function in y direction in rad.
76+
:param emittance_y: Emittance in y direction in m*rad.
7777
:param energy: Energy of the beam in eV.
7878
:param total_charge: Total charge of the beam in C.
7979
"""
@@ -110,15 +110,16 @@ def transformed_to(
110110
Create version of this beam that is transformed to new beam parameters.
111111
112112
:param mu_x: Center of the particle distribution on x in meters.
113-
:param mu_xp: Center of the particle distribution on px in meters.
113+
:param mu_xp: Center of the particle distribution on x' in rad.
114114
:param mu_y: Center of the particle distribution on y in meters.
115-
:param mu_yp: Center of the particle distribution on py in meters.
115+
:param mu_yp: Center of the particle distribution on y' in rad.
116116
:param sigma_x: Sigma of the particle distribution in x direction in meters.
117-
:param sigma_xp: Sigma of the particle distribution in px direction in meters.
117+
:param sigma_xp: Sigma of the particle distribution in x' direction in rad.
118118
:param sigma_y: Sigma of the particle distribution in y direction in meters.
119-
:param sigma_yp: Sigma of the particle distribution in py direction in meters.
119+
:param sigma_yp: Sigma of the particle distribution in y' direction in rad.
120120
:param sigma_s: Sigma of the particle distribution in s direction in meters.
121-
:param sigma_p: Sigma of the particle distribution in p direction in meters.
121+
:param sigma_p: Sigma of the particle distribution in p direction,
122+
dimensionless.
122123
:param energy: Energy of the beam in eV.
123124
:param total_charge: Total charge of the beam in C.
124125
"""
@@ -283,6 +284,7 @@ def beta_x(self) -> torch.Tensor:
283284

284285
@property
285286
def alpha_x(self) -> torch.Tensor:
287+
"""Alpha function in x direction in rad."""
286288
return -self.sigma_xxp / self.emittance_x
287289

288290
@property
@@ -307,6 +309,7 @@ def beta_y(self) -> torch.Tensor:
307309

308310
@property
309311
def alpha_y(self) -> torch.Tensor:
312+
"""Alpha function in y direction in rad."""
310313
return -self.sigma_yyp / self.emittance_y
311314

312315
def broadcast(self, shape: torch.Size) -> "Beam":
@@ -611,15 +614,15 @@ def transformed_to(
611614
612615
:param n: Number of particles to generate.
613616
:param mu_x: Center of the particle distribution on x in meters.
614-
:param mu_xp: Center of the particle distribution on px in meters.
617+
:param mu_xp: Center of the particle distribution on x' in rad.
615618
:param mu_y: Center of the particle distribution on y in meters.
616-
:param mu_yp: Center of the particle distribution on py in meters.
619+
:param mu_yp: Center of the particle distribution on y' in rad.
617620
:param sigma_x: Sigma of the particle distribution in x direction in meters.
618-
:param sigma_xp: Sigma of the particle distribution in px direction in meters.
621+
:param sigma_xp: Sigma of the particle distribution in x' direction in rad.
619622
:param sigma_y: Sigma of the particle distribution in y direction in meters.
620-
:param sigma_yp: Sigma of the particle distribution in py direction in meters.
623+
:param sigma_yp: Sigma of the particle distribution in y' direction in rad.
621624
:param sigma_s: Sigma of the particle distribution in s direction in meters.
622-
:param sigma_p: Sigma of the particle distribution in p direction in meters.
625+
:param sigma_p: Sigma of the particle distribution in p, dimensionless.
623626
:param energy: Energy of the beam in eV.
624627
:param total_charge: Total charge of the beam in C.
625628
"""
@@ -820,16 +823,16 @@ def from_parameters(
820823
:param num_particles: Number of particles to generate.
821824
:param mu_x: Center of the particle distribution on x in meters.
822825
:param mu_y: Center of the particle distribution on y in meters.
823-
:param mu_xp: Center of the particle distribution on px in meters.
824-
:param mu_yp: Center of the particle distribution on py in meters.
826+
:param mu_xp: Center of the particle distribution on x' in rad.
827+
:param mu_yp: Center of the particle distribution on y' in metraders.
825828
:param sigma_x: Sigma of the particle distribution in x direction in meters.
826829
:param sigma_y: Sigma of the particle distribution in y direction in meters.
827-
:param sigma_xp: Sigma of the particle distribution in px direction in meters.
828-
:param sigma_yp: Sigma of the particle distribution in py direction in meters.
830+
:param sigma_xp: Sigma of the particle distribution in x' direction in rad.
831+
:param sigma_yp: Sigma of the particle distribution in y' direction in rad.
829832
:param sigma_s: Sigma of the particle distribution in s direction in meters.
830-
:param sigma_p: Sigma of the particle distribution in p direction in meters.
831-
:param cor_x: Correlation between x and xp.
832-
:param cor_y: Correlation between y and yp.
833+
:param sigma_p: Sigma of the particle distribution in p, dimensionless.
834+
:param cor_x: Correlation between x and x'.
835+
:param cor_y: Correlation between y and y'.
833836
:param cor_s: Correlation between s and p.
834837
:param energy: Energy of the beam in eV.
835838
:total_charge: Total charge of the beam in C.
@@ -1041,14 +1044,14 @@ def make_linspaced(
10411044
:param n: Number of particles to generate.
10421045
:param mu_x: Center of the particle distribution on x in meters.
10431046
:param mu_y: Center of the particle distribution on y in meters.
1044-
:param mu_xp: Center of the particle distribution on px in meters.
1045-
:param mu_yp: Center of the particle distribution on py in meters.
1047+
:param mu_xp: Center of the particle distribution on x' in rad.
1048+
:param mu_yp: Center of the particle distribution on y' in rad.
10461049
:param sigma_x: Sigma of the particle distribution in x direction in meters.
10471050
:param sigma_y: Sigma of the particle distribution in y direction in meters.
1048-
:param sigma_xp: Sigma of the particle distribution in px direction in meters.
1049-
:param sigma_yp: Sigma of the particle distribution in py direction in meters.
1051+
:param sigma_xp: Sigma of the particle distribution in x' direction in rad.
1052+
:param sigma_yp: Sigma of the particle distribution in y' direction in rad.
10501053
:param sigma_s: Sigma of the particle distribution in s direction in meters.
1051-
:param sigma_p: Sigma of the particle distribution in p direction in meters.
1054+
:param sigma_p: Sigma of the particle distribution in p, dimensionless.
10521055
:param energy: Energy of the beam in eV.
10531056
:param device: Device to move the beam's particle array to. If set to `"auto"` a
10541057
CUDA GPU is selected if available. The CPU is used otherwise.
@@ -1232,14 +1235,14 @@ def transformed_to(
12321235
:param n: Number of particles to generate.
12331236
:param mu_x: Center of the particle distribution on x in meters.
12341237
:param mu_y: Center of the particle distribution on y in meters.
1235-
:param mu_xp: Center of the particle distribution on px in meters.
1236-
:param mu_yp: Center of the particle distribution on py in meters.
1238+
:param mu_xp: Center of the particle distribution on x' in rad.
1239+
:param mu_yp: Center of the particle distribution on y' in rad.
12371240
:param sigma_x: Sigma of the particle distribution in x direction in meters.
12381241
:param sigma_y: Sigma of the particle distribution in y direction in meters.
1239-
:param sigma_xp: Sigma of the particle distribution in px direction in meters.
1240-
:param sigma_yp: Sigma of the particle distribution in py direction in meters.
1242+
:param sigma_xp: Sigma of the particle distribution in x' direction in rad.
1243+
:param sigma_yp: Sigma of the particle distribution in y' direction in rad.
12411244
:param sigma_s: Sigma of the particle distribution in s direction in meters.
1242-
:param sigma_p: Sigma of the particle distribution in p direction in meters.
1245+
:param sigma_p: Sigma of the particle distribution in p, dimensionless.
12431246
:param energy: Energy of the beam in eV.
12441247
:param total_charge: Total charge of the beam in C.
12451248
:param device: Device to move the beam's particle array to. If set to `"auto"` a

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

docs/index.rst

+14-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Welcome to Cheetah's documentation!
1010

1111
GitHub repository: https://github.com/desy-ml/cheetah
1212

13-
Paper: https://accelconf.web.cern.ch/ipac2022/papers/wepoms036.pdf
13+
Paper: https://arxiv.org/abs/2401.05815
1414

1515

1616
Installation
@@ -61,18 +61,23 @@ For more advanced usage, please refer to the in-depth documentation.
6161
Cite Cheetah
6262
------------
6363

64-
To cite Cheetah in publications:
64+
If you use Cheetah, please cite the following two papers:
6565

6666
.. code-block:: bibtex
6767
68+
@misc{kaiser2024cheetah,
69+
title = {Cheetah: Bridging the Gap Between Machine Learning and Particle Accelerator Physics with High-Speed, Differentiable Simulations},
70+
author = {Kaiser, Jan and Xu, Chenran and Eichler, Annika and {Santamaria Garcia}, Andrea},
71+
year = {2024},
72+
eprint = {2401.05815},
73+
archiveprefix = {arXiv},
74+
primaryclass = {physics.acc-ph}
75+
}
6876
@inproceedings{stein2022accelerating,
69-
author = {Stein, Oliver and
70-
Kaiser, Jan and
71-
Eichler, Annika},
72-
title = {Accelerating Linear Beam Dynamics Simulations for Machine Learning Applications},
73-
booktitle = {Proceedings of the 13th International Particle Accelerator Conference},
74-
year = {2022},
75-
url = {https://github.com/desy-ml/cheetah},
77+
title = {Accelerating Linear Beam Dynamics Simulations for Machine Learning Applications},
78+
author = {Stein, Oliver and Kaiser, Jan and Eichler, Annika},
79+
year = {2022},
80+
booktitle = {Proceedings of the 13th International Particle Accelerator Conference}
7681
}
7782
7883
For Developers

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)