CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
GrandCanonical_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 #include <boost/filesystem.hpp>
9 
10 #include "Common.hh"
13 
14 using namespace CASM;
15 
16 BOOST_AUTO_TEST_SUITE(GrandCanonicalTest)
17 
19 
20  test::ZrOProj proj;
21  proj.check_init();
22  proj.check_composition();
23 
24  Logging logging = Logging::null();
25  //Logging logging;
26  PrimClex primclex(proj.dir, logging);
27 
28  fs::path eci_src = "tests/unit/monte_carlo/eci_0.json";
29  fs::path eci_dest = primclex.dir().eci("formation_energy", "default", "default", "default", "default");
30  fs::copy_file(eci_src, eci_dest, fs::copy_option::overwrite_if_exists);
31 
32  fs::path bspecs_src = "tests/unit/monte_carlo/bspecs_0.json";
33  fs::path bspecs_dest = primclex.dir().bspecs("default");
34  fs::copy_file(bspecs_src, bspecs_dest, fs::copy_option::overwrite_if_exists);
35 
36  fs::path settings_src = "tests/unit/monte_carlo/metropolis_grand_canonical_0.json";
37  fs::path mc_dir = primclex.dir().root_dir() / "mc_0";
38  fs::create_directory(mc_dir);
39  fs::path settings_dest = mc_dir / settings_src.filename();
40  fs::copy_file(settings_src, settings_dest, fs::copy_option::overwrite_if_exists);
41 
42 
43  // for autotools
44  primclex.settings().set_casm_libdir(fs::current_path() / ".libs");
45  primclex.settings().commit();
46 
47  auto check = [&](std::string str) {
48  CommandArgs args(str, &primclex, primclex.dir().root_dir(), Logging::null());
49  return !casm_api(args);
50  };
51 
52  BOOST_CHECK(check(R"(casm bset -u)"));
53 
54  BOOST_CHECK(check(std::string("casm monte -s ") + settings_dest.string()));
55 
56 }
57 
58 BOOST_AUTO_TEST_SUITE_END()
Data structure holding basic CASM command info.
fs::path eci(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const
Returns path to eci.json.
void commit() const
Save settings to project settings file.
fs::path dir
Definition: Proj.hh:34
const DirectoryStructure & dir() const
Definition: PrimClex.hh:112
PrimClex * primclex
Definition: settings.cc:101
void check_composition() override
Check "casm composition".
Definition: ZrOProj.hh:79
Main CASM namespace.
Definition: complete.cpp:8
fs::path bspecs(std::string bset) const
Return basis function specs (bspecs.json) file path.
fs::path root_dir() const
Return casm project directory path.
ProjectSettings & settings()
Definition: PrimClex.hh:116
static Logging null()
Definition: Log.hh:267
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:52
BOOST_AUTO_TEST_CASE(Test0)
bool set_casm_libdir(fs::path dir)
Set casm libdir (empty string to use default)
bool check(std::string test, const jsonParser &expected, const jsonParser &calculated, fs::path test_cases_path, bool quiet, double tol=0.0)
Check expected JSON vs calculated JSON using BOOST_CHECK_EQUAL.
virtual void check_init()
Check project initialization.
int casm_api(const CommandArgs &args)
Executes CASM commands specified by args.