shadow4-advanced 0.0.19__py3-none-any.whl
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.
- shadow4_advanced/__init__.py +46 -0
- shadow4_advanced/beamline/__init__.py +46 -0
- shadow4_advanced/beamline/optical_elements/__init__.py +46 -0
- shadow4_advanced/beamline/optical_elements/benders/__init__.py +46 -0
- shadow4_advanced/beamline/optical_elements/benders/s4_fixed_rods_bender_ellipsoid_mirror.py +283 -0
- shadow4_advanced/beamline/optical_elements/benders/s4_flexural_hinge_bender_ellipsoid_mirror.py +282 -0
- shadow4_advanced/beamline/optical_elements/gratings/__init__.py +46 -0
- shadow4_advanced/beamline/optical_elements/gratings/s4_simple_fzp.py +508 -0
- shadow4_advanced/beamline/optical_elements/hybrid/__init__.py +46 -0
- shadow4_advanced/beamline/optical_elements/hybrid/s4_hybrid_fzp.py +268 -0
- shadow4_advanced/beamline/optical_elements/hybrid/s4_hybrid_screen.py +849 -0
- shadow4_advanced/sources/__init__.py +46 -0
- shadow4_advanced/sources/hybrid/__init__.py +0 -0
- shadow4_advanced/sources/hybrid/s4_hybrid_undulator_light_source.py +267 -0
- shadow4_advanced-0.0.19.dist-info/METADATA +22 -0
- shadow4_advanced-0.0.19.dist-info/RECORD +19 -0
- shadow4_advanced-0.0.19.dist-info/WHEEL +5 -0
- shadow4_advanced-0.0.19.dist-info/licenses/LICENSE +22 -0
- shadow4_advanced-0.0.19.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ----------------------------------------------------------------------- #
|
|
4
|
+
# Copyright (c) 2024, UChicago Argonne, LLC. All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright 2024. 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
|
+
# ----------------------------------------------------------------------- #
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ----------------------------------------------------------------------- #
|
|
4
|
+
# Copyright (c) 2025, UChicago Argonne, LLC. All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright 2025. 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
|
+
# ----------------------------------------------------------------------- #
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ----------------------------------------------------------------------- #
|
|
4
|
+
# Copyright (c) 2025, UChicago Argonne, LLC. All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright 2025. 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
|
+
# ----------------------------------------------------------------------- #
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ----------------------------------------------------------------------- #
|
|
4
|
+
# Copyright (c) 2024, UChicago Argonne, LLC. All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright 2024. 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
|
+
# ----------------------------------------------------------------------- #
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ----------------------------------------------------------------------- #
|
|
4
|
+
# Copyright (c) 2024, UChicago Argonne, LLC. All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright 2024. 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
|
+
|
|
48
|
+
from srxraylib.profiles.benders.fixed_rods_bender_manager import FixedRodsStandardBenderManager, FixedRodsCalibratedBenderManager, \
|
|
49
|
+
FixedRodsBenderStructuralParameters, FixedRodsBenderFitParameters, BenderOuputData, CalibrationParameters, BenderMovement
|
|
50
|
+
|
|
51
|
+
from syned.beamline.shape import EllipticalCylinder, Rectangle
|
|
52
|
+
from syned.beamline.element_coordinates import ElementCoordinates
|
|
53
|
+
from syned.beamline.shape import NumericalMesh
|
|
54
|
+
|
|
55
|
+
from shadow4.beam.s4_beam import S4Beam
|
|
56
|
+
from shadow4.optical_surfaces.s4_mesh import S4Mesh
|
|
57
|
+
from shadow4.beamline.s4_beamline_element_movements import S4BeamlineElementMovements
|
|
58
|
+
from shadow4.beamline.optical_elements.mirrors.s4_ellipsoid_mirror import S4EllipsoidMirror
|
|
59
|
+
from shadow4.beamline.optical_elements.mirrors.s4_numerical_mesh_mirror import S4NumericalMeshMirror
|
|
60
|
+
from shadow4.beamline.optical_elements.mirrors.s4_additional_numerical_mesh_mirror import S4AdditionalNumericalMeshMirror, S4AdditionalNumericalMeshMirrorElement
|
|
61
|
+
|
|
62
|
+
class S4FixedRodsBenderEllipsoidMirror(S4AdditionalNumericalMeshMirror):
|
|
63
|
+
def __init__(self,
|
|
64
|
+
ellipsoid_mirror:S4EllipsoidMirror,
|
|
65
|
+
figure_error_data_file=None,
|
|
66
|
+
bender_bin_x=10,
|
|
67
|
+
bender_bin_y=100,
|
|
68
|
+
E=131000,
|
|
69
|
+
h=0.01,
|
|
70
|
+
r=0.012,
|
|
71
|
+
l=0.07,
|
|
72
|
+
R0=None,
|
|
73
|
+
eta=None,
|
|
74
|
+
W2=None,
|
|
75
|
+
calibration_parameters: CalibrationParameters=None,
|
|
76
|
+
fit_to_focus_parameters: FixedRodsBenderFitParameters=None,
|
|
77
|
+
bender_movement: BenderMovement=None):
|
|
78
|
+
assert ellipsoid_mirror is not None
|
|
79
|
+
surface_shape = ellipsoid_mirror.get_surface_shape()
|
|
80
|
+
boundary_shape = ellipsoid_mirror.get_boundary_shape()
|
|
81
|
+
|
|
82
|
+
assert not (surface_shape is None)
|
|
83
|
+
if not isinstance(surface_shape, EllipticalCylinder): raise ValueError("Calculation is possible on Elliptical Cylinders only")
|
|
84
|
+
if not isinstance(boundary_shape, Rectangle): raise ValueError("Calculation is possible on Rectangular Elliptical Cylinders only")
|
|
85
|
+
assert (bender_bin_x > 0 and bender_bin_y > 0 and E > 0.0 and h > 0.0 and r > 0.0 and l > 0.0)
|
|
86
|
+
|
|
87
|
+
self._figure_error_data_file = figure_error_data_file
|
|
88
|
+
self._bender_bin_x = bender_bin_x
|
|
89
|
+
self._bender_bin_y = bender_bin_y
|
|
90
|
+
self._E = E
|
|
91
|
+
self._h = h
|
|
92
|
+
self._r = r
|
|
93
|
+
self._l = l
|
|
94
|
+
|
|
95
|
+
self._fit_to_focus_parameters = fit_to_focus_parameters
|
|
96
|
+
self._bender_movement = bender_movement
|
|
97
|
+
self._calibration_parameters = calibration_parameters
|
|
98
|
+
|
|
99
|
+
if not fit_to_focus_parameters is None:
|
|
100
|
+
self._R0 = None
|
|
101
|
+
self._eta = None
|
|
102
|
+
self._W2 = None
|
|
103
|
+
elif not bender_movement is None:
|
|
104
|
+
assert not (R0 is None or eta is None or W2 is None)
|
|
105
|
+
#assert (0.0 <= eta <= 1.0) TODO: verify definition
|
|
106
|
+
self._R0 = R0
|
|
107
|
+
self._eta = eta
|
|
108
|
+
self._W2 = W2
|
|
109
|
+
else:
|
|
110
|
+
raise ValueError("Specify fit to focus or bender movement")
|
|
111
|
+
|
|
112
|
+
x_left, x_right, y_bottom, y_top = boundary_shape.get_boundaries()
|
|
113
|
+
|
|
114
|
+
if figure_error_data_file is None:
|
|
115
|
+
self._figure_error_mesh = None
|
|
116
|
+
else:
|
|
117
|
+
figure_error = S4Mesh()
|
|
118
|
+
figure_error.load_h5file(figure_error_data_file)
|
|
119
|
+
xx, yy = figure_error.get_mesh_x_y()
|
|
120
|
+
zz = figure_error.get_mesh_z()
|
|
121
|
+
self._figure_error_mesh = xx, yy, zz
|
|
122
|
+
|
|
123
|
+
grazing_angle = surface_shape.get_grazing_angle()
|
|
124
|
+
p, q = surface_shape.get_p_q(grazing_angle)
|
|
125
|
+
|
|
126
|
+
bender_structural_parameters = FixedRodsBenderStructuralParameters(dim_x_minus=-x_left,
|
|
127
|
+
dim_x_plus=x_right,
|
|
128
|
+
bender_bin_x=self._bender_bin_x,
|
|
129
|
+
dim_y_minus=-y_bottom,
|
|
130
|
+
dim_y_plus=y_top,
|
|
131
|
+
bender_bin_y=self._bender_bin_y,
|
|
132
|
+
p=p,
|
|
133
|
+
q=q,
|
|
134
|
+
grazing_angle=grazing_angle,
|
|
135
|
+
E=self._E,
|
|
136
|
+
h=self._h,
|
|
137
|
+
figure_error_mesh=self._figure_error_mesh,
|
|
138
|
+
r=self._r,
|
|
139
|
+
l=self._l,
|
|
140
|
+
R0=self._R0,
|
|
141
|
+
eta=self._eta,
|
|
142
|
+
W2=self._W2,
|
|
143
|
+
workspace_units_to_m=1.0,
|
|
144
|
+
workspace_units_to_mm=1000.0)
|
|
145
|
+
|
|
146
|
+
if not fit_to_focus_parameters is None:
|
|
147
|
+
bender_manager = FixedRodsStandardBenderManager(bender_structural_parameters=bender_structural_parameters)
|
|
148
|
+
bender_data = bender_manager.fit_bender_at_focus_position(fit_to_focus_parameters)
|
|
149
|
+
elif not bender_movement is None:
|
|
150
|
+
if calibration_parameters is None: bender_manager = FixedRodsStandardBenderManager(bender_structural_parameters=bender_structural_parameters)
|
|
151
|
+
else: bender_manager = FixedRodsCalibratedBenderManager(bender_structural_parameters=bender_structural_parameters, calibration_parameters=calibration_parameters)
|
|
152
|
+
|
|
153
|
+
bender_data = bender_manager.get_bender_shape_from_movement(bender_movement)
|
|
154
|
+
q = bender_manager.get_q_ideal_surface(bender_movement)
|
|
155
|
+
|
|
156
|
+
# modification of the shape of the mirror with the average q
|
|
157
|
+
ellipsoid_mirror.get_surface_shape().initialize_from_p_q(p, q, grazing_angle)
|
|
158
|
+
|
|
159
|
+
S4AdditionalNumericalMeshMirror.__init__(self,
|
|
160
|
+
ideal_mirror=ellipsoid_mirror,
|
|
161
|
+
numerical_mesh_mirror=S4NumericalMeshMirror(boundary_shape=ellipsoid_mirror.get_boundary_shape(),
|
|
162
|
+
xx=bender_data.x,
|
|
163
|
+
yy=bender_data.y,
|
|
164
|
+
zz=bender_data.z_bender_correction.T),
|
|
165
|
+
name=ellipsoid_mirror.get_name())
|
|
166
|
+
self._bender_data = bender_data
|
|
167
|
+
self._bender_manager = bender_manager
|
|
168
|
+
self._ellipsoid_mirror = ellipsoid_mirror
|
|
169
|
+
|
|
170
|
+
def move_bender(self, bender_movement: BenderMovement):
|
|
171
|
+
if self._bender_movement is None: raise ValueError("This bender has been initialized to fit to focus")
|
|
172
|
+
|
|
173
|
+
bender_data = self._bender_manager.get_bender_shape_from_movement(bender_movement)
|
|
174
|
+
q = self._bender_manager.get_q_ideal_surface(bender_movement)
|
|
175
|
+
|
|
176
|
+
surface_shape = self._ellipsoid_mirror.get_surface_shape()
|
|
177
|
+
|
|
178
|
+
grazing_angle = surface_shape.get_grazing_angle()
|
|
179
|
+
p, _ = surface_shape.get_p_q(grazing_angle)
|
|
180
|
+
|
|
181
|
+
# modification of the shape of the mirror with the average q
|
|
182
|
+
self._ellipsoid_mirror.get_surface_shape().initialize_from_p_q(p, q, grazing_angle)
|
|
183
|
+
|
|
184
|
+
numerical_mesh: NumericalMesh = self.get_surface_shape_instance() # numerical mesh
|
|
185
|
+
numerical_mesh._xx = bender_data.x
|
|
186
|
+
numerical_mesh._yy = bender_data.y
|
|
187
|
+
numerical_mesh._zz = bender_data.z_bender_correction.T
|
|
188
|
+
|
|
189
|
+
@property
|
|
190
|
+
def bender_movement(self) -> BenderMovement: return self._bender_movement
|
|
191
|
+
@property
|
|
192
|
+
def calibration_parameters(self) -> CalibrationParameters: return self._calibration_parameters
|
|
193
|
+
|
|
194
|
+
def get_bender_data(self) -> BenderOuputData: return self._bender_data
|
|
195
|
+
|
|
196
|
+
def to_python_code(self, **kwargs):
|
|
197
|
+
txt = self.ideal_mirror().to_python_code()
|
|
198
|
+
|
|
199
|
+
txt += "\n\nfrom shadow4_advanced.beamline.optical_elements.benders.s4_fixed_rods_bender_ellipsoid_mirror import S4FixedRodsBenderEllipsoidMirror"
|
|
200
|
+
txt += "\n\nellipsoid_mirror = optical_element"
|
|
201
|
+
|
|
202
|
+
if not self._fit_to_focus_parameters is None:
|
|
203
|
+
txt += "\nfrom srxraylib.profiles.benders.fixed_rods_bender_manager import FixedRodsBenderFitParameters"
|
|
204
|
+
txt += f"\n\nfit_to_focus_parameters = FixedRodsBenderFitParameters(optimized_length={self._fit_to_focus_parameters.optimized_length},"
|
|
205
|
+
txt += f"\n n_fit_steps={self._fit_to_focus_parameters.n_fit_steps},"
|
|
206
|
+
txt += f"\n R0={self._fit_to_focus_parameters.R0},"
|
|
207
|
+
txt += f"\n R0_min={self._fit_to_focus_parameters.R0_min},"
|
|
208
|
+
txt += f"\n R0_max={self._fit_to_focus_parameters.R0_max},"
|
|
209
|
+
txt += f"\n R0_fixed={self._fit_to_focus_parameters.R0_fixed},"
|
|
210
|
+
txt += f"\n eta={self._fit_to_focus_parameters.eta},"
|
|
211
|
+
txt += f"\n eta_min={self._fit_to_focus_parameters.eta_min},"
|
|
212
|
+
txt += f"\n eta_max={self._fit_to_focus_parameters.eta_max},"
|
|
213
|
+
txt += f"\n eta_fixed={self._fit_to_focus_parameters.eta_fixed},"
|
|
214
|
+
txt += f"\n W2={self._fit_to_focus_parameters.W2},"
|
|
215
|
+
txt += f"\n W2_min={self._fit_to_focus_parameters.W2_min},"
|
|
216
|
+
txt += f"\n W2_max={self._fit_to_focus_parameters.W2_max},"
|
|
217
|
+
txt += f"\n W2_fixed={self._fit_to_focus_parameters.W2_fixed})"
|
|
218
|
+
txt += "\nbender_movement = None"
|
|
219
|
+
txt += "\nR0 = None"
|
|
220
|
+
txt += "\neta = None"
|
|
221
|
+
txt += "\nW2 = None"
|
|
222
|
+
elif not self._bender_movement is None:
|
|
223
|
+
txt += "\nfrom srxraylib.profiles.benders.bender_io import BenderMovement"
|
|
224
|
+
txt += "\n\nfit_to_focus_parameters = None"
|
|
225
|
+
txt += f"\nbender_movement = BenderMovement(position_upstream={str(self._bender_movement.position_upstream)}, position_downstream={str(self._bender_movement.position_downstream)})"
|
|
226
|
+
txt += f"\nR0 = {self._R0}"
|
|
227
|
+
txt += f"\neta = {self._eta}"
|
|
228
|
+
txt += f"\nW2 = {self._W2}"
|
|
229
|
+
|
|
230
|
+
if self._calibration_parameters is None:
|
|
231
|
+
txt += "\ncalibration_parameters = None"
|
|
232
|
+
else:
|
|
233
|
+
p0u, p1u = self._calibration_parameters.upstream
|
|
234
|
+
p0d, p1d = self._calibration_parameters.downstream
|
|
235
|
+
txt += "\nfrom srxraylib.profiles.benders.flexural_hinge_bender_manager import CalibrationParameters"
|
|
236
|
+
txt += f"\n\ncalibration_parameters = CalibrationParameters(parameters_upstream=[{p0u}, {p1u}], parameters_downstream=[{p0d}, {p1d}])"
|
|
237
|
+
|
|
238
|
+
txt += "\n\noptical_element = S4FixedRodsBenderEllipsoidMirror(ellipsoid_mirror=ellipsoid_mirror,"
|
|
239
|
+
txt += "\n figure_error_data_file=" + ("None" if self._figure_error_data_file is None else ("'" + self._figure_error_data_file + "'")) + ","
|
|
240
|
+
txt += f"\n bender_bin_x={self._bender_bin_x},"
|
|
241
|
+
txt += f"\n bender_bin_y={self._bender_bin_y},"
|
|
242
|
+
txt += f"\n E={self._E},"
|
|
243
|
+
txt += f"\n h={self._h},"
|
|
244
|
+
txt += f"\n r={self._r},"
|
|
245
|
+
txt += f"\n l={self._l},"
|
|
246
|
+
txt += "\n R0=R0,"
|
|
247
|
+
txt += "\n e=e,"
|
|
248
|
+
txt += "\n W2=W2,"
|
|
249
|
+
txt += "\n calibration_parameters=calibration_parameters,"
|
|
250
|
+
txt += "\n fit_to_focus_parameters=fit_to_focus_parameters,"
|
|
251
|
+
txt += "\n bender_movement=bender_movement)"
|
|
252
|
+
|
|
253
|
+
txt += "\n\nbender_data = optical_element.get_bender_data()"
|
|
254
|
+
|
|
255
|
+
return txt
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class S4FixedRodsBenderEllipsoidMirrorElement(S4AdditionalNumericalMeshMirrorElement):
|
|
259
|
+
def __init__(self,
|
|
260
|
+
optical_element: S4FixedRodsBenderEllipsoidMirror=None,
|
|
261
|
+
coordinates: ElementCoordinates = None,
|
|
262
|
+
movements: S4BeamlineElementMovements = None,
|
|
263
|
+
input_beam: S4Beam = None):
|
|
264
|
+
super().__init__(optical_element=optical_element,
|
|
265
|
+
coordinates=coordinates if coordinates is not None else ElementCoordinates(),
|
|
266
|
+
movements=movements,
|
|
267
|
+
input_beam=input_beam)
|
|
268
|
+
|
|
269
|
+
def to_python_code(self, **kwargs):
|
|
270
|
+
txt = "\n\n# optical element number XX"
|
|
271
|
+
txt += self.get_optical_element().to_python_code()
|
|
272
|
+
coordinates = self.get_coordinates()
|
|
273
|
+
txt += "\nfrom syned.beamline.element_coordinates import ElementCoordinates"
|
|
274
|
+
txt += "\ncoordinates = ElementCoordinates(p=%g, q=%g, angle_radial=%g, angle_azimuthal=%g, angle_radial_out=%g)" % \
|
|
275
|
+
(coordinates.p(), coordinates.q(), coordinates.angle_radial(), coordinates.angle_azimuthal(), coordinates.angle_radial_out())
|
|
276
|
+
|
|
277
|
+
txt += self.to_python_code_movements()
|
|
278
|
+
|
|
279
|
+
txt += "\nfrom shadow4_advanced.beamline.optical_elements.benders.s4_fixed_rods_bender_ellipsoid_mirror import S4FixedRodsBenderEllipsoidMirrorElement"
|
|
280
|
+
txt += "\nbeamline_element = S4FixedRodsBenderEllipsoidMirrorElement(optical_element=optical_element, coordinates=coordinates, movements=movements, input_beam=beam)"
|
|
281
|
+
txt += "\n\nbeam, mirr = beamline_element.trace_beam()"
|
|
282
|
+
|
|
283
|
+
return txt
|