1 #define BOOST_TEST_DYN_LINK
2 #include <boost/test/unit_test.hpp>
8 #include <boost/filesystem.hpp>
12 #include "casm/external/MersenneTwister/MersenneTwister.h"
19 BOOST_AUTO_TEST_SUITE(OccLocationTest)
22 config.init_occupation();
23 for(
Index l = 0; l < config.size(); ++l) {
24 int Nocc = convert.occ_size(convert.l_to_asym(l));
25 config.set_occ(l, mtrand.randInt(Nocc - 1));
32 for(
Index l = 0; l < config.
size(); ++l) {
34 if(config.
occ(l) == 0 &&
45 for(
Index mol_id = 0; mol_id < occ_loc.
size(); ++mol_id) {
46 BOOST_REQUIRE_EQUAL(mol_id, occ_loc.
mol(mol_id).
id);
49 for(
Index l = 0; l < config.
size(); ++l) {
51 if(mol_id == occ_loc.
size()) {
54 auto &mol = occ_loc.
mol(mol_id);
56 BOOST_REQUIRE_EQUAL(mol.l, l);
57 BOOST_REQUIRE_EQUAL(mol.id, mol_id);
60 BOOST_REQUIRE_EQUAL(asym, mol.asym);
62 BOOST_REQUIRE_EQUAL(config.
occ(l), convert.
occ_index(asym, mol.species_index));
63 BOOST_REQUIRE_EQUAL(convert.
species_index(asym, config.
occ(l)), mol.species_index);
65 Index cand_index = cand_list.
index(mol.asym, mol.species_index);
66 BOOST_REQUIRE_EQUAL(mol.id, occ_loc.
mol_id(cand_index, mol.loc));
75 auto &mol = occ_loc.
mol(mol_id);
77 BOOST_REQUIRE_EQUAL(mol.l, l);
78 BOOST_REQUIRE_EQUAL(mol.id, mol_id);
79 BOOST_REQUIRE_EQUAL(occ.mol_id, mol_id);
82 BOOST_REQUIRE_EQUAL(asym, mol.asym);
84 BOOST_REQUIRE_EQUAL(config.
occ(l), convert.
occ_index(asym, mol.species_index));
85 BOOST_REQUIRE_EQUAL(convert.
species_index(asym, config.
occ(l)), mol.species_index);
87 Index cand_index = cand_list.
index(mol.asym, mol.species_index);
88 BOOST_REQUIRE_EQUAL(mol.id, occ_loc.
mol_id(cand_index, mol.loc));
92 template<
typename ProjType,
typename ConfigInit>
93 void run_case(ProjType &proj, ConfigInit f, MTRand &mtrand) {
95 proj.check_composition();
110 f(config, convert, mtrand);
125 while(count < 1000000) {
128 check_occ(config, e, occ_loc, convert, cand_list);
129 occ_loc.
apply(e, configdof);
130 check_occ(config, e, occ_loc, convert, cand_list);
163 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(ZrO_RandomConfig)
void initialize(const Configuration &config)
Fill tables with occupation info.
void init_occupation()
Set occupant variables to background structure.
bool species_allowed(Index asym, Index species_index) const
const int & occ(Index site_l) const
Occupant variable on site l.
void random_config(Configuration &config, Monte::Conversions &convert, MTRand &mtrand)
const std::vector< OccSwap > & canonical_swap() const
const ConfigDoF & configdof() const
const Access the DoF
Index species_size() const
void check_occ_init(Configuration &config, Monte::OccLocation &occ_loc, Monte::Conversions &convert, Monte::OccCandidateList &cand_list)
Index l_to_mol_id(Index l) const
Convert from config index to variable site index.
Represents a supercell of the primitive parent crystal structure.
Index mol_id(Index cand_index, Index loc) const
Mol.id of a particular OccCandidate type.
std::vector< OccTransform > occ_transform
Index l_to_asym(Index l) const
EigenIndex Index
For long integer indexing:
A container class for the different degrees of freedom a Configuration might have.
void apply(const OccEvent &e, ConfigDoF &configdof)
Update configdof and this to reflect that event 'e' occurred.
Index id
Location in OccLocation.m_mol.
PrimClex is the top-level data structure for a CASM project.
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.
List of asym / species_index pairs indicating allowed variable occupation dof.
void dilute_config(Configuration &config, Monte::Conversions &convert, MTRand &mtrand)
OccEvent & propose_canonical(OccEvent &e, const std::vector< OccSwap > &canonical_swap, MTRand &mtrand) const
Propose canonical OccEvent.
void set_occ(Index site_l, int val)
Set occupant variable on site l.
void run_case(ProjType &proj, ConfigInit f, MTRand &mtrand)
size_type size() const
Total number of mutating sites.
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
Stores data to enable efficient proposal and update of occupation mutation.
void check_occ(Configuration &config, Monte::OccEvent &e, Monte::OccLocation &occ_loc, Monte::Conversions &convert, Monte::OccCandidateList &cand_list)
A Configuration represents the values of all degrees of freedom in a Supercell.