4 #include "casm/external/MersenneTwister/MersenneTwister.h"
13 : m_convert(_convert), m_cand(_cand), m_loc(_cand.size()), m_kmc(false) {}
20 for (
auto &vec :
m_loc) {
50 for (
Index j = 0; j < 1; j++) {
81 return m_loc[cand_index].size();
91 return m_loc[cand_index][loc];
104 OccEvent &e,
const std::vector<OccSwap> &canonical_swap,
105 MTRand &mtrand)
const {
106 Index tsize = canonical_swap.size();
110 for (
Index i = 0; i < tsize; ++i) {
113 ((
double)
cand_size(canonical_swap[i].cand_b));
116 double rand = mtrand.randExc(
m_tsum.back());
118 for (
Index i = 0; i < tsize; ++i) {
119 if (rand <
m_tsum[i + 1]) {
120 return _propose(e, canonical_swap[i], mtrand);
124 throw std::runtime_error(
"OccLocation::propose_canonical error");
129 MTRand &mtrand)
const {
151 m_tmol[occ.mol_id].component =
m_mol[occ.mol_id].component;
167 m_loc[cand_index].pop_back();
185 m_mol[traj.to.mol_id].component[traj.to.mol_comp] =
186 m_tmol[traj.from.mol_id].component[traj.from.mol_comp];
199 f_a.
mol_id =
m_loc[cand_a][mtrand.randInt(size_a - 1)];
208 f_b.
mol_id =
m_loc[cand_b][mtrand.randInt(size_b - 1)];
221 MTRand &mtrand)
const {
226 return _propose(e,
swap, mtrand, cand_a, cand_b, size_a, size_b);
int & occ(Index i)
Reference occupation value on site i.
Index species_index(Index asym, Index occ_index) const
Index occ_size(Index asym) const
Index occ_index(Index asym, Index species_index) const
Index l_to_asym(Index l) const
UnitCellCoord l_to_bijk(Index l) const
Index components_size(Index species_index) const
Index index(const OccCandidate &cand) const
std::vector< Index > m_l_to_mol
l_to_mol[l] -> Mol.id, m_mol.size() otherwise
Index mol_id(Index cand_index, Index loc) const
Mol.id of a particular OccCandidate type.
OccEvent & _propose(OccEvent &e, const OccSwap &swap, MTRand &mtrand, Index cand_a, Index cand_b, Index size_a, Index size_b) const
Canonical propose.
size_type cand_size(Index cand_index) const
Total number of mutating sites, of OccCandidate type, specified by index.
std::vector< Mol > m_mol
Holds Mol objects, one for each mutating site in the configuration.
bool m_kmc
If true, update Species location during apply.
OccEvent & propose_grand_canonical(OccEvent &e, const OccSwap &swap, MTRand &mtrand) const
Propose grand canonical OccEvent.
std::vector< Species > m_species
Holds Monte::Species objects.
const OccCandidateList & m_cand
void apply(const OccEvent &e, ConfigDoF &configdof)
Update configdof and this to reflect that event 'e' occurred.
Index l_to_mol_id(Index l) const
Convert from config index to variable site index.
OccLocation(const Conversions &_convert, const OccCandidateList &_cand)
const Conversions & m_convert
std::vector< std::vector< Index > > m_loc
size_type size() const
Total number of mutating sites.
OccEvent & propose_canonical(OccEvent &e, const std::vector< OccSwap > &canonical_swap, MTRand &mtrand) const
Propose canonical OccEvent.
void initialize(const Configuration &config)
Fill tables with occupation info.
std::vector< double > m_tsum
Data used by propose_canonical.
std::vector< Mol > m_tmol
Data structure used store temporaries during apply.
Store swap type, mutating sites, and info for keeping OccLocation up-to-date.
ConfigIO::GenericConfigFormatter< jsonParser > config()
void swap(ConfigDoF &A, ConfigDoF &B)
INDEX_TYPE Index
For long integer indexing:
Represents the occupant on a site.
Index loc
Location in OccLocation.m_loc.
Index id
Location in OccLocation.m_mol.
std::vector< Index > component
Location of component Specie in OccLocation.m_species.
Index asym
Asym unit index (must be consistent with l)
Index l
Location in config.
std::vector< SpeciesTraj > species_traj
std::vector< OccTransform > occ_transform
Represents an indivisible molecule component.
Index id
Location in OccLocation.m_species.
Index species_index
Species type index.