1 #ifndef CASM_MonteSettings_HH
2 #define CASM_MonteSettings_HH
16 template<
typename ObjectType,
typename Metric,
typename ObjectCompare>
19 class MonteCarloEnumMetric;
20 class MonteCarloEnumCheck;
54 using jsonParser::operator==;
55 using jsonParser::operator!=;
176 bool _is_setting(std::string level1, std::string level2)
const;
179 bool _is_setting(std::string level1, std::string level2, std::string level3)
const;
183 T
_get_setting(std::string level1, std::string msg)
const;
187 T
_get_setting(std::string level1, std::string level2, std::string msg)
const;
191 T
_get_setting(std::string level1, std::string level2, std::string level3, std::string msg)
const;
206 return settings == json;
210 return settings != json;
326 return (*
this)[level1].get<T>();
329 catch(std::runtime_error &e) {
331 std::stringstream ss;
332 ss <<
"Monte Carlo setting " <<
"[\"" << level1 <<
"\"]";
336 err_log <<
"Expected " << ss.str() << std::endl;
337 err_log <<
" Either this was not found, or the type is wrong." << std::endl;
339 err_log <<
"[\"" << level1 <<
"\"]: ";
340 err_log << msg << std::endl;
350 return (*
this)[level1][level2].get<T>();
353 catch(std::runtime_error &e) {
355 std::stringstream ss;
356 ss <<
"Monte Carlo setting [\"" << level1 <<
"\"][\"" << level2 <<
"\"]";
360 err_log <<
"ERROR in MonteSettings::" << level2 << std::endl;
361 err_log <<
"Expected " << ss.str() << std::endl;
362 err_log <<
" Either this was not found, or the type is wrong." << std::endl;
364 err_log <<
"Found Settings[\"" << level1 <<
"\"], but not [\"" << level1 <<
"\"][\"" << level2 <<
"\"]" << std::endl;
365 err_log <<
"Settings[\"" << level1 <<
"\"]:\n" << (*this)[level1] << std::endl;
368 err_log <<
"No Settings[\"" << level1 <<
"\"] found" << std::endl;
369 err_log <<
"Settings:\n" <<
static_cast<const jsonParser &
>(*this) << std::endl;
372 err_log <<
"[\"" << level1 <<
"\"][\"" << level2 <<
"\"]: ";
373 err_log << msg << std::endl;
383 return (*
this)[level1][level2][level3].get<T>();
386 catch(std::runtime_error &e) {
388 std::stringstream ss;
389 ss <<
"Monte Carlo setting [\"" << level1 <<
"\"][\"" << level2 <<
"\"][\"" << level3 <<
"\"]";
393 err_log <<
"Expected " << ss.str() << std::endl;
394 err_log <<
" Either this was not found, or the type is wrong." << std::endl;
397 err_log <<
"Found Settings[\"" << level1 <<
"\"][\"" << level2 <<
"\"], \n"
398 "but not [\"" << level1 <<
"\"][\"" << level2 <<
"\"][\"" << level3 <<
"\"]" << std::endl;
399 err_log <<
"Settings[\"" << level1 <<
"\"][\"" << level2 <<
"\"]:\n" << (*this)[level1][level2] << std::endl;
402 err_log <<
"No Settings[\"" << level1 <<
"\"][\"" << level2 <<
"\"] found" << std::endl;
403 err_log <<
"Settings:\n" << (*this)[level1] << std::endl;
407 err_log <<
"No Settings[\"" << level1 <<
"\"] found" << std::endl;
408 err_log <<
"Settings:\n" <<
static_cast<const jsonParser &
>(*this) << std::endl;
411 err_log <<
"[\"" << level1 <<
"\"][\"" << level2 <<
"\"][\"" << level3 <<
"\"]: ";
412 err_log << msg << std::endl;
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.
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.
const PrimClex & primclex() const
bool write_trajectory() const
Returns true if snapshots are requested.
bool sample_by_pass() const
Sample by pass?
void write(const std::string &file_name, unsigned int indent=2, unsigned int prec=12) const
Write json to file.
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
EquilibriumMonteSettings()
Default constructor.
bool dependent_runs() const
If dependent runs, start subsequent calculations with the final state of the previous calculation...
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.
bool operator!=(const UnitCellCoord &A, const UnitCellCoord &B)
Compare UnitCellCoord.
size_type min_pass() const
Minimum number of passes, default 0 if sample by pass.
void print(std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
Print json to stream.
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 operator==(const UnitCellCoord &A, const UnitCellCoord &B)
Compare UnitCellCoord.
bool is_min_pass() const
Returns true if a minimum number of passes has been specified.
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)
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) ...
T _get_setting(std::string level1, std::string msg) const
Returns (*this)[level1].get();.
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.
EquilibriumMonteSettings(const PrimClex &_primclex, const fs::path &read_path)
Construct EquilibriumMonteSettings by reading a settings JSON file.
void error(const std::string &what)
Settings for Monte Carlo calculations.
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?