1 #ifndef CASM_MonteSettings_HH
2 #define CASM_MonteSettings_HH
19 class MonteCarloEnumMetric;
20 class MonteCarloEnumCheck;
52 using jsonParser::operator==;
53 using jsonParser::operator!=;
65 fs::path
root()
const;
174 bool _is_setting(std::string level1, std::string level2)
const;
177 bool _is_setting(std::string level1, std::string level2,
178 std::string level3)
const;
181 template <
typename T>
182 T
_get_setting(std::string level1, std::string msg)
const;
185 template <
typename T>
186 T
_get_setting(std::string level1, std::string level2, std::string msg)
const;
189 template <
typename T>
190 T
_get_setting(std::string level1, std::string level2, std::string level3,
191 std::string msg)
const;
202 return settings == json;
206 return settings != json;
305 template <
typename T>
308 return (*
this)[level1].get<T>();
311 catch (std::runtime_error &e) {
313 std::stringstream ss;
314 ss <<
"Monte Carlo setting "
315 <<
"[\"" << level1 <<
"\"]";
319 err_log <<
"Expected " << ss.str() << std::endl;
320 err_log <<
" Either this was not found, or the type is wrong."
323 err_log <<
"[\"" << level1 <<
"\"]: ";
331 template <
typename T>
333 std::string msg)
const {
335 return (*
this)[level1][level2].get<T>();
338 catch (std::runtime_error &e) {
340 std::stringstream ss;
341 ss <<
"Monte Carlo setting [\"" << level1 <<
"\"][\"" << level2 <<
"\"]";
345 err_log <<
"ERROR in MonteSettings::" << level2 << std::endl;
346 err_log <<
"Expected " << ss.str() << std::endl;
347 err_log <<
" Either this was not found, or the type is wrong."
350 err_log <<
"Found Settings[\"" << level1 <<
"\"], but not [\"" << level1
351 <<
"\"][\"" << level2 <<
"\"]" << std::endl;
352 err_log <<
"Settings[\"" << level1 <<
"\"]:\n"
353 << (*this)[level1] << std::endl;
355 err_log <<
"No Settings[\"" << level1 <<
"\"] found" << std::endl;
357 <<
static_cast<const jsonParser &
>(*this) << std::endl;
360 err_log <<
"[\"" << level1 <<
"\"][\"" << level2 <<
"\"]: ";
368 template <
typename T>
370 std::string level3, std::string msg)
const {
372 return (*
this)[level1][level2][level3].get<T>();
375 catch (std::runtime_error &e) {
377 std::stringstream ss;
378 ss <<
"Monte Carlo setting [\"" << level1 <<
"\"][\"" << level2 <<
"\"][\""
383 err_log <<
"Expected " << ss.str() << std::endl;
384 err_log <<
" Either this was not found, or the type is wrong."
388 err_log <<
"Found Settings[\"" << level1 <<
"\"][\"" << level2
391 << level1 <<
"\"][\"" << level2 <<
"\"][\"" << level3 <<
"\"]"
393 err_log <<
"Settings[\"" << level1 <<
"\"][\"" << level2 <<
"\"]:\n"
394 << (*this)[level1][level2] << std::endl;
396 err_log <<
"No Settings[\"" << level1 <<
"\"][\"" << level2
397 <<
"\"] found" << std::endl;
398 err_log <<
"Settings:\n" << (*this)[level1] << std::endl;
401 err_log <<
"No Settings[\"" << level1 <<
"\"] found" << std::endl;
403 <<
static_cast<const jsonParser &
>(*this) << std::endl;
406 err_log <<
"[\"" << level1 <<
"\"][\"" << level2 <<
"\"][\"" << level3
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.
EquilibriumMonteSettings()
Default constructor.
bool is_N_pass() const
Returns true if the number of passes has been specified.
EquilibriumMonteSettings(const PrimClex &_primclex, const fs::path &read_path)
Construct EquilibriumMonteSettings by reading a settings JSON file.
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.
Settings for Monte Carlo calculations.
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.
T _get_setting(std::string level1, std::string msg) const
Returns (*this)[level1].get<T>();.
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.
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
void write(const std::string &file_name, unsigned int indent=2, unsigned int prec=12) const
Write json to file.
void print(std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
Print json to stream.
METHOD
Monte Carlo method type.
bool operator==(const jsonParser &json, const MonteSettings &settings)
DRIVE_MODE
How to change conditions.
bool operator!=(const jsonParser &json, const MonteSettings &settings)
ENSEMBLE
Monte Carlo ensemble type.
ENUM_SAMPLE_MODE
How often to sample runs.
INDEX_TYPE Index
For long integer indexing:
Matrix< long int, 3, 3 > Matrix3l