syned 1.0.33__tar.gz → 1.0.35__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 (74) hide show
  1. {syned-1.0.33/syned.egg-info → syned-1.0.35}/PKG-INFO +1 -1
  2. {syned-1.0.33 → syned-1.0.35}/setup.py +1 -1
  3. {syned-1.0.33 → syned-1.0.35}/syned/version.py +3 -3
  4. {syned-1.0.33 → syned-1.0.35/syned.egg-info}/PKG-INFO +1 -1
  5. {syned-1.0.33 → syned-1.0.35}/syned.egg-info/SOURCES.txt +0 -13
  6. syned-1.0.33/syned/tools/__init__.py +0 -46
  7. syned-1.0.33/syned/tools/benders/__init__.py +0 -46
  8. syned-1.0.33/syned/tools/benders/aps_bendable_ellipsoid_mirror.py +0 -280
  9. syned-1.0.33/syned/tools/benders/bender_data_to_plot.py +0 -66
  10. syned-1.0.33/syned/tools/benders/double_rod_bendable_ellispoid_mirror.py +0 -279
  11. syned-1.0.33/syned/tools/diaboloid/__init__.py +0 -46
  12. syned-1.0.33/syned/tools/diaboloid/diaboloid_calculator.py +0 -467
  13. syned-1.0.33/syned/tools/diaboloid/fqs.py +0 -542
  14. syned-1.0.33/syned/tools/error_profile/__init__.py +0 -46
  15. syned-1.0.33/syned/tools/error_profile/error_profile_calculator.py +0 -581
  16. syned-1.0.33/syned/tools/hybrid_beam/__init__.py +0 -46
  17. syned-1.0.33/syned/tools/hybrid_undulator/__init__.py +0 -46
  18. syned-1.0.33/syned/tools/thermal_load/__init__.py +0 -46
  19. {syned-1.0.33 → syned-1.0.35}/LICENSE +0 -0
  20. {syned-1.0.33 → syned-1.0.35}/MANIFEST.in +0 -0
  21. {syned-1.0.33 → syned-1.0.35}/README.rst +0 -0
  22. {syned-1.0.33 → syned-1.0.35}/examples/__init__.py +0 -0
  23. {syned-1.0.33 → syned-1.0.35}/examples/example_beamline.py +0 -0
  24. {syned-1.0.33 → syned-1.0.35}/examples/example_double_slit.py +0 -0
  25. {syned-1.0.33 → syned-1.0.35}/examples/example_json_input_output.py +0 -0
  26. {syned-1.0.33 → syned-1.0.35}/setup.cfg +0 -0
  27. {syned-1.0.33 → syned-1.0.35}/syned/__init__.py +0 -0
  28. {syned-1.0.33 → syned-1.0.35}/syned/beamline/__init__.py +0 -0
  29. {syned-1.0.33 → syned-1.0.35}/syned/beamline/beamline.py +0 -0
  30. {syned-1.0.33 → syned-1.0.35}/syned/beamline/beamline_element.py +0 -0
  31. {syned-1.0.33 → syned-1.0.35}/syned/beamline/element_coordinates.py +0 -0
  32. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_element.py +0 -0
  33. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_element_with_surface_shape.py +0 -0
  34. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/__init__.py +0 -0
  35. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/absorbers/__init__.py +0 -0
  36. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/absorbers/absorber.py +0 -0
  37. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/absorbers/beam_stopper.py +0 -0
  38. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/absorbers/filter.py +0 -0
  39. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/absorbers/holed_filter.py +0 -0
  40. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/absorbers/slit.py +0 -0
  41. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/crystals/__init__.py +0 -0
  42. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/crystals/crystal.py +0 -0
  43. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/gratings/__init__.py +0 -0
  44. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/gratings/grating.py +0 -0
  45. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/ideal_elements/__init__.py +0 -0
  46. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/ideal_elements/ideal_element.py +0 -0
  47. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/ideal_elements/ideal_lens.py +0 -0
  48. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/ideal_elements/screen.py +0 -0
  49. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/mirrors/__init__.py +0 -0
  50. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/mirrors/mirror.py +0 -0
  51. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/refractors/__init__.py +0 -0
  52. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/refractors/crl.py +0 -0
  53. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/refractors/interface.py +0 -0
  54. {syned-1.0.33 → syned-1.0.35}/syned/beamline/optical_elements/refractors/lens.py +0 -0
  55. {syned-1.0.33 → syned-1.0.35}/syned/beamline/shape.py +0 -0
  56. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/__init__.py +0 -0
  57. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/electron_beam.py +0 -0
  58. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/empty_light_source.py +0 -0
  59. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/light_source.py +0 -0
  60. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/magnetic_structure.py +0 -0
  61. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/magnetic_structures/__init__.py +0 -0
  62. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/magnetic_structures/bending_magnet.py +0 -0
  63. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/magnetic_structures/insertion_device.py +0 -0
  64. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/magnetic_structures/undulator.py +0 -0
  65. {syned-1.0.33 → syned-1.0.35}/syned/storage_ring/magnetic_structures/wiggler.py +0 -0
  66. {syned-1.0.33 → syned-1.0.35}/syned/syned_object.py +0 -0
  67. {syned-1.0.33 → syned-1.0.35}/syned/util/__init__.py +0 -0
  68. {syned-1.0.33 → syned-1.0.35}/syned/util/json_tools.py +0 -0
  69. {syned-1.0.33 → syned-1.0.35}/syned/widget/__init__.py +0 -0
  70. {syned-1.0.33 → syned-1.0.35}/syned/widget/widget_decorator.py +0 -0
  71. {syned-1.0.33 → syned-1.0.35}/syned.egg-info/dependency_links.txt +0 -0
  72. {syned-1.0.33 → syned-1.0.35}/syned.egg-info/not-zip-safe +0 -0
  73. {syned-1.0.33 → syned-1.0.35}/syned.egg-info/requires.txt +0 -0
  74. {syned-1.0.33 → syned-1.0.35}/syned.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: syned
