\(\renewcommand\AA{\unicode{x212B}}\)
PredictPeaks v1¶
Summary¶
Using a known crystal lattice and UB matrix, predict where single crystal peaks should be found in detector/TOF space. Creates a PeaksWorkspace containing the peaks at the expected positions.
See Also¶
Properties¶
Name |
Direction |
Type |
Default |
Description |
---|---|---|---|---|
InputWorkspace |
Input |
Mandatory |
An input workspace (MatrixWorkspace, MDEventWorkspace, or PeaksWorkspace) containing: - The relevant Instrument (calibrated as needed). - A sample with a UB matrix. - The goniometer rotation matrix. |
|
WavelengthMin |
Input |
number |
0.1 |
Minimum wavelength limit at which to start looking for single-crystal peaks. |
WavelengthMax |
Input |
number |
100 |
Maximum wavelength limit at which to stop looking for single-crystal peaks. |
MinDSpacing |
Input |
number |
1 |
Minimum d-spacing of peaks to consider. Default = 1.0 |
MaxDSpacing |
Input |
number |
100 |
Maximum d-spacing of peaks to consider. |
CalculateGoniometerForCW |
Input |
boolean |
False |
This will calculate the goniometer rotation (around y-axis only) for a constant wavelength. |
Wavelength |
Input |
number |
Optional |
Wavelength to use when calculating goniometer angle |
InnerGoniometer |
Input |
boolean |
False |
Whether the goniometer to be calculated is the most inner (phi) or most outer (omega) |
FlipX |
Input |
boolean |
False |
Used when calculating goniometer angle if the q_lab x value should be negative, hence the detector of the other side (right) of the beam |
MinAngle |
Input |
number |
-180 |
Minimum goniometer rotation angle |
MaxAngle |
Input |
number |
180 |
Maximum goniometer rotation angle |
ReflectionCondition |
Input |
string |
Primitive |
Which reflection condition applies to this crystal, reducing the number of expected HKL peaks? Allowed values: [‘Primitive’, ‘C-face centred’, ‘A-face centred’, ‘B-face centred’, ‘Body centred’, ‘All-face centred’, ‘Rhombohedrally centred, obverse’, ‘Rhombohedrally centred, reverse’, ‘Hexagonally centred, reverse’] |
CalculateStructureFactors |
Input |
boolean |
False |
Calculate structure factors for the predicted peaks. This option only works if the sample of the input workspace has a crystal structure assigned. |
HKLPeaksWorkspace |
Input |
IPeaksWorkspace |
Optional: An input PeaksWorkspace with the HKL of the peaks that we should predict. The WavelengthMin/Max and Min/MaxDSpacing parameters are unused if this is specified. |
|
RoundHKL |
Input |
boolean |
True |
When using HKLPeaksWorkspace, this will round the HKL values in the HKLPeaksWorkspace to the nearest integers if checked. Keep unchecked to use the original values |
OutputType |
Input |
string |
Peak |
Type of Peak in OutputWorkspace. Allowed values: [‘Peak’, ‘LeanElasticPeak’] |
CalculateWavelength |
Input |
boolean |
True |
When OutputType is LeanElasticPeak you can choose to calculate the wavelength of the peak using the instrument and check it is in the valid range or alternatively just accept every peak while not setting the goniometer (Q-lab will be incorrect). |
OutputWorkspace |
Output |
IPeaksWorkspace |
Mandatory |
An output PeaksWorkspace. |
PredictPeaksOutsideDetectors |
Input |
boolean |
False |
Use an extended detector space (if defined for the instrument) to predict peaks which do not fall onto anydetector. This may produce a very high number of results. |
EdgePixels |
Input |
number |
0 |
Remove peaks that are at pixels this close to edge. |
Description¶
This algorithm will predict the position of single-crystal diffraction peaks (both in detector position/TOF and Q-space) and create an output PeaksWorkspace containing the result when OutputType is set to Peak, otherwise a LeanElasticPeaksWorkspace will be created that only has the Q-space positions.
This algorithm uses the InputWorkspace to determine the instrument in
use, as well as the UB matrix and Unit Cell of the
sample used. You can use the CopySample v1 algorithm (with
CopyLattice=1
) to copy a UB matrix from a
PeaksWorkspace to another workspace.
The algorithm operates by calculating the scattering direction (given the UB matrix) for a particular HKL, and determining whether that hits a detector. The Max/MinDSpacing parameters are used to determine what HKL’s to try.
The parameters of WavelengthMin/WavelengthMax also limit the peaks attempted to those that can be detected/produced by your instrument.
Furthermore it’s possible to calculate structure factors for the predicted peaks by activating the CalculateStructureFactors-option. For this to work the sample needs to have a crystal structure stored, which can currently be achieved as in the following example:
from mantid.geometry import CrystalStructure
import numpy as np
# Generate a workspace with an instrument definition
ws = CreateSimulationWorkspace(Instrument='WISH',
BinParams='0,10000,20000',
UnitX='TOF')
# Set a random UB, in this case for an orthorhombic structure
SetUB(ws, a=5.5, b=6.5, c=8.1, u='12,1,1', v='0,4,9')
# Set an arbitrary crystal structure with 2 atoms and some
# systematic absences due to space group Pbca
cs = CrystalStructure('5.5 6.5 8.1', 'P b c a',
"""Ni 0.232 0.114 0.543 1.0 0.00843;
Al 0.434 0.041 0.854 1.0 0.01120""")
ws.sample().setCrystalStructure(cs)
predicted = PredictPeaks(InputWorkspace=ws,
CalculateStructureFactors=True,
MinDSpacing=0.5,
WavelengthMin=0.9, WavelengthMax=6.0)
print('There are {} detectable peaks.'.format(predicted.getNumberPeaks()))
intensities = np.array(predicted.column('Intens'))
maxIntensity = np.max(intensities)
relativeIntensities = intensities / maxIntensity
print('Maximum intensity: {0:.2f}'.format(maxIntensity))
print('Peaks with relative intensity < 1%: {}'.format(len([x for x in relativeIntensities if x < 0.01])))
absences = [i for i, x in enumerate(intensities) if x < 1e-9]
print('Number of absences: {}'.format(len(absences)))
print('Absent HKLs: {}'.format([predicted.getPeak(i).getHKL() for i in absences]))
The script provides some information about the predicted peaks and their structure factors. Additionally it prints out the HKL of peaks with predicted structure factor very close to 0, which are absent:
There are 295 detectable peaks.
Maximum intensity: 6101.93
Peaks with relative intensity < 1%: 94
Number of absences: 16
Absent HKLs: [[2,0,-1], [6,0,-3], [10,0,-5], [3,0,-1], [4,0,-1], [5,0,-1], [6,0,-1], [7,0,-3], [7,0,-1], [8,0,-3], [8,0,-1], [9,-1,0], [9,0,-3], [9,0,-1], [10,0,-3], [10,0,-1]]
All absent HKLs have the form H0L with odd L. This fits with the reflection conditions given for \(Pbca\) in the International Tables for Crystallography A.
Please note that the calculated structure factors are currently not corrected for any instrument effects, so depending on instrument geometry and other factors (detector efficiency etc.) measured intensities will deviate from these values. They can however provide an estimate for which reflections might be especially strong or weak.
Using HKLPeaksWorkspace¶
If you specify the HKLPeaksWorkspace parameter, then the algorithm will use the list of HKL in that workspace as the starting point of HKLs, instead of doing all HKLs within range of Max/MinDSpacing and WavelengthMin/WavelengthMax.
A typical use case for this method is to use FindPeaksMD v1 followed by IndexPeaks v1 to find the HKL of each peak. The HKLs found will be floats, so specify RoundHKL=True in PredictPeaks to predict the position at the exact integer HKL. This may help locate the center of peaks.
Another way to use this algorithm is to use CreatePeaksWorkspace v1 to create a workspace with the desired number of peaks. Use python or the GUI to enter the desired HKLs. If these are fraction (e.g. magnetic peaks) then make sure RoundHKL=False.
Calculate Goniometer For Constant Wavelength¶
If you select the “CalculateGoniometerForCW” option instead of using the goniometer from the input workspace it will calculate the goniometer rotation, assuming a constant wavelength and that the rotation is around the y-axis only. For details on the calculation see “Calculate Goniometer For Constant Wavelength” at FindPeaksMD.
Categories: AlgorithmIndex | Crystal\Peaks
Source¶
C++ header: PredictPeaks.h
C++ source: PredictPeaks.cpp