CASM  1.1.0
A Clusters Approach to Statistical Mechanics
IrrepDecomposition.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 
7 
8 namespace CASM {
9 
10 namespace SymRepTools_v2 {
11 
12 IrrepInfo::IrrepInfo(Eigen::MatrixXcd _trans_mat, Eigen::VectorXcd _characters)
13  : trans_mat(std::move(_trans_mat)),
14  characters(std::move(_characters)),
15  complex(!almost_zero(trans_mat.imag())),
16  pseudo_irrep(false),
17  index(0) {}
18 
24 IrrepInfo make_dummy_irrep_info(Eigen::MatrixXcd const &trans_mat) {
25  Eigen::VectorXcd tchar(1);
26  tchar(0) = std::complex<double>(double(trans_mat.rows()), 0.);
27  return IrrepInfo(trans_mat, tchar);
28 }
29 
36  Eigen::VectorXcd tchar(1);
37  tchar(0) = std::complex<double>(double(trans_mat.rows()), 0.);
38  return IrrepInfo(trans_mat.template cast<std::complex<double>>(), tchar);
39 }
40 
43 Eigen::MatrixXd full_trans_mat(std::vector<IrrepInfo> const &irreps) {
44  Index row = 0;
45  Index col = 0;
46  for (auto const &irrep : irreps) {
47  col = irrep.vector_dim();
48  row += irrep.irrep_dim();
49  }
50  Eigen::MatrixXd trans_mat(row, col);
51  row = 0;
52  for (auto const &irrep : irreps) {
53  trans_mat.block(row, 0, irrep.irrep_dim(), irrep.vector_dim()) =
54  irrep.trans_mat.real();
55  row += irrep.irrep_dim();
56  }
57  return trans_mat;
58 }
59 
79  MatrixRep const &_fullspace_rep, GroupIndices const &_head_group,
80  Eigen::MatrixXd const &init_subspace,
81  GroupIndicesOrbitVector const &_cyclic_subgroups,
82  GroupIndicesOrbitVector const &_all_subgroups, bool allow_complex)
83  : fullspace_rep(_fullspace_rep),
84  head_group(_head_group),
85  cyclic_subgroups(_cyclic_subgroups),
86  all_subgroups(_all_subgroups) {
87  using namespace IrrepDecompositionImpl;
88 
89  Index dim = fullspace_rep[0].rows();
90 
91  // 1) Expand subspace by application of group, and orthonormalization
93 
94  // 2) Perform irrep_decomposition
95  // In some cases the `irrep_decomposition` method does not find all irreps.
96  // As long as it finds at least one, this loop will try again in the remaining
97  // subspace.
98  Eigen::MatrixXd subspace_i = subspace;
99  Eigen::MatrixXd finished_subspace = make_kernel(subspace);
100  while (finished_subspace.cols() != dim) {
101  // Irreps are found in a subspace specified via the subspace matrix rep
102  MatrixRep subspace_rep_i = make_subspace_rep(fullspace_rep, subspace_i);
103  std::vector<IrrepInfo> subspace_irreps_i =
104  irrep_decomposition(subspace_rep_i, head_group, allow_complex);
105 
106  // If not irreps found in the subspace, this method has failed
107  // If the irreps do not span the whole subspace, we'll try again
108  if (subspace_irreps_i.size() == 0) {
109  std::stringstream msg;
110  msg << "Error in IrrepDecomposition: failed to find all irreps";
111  throw std::runtime_error(msg.str());
112  }
113 
114  // Symmetrize all the irreps that were found
115  std::vector<IrrepInfo> symmetrized_subspace_irreps_i =
116  symmetrize_irreps(subspace_rep_i, head_group, subspace_irreps_i,
118  // Transform the irreps trans_mat to act on vectors in the fullspace
119  std::vector<IrrepInfo> symmetrized_fullspace_irreps_i =
120  make_fullspace_irreps(symmetrized_subspace_irreps_i, subspace_i);
121  // Save the new fullspace irreps
122  for (auto const irrep : symmetrized_fullspace_irreps_i) {
123  irreps.push_back(irrep);
124  }
125 
126  // Combine the irrep spaces and add to finished_subspace
127  Eigen::MatrixXd finished_subspace_i =
128  full_trans_mat(symmetrized_fullspace_irreps_i).adjoint();
129  finished_subspace = extend(finished_subspace, finished_subspace_i);
130 
131  // If not all irreps have been found, try again in remaining space
132  subspace_i = make_kernel(finished_subspace);
133  }
134 
135  // 3) Combine to form symmetry adapted subspace
137 }
138 
139 } // namespace SymRepTools_v2
140 
141 } // namespace CASM
142 
143 // for `make_irrep_decomposition` only
144 #include "casm/symmetry/SymGroup.hh"
146 
147 namespace CASM {
148 
151  SymGroupRep const &rep, SymGroup const &head_group,
152  Eigen::MatrixXd const &init_subspace, bool allow_complex) {
153  SymRepTools_v2::MatrixRep matrix_rep;
154  for (Index i = 0; i < rep.size(); ++i) {
155  matrix_rep.push_back(*rep[i]->MatrixXd());
156  }
157  SymRepTools_v2::GroupIndices head_group_indices;
158  for (SymOp const &op : head_group) {
159  head_group_indices.insert(op.index());
160  }
161  SymRepTools_v2::GroupIndicesOrbitVector cyclic_subgroups =
162  head_group.small_subgroups();
164  head_group.subgroups();
166  matrix_rep, head_group_indices, init_subspace,
167  cyclic_subgroups, all_subgroups, allow_complex};
168  return irrep_decomposition;
169 }
170 
171 } // namespace CASM
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
const std::vector< std::set< std::set< Index > > > & subgroups() const
Definition: SymGroup.cc:1695
std::vector< std::set< std::set< Index > > > small_subgroups() const
Definition: SymGroup.hh:206
SymGroupRep is an alternative representation of a SymGroup for something other than real space....
Definition: SymGroupRep.hh:31
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
std::vector< IrrepInfo > make_fullspace_irreps(std::vector< IrrepInfo > const &subspace_irreps, Eigen::MatrixXd const &subspace)
Convert irreps generated for a subspace to full space dimension.
Eigen::MatrixXd make_invariant_space(MatrixRep const &rep, GroupIndices const &head_group, Eigen::MatrixXd const &subspace)
Expand subspace by application of group, and orthogonalize.
Eigen::MatrixXcd extend(Eigen::MatrixXcd const &space_A, Eigen::MatrixXcd const &space_B)
Return matrix combining columns of space_A and space_B.
Eigen::MatrixXcd make_kernel(Eigen::MatrixXcd const &subspace)
MatrixRep make_subspace_rep(MatrixRep const &fullspace_rep, Eigen::MatrixXd const &subspace)
std::vector< IrrepInfo > symmetrize_irreps(MatrixRep const &subspace_rep, GroupIndices const &head_group, std::vector< IrrepInfo > const &irreps, GroupIndicesOrbitVector const &cyclic_subgroups, GroupIndicesOrbitVector const &all_subgroups)
Symmetrize IrrepInfo, by finding high symmetry directions and aligning the irrep subspace basis with ...
IrrepInfo make_dummy_irrep_info(Eigen::MatrixXcd const &trans_mat)
Construct a "dummy" IrrepInfo with user specified transformtion matrix.
std::set< Index > GroupIndices
Eigen::MatrixXd full_trans_mat(std::vector< IrrepInfo > const &irreps)
Assumes that irreps are real, and concatenates their individual trans_mats to form larger trans_mat.
std::vector< GroupIndicesOrbit > GroupIndicesOrbitVector
std::vector< Eigen::MatrixXd > MatrixRep
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
SymRepTools_v2::IrrepDecomposition make_irrep_decomposition(SymGroupRep const &rep, SymGroup const &head_group, Eigen::MatrixXd const &_init_subspace, bool allow_complex)
Make an IrrepDecompotion using CASM::SymGroupRep and CASM::SymGroup.
std::vector< SymRepTools::IrrepInfo > irrep_decomposition(SymGroupRep const &_rep, SymGroup const &head_group, bool allow_complex)
Finds irreducible subspaces that comprise an underlying subspace It does not rely on the character ta...
Definition: SymRepTools.cc:761
bool almost_zero(const T &val, double tol=TOL)
If T is not integral, use std::abs(val) < tol;.
Definition: CASM_math.hh:104
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Definition: stream_io.hh:24
Performs irreducible subspace construction and symmetrization.
IrrepDecomposition(MatrixRep const &_fullspace_rep, GroupIndices const &_head_group, Eigen::MatrixXd const &_init_subspace, GroupIndicesOrbitVector const &_cyclic_subgroups, GroupIndicesOrbitVector const &_all_subgroups, bool allow_complex)
IrrepDecomposition constructor.
GroupIndices head_group
Group (as indices into fullspace_rep) used to find irreps.
IrrepInfo(Eigen::MatrixXcd _trans_mat, Eigen::VectorXcd _characters)
Construct an IrrepInfo with transformation matrix and vector of irreducible characters.