CASM  1.1.0
A Clusters Approach to Statistical Mechanics
GrandCanonical.hh
Go to the documentation of this file.
1 #ifndef CASM_GrandCanonical_HH
2 #define CASM_GrandCanonical_HH
3 
4 #include "casm/clex/Clex.hh"
12 
13 namespace CASM {
14 namespace Monte {
15 
31 class GrandCanonical : public MonteCarlo {
32  public:
33  static const ENSEMBLE ensemble;
37 
41  Log &_log);
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 GrandCanonicalConditions &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 
85  double lte_grand_canonical_free_energy() const;
86 
88  const double &formation_energy() const { return *m_formation_energy; }
89 
91  const double &potential_energy() const { return *m_potential_energy; }
92 
94  const Eigen::VectorXd &corr() const { return *m_corr; }
95 
97  const Eigen::VectorXd &comp_n() const { return *m_comp_n; }
98 
100  double potential_energy(const Configuration &config) const;
101 
102  private:
104  double &_formation_energy() { return *m_formation_energy; }
105 
107  double &_potential_energy() { return *m_potential_energy; }
108 
110  Eigen::VectorXd &_corr() { return *m_corr; }
111 
114 
115  Clexulator const &_clexulator() const {
117  }
118 
119  const ECIContainer &_eci() const { return m_formation_energy_clex.eci; }
120 
122  void _set_dCorr(GrandCanonicalEvent &event, Index mutating_site, int sublat,
123  int current_occupant, int new_occupant, bool use_deltas,
124  bool all_correlations) const;
125 
127  void _print_correlations(const Eigen::VectorXd &corr, std::string title,
128  std::string colheader, bool all_correlations) const;
129 
132  void _update_deltas(GrandCanonicalEvent &event, Index mutating_site,
133  int sublat, int current_occupant, int new_occupant) const;
134 
136  void _update_properties();
137 
139  ConfigDoF _default_motif() const;
140 
142  std::pair<ConfigDoF, std::string> _auto_motif(
143  const GrandCanonicalConditions &cond) const;
144 
146  std::pair<ConfigDoF, std::string> _restricted_auto_motif(
147  const GrandCanonicalConditions &cond) const;
148 
150  ConfigDoF _configname_motif(const std::string &configname) const;
151 
154 
158 
161 
165 
168 
172 
173  // ---- Pointers to properties for faster access
174 
177 
180 
183 
186 };
187 
188 } // namespace Monte
189 } // namespace CASM
190 
191 #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.
GrandCanonicalConditions CondType
Clexulator const & _clexulator() const
void _update_properties()
Calculate properties given current conditions.
Eigen::VectorXd * m_comp_n
Number of atoms of each type, normalized per primitive cell.
const ECIContainer & _eci() const
GrandCanonicalEvent EventType
const Eigen::VectorXd & corr() const
Correlations, normalized per primitive cell.
void _set_dCorr(GrandCanonicalEvent &event, Index mutating_site, int sublat, int current_occupant, int new_occupant, bool use_deltas, bool all_correlations) const
Calculate delta correlations for an event.
void accept(const EventType &event)
Accept proposed event. Change configuration accordingly and update energies etc.
std::pair< ConfigDoF, std::string > set_state(const GrandCanonicalConditions &new_conditions, const GrandCanonicalSettings &settings)
Set configdof and conditions and clear previously collected data.
const EventType & propose()
Propose a new event, calculate delta properties, and return reference to it.
double * m_potential_energy
Potential energy, normalized per primitive cell.
void reject(const EventType &event)
Nothing needs to be done to reject a GrandCanonicalEvent.
Eigen::VectorXd & _corr()
Correlations, normalized per primitive cell.
void _update_deltas(GrandCanonicalEvent &event, Index mutating_site, int sublat, int current_occupant, int new_occupant) const
Calculate delta properties for an event and update the event with those properties.
double lte_grand_canonical_free_energy() const
Calculate the single spin flip low temperature expansion of the grand canonical potential.
size_type steps_per_pass() const
Return number of steps per pass. Equals number of sites with variable occupation.
void _print_correlations(const Eigen::VectorXd &corr, std::string title, std::string colheader, bool all_correlations) const
Print correlations to _log()
GrandCanonical(const PrimClex &primclex, const SettingsType &settings, Log &_log)
Constructs a GrandCanonical object and prepares it for running based on Settings.
const double & formation_energy() const
Formation energy, normalized per primitive cell.
Eigen::VectorXd * m_corr
Correlations, normalized per primitive cell.
const double & potential_energy() const
Potential energy, normalized per primitive cell.
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 ...
double & _formation_energy()
Formation energy, normalized per primitive cell.
void write_results(size_type cond_index) const
Write results to files.
Clex m_formation_energy_clex
Holds Clexulator and ECI references.
ConfigDoF _configname_motif(const std::string &configname) const
Generate supercell filling ConfigDoF from configuration.
const CondType & conditions() const
Return current conditions.
void set_conditions(const CondType &new_conditions)
Set conditions and clear previously collected data.
ConfigDoF _default_motif() const
Generate supercell filling ConfigDoF from default configuration.
Eigen::VectorXd & _comp_n()
Number of atoms of each type, normalized per primitive cell.
GrandCanonicalSettings SettingsType
std::pair< ConfigDoF, std::string > _auto_motif(const GrandCanonicalConditions &cond) const
Generate minimum potential energy ConfigDoF.
static const ENSEMBLE ensemble
const Eigen::VectorXd & comp_n() const
Number of atoms of each type, normalized per primitive cell.
std::pair< ConfigDoF, std::string > _restricted_auto_motif(const GrandCanonicalConditions &cond) const
Generate minimum potential energy ConfigDoF for this supercell.
double * m_formation_energy
Formation energy, normalized per primitive cell.
double & _potential_energy()
Potential energy, normalized per primitive cell.
GrandCanonicalConditions m_condition
EventType m_event
Event to propose, check, accept/reject:
void set_configdof(const ConfigDoF &configdof, const std::string &msg="")
Set configdof and clear previously collected data.
bool m_use_deltas
If the supercell is large enough, calculate delta correlations directly.
const SiteExchanger m_site_swaps
Keeps track of what sites can change to what.
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
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
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd
Pair of Clexulator and ECIContainer.
Definition: Clex.hh:16
ECIContainer eci
Definition: Clex.hh:18
Clexulator clexulator
Definition: Clex.hh:17