16#include <boost/algorithm/string.hpp>
26 std::vector<std::string> generatorStrings;
27 boost::split(generatorStrings, generatorString, boost::is_any_of(
";"));
29 for (
auto &identifier : generatorStrings) {
58 if (strings.size() < 3) {
59 throw std::invalid_argument(
"There must be at least three strings in the "
60 "vector for SymmetryOperation * "
61 "std::vector<std::string>.");
64 std::vector<int> transformedIndices = symOp.
matrix() * std::vector<int>{0, 1, 2};
66 std::vector<std::string> transformedStrings;
67 std::transform(transformedIndices.cbegin(), transformedIndices.cend(), std::back_inserter(transformedStrings),
68 [=](
int index) { return strings[abs(index)]; });
70 if (transformedStrings.size() < strings.size()) {
71 transformedStrings.insert(transformedStrings.end(), strings.cbegin() + transformedStrings.size(), strings.cend());
74 return transformedStrings;
79 std::string generatorInformation)
80 : m_number(number), m_hmSymbol(
std::move(hmSymbol)), m_generatorString(
std::move(generatorInformation)),
107 if (!generatingGroup) {
108 throw std::runtime_error(
"Could not create group from supplied symmetry operations.");
118 const std::string &generatorInformation)
121 throw std::runtime_error(
"Generator string could not be parsed: " + generatorInformation);
131 return baseGroup * centeringGroup;
142 const std::string &generatorInformation)
154 return std::make_shared<Group>(transformation(*baseGroup));
182 std::vector<std::string> parts;
183 boost::split(parts, generatorInformation, boost::is_any_of(
"|"));
185 if (parts.size() != 2) {
186 throw std::invalid_argument(
"Not a valid string for generation of "
187 "transformed space groups. Correct format is "
188 "'HM symbol | transformation'.");
199 const std::string &generatorInformation)
202 throw std::runtime_error(
"Generator string could not be parsed: " + generatorInformation);
215 throw std::invalid_argument(
"Space group with symbol '" + hmSymbol +
"' is not registered.");
231 std::vector<std::string> symbols;
234 [](
const auto &generator) { return generator.first; });
240 std::vector<std::string> symbols;
244 for (
auto it = keyPair.first; it != keyPair.second; ++it) {
245 symbols.emplace_back(it->second);
253 std::vector<size_t> numbers;
257 numbers.emplace_back(it->first);
268 std::string pointGroupSymbol = pointGroup->getSymbol();
270 std::vector<std::string> symbols;
273 for (
auto it = keyPair.first; it != keyPair.second; ++it) {
274 symbols.emplace_back(it->second);
284 throw std::invalid_argument(
"Cannot unsubscribe space group that is not registered.");
290 auto eraseNumber =
m_numberMap.find(generator->getNumber());
315 const std::string &generators) {
316 subscribeUsingGenerator<AlgorithmicSpaceGroupGenerator>(number, hmSymbol, generators);
322 const std::string &symmetryOperations) {
323 subscribeUsingGenerator<TabulatedSpaceGroupGenerator>(number, hmSymbol, symmetryOperations);
329 const std::string &transformation)
const {
331 std::vector<std::string> symbolComponents;
332 boost::split(symbolComponents, hmSymbol, boost::is_any_of(
" "));
335 std::string centeringLowerCase = boost::to_lower_copy(symbolComponents.front());
338 symbolComponents.erase(symbolComponents.begin());
344 std::vector<std::string> axes{
"a",
"b",
"c"};
345 std::vector<std::string> permutedAxes = op * axes;
348 std::vector<std::string> permuted = op * symbolComponents;
349 permuted.insert(permuted.begin(), centeringLowerCase);
352 std::transform(permuted.begin(), permuted.end(), permuted.begin(), [&](
const std::string &symbol) {
353 auto needsTransformation = std::find(permutedAxes.cbegin(), permutedAxes.cend(), symbol);
355 if (needsTransformation == permutedAxes.cend()) {
359 return axes[std::distance(permutedAxes.cbegin(), needsTransformation)];
363 boost::to_upper(*permuted.begin());
365 return boost::join(permuted,
" ");
371 return std::make_shared<const SpaceGroup>(*prototype);
382 m_pointGroupMap.emplace(spaceGroup->getPointGroup()->getSymbol(), generator.first);
391 throw std::runtime_error(
"No generator for symbol '" + hmSymbol +
"'");
394 return generator->getPrototype();
400 throw std::runtime_error(
"Cannot register null-generator.");
403 m_numberMap.emplace(generator->getNumber(), generator->getHMSymbol());
635DECLARE_GENERATED_SPACE_GROUP(123, "P 4/
m m m", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z; -
x,-
y,-
z")
636DECLARE_GENERATED_SPACE_GROUP(124, "P 4/
m c c", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z+1/2; -
x,-
y,-
z")
638DECLARE_GENERATED_SPACE_GROUP(125, "P 4/
n b
m", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z; -
x+1/2,-
y+1/2,-
z")
641DECLARE_GENERATED_SPACE_GROUP(126, "P 4/
n n c", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z; -
x+1/2,-
y+1/2,-
z+1/2")
644DECLARE_GENERATED_SPACE_GROUP(127, "P 4/
m b
m", "-
x,-
y,
z; -
y,
x,
z; -
x+1/2,
y+1/2,-
z; -
x,-
y,-
z")
645DECLARE_GENERATED_SPACE_GROUP(128, "P 4/
m n c", "-
x,-
y,
z; -
y,
x,
z; -
x+1/2,
y+1/2,-
z+1/2; -
x,-
y,-
z")
647DECLARE_GENERATED_SPACE_GROUP(129, "P 4/
n m m", "-
x,-
y,
z; -
y+1/2,
x+1/2,
z; -
x+1/2,
y+1/2,-
z; -
x+1/2,-
y+1/2,-
z")
650DECLARE_GENERATED_SPACE_GROUP(130, "P 4/
n c c", "-
x,-
y,
z; -
y+1/2,
x+1/2,
z; -
x+1/2,
y+1/2,-
z+1/2; -
x+1/2,-
y+1/2,-
z")
653DECLARE_GENERATED_SPACE_GROUP(131, "P 42/
m m c", "-
x,-
y,
z; -
y,
x,
z+1/2; -
x,
y,-
z; -
x,-
y,-
z")
654DECLARE_GENERATED_SPACE_GROUP(132, "P 42/
m c
m", "-
x,-
y,
z; -
y,
x,
z+1/2; -
x,
y,-
z+1/2; -
x,-
y,-
z")
656DECLARE_GENERATED_SPACE_GROUP(133, "P 42/
n b c", "-
x,-
y,
z; -
y+1/2,
x+1/2,
z+1/2; -
x,
y,-
z+1/2; -
x+1/2,-
y+1/2,-
z+1/2")
659DECLARE_GENERATED_SPACE_GROUP(134, "P 42/
n n m", "-
x,-
y,
z; -
y+1/2,
x+1/2,
z+1/2; -
x,
y,-
z; -
x+1/2,-
y+1/2,-
z+1/2")
662DECLARE_GENERATED_SPACE_GROUP(135, "P 42/
m b c", "-
x,-
y,
z; -
y,
x,
z+1/2; -
x+1/2,
y+1/2,-
z; -
x,-
y,-
z")
663DECLARE_GENERATED_SPACE_GROUP(136, "P 42/
m n m", "-
x,-
y,
z; -
y+1/2,
x+1/2,
z+1/2; -
x+1/2,
y+1/2,-
z+1/2; -
x,-
y,-
z")
666 "-
x,-
y,
z; -
y+1/2,
x+1/2,
z+1/2; -
x+1/2,
y+1/2,-
z+1/2; -
x+1/2,-
y+1/2,-
z+1/2")
669DECLARE_GENERATED_SPACE_GROUP(138, "P 42/
n c
m", "-
x,-
y,
z; -
y+1/2,
x+1/2,
z+1/2; -
x+1/2,
y+1/2,-
z; -
x+1/2,-
y+1/2,-
z+1/2")
672DECLARE_GENERATED_SPACE_GROUP(139, "I 4/
m m m", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z; -
x,-
y,-
z")
673DECLARE_GENERATED_SPACE_GROUP(140, "I 4/
m c
m", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z+1/2; -
x,-
y,-
z")
675 "-
x+1/2,-
y+1/2,
z+1/2; -
y,
x+1/2,
z+1/4; -
x+1/2,
y,-
z+3/4; -
x,-
y+1/2,-
z+1/4")
679 "-
x+1/2,-
y+1/2,
z+1/2; -
y,
x+1/2,
z+1/4; -
x+1/2,
y,-
z+1/4; -
x,-
y+1/2,-
z+1/4")
751DECLARE_GENERATED_SPACE_GROUP(191, "P 6/
m m m", "-
y,
x-
y,
z;
x,
y,-
z;
y,
x,-
z; -
x,-
y,-
z")
752DECLARE_GENERATED_SPACE_GROUP(192, "P 6/
m c c", "-
y,
x-
y,
z; -
x,-
y,
z;
y,
x,-
z+1/2; -
x,-
y,-
z")
753DECLARE_GENERATED_SPACE_GROUP(193, "P 63/
m c
m", "-
y,
x-
y,
z; -
x,-
y,
z+1/2;
y,
x,-
z+1/2; -
x,-
y,-
z")
754DECLARE_GENERATED_SPACE_GROUP(194, "P 63/
m m c", "-
y,
x-
y,
z; -
x,-
y,
z+1/2;
y,
x,-
z; -
x,-
y,-
z")
762DECLARE_GENERATED_SPACE_GROUP(200, "P
m -3", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y; -
x,-
y,-
z")
764DECLARE_GENERATED_SPACE_GROUP(201, "P
n -3", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y; -
x+1/2,-
y+1/2,-
z+1/2")
767DECLARE_GENERATED_SPACE_GROUP(202, "F
m -3", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y; -
x,-
y,-
z")
769DECLARE_GENERATED_SPACE_GROUP(203, "F
d -3", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y; -
x+1/4,-
y+1/4,-
z+1/4")
772DECLARE_GENERATED_SPACE_GROUP(204, "I
m -3", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y; -
x,-
y,-
z")
773DECLARE_GENERATED_SPACE_GROUP(205, "P a -3", "-
x+1/2,-
y,
z+1/2; -
x,
y+1/2,-
z+1/2;
z,
x,
y; -
x,-
y,-
z")
774DECLARE_GENERATED_SPACE_GROUP(206, "I a -3", "-
x+1/2,-
y,
z+1/2; -
x,
y+1/2,-
z+1/2;
z,
x,
y; -
x,-
y,-
z")
775DECLARE_GENERATED_SPACE_GROUP(207, "P 4 3 2", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z")
776DECLARE_GENERATED_SPACE_GROUP(208, "P 42 3 2", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y+1/2,
x+1/2,-
z+1/2")
777DECLARE_GENERATED_SPACE_GROUP(209, "F 4 3 2", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z")
779DECLARE_GENERATED_SPACE_GROUP(210, "F 41 3 2", "-
x,-
y+1/2,
z+1/2; -
x+1/2,
y+1/2,-
z;
z,
x,
y;
y+3/4,
x+1/4,-
z+3/4")
780DECLARE_GENERATED_SPACE_GROUP(211, "I 4 3 2", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z")
781DECLARE_GENERATED_SPACE_GROUP(212, "P 43 3 2", "-
x+1/2,-
y,
z+1/2; -
x,
y+1/2,-
z+1/2;
z,
x,
y;
y+1/4,
x+3/4,-
z+3/4")
782DECLARE_GENERATED_SPACE_GROUP(213, "P 41 3 2", "-
x+1/2,-
y,
z+1/2; -
x,
y+1/2,-
z+1/2;
z,
x,
y;
y+3/4,
x+1/4,-
z+1/4")
783DECLARE_GENERATED_SPACE_GROUP(214, "I 41 3 2", "-
x+1/2,-
y,
z+1/2; -
x,
y+1/2,-
z+1/2;
z,
x,
y;
y+3/4,
x+1/4,-
z+1/4")
784DECLARE_GENERATED_SPACE_GROUP(215, "P -4 3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,
z")
785DECLARE_GENERATED_SPACE_GROUP(216, "F -4 3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,
z")
786DECLARE_GENERATED_SPACE_GROUP(217, "I -4 3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,
z")
787DECLARE_GENERATED_SPACE_GROUP(218, "P -4 3
n", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y+1/2,
x+1/2,
z+1/2")
788DECLARE_GENERATED_SPACE_GROUP(219, "F -4 3 c", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y+1/2,
x+1/2,
z+1/2")
789DECLARE_GENERATED_SPACE_GROUP(220, "I -4 3
d", "-
x+1/2,-
y,
z+1/2; -
x,
y+1/2,-
z+1/2;
z,
x,
y;
y+1/4,
x+1/4,
z+1/4")
790DECLARE_GENERATED_SPACE_GROUP(221, "P
m -3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z; -
x,-
y,-
z")
792DECLARE_GENERATED_SPACE_GROUP(222, "P
n -3
n", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z; -
x+1/2,-
y+1/2,-
z+1/2")
795DECLARE_GENERATED_SPACE_GROUP(223, "P
m -3
n", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y+1/2,
x+1/2,-
z+1/2; -
x,-
y,-
z")
797DECLARE_GENERATED_SPACE_GROUP(224, "P
n -3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y+1/2,
x+1/2,-
z+1/2; -
x+1/2,-
y+1/2,-
z+1/2")
800DECLARE_GENERATED_SPACE_GROUP(225, "F
m -3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z; -
x,-
y,-
z")
801DECLARE_GENERATED_SPACE_GROUP(226, "F
m -3 c", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y+1/2,
x+1/2,-
z+1/2; -
x,-
y,-
z")
804 "-
x,-
y+1/2,
z+1/2; -
x+1/2,
y+1/2,-
z;
z,
x,
y; "
805 "
y+3/4,
x+1/4,-
z+3/4; -
x+1/4,-
y+1/4,-
z+1/4")
809 "-
x,-
y+1/2,
z+1/2; -
x+1/2,
y+1/2,-
z;
z,
x,
y; "
810 "
y+3/4,
x+1/4,-
z+3/4; -
x+3/4,-
y+3/4,-
z+3/4")
813DECLARE_GENERATED_SPACE_GROUP(229, "I
m -3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z; -
x,-
y,-
z")
814DECLARE_GENERATED_SPACE_GROUP(230, "I a -3
d", "-
x+1/2,-
y,
z+1/2; -
x,
y+1/2,-
z+1/2;
z,
x,
y;
y+3/4,
x+1/4,-
z+1/4; -
x,-
y,-
z")
std::map< DeltaEMode::Type, std::string > index
#define DECLARE_TABULATED_SPACE_GROUP(number, hmSymbol, symmetryOperations)
#define DECLARE_TRANSFORMED_SPACE_GROUP(number, hmSymbol, generators)
#define DECLARE_GENERATED_SPACE_GROUP(number, hmSymbol, generators)
#define DECLARE_TRANSFORMED_ORTHORHOMBIC_SPACE_GROUP(number, hmSymbol, generators)
#define DECLARE_ORTHORHOMBIC_SPACE_GROUP(number, hmSymbol, generators)
AbstractSpaceGroupGenerator is used by SpaceGroupFactory to delay (possibly costly) construction of s...
std::string getGeneratorString() const
SpaceGroup_const_sptr m_prototype
SpaceGroup_const_sptr getPrototype()
Returns the internally stored prototype, generates one if necessary.
AbstractSpaceGroupGenerator(size_t number, std::string hmSymbol, std::string generatorInformation)
Constructor for AbstractSpaceGroupGenerator.
std::string getHMSymbol() const
virtual Group_const_sptr generateGroup() const =0
SpaceGroup_const_sptr generatePrototype()
Generates a prototype space group object.
bool hasValidPrototype() const
Group_const_sptr generateGroup() const override
Uses an algorithm based on Shmueli, U.
AlgorithmicSpaceGroupGenerator(size_t number, const std::string &hmSymbol, const std::string &generatorInformation)
Constructor of AlgorithmicSpaceGroupGenerator which throws an std::runtime_error exception when the g...
std::string getCenteringSymbol() const
Returns the centering symbol, which is extracted from the Hermann-Mauguin-symbol.
std::multimap< std::string, std::string > m_pointGroupMap
std::vector< std::string > subscribedSpaceGroupSymbols() const
Returns a vector with all subscribed space group symbols.
void fillPointGroupMap()
Fills the internal multimap that maintains the mapping between space and point groups.
void subscribe(const AbstractSpaceGroupGenerator_sptr &generator)
Puts the space group factory into the factory.
void subscribeTabulatedSpaceGroup(size_t number, const std::string &hmSymbol, const std::string &symmetryOperations)
Subscribes a "tabulated space group" into the factory where all symmetry operations need to be suppli...
void unsubscribeSpaceGroup(const std::string &hmSymbol)
Unsubscribes the space group with the given Hermann-Mauguin symbol, but throws std::invalid_argument ...
SpaceGroup_const_sptr getPrototype(const std::string &hmSymbol)
Returns a prototype object for the requested space group.
SpaceGroup_const_sptr constructFromPrototype(const SpaceGroup_const_sptr &prototype) const
Returns a copy-constructed instance of the supplied space group prototype object.
void subscribeGeneratedSpaceGroup(size_t number, const std::string &hmSymbol, const std::string &generators)
Subscribes a space group into the factory using generators.
std::multimap< size_t, std::string > m_numberMap
std::map< std::string, AbstractSpaceGroupGenerator_sptr > m_generatorMap
std::vector< size_t > subscribedSpaceGroupNumbers() const
Returns a vector with all subscribed space group numbers.
SpaceGroup_const_sptr createSpaceGroup(const std::string &hmSymbol)
Creates a space group given the Hermann-Mauguin symbol, throws std::invalid_argument if symbol is not...
bool isSubscribed(const std::string &hmSymbol) const
Returns true if space group with given symbol is subscribed.
std::string getTransformedSymbolOrthorhombic(const std::string &hmSymbol, const std::string &transformation) const
Method to get the transformed symbol of an orthorhombic space group under the supplied transformation...
SpaceGroupFactoryImpl()
Constructor cannot be called, since SingletonHolder is used.
static MatrixVectorPair< int, V3R > parseIdentifier(const std::string &identifier)
Tries to parse the given symbol.
Crystallographic symmetry operations are composed of a rotational component, which is represented by ...
SymmetryOperation inverse() const
Returns the inverse of the symmetry operation.
const Kernel::IntMatrix & matrix() const
Returns a const reference to the internally stored matrix.
TabulatedSpaceGroupGenerator(size_t number, const std::string &hmSymbol, const std::string &generatorInformation)
Constructor of TabulatedSpaceGroupGenerator, throws an std::runtime_error exception if generatorInfor...
Group_const_sptr generateGroup() const override
Returns a group that contains the symmetry operations in.
Records the filename, the description of failure and the line on which it happened.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
MANTID_GEOMETRY_DLL Group_const_sptr operator*(const Group_const_sptr &lhs, const Group_const_sptr &rhs)
Convenience operator* for directly multiplying groups using shared pointers.
std::shared_ptr< PointGroup > PointGroup_sptr
Shared pointer to a PointGroup.
bool MANTID_GEOMETRY_DLL isValidGeneratorString(const std::string &generatorString)
Free function that tries to parse the given list of symmetry operations and returns true if successfu...
std::shared_ptr< const SpaceGroup > SpaceGroup_const_sptr
std::shared_ptr< AbstractSpaceGroupGenerator > AbstractSpaceGroupGenerator_sptr
std::shared_ptr< const Group > Group_const_sptr