10 "For CanonicalConditions, expect a JSON object of form:\n"
12 " \"comp\": { // option 1: parameteric composition object\n"
16 " \"comp\": [0.3, 0.2, ...], // option 2: parameteric composition array\n"
17 " \"comp_n\": { // option 3: mol per prim composition object\n"
21 " \"comp_n\": [1.2, 0.3, ...], // option 4: mol per prim composition array\n"
22 " \"temperature\" : 350.0,\n"
23 " \"tolerance\" : 0.001\n"
33 throw std::runtime_error(
"No composition axes selected.");
49 throw std::runtime_error(
"ERROR: Invalid drive mode.");
65 std::string level1 =
"driver";
66 std::string level2 =
"custom_conditions";
69 std::vector<CanonicalConditions> cond;
70 const jsonParser &json = (*this)[level1][level2];
71 for(
auto it = json.
begin(); it != json.
end(); ++it) {
76 catch(std::runtime_error &e) {
79 err_log <<
"Tried to read an array of CanonicalConditions from [\"" << level1 <<
"\"][\"" << level2 <<
"\"]" << std::endl;
80 err_log <<
_help() << std::endl;
90 std::string level1 =
"model";
96 std::vector<std::string> var {
"clex",
"calctype",
"ref",
"bset",
"eci"};
97 std::vector<std::string>
help {
98 "string\n Names the cluster expansion to be used.\n",
99 "string\n Names the calctype to be used.\n",
100 "string\n Names the reference to be used.\n",
101 "string\n Names the basis set to be used.\n",
102 "string\n Names the ECI to be used.\n"
106 _get_setting<std::string>(level1, var[0],
help[0]),
107 _get_setting<std::string>(level1, var[0],
help[0]),
108 _get_setting<std::string>(level1, var[1],
help[1]),
109 _get_setting<std::string>(level1, var[2],
help[2]),
110 _get_setting<std::string>(level1, var[3],
help[3]),
111 _get_setting<std::string>(level1, var[4],
help[4]));
114 std::string
help =
"(string, default='formation_energy')\n"
115 " Names the formation_energy cluster expansion to be used.\n";
119 formation_energy = _get_setting<std::string>(level1,
"formation_energy",
help);
122 if(!set.
has_clex(formation_energy)) {
125 err_log <<
"Error reading [\"model\"][\"formation_energy\"]\n";
126 err_log <<
"[\"model\"][\"formation_energy\"]: (string, optional, default='formation_energy')\n";
127 err_log <<
" Names the cluster expansion to be used for calculating formation_energy.\n";
128 err_log <<
"No cluster expansion named: '" << formation_energy <<
"' exists.\n";
130 return set.
clex(formation_energy);
137 std::string level1 =
"data";
138 std::string level2 =
"measurements";
140 const jsonParser &json = (*this)[level1][level2];
141 for(
auto it = json.
cbegin(); it != json.
cend(); ++it) {
142 if(it->contains(
"quantity") && (*it)[
"quantity"].get<std::string>() ==
"all_correlations") {
148 catch(std::runtime_error &e) {
151 err_log <<
"Error checking if 'all_correlations' should be sampled.\n";
152 err_log <<
"Error reading settings at [\"" << level1 <<
"\"][\"" << level2 <<
"\"]\n";
153 err_log <<
"See 'casm format --monte' for help.\n" << std::endl;
161 std::string level1 =
"driver";
162 std::string level2 = name;
166 catch(std::runtime_error &e) {
169 err_log <<
"Error reading: " << name << std::endl;
170 err_log <<
"Tried to construct CanonicalCondtions from [\"" << level1 <<
"\"][\"" << level2 <<
"\"]" << std::endl;
171 err_log <<
_help() << std::endl;
CanonicalConditions _conditions(std::string name) const
CanonicalSettings()
Default constructor.
Specifies a particular cluster expansion.
iterator end()
Returns iterator to end of JSON object or JSON array.
std::string help()
Print help message describing recognized strings for allowed enum values.
const PrimClex & primclex() const
bool all_correlations() const
Return true if all correlations should be sampled.
CanonicalConditions initial_conditions() const
Expects initial_conditions.
ClexDescription formation_energy(const PrimClex &primclex) const
Get formation energy cluster expansion.
bool has_composition_axes() const
check if CompositionConverter object initialized
iterator begin()
Returns const_iterator to beginning of JSON object or JSON array.
const_iterator cend() const
Returns const_iterator to end of JSON object or JSON array.
std::vector< CanonicalConditions > custom_conditions() const
Expects custom_conditions.
const ClexDescription & clex(std::string name) const
static const int standard
CanonicalConditions incremental_conditions() const
Expects incremental_conditions.
Read/modify settings of an already existing CASM project.
CanonicalConditions final_conditions() const
Expects final_conditions.
void from_json(CanonicalConditions &conditions, const PrimClex &primclex, const jsonParser &json)
Read CanonicalConditions from JSON format.
ProjectSettings & settings()
PrimClex is the top-level data structure for a CASM project.
bool has_clex(std::string name) const
bool _is_setting(std::string level1, std::string level2) const
Returns true if (*this)[level1].contains(level2)
virtual const Monte::DRIVE_MODE drive_mode() const
Given a settings jsonParser figure out the drive mode. Expects drive_mode/incremental,custom.
jsonParser & push_back(const T &value)
Puts new valued element at end of array of any type T for which 'jsonParser& to_json( const T &value...
void error(const std::string &what)
const_iterator cbegin() const
Returns const_iterator to beginning of JSON object or JSON array.