Mantid
Loading...
Searching...
No Matches
ReflectionGenerator.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
13
14namespace Mantid::Geometry {
15
16using namespace Kernel;
17
20public:
21 explicit LatticeSpacingCalculator(const UnitCell &cell) : m_cell(cell) {}
22
23 double operator()(const V3D &hkl) { return m_cell.d(hkl); }
24
25private:
27};
28
31 : m_crystalStructure(std::move(crystalStructure)),
32 m_sfCalculator(StructureFactorCalculatorFactory::create<StructureFactorCalculatorSummation>(m_crystalStructure)),
33 m_defaultHKLFilter(getReflectionConditionFilter(defaultFilter)) {}
34
37
41 return std::make_shared<const HKLFilterDRange>(m_crystalStructure.cell(), dMin, dMax);
42}
43
46 switch (filter) {
48 return std::make_shared<const HKLFilterCentering>(m_crystalStructure.centering());
49 break;
51 return std::make_shared<const HKLFilterSpaceGroup>(m_crystalStructure.spaceGroup());
52 break;
54 return std::make_shared<const HKLFilterStructureFactor>(m_sfCalculator);
55 default:
56 return HKLFilter_const_sptr();
57 }
58}
59
62std::vector<V3D> ReflectionGenerator::getHKLs(double dMin, double dMax) const {
63 return getHKLs(dMin, dMax, m_defaultHKLFilter);
64}
65
68std::vector<Kernel::V3D> ReflectionGenerator::getHKLs(double dMin, double dMax,
69 const HKLFilter_const_sptr &reflectionConditionFilter) const {
70 HKLGenerator generator(m_crystalStructure.cell(), dMin);
71
72 HKLFilter_const_sptr filter = getDRangeFilter(dMin, dMax);
73 if (reflectionConditionFilter) {
74 filter = filter & reflectionConditionFilter;
75 }
76
77 std::vector<V3D> hkls;
78 hkls.reserve(generator.size());
79
80 std::remove_copy_if(generator.begin(), generator.end(), std::back_inserter(hkls), (~filter)->fn());
81 return hkls;
82}
83
86std::vector<V3D> ReflectionGenerator::getUniqueHKLs(double dMin, double dMax) const {
87 return getUniqueHKLs(dMin, dMax, m_defaultHKLFilter);
88}
89
92std::vector<V3D> ReflectionGenerator::getUniqueHKLs(double dMin, double dMax,
93 const HKLFilter_const_sptr &reflectionConditionFilter) const {
94 HKLGenerator generator(m_crystalStructure.cell(), dMin);
95
96 HKLFilter_const_sptr filter = getDRangeFilter(dMin, dMax);
97 if (reflectionConditionFilter) {
98 filter = filter & reflectionConditionFilter;
99 }
100
101 std::vector<V3D> hkls;
102 hkls.reserve(generator.size());
103
104 PointGroup_sptr pg = m_crystalStructure.spaceGroup()->getPointGroup();
105
106 for (auto hkl = generator.begin(); hkl != generator.end(); ++hkl) {
107 if (filter->isAllowed(*hkl)) {
108 hkls.emplace_back(pg->getReflectionFamily(*hkl));
109 }
110 }
111
112 std::sort(hkls.begin(), hkls.end());
113 hkls.erase(std::unique(hkls.begin(), hkls.end()), hkls.end());
114
115 return hkls;
116}
117
120std::vector<double> ReflectionGenerator::getDValues(const std::vector<V3D> &hkls) const {
121 std::vector<double> dValues;
122 dValues.reserve(hkls.size());
123
124 std::transform(hkls.begin(), hkls.end(), std::back_inserter(dValues),
126
127 return dValues;
128}
129
132std::vector<double> ReflectionGenerator::getFsSquared(const std::vector<V3D> &hkls) const {
133 return m_sfCalculator->getFsSquared(hkls);
134}
135
136} // namespace Mantid::Geometry
Three components are required to describe a crystal structure:
UnitCell cell() const
Returns the unit cell of the structure.
ReflectionCondition_sptr centering() const
SpaceGroup_const_sptr spaceGroup() const
Returns the space group of the crystal structure.
const const_iterator & end() const
Returns an iterator which "points at" one element past the end.
Definition: HKLGenerator.h:146
const const_iterator & begin() const
Returns an iterator to the beginning of the sequence.
Definition: HKLGenerator.h:143
size_t size() const
Returns the number of HKLs to be generated.
Definition: HKLGenerator.h:140
Small helper functor to calculate d-Values from a unit cell.
ReflectionGenerator(CrystalStructure crystalStructure, ReflectionConditionFilter defaultFilter=ReflectionConditionFilter::SpaceGroup)
Constructor.
std::vector< Kernel::V3D > getHKLs(double dMin, double dMax) const
Returns a list of HKLs within the specified d-limits using the default reflection condition filter.
HKLFilter_const_sptr getReflectionConditionFilter(ReflectionConditionFilter filter) const
Returns a reflection condition HKLFilter based on the supplied enum.
std::vector< double > getFsSquared(const std::vector< Kernel::V3D > &hkls) const
Returns a list of squared structure factor amplitudes corresponding to the supplied list of HKLs.
std::vector< Kernel::V3D > getUniqueHKLs(double dMin, double dMax) const
Returns a list of symetrically independent HKLs within the specified d-limits using the default refle...
std::vector< double > getDValues(const std::vector< Kernel::V3D > &hkls) const
Returns a list of d-values that correspond to the supplied hkl list, using the unit cell of the store...
StructureFactorCalculator_sptr m_sfCalculator
HKLFilter_const_sptr getDRangeFilter(double dMin, double dMax) const
Returns a DRangeFilter from the supplied d-limits and the internally stored cell.
const CrystalStructure & getCrystalStructure() const
Returns the internally stored crystal structure.
Class to implement unit cell of crystals.
Definition: UnitCell.h:44
double d(double h, double k, double l) const
Return d-spacing ( ) for a given h,k,l coordinate.
Definition: UnitCell.cpp:700
Class for 3D vectors.
Definition: V3D.h:34
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::shared_ptr< const HKLFilter > HKLFilter_const_sptr
Definition: HKLFilter.h:76
std::shared_ptr< PointGroup > PointGroup_sptr
Shared pointer to a PointGroup.
Definition: PointGroup.h:67
STL namespace.