10 "For GrandCanonicalConditions, expect a JSON object of form:\n"
12 " \"param_chem_pot\": {\n"
16 " \"temperature\" : 350.0,\n"
17 " \"tolerance\" : 0.001\n"
27 throw std::runtime_error(
"No composition axes selected.");
43 throw std::runtime_error(
"ERROR: Invalid drive mode.");
59 std::string level1 =
"driver";
60 std::string level2 =
"custom_conditions";
63 std::vector<GrandCanonicalConditions> cond;
64 const jsonParser &json = (*this)[level1][level2];
65 for(
auto it = json.
begin(); it != json.
end(); ++it) {
70 catch(std::runtime_error &e) {
73 err_log <<
"Tried to read an array of GrandCanonicalConditions from [\"" << level1 <<
"\"][\"" << level2 <<
"\"]" << std::endl;
74 err_log <<
_help() << std::endl;
84 std::string level1 =
"model";
90 std::vector<std::string> var {
"clex",
"calctype",
"ref",
"bset",
"eci"};
91 std::vector<std::string>
help {
92 "string\n Names the cluster expansion to be used.\n",
93 "string\n Names the calctype to be used.\n",
94 "string\n Names the reference to be used.\n",
95 "string\n Names the basis set to be used.\n",
96 "string\n Names the ECI to be used.\n"
100 _get_setting<std::string>(level1, var[0],
help[0]),
101 _get_setting<std::string>(level1, var[0],
help[0]),
102 _get_setting<std::string>(level1, var[1],
help[1]),
103 _get_setting<std::string>(level1, var[2],
help[2]),
104 _get_setting<std::string>(level1, var[3],
help[3]),
105 _get_setting<std::string>(level1, var[4],
help[4]));
108 std::string
help =
"(string, default='formation_energy')\n"
109 " Names the formation_energy cluster expansion to be used.\n";
113 formation_energy = _get_setting<std::string>(level1,
"formation_energy",
help);
116 if(!set.
has_clex(formation_energy)) {
119 err_log <<
"Error reading [\"model\"][\"formation_energy\"]\n";
120 err_log <<
"[\"model\"][\"formation_energy\"]: (string, optional, default='formation_energy')\n";
121 err_log <<
" Names the cluster expansion to be used for calculating formation_energy.\n";
122 err_log <<
"No cluster expansion named: '" << formation_energy <<
"' exists.\n";
124 return set.
clex(formation_energy);
134 std::string level1 =
"data";
135 std::string level2 =
"measurements";
137 const jsonParser &json = (*this)[level1][level2];
138 for(
auto it = json.
cbegin(); it != json.
cend(); ++it) {
139 if(it->contains(
"quantity") && (*it)[
"quantity"].get<std::string>() ==
"all_correlations") {
145 catch(std::runtime_error &e) {
148 err_log <<
"Error checking if 'all_correlations' should be sampled.\n";
149 err_log <<
"Error reading settings at [\"" << level1 <<
"\"][\"" << level2 <<
"\"]\n";
150 err_log <<
"See 'casm format --monte' for help.\n" << std::endl;
158 std::string level1 =
"driver";
159 std::string level2 = name;
163 catch(std::runtime_error &e) {
166 err_log <<
"Error reading: " << name << std::endl;
167 err_log <<
"Tried to construct GrandCanonicalCondtions from [\"" << level1 <<
"\"][\"" << level2 <<
"\"]" << std::endl;
168 err_log <<
_help() << std::endl;
Specifies a particular cluster expansion.
GrandCanonicalConditions _conditions(std::string name) const
GrandCanonicalConditions incremental_conditions() const
Expects incremental_conditions.
void from_json(ClexDescription &desc, const jsonParser &json)
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
std::vector< GrandCanonicalConditions > custom_conditions() const
Expects custom_conditions.
bool has_composition_axes() const
check if CompositionConverter object initialized
GrandCanonicalConditions final_conditions() const
Expects final_conditions.
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.
GrandCanonicalSettings()
Default constructor.
bool all_correlations() const
Return true if all correlations should be sampled.
const ClexDescription & clex(std::string name) const
static const int standard
Read/modify settings of an already existing CASM project.
ProjectSettings & settings()
PrimClex is the top-level data structure for a CASM project.
bool has_clex(std::string name) const
ClexDescription formation_energy(const PrimClex &primclex) const
Get formation energy cluster expansion.
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...
GrandCanonicalConditions initial_conditions() const
Expects initial_conditions.
Monte::METHOD method() const
Return type of Monte Carlo method.
void error(const std::string &what)
const_iterator cbegin() const
Returns const_iterator to beginning of JSON object or JSON array.