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.


Construct a MonteCarlo object with RandomMT19937.

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

Set the random number generator.

void seed_random(const int seed)

Return the random number generator.

Seed random number generator.

void add(const 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)

The second action is to add Potentials.

void add(const Potential &potential)

Warning for depreciated 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)

Add potential to reference.

void add(std::shared_ptr<NeighborCriteria> neighbor_criteria)

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()

Reinitialize the system. Return total energy.

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. 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.

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.

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.

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.

void attempt(const int num_trials = 1)

Attempt one trial, with subsequent analysers and modifiers.

Attempt a number of Monte Carlo trials.

virtual void reset_trial_stats()

Reset trial statistics.

void run_until_complete()

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

bool attempt_trial(const int index)

Attempt trial index without analyzers, modifiers or checkpoints.