3
- Version: 1.0.33
3
+ Version: 1.0.35
4
4
  Summary: SYNED (SYNchrotron Elements Dictionary) kernel library
5
5
  Home-page: https://github.com/oasys-kit/syned
6
6
  Download-URL: https://github.com/oasys-kit/syned
@@ -11,7 +11,7 @@ except AttributeError:
11
11
 
12
12
  NAME = 'syned'
13
13
 
14
- VERSION = '1.0.33'
14
+ VERSION = '1.0.35'
15
15
  ISRELEASED = True
16
16
 
17
17
  DESCRIPTION = 'SYNED (SYNchrotron Elements Dictionary) kernel library'
@@ -1,8 +1,8 @@
1
1
 
2
2
  # THIS FILE IS GENERATED FROM syned SETUP.PY
3
- short_version = '1.0.33'
4
- version = '1.0.33'
5
- full_version = '1.0.33'
3
+ short_version = '1.0.35'
4
+ version = '1.0.35'
5
+ full_version = '1.0.35'
6
6
  git_revision = ''
7
7
  release = True
8
8
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: syned
3
- Version: 1.0.33
3
+ Version: 1.0.35
4
4
  Summary: SYNED (SYNchrotron Elements Dictionary) kernel library
5
5
  Home-page: https://github.com/oasys-kit/syned
6
6
  Download-URL: https://github.com/oasys-kit/syned
@@ -53,19 +53,6 @@ syned/storage_ring/magnetic_structures/bending_magnet.py
53
53
  syned/storage_ring/magnetic_structures/insertion_device.py
54
54
  syned/storage_ring/magnetic_structures/undulator.py
55
55
  syned/storage_ring/magnetic_structures/wiggler.py
56
- syned/tools/__init__.py
57
- syned/tools/benders/__init__.py
58
- syned/tools/benders/aps_bendable_ellipsoid_mirror.py
59
- syned/tools/benders/bender_data_to_plot.py
60
- syned/tools/benders/double_rod_bendable_ellispoid_mirror.py
61
- syned/tools/diaboloid/__init__.py
62
- syned/tools/diaboloid/diaboloid_calculator.py
63
- syned/tools/diaboloid/fqs.py
64
- syned/tools/error_profile/__init__.py
65
- syned/tools/error_profile/error_profile_calculator.py
66
- syned/tools/hybrid_beam/__init__.py
67
- syned/tools/hybrid_undulator/__init__.py
68
- syned/tools/thermal_load/__init__.py
69
56
  syned/util/__init__.py
