11 const std::string &B)
const {
14 if (A.substr(0, Apos1) == B.substr(0, Bpos1)) {
18 std::string Aindex = A.substr(Apos1 + 1, Apos2 - Apos1 - 1);
19 std::string Bindex = B.substr(Bpos1 + 1, Bpos2 - Bpos1 - 1);
21 for (
int i = 0; i < Aindex.size(); i++) {
22 if (!std::isdigit(Aindex[i])) {
23 return Aindex < Bindex;
27 return std::stoi(Aindex) < std::stoi(Bindex);
29 return A.substr(0, Apos1) < B.substr(0, Bpos1);
37 it->second->sample(*
this, counter);
77 _log() << std::boolalpha << std::setw(24) <<
"quantity" << std::setw(20)
78 <<
"is_equilibrated" << std::setw(16) <<
"at_sample" << std::endl;
84 if (it->second->must_converge()) {
86 auto equil = it->second->is_equilibrated();
88 _log() << std::setw(24) << it->second->name() << std::setw(20)
89 << (equil.first ?
"true"
92 _log() << std::setw(16) << equil.second << std::endl;
94 _log() << std::setw(16) <<
"unknown" << std::endl;
100 if (equil.second > max_equil_samples) {
101 max_equil_samples = equil.second;
110 _log() <<
"Overall equilibration at sample: " << max_equil_samples <<
"\n"
113 return m_is_equil = std::make_pair(
true, max_equil_samples);
151 _log() << std::boolalpha << std::setw(24) <<
"quantity" << std::setw(16)
152 <<
"mean" << std::setw(16) <<
"req_prec" << std::setw(16)
153 <<
"calc_prec" << std::setw(16) <<
"is_converged" << std::endl;
159 [=](
const SamplerMap::value_type &val) {
160 if (val.second->must_converge()) {
161 bool result = val.second->is_converged(equil.second);
162 _log() << std::setw(24) << val.second->name() << std::setw(16)
163 << val.second->mean(equil.second) << std::setw(16)
164 << val.second->requested_precision() << std::setw(16)
165 << val.second->calculated_precision(equil.second)
167 << (result ?
"true" :
"false")
181 _log() <<
"Overall convergence?: " << std::boolalpha << m_is_converged <<
"\n"
184 return m_is_converged;
190 bool MonteCarlo::check_convergence_time()
const {
191 if (m_sample_time.size() >= m_next_convergence_check) {
200 void MonteCarlo::_set_check_convergence_time()
const {
201 m_next_convergence_check = m_sample_time.size() + m_convergence_check_period;
void check(const std::string &what)
void _set_check_convergence_time() const
Set the next time convergence is due to be checked.
std::pair< bool, size_type > is_equilibrated() const
Returns pair(true, equil_samples) if required equilibration has occured for all samplers that must co...
void clear_samples()
Clear all data from all samplers.
SamplerMap m_sampler
a map of pair<keyname, index> to MonteSampler
size_type m_next_convergence_check
void sample_data(const MonteCounter &counter)
Samples all requested property data, and stores pass and step number sample was taken at.
bool m_write_trajectory
Save trajectory?
SampleTimes m_sample_time
a vector of std::pair(pass, step) indicating when samples were taken
bool m_is_converged_uptodate
std::vector< ConfigDoF > m_trajectory
Snapshots of the Monte Carlo simulation, taken by sample_data() if m_write_trajectory is true.
bool is_converged() const
Check to see if all the properties required to converge have converged.
Monte::size_type size_type
size_type m_convergence_check_period
const ConfigDoF & configdof() const
const Access current microstate
std::pair< bool, size_type > m_is_equil
Track the number of passes, steps and samples taken in a Monte Carlo calculation.
size_type step() const
Number of steps into the current pass.
size_type pass() const
Number of complete passes performed.
bool operator()(const std::string &A, const std::string &B) const