mcstasscript.tools.cryostat_builder.Cryostat
mcstasscript.tools.cryostat_builder.Cryostat¶
- class mcstasscript.tools.cryostat_builder.Cryostat(name, instr, reference='PREVIOUS', min_priority=20, max_priority=100)¶
- __init__(name, instr, reference='PREVIOUS', min_priority=20, max_priority=100)¶
Handles addition of a cryostat with multiple layers and windows
This class can add a description of a cryostat to a McStasScript instrument object. The cryostat is made of several layers consisting of a shell and vacuum, these are added with the add_layer method and should be added in the order from smallest (inside) to largest. Each layer can be accessed with the last_layer attribute, and one can add windows to each layer. Consult the Layer class for details. When all layers are added, it is necessary to build the cryostat, this step is necessary to adjust the priority of each Union component. The position of the cryostat can be adjusted with the set_AT and set_ROTATED methods that works as the standard McStasScript versions. It is possible to add logger components that show scattering in the system with the add_spatial_loggers method. The position of the cryostat refers to the sample position and is called the origin. It can be placed in McStas with set_AT and set_ROTATED methods on the cryostat object.
- Parameters
name (str) – Name of the cryostat, will be used in naming of all added components
instr (instrument object inherited from McCode_instr) – Instrument object where the cryostat should be added
- Keyword Arguments
reference (str) – Name of the component which the cryostat should be located relative to
min_priority (float) – Minimum Union priority used (default 20)
max_priority (float) – Maximum Union priority used, add a sample with higher priority (default 100)
Methods
__init__
(name, instr[, reference, ...])Handles addition of a cryostat with multiple layers and windows
add_animation
([t_min, t_max, n_frames, d1, ...])Adds 2D_space_time logger that records the information necessary for animation
add_layer
(*args, **kwargs)Adds layer to cryostat, all arguments passed to Layer.
add_radius
(value)Adds a radius to databse, checking if it is already present
add_spatial_loggers
([n_x, n_y, n_z])Adds spatial Union loggers to the code
add_time_histogram
([t_min, t_max])Adds histogram of scattering intensity as function of time
add_y_plane
(value)Adds a y plane to database, checking if it is already present
build
([include_master])Assigns priorities to the internal components of the cryostat
Returns spatial extend of cryostat with padding for plotting
set_AT
(*args, **kwargs)Sets position of cryostat, sample position used as reference
set_ROTATED
(*args, **kwargs)Sets rotation of cryostat, sample position used as reference
- add_animation(t_min=0, t_max=0.1, n_frames=10, d1='z', n1=300, d2='y', n2=300)¶
Adds 2D_space_time logger that records the information necessary for animation
Adds a 2D_space_time logger that records the requested number of frames, n_frames. The time span of both is from t_min to t_max. The default orientation is in the zy plane, but this can be chosen along with the desired resolution. Errors can happen with too many empty frames, so it is recommended to set t_min close to the first scattering time. Select the appropriate animation data from simulation output and use plotter.make_animation with a filename to save the animation as a gif.
- Parameters
t_min (float) – Lowest time recorded in [s]
t_max (float) – Highest time recorded in [s]
n_frames (int) – Number of frames in space 2D time logger
d1 (str) – First direction of space 2D time logger, “x”, “y” or “z”
n1 (int) – Number of bins in first direction
d2 (str) – Second direction of space 2D time logger, “x”, “y” or “z”
n2 (int) – Number of bins in second direction
- add_layer(*args, **kwargs)¶
Adds layer to cryostat, all arguments passed to Layer. Consult Layer class for additional help on adding a layer.
- add_radius(value)¶
Adds a radius to databse, checking if it is already present
If duplicates occur, errors would happen in the Union algorithm
- add_spatial_loggers(n_x=500, n_y=500, n_z=500)¶
Adds spatial Union loggers to the code
The spatial loggers will be set so they cover the entire cryostat and include views from top, side and front along with a close up of the windows as a slice in zy with limited z of +/- 5 mm.
- Keyword Arguments
n_x (int) – Number of bins in x direction
n_y (int) – Number of bins in y direction
n_z (int) – Number of bins in z direction
- add_time_histogram(t_min=0, t_max=0.1)¶
Adds histogram of scattering intensity as function of time
Very useful when setting time range for animation, only one can be added.
- Parameters
t_min (float) – Lowest time recorded in [s]
t_max (float) – Highest time recorded in [s]
- add_y_plane(value)¶
Adds a y plane to database, checking if it is already present
If duplicates occur, errors would happen in the Union algorithm
- build(include_master=True)¶
Assigns priorities to the internal components of the cryostat
The build method must be called after all layers and windows are added in order for priorities to be assigned according to the priority window given at class initialization. It is optional to include the Union_master with the build method, if it is not included it must be manually provided later.
- Keyword Arguments
inclde_master (bool) – If True a Union_master component is added to the instrument file
- find_cryostat_dimensions()¶
Returns spatial extend of cryostat with padding for plotting
Returns tuple with x, lowest y, highest y and z
- set_AT(*args, **kwargs)¶
Sets position of cryostat, sample position used as reference
- set_ROTATED(*args, **kwargs)¶
Sets rotation of cryostat, sample position used as reference