Mantid
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Member Functions | List of all members
Mantid::Geometry::ScalarUtils Class Reference

This class contains static utility methods for determining an orientation matrix corresponding to a conventional, given the orientation matrix corresponding to the Niggli reduced cell. More...

#include <ScalarUtils.h>

Static Public Member Functions

static ConventionalCell GetCellBestError (const std::vector< ConventionalCell > &list, bool use_triclinic)
 Get the cell from the list with the smallest error, possibly excluding triclinic cells. More...
 
static ConventionalCell GetCellForForm (const Kernel::DblMatrix &UB, size_t form_num, bool allowPermutations=false)
 Get the best conventional cell for the form number, using the specified UB, and three related "almost Niggli" cells obtained by reflecting pairs of sides a, b, c. More...
 
static std::vector< ConventionalCellGetCells (const Kernel::DblMatrix &UB, bool best_only, bool allowPermutations=false)
 Get list of all possible conventional cells for UB, regardless of errors, using this UB, and three related "almost Niggli" cells obtained by reflecting pairs of sides a, b, c. More...
 
static std::vector< ConventionalCellGetCells (const Kernel::DblMatrix &UB, const std::string &cell_type, const std::string &centering, bool allowPermutations=false)
 Get list of conventional cells for UB with specified type and centering, using this UB, and three related "almost Niggli" cells obtained by reflecting pairs of sides a, b, c. More...
 
static std::vector< ConventionalCellGetCellsUBOnly (const Kernel::DblMatrix &UB, const std::string &cell_type, const std::string &centering, bool allowPermutations=false)
 Get list of conventional cells for UB with specified type and centering, using ONLY this UB, not related reflected cells. More...
 
static std::vector< Kernel::DblMatrixGetRelatedUBs (const Kernel::DblMatrix &UB, double factor, double angle_tolerance)
 Get list of related cells obtained by reflecting pairs of sides with nearly a 90 degree angle between the sides, and permuting sides. More...
 
static void RemoveHighErrorForms (std::vector< ConventionalCell > &list, double level)
 Remove cells from list that have scalar errors above the specified level. More...
 

Static Private Member Functions

static void AddIfBest (std::vector< ConventionalCell > &list, ConventionalCell &info)
 Add conventional cell to list if it has the least error for its form num. More...
 

Detailed Description

This class contains static utility methods for determining an orientation matrix corresponding to a conventional, given the orientation matrix corresponding to the Niggli reduced cell.

Author
Dennis Mikkelson
Date
2012-01-12

Definition at line 32 of file ScalarUtils.h.

Member Function Documentation

◆ AddIfBest()

void ScalarUtils::AddIfBest ( std::vector< ConventionalCell > &  list,
ConventionalCell info 
)
staticprivate

Add conventional cell to list if it has the least error for its form num.

Add the conventional cell record to the list if there is not already an entry with the same form number, or replace the entry that has the same form number with the specified cell info, if the specified cell info has a smaller error.

NOTE: The list must initially contain at most one entry with the same form number as the specified ConventionalCellInfo object. That list property will be maintained by this method.

Parameters
listThe initial list of ConventionalCell objects.
infoThe new ConventionalCell object that might be added to the list.

Definition at line 418 of file ScalarUtils.cpp.

References Mantid::Geometry::ConventionalCell::GetError(), and Mantid::Geometry::ConventionalCell::GetFormNum().

Referenced by GetCells().

◆ GetCellBestError()

ConventionalCell ScalarUtils::GetCellBestError ( const std::vector< ConventionalCell > &  list,
bool  use_triclinic 
)
static

Get the cell from the list with the smallest error, possibly excluding triclinic cells.

Get the cell info object that has the smallest error of any of the cells in the list.

If use_triclinc is false, this will skip triclinic cells in the list, and return the non-triclinic cell with the smallest error of all non-triclinic cells. If there is no such cell, or if the list is empty, this will throw an exception.

Parameters
listThe list of conventional cell info objects.
use_triclinicIf false, skip any triclinic cells in the list when checking for smallest error.
Returns
The entry in the list with the smallest error.

Definition at line 280 of file ScalarUtils.cpp.

References error, Mantid::Geometry::ConventionalCell::GetCellType(), and Mantid::Geometry::ReducedCell::TRICLINIC().

