CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
LatticeEnumEquivalents_test.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_DYN_LINK
2 #include <boost/test/unit_test.hpp>
3 
6 
9 #include "ZrOProj.hh"
10 
11 using namespace CASM;
12 using namespace test;
13 
14 BOOST_AUTO_TEST_SUITE(LatticeEnumEquivalentsTest)
15 
17 
18  Structure ZrO(ZrO_prim());
19  double tol = CASM::TOL;
20 
21  LatticeEnumEquivalents enumerator(ZrO.lattice(), ZrO.factor_group(), tol);
22  BOOST_CHECK_MESSAGE(1, "LatticeEnumEquivalents construction failed");
23 
24  auto begin = enumerator.begin();
25  BOOST_CHECK_MESSAGE(1, "LatticeEnumEquivalents::begin() failed");
26 
27  auto end = enumerator.end();
28  BOOST_CHECK_MESSAGE(1, "LatticeEnumEquivalents::end() failed");
29 
30  // for prim, should only be one equivalent
31  BOOST_CHECK_EQUAL(1, std::distance(begin, end));
32 
33  // LatticeEnumEquivalents is an InputEnum and allows only a single pass
34  BOOST_CHECK_EQUAL(enumerator.valid(), false);
35 
36  // LatticeEnumEquivalents is an InputEnum and allows only a single pass
37  BOOST_CHECK_EQUAL(0, std::distance(enumerator.begin(), enumerator.end()));
38 
39 }
40 
42 
43  Structure ZrO(ZrO_prim());
44  double tol = CASM::TOL;
45 
46  Eigen::Vector3d a, b, c;
47  std::tie(a, b, c) = ZrO.lattice().vectors();
48 
49  {
50  LatticeEnumEquivalents e(Lattice(2.*a, b, c), ZrO.factor_group(), tol);
51  BOOST_CHECK_EQUAL(3, std::distance(e.begin(), e.end()));
52  }
53 
54  {
55  LatticeEnumEquivalents e(Lattice(2.*a, 2 * b, c), ZrO.factor_group(), tol);
56  BOOST_CHECK_EQUAL(1, std::distance(e.begin(), e.end()));
57  }
58 
59 }
60 
62 
64  double tol = CASM::TOL;
65 
66  MasterSymGroup pg;
67  lat.generate_point_group(pg, tol);
68 
69  Eigen::Vector3d a, b, c;
70  std::tie(a, b, c) = lat.vectors();
71 
72  {
73  LatticeEnumEquivalents e(lat, pg, tol);
74  BOOST_CHECK_EQUAL(1, std::distance(e.begin(), e.end()));
75  }
76 
77  {
78  LatticeEnumEquivalents e(Lattice(2.*a, b, c), pg, tol);
79  BOOST_CHECK_EQUAL(3, std::distance(e.begin(), e.end()));
80  }
81 
82  {
83  LatticeEnumEquivalents e(Lattice(2.*a, 2 * b, c), pg, tol);
84  BOOST_CHECK_EQUAL(1, std::distance(e.begin(), e.end()));
85  }
86 
87 }
88 
90 
91  Lattice lat = Lattice::cubic();
92  double tol = CASM::TOL;
93 
94  MasterSymGroup pg;
95  lat.generate_point_group(pg, tol);
96 
97  Eigen::Vector3d a, b, c;
98  std::tie(a, b, c) = lat.vectors();
99 
100  {
101  LatticeEnumEquivalents e(lat, pg, tol);
102  BOOST_CHECK_EQUAL(1, std::distance(e.begin(), e.end()));
103  }
104 
105  {
106  LatticeEnumEquivalents e(Lattice(2.*a, b, c), pg, tol);
107  BOOST_CHECK_EQUAL(3, std::distance(e.begin(), e.end()));
108  }
109 
110  {
111  LatticeEnumEquivalents e(Lattice(2.*a, 2.*b, c), pg, tol);
112  BOOST_CHECK_EQUAL(3, std::distance(e.begin(), e.end()));
113  }
114 
115  {
116  LatticeEnumEquivalents e(Lattice(2.*a, 2.*b, 2.*c), pg, tol);
117  BOOST_CHECK_EQUAL(1, std::distance(e.begin(), e.end()));
118  }
119 
120  {
121  LatticeEnumEquivalents e(Lattice(4.*a, 2.*b, 1.*c), pg, tol);
122  BOOST_CHECK_EQUAL(6, std::distance(e.begin(), e.end()));
123  }
124 
125 }
126 
128 
129  Lattice lat = Lattice::fcc();
130  double tol = CASM::TOL;
131 
132  MasterSymGroup pg;
133  lat.generate_point_group(pg, tol);
134 
135  Eigen::Vector3d a, b, c;
136  std::tie(a, b, c) = lat.vectors();
137 
138  {
139  LatticeEnumEquivalents e(lat, pg, tol);
140  BOOST_CHECK_EQUAL(1, std::distance(e.begin(), e.end()));
141  }
142 
143  {
144  LatticeEnumEquivalents e(Lattice(2.*a, b, c), pg, tol);
145  BOOST_CHECK_EQUAL(4, std::distance(e.begin(), e.end()));
146  }
147 
148  {
149  LatticeEnumEquivalents e(Lattice(c, a - b, a + b - c), pg, tol);
150  BOOST_CHECK_EQUAL(3, std::distance(e.begin(), e.end()));
151  }
152 
153  {
154  LatticeEnumEquivalents e(Lattice(2.*a, 2.*b, c), pg, tol);
155  BOOST_CHECK_EQUAL(6, std::distance(e.begin(), e.end()));
156  }
157 
158  {
159  LatticeEnumEquivalents e(Lattice(2.*a, 2.*b, 2.*c), pg, tol);
160  BOOST_CHECK_EQUAL(1, std::distance(e.begin(), e.end()));
161  }
162 
163  {
164  LatticeEnumEquivalents e(Lattice(4.*a, 2.*b, 1.*c), pg, tol);
165  BOOST_CHECK_EQUAL(12, std::distance(e.begin(), e.end()));
166  }
167 
168 }
169 
170 BOOST_AUTO_TEST_SUITE_END()
void generate_point_group(SymGroup &point_group, double pg_tol=TOL) const
Populate.
Definition: Lattice.cc:304
static Lattice hexagonal()
Construct cubic primitive cell of unit volume.
Definition: Lattice.cc:75
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:29
Definition: Common.hh:7
Main CASM namespace.
Definition: complete.cpp:8
const Lattice & lattice() const
const double TOL
double tol
BOOST_AUTO_TEST_CASE(Test1)
static Lattice cubic()
Construct simple cubic primitive cell of unit volume.
Definition: Lattice.cc:69
const MasterSymGroup & factor_group() const
Definition: Structure.cc:94
BasicStructure< Site > ZrO_prim()
Definition: ZrOProj.hh:13
std::tuple< LatVec, LatVec, LatVec > vectors()
Definition: Lattice.hh:65
static Lattice fcc()
Construct FCC primitive cell of unit volume.
Definition: Lattice.cc:45
Enumerate equivalent Lattics, given a SymGroup.