faunus
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
Faunus::MetropolisMonteCarlo Class Reference

Class to handle Monte Carlo moves. More...

#include <montecarlo.h>

Classes

struct  State
 Class to describe a system state. More...
 

Public Member Functions

 MetropolisMonteCarlo (const json &j)
 
Energy::HamiltoniangetHamiltonian ()
 Get Hamiltonian of accepted (default) state.
 
SpacegetSpace ()
 Access to space in accepted (default) state.
 
SpacegetTrialSpace ()
 Access to trial space.
 
double relativeEnergyDrift ()
 Relative energy drift from initial configuration. More...
 
void sweep ()
 Perform all moves (stochastic and static) More...
 
void restore (const json &j)
 Restores system from previously store json object. More...
 
 ~MetropolisMonteCarlo ()
 Required due to unique_ptr to incomplete type.
 

Static Public Member Functions

static bool metropolisCriterion (double energy_change)
 Metropolis criterion. More...
 

Friends

void to_json (json &, const MetropolisMonteCarlo &)
 Write information to JSON object.
 

Detailed Description

Class to handle Monte Carlo moves.

This class maintains a list of MC moves and takes care of randomly selecting a move; perform the move; decides if the move is accepted; and checks if there is a drift in the potential energy.

The moves always operate on a trial state (new_state). If accepted, the changes will be copied into the old_state. The state here refers to the particle states (positions etc.), the simulation geometry (size, volume), and the state of the Hamiltonian (wave-vectors for Ewald etc.).

Todo:
The class has too many responsibilities, particularly in setting up the system.

Member Function Documentation

◆ metropolisCriterion()

bool Faunus::MetropolisMonteCarlo::metropolisCriterion ( double  energy_change)
static

Metropolis criterion.

Parameters
energy_changeEnergy change, (new minus old) in units of kT
Returns
True if accepted, false of rejected
Note
Regardless of outcome the random number generator should be incremented. This is important when using some MPI schemes where the simulations must be in sync.

◆ relativeEnergyDrift()

double Faunus::MetropolisMonteCarlo::relativeEnergyDrift ( )

Relative energy drift from initial configuration.

This is a powerful test that compares the final energy with the initial energy plus the accumulated list of changes.

Ideally this difference should be very small. If a MC move improperly captures the resulting energy change, a large drift will usually appear. This test has a minimal computational overhead as only the initial and final energies need to be calculated; the accumulated change is sampled during simulation for free.

Returns
Relative energy drift

◆ restore()

void Faunus::MetropolisMonteCarlo::restore ( const json j)

Restores system from previously store json object.

Todo:
Too many responsibilities; tidy up!

◆ sweep()

void Faunus::MetropolisMonteCarlo::sweep ( )

Perform all moves (stochastic and static)

This "sweeps" over all registered MC moves respecting, with the probability of picking a move given by Movebase::weight.

First stochastic moves are randomly picked and, if needed, repeated (randomly). Next, static moves are performed. Currently static moves are defined by setting weight=0.

Todo:
using weight to mark as move as static is ugly

The documentation for this class was generated from the following files: