Mantid
Loading...
Searching...
No Matches
BasicHKLFilters.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#include <utility>
8
10
11namespace Mantid::Geometry {
12
14HKLFilterDRange::HKLFilterDRange(const UnitCell &cell, double dMin) : m_cell(cell), m_dmin(dMin) {
15 m_dmax = std::max(m_cell.a(), std::max(m_cell.b(), m_cell.c()));
16
18}
19
21HKLFilterDRange::HKLFilterDRange(const UnitCell &cell, double dMin, double dMax)
22 : m_cell(cell), m_dmin(dMin), m_dmax(dMax) {
24}
25
27std::string HKLFilterDRange::getDescription() const noexcept {
28 std::ostringstream strm;
29 strm << "(" << m_dmin << " <= d <= " << m_dmax << ")";
30
31 return strm.str();
32}
33
35bool HKLFilterDRange::isAllowed(const Kernel::V3D &hkl) const noexcept {
36 double d = m_cell.d(hkl);
37
38 return d >= m_dmin && d <= m_dmax;
39}
40
43 if (m_dmin <= 0.0) {
44 throw std::range_error("dMin cannot be <= 0.");
45 }
46
47 if (m_dmax <= 0.0) {
48 throw std::range_error("dMax cannot be <= 0.");
49 }
50
51 if (m_dmax < m_dmin) {
52 throw std::range_error("dMax cannot be smaller than dMin.");
53 }
54}
55
57HKLFilterSpaceGroup::HKLFilterSpaceGroup(SpaceGroup_const_sptr spaceGroup) : m_spaceGroup(std::move(spaceGroup)) {
58 if (!m_spaceGroup) {
59 throw std::runtime_error("Cannot construct HKLFilterSpaceGroup from null space group.");
60 }
61}
62
64std::string HKLFilterSpaceGroup::getDescription() const noexcept {
65 return "(Space group: " + m_spaceGroup->hmSymbol() + ")";
66}
67
70bool HKLFilterSpaceGroup::isAllowed(const Kernel::V3D &hkl) const noexcept {
71 return m_spaceGroup->isAllowedReflection(hkl);
72}
73
76 : m_calculator(std::move(calculator)), m_fSquaredMin(fSquaredMin) {
77 if (!m_calculator) {
78 throw std::runtime_error("Cannot construct HKLFilterStructureFactor from null calculator.");
79 }
80}
81
83std::string HKLFilterStructureFactor::getDescription() const noexcept {
84 std::ostringstream strm;
85 strm << "(F^2 > " << m_fSquaredMin << ")";
86
87 return strm.str();
88}
89
91bool HKLFilterStructureFactor::isAllowed(const Kernel::V3D &hkl) const noexcept {
92 return m_calculator->getFSquared(hkl) > m_fSquaredMin;
93}
94
96HKLFilterCentering::HKLFilterCentering(ReflectionCondition_sptr centering) : m_centering(std::move(centering)) {
97 if (!m_centering) {
98 throw std::runtime_error("Cannot construct HKLFilterCentering from null centering.");
99 }
100}
101
103std::string HKLFilterCentering::getDescription() const noexcept {
104 return "(Centering: " + m_centering->getSymbol() + ")";
105}
106
108bool HKLFilterCentering::isAllowed(const Kernel::V3D &hkl) const noexcept {
109 return m_centering->isAllowed(static_cast<int>(hkl.X()), static_cast<int>(hkl.Y()), static_cast<int>(hkl.Z()));
110}
111
112} // namespace Mantid::Geometry
bool isAllowed(const Kernel::V3D &hkl) const noexcept override
Returns true if the HKL is allowed according to the lattice centering.
HKLFilterCentering(ReflectionCondition_sptr centering)
Constructor, throws exception if pointer is null.
ReflectionCondition_sptr m_centering
std::string getDescription() const noexcept override
Returns a description with the centering symbol.
bool isAllowed(const Kernel::V3D &hkl) const noexcept override
Returns true if the d-value of the HKL is within the specified range.
std::string getDescription() const noexcept override
Returns a description containing the parameters of the filter.
HKLFilterDRange(const UnitCell &cell, double dMin)
Constructor, dMax is set to the largest lattice parameter.
void checkProperDRangeValues()
Throws exception if m_dMin or m_dMax is <= 0 or if m_dMax < m_dMin.
std::string getDescription() const noexcept override
Returns a description of the filter that contains the space group symbol.
bool isAllowed(const Kernel::V3D &hkl) const noexcept override
Returns true if the reflection is allowed by the space group reflection conditions.
HKLFilterSpaceGroup(SpaceGroup_const_sptr spaceGroup)
Constructor, throws exception if the supplied pointer is invalid.
StructureFactorCalculator_sptr m_calculator
HKLFilterStructureFactor(StructureFactorCalculator_sptr calculator, double fSquaredMin=1.0e-6)
Constructor, throws exception if the calculator pointer is invalid.
std::string getDescription() const noexcept override
Returns a description for the filter that contains the minimum F^2.
bool isAllowed(const Kernel::V3D &hkl) const noexcept override
Returns true if F^2(hkl) is larger than the stored minimum.
Class to implement unit cell of crystals.
Definition: UnitCell.h:44
double a(int nd) const
Get lattice parameter a1-a3 as function of index (0-2)
Definition: UnitCell.cpp:94
double c() const
Get lattice parameter.
Definition: UnitCell.cpp:128
double b() const
Get lattice parameter.
Definition: UnitCell.cpp:123
Class for 3D vectors.
Definition: V3D.h:34
std::shared_ptr< ReflectionCondition > ReflectionCondition_sptr
Shared pointer to a ReflectionCondition.
std::shared_ptr< StructureFactorCalculator > StructureFactorCalculator_sptr
std::shared_ptr< const SpaceGroup > SpaceGroup_const_sptr
Definition: SpaceGroup.h:82
STL namespace.