CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
Conversions.cc
Go to the documentation of this file.
2 #include "casm/clex/PrimClex.hh"
3 #include "casm/clex/Supercell.hh"
6 
7 namespace CASM {
8  namespace Monte {
9 
10  namespace {
11  Configuration default_prim_config(PrimClex &primclex) {
12  auto &scel = primclex.get_supercell(primclex.add_supercell(primclex.get_prim().lattice()));
13  Configuration res(scel);
14  res.init_occupation();
15  return res;
16  }
17  }
18 
20  Conversions(default_prim_config(mc_scel.get_primclex()), mc_scel) {}
21 
22 
23  Conversions::Conversions(const Configuration &unit_config, const Supercell &mc_scel) :
24  m_unit_scel(&unit_config.get_supercell()),
25  m_mc_scel(&mc_scel),
26  m_struc_mol(m_mc_scel->get_prim().get_struc_molecule()),
27  m_struc_molname(m_mc_scel->get_prim().get_struc_molecule_name()) {
28 
29  // make m_unitl_to_asym, m_Nasym
30  Index asym = 0;
31  Index unit_Nsites = m_unit_scel->num_sites();
32  m_unitl_to_asym.resize(unit_Nsites, -1);
33  std::vector<PermuteIterator> fg = unit_config.factor_group();
34  for(Index unitl = 0; unitl < unit_Nsites; ++unitl) {
35  if(m_unitl_to_asym[unitl] == -1) {
36  for(auto it = fg.begin(); it != fg.end(); ++it) {
37  // permutation defined by: after[i] = before[it->permute_ind(i)]
38  m_unitl_to_asym[it->permute_ind(unitl)] = asym;
39  }
40  ++asym;
41  }
42  }
43  m_Nasym = asym;
44 
45  // make m_asym_to_unitl & m_asym_to_b
46  m_asym_to_unitl.resize(m_Nasym);
47  m_asym_to_b.resize(m_Nasym);
48  for(Index unitl = 0; unitl < unit_Nsites; ++unitl) {
49  Index asym = m_unitl_to_asym[unitl];
50  m_asym_to_unitl[asym].insert(unitl);
51  m_asym_to_b[asym].insert(unitl_to_b(unitl));
52  }
53 
54  // make m_occ_to_species and m_species_to_occ
55 
56  // [b][occ] -> species
57  auto index_converter = get_index_converter(m_mc_scel->get_prim(), m_struc_molname);
58 
59  // [b][species] -> occ, index_converter[b].size() if not allowed
60  auto index_converter_inv = get_index_converter_inverse(m_mc_scel->get_prim(), m_struc_molname);
61 
62  m_occ_to_species.resize(m_Nasym);
63  m_species_to_occ.resize(m_Nasym);
64  for(Index asym = 0; asym < m_Nasym; ++asym) {
65  Index b = *(m_asym_to_b[asym].begin());
66  m_occ_to_species[asym] = index_converter[b];
67  m_species_to_occ[asym] = index_converter_inv[b];
68  }
69  }
70 
72  return m_mc_scel->get_b(l);
73  }
75  return m_mc_scel->prim_grid().unitcell(l % m_mc_scel->volume());
76  }
78  return m_mc_scel->uccoord(l);
79  }
81  return bijk_to_unitl(l_to_bijk(l));
82  }
84  return m_unitl_to_asym[l_to_unitl(l)];
85  }
86 
88  return m_mc_scel->find(bijk);
89  }
91  return m_unit_scel->find(bijk);
92  }
94  return l_to_asym(bijk_to_l(bijk));
95  }
96 
98  return m_unit_scel->get_b(unitl);
99  }
101  return m_unit_scel->uccoord(unitl);
102  }
104  return m_unitl_to_asym[unitl];
105  }
106 
108  return m_Nasym;
109  }
110  const std::set<Index> &Conversions::asym_to_b(Index asym) const {
111  return m_asym_to_b[asym];
112  }
113  const std::set<Index> &Conversions::asym_to_unitl(Index asym) const {
114  return m_asym_to_unitl[asym];
115  }
116 
118  return *m_unit_scel;
119  }
121  return *m_mc_scel;
122  }
123 
125  return m_occ_to_species[asym].size();
126  }
127  Index Conversions::species_index(Index asym, Index occ_index) const {
128  return m_occ_to_species[asym][occ_index];
129  }
130  Index Conversions::occ_index(Index asym, Index species_index) const {
131  // returns occ_size(asym) if species not allowed
132  return m_species_to_occ[asym][species_index];
133  }
134  bool Conversions::species_allowed(Index asym, Index species_index) const {
135  return occ_index(asym, species_index) != occ_size(asym);
136  }
137 
139  return m_struc_mol.size();
140  }
141  Index Conversions::species_index(std::string species_name) const {
142  return find_index(m_struc_molname, species_name);
143  }
144  const Molecule &Conversions::species_to_mol(Index species_index) const {
145  return m_struc_mol[species_index];
146  }
147  const std::string &Conversions::species_name(Index species_index) const {
149  }
150  Index Conversions::components_size(Index species_index) const {
151  return species_to_mol(species_index).size();
152  }
153 
154  }
155 }
const PrimGrid & prim_grid() const
Definition: Supercell.hh:205
Index asym_size() const
Definition: Conversions.cc:107
const std::set< Index > & asym_to_unitl(Index asym) const
Definition: Conversions.cc:113
Index unitl_to_asym(Index unitl) const
Definition: Conversions.cc:103
Index l_to_unitl(Index l) const
Definition: Conversions.cc:80
std::vector< std::string > m_struc_molname
Definition: Conversions.hh:71
bool species_allowed(Index asym, Index species_index) const
Definition: Conversions.cc:134
Index size() const
Definition: Array.hh:145
Index bijk_to_unitl(const UnitCellCoord &bijk) const
Definition: Conversions.cc:90
const Structure & get_prim() const
Definition: Supercell.cc:74
const std::string & species_name(Index species_index) const
Definition: Conversions.cc:147
PrimClex * primclex
Definition: settings.cc:101
Unit Cell Coordinates.
Index find_index(Iterator begin, Iterator end, const T &value)
Equivalent to std::distance(begin, std::find(begin, end, value))
Definition: algorithm.hh:16
Index species_size() const
Definition: Conversions.cc:138
std::vector< std::vector< Index > > m_species_to_occ
m_species_to_occ[asym][species_index] -> occ_index
Definition: Conversions.hh:82
const Supercell * m_mc_scel
Definition: Conversions.hh:69
Main CASM namespace.
Definition: complete.cpp:8
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:37
const Supercell * m_unit_scel
Definition: Conversions.hh:68
Unit Cell Indices.
Index l_to_asym(Index l) const
Definition: Conversions.cc:83
Index bijk_to_l(const UnitCellCoord &bijk) const
Definition: Conversions.cc:87
const Supercell & mc_scel() const
Definition: Conversions.cc:120
std::vector< Molecule > m_struc_mol
Definition: Conversions.hh:70
EigenIndex Index
For long integer indexing:
Index volume() const
Return number of primitive cells that fit inside of *this.
Definition: Supercell.hh:212
std::vector< Index > m_unitl_to_asym
Definition: Conversions.hh:74
UnitCellCoord l_to_bijk(Index l) const
Definition: Conversions.cc:77
UnitCellCoord uccoord(Index i) const
Definition: Supercell.hh:224
const std::set< Index > & asym_to_b(Index asym) const
Definition: Conversions.cc:110
Index l_to_b(Index l) const
Definition: Conversions.cc:71
std::vector< std::vector< Index > > get_index_converter(const Structure &struc, std::vector< Molecule > mol_list)
Helper Functions.
Definition: Structure.cc:1297
const Molecule & species_to_mol(Index species_index) const
Definition: Conversions.cc:144
UnitCellCoord unitl_to_bijk(Index unitl) const
Definition: Conversions.cc:100
Index occ_index(Index asym, Index species_index) const
Definition: Conversions.cc:130
Index find(const UnitCellCoord &bijk) const
Definition: Supercell.cc:39
std::vector< std::set< Index > > m_asym_to_b
Definition: Conversions.hh:76
std::vector< PermuteIterator > factor_group() const
Returns the subgroup of the Supercell factor group that leaves the Configuration unchanged.
std::vector< std::vector< Index > > get_index_converter_inverse(const Structure &struc, std::vector< std::string > mol_name_list)
Definition: Structure.cc:1335
Conversions(const Supercell &mc_scel)
Definition: Conversions.cc:19
Index components_size(Index species_index) const
Definition: Conversions.cc:150
Index bijk_to_asym(const UnitCellCoord &bijk) const
Definition: Conversions.cc:93
Index species_index(Index asym, Index occ_index) const
Definition: Conversions.cc:127
std::vector< std::set< Index > > m_asym_to_unitl
Definition: Conversions.hh:75
std::vector< std::vector< Index > > m_occ_to_species
m_occ_to_species[asym][occ_index] -> species_index
Definition: Conversions.hh:79
UnitCell unitcell(Index i) const
Definition: PrimGrid.cc:229
Index get_b(Index i) const
Definition: Supercell.hh:259
Index unitl_to_b(Index unitl) const
Definition: Conversions.cc:97
const Supercell & unit_scel() const
Definition: Conversions.cc:117
Index occ_size(Index asym) const
Definition: Conversions.cc:124
A Configuration represents the values of all degrees of freedom in a Supercell.
UnitCell l_to_ijk(Index l) const
Definition: Conversions.cc:74
Index num_sites() const
Definition: Supercell.hh:220