MonteCarlo

class MonteCarlo

MonteCarlo contains Trials which perturb the System by generating the probability of acceptance through Criteria that are accepted based on a Random number generator. Between trials, MonteCarlo also contains classes that Analyze or Modify.

Subclassed by feasst::Prefetch

Public Functions

MonteCarlo(std::shared_ptr<Random> random)

Construct with Random number generator.

MonteCarlo()

Construct with RandomMT19937.

void begin(arglist args, const bool silent = false)

Begin processing the arguments.

void parse_args(arglist *args, const bool silent = false)

Process arguments.

void add_args(arglist args)

Add more arguments.

void resume(const bool silent = false)

Resume processing the above arguments after Checkpointing.

void clear_arguments()

Clear arguments;.

void set(std::shared_ptr<Random> random)

Set the random number generator.

const Random &random() const

Return the random number generator.

void seed_random(const int seed)

Seed random number generator.

void add(std::shared_ptr<Configuration> config)

The first action with a Monte Carlo object is to set the Configuration.

const Configuration &configuration(const int index = 0) const

The configuration may be accessed read-only.

void add(std::shared_ptr<Potential> potential, const int config = 0)

The second action is to add Potentials.

void add(const Potential &potential)

Warning for deprecated use.

void set(const int index, std::shared_ptr<Potential> potential)

Set an existing potential.

void add_to_optimized(std::shared_ptr<Potential> potential)

Add potential to optimized.

void add_to_reference(std::shared_ptr<Potential> potential, const int index = 0, const int config = 0)

Add potential to reference.

param index:

Store different references by index.

void add(std::shared_ptr<NeighborCriteria> neighbor_criteria, const int config = 0)

Add NeighborCriteria.

void set(std::shared_ptr<ThermoParams> thermo_params)

The third action is to set the ThermoParams.

const ThermoParams &thermo_params() const

Return the ThermoParams.

void set(const System &system)

Alternatively, the first, second and third actions may be combined by setting the system directly. This must be done before setting Criteria.

const System &system() const

Once the System is set, it may be accessed on a read-only basis.

double initialize_system(const int config)

Reinitialize the system. Return total energy.

const TrialFactory &trial_factory() const

Return the trials.

const AnalyzeFactory &analyze_factory() const

Return the analyzers.

const ModifyFactory &modify_factory() const

Return the modifiers.

void set(std::shared_ptr<Criteria> criteria)

The fourth action is to set the Criteria. Configuration and Potentials (or System) must be set first.

const Criteria &criteria() const

Once Criteria is set, it may be accessed on a read-only basis.

void initialize_criteria()

Initialize the criteria. Also initializes system.

void add(std::shared_ptr<Trial> trial)

The remaining actions can be done in almost any order. Typically, one begins by adding trials.

void add(std::shared_ptr<TrialFactoryNamed> trials)

Some Trials are simply TrialFactories containing multiple trials, such as TrialTransfer (factory of TrialAdd and TrialRemove). If a TrialFactory is added, flatten by adding individual trials instead. This means that add(MakeTrialTransfer()) will add both a TrialAdd and TrialRemove with weights equal to TrialFactory weight divided according to the weights of the individual trials. Thus, adding TrialTransfer with a weight of 4 will result in TrialAdd with weight of 2 and TrialRemove with weight of 2.

void remove_trial(const int index)

Remove a trial by index.

const TrialFactory &trials() const

Access the trials on a read-only basis.

const Trial &trial(const int index) const

Access the trials on a read-only basis.

void initialize_trials()

Initialize trials.

void add(std::shared_ptr<Analyze> analyze)

An Analyzer performs some task after a given number of steps, but is read-only on System, Criteria and Trials. At this stage, multistate non-factory classes are converted into factories for each state in criteria.

void remove_analyze(const int index)

Remove an analyze by index.

const std::vector<std::shared_ptr<Analyze>> &analyzers() const

Return all analyzers.

const Analyze &analyze(const int index) const

Return an Analyze by index.

int num_analyzers() const

Return the number of analyzers.

void initialize_analyzers()

Initialize analyzers.

void add(const std::shared_ptr<Modify> modify)

A Modifier performs some task after a given number of steps, but may change the System, Criteria and Trials.

void remove_modify(const int index)

Remove a modify by index.

const std::vector<std::shared_ptr<Modify>> &modifiers() const

Return all modifiers.

const Modify &modify(const int index) const

Return an Modify by index.

int num_modifiers() const

Return the number of modifiers.

void set(const std::shared_ptr<Checkpoint> checkpoint)

Add a checkpoint.

void write_checkpoint() const

Write checkpoint file.

virtual void run(std::shared_ptr<Action> action)

Attempt one trial, with subsequent analysers and modifiers.

Perform an Action

void attempt(const int num_trials = 1)

Attempt a number of Monte Carlo trials.

virtual void reset_trial_stats()

Reset trial statistics.

virtual void run_num_trials(int num_trials)

Run a number of trials.

virtual void run_until_num_particles(const int num_particles, const int particle_type, const int configuration_index)

Run until a number of particles is reached.

virtual void run_for_hours(const double hours)

Run trials for a number of hours.

void run_until_complete()

Attempt Monte Carlo trials until Criteria returns completion. If available, automatically write checkpoint when complete.

virtual void run_until_file_exists(const std::string &file_name)

Attempt Monte Carlo trials until the given file name exists.

void set_num_iterations_to_complete(const int num)

Set the Criteria::number_iterations_to_complete.

bool attempt_trial(const int index)

Attempt trial index without analyzers, modifiers or checkpoints.

void write_to_file()

Write all Analyze and Modify.

const std::pair<std::string, argtype> &next_arg() const

Return the last argument parsed.

void set_parse_for_num_configs(const int num)

Set the number of configurations to parse simultaneously.

void set_parse_replace(const std::vector<std::vector<std::string>> &replace = {})

Set the parse replacements.

void set_timer()

Set the timer.

const TimerRDTSC *const timer() const

Return timer.