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 +
9#include <algorithm>
10#include <utility>
11
12namespace Mantid::Geometry {
13
14using namespace Kernel;
15
27SpaceGroup::SpaceGroup(size_t itNumber, std::string hmSymbol, const Group &group)
28 : Group(group), m_number(itNumber), m_hmSymbol(std::move(hmSymbol)) {}
29
31size_t SpaceGroup::number() const { return m_number; }
32
34std::string SpaceGroup::hmSymbol() const { return m_hmSymbol; }
35
54 for (const auto &operation : m_allOperations) {
55 if (operation.hasTranslation()) {
56 /* Floating point precision problem:
57 * (H . v) % 1.0 is not always exactly 0, so instead:
58 * | [(H . v) + delta] % 1.0 | > 1e-14 is checked
59 * The transformation is only performed if necessary.
60 */
61 if ((fabs(fmod(fabs(hkl.scalar_prod(operation.reducedVector())) + 1e-15, 1.0)) > 1e-14) &&
62 (operation.transformHKL(hkl) == hkl)) {
63 return false;
64 }
65 }
66 }
67
68 return true;
69}
70
73bool SpaceGroup::isAllowedUnitCell(const UnitCell &cell) const { return isInvariant(cell.getG()); }
74
85 return PointGroupFactory::Instance().createPointGroupFromSpaceGroup(*this);
86}
87
99 V3D wrappedPosition = Geometry::getWrappedVector(position);
100
101 std::vector<SymmetryOperation> siteSymmetryOps;
102 AtomPositionsEqual comparator;
103 std::copy_if(
104 m_allOperations.begin(), m_allOperations.end(), std::inserter(siteSymmetryOps, siteSymmetryOps.begin()),
105 [&](const SymmetryOperation &op) { return Geometry::getWrappedVector(op * wrappedPosition) == wrappedPosition; });
106
107 return GroupFactory::create<Group>(siteSymmetryOps);
108}
109
110std::ostream &operator<<(std::ostream &stream, const SpaceGroup &self) {
111 stream << "Space group with Hermann-Mauguin symbol: " << self.hmSymbol();
112 return stream;
113}
114
115} // namespace Mantid::Geometry
double position
Definition: GetAllEi.cpp:154
#define fabs(x)
Definition: Matrix.cpp:22
Equality-functor for comparison of atom positions with specifiable precision.
Definition: Group.h:22
The class Group represents a set of symmetry operations (or symmetry group).
Definition: Group.h:135
bool isInvariant(const Kernel::DblMatrix &tensor, double tolerance=1e-8) const
Returns true if the tensor is invariant under the group operations.
Definition: Group.cpp:117
std::vector< SymmetryOperation > m_allOperations
Definition: Group.h:173
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
SpaceGroup(size_t itNumber, std::string hmSymbol, const Group &group)
Constructor.
Definition: SpaceGroup.cpp:27
Crystallographic symmetry operations are composed of a rotational component, which is represented by ...
Class to implement unit cell of crystals.
Definition: UnitCell.h:44
const Kernel::DblMatrix & getG() const
Get the metric tensor.
Definition: UnitCell.cpp:750
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Class for 3D vectors.
Definition: V3D.h:34
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
Definition: V3D.h:274
std::shared_ptr< PointGroup > PointGroup_sptr
Shared pointer to a PointGroup.
Definition: PointGroup.h:67
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
Definition: PointGroup.cpp:312
MANTID_GEOMETRY_DLL V3R getWrappedVector(const V3R &vector)
Wraps a V3R to the interval (0, 1].
std::shared_ptr< const Group > Group_const_sptr
Definition: Group.h:179
STL namespace.