\(\renewcommand\AA{\unicode{x212B}}\)
Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | InOut | Workspace | Mandatory | A workspace whose sample properties will be updated |
Geometry | Input | Dictionary | A dictionary of geometry parameters for the sample. | |
Material | Input | Dictionary | A dictionary of material parameters for the sample. See SetSampleMaterial for all accepted parameters | |
Environment | Input | Dictionary | A dictionary of parameters to configure the sample environment | |
ContainerGeometry | Input | Dictionary | A dictionary of geometry parameters for the container. | |
ContainerMaterial | Input | Dictionary | A dictionary of material parameters for the container. |
Set properties of the sample and its environment on a workspace.
The arguments to this algorithm are all expected to be dictionaries specifying multiple parameters that relate to the respective argument, as explained below.
Note
Contrary to the xml forms of defining the geometry which are in metres,
dict
versions are in centimetres.
Specifies the shape of the sample (and container). This can be specified in the following ways:
For defining the full shape a key called Shape
specifying the desired shape is
expected along with additional keys specifying the values (all values are assumed to
be in centimeters):
FlatPlate
: Width, Height, Thick, Center, AngleCylinder
: Height, Radius, CenterHollowCylinder
: Height, InnerRadius, OuterRadius, CenterFlatPlateHolder
: Width, Height, Thick, Center, Angle, FrontThick, BackThick. This is a CSG union of 2 FlatPlates tightly wrapping a FlatPlate sample. To be used for the ContainerGeometry.HollowCylinderHolder
: Height, InnerRadius, InnerOuterRadius, OuterInnerRadius, OuterRadius, Center. This is a CSG union of 2 HollowCylinders tightly wrapping a HollowCylinder sample. To be used for the ContainerGeometry.CSG
: Value is a string containing any generic shape as detailed in How To Define Geometric ShapeThe Center
key is expected to be a list of three values indicating the [X,Y,Z]
position of the center, which would be the geometrical center of the shape.
The reference frame of the defined instrument is used to
set the coordinate system for the shape.
The Angle
argument for a flat plate shape is expected to be in degrees and is defined as
the angle between the positive beam axis and the normal to the face perpendicular to the
beam axis when it is not rotated, increasing in an anti-clockwise sense. The rotation is
performed about the vertical axis of the instrument’s reference frame.
Specifies the composition of the sample (or its container) using properties from the SetSampleMaterial v1 algorithm. Please see the algorithm documentation for the supported keywords.
Note
Note that for the keys which historically had the Sample prefix (e.g. SampleNumberDensity) the prefix should not be specified here; that is, NumberDensity instead of SampleNumberDensity, etc. However, for backwards compatibility, it works also with prefixes.
Note
Note that this algorithm does not invoke SetSampleMaterial v1 anymore, but sets the material directly through the API.
Specifies the sample environment kit to be used. There are two possibilities:
In this case the environment kit must be defined in the XML format. See Sample Environment concept page for further details on how the creating a definition file.
Two keywords must be specified in the Environment
dictionary:
Name
: The name of the predefined kit (required)Container
: The id of the container within the predefined kit. (required if there is more than one container defined for the kit).The name of a kit must be unique for a given instrument. The following
procedure is used when trying to find a named definition, e.g CRYO-01
:
FACILITY
& INSTRUMENT
respectivelyFACILITY
& INSTRUMENT
respectively.xml
to the given kit nameINSTDIR
) in turn:INSTDIR/sampleenvironments/FACILITY/INSTRUMENT/CRYO-01.xml
INSTDIR
You can specify the geometry and the material of a single container directly with the ContainerGeometry and ContainerMaterial dictionaries. This option is used only when Environment input is left blank. See the sections above for the available keywords to configure those.
The following example uses a test file called CRYO-01.xml
in the
[INSTALLDIR]/instrument/sampleenvironments/TEST_LIVE/ISIS_Histogram/
directory.
If the examples are run via the Mantid user interface then double instead of single quotes will need to be used for the dictionary parameters.
Example - Container with preset cylinderical sample geometry
# A fake host workspace, replace this with your real one.
ws = CreateSampleWorkspace()
# Use geometry as is from environment definition
SetSample(ws, Environment={'Name': 'CRYO-01', 'Container': '8mm'},
Material={'ChemicalFormula': '(Li7)2-C-H4-N-Cl6',
'NumberDensity': 0.1})
Example - Override height of preset cylinder sample
# A fake host workspace, replace this with your real one.
ws = CreateSampleWorkspace()
# Use geometry from environment but set different height for sample
SetSample(ws, Environment={'Name': 'CRYO-01', 'Container': '8mm'},
Geometry={'Height': 4.0},
Material={'ChemicalFormula': '(Li7)2-C-H4-N-Cl6',
'NumberDensity': 0.1})
Example - Specify height and mass of preset cylinder sample
# A fake host workspace, replace this with your real one.
ws = CreateSampleWorkspace()
# Use geometry from environment but set different height for sample
# and calculate density with supplied sample mass
SetSample(ws, Environment={'Name': 'CRYO-01', 'Container': '8mm'},
Geometry={'Height': 4.0},
Material={'ChemicalFormula': '(Li7)2-C-H4-N-Cl6',
'Mass': 3.0})
Example - Override complete sample geometry
# A fake host workspace, replace this with your real one.
ws = CreateSampleWorkspace()
# Use geometry from environment but set different height for sample
SetSample(ws, Environment={'Name': 'CRYO-01', 'Container': '8mm'},
Geometry={'Shape': 'HollowCylinder', 'Height': 4.0,
'InnerRadius': 0.8, 'OuterRadius': 1.0,
'Center': [0.,0.,0.]},
Material={'ChemicalFormula': '(Li7)2-C-H4-N-Cl6',
'NumberDensity': 0.1})
Example - Specify shape using CSG object
# A fake host workspace, replace this with your real one.
ws = CreateSampleWorkspace()
# Specify a Sphere geometry using CSG
sphere_xml = " \
<sphere id='some-sphere'> \
<centre x='0.0' y='0.0' z='0.0' /> \
<radius val='0.5' /> \
</sphere> \
<algebra val='some-sphere' /> \
"
# Set sample geometry of workspace to this CSG object Sphere
SetSample(ws, Geometry={'Shape': 'CSG', 'Value': sphere_xml})
Example - Flat plate sample in a flat plate holder container
# A fake host workspace, replace this with your real one.
ws = CreateSampleWorkspace()
SetSample(ws,
Geometry={'Shape': 'FlatPlate', 'Height': 4.0,
'Width': 2.0, 'Thick': 1.0,
'Center': [0.,0.,0.]},
Material={'ChemicalFormula': '(Li7)2-C-H4-N-Cl6',
'NumberDensity': 0.1},
ContainerGeometry={'Shape': 'FlatPlateHolder', 'Height': 4.0,
'Width': 2.0, 'Thick': 1.0, 'FrontThick': 0.3, 'BackThick': 0.4,
'Center': [0.,0.,0.]},
ContainerMaterial={'ChemicalFormula': 'Al',
'NumberDensity': 0.01})
Example - Cylinder sample in a hollow cylinder container
# A fake host workspace, replace this with your real one.
ws = CreateSampleWorkspace()
SetSample(ws,
Geometry={'Shape': 'Cylinder', 'Height': 4.0,
'Radius': 2.0, 'Center': [0.,0.,0.]},
Material={'ChemicalFormula': '(Li7)2-C-H4-N-Cl6',
'NumberDensity': 0.1},
ContainerGeometry={'Shape': 'HollowCylinder', 'Height': 4.0,
'InnerRadius': 2.0, 'OuterRadius': 2.3,
'Center': [0.,0.,0.]},
ContainerMaterial={'ChemicalFormula': 'Al',
'NumberDensity': 0.01})
Example - Hollow cylinder sample in a hollow cylinder holder container
# A fake host workspace, replace this with your real one.
ws = CreateSampleWorkspace()
SetSample(ws,
Geometry={'Shape': 'HollowCylinder', 'Height': 4.0,
'InnerRadius': 2.0, 'OuterRadius': 3.0, 'Center': [0.,0.,0.]},
Material={'ChemicalFormula': '(Li7)2-C-H4-N-Cl6',
'NumberDensity': 0.1},
ContainerGeometry={'Shape': 'HollowCylinderHolder', 'Height': 4.0,
'InnerRadius': 1.5, 'InnerOuterRadius': 2.0, 'OuterInnerRadius': 3.0, 'OuterRadius': 4.0,
'Center': [0.,0.,0.]},
ContainerMaterial={'ChemicalFormula': 'Al',
'NumberDensity': 0.01})
Example - SetGoniometer to apply automatic rotation to Sample Shape.
SetSample can be used to apply an automatic goniometer rotation. SetGoniometer should be called before SetSample. After running this example code to rotate a cuboid by 30° anti-clockwise around y, the sample shape can be plotted (see 3D Mesh Plots for Sample Shapes):
cuboid = " \
<cuboid id='some-cuboid'> \
<height val='2.0' /> \
<width val='2.0' /> \
<depth val='0.2' /> \
<centre x='10.0' y='10.0' z='10.0' /> \
</cuboid> \
<algebra val='some-cuboid' /> \
"
ws = CreateSampleWorkspace()
SetGoniometer(ws, Axis0="30,0,1,0,-1")
SetSample(ws, Geometry={'Shape': 'CSG', 'Value': cuboid})
(Source code, png, hires.png, pdf)
Categories: AlgorithmIndex | Sample
C++ header: SetSample.h (last modified: 2021-03-31)
C++ source: SetSample.cpp (last modified: 2021-08-03)