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 +
9#include <boost/python/class.hpp>
10#include <boost/python/enum.hpp>
11#include <boost/python/list.hpp>
12
13using namespace Mantid::Geometry;
14using namespace Mantid::Kernel;
15using namespace Mantid::PythonInterface;
16using namespace boost::python;
17
18namespace {
19boost::python::list getListFromV3DVector(const std::vector<V3D> &hkls) {
20 boost::python::list hklList;
21 for (const auto &hkl : hkls) {
22 hklList.append(hkl);
23 }
24 return hklList;
25}
26
27boost::python::list getHKLsDefaultFilter(const ReflectionGenerator &self, double dMin, double dMax) {
28 return getListFromV3DVector(self.getHKLs(dMin, dMax));
29}
30
31boost::python::list getHKLsUsingFilter(const ReflectionGenerator &self, double dMin, double dMax,
33 return getListFromV3DVector(self.getHKLs(dMin, dMax, self.getReflectionConditionFilter(std::move(filter))));
34}
35
36boost::python::list getUniqueHKLsDefaultFilter(const ReflectionGenerator &self, double dMin, double dMax) {
37 return getListFromV3DVector(self.getUniqueHKLs(dMin, dMax));
38}
39
40boost::python::list getUniqueHKLsUsingFilter(ReflectionGenerator &self, double dMin, double dMax,
42 return getListFromV3DVector(self.getUniqueHKLs(dMin, dMax, self.getReflectionConditionFilter(std::move(filter))));
43}
44
45std::vector<double> getDValues(const ReflectionGenerator &self, const boost::python::object &hkls) {
47
48 return self.getDValues(converter());
49}
50
51std::vector<double> getFsSquared(const ReflectionGenerator &self, const boost::python::object &hkls) {
53
54 return self.getFsSquared(converter());
55}
56} // namespace
57
59 enum_<ReflectionConditionFilter>("ReflectionConditionFilter")
60 .value("None", ReflectionConditionFilter::None)
61 .value("Centering", ReflectionConditionFilter::Centering)
62 .value("SpaceGroup", ReflectionConditionFilter::SpaceGroup)
63 .value("StructureFactor", ReflectionConditionFilter::StructureFactor)
64 .export_values();
65
66 class_<ReflectionGenerator>("ReflectionGenerator", no_init)
67 .def(init<const CrystalStructure &, optional<ReflectionConditionFilter>>(
68 (arg("crystalStructure"), arg("defaultFilter"))))
69 .def("getHKLs", &getHKLsDefaultFilter, (arg("self"), arg("dMin"), arg("dmax")))
70 .def("getHKLsUsingFilter", &getHKLsUsingFilter, (arg("self"), arg("dMin"), arg("dmax"), arg("filter")))
71 .def("getUniqueHKLs", &getUniqueHKLsDefaultFilter, (arg("self"), arg("dMin"), arg("dmax")))
72 .def("getUniqueHKLsUsingFilter", &getUniqueHKLsUsingFilter,
73 (arg("self"), arg("dMin"), arg("dmax"), arg("filter")))
74 .def("getDValues", &getDValues, (arg("self"), arg("hkls")))
75 .def("getFsSquared", &getFsSquared, (arg("self"), arg("hkls")));
76}
void export_ReflectionGenerator()
Three components are required to describe a crystal structure:
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...
Converts a Python sequence type to a C++ std::vector, where the element type is defined by the templa...