Referenced by Mantid::Crystal::SelectCellOfType::exec(), and GetCells().

◆ GetCellForForm()

ConventionalCell ScalarUtils::GetCellForForm ( const Kernel::DblMatrix UB,
size_t  form_num,
bool  allowPermutations = false 
)
static

Get the best conventional cell for the form number, using the specified UB, and three related "almost Niggli" cells obtained by reflecting pairs of sides a, b, c.

Get one cell, the for specified UB and form, by trying different reflections of a,b,c and forming the ConventionalCellInfo object corresponding to the smallest form error.

Parameters
UBCrystal::Orientation transformation corresponding to a Niggli reduced cell.
form_numThe form number to use.
allowPermutationsAllow permutations of conventional cells for related UBs with better fit to peaks.
Returns
A ConventionalCellInfo object corresponding to the specified form number and UB (or a related matrix) with the smallest error of any related matrix.

Definition at line 217 of file ScalarUtils.cpp.

References error, Mantid::Geometry::IndexingUtils::GetLatticeParameters(), GetRelatedUBs(), and Mantid::Geometry::ReducedCell::WeightedDistance().

Referenced by Mantid::Crystal::SelectCellWithForm::exec().

◆ GetCells() [1/2]

std::vector< ConventionalCell > ScalarUtils::GetCells ( const Kernel::DblMatrix UB,
bool  best_only,
bool  allowPermutations = false 
)
static

Get list of all possible conventional cells for UB, regardless of errors, using this UB, and three related "almost Niggli" cells obtained by reflecting pairs of sides a, b, c.

Get a list of cell info objects, corresponding to all forms that match the specified UB, or related UBs, with pairs of edges reflected.

If the same form number matches several times when different pairs of edges are reflected, only the one with the smallest error value will be included. A pair of edges will be reflected if the angle between the edges is within 2 degrees of 90 degrees. This is needed to take care of the case where a positive Niggli cell was found, but due to errors in the data, a negative Niggli cell should have been found, and visa-versa.

Parameters
UBThe lattice parameters for this UB matrix and matrices related to it by reflecting pairs of sides, are used to form the list of possible conventional cells.
best_onlyIf true, only include the best form for each Bravais lattice.
allowPermutationsAllow permutations of conventional cells for related UBs with better fit to peaks.
Returns
a vector of conventional cell info objects, corresponding to the best matching forms for UB and cells related to UB by reflections of pairs of cell edges.

Definition at line 91 of file ScalarUtils.cpp.

References AddIfBest(), BRAVAIS_CENTERING, BRAVAIS_TYPE, GetCellBestError(), and GetCells().

Referenced by Mantid::Crystal::SelectCellOfType::exec(), Mantid::Crystal::ShowPossibleCells::exec(), and GetCells().

◆ GetCells() [2/2]

std::vector< ConventionalCell > ScalarUtils::GetCells ( const Kernel::DblMatrix UB,
const std::string &  cell_type,
const std::string &  centering,
bool  allowPermutations = false 
)
static

Get list of conventional cells for UB with specified type and centering, using this UB, and three related "almost Niggli" cells obtained by reflecting pairs of sides a, b, c.

Get a list of cell info objects, corresponding to all forms that match the specified UB, or related UBs, with pairs of edges reflected, and have the specified cell type and centering.

If the same form number matches several times when different pairs of edges are reflected, only the one with the smallest error value will be included. A pair of edges will be reflected if the angle between the edges is within 2 degrees of 90 degrees. This is needed to take care of the case where a positive Niggli cell was found, but due to errors in the data, a negative Niggli cell should have been found, and visa-versa.

Parameters
UBThe lattice parameters for this UB matrix and matrices related to it by reflecting pairs of sides, are used to form the list of possible conventional cells.
cell_typeString specifying the cell type, as listed in the ReducedCell class.
centeringString specifying the centering, as listed in the ReducedCell class.
allowPermutationsAllow permutations of conventional cells for related UBs with better fit to peaks.
Returns
a vector of conventional cell objects, for the specified cell type and centering, corresponding to the best matching forms for UB and cells related to UB by reflections of pairs of cell edges.

Definition at line 135 of file ScalarUtils.cpp.

References AddIfBest(), GetCellsUBOnly(), and GetRelatedUBs().

◆ GetCellsUBOnly()

std::vector< ConventionalCell > ScalarUtils::GetCellsUBOnly ( const Kernel::DblMatrix UB,
const std::string &  cell_type,
const std::string &  centering,
bool  allowPermutations = false 
)
static

Get list of conventional cells for UB with specified type and centering, using ONLY this UB, not related reflected cells.

Get a list of cell info objects that correspond to the specific given UB matrix.

The list will have at most one instance of any matching form since only the specified UB matrix is used (no reflections or other related cell modifications). For any form with the specified cell type and centering, a cell info object will be added to the list, regardless of the error in cell scalars. As a result, the list returned by this method will often have forms that don't fit well. However, the list will be a complete list of matching forms for the specified UB, cell_type and centering. Poorly matching entries can be removed subsequently by the calling code, if need be.

Parameters
UBThe lattice parameters for this UB matrix are used to form the list of possible conventional cells.
cell_typeString specifying the cell type, as listed in the ReducedCell class.
centeringString specifying the centering, as listed in the ReducedCell class.
allowPermutationsAllow permutations of conventional cells for related UBs with better fit to peaks.
Returns
a list of conventional cells for the specified UB, of the specified type and centering.

Definition at line 182 of file ScalarUtils.cpp.

References Mantid::Geometry::ReducedCell::GetCellType(), Mantid::Geometry::ReducedCell::GetCentering(), Mantid::Geometry::IndexingUtils::GetLatticeParameters(), and Mantid::Geometry::ReducedCell::NUM_CELL_TYPES.

Referenced by GetCells().

◆ GetRelatedUBs()

std::vector< DblMatrix > ScalarUtils::GetRelatedUBs ( const Kernel::DblMatrix UB,
double  factor,
double  angle_tolerance 
)
static

Get list of related cells obtained by reflecting pairs of sides with nearly a 90 degree angle between the sides, and permuting sides.

Get a list of UB matrices that are related to the specified UB.

The related UBs are generated by both reflecting pairs of of the unit cell edge vectors a,b,c and permuting the resulting edge vectors in ways that preserve the handedness of the cell. For example replacing a,b,c with b,c,a would preserve the handedness, but replacing a,b,c with a,c,b would not. In this case we would also need to negate side a, so we would replace a,b,c with -a,c,b. A permutation of the sides is only used provided the sides are still "essentially" in increasing order. The specified factor provides a tolerance to relax the restriction that |a|<=|b|<=|c|. As long as a side is less than or equal to the following side times the specified factor, it is considered less than or equal to the following side, for purposes of checking whether or not the list of sides could form a Niggli cell. This provides a tolerance for experimental error. Two sides will be reflected across the origin if the angle between them is within the specified angle_tolerance of 90 degrees. This will help find the correct Niggli cell for cases where the angle is near 90 degrees. In particular, if a positive Niggli cell was found with an angle near 90 degrees, due to errors in the data, it possibly should have been a negative Niggli cell. Adding the cases with reflected sides for angles near 90 degrees will include the opposite sign Niggli cell so it is also checked.

Parameters
UBThe original matrix (should be for Niggli cell)
factorTolerance for error in real-space cell edge lengths.
angle_toleranceTolerance for angles near 90 degree.
Returns
A vector of UB matrices related to the original UB matrix by reflections of pairs of the side vectors a, b, c.

Definition at line 339 of file ScalarUtils.cpp.

References Mantid::Kernel::V3D::angle(), fabs, Mantid::Geometry::OrientedLattice::GetABC(), Mantid::Geometry::OrientedLattice::GetUB(), and Mantid::Kernel::V3D::norm().

Referenced by GetCellForForm(), and GetCells().

◆ RemoveHighErrorForms()

void ScalarUtils::RemoveHighErrorForms ( std::vector< ConventionalCell > &  list,
double  level 
)
static

Remove cells from list that have scalar errors above the specified level.

Remove any forms from the list that have errors that are above the specified level.

Parameters
listThe list of conventional cell objects to be cleaned up.
levelThis specifies the maximum error for cells that will not be discarded from the list.

Definition at line 259 of file ScalarUtils.cpp.

Referenced by Mantid::Crystal::ShowPossibleCells::exec().


The documentation for this class was generated from the following files: