3 #include <boost/algorithm/string/classification.hpp>
4 #include <boost/algorithm/string/split.hpp>
25 const Eigen::Matrix3l &transformation_matrix,
int basis_sites_in_prim) {
32 for (
Index translation_ix = 0;
33 translation_ix < ijk_index_converter.
total_sites(); ++translation_ix) {
34 std::vector<Index> single_translation_permutation(
36 UnitCell translation_uc = ijk_index_converter(translation_ix);
39 for (
Index old_site_ix = 0;
40 old_site_ix < bijk_index_converter.
total_sites(); ++old_site_ix) {
41 UnitCellCoord old_site_ucc = bijk_index_converter(old_site_ix);
42 Index new_site_ix = bijk_index_converter(old_site_ucc + translation_uc);
44 single_translation_permutation[new_site_ix] = old_site_ix;
47 assert(
std::find(single_translation_permutation.begin(),
48 single_translation_permutation.end(),
49 -1) == single_translation_permutation.end());
60 std::map<DoFKey, SymGroupRepID>
const &global_dof_symrep_IDs,
61 std::vector<SymGroupRepID>
const &occ_symrep_IDs,
62 std::map<
DoFKey, std::vector<SymGroupRepID> >
const &local_dof_symrep_IDs)
63 : m_supercell_superlattice(_prim_lat, _super_lat),
64 m_unitcell_to_index_converter(
66 m_unitcellcoord_to_index_converter(
73 m_basis_perm_symrep(
factor_group(), basis_permutation_symrep_ID),
74 m_has_aniso_occs(false),
75 m_has_occupation_dofs(false) {
76 for (
auto const &dofID : global_dof_symrep_IDs)
80 for (
auto const &dofID : local_dof_symrep_IDs) {
82 for (
Index b = 0; b < num_sites_in_prim; ++b) {
83 if (!dofID.second[b].empty())
90 for (
Index b = 0; b < num_sites_in_prim; ++b) {
91 if (!occ_symrep_IDs[b].is_identity()) {
94 }
else if (occ_symrep_IDs[b].rep_index() > 1) {
108 long total_sites = bijk_index_converter.
total_sites();
109 for (
Index operation_ix = 0; operation_ix < group.size(); ++operation_ix) {
110 const auto &operation = group[operation_ix];
111 std::vector<Index> permutation(total_sites);
112 for (
Index old_l = 0; old_l < total_sites; ++old_l) {
116 Index new_l = bijk_index_converter(new_ucc);
117 permutation[new_l] = old_l;
120 group[operation_ix].set_rep(perm_rep_ID,
SymPermutation(permutation));
180 Index supercell_factor_group_index)
const {
218 std::string name_str;
222 std::stringstream tname;
224 tname << H(0, 0) * H(1, 1) * H(2, 2) <<
"_" << H(0, 0) <<
"_" << H(1, 1)
225 <<
"_" << H(2, 2) <<
"_" << H(1, 2) <<
"_" << H(0, 2) <<
"_" << H(0, 1);
226 name_str.append(tname.str());
232 std::vector<std::string> tmp, tokens;
237 boost::token_compress_on);
238 std::copy_if(tmp.begin(), tmp.end(), std::back_inserter(tokens),
239 [](
const std::string &val) { return !val.empty(); });
240 if (tokens.size() != 7) {
241 throw std::invalid_argument(
242 "Error in make_supercell: supercell name format error");
245 auto cast = [](std::string val) {
return std::stol(val); };
246 T << cast(tokens[1]), cast(tokens[6]), cast(tokens[5]), 0, cast(tokens[2]),
247 cast(tokens[4]), 0, 0, cast(tokens[3]);
249 }
catch (std::exception &e) {
250 std::string format =
"SCELV_T00_T11_T22_T12_T02_T01";
251 std::stringstream ss;
252 ss <<
"Error in make_hermite_normal_form: "
253 <<
"expected format: " << format <<
", "
256 <<
"tokens: " << tokens <<
", "
257 <<
"tokens.size(): " << tokens.size() <<
", "
258 <<
"error: " << e.what();
259 throw std::runtime_error(ss.str());
285 canon_superlattice.transformation_matrix_to_super());
287 canon_superlattice.superlattice())) {
288 double tol = prim_lattice.
tol();
289 auto from_canonical_index =
291 canon_superlattice.superlattice(),
292 point_group.begin(), point_group.end(), tol)
296 return supercell_name;
307 canon_superlattice.transformation_matrix_to_super());
313 std::string supercell_name) {
316 std::vector<std::string> tokens;
317 boost::split(tokens, supercell_name, boost::is_any_of(
"."),
318 boost::token_compress_on);
321 if (tokens.size() == 0 || tokens.size() > 2) {
322 throw std::invalid_argument(
"supercell_name format error");
328 if (tokens.size() == 2) {
329 Index fg_op_index = std::stol(tokens[1]);
331 std::stringstream ss;
332 ss <<
"Error in make_superlattice_from_supercell_name: "
333 <<
"found prim factor group index: " << fg_op_index
334 <<
", which is out of range [0, " <<
factor_group.size() <<
").";
335 throw std::invalid_argument(ss.str());
347 }
catch (std::exception &e) {
348 std::string format =
"$CANON_SCEL_NAME[.$PRIM_FG_OP]";
349 std::stringstream ss;
350 ss <<
"Error in make_superlattice_from_supercell_name: "
351 <<
"expected format: " << format <<
", name: " << supercell_name
352 <<
", error: " << e.what();
353 throw std::runtime_error(ss.str());
374 DoFKey const &_key, std::vector<PermuteIterator>
const &_group) {
403 std::pair<MasterSymGroup, SymGroupRepID> result;
405 throw std::runtime_error(
"Empty group passed to collective_dof_symrep()");
408 result.first.push_back(perm.sym_op());
411 result.second = result.first.allocate_representation();
417 std::map<Index, Index> site_index_to_basis_index;
419 for (
Index site_index : site_indices) {
421 Index site_dof_dim = subreps[b].dim();
422 site_index_to_basis_index[site_index] = total_dim;
423 total_dim += site_dof_dim;
431 for (
Index site_index : site_indices) {
434 Index to_site_index = site_index;
435 Index row = site_index_to_basis_index.find(to_site_index)->second;
439 Index from_site_index = perm.permute_ind(site_index);
440 auto col_it = site_index_to_basis_index.find(from_site_index);
441 if (col_it == site_index_to_basis_index.end()) {
442 throw std::runtime_error(
443 "Error in collective_dof_symrep: Input group includes permutations "
444 "between selected and unselected sites.");
446 Index col = col_it->second;
454 *(subreps[from_site_b][perm.factor_group_index()]->MatrixXd());
457 trep.block(row, col, U.rows(), U.cols()) = U;
459 result.first[g++].set_rep(result.second,
SymMatrixXd(trep));
PermuteIterator begin_next_fg_op() const
A class that collects all symmetry information for for performing symmetry transformations on the sit...
SymGroupRep::RemoteHandle m_basis_perm_symrep
const Permutation & factor_group_permute(Index supercell_factor_group_index) const
Site permutation corresponding to supercell factor group operation.
const xtal::UnitCellCoordIndexConverter & unitcellcoord_index_converter() const
UnitCellCoordIndexConverter for this superstructure/primstructure pair Used to convert from lattice t...
SupercellSymInfo(Lattice const &_prim_lat, Lattice const &_super_lat, Index number_of_sublats, SymGroup const &_prim_factor_group, SymGroupRepID basis_permutation_symrep_ID, std::map< DoFKey, SymGroupRepID > const &global_dof_symrep_IDs, std::vector< SymGroupRepID > const &occ_symrep_IDs, std::map< DoFKey, std::vector< SymGroupRepID > > const &local_dof_symrep_IDs)
Construct with primitive and super lattice, number of sublattice and all relevant representation IDs.
SublatSymReps m_occ_symreps
permute_const_iterator translate_end() const
End PermuteIterator over pure translational permutations.
const xtal::Lattice & prim_lattice() const
const reference to primitive lattice
SymGroup const & factor_group() const
Subgroup of primitive-cell factor group operations that leave supercell lattice invariant.
permute_const_iterator permute_end() const
const xtal::UnitCellIndexConverter & unitcell_index_converter() const
UnitCellIndexConverter for this superlattice/primlattice pair Used to convert from lattice translatio...
SymGroupRep::RemoteHandle const & site_permutation_symrep() const
const xtal::Lattice & supercell_lattice() const
const reference to supercell lattice
bool m_has_occupation_dofs
PermuteIterator permute_const_iterator
std::vector< SymGroupRep::RemoteHandle > SublatSymReps
permute_const_iterator permute_begin() const
permute_const_iterator permute_it(Index supercell_factor_group_index, Index translation_index) const
std::map< DoFKey, SymGroupRep::RemoteHandle > m_global_dof_symreps
SymGroupRep::RemoteHandle const & basis_permutation_symrep() const
permute_const_iterator translate_begin() const
Begin PermuteIterator over pure translational permutations / Equivalent to permute_begin()
std::map< DoFKey, SublatSymReps > m_local_dof_symreps
SymGroupRep::RemoteHandle m_site_perm_symrep
std::map< DoFKey, SublatSymReps > const & local_dof_symreps() const
Const reference local DoF matrix representations of the supercell's factor group.
SublatSymReps const & occ_symreps() const
SymGroupRep handle for occupant permutation representation of supercell's factor group An occupant pe...
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
SymGroupRepID allocate_representation() const
Add a new empty representation.
SymGroupRepHandle RemoteHandle
Permutation const * permutation(Index i) const
pointer to Permutation corresponding to SymOpRepresentation at entry 'i' of this SymGroupRep Returns ...
Type-safe ID object for communicating and accessing Symmetry representation info.
Generalized symmetry matrix representation for arbitrary dimension Can be used to describe applicatio...
SymPermutation describes how a symmetry operation permutes a list of 'things' For example,...
Index total_sites() const
Returns the total number of sites within the superlattice.
Index total_sites() const
Returns the total number of sites within the superlattice.
std::string to_string(ENUM val)
Return string representation of enum class.
Lattice make_superlattice(const Lattice &lat, const Eigen::Matrix< IntegralType, 3, 3, Options > &transf_mat)
Returns a super Lattice. Transformation matrix must be integer.
std::pair< Eigen::MatrixXi, Eigen::MatrixXi > hermite_normal_form(const Eigen::MatrixXi &M)
Return the hermite normal form, M == H*V.
xtal::Superlattice make_superlattice_from_supercell_name(Structure const &prim, std::string supercell_name)
Construct a Superlattice from the supercell name.
std::string make_canonical_supercell_name(Structure const &prim, xtal::Superlattice const &superlattice)
Make the canonical supercell name from a Superlattice.
std::string make_supercell_name(Structure const &prim, xtal::Superlattice const &superlattice)
Make the supercell name from a Superlattice.
xtal::Coordinate copy_apply(const xtal::SymOp &op, xtal::Coordinate coord)
Copy and apply SymOp to a Coordinate.
SymGroup invariant_subgroup(const SymGroup &super_group, const xtal::Lattice &lat)
Returns the subgroup of the given group that keeps the lattice invariant.
Lattice equivalent(Lattice const &in_lat, SymOpVector const &point_grp, double compare_tol)
bool is_equivalent(const Lattice &ref_lattice, const Lattice &other)
Check if ref_lattice = other*U, where U is unimodular.
std::pair< OpIterator, Eigen::Matrix3d > is_equivalent_superlattice(const Object &scel, const Object &unit, OpIterator begin, OpIterator end, double tol)
std::vector< Permutation > make_translation_permutations(const Eigen::Matrix3l &transformation_matrix, int basis_sites_in_prim)
std::pair< MasterSymGroup, SymGroupRepID > make_collective_dof_symrep(std::set< Index > const &site_indices, SupercellSymInfo const &_syminfo, DoFKey const &_key, std::vector< PermuteIterator > const &_group)
Make the matrix representation for group '_group' describing the transformation of DoF '_key' among a...
SymGroupRepID make_permutation_representation(const SymGroup &group, const xtal::UnitCellCoordIndexConverter &bijk_index_converter, const Lattice &prim_lattice, const SymGroupRepID &prim_symrep_ID)
Eigen::Matrix3l make_hermite_normal_form(std::string hermite_normal_form_name)
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
std::string hermite_normal_form_name(const Eigen::Matrix3l &matrix)
INDEX_TYPE Index
For long integer indexing:
Matrix< long int, 3, 3 > Matrix3l