CASM
AClustersApproachtoStatisticalMechanics
|
#include <MonteCarlo.hh>
Interface base class for all types of Monte Carlo simulations (not meant to be used polymorphically)
MonteCarlo serves as a base for all types of Monte Carlo simulations (e.g. GrandCanonical). The base class holds all the data structures to be sampled for every type of derived Monte Carlo class. The derived class is responsible for adding data and using it to perform a calculation.
Definition at line 32 of file MonteCarlo.hh.
Public Types | |
typedef MonteSampler::size_type | size_type |
typedef std::map< std::string, double > | ScalarPropertyMap |
a map of keyname to property value More... | |
typedef std::map< std::string, Eigen::VectorXd > | VectorPropertyMap |
a map of keyname to property value Eigen::VectorXd More... | |
typedef std::map< std::string, notstd::cloneable_ptr < MonteSampler > , SamplerNameCompare > | SamplerMap |
a map of keyname to MonteSampler More... | |
typedef std::vector< std::pair < MonteCounter::size_type, MonteCounter::size_type > > | SampleTimes |
a vector of std::pair(pass, step) indicating when samples were taken More... | |
Public Member Functions | |
const MonteSettings & | settings () const |
const Access settings used for construction More... | |
const PrimClex & | primclex () const |
const Access the PrimClex that *this is based on More... | |
const Supercell & | supercell () const |
const Access the Supercell that *this is based on More... | |
void | set_nlist () |
Set a pointer to the SuperNeighborList once it is ready. More... | |
const SuperNeighborList & | nlist () const |
const Access the SuperNeighborList via pointer stored by 'set_nlist' More... | |
const Configuration & | config () const |
const Access current microstate More... | |
const ConfigDoF & | configdof () const |
const Access current microstate More... | |
void | reset (const ConfigDoF &dof) |
Set current microstate and clear samplers. More... | |
const ScalarPropertyMap & | scalar_properties () const |
const Access scalar properties map More... | |
const double & | scalar_property (std::string property_name) const |
const Access a particular scalar property More... | |
const VectorPropertyMap & | vector_properties () const |
const Access vector properties map More... | |
const Eigen::VectorXd & | vector_property (std::string property_name) const |
const Access a particular vector property More... | |
void | sample_data (const MonteCounter &counter) |
Samples all requested property data, and stores pass and step number sample was taken at. More... | |
void | clear_samples () |
Clear all data from all samplers. More... | |
bool | must_converge () const |
Return true if convergence is requested. More... | |
std::pair< bool, MonteSampler::size_type > | is_equilibrated () const |
Returns pair(true, equil_samples) if required equilibration has occured for all samplers that must converge. More... | |
bool | check_convergence_time () const |
Returns true if a convergence check is due. More... | |
bool | is_converged () const |
Check to see if all the properties required to converge have converged. More... | |
const SamplerMap & | samplers () const |
const Access sampler map More... | |
const SampleTimes & | sample_times () const |
const Access a vector of std::pair<pass, step> indicating when samples were taken More... | |
const std::vector< ConfigDoF > & | trajectory () const |
const Access snapshots of the Monte Carlo calculation More... | |
bool | debug () const |
return true if running in debug mode More... | |
Protected Member Functions | |
template<typename MonteTypeSettings > | |
MonteCarlo (PrimClex &primclex, const MonteTypeSettings &settings, Log &_log) | |
Construct with a starting ConfigDoF as specified the given MonteSettings and prepare data samplers. More... | |
PrimClex & | _primclex () const |
Access the PrimClex that *this is based on. More... | |
Supercell & | _supercell () const |
Access the Supercell that *this is based on. More... | |
Configuration & | _config () const |
Access current microstate. More... | |
ConfigDoF & | _configdof () const |
Access current microstate. More... | |
Log & | _log () const |
MTRand & | _mtrand () |
ScalarPropertyMap & | _scalar_properties () |
Access scalar properties map. More... | |
double & | _scalar_property (std::string property_name) |
Access a particular scalar property. More... | |
VectorPropertyMap & | _vector_properties () |
const Access vector properties map More... | |
Eigen::VectorXd & | _vector_property (std::string property_name) |
const Access a particular vector property More... | |
Private Member Functions | |
void | _set_check_convergence_time () const |
Set the next time convergence is due to be checked. More... | |
Private Attributes | |
ScalarPropertyMap | m_scalar_property |
a map of keyname to property value More... | |
VectorPropertyMap | m_vector_property |
a map of keyname to property value Eigen::VectorXd More... | |
const MonteSettings & | m_settings |
Contains all input settings. More... | |
PrimClex & | m_primclex |
PrimClex for this system. More... | |
Supercell | m_scel |
Supercell for the calculation. More... | |
const SuperNeighborList * | m_nlist |
Pointer to SuperNeighborList. More... | |
Configuration | m_config |
Stores all degrees of freedom of the current microstate. More... | |
ConfigDoF & | m_configdof |
Reference to m_config.configdof(), to avoid invalidating id every time used. More... | |
MTRand | m_twister |
Random number generator. More... | |
bool | m_write_trajectory = false |
Save trajectory? More... | |
std::vector< ConfigDoF > | m_trajectory |
Snapshots of the Monte Carlo simulation, taken by sample_data() if m_write_trajectory is true. More... | |
bool | m_must_converge |
True if any Sampler must converge. More... | |
Log & | m_log |
Target for messages. More... | |
SamplerMap | m_sampler |
a map of pair<keyname, index> to MonteSampler More... | |
SampleTimes | m_sample_time |
a vector of std::pair(pass, step) indicating when samples were taken More... | |
std::pair< bool, MonteSampler::size_type > | m_is_equil |
bool | m_is_equil_uptodate = false |
bool | m_is_converged |
bool | m_is_converged_uptodate = false |
MonteSampler::size_type | m_next_convergence_check = 100 |
MonteSampler::size_type | m_convergence_check_period = 100 |
bool | m_debug |
typedef std::map<std::string, notstd::cloneable_ptr<MonteSampler>, SamplerNameCompare> CASM::MonteCarlo::SamplerMap |
a map of keyname to MonteSampler
Definition at line 54 of file MonteCarlo.hh.
typedef std::vector<std::pair<MonteCounter::size_type, MonteCounter::size_type> > CASM::MonteCarlo::SampleTimes |
a vector of std::pair(pass, step) indicating when samples were taken
Definition at line 57 of file MonteCarlo.hh.
typedef std::map<std::string, double> CASM::MonteCarlo::ScalarPropertyMap |
a map of keyname to property value
Definition at line 42 of file MonteCarlo.hh.
Definition at line 37 of file MonteCarlo.hh.
typedef std::map<std::string, Eigen::VectorXd> CASM::MonteCarlo::VectorPropertyMap |
a map of keyname to property value Eigen::VectorXd
Definition at line 47 of file MonteCarlo.hh.
|
protected |
Construct with a starting ConfigDoF as specified the given MonteSettings and prepare data samplers.
Definition at line 318 of file MonteCarlo.hh.
|
inlineprotected |
Access current microstate.
Definition at line 196 of file MonteCarlo.hh.
|
inlineprotected |
Access current microstate.
Definition at line 204 of file MonteCarlo.hh.
|
inlineprotected |
Definition at line 208 of file MonteCarlo.hh.
|
inlineprotected |
Definition at line 212 of file MonteCarlo.hh.
|
inlineprotected |
Access the PrimClex that *this is based on.
Definition at line 183 of file MonteCarlo.hh.
|
inlineprotected |
Access scalar properties map.
Definition at line 217 of file MonteCarlo.hh.
|
inlineprotected |
Access a particular scalar property.
Definition at line 222 of file MonteCarlo.hh.
|
private |
Set the next time convergence is due to be checked.
Currently set to 10 samples from the time this function is called
Definition at line 199 of file MonteCarlo.cc.
|
inlineprotected |
Access the Supercell that *this is based on.
Definition at line 188 of file MonteCarlo.hh.
|
inlineprotected |
const Access vector properties map
Definition at line 227 of file MonteCarlo.hh.
|
inlineprotected |
const Access a particular vector property
Definition at line 232 of file MonteCarlo.hh.
bool CASM::MonteCarlo::check_convergence_time | ( | ) | const |
Returns true if a convergence check is due.
Currently set to every 10 samples
Definition at line 188 of file MonteCarlo.cc.
void CASM::MonteCarlo::clear_samples | ( | ) |
Clear all data from all samplers.
Definition at line 46 of file MonteCarlo.cc.
|
inline |
const Access current microstate
Definition at line 88 of file MonteCarlo.hh.
|
inline |
const Access current microstate
Definition at line 93 of file MonteCarlo.hh.
|
inline |
return true if running in debug mode
Definition at line 171 of file MonteCarlo.hh.
bool CASM::MonteCarlo::is_converged | ( | ) | const |
Check to see if all the properties required to converge have converged.
Definition at line 122 of file MonteCarlo.cc.
std::pair< bool, MonteSampler::size_type > CASM::MonteCarlo::is_equilibrated | ( | ) | const |
Returns pair(true, equil_samples) if required equilibration has occured for all samplers that must converge.
Definition at line 63 of file MonteCarlo.cc.
|
inline |
Return true if convergence is requested.
Definition at line 139 of file MonteCarlo.hh.
|
inline |
const Access the SuperNeighborList via pointer stored by 'set_nlist'
Definition at line 83 of file MonteCarlo.hh.
|
inline |
const Access the PrimClex that *this is based on
Definition at line 68 of file MonteCarlo.hh.
|
inline |
Set current microstate and clear samplers.
Definition at line 101 of file MonteCarlo.hh.
void CASM::MonteCarlo::sample_data | ( | const MonteCounter & | counter | ) |
Samples all requested property data, and stores pass and step number sample was taken at.
Definition at line 29 of file MonteCarlo.cc.
|
inline |
const Access a vector of std::pair<pass, step> indicating when samples were taken
Definition at line 158 of file MonteCarlo.hh.
|
inline |
const Access sampler map
Definition at line 153 of file MonteCarlo.hh.
|
inline |
const Access scalar properties map
Definition at line 110 of file MonteCarlo.hh.
|
inline |
const Access a particular scalar property
Definition at line 115 of file MonteCarlo.hh.
|
inline |
Set a pointer to the SuperNeighborList once it is ready.
Definition at line 78 of file MonteCarlo.hh.
|
inline |
const Access settings used for construction
Definition at line 63 of file MonteCarlo.hh.
|
inline |
const Access the Supercell that *this is based on
Definition at line 73 of file MonteCarlo.hh.
|
inline |
const Access snapshots of the Monte Carlo calculation
If requested, snapshots are taken at the same time as samples. So examine sample_times for pass and step information.
Definition at line 166 of file MonteCarlo.hh.
|
inline |
const Access vector properties map
Definition at line 120 of file MonteCarlo.hh.
|
inline |
const Access a particular vector property
Definition at line 125 of file MonteCarlo.hh.
|
mutableprivate |
Stores all degrees of freedom of the current microstate.
'mutable' is used for case where the DoF are modified to calculate event property values and then reverted within a const function
Definition at line 265 of file MonteCarlo.hh.
|
private |
Reference to m_config.configdof(), to avoid invalidating id every time used.
Definition at line 268 of file MonteCarlo.hh.
|
private |
Definition at line 309 of file MonteCarlo.hh.
|
private |
Definition at line 312 of file MonteCarlo.hh.
|
mutableprivate |
Definition at line 304 of file MonteCarlo.hh.
|
mutableprivate |
Definition at line 305 of file MonteCarlo.hh.
|
mutableprivate |
Definition at line 302 of file MonteCarlo.hh.
|
mutableprivate |
Definition at line 303 of file MonteCarlo.hh.
|
private |
Target for messages.
Definition at line 284 of file MonteCarlo.hh.
|
private |
True if any Sampler must converge.
Definition at line 281 of file MonteCarlo.hh.
|
mutableprivate |
Definition at line 308 of file MonteCarlo.hh.
|
private |
Pointer to SuperNeighborList.
Definition at line 259 of file MonteCarlo.hh.
|
private |
PrimClex for this system.
Definition at line 253 of file MonteCarlo.hh.
|
private |
a vector of std::pair(pass, step) indicating when samples were taken
Definition at line 297 of file MonteCarlo.hh.
|
private |
a map of pair<keyname, index> to MonteSampler
Definition at line 294 of file MonteCarlo.hh.
|
private |
a map of keyname to property value
Definition at line 241 of file MonteCarlo.hh.
|
mutableprivate |
Supercell for the calculation.
Definition at line 256 of file MonteCarlo.hh.
|
private |
Contains all input settings.
Definition at line 250 of file MonteCarlo.hh.
|
private |
Snapshots of the Monte Carlo simulation, taken by sample_data() if m_write_trajectory is true.
Definition at line 278 of file MonteCarlo.hh.
|
private |
Random number generator.
Definition at line 271 of file MonteCarlo.hh.
|
private |
a map of keyname to property value Eigen::VectorXd
Definition at line 247 of file MonteCarlo.hh.
|
private |
Save trajectory?
Definition at line 275 of file MonteCarlo.hh.