CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Conversions.cc
Go to the documentation of this file.
2 
4 #include "casm/clex/PrimClex.hh"
5 #include "casm/clex/Supercell.hh"
9 #include "casm/misc/algorithm.hh"
10 
11 namespace CASM {
12 namespace Monte {
13 
14 namespace {
15 Configuration default_prim_config(const PrimClex &primclex) {
16  const Supercell &scel = *primclex.db<Supercell>()
18  .first;
19  Configuration res(scel);
20  res.init_occupation();
21  return res;
22 }
23 } // namespace
24 
26  : Conversions(default_prim_config(mc_scel.primclex()), mc_scel) {}
27 
29  const Supercell &mc_scel)
30  : m_unit_scel(&unit_config.supercell()),
31  m_mc_scel(&mc_scel),
32  m_struc_mol(xtal::struc_molecule(m_mc_scel->prim())),
33  m_struc_molname(xtal::struc_molecule_name(m_mc_scel->prim())) {
34  // make m_unitl_to_asym, m_Nasym
35  Index asym = 0;
36  Index unit_Nsites = m_unit_scel->num_sites();
37  m_unitl_to_asym.resize(unit_Nsites, -1);
38  std::vector<PermuteIterator> fg = unit_config.factor_group();
39  for (Index unitl = 0; unitl < unit_Nsites; ++unitl) {
40  if (m_unitl_to_asym[unitl] == -1) {
41  for (auto it = fg.begin(); it != fg.end(); ++it) {
42  // permutation defined by: after[i] = before[it->permute_ind(i)]
43  m_unitl_to_asym[it->permute_ind(unitl)] = asym;
44  }
45  ++asym;
46  }
47  }
48  m_Nasym = asym;
49 
50  // make m_asym_to_unitl & m_asym_to_b
51  m_asym_to_unitl.resize(m_Nasym);
52  m_asym_to_b.resize(m_Nasym);
53  for (Index unitl = 0; unitl < unit_Nsites; ++unitl) {
54  Index asym = m_unitl_to_asym[unitl];
55  m_asym_to_unitl[asym].insert(unitl);
56  m_asym_to_b[asym].insert(unitl_to_b(unitl));
57  }
58 
59  // make m_occ_to_species and m_species_to_occ
60 
61  // [b][occ] -> species
62  auto index_converter =
64 
65  // [b][species] -> occ, index_converter[b].size() if not allowed
66  auto index_converter_inv =
68 
69  m_occ_to_species.resize(m_Nasym);
70  m_species_to_occ.resize(m_Nasym);
71  for (Index asym = 0; asym < m_Nasym; ++asym) {
72  Index b = *(m_asym_to_b[asym].begin());
73  m_occ_to_species[asym] = index_converter[b];
74  m_species_to_occ[asym] = index_converter_inv[b];
75  }
76 }
77 
80  return m_mc_scel->uccoord(l).unitcell();
81 }
83  return m_mc_scel->uccoord(l);
84 }
86  return bijk_to_unitl(l_to_bijk(l));
87 }
89  return m_unitl_to_asym[l_to_unitl(l)];
90 }
91 
93  return m_mc_scel->linear_index(bijk);
94 }
96  return m_unit_scel->linear_index(bijk);
97 }
99  return l_to_asym(bijk_to_l(bijk));
100 }
101 
103  return m_unit_scel->sublat(unitl);
104 }
106  return m_unit_scel->uccoord(unitl);
107 }
109  return m_unitl_to_asym[unitl];
110 }
111 
113 const std::set<Index> &Conversions::asym_to_b(Index asym) const {
114  return m_asym_to_b[asym];
115 }
116 const std::set<Index> &Conversions::asym_to_unitl(Index asym) const {
117  return m_asym_to_unitl[asym];
118 }
119 
120 const Supercell &Conversions::unit_scel() const { return *m_unit_scel; }
121 const Supercell &Conversions::mc_scel() const { return *m_mc_scel; }
122 
124  return m_occ_to_species[asym].size();
125 }
126 Index Conversions::species_index(Index asym, Index occ_index) const {
127  return m_occ_to_species[asym][occ_index];
128 }
129 Index Conversions::occ_index(Index asym, Index species_index) const {
130  // returns occ_size(asym) if species not allowed
131  return m_species_to_occ[asym][species_index];
132 }
133 bool Conversions::species_allowed(Index asym, Index species_index) const {
134  return occ_index(asym, species_index) != occ_size(asym);
135 }
136 
137 Index Conversions::species_size() const { return m_struc_mol.size(); }
138 Index Conversions::species_index(std::string species_name) const {
140 }
141 const Molecule &Conversions::species_to_mol(Index species_index) const {
142  return m_struc_mol[species_index];
143 }
144 const std::string &Conversions::species_name(Index species_index) const {
146 }
149 }
150 
151 } // namespace Monte
152 } // namespace CASM
std::vector< PermuteIterator > factor_group() const
Returns the subgroup of the Supercell factor group that leaves the Configuration unchanged.
const Supercell & unit_scel() const
Definition: Conversions.cc:120
Index bijk_to_unitl(const UnitCellCoord &bijk) const
Definition: Conversions.cc:95
const std::set< Index > & asym_to_b(Index asym) const
Definition: Conversions.cc:113
UnitCell l_to_ijk(Index l) const
Definition: Conversions.cc:79
std::vector< std::set< Index > > m_asym_to_unitl
Definition: Conversions.hh:78
std::vector< std::set< Index > > m_asym_to_b
Definition: Conversions.hh:79
Conversions(const Supercell &mc_scel)
Definition: Conversions.cc:25
std::vector< std::vector< Index > > m_species_to_occ
m_species_to_occ[asym][species_index] -> occ_index
Definition: Conversions.hh:85
Index species_index(Index asym, Index occ_index) const
Definition: Conversions.cc:126
const Supercell * m_mc_scel
Definition: Conversions.hh:72
const std::set< Index > & asym_to_unitl(Index asym) const
Definition: Conversions.cc:116
Index l_to_b(Index l) const
Definition: Conversions.cc:78
Index unitl_to_asym(Index unitl) const
Definition: Conversions.cc:108
Index occ_size(Index asym) const
Definition: Conversions.cc:123
const Molecule & species_to_mol(Index species_index) const
Definition: Conversions.cc:141
std::vector< Molecule > m_struc_mol
Definition: Conversions.hh:73
const Supercell & mc_scel() const
Definition: Conversions.cc:121
Index occ_index(Index asym, Index species_index) const
Definition: Conversions.cc:129
std::vector< std::string > m_struc_molname
Definition: Conversions.hh:74
Index l_to_asym(Index l) const
Definition: Conversions.cc:88
UnitCellCoord l_to_bijk(Index l) const
Definition: Conversions.cc:82
const Supercell * m_unit_scel
Definition: Conversions.hh:71
Index bijk_to_l(const UnitCellCoord &bijk) const
Definition: Conversions.cc:92
Index unitl_to_b(Index unitl) const
Definition: Conversions.cc:102
std::vector< std::vector< Index > > m_occ_to_species
m_occ_to_species[asym][occ_index] -> species_index
Definition: Conversions.hh:82
UnitCellCoord unitl_to_bijk(Index unitl) const
Definition: Conversions.cc:105
bool species_allowed(Index asym, Index species_index) const
Definition: Conversions.cc:133
Index l_to_unitl(Index l) const
Definition: Conversions.cc:85
const std::string & species_name(Index species_index) const
Definition: Conversions.cc:144
Index bijk_to_asym(const UnitCellCoord &bijk) const
Definition: Conversions.cc:98
std::vector< Index > m_unitl_to_asym
Definition: Conversions.hh:77
Index components_size(Index species_index) const
Definition: Conversions.cc:147
Index species_size() const
Definition: Conversions.cc:137
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
Index sublat(Index linear_index) const
Return the sublattice index for a linear index.
Definition: Supercell.cc:165
Index linear_index(const Coordinate &coord, double tol=TOL) const
Given a Coordinate and tolerance, return linear index into Configuration.
Definition: Supercell.cc:183
UnitCellCoord uccoord(Index linear_index) const
Return the integral coordinates corresponding to a linear index.
Definition: Supercell.cc:209
Index num_sites() const
Definition: Supercell.cc:233
const Structure & prim() const
Definition: Supercell.cc:113
Class representing a Molecule.
Definition: Molecule.hh:93
Unit Cell Coordinates.
const UnitCell & unitcell() const
Unit Cell Indices.
Index size() const
Number of atoms contained Molecule.
Definition: Molecule.hh:113
std::vector< Molecule > struc_molecule(BasicStructure const &_struc)
Returns an Array of each possible Molecule in this Structure.
std::vector< std::string > struc_molecule_name(BasicStructure const &_struc)
Returns an Array of each possible Molecule in this Structure.
IdentitySymRepBuilder Identity()
Main CASM namespace.
Definition: APICommand.hh:8
Index find_index(Iterator begin, Iterator end, const T &value)
Equivalent to std::distance(begin, std::find(begin, end, value))
Definition: algorithm.hh:24
std::vector< std::vector< Index > > make_index_converter(const Structure &struc, std::vector< xtal::Molecule > mol_list)
Definition: Structure.cc:322
std::vector< std::vector< Index > > make_index_converter_inverse(const Structure &struc, std::vector< std::string > mol_name_list)
Definition: Structure.cc:363
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
PrimClex * primclex
Definition: settings.cc:135