8 std::string::size_type Apos1 = A.find_first_of(
"([");
9 std::string::size_type Bpos1 = B.find_first_of(
"([");
10 if(A.substr(0, Apos1) == B.substr(0, Bpos1)) {
11 std::string::size_type Apos2 = A.find_first_of(
"])");
12 std::string::size_type Bpos2 = B.find_first_of(
"])");
14 std::string Aindex = A.substr(Apos1 + 1, Apos2 - Apos1 - 1);
15 std::string Bindex = B.substr(Bpos1 + 1, Bpos2 - Bpos1 - 1);
17 for(
int i = 0; i < Aindex.size(); i++) {
18 if(!std::isdigit(Aindex[i])) {
19 return Aindex < Bindex;
23 return std::stoi(Aindex) < std::stoi(Bindex);
25 return A.substr(0, Apos1) < B.substr(0, Bpos1);
33 it->second->sample(*
this, counter);
73 _log() << std::boolalpha
74 << std::setw(24) <<
"quantity"
75 << std::setw(20) <<
"is_equilibrated"
76 << std::setw(16) <<
"at_sample"
82 if(it->second->must_converge()) {
85 auto equil = it->second->is_equilibrated();
87 _log() << std::setw(24) << it->second->name()
88 << std::setw(20) << (equil.first ?
"true" :
"false");
90 _log() << std::setw(16) << equil.second << std::endl;
93 _log() << std::setw(16) <<
"unknown" << std::endl;
99 if(equil.second > max_equil_samples) {
100 max_equil_samples = equil.second;
110 _log() <<
"Overall equilibration at sample: " << max_equil_samples <<
"\n" << std::endl;
112 return m_is_equil = std::make_pair(
true, max_equil_samples);
147 _log() << std::boolalpha
148 << std::setw(24) <<
"quantity"
149 << std::setw(16) <<
"mean"
150 << std::setw(16) <<
"req_prec"
151 << std::setw(16) <<
"calc_prec"
152 << std::setw(16) <<
"is_converged"
158 [ = ](
const SamplerMap::value_type & val) {
159 if(val.second->must_converge()) {
160 bool result = val.second->is_converged(equil.second);
161 _log() << std::setw(24) << val.second->name()
162 << std::setw(16) << val.second->mean(equil.second)
163 << std::setw(16) << val.second->requested_precision()
164 << std::setw(16) << val.second->calculated_precision(equil.second)
165 << std::setw(16) << (result ?
"true" :
"false")
180 _log() <<
"Overall convergence?: " << std::boolalpha <<
m_is_converged <<
"\n" << std::endl;
void clear_samples()
Clear all data from all samplers.
std::pair< bool, MonteSampler::size_type > m_is_equil
bool m_is_converged_uptodate
std::pair< bool, MonteSampler::size_type > is_equilibrated() const
Returns pair(true, equil_samples) if required equilibration has occured for all samplers that must co...
SampleTimes m_sample_time
a vector of std::pair(pass, step) indicating when samples were taken
const ConfigDoF & configdof() const
const Access current microstate
bool operator()(const std::string &A, const std::string &B) const
Track the number of passes, steps and samples taken in a Monte Carlo calculation. ...
size_type pass() const
Number of complete passes performed.
MonteSampler::size_type m_next_convergence_check
SamplerMap m_sampler
a map of pair to MonteSampler
size_type step() const
Number of steps into the current pass.
bool is_converged() const
Check to see if all the properties required to converge have converged.
MCData::size_type size_type
void sample_data(const MonteCounter &counter)
Samples all requested property data, and stores pass and step number sample was taken at...
void _set_check_convergence_time() const
Set the next time convergence is due to be checked.
bool check_convergence_time() const
Returns true if a convergence check is due.
MonteSampler::size_type m_convergence_check_period
void check(const std::string &what)
std::vector< ConfigDoF > m_trajectory
Snapshots of the Monte Carlo simulation, taken by sample_data() if m_write_trajectory is true...
bool m_write_trajectory
Save trajectory?