CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
ConfigEnumRandomOccupations_test.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_DYN_LINK
2 #include <boost/test/unit_test.hpp>
3 
6 
8 
9 #include "Common.hh"
10 #include "FCCTernaryProj.hh"
11 #include "casm/external/MersenneTwister/MersenneTwister.h"
12 #include "casm/clex/ScelEnum.hh"
14 
15 using namespace CASM;
16 
17 BOOST_AUTO_TEST_SUITE(ConfigEnumRandomOccupationsTest)
18 
20 
22  proj.check_init();
23 
24  PrimClex primclex(proj.dir, null_log());
25 
26  Eigen::Vector3d a, b, c;
27  std::tie(a, b, c) = primclex.get_prim().lattice().vectors();
28 
29  Supercell scel = Supercell(&primclex, Lattice {2.*a, 2.*b, 2.*c}).canonical_form();
30 
31  Index n_configs = 100;
32  MTRand mtrand;
33 
34  {
35  ConfigEnumRandomOccupations e(scel, n_configs, mtrand);
36  BOOST_CHECK_EQUAL(n_configs, std::distance(e.begin(), e.end()));
37  }
38 
39 
40  {
41  jsonParser json;
42  json["existing_only"] = false;
43  json["max"] = 4;
44 
45  ScelEnum e(primclex, json);
46  for(const auto &scel : e) {
47  (void) scel;
48  }
49  BOOST_CHECK_EQUAL(primclex.get_supercell_list().size(), 14);
50  }
51 
52  {
53  Completer::EnumOption enum_opt;
54  jsonParser json;
55  json["n_configs"] = 200;
56  ConfigEnumRandomOccupations::run(primclex, json, enum_opt);
57  for(const auto &scel : primclex.get_supercell_list()) {
58  BOOST_CHECK_EQUAL(scel.get_config_list().size() > 0, true);
59  }
60  }
61 
62 }
63 
64 BOOST_AUTO_TEST_SUITE_END()
boost::container::stable_vector< Supercell > & get_supercell_list()
Access entire supercell_list.
Definition: PrimClex.cc:299
fs::path dir
Definition: Proj.hh:34
PrimClex * primclex
Definition: settings.cc:101
ConfigList & get_config_list()
Definition: Supercell.hh:279
Main CASM namespace.
Definition: complete.cpp:8
const Lattice & lattice() const
Log & null_log()
Definition: Log.hh:211
Enumerate n random occupations in a particular Supercell.
Enumerate over Supercell.
Definition: ScelEnum.hh:148
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:37
static int run(PrimClex &primclex, const jsonParser &kwargs, const Completer::EnumOption &enum_opt)
EigenIndex Index
For long integer indexing:
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:52
std::tuple< LatVec, LatVec, LatVec > vectors()
Definition: Lattice.hh:65
virtual void check_init()
Check project initialization.
const Structure & get_prim() const
const Access to primitive Structure
Definition: PrimClex.cc:260