CASM
1.1.0
A Clusters Approach to Statistical Mechanics
|
#include <Canonical.hh>
Derives from base MonteCarlo class, to be used for simulations at constant temperature and chemical potential.
As with all the other derived Monte Carlo classes, member functions must follow a specific naming convention to be used with templated routines currently defined in MonteDriver.hh: -conditions -set_conditions -propose -check -accept -reject -write_results
Definition at line 32 of file Canonical.hh.
Public Types | |
typedef CanonicalEvent | EventType |
typedef CanonicalConditions | CondType |
typedef CanonicalSettings | SettingsType |
typedef Monte::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< size_type, size_type > > | SampleTimes |
a vector of std::pair(pass, step) indicating when samples were taken More... | |
Public Member Functions | |
Canonical (const PrimClex &primclex, const SettingsType &settings, Log &_log) | |
Constructs a Canonical object and prepares it for running based on Settings. More... | |
size_type | steps_per_pass () const |
Return number of steps per pass. Equals number of sites with variable occupation. More... | |
const CondType & | conditions () const |
Return current conditions. More... | |
void | set_conditions (const CondType &new_conditions) |
Set conditions and clear previously collected data. More... | |
void | set_configdof (const ConfigDoF &configdof, const std::string &msg="") |
Set configdof and clear previously collected data. More... | |
std::pair< ConfigDoF, std::string > | set_state (const CanonicalConditions &new_conditions, const CanonicalSettings &settings) |
Set configdof and conditions and clear previously collected data. More... | |
void | set_state (const CondType &new_conditions, const ConfigDoF &configdof, const std::string &msg="") |
Set configdof and conditions and clear previously collected data. More... | |
const EventType & | propose () |
Propose a new event, calculate delta properties, and return reference to it. More... | |
bool | check (const EventType &event) |
Based on a random number, decide if the change in energy from the proposed event is low enough to be accepted. More... | |
void | accept (const EventType &event) |
Accept proposed event. Change configuration accordingly and update energies etc. More... | |
void | reject (const EventType &event) |
Nothing needs to be done to reject a CanonicalEvent. More... | |
void | write_results (size_type cond_index) const |
Write results to files. More... | |
const double & | formation_energy () const |
Formation energy, normalized per primitive cell. More... | |
const double & | potential_energy () const |
Potential energy, normalized per primitive cell. More... | |
const Eigen::VectorXd & | corr () const |
Correlations, normalized per primitive cell. More... | |
const Eigen::VectorXd & | comp_n () const |
Number of atoms of each type, normalized per primitive cell. More... | |
double | potential_energy (const Configuration &config) const |
Get potential energy. More... | |
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, 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... | |
Static Public Attributes | |
static const ENSEMBLE | ensemble = ENSEMBLE::Canonical |
Protected Member Functions | |
const PrimClex & | _primclex () const |
Access the PrimClex that *this is based on. More... | |
const 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 | |
double & | _formation_energy () |
Formation energy, normalized per primitive cell. More... | |
double & | _potential_energy () |
Potential energy, normalized per primitive cell. More... | |
Eigen::VectorXd & | _corr () |
Correlations, normalized per primitive cell. More... | |
Eigen::VectorXd & | _comp_n () |
Number of atoms of each type, normalized per primitive cell. More... | |
Clexulator const & | _clexulator () const |
const ECIContainer & | _eci () const |
void | _set_nlist (size_type l) const |
void | _calc_delta_point_corr (size_type l, int new_occ, Eigen::VectorXd &dCorr_comp) const |
void | _set_dCorr (CanonicalEvent &event) const |
Calculate delta correlations for an event. More... | |
void | _print_correlations (const Eigen::VectorXd &corr, std::string title, std::string colheader, bool all_correlations) const |
Print correlations to _log() More... | |
void | _update_deltas (CanonicalEvent &event) const |
Calculate delta properties for an event and update the event with those properties. More... | |
void | _update_properties () |
Calculate properties given current conditions. More... | |
ConfigDoF | _default_motif () const |
Generate supercell filling ConfigDoF from default configuration. More... | |
std::pair< ConfigDoF, std::string > | _auto_motif (const CanonicalConditions &cond) const |
Generate minimum potential energy ConfigDoF. More... | |
std::pair< ConfigDoF, std::string > | _restricted_auto_motif (const CanonicalConditions &cond) const |
Generate minimum potential energy ConfigDoF for this supercell. More... | |
ConfigDoF | _configname_motif (const std::string &configname) const |
Generate supercell filling ConfigDoF from configuration. More... | |
void | _make_possible_swaps (const CanonicalSettings &settings) |
Construct m_candidate, m_cand_to_index, m_occ_loc, m_canonical_swaps, m_grand_canonical_swaps. More... | |
std::vector< OccSwap >::const_iterator | _find_grand_canonical_swap (const Configuration &config, std::vector< OccSwap >::const_iterator begin, std::vector< OccSwap >::const_iterator end) |
Find a OccSwap to help enforce composition. More... | |
ConfigDoF | _enforce_conditions (const ConfigDoF &configdof) |
Enforce composition by repeatedly applying grand canonical events. More... | |
void | _set_check_convergence_time () const |
Set the next time convergence is due to be checked. More... | |
Private Attributes | |
Clex | m_formation_energy_clex |
Holds Clexulator and ECI references. More... | |
Conversions | m_convert |
Convert sublat/asym_unit and species/occ index. More... | |
OccCandidateList | m_cand |
Convert sublat/asym_unit and species/occ index. More... | |
bool | m_all_correlations |
bool | m_use_deltas |
If the supercell is large enough, calculate delta correlations directly. More... | |
OccLocation | m_occ_loc |
Keeps track of what sites have which occupants. More... | |
CanonicalConditions | m_condition |
CanonicalEvent | m_event |
Event to propose, check, accept/reject: More... | |
double * | m_formation_energy |
Formation energy, normalized per primitive cell. More... | |
double * | m_potential_energy |
Potential energy, normalized per primitive cell. More... | |
Eigen::VectorXd * | m_corr |
Correlations, normalized per primitive cell. More... | |
Eigen::VectorXd * | m_comp_n |
Number of atoms of each type, normalized per primitive cell. More... | |
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... | |
const 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 |
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 MonteSampler 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, size_type > | m_is_equil |
bool | m_is_equil_uptodate = false |
bool | m_is_converged |
bool | m_is_converged_uptodate = false |
size_type | m_next_convergence_check = 100 |
size_type | m_convergence_check_period = 100 |
bool | m_debug |
Definition at line 36 of file Canonical.hh.
Definition at line 35 of file Canonical.hh.
|
inherited |
a map of keyname to MonteSampler
Definition at line 65 of file MonteCarlo.hh.
|
inherited |
a vector of std::pair(pass, step) indicating when samples were taken
Definition at line 69 of file MonteCarlo.hh.
|
inherited |
a map of keyname to property value
Definition at line 51 of file MonteCarlo.hh.
Definition at line 37 of file Canonical.hh.
|
inherited |
Definition at line 46 of file MonteCarlo.hh.
|
inherited |
a map of keyname to property value Eigen::VectorXd
Definition at line 56 of file MonteCarlo.hh.
CASM::Monte::Canonical::Canonical | ( | const PrimClex & | primclex, |
const SettingsType & | settings, | ||
Log & | log | ||
) |
Constructs a Canonical object and prepares it for running based on Settings.
Constructs a Canonical object and prepares it for running based on MonteSettings.
Definition at line 35 of file Canonical.cc.
|
private |
Generate minimum potential energy ConfigDoF.
Raises exception if it doesn't tile the supercell
Definition at line 470 of file Canonical.cc.
|
private |
Definition at line 278 of file Canonical.cc.
|
inlineprivate |
Definition at line 111 of file Canonical.hh.
|
inlineprivate |
Number of atoms of each type, normalized per primitive cell.
Definition at line 109 of file Canonical.hh.
|
inlineprotectedinherited |
Access current microstate.
Definition at line 181 of file MonteCarlo.hh.
|
inlineprotectedinherited |
Access current microstate.
Definition at line 187 of file MonteCarlo.hh.
|
private |
Generate supercell filling ConfigDoF from configuration.
Definition at line 484 of file Canonical.cc.
|
inlineprivate |
Correlations, normalized per primitive cell.
Definition at line 106 of file Canonical.hh.
|
private |
Generate supercell filling ConfigDoF from default configuration.
Definition at line 459 of file Canonical.cc.
|
inlineprivate |
Definition at line 115 of file Canonical.hh.
Enforce composition by repeatedly applying grand canonical events.
Enforce composition by repeatedly applying GrandCanonicalSwap.
apply chosen swap (*it)
Definition at line 557 of file Canonical.cc.
|
private |
Find a OccSwap to help enforce composition.
Find a grand canonical OccSwap to help enforce composition.
Definition at line 500 of file Canonical.cc.
|
inlineprivate |
Formation energy, normalized per primitive cell.
Definition at line 100 of file Canonical.hh.
|
inlineprotectedinherited |
Definition at line 189 of file MonteCarlo.hh.
|
private |
Construct m_candidate, m_cand_to_index, m_occ_loc, m_canonical_swaps, m_grand_canonical_swaps.
|
inlineprotectedinherited |
Definition at line 191 of file MonteCarlo.hh.
|
inlineprivate |
Potential energy, normalized per primitive cell.
Definition at line 103 of file Canonical.hh.
|
inlineprotectedinherited |
Access the PrimClex that *this is based on.
Definition at line 172 of file MonteCarlo.hh.
|
private |
Print correlations to _log()
Definition at line 376 of file Canonical.cc.
|
private |
Generate minimum potential energy ConfigDoF for this supercell.
Definition at line 477 of file Canonical.cc.
|
inlineprotectedinherited |
Access scalar properties map.
Definition at line 194 of file MonteCarlo.hh.
|
inlineprotectedinherited |
Access a particular scalar property.
Definition at line 197 of file MonteCarlo.hh.
|
privateinherited |
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 200 of file MonteCarlo.cc.
|
private |
Calculate delta correlations for an event.
Definition at line 345 of file Canonical.cc.
|
private |
|
inlineprotectedinherited |
Access the Supercell that *this is based on.
Definition at line 175 of file MonteCarlo.hh.
|
private |
Calculate delta properties for an event and update the event with those properties.
Update delta properties in 'event'.
Definition at line 407 of file Canonical.cc.
|
private |
Calculate properties given current conditions.
Definition at line 416 of file Canonical.cc.
|
inlineprotectedinherited |
const Access vector properties map
Definition at line 202 of file MonteCarlo.hh.
|
inlineprotectedinherited |
const Access a particular vector property
Definition at line 205 of file MonteCarlo.hh.
void CASM::Monte::Canonical::accept | ( | const EventType & | event | ) |
Accept proposed event. Change configuration accordingly and update energies etc.
Once you've found an event that passes the random number test, you want to accept it. This routine will apply all the changes in the event to *this (change occupation of one atom) and update the formation energy, generalized enthalpy, number of species and correlations values.
Definition at line 231 of file Canonical.cc.
bool CASM::Monte::Canonical::check | ( | const EventType & | event | ) |
Based on a random number, decide if the change in energy from the proposed event is low enough to be accepted.
Definition at line 201 of file Canonical.cc.
|
inherited |
Returns true if a convergence check is due.
Currently set to every 10 samples
Definition at line 190 of file MonteCarlo.cc.
|
inherited |
Clear all data from all samplers.
Definition at line 50 of file MonteCarlo.cc.
|
inline |
Number of atoms of each type, normalized per primitive cell.
Definition at line 93 of file Canonical.hh.
const Canonical::CondType & CASM::Monte::Canonical::conditions | ( | ) | const |
Return current conditions.
Definition at line 90 of file Canonical.cc.
|
inlineinherited |
const Access current microstate
Definition at line 90 of file MonteCarlo.hh.
|
inlineinherited |
const Access current microstate
Definition at line 93 of file MonteCarlo.hh.
|
inline |
Correlations, normalized per primitive cell.
Definition at line 90 of file Canonical.hh.
|
inlineinherited |
return true if running in debug mode
Definition at line 162 of file MonteCarlo.hh.
|
inline |
Formation energy, normalized per primitive cell.
Definition at line 84 of file Canonical.hh.
|
inherited |
Check to see if all the properties required to converge have converged.
Definition at line 126 of file MonteCarlo.cc.
|
inherited |
Returns pair(true, equil_samples) if required equilibration has occured for all samplers that must converge.
Definition at line 69 of file MonteCarlo.cc.
|
inlineinherited |
Return true if convergence is requested.
Definition at line 135 of file MonteCarlo.hh.
|
inlineinherited |
const Access the SuperNeighborList via pointer stored by 'set_nlist'
Definition at line 87 of file MonteCarlo.hh.
|
inline |
Potential energy, normalized per primitive cell.
Definition at line 87 of file Canonical.hh.
double CASM::Monte::Canonical::potential_energy | ( | const Configuration & | config | ) | const |
Get potential energy.
Definition at line 271 of file Canonical.cc.
|
inlineinherited |
const Access the PrimClex that *this is based on
Definition at line 77 of file MonteCarlo.hh.
const Canonical::EventType & CASM::Monte::Canonical::propose | ( | ) |
Propose a new event, calculate delta properties, and return reference to it.
Randomly picks a site that's allowed more than one occupant, and randomly picks what occupant it changes to. Then calculates delta properties associated with that change.
Definition at line 192 of file Canonical.cc.
void CASM::Monte::Canonical::reject | ( | const EventType & | event | ) |
Nothing needs to be done to reject a CanonicalEvent.
Definition at line 250 of file Canonical.cc.
|
inlineinherited |
Set current microstate and clear samplers.
Definition at line 98 of file MonteCarlo.hh.
|
inherited |
Samples all requested property data, and stores pass and step number sample was taken at.
Definition at line 34 of file MonteCarlo.cc.
|
inlineinherited |
const Access a vector of std::pair<pass, step> indicating when samples were taken
Definition at line 153 of file MonteCarlo.hh.
|
inlineinherited |
const Access sampler map
Definition at line 149 of file MonteCarlo.hh.
|
inlineinherited |
const Access scalar properties map
Definition at line 106 of file MonteCarlo.hh.
|
inlineinherited |
const Access a particular scalar property
Definition at line 111 of file MonteCarlo.hh.
void CASM::Monte::Canonical::set_conditions | ( | const CondType & | new_conditions | ) |
Set conditions and clear previously collected data.
Definition at line 93 of file Canonical.cc.
void CASM::Monte::Canonical::set_configdof | ( | const ConfigDoF & | configdof, |
const std::string & | msg = "" |
||
) |
Set configdof and clear previously collected data.
Definition at line 106 of file Canonical.cc.
|
inlineinherited |
Set a pointer to the SuperNeighborList once it is ready.
Definition at line 83 of file MonteCarlo.hh.
std::pair< ConfigDoF, std::string > CASM::Monte::Canonical::set_state | ( | const CanonicalConditions & | new_conditions, |
const CanonicalSettings & | settings | ||
) |
Set configdof and conditions and clear previously collected data.
Definition at line 122 of file Canonical.cc.
void CASM::Monte::Canonical::set_state | ( | const CondType & | new_conditions, |
const ConfigDoF & | configdof, | ||
const std::string & | msg = "" |
||
) |
Set configdof and conditions and clear previously collected data.
Definition at line 166 of file Canonical.cc.
|
inlineinherited |
const Access settings used for construction
Definition at line 74 of file MonteCarlo.hh.
Index CASM::Monte::Canonical::steps_per_pass | ( | ) | const |
Return number of steps per pass. Equals number of sites with variable occupation.
Definition at line 87 of file Canonical.cc.
|
inlineinherited |
const Access the Supercell that *this is based on
Definition at line 80 of file MonteCarlo.hh.
|
inlineinherited |
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 159 of file MonteCarlo.hh.
|
inlineinherited |
const Access vector properties map
Definition at line 116 of file MonteCarlo.hh.
|
inlineinherited |
const Access a particular vector property
Definition at line 121 of file MonteCarlo.hh.
void CASM::Monte::Canonical::write_results | ( | size_type | cond_index | ) | const |
Write results to files.
Definition at line 259 of file Canonical.cc.
|
static |
Definition at line 34 of file Canonical.hh.
|
private |
If true, calculate all correlations; if false, calculate correlations with non-zero eci
Definition at line 172 of file Canonical.hh.
|
private |
Convert sublat/asym_unit and species/occ index.
Definition at line 168 of file Canonical.hh.
|
private |
Number of atoms of each type, normalized per primitive cell.
Definition at line 200 of file Canonical.hh.
|
private |
Conditions (T, mu). Initially determined by m_settings, but can be changed halfway through the run
Definition at line 183 of file Canonical.hh.
|
mutableprivateinherited |
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 236 of file MonteCarlo.hh.
|
privateinherited |
Reference to m_config.configdof(), to avoid invalidating id every time used
Definition at line 240 of file MonteCarlo.hh.
|
privateinherited |
Definition at line 281 of file MonteCarlo.hh.
|
private |
Convert sublat/asym_unit and species/occ index.
Definition at line 165 of file Canonical.hh.
|
private |
Correlations, normalized per primitive cell.
Definition at line 197 of file Canonical.hh.
|
privateinherited |
Definition at line 284 of file MonteCarlo.hh.
|
private |
Event to propose, check, accept/reject:
Definition at line 186 of file Canonical.hh.
|
private |
Formation energy, normalized per primitive cell.
Definition at line 191 of file Canonical.hh.
|
private |
Holds Clexulator and ECI references.
Definition at line 162 of file Canonical.hh.
|
mutableprivateinherited |
Definition at line 276 of file MonteCarlo.hh.
|
mutableprivateinherited |
Definition at line 277 of file MonteCarlo.hh.
|
mutableprivateinherited |
Definition at line 274 of file MonteCarlo.hh.
|
mutableprivateinherited |
Definition at line 275 of file MonteCarlo.hh.
|
privateinherited |
Target for messages.
Definition at line 256 of file MonteCarlo.hh.
|
privateinherited |
True if any MonteSampler must converge.
Definition at line 253 of file MonteCarlo.hh.
|
mutableprivateinherited |
Definition at line 280 of file MonteCarlo.hh.
|
privateinherited |
Pointer to SuperNeighborList.
Definition at line 230 of file MonteCarlo.hh.
|
private |
Keeps track of what sites have which occupants.
Definition at line 179 of file Canonical.hh.
|
private |
Potential energy, normalized per primitive cell.
Definition at line 194 of file Canonical.hh.
|
privateinherited |
PrimClex for this system.
Definition at line 224 of file MonteCarlo.hh.
|
privateinherited |
a vector of std::pair(pass, step) indicating when samples were taken
Definition at line 270 of file MonteCarlo.hh.
|
privateinherited |
a map of pair<keyname, index> to MonteSampler
Definition at line 266 of file MonteCarlo.hh.
|
privateinherited |
a map of keyname to property value
Definition at line 213 of file MonteCarlo.hh.
|
privateinherited |
Supercell for the calculation.
Definition at line 227 of file MonteCarlo.hh.
|
privateinherited |
Contains all input settings.
Definition at line 221 of file MonteCarlo.hh.
|
privateinherited |
Snapshots of the Monte Carlo simulation, taken by sample_data() if m_write_trajectory is true.
Definition at line 250 of file MonteCarlo.hh.
|
privateinherited |
Random number generator.
Definition at line 243 of file MonteCarlo.hh.
|
private |
If the supercell is large enough, calculate delta correlations directly.
Definition at line 176 of file Canonical.hh.
|
privateinherited |
a map of keyname to property value Eigen::VectorXd
Definition at line 218 of file MonteCarlo.hh.
|
privateinherited |
Save trajectory?
Definition at line 246 of file MonteCarlo.hh.