simplestoragering 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. simplestoragering-0.0.1/LICENSE +21 -0
  2. simplestoragering-0.0.1/PKG-INFO +167 -0
  3. simplestoragering-0.0.1/README.md +126 -0
  4. simplestoragering-0.0.1/pyproject.toml +26 -0
  5. simplestoragering-0.0.1/setup.cfg +4 -0
  6. simplestoragering-0.0.1/simplestoragering/CSLattice.c +58650 -0
  7. simplestoragering-0.0.1/simplestoragering/Drift.c +15313 -0
  8. simplestoragering-0.0.1/simplestoragering/DrivingTerms.py +666 -0
  9. simplestoragering-0.0.1/simplestoragering/DynamicAperture.py +311 -0
  10. simplestoragering-0.0.1/simplestoragering/HBend.c +19569 -0
  11. simplestoragering-0.0.1/simplestoragering/Octupole.c +17047 -0
  12. simplestoragering-0.0.1/simplestoragering/Quadrupole.c +16610 -0
  13. simplestoragering-0.0.1/simplestoragering/Sextupole.c +17176 -0
  14. simplestoragering-0.0.1/simplestoragering/__init__.py +43 -0
  15. simplestoragering-0.0.1/simplestoragering/c_functions.c +8330 -0
  16. simplestoragering-0.0.1/simplestoragering/components.c +23400 -0
  17. simplestoragering-0.0.1/simplestoragering/exceptions.py +26 -0
  18. simplestoragering-0.0.1/simplestoragering/functions.py +241 -0
  19. simplestoragering-0.0.1/simplestoragering/globalvars.c +7697 -0
  20. simplestoragering-0.0.1/simplestoragering/line_matrix.c +11292 -0
  21. simplestoragering-0.0.1/simplestoragering/objectives.py +44 -0
  22. simplestoragering-0.0.1/simplestoragering/plotlib.py +512 -0
  23. simplestoragering-0.0.1/simplestoragering/track.c +34274 -0
  24. simplestoragering-0.0.1/simplestoragering.egg-info/PKG-INFO +167 -0
  25. simplestoragering-0.0.1/simplestoragering.egg-info/SOURCES.txt +26 -0
  26. simplestoragering-0.0.1/simplestoragering.egg-info/dependency_links.txt +1 -0
  27. simplestoragering-0.0.1/simplestoragering.egg-info/requires.txt +2 -0
  28. simplestoragering-0.0.1/simplestoragering.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Wei, Bingfeng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.1
