1 #ifndef CASM_MonteSampler_HH
2 #define CASM_MonteSampler_HH
29 MonteSampler(
const std::string &print_name,
double data_confidence,
33 MonteSampler(
const std::string &print_name,
double data_prec,
34 double data_confidence,
size_type data_initsize);
39 throw std::runtime_error(
"Error: MonteSampler base class used to sample");
134 std::unique_ptr<MonteSampler>
clone()
const {
135 return std::unique_ptr<MonteSampler>(this->
_clone());
189 double data_confidence,
size_type data_initsize);
193 double data_prec,
double data_confidence,
200 std::unique_ptr<ScalarMonteSampler>
clone()
const {
201 return std::unique_ptr<ScalarMonteSampler>(this->
_clone());
218 std::string print_name,
double data_confidence,
223 std::string print_name,
double data_prec,
224 double data_confidence,
size_type data_initsize);
230 std::unique_ptr<VectorMonteSampler>
clone()
const {
231 return std::unique_ptr<VectorMonteSampler>(this->
_clone());
271 size_type _index, std::string print_name,
272 double data_confidence,
size_type data_initsize);
276 size_type _index, std::string print_name,
double data_prec,
277 double data_confidence,
size_type data_initsize);
283 std::unique_ptr<QueryMonteSampler>
clone()
const {
284 return std::unique_ptr<QueryMonteSampler>(this->
_clone());
305 std::string print_name,
double data_confidence,
311 std::string print_name,
double data_prec,
312 double data_confidence,
size_type data_initsize);
318 std::unique_ptr<CompMonteSampler>
clone()
const {
319 return std::unique_ptr<CompMonteSampler>(this->
_clone());
340 std::string print_name,
double data_confidence,
345 std::string print_name,
double data_prec,
346 double data_confidence,
size_type data_initsize);
352 std::unique_ptr<SiteFracMonteSampler>
clone()
const {
353 return std::unique_ptr<SiteFracMonteSampler>(this->
_clone());
374 std::string print_name,
double data_confidence,
379 std::string print_name,
double data_prec,
380 double data_confidence,
size_type data_initsize);
386 std::unique_ptr<AtomFracMonteSampler>
clone()
const {
387 return std::unique_ptr<AtomFracMonteSampler>(this->
_clone());
Convert between number of species per unit cell and parametric composition.
Sampler for atom fraction.
void sample(const MonteCarlo &mc, const MonteCounter &counter)
Sample data from a MonteCarlo calculation.
virtual AtomFracMonteSampler * _clone() const
AtomFracMonteSampler(size_type _index, size_type _vacancy_index, std::string print_name, double data_confidence, size_type data_initsize)
Construct sampler that does not need to converge.
std::unique_ptr< AtomFracMonteSampler > clone() const
Clone this object.
size_type m_vacancy_index
Sampler for parametric composition.
virtual CompMonteSampler * _clone() const
void sample(const MonteCarlo &mc, const MonteCounter &counter)
Sample data from a MonteCarlo calculation.
std::unique_ptr< CompMonteSampler > clone() const
Clone this object.
CompositionConverter m_comp_converter
CompMonteSampler(size_type _index, const CompositionConverter &_comp_converter, std::string print_name, double data_confidence, size_type data_initsize)
Construct sampler that does not need to converge.
Checks if a range of observations have converged.
bool is_converged(double prec) const
Returns true if converged to the requested level.
double calculated_precision() const
Calculated precision of <X>
double squared_norm() const
<X*X>
Checks if a range of observations have equilibrated.
size_type equilibration_samples() const
bool is_equilibrated() const
MCData stores observations of properties.
void clear()
Forget all the observed values (does not resize reserved space)
Eigen::VectorBlock< const Eigen::VectorXd > observations() const
Return all observations.
size_type size() const
Number of observations.
Interface base class for all types of Monte Carlo simulations (not meant to be used polymorphically)
Track the number of passes, steps and samples taken in a Monte Carlo calculation.
An abstract base class for sampling and storing data observations.
MonteSampler(const std::string &print_name, double data_confidence, size_type data_initsize)
Construct sampler that does not need to converge.
bool m_must_converge
If false, data observations are recorded but shouldn't be used to determine if Monte Carlo run has co...
bool is_converged(size_type equil_samples) const
Returns true if convergence criteria have been met for data sampled in range [equil_samples,...
std::string name() const
Property name for printing.
bool m_equilibration_uptodate
size_type m_convergence_start_sample
std::unique_ptr< MonteSampler > clone() const
Clone this object.
virtual MonteSampler * _clone() const
std::string m_name
Property name for printing.
void _check_convergence(size_type equil_samples) const
const MCData & data() const
const Access the raw data observation container
MCData m_data
An array of observations, one for every so many steps or passes.
double calculated_precision(size_type equil_samples) const
Returns calculated precision on the mean for data sampled in range [equil_samples,...
bool must_converge() const
Returns true if convergence criteria must be met for Monte Carlo calculation to be complete.
bool m_convergence_uptodate
std::pair< bool, size_type > is_equilibrated() const
Returns pair(true, equil_steps) if equilibration has occured to required precision.
virtual void sample(const MonteCarlo &mc, const MonteCounter &counter)
double requested_precision() const
Returns requested precision on the mean.
double mean(size_type equil_samples) const
Returns <X> for data sampled in range [equil_samples, end)
MCDataEquilibration m_equilibration
MCDataConvergence m_convergence
void clear()
Clear all data observations.
MCData & data()
Access the raw data observation container.
double squared_norm(size_type equil_samples) const
Returns <X*X> for data sampled in range [equil_samples, end)
double m_prec
Requested precision, if must_converge.
double m_conf
Requested confidence, if must_converge.
Sampler for individual elements of a vector property.
std::shared_ptr< QueryMonteSampler::Formatter > m_formatter
QueryMonteSampler(std::shared_ptr< QueryMonteSampler::Formatter > formatter, size_type _index, std::string print_name, double data_confidence, size_type data_initsize)
Construct sampler that does not need to converge.
void sample(const MonteCarlo &mc, const MonteCounter &counter)
Sample data from a MonteCarlo calculation.
virtual QueryMonteSampler * _clone() const
std::unique_ptr< QueryMonteSampler > clone() const
Clone this object.
Sampler for a scalar property.
ScalarMonteSampler(std::string _property_name, std::string print_name, double data_confidence, size_type data_initsize)
Construct sampler that does not need to converge.
void sample(const MonteCarlo &mc, const MonteCounter &counter)
Sample data from a MonteCarlo calculation.
std::unique_ptr< ScalarMonteSampler > clone() const
Clone this object.
std::string m_property_name
virtual ScalarMonteSampler * _clone() const
Sampler for site fraction.
std::unique_ptr< SiteFracMonteSampler > clone() const
Clone this object.
virtual SiteFracMonteSampler * _clone() const
SiteFracMonteSampler(size_type _index, size_type _basis_size, std::string print_name, double data_confidence, size_type data_initsize)
Construct sampler that does not need to converge.
void sample(const MonteCarlo &mc, const MonteCounter &counter)
Sample data from a MonteCarlo calculation.
Sampler for individual elements of a vector property.
std::string m_property_name
std::unique_ptr< VectorMonteSampler > clone() const
Clone this object.
VectorMonteSampler(std::string _property_name, size_type _index, std::string print_name, double data_confidence, size_type data_initsize)
Construct sampler that does not need to converge.
virtual VectorMonteSampler * _clone() const
void sample(const MonteCarlo &mc, const MonteCounter &counter)
Sample data from a MonteCarlo calculation.