16#include <boost/algorithm/string.hpp>
26 std::vector<std::string> generatorStrings;
27 boost::split(generatorStrings, generatorString, boost::is_any_of(
";"));
29 return std::all_of(generatorStrings.cbegin(), generatorStrings.cend(), [&](
const auto &identifier) {
31 SymmetryOperationSymbolParser::parseIdentifier(identifier);
57 if (strings.size() < 3) {
58 throw std::invalid_argument(
"There must be at least three strings in the "
59 "vector for SymmetryOperation * "
60 "std::vector<std::string>.");
63 std::vector<int> transformedIndices = symOp.
matrix() * std::vector<int>{0, 1, 2};
65 std::vector<std::string> transformedStrings;
66 std::transform(transformedIndices.cbegin(), transformedIndices.cend(), std::back_inserter(transformedStrings),
67 [=](
int index) { return strings[abs(index)]; });
69 if (transformedStrings.size() < strings.size()) {
70 transformedStrings.insert(transformedStrings.end(), strings.cbegin() + transformedStrings.size(), strings.cend());
73 return transformedStrings;
77AbstractSpaceGroupGenerator::AbstractSpaceGroupGenerator(
size_t number, std::string hmSymbol,
78 std::string generatorInformation)
79 : m_number(number), m_hmSymbol(
std::move(hmSymbol)), m_generatorString(
std::move(generatorInformation)),
106 if (!generatingGroup) {
107 throw std::runtime_error(
"Could not create group from supplied symmetry operations.");
117 const std::string &generatorInformation)
120 throw std::runtime_error(
"Generator string could not be parsed: " + generatorInformation);
130 return baseGroup * centeringGroup;
141 const std::string &generatorInformation)
153 return std::make_shared<Group>(transformation(*baseGroup));
181 std::vector<std::string> parts;
182 boost::split(parts, generatorInformation, boost::is_any_of(
"|"));
184 if (parts.size() != 2) {
185 throw std::invalid_argument(
"Not a valid string for generation of "
186 "transformed space groups. Correct format is "
187 "'HM symbol | transformation'.");
198 const std::string &generatorInformation)
201 throw std::runtime_error(
"Generator string could not be parsed: " + generatorInformation);
214 throw std::invalid_argument(
"Space group with symbol '" + hmSymbol +
"' is not registered.");
230 std::vector<std::string> symbols;
233 [](
const auto &generator) { return generator.first; });
239 std::vector<std::string> symbols;
243 for (
auto it = keyPair.first; it != keyPair.second; ++it) {
244 symbols.emplace_back(it->second);
252 std::vector<size_t> numbers;
256 numbers.emplace_back(it->first);
267 std::string pointGroupSymbol = pointGroup->getSymbol();
269 std::vector<std::string> symbols;
272 for (
auto it = keyPair.first; it != keyPair.second; ++it) {
273 symbols.emplace_back(it->second);
283 throw std::invalid_argument(
"Cannot unsubscribe space group that is not registered.");
289 auto eraseNumber =
m_numberMap.find(generator->getNumber());
314 const std::string &generators) {
315 subscribeUsingGenerator<AlgorithmicSpaceGroupGenerator>(number, hmSymbol, generators);
321 const std::string &symmetryOperations) {
322 subscribeUsingGenerator<TabulatedSpaceGroupGenerator>(number, hmSymbol, symmetryOperations);
328 const std::string &transformation)
const {
330 std::vector<std::string> symbolComponents;
331 boost::split(symbolComponents, hmSymbol, boost::is_any_of(
" "));
334 std::string centeringLowerCase = boost::to_lower_copy(symbolComponents.front());
337 symbolComponents.erase(symbolComponents.begin());
343 std::vector<std::string> axes{
"a",
"b",
"c"};
344 std::vector<std::string> permutedAxes = op * axes;
347 std::vector<std::string> permuted = op * symbolComponents;
348 permuted.insert(permuted.begin(), centeringLowerCase);
351 std::transform(permuted.begin(), permuted.end(), permuted.begin(), [&](
const std::string &symbol) {
352 auto needsTransformation = std::find(permutedAxes.cbegin(), permutedAxes.cend(), symbol);
354 if (needsTransformation == permutedAxes.cend()) {
358 return axes[std::distance(permutedAxes.cbegin(), needsTransformation)];
362 boost::to_upper(*permuted.begin());
364 return boost::join(permuted,
" ");
370 return std::make_shared<const SpaceGroup>(*prototype);
381 m_pointGroupMap.emplace(spaceGroup->getPointGroup()->getSymbol(), generator.first);
390 throw std::runtime_error(
"No generator for symbol '" + hmSymbol +
"'");
393 return generator->getPrototype();
399 throw std::runtime_error(
"Cannot register null-generator.");
402 m_numberMap.emplace(generator->getNumber(), generator->getHMSymbol());
411 Kernel::LibraryManager::Instance();
634DECLARE_GENERATED_SPACE_GROUP(123, "P 4/
m m m", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z; -
x,-
y,-
z")
635DECLARE_GENERATED_SPACE_GROUP(124, "P 4/
m c c", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z+1/2; -
x,-
y,-
z")
637DECLARE_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")
640DECLARE_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")
643DECLARE_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")
644DECLARE_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")
646DECLARE_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")
649DECLARE_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")
652DECLARE_GENERATED_SPACE_GROUP(131, "P 42/
m m c", "-
x,-
y,
z; -
y,
x,
z+1/2; -
x,
y,-
z; -
x,-
y,-
z")
653DECLARE_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")
655DECLARE_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")
658DECLARE_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")
661DECLARE_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")
662DECLARE_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")
665 "-
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")
668DECLARE_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")
671DECLARE_GENERATED_SPACE_GROUP(139, "I 4/
m m m", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z; -
x,-
y,-
z")
672DECLARE_GENERATED_SPACE_GROUP(140, "I 4/
m c
m", "-
x,-
y,
z; -
y,
x,
z; -
x,
y,-
z+1/2; -
x,-
y,-
z")
674 "-
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")
678 "-
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")
750DECLARE_GENERATED_SPACE_GROUP(191, "P 6/
m m m", "-
y,
x-
y,
z;
x,
y,-
z;
y,
x,-
z; -
x,-
y,-
z")
751DECLARE_GENERATED_SPACE_GROUP(192, "P 6/
m c c", "-
y,
x-
y,
z; -
x,-
y,
z;
y,
x,-
z+1/2; -
x,-
y,-
z")
752DECLARE_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")
753DECLARE_GENERATED_SPACE_GROUP(194, "P 63/
m m c", "-
y,
x-
y,
z; -
x,-
y,
z+1/2;
y,
x,-
z; -
x,-
y,-
z")
761DECLARE_GENERATED_SPACE_GROUP(200, "P
m -3", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y; -
x,-
y,-
z")
763DECLARE_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")
766DECLARE_GENERATED_SPACE_GROUP(202, "F
m -3", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y; -
x,-
y,-
z")
768DECLARE_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")
771DECLARE_GENERATED_SPACE_GROUP(204, "I
m -3", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y; -
x,-
y,-
z")
772DECLARE_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")
773DECLARE_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")
774DECLARE_GENERATED_SPACE_GROUP(207, "P 4 3 2", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z")
775DECLARE_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")
776DECLARE_GENERATED_SPACE_GROUP(209, "F 4 3 2", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z")
778DECLARE_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")
779DECLARE_GENERATED_SPACE_GROUP(211, "I 4 3 2", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z")
780DECLARE_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")
781DECLARE_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")
782DECLARE_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")
783DECLARE_GENERATED_SPACE_GROUP(215, "P -4 3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,
z")
784DECLARE_GENERATED_SPACE_GROUP(216, "F -4 3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,
z")
785DECLARE_GENERATED_SPACE_GROUP(217, "I -4 3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,
z")
786DECLARE_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")
787DECLARE_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")
788DECLARE_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")
789DECLARE_GENERATED_SPACE_GROUP(221, "P
m -3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z; -
x,-
y,-
z")
791DECLARE_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")
794DECLARE_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")
796DECLARE_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")
799DECLARE_GENERATED_SPACE_GROUP(225, "F
m -3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z; -
x,-
y,-
z")
800DECLARE_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")
803 "-
x,-
y+1/2,
z+1/2; -
x+1/2,
y+1/2,-
z;
z,
x,
y; "
804 "
y+3/4,
x+1/4,-
z+3/4; -
x+1/4,-
y+1/4,-
z+1/4")
808 "-
x,-
y+1/2,
z+1/2; -
x+1/2,
y+1/2,-
z;
z,
x,
y; "
809 "
y+3/4,
x+1/4,-
z+3/4; -
x+3/4,-
y+3/4,-
z+3/4")
812DECLARE_GENERATED_SPACE_GROUP(229, "I
m -3
m", "-
x,-
y,
z; -
x,
y,-
z;
z,
x,
y;
y,
x,-
z; -
x,-
y,-
z")
813DECLARE_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...
SpaceGroup_const_sptr m_prototype
const std::string & getGeneratorString() const
SpaceGroup_const_sptr getPrototype()
Returns the internally stored prototype, generates one if necessary.
virtual Group_const_sptr generateGroup() const =0
SpaceGroup_const_sptr generatePrototype()
Generates a prototype space group object.
const std::string & getHMSymbol() const
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.
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.
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
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