5 #include "casm/external/MersenneTwister/MersenneTwister.h"
23 for(
auto &vec :
m_loc) {
28 for(
Index l = 0; l < config.
size(); ++l) {
38 for(
Index l = 0; l < config.
size(); ++l) {
49 mol.
loc = m_loc[cand_index].size();
53 for(
Index j = 0; j < 1; j++) {
64 m_loc[cand_index].push_back(mol_id);
92 return m_loc[cand_index].size();
102 return m_loc[cand_index][loc];
118 const std::vector<OccSwap> &canonical_swap,
119 MTRand &mtrand)
const {
121 Index tsize = canonical_swap.size();
125 for(
Index i = 0; i < tsize; ++i) {
127 ((double)
cand_size(canonical_swap[i].cand_a)) *
128 ((
double)
cand_size(canonical_swap[i].cand_b));
131 double rand = mtrand.randExc(
m_tsum.back());
133 for(
Index i = 0; i < tsize; ++i) {
134 if(rand <
m_tsum[i + 1]) {
135 return _propose(e, canonical_swap[i], mtrand);
139 throw std::runtime_error(
"OccLocation::propose_canonical error");
166 m_tmol[occ.mol_id].component =
m_mol[occ.mol_id].component;
182 m_loc[cand_index].pop_back();
201 m_mol[traj.to.mol_id].component[traj.to.mol_comp] =
m_tmol[traj.from.mol_id].component[traj.from.mol_comp];
212 f_a.
mol_id =
m_loc[cand_a][mtrand.randInt(size_a - 1)];
220 f_b.
mol_id =
m_loc[cand_b][mtrand.randInt(size_b - 1)];
236 return _propose(e, swap, mtrand, cand_a, cand_b, size_a, size_b);
void initialize(const Configuration &config)
Fill tables with occupation info.
const OccCandidateList & m_cand
std::vector< Mol > m_mol
Holds Mol objects, one for each mutating site in the configuration.
const int & occ(Index site_l) const
Occupant variable on site l.
Index species_index
Species type index (must be consistent with config.occ(l))
std::vector< double > m_tsum
Data used by propose_canonical.
std::vector< SpecieTraj > species_traj
OccEvent & propose_grand_canonical(OccEvent &e, const OccSwap &swap, MTRand &mtrand) const
Propose grand canonical OccEvent.
Index l_to_mol_id(Index l) const
Convert from config index to variable site index.
Index l
Location in config.
UnitCellCoord bijk_begin
Saves initial position.
Index asym
Asym unit index (must be consistent with l)
Index mol_id(Index cand_index, Index loc) const
Mol.id of a particular OccCandidate type.
std::vector< OccTransform > occ_transform
const Conversions & m_convert
std::vector< Index > component
Location of component Specie in OccLocation.m_species.
size_type cand_size(Index cand_index) const
Total number of mutating sites, of OccCandidate type, specified by index.
Index l_to_asym(Index l) const
void swap(ConfigDoF &A, ConfigDoF &B)
std::vector< Species > m_species
Holds Monte::Species objects.
Index id
Location in OccLocation.m_species.
std::vector< std::vector< Index > > m_loc
EigenIndex Index
For long integer indexing:
Store swap type, mutating sites, and info for keeping OccLocation up-to-date.
A container class for the different degrees of freedom a Configuration might have.
UnitCellCoord l_to_bijk(Index l) const
Represents the occupant on a site.
void apply(const OccEvent &e, ConfigDoF &configdof)
Update configdof and this to reflect that event 'e' occurred.
Index id
Location in OccLocation.m_mol.
Represents an indivisible molecule component.
Index occ_index(Index asym, Index species_index) const
Index size() const
Returns number of sites, NOT the number of primitives that fit in here.
OccEvent & _propose(OccEvent &e, const OccSwap &swap, MTRand &mtrand, Index cand_a, Index cand_b, Index size_a, Index size_b) const
Canonical propose.
List of asym / species_index pairs indicating allowed variable occupation dof.
Index loc
Location in OccLocation.m_loc.
OccEvent & propose_canonical(OccEvent &e, const std::vector< OccSwap > &canonical_swap, MTRand &mtrand) const
Propose canonical OccEvent.
bool m_kmc
If true, update Species location during apply.
Index components_size(Index species_index) const
size_type size() const
Total number of mutating sites.
std::vector< Mol > m_tmol
Data structure used store temporaries during apply.
Index index(const OccCandidate &cand) const
Return index into std::vector, or _candidate.size() if not allowed. ...
Index species_index(Index asym, Index occ_index) const
Index species_index
Species type index.
Index occ_size(Index asym) const
A Configuration represents the values of all degrees of freedom in a Supercell.
OccLocation(const Conversions &_convert, const OccCandidateList &_cand)
std::vector< Index > m_l_to_mol
l_to_mol[l] -> Mol.id, m_mol.size() otherwise