CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Canonical.hh
Go to the documentation of this file.
1 #ifndef CASM_Canonical_HH
2 #define CASM_Canonical_HH
3 
4 #include "casm/clex/Clex.hh"
13 
14 namespace CASM {
15 namespace Monte {
16 
32 class Canonical : public MonteCarlo {
33  public:
34  static const ENSEMBLE ensemble;
38 
42 
45  size_type steps_per_pass() const;
46 
48  const CondType &conditions() const;
49 
51  void set_conditions(const CondType &new_conditions);
52 
54  void set_configdof(const ConfigDoF &configdof, const std::string &msg = "");
55 
57  std::pair<ConfigDoF, std::string> set_state(
58  const CanonicalConditions &new_conditions,
60 
62  void set_state(const CondType &new_conditions, const ConfigDoF &configdof,
63  const std::string &msg = "");
64 
67  const EventType &propose();
68 
71  bool check(const EventType &event);
72 
75  void accept(const EventType &event);
76 
78  void reject(const EventType &event);
79 
81  void write_results(size_type cond_index) const;
82 
84  const double &formation_energy() const { return *m_formation_energy; }
85 
87  const double &potential_energy() const { return *m_potential_energy; }
88 
90  const Eigen::VectorXd &corr() const { return *m_corr; }
91 
93  const Eigen::VectorXd &comp_n() const { return *m_comp_n; }
94 
96  double potential_energy(const Configuration &config) const;
97 
98  private:
100  double &_formation_energy() { return *m_formation_energy; }
101 
103  double &_potential_energy() { return *m_potential_energy; }
104 
106  Eigen::VectorXd &_corr() { return *m_corr; }
107 
110 
111  Clexulator const &_clexulator() const {
113  }
114 
115  const ECIContainer &_eci() const { return m_formation_energy_clex.eci; }
116 
117  void _set_nlist(size_type l) const;
118  void _calc_delta_point_corr(size_type l, int new_occ,
119  Eigen::VectorXd &dCorr_comp) const;
120 
122  void _set_dCorr(CanonicalEvent &event) const;
123 
125  void _print_correlations(const Eigen::VectorXd &corr, std::string title,
126  std::string colheader, bool all_correlations) const;
127 
130  void _update_deltas(CanonicalEvent &event) const;
131 
133  void _update_properties();
134 
136  ConfigDoF _default_motif() const;
137 
139  std::pair<ConfigDoF, std::string> _auto_motif(
140  const CanonicalConditions &cond) const;
141 
143  std::pair<ConfigDoF, std::string> _restricted_auto_motif(
144  const CanonicalConditions &cond) const;
145 
147  ConfigDoF _configname_motif(const std::string &configname) const;
148 
152 
154  std::vector<OccSwap>::const_iterator _find_grand_canonical_swap(
155  const Configuration &config, std::vector<OccSwap>::const_iterator begin,
156  std::vector<OccSwap>::const_iterator end);
157 
160 
163 
166 
169 
173 
177 
180 
184 
187 
188  // ---- Pointers to properties for faster access
189 
192 
195 
198 
201 };
202 
203 } // namespace Monte
204 } // namespace CASM
205 
206 #endif
Evaluates correlations.
Definition: Clexulator.hh:440
A sparse container of ECI values and their corresponding orbit indices.
Definition: ECIContainer.hh:12
Definition: Log.hh:48
Data structure for storing information regarding a proposed grand canonical Monte Carlo event.
const CondType & conditions() const
Return current conditions.
Definition: Canonical.cc:90
void _calc_delta_point_corr(size_type l, int new_occ, Eigen::VectorXd &dCorr_comp) const
Definition: Canonical.cc:278
CanonicalConditions m_condition
Definition: Canonical.hh:183
void accept(const EventType &event)
Accept proposed event. Change configuration accordingly and update energies etc.
Definition: Canonical.cc:231
ConfigDoF _default_motif() const
Generate supercell filling ConfigDoF from default configuration.
Definition: Canonical.cc:459
CanonicalEvent m_event
Event to propose, check, accept/reject:
Definition: Canonical.hh:186
Eigen::VectorXd & _comp_n()
Number of atoms of each type, normalized per primitive cell.
Definition: Canonical.hh:109
void write_results(size_type cond_index) const
Write results to files.
Definition: Canonical.cc:259
const Eigen::VectorXd & corr() const
Correlations, normalized per primitive cell.
Definition: Canonical.hh:90
const Eigen::VectorXd & comp_n() const
Number of atoms of each type, normalized per primitive cell.
Definition: Canonical.hh:93
void _update_properties()
Calculate properties given current conditions.
Definition: Canonical.cc:416
std::pair< ConfigDoF, std::string > set_state(const CanonicalConditions &new_conditions, const CanonicalSettings &settings)
Set configdof and conditions and clear previously collected data.
Definition: Canonical.cc:122
void _set_nlist(size_type l) const
ConfigDoF _configname_motif(const std::string &configname) const
Generate supercell filling ConfigDoF from configuration.
Definition: Canonical.cc:484
size_type steps_per_pass() const
Return number of steps per pass. Equals number of sites with variable occupation.
Definition: Canonical.cc:87
const double & formation_energy() const
Formation energy, normalized per primitive cell.
Definition: Canonical.hh:84
CanonicalEvent EventType
Definition: Canonical.hh:35
void reject(const EventType &event)
Nothing needs to be done to reject a CanonicalEvent.
Definition: Canonical.cc:250
void _make_possible_swaps(const CanonicalSettings &settings)
Construct m_candidate, m_cand_to_index, m_occ_loc, m_canonical_swaps, m_grand_canonical_swaps.
Eigen::VectorXd & _corr()
Correlations, normalized per primitive cell.
Definition: Canonical.hh:106
Conversions m_convert
Convert sublat/asym_unit and species/occ index.
Definition: Canonical.hh:165
ConfigDoF _enforce_conditions(const ConfigDoF &configdof)
Enforce composition by repeatedly applying grand canonical events.
Definition: Canonical.cc:557
void set_configdof(const ConfigDoF &configdof, const std::string &msg="")
Set configdof and clear previously collected data.
Definition: Canonical.cc:106
Eigen::VectorXd * m_corr
Correlations, normalized per primitive cell.
Definition: Canonical.hh:197
void set_conditions(const CondType &new_conditions)
Set conditions and clear previously collected data.
Definition: Canonical.cc:93
double * m_potential_energy
Potential energy, normalized per primitive cell.
Definition: Canonical.hh:194
std::pair< ConfigDoF, std::string > _restricted_auto_motif(const CanonicalConditions &cond) const
Generate minimum potential energy ConfigDoF for this supercell.
Definition: Canonical.cc:477
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 ...
Definition: Canonical.cc:201
Clex m_formation_energy_clex
Holds Clexulator and ECI references.
Definition: Canonical.hh:162
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.
Definition: Canonical.cc:500
void _update_deltas(CanonicalEvent &event) const
Calculate delta properties for an event and update the event with those properties.
Definition: Canonical.cc:407
static const ENSEMBLE ensemble
Definition: Canonical.hh:34
Canonical(const PrimClex &primclex, const SettingsType &settings, Log &_log)
Constructs a Canonical object and prepares it for running based on Settings.
Definition: Canonical.cc:35
const double & potential_energy() const
Potential energy, normalized per primitive cell.
Definition: Canonical.hh:87
const ECIContainer & _eci() const
Definition: Canonical.hh:115
double * m_formation_energy
Formation energy, normalized per primitive cell.
Definition: Canonical.hh:191
OccCandidateList m_cand
Convert sublat/asym_unit and species/occ index.
Definition: Canonical.hh:168
double & _formation_energy()
Formation energy, normalized per primitive cell.
Definition: Canonical.hh:100
double & _potential_energy()
Potential energy, normalized per primitive cell.
Definition: Canonical.hh:103
const EventType & propose()
Propose a new event, calculate delta properties, and return reference to it.
Definition: Canonical.cc:192
std::pair< ConfigDoF, std::string > _auto_motif(const CanonicalConditions &cond) const
Generate minimum potential energy ConfigDoF.
Definition: Canonical.cc:470
void _print_correlations(const Eigen::VectorXd &corr, std::string title, std::string colheader, bool all_correlations) const
Print correlations to _log()
Definition: Canonical.cc:376
OccLocation m_occ_loc
Keeps track of what sites have which occupants.
Definition: Canonical.hh:179
CanonicalConditions CondType
Definition: Canonical.hh:36
CanonicalSettings SettingsType
Definition: Canonical.hh:37
bool m_use_deltas
If the supercell is large enough, calculate delta correlations directly.
Definition: Canonical.hh:176
Eigen::VectorXd * m_comp_n
Number of atoms of each type, normalized per primitive cell.
Definition: Canonical.hh:200
Clexulator const & _clexulator() const
Definition: Canonical.hh:111
void _set_dCorr(CanonicalEvent &event) const
Calculate delta correlations for an event.
Definition: Canonical.cc:345
Interface base class for all types of Monte Carlo simulations (not meant to be used polymorphically)
Definition: MonteCarlo.hh:44
const MonteSettings & settings() const
const Access settings used for construction
Definition: MonteCarlo.hh:74
const Configuration & config() const
const Access current microstate
Definition: MonteCarlo.hh:90
const PrimClex & primclex() const
const Access the PrimClex that *this is based on
Definition: MonteCarlo.hh:77
Monte::size_type size_type
Definition: MonteCarlo.hh:46
const ConfigDoF & configdof() const
const Access current microstate
Definition: MonteCarlo.hh:93
Stores data to enable efficient proposal and update of occupation mutation.
Definition: OccLocation.hh:76
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:563
ENSEMBLE
Monte Carlo ensemble type.
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::VectorXd VectorXd
Pair of Clexulator and ECIContainer.
Definition: Clex.hh:16
ECIContainer eci
Definition: Clex.hh:18
Clexulator clexulator
Definition: Clex.hh:17