Mantid
Loading...
Searching...
No Matches
SpaceGroup.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 +
11
12#include <boost/python/class.hpp>
13#include <boost/python/enum.hpp>
14#include <boost/python/list.hpp>
15#include <boost/python/operators.hpp>
16#include <boost/python/register_ptr_to_python.hpp>
17#include <boost/python/scope.hpp>
18#include <boost/python/self.hpp>
19
22using namespace boost::python;
23
25
26namespace //<unnamed>
27{
28using namespace Mantid::PythonInterface;
29
30boost::python::list getEquivalentPositions(const SpaceGroup &self, const object &point) {
31 const auto &equivalents = self.getEquivalentPositions(Converters::PyObjectToV3D(point)());
32
33 boost::python::list pythonEquivalents;
34 for (const auto &equivalent : equivalents) {
35 pythonEquivalents.append(equivalent);
36 }
37
38 return pythonEquivalents;
39}
40
41bool isAllowedReflection(const SpaceGroup &self, const object &hkl) {
42 const auto &hklV3d = Converters::PyObjectToV3D(hkl)();
43
44 return self.isAllowedReflection(hklV3d);
45}
46
47Mantid::Geometry::Group_sptr getSiteSymmetryGroup(const SpaceGroup &self, const object &position) {
48 const auto &posV3d = Converters::PyObjectToV3D(position)();
49 return std::const_pointer_cast<Group>(self.getSiteSymmetryGroup(posV3d));
50}
51
52std::string __repr__implementation(const SpaceGroup &self) {
53 std::stringstream ss;
54 ss << "SpaceGroupFactory.createSpaceGroup(\"";
55 ss << self.hmSymbol();
56 ss << "\")";
57 return ss.str();
58}
59} // namespace
60
62 register_ptr_to_python<std::shared_ptr<SpaceGroup>>();
63
64 class_<SpaceGroup, boost::noncopyable, bases<Group>>("SpaceGroup", no_init)
65 .def("getNumber", &SpaceGroup::number, arg("self"))
66 .def("getHMSymbol", &SpaceGroup::hmSymbol, arg("self"))
67 .def("getEquivalentPositions", &getEquivalentPositions, (arg("self"), arg("point")),
68 "Returns an array with all symmetry equivalents of the supplied "
69 "HKL.")
70 .def("isAllowedReflection", &isAllowedReflection, (arg("self"), arg("hkl")),
71 "Returns True if the supplied reflection is allowed with respect to "
72 "space group symmetry operations.")
73 .def("isAllowedUnitCell", &SpaceGroup::isAllowedUnitCell, (arg("self"), arg("cell")),
74 "Returns true if the metric of the cell "
75 "is compatible with the space group.")
76 .def("getPointGroup", &SpaceGroup::getPointGroup, arg("self"), "Returns the point group of the space group.")
77 .def("getSiteSymmetryGroup", &getSiteSymmetryGroup, (arg("self"), arg("position")),
78 "Returns the site symmetry group for supplied point coordinates.")
79 .def(str(self))
80 .def("__repr__", &__repr__implementation);
81}
double position
Definition: GetAllEi.cpp:154
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
void export_SpaceGroup()
Definition: SpaceGroup.cpp:61
The class Group represents a set of symmetry operations (or symmetry group).
Definition: Group.h:135
A class for representing space groups, inheriting from Group.
Definition: SpaceGroup.h:46
PointGroup_sptr getPointGroup() const
Returns the point group of the space group.
Definition: SpaceGroup.cpp:84
bool isAllowedReflection(const Kernel::V3D &hkl) const
Returns whether the given reflection is allowed or not in this space group.
Definition: SpaceGroup.cpp:53
Group_const_sptr getSiteSymmetryGroup(const Kernel::V3D &position) const
Returns the site symmetry group.
Definition: SpaceGroup.cpp:98
std::string hmSymbol() const
Returns the stored Hermann-Mauguin symbol.
Definition: SpaceGroup.cpp:34
bool isAllowedUnitCell(const UnitCell &cell) const
Convenience function for checking compatibility of a cell metric with the space group,...
Definition: SpaceGroup.cpp:73
size_t number() const
Returns the stored space group number.
Definition: SpaceGroup.cpp:31
std::vector< T > getEquivalentPositions(const T &position) const
Definition: SpaceGroup.h:53
std::shared_ptr< Group > Group_sptr
Definition: Group.h:178
Takes a Python object and if it supports indexing and is of length 3 then it will attempt to convert ...
Definition: PyObjectToV3D.h:22