CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
MonteCounter.hh
Go to the documentation of this file.
1 #ifndef CASM_MonteCounter_HH
2 #define CASM_MonteCounter_HH
3 
6 
7 namespace CASM {
8 
9  class EquilibriumMonteSettings;
10  class MonteCarlo;
11 
20  class MonteCounter {
21  public:
22 
23  typedef Index size_type;
24 
25 
27  MonteCounter(const EquilibriumMonteSettings &settings, size_type _steps_per_pass);
28 
29 
31  size_type pass() const;
32 
34  size_type step() const;
35 
36 
38  size_type steps_per_pass() const;
39 
40 
42  size_type samples() const;
43 
44 
46  void increment_samples();
47 
48 
50  void reset();
51 
53  void set(size_type _pass,
54  size_type _step,
55  size_type _samples);
56 
57 
59  bool sample_time() const;
60 
61 
64 
67 
68 
70  bool is_complete() const;
71 
73  bool minimums_met() const;
74 
76  bool maximums_met() const;
77 
78  void debugprint(std::ostream &sout) const;
79 
80  private:
81 
83  size_type m_pass = 0;
84 
86  size_type m_step = 0;
87 
88 
90  size_type m_samples = 0;
91 
92 
94  size_type m_since_last_sample = 0;
95 
96  // --- If not in 'must converge mode' -----
97 
99  bool m_is_N_step = false;
100  size_type m_N_step = 0;
101 
103  bool m_is_N_pass = false;
104  size_type m_N_pass = 0;
105 
107  bool m_is_N_sample = false;
108  size_type m_N_sample = 0;
109 
110 
111 
112  // --- Imposed limits ------------
113 
115  bool m_is_max_step = false;
116  size_type m_max_step = 0;
117 
119  bool m_is_min_step = false;
120  size_type m_min_step = 0;
121 
123  bool m_is_max_pass = false;
124  size_type m_max_pass = 0;
125 
127  bool m_is_min_pass = false;
128  size_type m_min_pass = 0;
129 
131  bool m_is_max_sample = false;
132  size_type m_max_sample = 0;
133 
135  bool m_is_min_sample = false;
136  size_type m_min_sample = 0;
137 
138 
139  // --- Periods at which certain things should happen --------
140 
143 
146 
149 
150  };
151 
152 }
153 
154 #endif
155 
156 
bool minimums_met() const
Check if minimum number of pass, step, and samples has been met.
size_type m_step
Number of steps taken during the current pass.
Definition: MonteCounter.hh:86
void increment_samples()
Increments the number of samples taken and resets counter until the next sample should be taken...
MonteCounter & operator++()
Prefix increment step and updates pass.
size_type m_min_sample
Monte::SAMPLE_MODE m_sample_mode
Whether sampling mode is by Monte::SAMPLE_MODE::PASS or Monte::SAMPLE_MODE::STEP. ...
void debugprint(std::ostream &sout) const
bool is_complete() const
Check if requested number of pass, step, or samples has been met.
bool m_is_max_pass
Maximum allowed number of passes.
Main CASM namespace.
Definition: complete.cpp:8
size_type m_since_last_sample
Number of passes or steps since last sample.
Definition: MonteCounter.hh:94
bool m_is_N_step
Requested number of steps.
Definition: MonteCounter.hh:99
bool m_is_max_sample
Maximum allowed number of samples to take.
bool m_is_N_sample
Requested number of samples.
Track the number of passes, steps and samples taken in a Monte Carlo calculation. ...
Definition: MonteCounter.hh:20
size_type pass() const
Number of complete passes performed.
Definition: MonteCounter.cc:91
bool maximums_met() const
Check if maximum number of pass, step, and samples has been met.
void reset()
Set all counter variables back to 0.
int m_steps_per_pass
Number of steps per pass is equal to the number of sites with variable degrees of freedom in the supe...
bool m_is_min_step
Minimum allowed number of steps.
EigenIndex Index
For long integer indexing:
size_type m_pass
One pass is equal to the number of sites with variable degrees of freedom in the supercell.
Definition: MonteCounter.hh:83
size_type step() const
Number of steps into the current pass.
Definition: MonteCounter.cc:95
bool sample_time() const
Returns true if based on period and current number of steps it is time to take a sample.
SAMPLE_MODE
How often to sample runs.
MonteCounter(const EquilibriumMonteSettings &settings, size_type _steps_per_pass)
Construct a MonteCounter and initialize to all counts to zero.
Definition: MonteCounter.cc:11
int m_sample_period
How often to sample data. In terms of m_sample_mode. If == 1 sample every pass/step.
bool m_is_min_sample
Minimum allowed number of samples to take.
bool m_is_min_pass
Minimum allowed number of passes.
size_type samples() const
Number of samples taken.
size_type m_max_sample
bool m_is_N_pass
Requested number of passes.
size_type steps_per_pass() const
Number of steps per pass.
void set(size_type _pass, size_type _step, size_type _samples)
Set all counter variables for performing a restart.
size_type m_samples
Number of data samples taken.
Definition: MonteCounter.hh:90
bool m_is_max_step
Maximum allowed number of steps.