3 #include <boost/filesystem.hpp>
26 const fs::path &read_path)
27 :
jsonParser(read_path), m_primclex(&_primclex) {
42 return _get_setting<Monte::ENSEMBLE>(
"ensemble", help<Monte::ENSEMBLE>());
47 return _get_setting<Monte::METHOD>(
"method", help<Monte::METHOD>());
52 auto it =
find(
"debug");
56 return it->get<
bool>();
67 return _is_setting(
"driver",
"motif",
"configname");
74 " The name of a configuration, of the form \"SCELV_A_B_C_D_E_F/N\"";
75 return _get_setting<std::string>(
"driver",
"motif",
"configname",
help);
88 " Path to file containing DoF, such as an \"final_state.json\" file.";
89 fs::path configdof_path =
90 _get_setting<fs::path>(
"driver",
"motif",
"configdof",
help);
97 std::string
help =
"";
98 return _get_setting<fs::path>(
"driver",
"motif",
"configdof",
help);
104 "3x3 transformation matrix, T, such that S = U*T,\n"
105 " where S, is the supercell lattice vectors,\n"
106 " and P, is the primitive cell lattice vectors.\n";
107 return _get_setting<Eigen::Matrix3l>(
"supercell",
help);
115 return _get_setting<Monte::DRIVE_MODE>(
"driver",
"mode",
116 help<Monte::DRIVE_MODE>());
126 "bool (default=true)\n"
127 " If true, begin the next calculation with the final DoF from the "
130 " If false, begin each calculation with the DoF specified for the "
132 return _get_setting<bool>(
"driver",
"dependent_runs",
help);
144 std::string
help =
"number, range (0.0, 1.0), default 0.95)";
146 return _get_setting<double>(
"data",
"confidence",
help);
154 std::string level1 =
"data";
155 std::string level2 =
"storage";
156 std::string level3 =
"write_trajectory";
157 std::string
help =
"bool (default=false)";
162 return _get_setting<bool>(level1, level2, level3,
help);
168 std::string level1 =
"data";
169 std::string level2 =
"storage";
170 std::string level3 =
"write_POSCAR_snapshots";
171 std::string
help =
"(bool, default=false)";
176 return _get_setting<bool>(level1, level2, level3,
help);
181 std::string level1 =
"data";
182 std::string level2 =
"storage";
183 std::string level3 =
"write_observations";
184 std::string
help =
"(bool, default=false)";
189 return _get_setting<bool>(level1, level2, level3,
help);
195 std::string level1 =
"data";
196 std::string level2 =
"storage";
197 std::string level3 =
"output_format";
199 "(string or JSON array of string, optional, default='csv')\n"
200 " Accepts: 'csv' or 'CSV' to write .csv files\n"
201 " 'json' or 'JSON' to write .json files\n"
202 " Use an array to write in multiple formats.\n";
210 if (
ref.is_array()) {
211 std::vector<std::string> formats =
212 _get_setting<std::vector<std::string> >(level1, level2, level3,
help);
213 for (
auto it = formats.begin(); it != formats.end(); ++it) {
214 if (*it ==
"csv" || *it ==
"CSV") {
220 std::string input = _get_setting<std::string>(level1, level2, level3,
help);
221 if (input ==
"csv" || input ==
"CSV") {
230 std::string level1 =
"data";
231 std::string level2 =
"storage";
232 std::string level3 =
"output_format";
234 "(string or JSON array of string, optional, default='csv')\n"
235 " Accepts: 'csv' or 'CSV' to write .csv files\n"
236 " 'json' or 'JSON' to write .json files\n"
237 " Use an array to write in multiple formats.\n";
245 if (
ref.is_array()) {
246 std::vector<std::string> formats =
247 _get_setting<std::vector<std::string> >(level1, level2, level3,
help);
248 for (
auto it = formats.begin(); it != formats.end(); ++it) {
249 if (*it ==
"json" || *it ==
"JSON") {
255 std::string input = _get_setting<std::string>(level1, level2, level3,
help);
256 if (input ==
"json" || input ==
"JSON") {
281 "(string, optional, default=\"clex_hull_dist(ALL)\")\n"
282 " A 'casm query'-like string that provides a metric for \n"
283 " ranking configurations as they are encountered during \n"
284 " a Monte Carlo calculation. The resulting value is used\n"
285 " to create a hall of fame of 'best' configurations \n"
286 " encountered during the calculation. When the \n"
287 " calculation is complete configurations in the hall of \n"
288 " fame are added to the CASM project config list. \n"
289 " The 'casm query'-like command should evaluate to a \n"
292 if (!
_is_setting(
"data",
"enumeration",
"metric")) {
293 return "clex_hull_dist(ALL)";
295 return _get_setting<std::string>(
"data",
"enumeration",
"metric",
help);
309 "(string, optional, default=\"eq(1,1)\")\n"
310 " A 'casm query'-like string that returns a boolean value \n"
311 " indicating if (true) a configuration should be considered\n"
312 " for the enumeration hall of fame.";
314 if (!
_is_setting(
"data",
"enumeration",
"check")) {
317 return _get_setting<std::string>(
"data",
"enumeration",
"check",
help);
322 if (!
_is_setting(
"data",
"enumeration",
"sample_mode")) {
325 return _get_setting<Monte::ENUM_SAMPLE_MODE>(
326 "data",
"enumeration",
"sample_mode", help<Monte::ENUM_SAMPLE_MODE>());
332 "(bool, optional, default=true)\n"
333 " If true, only configurations that do not already exist\n"
334 " in the config list are inserted into the enumeration \n"
337 if (!
_is_setting(
"data",
"enumeration",
"check_existence")) {
340 return _get_setting<bool>(
"data",
"enumeration",
"check_existence",
help);
346 "(bool, optional, default=true)\n"
347 " If true, configurations are inserted into the \n"
348 " enumeration hall of fame in their canonical form. If \n"
349 " 'check_existence' is true, this must be set to true.";
352 if (!
_is_setting(
"data",
"enumeration",
"insert_canonical")) {
355 val = _get_setting<bool>(
"data",
"enumeration",
"insert_canonical",
help);
360 throw std::runtime_error(
361 "Error in Monte Carlo enumeration in settings: "
362 "If 'check_existence' is true, then 'insert_canonical' must be true");
370 "(integer, optional, default=100)\n"
371 " The number of configurations that are allowed in the \n"
372 " enumeration hall of fame.";
374 if (!
_is_setting(
"data",
"enumeration",
"N_halloffame")) {
377 return _get_setting<Index>(
"data",
"enumeration",
"N_halloffame",
help);
383 "(number, optional, default=1e-8)\n"
384 " Tolerance used for floating point comparison of \n"
385 " configuration scores in the enumeration hall of fame.";
387 if (!
_is_setting(
"data",
"enumeration",
"tolerance")) {
390 return _get_setting<double>(
"data",
"enumeration",
"tolerance",
help);
396 return (*
this)[level1].contains(level2);
399 catch (std::runtime_error &e) {
402 err_log <<
"No [\"" << level1 <<
"\"] setting found.\n" << std::endl;
409 std::string level3)
const {
411 return (*
this)[level1][level2].contains(level3);
414 catch (std::runtime_error &e) {
418 err_log <<
"No [\"" << level1 <<
"\"][\"" << level2 <<
"\"] setting found"
421 err_log <<
"No [\"" << level1 <<
"\"] setting found" << std::endl;
435 _get_setting<Monte::SAMPLE_MODE>(
"data",
"sample_by",
436 help<Monte::SAMPLE_MODE>());
442 _get_setting<Monte::SAMPLE_MODE>(
"data",
"sample_by",
443 help<Monte::SAMPLE_MODE>());
449 std::string level1 =
"data";
450 std::string level2 =
"sample_period";
453 " In conjunction with \"sample_by\", determines how often to make "
459 return _get_setting<size_type>(level1, level2,
help);
465 return _is_setting(
"data",
"equilibration_passes_first_run");
471 std::string
help =
"int (optional)";
472 return _get_setting<size_type>(
"data",
"equilibration_passes_first_run",
479 return _is_setting(
"data",
"equilibration_passes_each_run");
485 std::string
help =
"int (optional)";
486 return _get_setting<size_type>(
"data",
"equilibration_passes_each_run",
help);
496 std::string
help =
"int (optional)";
497 return _get_setting<size_type>(
"data",
"N_pass",
help);
502 std::string
help =
"int (optional)";
508 std::string
help =
"int (optional)";
509 return _get_setting<size_type>(
"data",
"N_step",
help);
519 std::string
help =
"int (optional)";
520 return _get_setting<size_type>(
"data",
"N_sample",
help);
530 std::string
help =
"int (optional)";
531 return _get_setting<size_type>(
"data",
"max_pass",
help);
541 std::string
help =
"int (optional)";
542 return _get_setting<size_type>(
"data",
"min_pass",
help);
552 std::string
help =
"int (optional)";
553 return _get_setting<size_type>(
"data",
"max_step",
help);
563 std::string
help =
"int (optional)";
564 return _get_setting<size_type>(
"data",
"min_step",
help);
575 std::string
help =
"int (optional)";
576 return _get_setting<size_type>(
"data",
"max_sample",
help);
587 std::string
help =
"int (optional)";
588 return _get_setting<size_type>(
"data",
"min_sample",
help);
621 err_log <<
"Could not determine max data length.\n";
622 err_log <<
"Please check 'sample_by', 'max_pass' or 'max_step', and "
623 "'sample_period' in your input file.\n"
625 throw std::runtime_error(std::string(
"Error determining max_data_length"));
void error(const std::string &what)
static const int standard
size_type min_step() const
Minimum number of steps, default 0 if sample by step.
bool is_max_step() const
Returns true if a maximum number of steps has been specified.
size_type max_data_length() const
Figure out how large data containers should be.
bool sample_by_pass() const
Sample by pass?
bool is_min_step() const
Returns true if a minimum number of steps has been specified.
bool is_N_pass() const
Returns true if the number of passes has been specified.
bool is_max_pass() const
Returns true if a maximum number of passes has been specified.
size_type max_sample() const
Maximum number of steps, default std::numeric_limit<size_type>::max()
size_type sample_period() const
Figure out how often to take samples.
size_type max_step() const
Maximum number of steps, required if sample by step.
bool is_min_pass() const
Returns true if a minimum number of passes has been specified.
bool sample_by_step() const
Sample by step?
size_type N_sample() const
Returns the number of samples requested.
bool is_equilibration_passes_each_run() const
Returns true if explicit equilibration passes for each run have been specified.
size_type min_sample() const
Minimum number of steps, default 0.
size_type max_pass() const
Maximum number of passes, required if sample by pass.
bool is_N_sample() const
Returns true if the number of samples has been specified.
size_type equilibration_passes_each_run() const
Number of explicit equilibration passes requsted for each run.
bool is_equilibration_passes_first_run() const
Returns true if explicit equilibration passes for the first run have been specified.
size_type N_pass() const
Returns the number of passes requested.
bool is_max_sample() const
Returns true if a maximum number of samples has been specified.
size_type min_pass() const
Minimum number of passes, default 0 if sample by pass.
bool is_min_sample() const
Returns true if a minimum number of samples has been specified.
size_type N_step() const
Returns the number of steps requested.
bool is_N_step() const
Returns true if the number of steps has been specified.
size_type equilibration_passes_first_run() const
Number of explicit equilibration passes requsted for the first run.
bool dependent_runs() const
If dependent runs, start subsequent calculations with the final state of the previous calculation....
const PrimClex & primclex() const
Monte::METHOD method() const
Return type of Monte Carlo method.
std::string enumeration_metric_args() const
Returns 'casm query'-like enumeration metric args.
double enumeration_tol() const
Returns enumeration halloffame tolerance (default 1e-8)
bool debug() const
Run in debug mode?
double confidence() const
Given a settings jsonParser figure out the global tolerance (probably for == operator)....
const fs::path output_directory() const
Directory where output should go.
bool write_trajectory() const
Returns true if snapshots are requested.
bool enumeration_check_existence() const
Only insert configurations that are not already enumerated.
bool is_motif_configdof() const
Returns true if path to ConfigDoF file to use as starting motif has been specified.
std::string motif_configname() const
Configname of configuration to use as starting motif.
fs::path m_output_directory
virtual const Monte::DRIVE_MODE drive_mode() const
Given a settings jsonParser figure out the drive mode. Expects drive_mode/incremental,...
std::string enumeration_check_args() const
Returns 'casm query'-like enumeration check args.
const PrimClex * m_primclex
bool write_observations() const
Writes all observations.
Eigen::Matrix3l simulation_cell_matrix() const
Supercell matrix defining the simulation cell.
Index enumeration_N_halloffame() const
Returns enumeration halloffame max size (default 100)
bool is_motif_configname() const
Returns true if configname of configuration to use as starting motif has been specified.
bool enumeration_insert_canonical() const
Insert configurations in their canonical form.
bool write_csv() const
Write csv versions of files? (csv is the default format if no 'output_format' given)
ConfigDoF motif_configdof(Index supercell_volume) const
ConfigDoF to use as starting motif.
Monte::ENUM_SAMPLE_MODE enumeration_sample_mode() const
Enumeration sample mode (default Monte::ENUM_SAMPLE_MODE::ON_SAMPLE)
fs::path motif_configdof_path() const
Path to ConfigDoF file to use as starting motif.
bool write_POSCAR_snapshots() const
Returns true if POSCARs of snapshots are requsted. Requires write_trajectory.
void set_debug(bool _debug)
Set debug mode.
MonteSettings()
Default constructor.
bool write_json() const
Write json versions of files?
bool is_enumeration() const
Returns true if enumeration is requested. (Default false)
bool _is_setting(std::string level1, std::string level2) const
Returns true if (*this)[level1].contains(level2)
Monte::ENSEMBLE ensemble() const
Return type of Monte Carlo ensemble.
PrimClex is the top-level data structure for a CASM project.
jsonParser()
Create a new empty jsonParser.
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
iterator end()
Returns iterator to end of JSON object or JSON array.
json_spirit::mObject::size_type size_type
iterator find(const std::string &name)
Return iterator to JSON object value with 'name'.
const PrimType & prim() const
const Access to primitive Structure
METHOD
Monte Carlo method type.
DRIVE_MODE
How to change conditions.
ENSEMBLE
Monte Carlo ensemble type.
ENUM_SAMPLE_MODE
How often to sample runs.
fs::path find_casmroot(const fs::path &cwd)
std::string help()
Uses 'multiline_help<T>()' by default.
INDEX_TYPE Index
For long integer indexing:
Matrix< long int, 3, 3 > Matrix3l