CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
ConfigEnumInterpolation_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(ConfigEnumInterpolationTest)
15 
17 
19  proj.check_init();
20 
21  PrimClex primclex(proj.dir, null_log());
22  double tol = primclex.crystallography_tol();
23 
24  Eigen::Vector3d a, b, c;
25  std::tie(a, b, c) = primclex.get_prim().lattice().vectors();
26 
27  Supercell scel {&primclex, Lattice(c, a - b, a + b - c)};
28 
29  Configuration c_begin(scel);
30  c_begin.init_displacement();
31  c_begin.init_deformation();
32 
33  // include displacements & deformation
34  Eigen::Vector3d zero(0., 0., 0.);
35  Eigen::Vector3d dx(0.001, 0., 0.);
36  Eigen::Vector3d dy(0., 0.001, 0.);
37  Eigen::Vector3d dz(0., 0., 0.001);
38  Eigen::Matrix3d dF;
39  dF << 0.01, 0.01, 0.0,
40  0.0, -0.01, 0.0,
41  0.0, 0.0, 0.05;
42  Eigen::Matrix3d I = Eigen::Matrix3d::Identity();
43 
44  Configuration c_final {c_begin};
45  c_final.set_disp(0, dx);
46  c_final.set_disp(1, dy);
47  c_final.set_deformation(I + dF);
48 
49  ConfigEnumInterpolation e(c_begin, c_final, 11);
50 
51  Index i = 0;
52  for(const auto &tconfig : e) {
53  //std::cout << "\n--\n" << tconfig << std::endl;
54  double f = (1.*i) / (e.size() - 1);
55  BOOST_CHECK_EQUAL(almost_equal(tconfig.disp(0), dx * f, tol), true);
56  BOOST_CHECK_EQUAL(almost_equal(tconfig.disp(1), dy * f, tol), true);
57  BOOST_CHECK_EQUAL(almost_equal(tconfig.deformation(), I + dF * f, tol), true);
58  ++i;
59  }
60 
61 }
62 
63 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
void set_disp(Index site_l, const Eigen::VectorXd &_disp)
Set occupant displacements.
const Lattice & lattice() const
Log & null_log()
Definition: Log.hh:211
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:37
double tol
double crystallography_tol() const
Definition: PrimClex.hh:124
EigenIndex Index
For long integer indexing:
BOOST_AUTO_TEST_CASE(Test1)
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
void init_displacement()
Set all occupant displacements to (0.,0.,0.)
virtual void check_init()
Check project initialization.
bool almost_equal(const GenericCluster< CoordType > &LHS, const GenericCluster< CoordType > &RHS, double tol)
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
void init_deformation()
Set applied strain to Eigen::Matrix3d::Zero()