CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
SuperConfigEnum_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 
12 using namespace CASM;
13 
14 BOOST_AUTO_TEST_SUITE(SuperConfigEnumTest)
15 
17 
19  proj.check_init();
20 
21  PrimClex primclex(proj.dir, null_log());
22 
23  Eigen::Vector3d a, b, c;
24  std::tie(a, b, c) = primclex.get_prim().lattice().vectors();
25 
26  Eigen::Matrix3d target_M;
27  target_M << 8.0, 0.0, 0.0,
28  0.0, 8.0, 0.0,
29  0.0, 0.0, 8.0;
30 
31  Supercell target_scel(&primclex, Lattice {target_M});
32 
33  Eigen::Matrix3d motif_M;
34  motif_M << 4.0, 0.0, 0.0,
35  0.0, 4.0, 0.0,
36  0.0, 0.0, 4.0;
37 
38  Supercell motif_scel = Supercell(&primclex, Lattice {motif_M});
39 
40  auto sub_config = [&](std::initializer_list<int> occ) {
41  Configuration tconfig(motif_scel);
42  tconfig.set_occupation(occ);
43  return tconfig;
44  };
45 
46  std::vector<Configuration> sub_configs = {
47  sub_config({0, 0, 0, 0}),
48  sub_config({1, 1, 1, 1})
49  };
50 
51 
52  {
53  SuperConfigEnum e(target_scel, sub_configs.begin(), sub_configs.end());
54  BOOST_CHECK_EQUAL(pow(2, 8), std::distance(e.begin(), e.end()));
55  }
56 
57  {
58  SuperConfigEnum e(target_scel, sub_configs.begin(), sub_configs.end());
59  std::map<Configuration, Array<int> > cmap;
60 
61  for(const auto &tconfig : e) {
62  auto res = cmap.insert(std::make_pair(tconfig.primitive().in_canonical_supercell(), e.counter()));
63  (void) res;
64  }
65 
66  //for(const auto &val : cmap) {
67  // std::cout << "counter: " << val.second << " occ: " << val.first.occupation() << std::endl;
68  //}
69 
70  BOOST_CHECK_EQUAL(cmap.size(), 22);
71  }
72 
73 }
74 
75 BOOST_AUTO_TEST_SUITE_END()
fs::path dir
Definition: Proj.hh:34
PrimClex * primclex
Definition: settings.cc:101
Main CASM namespace.
Definition: complete.cpp:8
const Lattice & lattice() const
Given a selection of Configurations, enumerate all tilings into some supercell.
Log & null_log()
Definition: Log.hh:211
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:37
void set_occupation(const Array< int > &newoccupation)
Set occupant variables.
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
Eigen::Matrix3d Matrix3d
BOOST_AUTO_TEST_CASE(Test1)
virtual void check_init()
Check project initialization.
A Configuration represents the values of all degrees of freedom in a Supercell.
const Structure & get_prim() const
const Access to primitive Structure
Definition: PrimClex.cc:260