2
+ Name: simplestoragering
3
+ Version: 0.0.1
4
+ Summary: simple storage ring for single particle dynamics simulation.
5
+ Author-email: Bingfeng WEI <wbf2016@mail.ustc.edu.cn>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2021 Wei, Bingfeng
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/wei0852/simplestoragering
29
+ Project-URL: Repository, https://github.com/wei0852/simplestoragering.git
30
+ Project-URL: Issues, https://github.com/wei0852/simplestoragering/issues
31
+ Classifier: Development Status :: 4 - Beta
32
+ Classifier: Operating System :: OS Independent
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Cython
35
+ Classifier: Programming Language :: Python :: 3
36
+ Requires-Python: >=3.8
37
+ Description-Content-Type: text/markdown
38
+ License-File: LICENSE
39
+ Requires-Dist: numpy>1.18.0
40
+ Requires-Dist: matplotlib>3.4.0
41
+
42
+ # SimpleStorageRing
43
+ SimpleStorageRing is a python project to simulate simple storage ring and calculate lattice data.
44
+
45
+ You can sort the components to generate a ring, and then calculate the data of storage ring by Courant-Snyder method.
46
+
47
+ ----------------------
48
+ The code is written in Cython, must be compiled first:
49
+ ```command
50
+ python setup.py build_ext --inplace
51
+ ```
52
+ reference: http://docs.cython.org/en/stable/src/quickstart/build.html
53
+
54
+ ## reference particle
55
+ set reference particle (electron) energy first:
56
+
57
+ ```
58
+ set_ref_energy(energy_MeV: float)
59
+ ```
60
+ or
61
+ ```
62
+ set_ref_gamma(gamma: float)
63
+ ```
64
+ ## components
65
+ A storage ring consists of many magnets to guide electron beam,
66
+
67
+ * `Mark(name: str)`
68
+ * `Drift(name: str, length: float, Ax: float = 10, Ay: float = 10)`
69
+ * `HBend(name: str, length: float, theta: float, theta_in: float, theta_out: float, k1: float = 0, gap: float = 0, fint_in: float = 0.5, fint_out: float = 0.5, Ax: float = 10, Ay: float = 10))`, horizontal bend.
70
+ * `Quadrupole(name: str, length: float, k1: float, Ax: float = 10, Ay: float = 10)`
71
+ * `Sextupole(name: str, length: float, k2: float = 0, n_slices: int = 4, Ax: float = 10, Ay: float = 10)`
72
+ * `Octupole(name: str = None, length: float = 0, k3: float = 0, n_slices: int = 1, Ax: float = 10, Ay: float = 10)`
73
+
74
+ $k_n = \dfrac{q}{P_0} \dfrac{\partial^n B_y}{\partial x^n}$. All the components are child classes of the Element class.
75
+
76
+ Attributes:
77
+
78
+ * magnet data
79
+ * name: str,
80
+ * length: float,
81
+ * h: float, curvature of the reference trajectory.
82
+ * theta_in, theta_out: float, edge angle of bend.
83
+ * k1, k2, k3: float, multipole strength.
84
+ * Ax, Ay: float, aperture.
85
+ * n_slices: int, slice magnets for RDTs calculation and particle tracking.
86
+ * matrix: 6x6 np.ndarray, transport matrix.
87
+ * data about beam and lattice.
88
+ * s: float, location in a line or ring.
89
+ * closed_orbit: list[6]
90
+ * betax, alphax, gammax, psix, betay, alphay, gammay, psiy, etax, etaxp, etay, etayp: float, twiss parameters and dispersion.
91
+ * nux, nuy: float, psix / 2$\pi$, psiy / 2$\pi$
92
+ * curl_H: float, dispersion H-function (curly-H function) $\mathcal{H}_x=\gamma_x \eta_x^2 + 2\alpha_x \eta_x \eta_x' + \beta_x\eta_x'^2$.
93
+
94
+ and methods:
95
+
96
+ * copy(), return a same component without data about beam or lattice.
97
+ * slice(n_slices: int) -> list[Elements]
98
+ * linear_optics() -> np.array([i1, i2, i3, i4, i5, xix, xiy]),
99
+ np.array([betax, alphax, gammax, betay, alphay, gammay, etax, etaxp, etay, etayp, psix, psiy])
100
+
101
+ ## Courant-Snyder lattice
102
+ `CSLattice(ele_list: list[Element], n_periods: int, coupling: float=0.0)`, lattice solved by cs method.
103
+
104
+ Attributes:
105
+ * length: float
106
+ * n_periods: int, number of periods
107
+ * angle, abs_angle: float
108
+ * elements: list of Elements
109
+ * mark: Dictionary of Mark in lattice. The key is the name of Mark, and the value is a list of Mark with the same name.
110
+ * initialize twiss
111
+ * twiss_x0, twiss_y0: np.ndarray, [$\beta$, $\alpha$, $\gamma$]
112
+ * eta_x0, eta_y0: np.ndarray, [$\eta$, $\eta'$]. eta_y0=[0,0] because the coupled motion has not be considered yet.
113
+ * nux, nuy: Tunes
114
+ * xi_x, xi_y: Chromaticities (Calculated with linear model. use track_chromaticity for more accurate results.).
115
+ * natural_xi_x, natural_xi_y: Natural chromaticities
116
+ * I1, I2, I3, I4, I5: radiation integrals.
117
+ * Jx, Jy, Js: horizontal / vertical / longitudinal damping partition number
118
+ * sigma_e: natural energy spread
119
+ * emittance: natural emittance
120
+ * U0: energy loss [MeV]
121
+ * f_c: frequency
122
+ * tau_s, tau_x, tau_y: longitudinal / horizontal / vertical damping time
123
+ * alpha: Momentum compaction
124
+ * etap: phase slip factor
125
+
126
+ Methods:
127
+ * set_initial_twiss(betax, alphax, betay, alphay, etax, etaxp, etay, etayp)
128
+
129
+ If periodic solutions are not used ( linear_optics(periodicity=False) ).
130
+ * linear_optics(periodicity=True, line_mode=False)
131
+ * driving_terms(verbose=True)
132
+ * adts(verbose=True)
133
+ * track_chromaticity(order=2, verbose=True, delta=None, matrix_precision=1e-9, resdl_limit=1e-12)
134
+
135
+ compute chromaticities using the tunes of 4d off-momentum closed orbit.
136
+ * slice_elements(drift_maxlength=10.0, bend_maxlength=10.0, quad_maxlength=10.0, sext_maxlength=10.0)
137
+ * output_twiss(file_name: str = u'twiss_data.txt')
138
+
139
+ ## Functions
140
+
141
+ `symplectic_track(particle, lattice, n_turns: int, record = True)`
142
+
143
+ `track_4d_closed_orbit(lattice: CSLattice, delta, resdl_limit=1e-16, matrix_precision=1e-9)`
144
+
145
+ `output_opa_file(lattice: CSLattice, file_name=None)`
146
+
147
+ `output_elegant_file(lattice: CSLattice, filename=None, new_version=True)`
148
+
149
+ `chromaticity_correction(lattice: CSLattice, sextupole_name_list: list, target: list=None, initial_k2=None, update_sext=True, verbose=True)`
150
+
151
+ ## DA & LMA
152
+
153
+ * XYGrid()
154
+ * XDeltaGrid()
155
+ * NLine()
156
+ * LocalMomentumAperture()
157
+
158
+ and some functions:
159
+
160
+ `plot_layout_in_ax(ele_list: list, ax: Axes, ratio=0.03)`
161
+
162
+ `plot_resonance_line_in_ax(ax: Axes, order: int = 3, refnux: float=None, refnuy: float=None)`
163
+
164
+ `plot_lattice(ele_list, parameter: str or list[str], with_layout=True)`
165
+
166
+ or use `get_col(ele_list, parameter)` to get a column of the parameter along the element list.
167
+
@@ -0,0 +1,126 @@
1
+ # SimpleStorageRing
2
+ SimpleStorageRing is a python project to simulate simple storage ring and calculate lattice data.
3
+
4
+ You can sort the components to generate a ring, and then calculate the data of storage ring by Courant-Snyder method.
5
+
6
+ ----------------------
7
+ The code is written in Cython, must be compiled first:
8
+ ```command
9
+ python setup.py build_ext --inplace
10
+ ```
11
+ reference: http://docs.cython.org/en/stable/src/quickstart/build.html
12
+
13
+ ## reference particle
14
+ set reference particle (electron) energy first:
15
+
16
+ ```
17
+ set_ref_energy(energy_MeV: float)
18
+ ```
19
+ or
20
+ ```
21
+ set_ref_gamma(gamma: float)
22
+ ```
23
+ ## components
24
+ A storage ring consists of many magnets to guide electron beam,
25
+
26
+ * `Mark(name: str)`
27
+ * `Drift(name: str, length: float, Ax: float = 10, Ay: float = 10)`
28
+ * `HBend(name: str, length: float, theta: float, theta_in: float, theta_out: float, k1: float = 0, gap: float = 0, fint_in: float = 0.5, fint_out: float = 0.5, Ax: float = 10, Ay: float = 10))`, horizontal bend.
29
+ * `Quadrupole(name: str, length: float, k1: float, Ax: float = 10, Ay: float = 10)`
30
+ * `Sextupole(name: str, length: float, k2: float = 0, n_slices: int = 4, Ax: float = 10, Ay: float = 10)`
31
+ * `Octupole(name: str = None, length: float = 0, k3: float = 0, n_slices: int = 1, Ax: float = 10, Ay: float = 10)`
32
+
33
+ $k_n = \dfrac{q}{P_0} \dfrac{\partial^n B_y}{\partial x^n}$. All the components are child classes of the Element class.
34
+
35
+ Attributes:
36
+
37
+ * magnet data
38
+ * name: str,
39
+ * length: float,
40
+ * h: float, curvature of the reference trajectory.
41
+ * theta_in, theta_out: float, edge angle of bend.
42
+ * k1, k2, k3: float, multipole strength.
43
+ * Ax, Ay: float, aperture.
44
+ * n_slices: int, slice magnets for RDTs calculation and particle tracking.
45
+ * matrix: 6x6 np.ndarray, transport matrix.
46
+ * data about beam and lattice.
47
+ * s: float, location in a line or ring.
48
+ * closed_orbit: list[6]
49
+ * betax, alphax, gammax, psix, betay, alphay, gammay, psiy, etax, etaxp, etay, etayp: float, twiss parameters and dispersion.
50
+ * nux, nuy: float, psix / 2$\pi$, psiy / 2$\pi$
51
+ * curl_H: float, dispersion H-function (curly-H function) $\mathcal{H}_x=\gamma_x \eta_x^2 + 2\alpha_x \eta_x \eta_x' + \beta_x\eta_x'^2$.
52
+
53
+ and methods:
54
+
55
+ * copy(), return a same component without data about beam or lattice.
56
+ * slice(n_slices: int) -> list[Elements]
57
+ * linear_optics() -> np.array([i1, i2, i3, i4, i5, xix, xiy]),
58
+ np.array([betax, alphax, gammax, betay, alphay, gammay, etax, etaxp, etay, etayp, psix, psiy])
59
+
60
+ ## Courant-Snyder lattice
61
+ `CSLattice(ele_list: list[Element], n_periods: int, coupling: float=0.0)`, lattice solved by cs method.
62
+
63
+ Attributes:
64
+ * length: float
65
+ * n_periods: int, number of periods
66
+ * angle, abs_angle: float
67
+ * elements: list of Elements
68
+ * mark: Dictionary of Mark in lattice. The key is the name of Mark, and the value is a list of Mark with the same name.
69
+ * initialize twiss
70
+ * twiss_x0, twiss_y0: np.ndarray, [$\beta$, $\alpha$, $\gamma$]
71
+ * eta_x0, eta_y0: np.ndarray, [$\eta$, $\eta'$]. eta_y0=[0,0] because the coupled motion has not be considered yet.
72
+ * nux, nuy: Tunes
73
+ * xi_x, xi_y: Chromaticities (Calculated with linear model. use track_chromaticity for more accurate results.).
74
+ * natural_xi_x, natural_xi_y: Natural chromaticities
75
+ * I1, I2, I3, I4, I5: radiation integrals.
76
+ * Jx, Jy, Js: horizontal / vertical / longitudinal damping partition number
77
+ * sigma_e: natural energy spread
78
+ * emittance: natural emittance
79
+ * U0: energy loss [MeV]
80
+ * f_c: frequency
81
+ * tau_s, tau_x, tau_y: longitudinal / horizontal / vertical damping time
82
+ * alpha: Momentum compaction
83
+ * etap: phase slip factor
84
+
85
+ Methods:
86
+ * set_initial_twiss(betax, alphax, betay, alphay, etax, etaxp, etay, etayp)
87
+
88
+ If periodic solutions are not used ( linear_optics(periodicity=False) ).
89
+ * linear_optics(periodicity=True, line_mode=False)
90
+ * driving_terms(verbose=True)
91
+ * adts(verbose=True)
92
+ * track_chromaticity(order=2, verbose=True, delta=None, matrix_precision=1e-9, resdl_limit=1e-12)
93
+
94
+ compute chromaticities using the tunes of 4d off-momentum closed orbit.
95
+ * slice_elements(drift_maxlength=10.0, bend_maxlength=10.0, quad_maxlength=10.0, sext_maxlength=10.0)
96
+ * output_twiss(file_name: str = u'twiss_data.txt')
97
+
98
+ ## Functions
99
+
100
+ `symplectic_track(particle, lattice, n_turns: int, record = True)`
101
+
102
+ `track_4d_closed_orbit(lattice: CSLattice, delta, resdl_limit=1e-16, matrix_precision=1e-9)`
103
+
104
+ `output_opa_file(lattice: CSLattice, file_name=None)`
105
+
106
+ `output_elegant_file(lattice: CSLattice, filename=None, new_version=True)`
107
+
108
+ `chromaticity_correction(lattice: CSLattice, sextupole_name_list: list, target: list=None, initial_k2=None, update_sext=True, verbose=True)`
109
+
110
+ ## DA & LMA
111
+
112
+ * XYGrid()
113
+ * XDeltaGrid()
114
+ * NLine()
115
+ * LocalMomentumAperture()
116
+
117
+ and some functions:
118
+
119
+ `plot_layout_in_ax(ele_list: list, ax: Axes, ratio=0.03)`
120
+
121
+ `plot_resonance_line_in_ax(ax: Axes, order: int = 3, refnux: float=None, refnuy: float=None)`
122
+
123
+ `plot_lattice(ele_list, parameter: str or list[str], with_layout=True)`
124
+
125
+ or use `get_col(ele_list, parameter)` to get a column of the parameter along the element list.
126
+
@@ -0,0 +1,26 @@
1
+ [project]
2
+ name = "simplestoragering"
3
+ version = "0.0.1"
4
+ authors = [
5
+ { name="Bingfeng WEI", email="wbf2016@mail.ustc.edu.cn" },
6
+ ]
7
+ description = "simple storage ring for single particle dynamics simulation."
8
+ readme = "README.md"
9
+ requires-python = ">=3.8"
10
+ dependencies = [
11
+ "numpy>1.18.0",
12
+ "matplotlib>3.4.0",
13
+ ]
14
+ license = {file = "LICENSE"}
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Operating System :: OS Independent",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Cython",
20
+ "Programming Language :: Python :: 3",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/wei0852/simplestoragering"
25
+ Repository = "https://github.com/wei0852/simplestoragering.git"
26
+ Issues = "https://github.com/wei0852/simplestoragering/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+