syned 1.0.47__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.
- syned/__init__.py +0 -0
- syned/__test/__init__.py +46 -0
- syned/__test/test.py +28 -0
- syned/beamline/__init__.py +1 -0
- syned/beamline/beamline.py +155 -0
- syned/beamline/beamline_element.py +76 -0
- syned/beamline/element_coordinates.py +199 -0
- syned/beamline/optical_element.py +47 -0
- syned/beamline/optical_element_with_surface_shape.py +126 -0
- syned/beamline/optical_elements/__init__.py +1 -0
- syned/beamline/optical_elements/absorbers/__init__.py +0 -0
- syned/beamline/optical_elements/absorbers/absorber.py +21 -0
- syned/beamline/optical_elements/absorbers/beam_stopper.py +64 -0
- syned/beamline/optical_elements/absorbers/filter.py +61 -0
- syned/beamline/optical_elements/absorbers/holed_filter.py +67 -0
- syned/beamline/optical_elements/absorbers/slit.py +81 -0
- syned/beamline/optical_elements/crystals/__init__.py +1 -0
- syned/beamline/optical_elements/crystals/crystal.py +70 -0
- syned/beamline/optical_elements/gratings/__init__.py +1 -0
- syned/beamline/optical_elements/gratings/grating.py +279 -0
- syned/beamline/optical_elements/ideal_elements/__init__.py +1 -0
- syned/beamline/optical_elements/ideal_elements/ideal_element.py +16 -0
- syned/beamline/optical_elements/ideal_elements/ideal_fzp.py +183 -0
- syned/beamline/optical_elements/ideal_elements/ideal_lens.py +54 -0
- syned/beamline/optical_elements/ideal_elements/screen.py +16 -0
- syned/beamline/optical_elements/mirrors/__init__.py +1 -0
- syned/beamline/optical_elements/mirrors/mirror.py +39 -0
- syned/beamline/optical_elements/multilayers/__init__.py +46 -0
- syned/beamline/optical_elements/multilayers/multilayer.py +45 -0
- syned/beamline/optical_elements/refractors/__init__.py +1 -0
- syned/beamline/optical_elements/refractors/crl.py +79 -0
- syned/beamline/optical_elements/refractors/interface.py +61 -0
- syned/beamline/optical_elements/refractors/lens.py +105 -0
- syned/beamline/shape.py +2803 -0
- syned/storage_ring/__init__.py +1 -0
- syned/storage_ring/electron_beam.py +804 -0
- syned/storage_ring/empty_light_source.py +40 -0
- syned/storage_ring/light_source.py +90 -0
- syned/storage_ring/magnetic_structure.py +8 -0
- syned/storage_ring/magnetic_structures/__init__.py +1 -0
- syned/storage_ring/magnetic_structures/bending_magnet.py +329 -0
- syned/storage_ring/magnetic_structures/insertion_device.py +169 -0
- syned/storage_ring/magnetic_structures/undulator.py +413 -0
- syned/storage_ring/magnetic_structures/wiggler.py +27 -0
- syned/syned_object.py +264 -0
- syned/util/__init__.py +22 -0
- syned/util/json_tools.py +198 -0
- syned/widget/__init__.py +0 -0
- syned/widget/widget_decorator.py +67 -0
- syned-1.0.47.dist-info/METADATA +88 -0
- syned-1.0.47.dist-info/RECORD +54 -0
- syned-1.0.47.dist-info/WHEEL +5 -0
- syned-1.0.47.dist-info/licenses/LICENSE +20 -0
- syned-1.0.47.dist-info/top_level.txt +1 -0
syned/__init__.py
ADDED
|
File without changes
|
syned/__test/__init__.py
ADDED
|
@@ -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
|
+
# ----------------------------------------------------------------------- #
|
syned/__test/test.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import traceback
|
|
2
|
+
import warnings
|
|
3
|
+
warnings.simplefilter("always")
|
|
4
|
+
|
|
5
|
+
from syned.storage_ring.electron_beam import ElectronBeam
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
a = ElectronBeam.initialize_as_pencil_beam(energy_in_GeV=6.0,
|
|
9
|
+
current=0.2,
|
|
10
|
+
energy_spread=0.00095,
|
|
11
|
+
moment_xx =1.0,
|
|
12
|
+
moment_xxp =1.0,
|
|
13
|
+
moment_xpxp =1.0,
|
|
14
|
+
moment_yy =1.0,
|
|
15
|
+
moment_yyp =1.0,
|
|
16
|
+
moment_ypyp =1.0,
|
|
17
|
+
dispersion_x =1.0,
|
|
18
|
+
dispersion_y =1.0,
|
|
19
|
+
dispersionp_x=1.0,
|
|
20
|
+
dispersionp_y=1.0)
|
|
21
|
+
a.set_twiss_horizontal (0, 0, 0)
|
|
22
|
+
a.set_twiss_vertical (0, 1, 1, eta_y=2.0, etap_y=3.0)
|
|
23
|
+
|
|
24
|
+
print(a.info())
|
|
25
|
+
|
|
26
|
+
print(a.get_twiss_no_dispersion_all())
|
|
27
|
+
except:
|
|
28
|
+
traceback.print_exc()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Represents a beamline. The beamline is composed by a light source ans a list of beamline elements.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from syned.syned_object import SynedObject
|
|
6
|
+
from syned.storage_ring.light_source import LightSource
|
|
7
|
+
from syned.storage_ring.empty_light_source import EmptyLightSource
|
|
8
|
+
from syned.beamline.beamline_element import BeamlineElement
|
|
9
|
+
|
|
10
|
+
from collections import OrderedDict
|
|
11
|
+
|
|
12
|
+
class Beamline(SynedObject):
|
|
13
|
+
"""
|
|
14
|
+
Constructor.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
light_source : instance of LightSource
|
|
19
|
+
The light source
|
|
20
|
+
beamline_elements_list : list
|
|
21
|
+
The beamline elements (each one an instance of BeamlineElement).
|
|
22
|
+
"""
|
|
23
|
+
def __init__(self, light_source=LightSource(), beamline_elements_list=None):
|
|
24
|
+
self._light_source = light_source
|
|
25
|
+
if beamline_elements_list is None:
|
|
26
|
+
self._beamline_elements_list = []
|
|
27
|
+
else:
|
|
28
|
+
self._beamline_elements_list = beamline_elements_list
|
|
29
|
+
|
|
30
|
+
# support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
|
|
31
|
+
self._set_support_text([
|
|
32
|
+
("light_source", "Light Source", ""),
|
|
33
|
+
("beamline_elements_list", "Beamline Elements", ""),
|
|
34
|
+
] )
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# overwrites the SynedObject method for dealing with list
|
|
38
|
+
def to_dictionary(self):
|
|
39
|
+
"""
|
|
40
|
+
Returns a dictionary with the object fields.
|
|
41
|
+
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
dict
|
|
45
|
+
A dictionary with the data.
|
|
46
|
+
|
|
47
|
+
"""
|
|
48
|
+
dict_to_save = OrderedDict()
|
|
49
|
+
dict_to_save.update({"CLASS_NAME":self.__class__.__name__})
|
|
50
|
+
|
|
51
|
+
dict_to_save["light_source"] = self._light_source.to_dictionary()
|
|
52
|
+
dict_to_save["beamline_elements_list"] = [el.to_dictionary() for el in self._beamline_elements_list]
|
|
53
|
+
|
|
54
|
+
return dict_to_save
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def get_light_source(self):
|
|
59
|
+
"""
|
|
60
|
+
Returns the light source
|
|
61
|
+
|
|
62
|
+
Returns
|
|
63
|
+
-------
|
|
64
|
+
instance of LightSource
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
return self._light_source
|
|
68
|
+
|
|
69
|
+
def get_beamline_elements(self):
|
|
70
|
+
"""
|
|
71
|
+
returns the beamline elements.
|
|
72
|
+
|
|
73
|
+
Returns
|
|
74
|
+
-------
|
|
75
|
+
list
|
|
76
|
+
|
|
77
|
+
"""
|
|
78
|
+
return self._beamline_elements_list
|
|
79
|
+
|
|
80
|
+
def set_light_source(self, light_source=LightSource()):
|
|
81
|
+
"""
|
|
82
|
+
Sets a light source.
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
light_source : instance of LightSource
|
|
87
|
+
|
|
88
|
+
"""
|
|
89
|
+
if not (isinstance(light_source,LightSource) or isinstance(light_source,EmptyLightSource)):
|
|
90
|
+
raise Exception("Input class must be of type: "+LightSource.__name__+" or "+EmptyLightSource.__name__)
|
|
91
|
+
else:
|
|
92
|
+
self._light_source = light_source
|
|
93
|
+
|
|
94
|
+
def append_beamline_element(self, beamline_element=BeamlineElement()):
|
|
95
|
+
"""
|
|
96
|
+
Appends a beamline element.
|
|
97
|
+
|
|
98
|
+
Parameters
|
|
99
|
+
----------
|
|
100
|
+
beamline_element : instance of BeamlineElement.
|
|
101
|
+
|
|
102
|
+
"""
|
|
103
|
+
if not isinstance(beamline_element,BeamlineElement):
|
|
104
|
+
raise Exception("Input class must be of type: "+BeamlineElement.__name__)
|
|
105
|
+
else:
|
|
106
|
+
self._beamline_elements_list.append(beamline_element)
|
|
107
|
+
|
|
108
|
+
def get_beamline_elements_number(self):
|
|
109
|
+
"""
|
|
110
|
+
Gets the number of beamline elements stored.
|
|
111
|
+
|
|
112
|
+
Returns
|
|
113
|
+
-------
|
|
114
|
+
int
|
|
115
|
+
|
|
116
|
+
"""
|
|
117
|
+
return len(self._beamline_elements_list)
|
|
118
|
+
|
|
119
|
+
def get_beamline_element_at(self, index):
|
|
120
|
+
"""
|
|
121
|
+
gets an individual beamline element.
|
|
122
|
+
|
|
123
|
+
Parameters
|
|
124
|
+
----------
|
|
125
|
+
index : int
|
|
126
|
+
The index of the beamline element to be retrieved.
|
|
127
|
+
|
|
128
|
+
Returns
|
|
129
|
+
-------
|
|
130
|
+
instance of BeamlineElement
|
|
131
|
+
The wanted beamline element (referenced, not copied).
|
|
132
|
+
|
|
133
|
+
"""
|
|
134
|
+
if index >= len(self._beamline_elements_list):
|
|
135
|
+
raise IndexError("Index " + str(index) + " out of bounds")
|
|
136
|
+
|
|
137
|
+
return self._beamline_elements_list[index]
|
|
138
|
+
|
|
139
|
+
# TODO: remove: probably this is not needed, as the deepcopy in SynedObject makes the work.
|
|
140
|
+
def duplicate(self):
|
|
141
|
+
"""
|
|
142
|
+
Returns a copy of the beamline element instance.
|
|
143
|
+
|
|
144
|
+
Returns
|
|
145
|
+
-------
|
|
146
|
+
BeamlineElement instance
|
|
147
|
+
A copy of the object instance.
|
|
148
|
+
|
|
149
|
+
"""
|
|
150
|
+
beamline_elements_list = []
|
|
151
|
+
for beamline_element in self._beamline_elements_list:
|
|
152
|
+
beamline_elements_list.append(beamline_element)
|
|
153
|
+
|
|
154
|
+
return Beamline(light_source=self._light_source,
|
|
155
|
+
beamline_elements_list = beamline_elements_list)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Base class for all beamline elements. A beamline element is composed by an optical element (instance of OpticalElement)
|
|
3
|
+
and its position in th ebeamline (an instance of ElementCoordinates).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from syned.syned_object import SynedObject
|
|
7
|
+
from syned.beamline.optical_element import OpticalElement
|
|
8
|
+
from syned.beamline.element_coordinates import ElementCoordinates
|
|
9
|
+
|
|
10
|
+
class BeamlineElement(SynedObject):
|
|
11
|
+
"""
|
|
12
|
+
Constructor
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
optical_element : instance of OpticalElement
|
|
17
|
+
coordinates : instance of ElementCoordinates
|
|
18
|
+
"""
|
|
19
|
+
def __init__(self, optical_element=OpticalElement(), coordinates=ElementCoordinates()):
|
|
20
|
+
self._optical_element = optical_element
|
|
21
|
+
self._coordinates = coordinates
|
|
22
|
+
# support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
|
|
23
|
+
self._set_support_text([
|
|
24
|
+
("optical_element", "Optical Element", ""),
|
|
25
|
+
("coordinates", "Element coordinates", ""),
|
|
26
|
+
] )
|
|
27
|
+
|
|
28
|
+
def get_optical_element(self):
|
|
29
|
+
"""
|
|
30
|
+
Returns the optical element.
|
|
31
|
+
|
|
32
|
+
Returns
|
|
33
|
+
-------
|
|
34
|
+
instance of OpticalElement
|
|
35
|
+
|
|
36
|
+
"""
|
|
37
|
+
return self._optical_element
|
|
38
|
+
|
|
39
|
+
def get_coordinates(self):
|
|
40
|
+
"""
|
|
41
|
+
Returns the element coordinates.
|
|
42
|
+
|
|
43
|
+
Returns
|
|
44
|
+
-------
|
|
45
|
+
instance of ElementCoordinates
|
|
46
|
+
|
|
47
|
+
"""
|
|
48
|
+
return self._coordinates
|
|
49
|
+
|
|
50
|
+
def set_optical_element(self, value):
|
|
51
|
+
"""
|
|
52
|
+
Sets the optical element.
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
value : instance of OpticalElement
|
|
57
|
+
|
|
58
|
+
"""
|
|
59
|
+
if isinstance(value, OpticalElement):
|
|
60
|
+
self._optical_element = value
|
|
61
|
+
else:
|
|
62
|
+
raise Exception("entry is not an instance of OpticalElement")
|
|
63
|
+
|
|
64
|
+
def set_coordinates(self, value):
|
|
65
|
+
"""
|
|
66
|
+
Sets the coordinates.
|
|
67
|
+
|
|
68
|
+
Parameters
|
|
69
|
+
----------
|
|
70
|
+
value : instance of ElementCoordinates.
|
|
71
|
+
|
|
72
|
+
"""
|
|
73
|
+
if isinstance(value, ElementCoordinates):
|
|
74
|
+
self._coordinates = value
|
|
75
|
+
else:
|
|
76
|
+
raise Exception("entry is not an instance of ElementCoordinates")
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Position coordinates of a beamline component.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from syned.syned_object import SynedObject
|
|
6
|
+
|
|
7
|
+
class ElementCoordinates(SynedObject):
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
def __init__(self, p = 0.0, q = 0.0, angle_radial=0.0, angle_azimuthal=0.0, angle_radial_out=None):
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
p : float, optional
|
|
17
|
+
distance from previous element in m.
|
|
18
|
+
q : float, optional
|
|
19
|
+
distance to next element in m.
|
|
20
|
+
angle_radial : float, optional
|
|
21
|
+
Radial inclination angle in rads.
|
|
22
|
+
angle_azimuthal : float, optional
|
|
23
|
+
Azimuthal inclination angle in rads.
|
|
24
|
+
angle_radial_out : float, optional
|
|
25
|
+
The radial angle in rads in the output direction (default=None, the same as angle_radial).
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
self._p = p
|
|
29
|
+
self._q = q
|
|
30
|
+
self._angle_radial = angle_radial
|
|
31
|
+
self._angle_azimuthal = angle_azimuthal
|
|
32
|
+
self._angle_radial_out = angle_radial_out
|
|
33
|
+
|
|
34
|
+
# support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
|
|
35
|
+
self._set_support_text([
|
|
36
|
+
("p", "distance from previous continuation plane", "m" ),
|
|
37
|
+
("q", "distance to next continuation plane", "m" ),
|
|
38
|
+
("angle_radial", "incident angle [to normal]", "rad" ),
|
|
39
|
+
("angle_radial_out", "output angle [to normal]", "rad"),
|
|
40
|
+
("angle_azimuthal", "rotation along beam axis", "rad" ),
|
|
41
|
+
])
|
|
42
|
+
|
|
43
|
+
def p(self):
|
|
44
|
+
"""
|
|
45
|
+
Returns the distance from previous element.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
float
|
|
50
|
+
|
|
51
|
+
"""
|
|
52
|
+
return self._p
|
|
53
|
+
|
|
54
|
+
def q(self):
|
|
55
|
+
"""
|
|
56
|
+
Returns the distance to next element.
|
|
57
|
+
|
|
58
|
+
Returns
|
|
59
|
+
-------
|
|
60
|
+
float
|
|
61
|
+
|
|
62
|
+
"""
|
|
63
|
+
return self._q
|
|
64
|
+
|
|
65
|
+
def angle_radial(self):
|
|
66
|
+
"""
|
|
67
|
+
Returns the radial angle.
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
float
|
|
72
|
+
|
|
73
|
+
"""
|
|
74
|
+
return self._angle_radial
|
|
75
|
+
|
|
76
|
+
def angle_radial_out(self):
|
|
77
|
+
"""
|
|
78
|
+
Returns the radial angle in the output direction.
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
float
|
|
83
|
+
|
|
84
|
+
"""
|
|
85
|
+
if self._angle_radial_out is None:
|
|
86
|
+
return self.angle_radial()
|
|
87
|
+
else:
|
|
88
|
+
return self._angle_radial_out
|
|
89
|
+
|
|
90
|
+
def angle_azimuthal(self):
|
|
91
|
+
"""
|
|
92
|
+
Returns the azimuthal angle.
|
|
93
|
+
|
|
94
|
+
Returns
|
|
95
|
+
-------
|
|
96
|
+
float
|
|
97
|
+
|
|
98
|
+
"""
|
|
99
|
+
return self._angle_azimuthal
|
|
100
|
+
|
|
101
|
+
def set_positions(self, p=0.0, q=0.0, angle_radial=0.0, angle_radial_out=None, angle_azimuthal=0.0):
|
|
102
|
+
"""
|
|
103
|
+
Sets the coordinates.
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
p : float, optional
|
|
108
|
+
distance from previous element in m.
|
|
109
|
+
q : float, optional
|
|
110
|
+
distance to next element in m.
|
|
111
|
+
angle_radial : float, optional
|
|
112
|
+
Radial inclination angle in rads.
|
|
113
|
+
angle_azimuthal : float, optional
|
|
114
|
+
Azimuthal inclination angle in rads.
|
|
115
|
+
angle_radial_out : float, optional
|
|
116
|
+
The radial angle in rads in the output direction (default=None, the same as angle_radial).
|
|
117
|
+
|
|
118
|
+
"""
|
|
119
|
+
self._p = p
|
|
120
|
+
self._q = q
|
|
121
|
+
self._angle_radial = angle_radial
|
|
122
|
+
self._angle_radial_out = angle_radial_out
|
|
123
|
+
self._angle_azimuthal = angle_azimuthal
|
|
124
|
+
|
|
125
|
+
def get_positions(self):
|
|
126
|
+
"""
|
|
127
|
+
Gets the coordinates.
|
|
128
|
+
|
|
129
|
+
Returns
|
|
130
|
+
-------
|
|
131
|
+
tuple
|
|
132
|
+
(p, q, angle_radial, angle_radial_out, angle_azimuthal)
|
|
133
|
+
|
|
134
|
+
"""
|
|
135
|
+
return self.p(), \
|
|
136
|
+
self.q(), \
|
|
137
|
+
self.angle_radial(), \
|
|
138
|
+
self.angle_radial_out(), \
|
|
139
|
+
self.angle_azimuthal()
|
|
140
|
+
|
|
141
|
+
def set_p_and_q(self, p=0.0, q=0.0):
|
|
142
|
+
"""
|
|
143
|
+
Set the distances p and q.
|
|
144
|
+
|
|
145
|
+
Parameters
|
|
146
|
+
----------
|
|
147
|
+
p : float, optional
|
|
148
|
+
distance from previous element in m.
|
|
149
|
+
q : float, optional
|
|
150
|
+
distance to next element in m.
|
|
151
|
+
|
|
152
|
+
"""
|
|
153
|
+
self._p = p
|
|
154
|
+
self._q = q
|
|
155
|
+
|
|
156
|
+
def get_p_and_q(self):
|
|
157
|
+
"""
|
|
158
|
+
Gets p and q.
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
-------
|
|
162
|
+
tuple
|
|
163
|
+
(p,q).
|
|
164
|
+
|
|
165
|
+
"""
|
|
166
|
+
return self.p(), self.q()
|
|
167
|
+
|
|
168
|
+
def set_angles(self, angle_radial=0.0, angle_radial_out=None, angle_azimuthal=0.0):
|
|
169
|
+
"""
|
|
170
|
+
Sets the angles.
|
|
171
|
+
|
|
172
|
+
Parameters
|
|
173
|
+
----------
|
|
174
|
+
angle_radial : float, optional
|
|
175
|
+
Radial inclination angle in rads.
|
|
176
|
+
angle_azimuthal : float, optional
|
|
177
|
+
Azimuthal inclination angle in rads.
|
|
178
|
+
angle_radial_out : float, optional
|
|
179
|
+
The radial angle in rads in the output direction (default=None, the same as angle_radial).
|
|
180
|
+
|
|
181
|
+
Returns
|
|
182
|
+
-------
|
|
183
|
+
|
|
184
|
+
"""
|
|
185
|
+
self._angle_radial = angle_radial
|
|
186
|
+
self._angle_radial_out = angle_radial_out
|
|
187
|
+
self._angle_azimuthal = angle_azimuthal
|
|
188
|
+
|
|
189
|
+
def get_angles(self):
|
|
190
|
+
"""
|
|
191
|
+
Get the angles.
|
|
192
|
+
|
|
193
|
+
Returns
|
|
194
|
+
-------
|
|
195
|
+
tuple
|
|
196
|
+
(angle_radial, angle_radial_out, angle_azimuthal)
|
|
197
|
+
|
|
198
|
+
"""
|
|
199
|
+
return self.angle_radial(), self.angle_radial_out(), self.angle_azimuthal()
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Base class for an optical element.
|
|
3
|
+
"""
|
|
4
|
+
from syned.syned_object import SynedObject
|
|
5
|
+
|
|
6
|
+
class OpticalElement(SynedObject):
|
|
7
|
+
"""
|
|
8
|
+
Constructor.
|
|
9
|
+
|
|
10
|
+
Parameters
|
|
11
|
+
----------
|
|
12
|
+
name : str
|
|
13
|
+
The element name.
|
|
14
|
+
boundary_shape : instance of BoundaryShape, optional
|
|
15
|
+
The element shape. The default=None means no shape associated to the optical element.
|
|
16
|
+
"""
|
|
17
|
+
def __init__(self, name="Undefined", boundary_shape=None):
|
|
18
|
+
self._name = name
|
|
19
|
+
self._boundary_shape = boundary_shape
|
|
20
|
+
|
|
21
|
+
# support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
|
|
22
|
+
self._set_support_text([
|
|
23
|
+
("name", "Name", ""),
|
|
24
|
+
("boundary_shape" , "", "" ),
|
|
25
|
+
] )
|
|
26
|
+
|
|
27
|
+
def get_name(self):
|
|
28
|
+
"""
|
|
29
|
+
returns the optical element name.
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
str
|
|
34
|
+
|
|
35
|
+
"""
|
|
36
|
+
return self._name
|
|
37
|
+
|
|
38
|
+
def get_boundary_shape(self):
|
|
39
|
+
"""
|
|
40
|
+
Returns the boundary shape.
|
|
41
|
+
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
None or instance of BoundaryShape
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
return self._boundary_shape
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Base classes for optical elements with shape(s).
|
|
3
|
+
|
|
4
|
+
* OpticalElementsWithSurfaceShape (e.g. an elliptical mirror).
|
|
5
|
+
* OpticalElementsWithMultipleShapes (e.g. a lens that has two surfaces).
|
|
6
|
+
"""
|
|
7
|
+
from syned.beamline.optical_element import OpticalElement
|
|
8
|
+
from syned.beamline.shape import SurfaceShape
|
|
9
|
+
|
|
10
|
+
class OpticalElementsWithMultipleShapes(OpticalElement):
|
|
11
|
+
"""
|
|
12
|
+
Constructor.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
name : str
|
|
17
|
+
The optical elemnt name.
|
|
18
|
+
surface_shapes : list
|
|
19
|
+
List with surface shapes (instances of SurfaceShape)
|
|
20
|
+
boundary_shape : instance of BoundaryShape, optional
|
|
21
|
+
The element shape. The default=None means no shape associated to the optical element.
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(self, name="",
|
|
26
|
+
surface_shapes=None,
|
|
27
|
+
boundary_shape=None):
|
|
28
|
+
super().__init__(name, boundary_shape)
|
|
29
|
+
if surface_shapes is None: surface_shapes = [SurfaceShape()]
|
|
30
|
+
if not isinstance(surface_shapes, list): raise ValueError("surface_shapes must of type 'list'")
|
|
31
|
+
self._surface_shapes = surface_shapes
|
|
32
|
+
|
|
33
|
+
def get_surface_shape(self, index):
|
|
34
|
+
"""
|
|
35
|
+
Gets the surface shape.
|
|
36
|
+
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
index : int
|
|
40
|
+
The index of the requested surface shape in the list.
|
|
41
|
+
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
instance of SurfaceShape
|
|
45
|
+
The requested surface shape.
|
|
46
|
+
|
|
47
|
+
"""
|
|
48
|
+
try: return self._surface_shapes[index]
|
|
49
|
+
except: raise Exception("only " + str(len(self._surface_shapes)) + " shapes in OpticalElementsWithMultipleShapes")
|
|
50
|
+
|
|
51
|
+
def set_surface_shape(self, index, surface_shape=None):
|
|
52
|
+
"""
|
|
53
|
+
Sets a surface shape.
|
|
54
|
+
|
|
55
|
+
Parameters
|
|
56
|
+
----------
|
|
57
|
+
index : int
|
|
58
|
+
The index of the surface shape to be set in the list.
|
|
59
|
+
surface_shape : instances of SurfaceShape, optional
|
|
60
|
+
The surface shape to be set (If None, initialize to SurfaceShape())
|
|
61
|
+
|
|
62
|
+
"""
|
|
63
|
+
if surface_shape is None: surface_shape = SurfaceShape()
|
|
64
|
+
try: self._surface_shapes[index] = surface_shape
|
|
65
|
+
except: raise Exception("only " + str(len(self._surface_shapes)) + " shapes in OpticalElementsWithMultipleShapes")
|
|
66
|
+
|
|
67
|
+
class OpticalElementsWithSurfaceShape(OpticalElementsWithMultipleShapes):
|
|
68
|
+
"""
|
|
69
|
+
Constructor.
|
|
70
|
+
|
|
71
|
+
Parameters
|
|
72
|
+
----------
|
|
73
|
+
name : str
|
|
74
|
+
The optical elemnt name.
|
|
75
|
+
surface_shape : instances of SurfaceShape
|
|
76
|
+
The surface shape.
|
|
77
|
+
boundary_shape : instance of BoundaryShape, optional
|
|
78
|
+
The element shape. The default=None means no shape associated to the optical element.
|
|
79
|
+
"""
|
|
80
|
+
def __init__(self, name, surface_shape=None, boundary_shape=None):
|
|
81
|
+
super(OpticalElementsWithSurfaceShape, self).__init__(name=name,
|
|
82
|
+
boundary_shape=boundary_shape,
|
|
83
|
+
surface_shapes=[surface_shape])
|
|
84
|
+
|
|
85
|
+
# these definitions are necessary to define self._surface_shape which is needed to
|
|
86
|
+
# build the object instance from json files.
|
|
87
|
+
@property
|
|
88
|
+
def _surface_shape(self):
|
|
89
|
+
return self.get_surface_shape()
|
|
90
|
+
|
|
91
|
+
@_surface_shape.setter
|
|
92
|
+
def _surface_shape(self, value):
|
|
93
|
+
self.set_surface_shape(value)
|
|
94
|
+
|
|
95
|
+
def get_surface_shape(self):
|
|
96
|
+
"""
|
|
97
|
+
Gets the surface shape.
|
|
98
|
+
|
|
99
|
+
Returns
|
|
100
|
+
-------
|
|
101
|
+
instance of SurfaceShape
|
|
102
|
+
The requested surface shape.
|
|
103
|
+
|
|
104
|
+
"""
|
|
105
|
+
return super(OpticalElementsWithSurfaceShape, self).get_surface_shape(index=0)
|
|
106
|
+
|
|
107
|
+
def set_surface_shape(self, surface_shape=None):
|
|
108
|
+
"""
|
|
109
|
+
Sets a surface shape.
|
|
110
|
+
|
|
111
|
+
Parameters
|
|
112
|
+
----------
|
|
113
|
+
surface_shape : instances of SurfaceShape, optional
|
|
114
|
+
The surface shape to be set (If None, initialize to SurfaceShape())
|
|
115
|
+
|
|
116
|
+
"""
|
|
117
|
+
super(OpticalElementsWithSurfaceShape, self).set_surface_shape(index=0, surface_shape=surface_shape)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__=="__main__":
|
|
121
|
+
from syned.beamline.shape import Cylinder, EllipticalCylinder
|
|
122
|
+
|
|
123
|
+
oe = OpticalElementsWithSurfaceShape(name="TEST", surface_shape=Cylinder())
|
|
124
|
+
print(oe.get_surface_shape())
|
|
125
|
+
oe.set_surface_shape(surface_shape=EllipticalCylinder())
|
|
126
|
+
print(oe.get_surface_shape())
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|