70
57
  syned/util/json_tools.py
71
58
  syned/widget/__init__.py
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # ----------------------------------------------------------------------- #
4
- # Copyright (c) 2023, UChicago Argonne, LLC. All rights reserved. #
5
- # #
6
- # Copyright 2023. UChicago Argonne, LLC. This software was produced #
7
- # under U.S. Government contract DE-AC02-06CH11357 for Argonne National #
8
- # Laboratory (ANL), which is operated by UChicago Argonne, LLC for the #
9
- # U.S. Department of Energy. The U.S. Government has rights to use, #
10
- # reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR #
11
- # UChicago Argonne, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR #
12
- # ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is #
13
- # modified to produce derivative works, such modified software should #
14
- # be clearly marked, so as not to confuse it with the version available #
15
- # from ANL. #
16
- # #
17
- # Additionally, redistribution and use in source and binary forms, with #
18
- # or without modification, are permitted provided that the following #
19
- # conditions are met: #
20
- # #
21
- # * Redistributions of source code must retain the above copyright #
22
- # notice, this list of conditions and the following disclaimer. #
23
- # #
24
- # * Redistributions in binary form must reproduce the above copyright #
25
- # notice, this list of conditions and the following disclaimer in #
26
- # the documentation and/or other materials provided with the #
27
- # distribution. #
28
- # #
29
- # * Neither the name of UChicago Argonne, LLC, Argonne National #
30
- # Laboratory, ANL, the U.S. Government, nor the names of its #
31
- # contributors may be used to endorse or promote products derived #
32
- # from this software without specific prior written permission. #
33
- # #
34
- # THIS SOFTWARE IS PROVIDED BY UChicago Argonne, LLC AND CONTRIBUTORS #
35
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #
36
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS #
37
- # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UChicago #
38
- # Argonne, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, #
39
- # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, #
40
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; #
41
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
42
- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT #
43
- # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN #
44
- # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
45
- # POSSIBILITY OF SUCH DAMAGE. #
46
- # ----------------------------------------------------------------------- #
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # ----------------------------------------------------------------------- #
4
- # Copyright (c) 2023, UChicago Argonne, LLC. All rights reserved. #
5
- # #
6
- # Copyright 2023. UChicago Argonne, LLC. This software was produced #
7
- # under U.S. Government contract DE-AC02-06CH11357 for Argonne National #
8
- # Laboratory (ANL), which is operated by UChicago Argonne, LLC for the #
9
- # U.S. Department of Energy. The U.S. Government has rights to use, #
10
- # reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR #
11
- # UChicago Argonne, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR #
12
- # ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is #
13
- # modified to produce derivative works, such modified software should #
14
- # be clearly marked, so as not to confuse it with the version available #
15
- # from ANL. #
16
- # #
17
- # Additionally, redistribution and use in source and binary forms, with #
18
- # or without modification, are permitted provided that the following #
19
- # conditions are met: #
20
- # #
21
- # * Redistributions of source code must retain the above copyright #
22
- # notice, this list of conditions and the following disclaimer. #
23
- # #
24
- # * Redistributions in binary form must reproduce the above copyright #
25
- # notice, this list of conditions and the following disclaimer in #
26
- # the documentation and/or other materials provided with the #
27
- # distribution. #
28
- # #
29
- # * Neither the name of UChicago Argonne, LLC, Argonne National #
30
- # Laboratory, ANL, the U.S. Government, nor the names of its #
31
- # contributors may be used to endorse or promote products derived #
32
- # from this software without specific prior written permission. #
33
- # #
34
- # THIS SOFTWARE IS PROVIDED BY UChicago Argonne, LLC AND CONTRIBUTORS #
35
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #
36
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS #
37
- # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UChicago #
38
- # Argonne, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, #
39
- # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, #
40
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; #
41
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
42
- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT #
43
- # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN #
44
- # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
45
- # POSSIBILITY OF SUCH DAMAGE. #
46
- # ----------------------------------------------------------------------- #
@@ -1,280 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # ----------------------------------------------------------------------- #
4
- # Copyright (c) 2023, UChicago Argonne, LLC. All rights reserved. #
5
- # #
6
- # Copyright 2023. UChicago Argonne, LLC. This software was produced #
7
- # under U.S. Government contract DE-AC02-06CH11357 for Argonne National #
8
- # Laboratory (ANL), which is operated by UChicago Argonne, LLC for the #
9
- # U.S. Department of Energy. The U.S. Government has rights to use, #
10
- # reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR #
11
- # UChicago Argonne, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR #
12
- # ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is #
13
- # modified to produce derivative works, such modified software should #
14
- # be clearly marked, so as not to confuse it with the version available #
15
- # from ANL. #
16
- # #
17
- # Additionally, redistribution and use in source and binary forms, with #
18
- # or without modification, are permitted provided that the following #
19
- # conditions are met: #
20
- # #
21
- # * Redistributions of source code must retain the above copyright #
22
- # notice, this list of conditions and the following disclaimer. #
23
- # #
24
- # * Redistributions in binary form must reproduce the above copyright #
25
- # notice, this list of conditions and the following disclaimer in #
26
- # the documentation and/or other materials provided with the #
27
- # distribution. #
28
- # #
29
- # * Neither the name of UChicago Argonne, LLC, Argonne National #
30
- # Laboratory, ANL, the U.S. Government, nor the names of its #
31
- # contributors may be used to endorse or promote products derived #
32
- # from this software without specific prior written permission. #
33
- # #
34
- # THIS SOFTWARE IS PROVIDED BY UChicago Argonne, LLC AND CONTRIBUTORS #
35
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #
36
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS #
37
- # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UChicago #
38
- # Argonne, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, #
39
- # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, #
40
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; #
41
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
42
- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT #
43
- # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN #
44
- # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
45
- # POSSIBILITY OF SUCH DAMAGE. #
46
- # ----------------------------------------------------------------------- #
47
- import numpy
48
- from scipy.interpolate import interp2d
49
- from scipy.optimize import curve_fit
50
-
51
- from syned.tools.benders.bender_data_to_plot import BenderDataToPlot
52
-
53
- TRAPEZIUM = 0
54
- RECTANGLE = 1
55
-
56
- SINGLE_MOMENTUM = 0
57
- DOUBLE_MOMENTUM = 1
58
-
59
- class ApsBenderParameters:
60
- dim_x_minus = None
61
- dim_x_plus = None
62
- bender_bin_x = None
63
- dim_y_minus = None
64
- dim_y_plus = None
65
- bender_bin_y = None
66
- conic_coefficients = None
67
-
68
- optimized_length = None
69
- n_fit_steps = None
70
-
71
- E = None
72
- h = None
73
- shape = None
74
- kind_of_bender = None
75
-
76
- M1 = None
77
- M1_min = None
78
- M1_max = None
79
- M1_fixed = None
80
-
81
- e = None
82
- e_min = None
83
- e_max = None
84
- e_fixed = None
85
-
86
- ratio = None
87
- ratio_min = None
88
- ratio_max = None
89
- ratio_fixed = None
90
-
91
- workspace_units_to_m = None
92
-
93
- figure_error = None
94
-
95
-
96
- def calculate_ideal_surface(bender_parameters : ApsBenderParameters, sign=-1):
97
- x = numpy.linspace(-bender_parameters.dim_x_minus, bender_parameters.dim_x_plus, bender_parameters.bender_bin_x + 1)
98
- y = numpy.linspace(-bender_parameters.dim_y_minus, bender_parameters.dim_y_plus, bender_parameters.bender_bin_y + 1)
99
-
100
- c1 = round(bender_parameters.conic_coefficients[0], 10)
101
- c2 = round(bender_parameters.conic_coefficients[1], 10)
102
- c3 = round(bender_parameters.conic_coefficients[2], 10)
103
- c4 = round(bender_parameters.conic_coefficients[3], 10)
104
- c5 = round(bender_parameters.conic_coefficients[4], 10)
105
- c6 = round(bender_parameters.conic_coefficients[5], 10)
106
- c7 = round(bender_parameters.conic_coefficients[6], 10)
107
- c8 = round(bender_parameters.conic_coefficients[7], 10)
108
- c9 = round(bender_parameters.conic_coefficients[8], 10)
109
- c10 = round(bender_parameters.conic_coefficients[9], 10)
110
-
111
- xx, yy = numpy.meshgrid(x, y)
112
-
113
- c = c1 * (xx ** 2) + c2 * (yy ** 2) + c4 * xx * yy + c7 * xx + c8 * yy + c10
114
- b = c5 * yy + c6 * xx + c9
115
- a = c3
116
-
117
- z = (-b + sign * numpy.sqrt(b ** 2 - 4 * a * c)) / (2 * a)
118
- z[b ** 2 - 4 * a * c < 0] = numpy.nan
119
-
120
- return x, y, z.T
121
-
122
- def calculate_bender_correction(bender_parameters : ApsBenderParameters):
123
- x, y, z = calculate_ideal_surface(bender_parameters)
124
-
125
- E = bender_parameters.E
126
- h = bender_parameters.h
127
- shape = bender_parameters.shape
128
- kind_of_bender = bender_parameters.kind_of_bender
129
-
130
- optimized_length = bender_parameters.optimized_length
131
-
132
- n_fit_steps = bender_parameters.n_fit_steps
133
- workspace_units_to_m = bender_parameters.workspace_units_to_m
134
-
135
- b0 = bender_parameters.dim_x_plus + bender_parameters.dim_x_minus
136
- L = bender_parameters.dim_y_plus + bender_parameters.dim_y_minus # add optimization length
137
-
138
- # flip the coordinate system to be consistent with Mike's formulas
139
- ideal_profile = z[0, :][::-1] # one row is the profile of the cylinder, enough for the minimizer
140
- ideal_profile += -ideal_profile[0] + ((L / 2 + y) * (ideal_profile[0] - ideal_profile[-1])) / L # Rotation
141
-
142
- if bender_parameters.optimized_length is None:
143
- y_fit = y
144
- ideal_profile_fit = ideal_profile
145
- else:
146
- cursor = numpy.where(numpy.logical_and(y >= -optimized_length / 2, y <= optimized_length / 2))
147
- y_fit = y[cursor]
148
- ideal_profile_fit = ideal_profile[cursor]
149
-
150
- epsilon_minus = 1 - 1e-8
151
- epsilon_plus = 1 + 1e-8
152
-
153
- Eh_3 = E * h ** 3
154
-
155
- initial_guess = None
156
- constraints = None
157
- bender_function = None
158
-
159
- if shape == TRAPEZIUM:
160
- def general_bender_function(Y, M1, e, ratio):
161
- M2 = M1 * ratio
162
- A = (M1 + M2) / 2
163
- B = (M1 - M2) / L
164
- C = Eh_3 * (2 * b0 + e * b0) / 24
165
- D = Eh_3 * e * b0 / (12 * L)
166
- H = (A * D + B * C) / D ** 2
167
- CDLP = C + D * L / 2
168
- CDLM = C - D * L / 2
169
- F = (H / L) * ((CDLM * numpy.log(CDLM) - CDLP * numpy.log(CDLP)) / D + L)
170
- G = (-H * ((CDLM * numpy.log(CDLM) + CDLP * numpy.log(CDLP))) + (B * L ** 2) / 4) / (2 * D)
171
- CDY = C + D * Y
172
-
173
- return H * ((CDY / D) * numpy.log(CDY) - Y) - (B * Y ** 2) / (2 * D) + F * Y + G
174
-
175
- def bender_function_2m(Y, M1, e, ratio):
176
- return general_bender_function(Y, M1, e, ratio)
177
-
178
- def bender_function_1m(Y, M1, e):
179
- return general_bender_function(Y, M1, e, 1.0)
180
-
181
- if kind_of_bender == SINGLE_MOMENTUM:
182
- bender_function = bender_function_1m
183
- initial_guess = [bender_parameters.M1, bender_parameters.e]
184
- constraints = [[bender_parameters.M1_min if bender_parameters.M1_fixed == False else (bender_parameters.M1 * epsilon_minus),
185
- bender_parameters.e_min if bender_parameters.e_fixed == False else (bender_parameters.e * epsilon_minus)],
186
- [bender_parameters.M1_max if bender_parameters.M1_fixed == False else (bender_parameters.M1 * epsilon_plus),
187
- bender_parameters.e_max if bender_parameters.e_fixed == False else (bender_parameters.e * epsilon_plus)]]
188
- elif kind_of_bender == DOUBLE_MOMENTUM:
189
- bender_function = bender_function_2m
190
- initial_guess = [bender_parameters.M1, bender_parameters.e, bender_parameters.ratio]
191
- constraints = [[bender_parameters.M1_min if bender_parameters.M1_fixed == False else (bender_parameters.M1 * epsilon_minus),
192
- bender_parameters.e_min if bender_parameters.e_fixed == False else (bender_parameters.e * epsilon_minus),
193
- bender_parameters.ratio_min if bender_parameters.ratio_fixed == False else (bender_parameters.ratio * epsilon_minus)],
194
- [bender_parameters.M1_max if bender_parameters.M1_fixed == False else (bender_parameters.M1 * epsilon_plus),
195
- bender_parameters.e_max if bender_parameters.e_fixed == False else (bender_parameters.e * epsilon_plus),
196
- bender_parameters.ratio_max if bender_parameters.ratio_fixed == False else (bender_parameters.ratio * epsilon_plus)]]
197
- elif shape == RECTANGLE:
198
- def general_bender_function(Y, M1, ratio):
199
- M2 = M1 * ratio
200
- A = (M1 + M2) / 2
201
- B = (M1 - M2) / L
202
- C = Eh_3 * b0 / 12
203
- F = (B * L ** 2) / (24 * C)
204
- G = -(A * L ** 2) / (8 * C)
205
-
206
- return -(B * Y ** 3) / (6 * C) + (A * Y ** 2) / (2 * C) + F * Y + G
207
-
208
- def bender_function_2m(Y, M1, ratio):
209
- return general_bender_function(Y, M1, ratio)
210
-
211
- def bender_function_1m(Y, M1):
212
- return general_bender_function(Y, M1, 1.0)
213
-
214
- if kind_of_bender == SINGLE_MOMENTUM:
215
- bender_function = bender_function_1m
216
- initial_guess = [bender_parameters.M1]
217
- constraints = [[bender_parameters.M1_min if bender_parameters.M1_fixed == False else (bender_parameters.M1 * epsilon_minus)],
218
- [bender_parameters.M1_max if bender_parameters.M1_fixed == False else (bender_parameters.M1 * epsilon_plus)]]
219
- elif kind_of_bender == DOUBLE_MOMENTUM:
220
- bender_function = bender_function_2m
221
- initial_guess = [bender_parameters.M1, bender_parameters.ratio]
222
- constraints = [[bender_parameters.M1_min if bender_parameters.M1_fixed == False else (bender_parameters.M1 * epsilon_minus),
223
- bender_parameters.ratio_min if bender_parameters.ratio_fixed == False else (bender_parameters.ratio * epsilon_minus)],
224
- [bender_parameters.M1_max if bender_parameters.M1_fixed == False else (bender_parameters.M1 * epsilon_plus),
225
- bender_parameters.ratio_max if bender_parameters.ratio_fixed == False else (bender_parameters.ratio * epsilon_plus)]]
226
-
227
- for i in range(n_fit_steps):
228
- parameters, _ = curve_fit(f=bender_function,
229
- xdata=y_fit,
230
- ydata=ideal_profile_fit,
231
- p0=initial_guess,
232
- bounds=constraints,
233
- method='trf')
234
- initial_guess = parameters
235
-
236
- if len(parameters) == 1: bender_profile = bender_function(y, parameters[0])
237
- elif len(parameters) == 2: bender_profile = bender_function(y, parameters[0], parameters[1])
238
- else: bender_profile = bender_function(y, parameters[0], parameters[1], parameters[2])
239
-
240
- # rotate back to Shadow system
241
- bender_profile = bender_profile[::-1]
242
- ideal_profile = ideal_profile[::-1]
243
-
244
- # from here it's Shadow Axis system
245
- correction_profile = ideal_profile - bender_profile
246
-
247
- # r-squared = 1 - residual sum of squares / total sum of squares
248
- r_squared = 1 - (numpy.sum(correction_profile ** 2) / numpy.sum((ideal_profile - numpy.mean(ideal_profile)) ** 2))
249
- rms = round(correction_profile.std() * 1e9 * workspace_units_to_m, 6)
250
- if not bender_parameters.optimized_length is None: rms_opt = round(correction_profile[cursor].std() * 1e9 * workspace_units_to_m, 6)
251
-
252
- z_bender_correction_no_figure_error = numpy.zeros(z.shape)
253
-
254
- for i in range(z_bender_correction_no_figure_error.shape[0]): z_bender_correction_no_figure_error[i, :] = numpy.copy(correction_profile)
255
-
256
- if not bender_parameters.figure_error is None:
257
- x_e, y_e, z_e = bender_parameters.figure_error
258
-
259
- if len(x) == len(x_e) and len(y) == len(y_e) and \
260
- x[0] == x_e[0] and x[-1] == x_e[-1] and \
261
- y[0] == y_e[0] and y[-1] == y_e[-1]:
262
- z_figure_error = z_e
263
- else:
264
- z_figure_error = interp2d(y_e, x_e, z_e, kind='cubic')(y, x)
265
-
266
- z_bender_correction = z_bender_correction_no_figure_error + z_figure_error
267
- else:
268
- z_figure_error = None
269
- z_bender_correction = z_bender_correction_no_figure_error
270
-
271
- return parameters, BenderDataToPlot(x=x,
272
- y=y,
273
- ideal_profile=ideal_profile,
274
- bender_profile=bender_profile,
275
- correction_profile=correction_profile,
276
- titles=["Bender vs. Ideal Profiles" + "\n" + r'$R^2$ = ' + str(r_squared),
277
- "Correction Profile 1D, r.m.s. = " + str(rms) + " nm" + ("" if optimized_length is None else (", " + str(rms_opt) + " nm (optimized)"))],
278
- z_bender_correction=z_bender_correction,
279
- z_figure_error=z_figure_error,
280
- z_bender_correction_no_figure_error=z_bender_correction_no_figure_error)
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # ----------------------------------------------------------------------- #
4
- # Copyright (c) 2021, UChicago Argonne, LLC. All rights reserved. #
5
- # #
6
- # Copyright 2021. UChicago Argonne, LLC. This software was produced #
7
- # under U.S. Government contract DE-AC02-06CH11357 for Argonne National #
8
- # Laboratory (ANL), which is operated by UChicago Argonne, LLC for the #
9
- # U.S. Department of Energy. The U.S. Government has rights to use, #
10
- # reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR #
11
- # UChicago Argonne, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR #
12
- # ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is #
13
- # modified to produce derivative works, such modified software should #
14
- # be clearly marked, so as not to confuse it with the version available #
15
- # from ANL. #
16
- # #
17
- # Additionally, redistribution and use in source and binary forms, with #
18
- # or without modification, are permitted provided that the following #
19
- # conditions are met: #
20
- # #
21
- # * Redistributions of source code must retain the above copyright #
22
- # notice, this list of conditions and the following disclaimer. #
23
- # #
24
- # * Redistributions in binary form must reproduce the above copyright #
25
- # notice, this list of conditions and the following disclaimer in #
26
- # the documentation and/or other materials provided with the #
27
- # distribution. #
28
- # #
29
- # * Neither the name of UChicago Argonne, LLC, Argonne National #
30
- # Laboratory, ANL, the U.S. Government, nor the names of its #
31
- # contributors may be used to endorse or promote products derived #
32
- # from this software without specific prior written permission. #
33
- # #
34
- # THIS SOFTWARE IS PROVIDED BY UChicago Argonne, LLC AND CONTRIBUTORS #
35
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #
36
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS #
37
- # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UChicago #
38
- # Argonne, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, #
39
- # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, #
40
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; #
41
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
42
- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT #
43
- # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN #
44
- # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
45
- # POSSIBILITY OF SUCH DAMAGE. #
46
- # ----------------------------------------------------------------------- #
47
- class BenderDataToPlot:
48
- def __init__(self,
49
- x=None,
50
- y=None,
51
- ideal_profile=None,
52
- bender_profile=None,
53
- correction_profile=None,
54
- titles=None,
55
- z_bender_correction=None,
56
- z_figure_error=None,
57
- z_bender_correction_no_figure_error=None):
58
- self.x = x
59
- self.y = y
60
- self.ideal_profile = ideal_profile
61
- self.bender_profile = bender_profile
62
- self.correction_profile = correction_profile
63
- self.titles = titles
64
- self.z_bender_correction=z_bender_correction
65
- self.z_figure_error=z_figure_error
66
- self.z_bender_correction_no_figure_error=z_bender_correction_no_figure_error