17 m_primclex(&_primclex) {
40 return _get_setting<Monte::ENSEMBLE>(
"ensemble", help<Monte::ENSEMBLE>());
45 return _get_setting<Monte::METHOD>(
"method", help<Monte::METHOD>());
50 auto it =
find(
"debug");
54 return it->get<
bool>();
59 (*this)[
"debug"] = _debug;
67 return _is_setting(
"driver",
"motif",
"configname");
72 std::string
help =
"string"
73 " The name of a configuration, of the form \"SCELV_A_B_C_D_E_F/N\"";
74 return _get_setting<std::string>(
"driver",
"motif",
"configname",
help);
84 std::string
help =
"string\n"
85 " Path to file containing DoF, such as an \"final_state.json\" file.";
86 fs::path configdof_path = _get_setting<fs::path>(
"driver",
"motif",
"configdof",
help);
92 std::string
help =
"";
93 return _get_setting<fs::path>(
"driver",
"motif",
"configdof",
help);
99 std::string
help =
"3x3 transformation matrix, T, such that S = U*T,\n"
100 " where S, is the supercell lattice vectors,\n"
101 " and P, is the primitive cell lattice vectors.\n";
102 return _get_setting<Eigen::Matrix3i>(
"supercell",
help);
110 return _get_setting<Monte::DRIVE_MODE>(
"driver",
"mode", help<Monte::DRIVE_MODE>());
119 std::string
help =
"bool (default=true)\n"
120 " If true, begin the next calculation with the final DoF from the previous \n"
122 " If false, begin each calculation with the DoF specified for the \"motif\".\n";
123 return _get_setting<bool>(
"driver",
"dependent_runs",
help);
136 std::string
help =
"number, range (0.0, 1.0), default 0.95)";
138 return _get_setting<double>(
"data",
"confidence",
help);
147 std::string level1 =
"data";
148 std::string level2 =
"storage";
149 std::string level3 =
"write_trajectory";
150 std::string
help =
"bool (default=false)";
155 return _get_setting<bool>(level1, level2, level3,
help);
160 std::string level1 =
"data";
161 std::string level2 =
"storage";
162 std::string level3 =
"write_POSCAR_snapshots";
163 std::string
help =
"(bool, default=false)";
168 return _get_setting<bool>(level1, level2, level3,
help);
173 std::string level1 =
"data";
174 std::string level2 =
"storage";
175 std::string level3 =
"write_observations";
176 std::string
help =
"(bool, default=false)";
181 return _get_setting<bool>(level1, level2, level3,
help);
186 std::string level1 =
"data";
187 std::string level2 =
"storage";
188 std::string level3 =
"output_format";
189 std::string
help =
"(string or JSON array of string, optional, default='csv')\n"
190 " Accepts: 'csv' or 'CSV' to write .csv files\n"
191 " 'json' or 'JSON' to write .json files\n"
192 " Use an array to write in multiple formats.\n";
201 std::vector<std::string> formats = _get_setting<std::vector<std::string> >(level1, level2, level3,
help);
202 for(
auto it = formats.begin(); it != formats.end(); ++it) {
203 if(*it ==
"csv" || *it ==
"CSV") {
210 std::string input = _get_setting<std::string>(level1, level2, level3,
help);
211 if(input ==
"csv" || input ==
"CSV") {
220 std::string level1 =
"data";
221 std::string level2 =
"storage";
222 std::string level3 =
"output_format";
223 std::string
help =
"(string or JSON array of string, optional, default='csv')\n"
224 " Accepts: 'csv' or 'CSV' to write .csv files\n"
225 " 'json' or 'JSON' to write .json files\n"
226 " Use an array to write in multiple formats.\n";
235 std::vector<std::string> formats = _get_setting<std::vector<std::string> >(level1, level2, level3,
help);
236 for(
auto it = formats.begin(); it != formats.end(); ++it) {
237 if(*it ==
"json" || *it ==
"JSON") {
244 std::string input = _get_setting<std::string>(level1, level2, level3,
help);
245 if(input ==
"json" || input ==
"JSON") {
271 std::string
help =
"(string, optional, default=\"clex_hull_dist(ALL)\")\n"
272 " A 'casm query'-like string that provides a metric for \n"
273 " ranking configurations as they are encountered during \n"
274 " a Monte Carlo calculation. The resulting value is used\n"
275 " to create a hall of fame of 'best' configurations \n"
276 " encountered during the calculation. When the \n"
277 " calculation is complete configurations in the hall of \n"
278 " fame are added to the CASM project config list. \n"
279 " The 'casm query'-like command should evaluate to a \n"
282 if(!
_is_setting(
"data",
"enumeration",
"metric")) {
283 return "clex_hull_dist(ALL)";
285 return _get_setting<std::string>(
"data",
"enumeration",
"metric",
help);
299 std::string
help =
"(string, optional, default=\"eq(1,1)\")\n"
300 " A 'casm query'-like string that returns a boolean value \n"
301 " indicating if (true) a configuration should be considered\n"
302 " for the enumeration hall of fame.";
307 return _get_setting<std::string>(
"data",
"enumeration",
"check",
help);
312 if(!
_is_setting(
"data",
"enumeration",
"sample_mode")) {
315 return _get_setting<Monte::ENUM_SAMPLE_MODE>(
"data",
"enumeration",
"sample_mode", help<Monte::ENUM_SAMPLE_MODE>());
321 std::string
help =
"(bool, optional, default=true)\n"
322 " If true, only configurations that do not already exist\n"
323 " in the config list are inserted into the enumeration \n"
326 if(!
_is_setting(
"data",
"enumeration",
"check_existence")) {
329 return _get_setting<bool>(
"data",
"enumeration",
"check_existence",
help);
335 std::string
help =
"(bool, optional, default=true)\n"
336 " If true, configurations are inserted into the \n"
337 " enumeration hall of fame in their canonical form. If \n"
338 " 'check_existence' is true, this must be set to true.";
341 if(!
_is_setting(
"data",
"enumeration",
"insert_canonical")) {
345 val = _get_setting<bool>(
"data",
"enumeration",
"insert_canonical",
help);
350 throw std::runtime_error(
351 "Error in Monte Carlo enumeration in settings: "
352 "If 'check_existence' is true, then 'insert_canonical' must be true"
361 std::string
help =
"(integer, optional, default=100)\n"
362 " The number of configurations that are allowed in the \n"
363 " enumeration hall of fame.";
365 if(!
_is_setting(
"data",
"enumeration",
"N_halloffame")) {
368 return _get_setting<Index>(
"data",
"enumeration",
"N_halloffame",
help);
374 std::string
help =
"(number, optional, default=1e-8)\n"
375 " Tolerance used for floating point comparison of \n"
376 " configuration scores in the enumeration hall of fame.";
378 if(!
_is_setting(
"data",
"enumeration",
"tolerance")) {
381 return _get_setting<double>(
"data",
"enumeration",
"tolerance",
help);
388 return (*
this)[level1].contains(level2);
391 catch(std::runtime_error &e) {
394 err_log <<
"No [\"" << level1 <<
"\"] setting found.\n" << std::endl;
402 return (*
this)[level1][level2].contains(level3);
405 catch(std::runtime_error &e) {
409 err_log <<
"No [\"" << level1 <<
"\"][\"" << level2 <<
"\"] setting found" << std::endl;
412 err_log <<
"No [\"" << level1 <<
"\"] setting found" << std::endl;
427 return Monte::SAMPLE_MODE::PASS == _get_setting<Monte::SAMPLE_MODE>(
"data",
"sample_by", help<Monte::SAMPLE_MODE>());
432 return Monte::SAMPLE_MODE::STEP == _get_setting<Monte::SAMPLE_MODE>(
"data",
"sample_by", help<Monte::SAMPLE_MODE>());
438 std::string level1 =
"data";
439 std::string level2 =
"sample_period";
440 std::string
help =
"(int, default=1)\n"
441 " In conjunction with \"sample_by\", determines how often to make observations.";
446 return _get_setting<size_type>(level1, level2,
help);
451 return _is_setting(
"data",
"equilibration_passes_first_run");
456 std::string
help =
"int (optional)";
457 return _get_setting<size_type>(
"data",
"equilibration_passes_first_run",
help);
462 return _is_setting(
"data",
"equilibration_passes_each_run");
467 std::string
help =
"int (optional)";
468 return _get_setting<size_type>(
"data",
"equilibration_passes_each_run",
help);
479 std::string
help =
"int (optional)";
480 return _get_setting<size_type>(
"data",
"N_pass",
help);
485 std::string
help =
"int (optional)";
491 std::string
help =
"int (optional)";
492 return _get_setting<size_type>(
"data",
"N_step",
help);
502 std::string
help =
"int (optional)";
503 return _get_setting<size_type>(
"data",
"N_sample",
help);
514 std::string
help =
"int (optional)";
515 return _get_setting<size_type>(
"data",
"max_pass",
help);
525 std::string
help =
"int (optional)";
526 return _get_setting<size_type>(
"data",
"min_pass",
help);
537 std::string
help =
"int (optional)";
538 return _get_setting<size_type>(
"data",
"max_step",
help);
549 std::string
help =
"int (optional)";
550 return _get_setting<size_type>(
"data",
"min_step",
help);
561 std::string
help =
"int (optional)";
562 return _get_setting<size_type>(
"data",
"max_sample",
help);
572 std::string
help =
"int (optional)";
573 return _get_setting<size_type>(
"data",
"min_sample",
help);
615 err_log <<
"Could not determine max data length.\n";
616 err_log <<
"Please check 'sample_by', 'max_pass' or 'max_step', and 'sample_period' in your input file.\n" << std::endl;
617 throw std::runtime_error(std::string(
"Error determining max_data_length"));
bool is_N_step() const
Returns true if the number of steps has been specified.
bool is_max_step() const
Returns true if a maximum number of steps has been specified.
jsonParser()
Create a new empty jsonParser.
MonteSettings()
Default constructor.
size_type min_step() const
Minimum number of steps, default 0 if sample by step.
size_type max_step() const
Maximum number of steps, required if sample by step.
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 write_trajectory() const
Returns true if snapshots are requested.
bool sample_by_pass() const
Sample by pass?
fs::path m_output_directory
size_type N_step() const
Returns the number of steps requested.
bool is_enumeration() const
Returns true if enumeration is requested. (Default false)
bool write_observations() const
Writes all observations.
size_type max_data_length() const
Figure out how large data containers should be.
ENSEMBLE
Monte Carlo ensemble type.
Index enumeration_N_halloffame() const
Returns enumeration halloffame max size (default 100)
const fs::path output_directory() const
Directory where output should go.
size_type sample_period() const
Figure out how often to take samples.
bool is_equilibration_passes_each_run() const
Returns true if explicit equilibration passes for each run have been specified.
const PrimClex * m_primclex
bool dependent_runs() const
If dependent runs, start subsequent calculations with the final state of the previous calculation...
fs::path find_casmroot(const fs::path &cwd)
size_type equilibration_passes_each_run() const
Number of explicit equilibration passes requsted for each run.
bool is_max_pass() const
Returns true if a maximum number of passes has been specified.
size_type min_pass() const
Minimum number of passes, default 0 if sample by pass.
bool is_N_sample() const
Returns true if the number of samples has been specified.
size_type min_sample() const
Minimum number of steps, default 0.
bool is_min_step() const
Returns true if a minimum number of steps has been specified.
DRIVE_MODE
How to change conditions.
bool is_motif_configname() const
Returns true if configname of configuration to use as starting motif has been specified.
std::string motif_configname() const
Configname of configuration to use as starting motif.
static const int standard
size_type equilibration_passes_first_run() const
Number of explicit equilibration passes requsted for the first run.
bool is_N_pass() const
Returns true if the number of passes has been specified.
bool is_motif_configdof() const
Returns true if path to ConfigDoF file to use as starting motif has been specified.
bool is_min_pass() const
Returns true if a minimum number of passes has been specified.
json_spirit::mObject::size_type size_type
METHOD
Monte Carlo method type.
EigenIndex Index
For long integer indexing:
A container class for the different degrees of freedom a Configuration might have.
size_type N_sample() const
Returns the number of samples requested.
Monte::ENUM_SAMPLE_MODE enumeration_sample_mode() const
Enumeration sample mode (default Monte::ENUM_SAMPLE_MODE::ON_SAMPLE)
PrimClex is the top-level data structure for a CASM project.
void set_debug(bool _debug)
Set debug mode.
bool is_min_sample() const
Returns true if a minimum number of samples has been specified.
std::string enumeration_metric_args() const
Returns 'casm query'-like enumeration metric args.
bool enumeration_insert_canonical() const
Insert configurations in their canonical form.
bool enumeration_check_existence() const
Only insert configurations that are not already enumerated.
ENUM_SAMPLE_MODE
How often to sample runs.
bool _is_setting(std::string level1, std::string level2) const
Returns true if (*this)[level1].contains(level2)
iterator find(const std::string &name)
Return iterator to JSON object value with 'name'.
double enumeration_tol() const
Returns enumeration halloffame tolerance (default 1e-8)
bool is_equilibration_passes_first_run() const
Returns true if explicit equilibration passes for the first run have been specified.
virtual const Monte::DRIVE_MODE drive_mode() const
Given a settings jsonParser figure out the drive mode. Expects drive_mode/incremental,custom.
bool debug() const
Run in debug mode?
Monte::ENSEMBLE ensemble() const
Return type of Monte Carlo ensemble.
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
ConfigDoF motif_configdof() const
ConfigDoF to use as starting motif.
bool write_csv() const
Write csv versions of files? (csv is the default format if no 'output_format' given) ...
bool write_json() const
Write json versions of files?
size_type N_pass() const
Returns the number of passes requested.
Monte::METHOD method() const
Return type of Monte Carlo method.
bool write_POSCAR_snapshots() const
Returns true if POSCARs of snapshots are requsted. Requires write_trajectory.
void error(const std::string &what)
bool is_array() const
Check if array type.
size_type max_sample() const
Maximum number of steps, default std::numeric_limit::max()
std::string enumeration_check_args() const
Returns 'casm query'-like enumeration check args.
Eigen::Matrix3i simulation_cell_matrix() const
Supercell matrix defining the simulation cell.
double confidence() const
Given a settings jsonParser figure out the global tolerance (probably for == operator). Expects tolerance/value.
fs::path motif_configdof_path() const
Path to ConfigDoF file to use as starting motif.
size_type max_pass() const
Maximum number of passes, required if sample by pass.
bool is_max_sample() const
Returns true if a maximum number of samples has been specified.
bool sample_by_step() const
Sample by step?