CASM  1.1.0
A Clusters Approach to Statistical Mechanics
InvariantSubgroup_impl.hh
Go to the documentation of this file.
1 #ifndef CASM_InvariantSubgroup_impl
2 #define CASM_InvariantSubgroup_impl
3 
7 
8 namespace CASM {
9 
10 // using xtal::Coordinate;
11 
27 template <typename Element, typename OpIterator, typename SymCompareType,
28  typename OpOutputIterator>
29 OpOutputIterator make_invariant_subgroup(Element const &element,
30  OpIterator group_begin,
31  OpIterator group_end,
32  SymCompareType const &sym_compare,
33  OpOutputIterator result) {
34  Element e{sym_compare.prepare(element)};
35  for (auto group_it = group_begin; group_it != group_end; ++group_it) {
36  if (sym_compare.equal(
37  e, sym_compare.prepare(sym_compare.copy_apply(*group_it, e)))) {
38  *result++ = sym_compare.spatial_transform() * (*group_it);
39  }
40  }
41  return result;
42 }
43 
57 template <typename Element, typename SymCompareType, typename OutputIterator>
58 OutputIterator make_invariant_subgroup(Element const &element,
59  PermuteIterator permute_begin,
60  PermuteIterator permute_end,
61  SymCompareType const &sym_compare,
62  OutputIterator result) {
63  Element e{sym_compare.prepare(element)};
64  for (auto permute_it = permute_begin; permute_it != permute_end;
65  ++permute_it) {
66  if (sym_compare.equal(e, sym_compare.prepare(sym_compare.copy_apply(
67  permute_it->sym_op(), e)))) {
68  *result++ = permute_it;
69  }
70  }
71  return result;
72 }
73 
91 template <typename Element, typename SymCompareType>
92 SymGroup make_invariant_subgroup(const Element &element,
93  const SymGroup &generating_grp,
94  const SymCompareType &sym_compare) {
95  SymGroup result = generating_grp;
96  result.clear();
97  make_invariant_subgroup(element, generating_grp.begin(), generating_grp.end(),
98  sym_compare, std::back_inserter(result));
99  if (result[0].index() != 0) {
100  throw std::runtime_error(
101  "Error in make_invariant_subgroup (0): First element is not identity.");
102  }
103  return result;
104 }
105 
117 template <typename OrbitType>
118 SymGroup make_invariant_subgroup(const OrbitType &orbit, Index element_index) {
119  SymGroup result;
120  const auto &map = orbit.equivalence_map();
121  result.set_lattice(map[0][0].master_group().lattice());
122  for (Index i = 0; i < orbit.equivalence_map()[0].size(); ++i) {
123  result.push_back(map[element_index][0] * map[0][i] *
124  map[element_index][0].inverse());
125  }
126  if (result[0].index() != 0) {
127  throw std::runtime_error(
128  "Error in make_invariant_subgroup (1): First element is not identity.");
129  }
130  return result;
131 }
132 
133 } // namespace CASM
134 
135 #endif
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
virtual void clear()
Definition: SymGroup.cc:871
virtual void push_back(const SymOp &new_op)
Definition: SymGroup.cc:818
void set_lattice(const Lattice &new_lat)
Lattice used for periodic comparisons (for instance, to generate multiplcation table)
Definition: SymGroup.cc:814
std::vector< PermuteIterator > make_invariant_subgroup(ConfigEnumInput const &config_enum_input)
Eigen::Matrix< typename Derived::Scalar, Derived::RowsAtCompileTime, Derived::ColsAtCompileTime > inverse(const Eigen::MatrixBase< Derived > &M)
Return the integer inverse matrix of an invertible integer matrix.
GenericVectorXdScelFormatter lattice()
Definition: SupercellIO.cc:266
Main CASM namespace.
Definition: APICommand.hh:8
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39