1 #ifndef CASM_GrandCanonicalSettings
2 #define CASM_GrandCanonicalSettings
9 class GrandCanonicalConditions;
46 template<
typename SamplerInsertIterator>
58 template<
typename jsonParserIteratorType>
59 std::tuple<bool, double>
_get_precision(jsonParserIteratorType it)
const;
61 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
64 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
67 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
70 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
73 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
76 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
79 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
90 template<
typename SamplerInsertIterator>
93 SamplerInsertIterator result)
const {
100 std::string prop_name;
101 std::string print_name;
107 std::string level1 =
"data";
108 std::string level2 =
"measurements";
109 jsonParser t_measurements = (*this)[level1][level2];
112 std::set<std::string> input_measurements;
113 for(
auto it = t_measurements.
cbegin(); it != t_measurements.
cend(); it++) {
114 input_measurements.insert((*it)[
"quantity"].get<std::string>());
117 std::vector<std::string> required = {
125 for(
auto it = required.begin(); it != required.end(); ++it) {
126 if(
std::find(input_measurements.begin(), input_measurements.end(), *it) == input_measurements.end()) {
128 json[
"quantity"] = *it;
137 for(
auto it = t_measurements.
cbegin(); it != t_measurements.
cend(); it++) {
139 prop_name = (*it)[
"quantity"].
get<std::string>();
142 std::vector<std::string> scalar_possible = {
148 if(
std::find(scalar_possible.cbegin(), scalar_possible.cend(), prop_name) != scalar_possible.cend()) {
165 std::vector<std::string> vector_possible = {
171 "non_zero_eci_correlations"
175 if(
std::find(vector_possible.cbegin(), vector_possible.cend(), prop_name) != vector_possible.cend()) {
178 if(prop_name ==
"comp") {
185 else if(prop_name ==
"comp_n") {
192 else if(prop_name ==
"site_frac") {
199 else if(prop_name ==
"atom_frac") {
206 else if(prop_name ==
"all_correlations") {
213 else if(prop_name ==
"non_zero_eci_correlations") {
227 catch(std::runtime_error &e) {
229 err_log.
error<
Log::standard>(
"'MonteSettings::samplers(const PrimClex &primclex, SamplerInsertIterator result)'");
230 err_log <<
"Error reading [\"" << level1 <<
"\"][\"" << level2 <<
"\"]\n" << std::endl;
237 template<
typename jsonParserIteratorType>
239 if(it->contains(
"precision")) {
240 return std::make_tuple(
true, (*it)[
"precision"].
template get<double>());
243 return std::make_tuple(
false, 0.0);
247 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
250 jsonParserIteratorType it,
251 SamplerInsertIterator result)
const {
254 std::string print_name;
261 print_name = std::string(
"comp(") + std::string(1, (
char)(i + ((
int)
'a'))) +
")";
280 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
283 jsonParserIteratorType it,
284 SamplerInsertIterator result)
const {
287 std::string prop_name;
288 std::string print_name;
295 prop_name =
"comp_n";
316 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
319 jsonParserIteratorType it,
320 SamplerInsertIterator result)
const {
323 std::string print_name;
350 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
353 jsonParserIteratorType it,
354 SamplerInsertIterator result)
const {
357 std::string print_name;
401 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
404 jsonParserIteratorType it,
405 SamplerInsertIterator result)
const {
408 std::string prop_name;
409 std::string print_name;
436 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
439 jsonParserIteratorType it,
440 SamplerInsertIterator result)
const {
443 std::string prop_name;
444 std::string print_name;
478 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
481 jsonParserIteratorType it,
482 SamplerInsertIterator result)
const {
485 double must_converge;
487 std::string prop_name = (*it)[
"quantity"].template get<std::string>();
493 std::shared_ptr<FormatterType> formatter = std::make_shared<FormatterType>(
494 dict.parse(prop_name));
501 auto col = formatter->get().col_header(config);
503 if(test.size() != col.size()) {
504 std::stringstream ss;
505 ss <<
"Error constructing Monte Carlo samplers from query: '" << prop_name <<
"'";
506 primclex.
err_log() << ss.str();
507 primclex.
err_log() <<
"headers: " << col << std::endl;
508 primclex.
err_log() <<
" Some queries may not be available for sampling at this time." << std::endl;
509 throw std::runtime_error(ss.str());
512 for(
int i = 0; i < col.size(); ++i) {
514 std::string print_name = col[i];
515 boost::algorithm::trim(print_name);
Clexulator clexulator(const ClexDescription &key) const
Sampler for atom fraction.
Specifies a particular cluster expansion.
GrandCanonicalConditions _conditions(std::string name) const
GrandCanonicalConditions incremental_conditions() const
Expects incremental_conditions.
SamplerInsertIterator _make_site_frac_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
void init_occupation()
Set occupant variables to background structure.
const PrimClex & primclex() const
bool is_vacancy(const std::string &name)
A vacancy is any Specie/Molecule with (name == "VA" || name == "va" || name == "Va") ...
std::tuple< bool, double > _get_precision(jsonParserIteratorType it) const
size_type max_data_length() const
Figure out how large data containers should be.
std::vector< GrandCanonicalConditions > custom_conditions() const
Expects custom_conditions.
Sampler for a scalar property.
GrandCanonicalConditions final_conditions() const
Expects final_conditions.
An abstract base class for sampling and storing data observations.
size_type corr_size() const
Number of correlations.
std::string to_string(ENUM val)
Return string representation of enum class.
Represents a supercell of the primitive parent crystal structure.
Sampler for individual elements of a vector property.
const_iterator cend() const
Returns const_iterator to end of JSON object or JSON array.
T get(Args...args) const
Get data from json, using one of several alternatives.
GrandCanonicalSettings()
Default constructor.
std::vector< std::string > components() const
The order of components in mol composition vectors.
bool all_correlations() const
Return true if all correlations should be sampled.
static const int standard
json_spirit::mObject::size_type size_type
QueryHandler< DataObject > & query_handler()
Sampler for individual elements of a vector property.
Array< CoordType > basis
Lattice vectors that specifies periodicity of the crystal.
ProjectSettings & settings()
const std::vector< size_type > & index() const
const Access orbit indices of ECI values
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
PrimClex is the top-level data structure for a CASM project.
size_type independent_compositions() const
The dimensionality of the composition space.
const CompositionConverter & composition_axes() const
const Access CompositionConverter object
SamplerInsertIterator _make_comp_n_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
ClexDescription formation_energy(const PrimClex &primclex) const
Get formation energy cluster expansion.
Sampler for parametric composition.
SamplerInsertIterator _make_query_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
SamplerInsertIterator _make_all_correlations_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
jsonParser & push_back(const T &value)
Puts new valued element at end of array of any type T for which 'jsonParser& to_json( const T &value...
SamplerInsertIterator _make_atom_frac_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
GrandCanonicalConditions initial_conditions() const
Expects initial_conditions.
Monte::METHOD method() const
Return type of Monte Carlo method.
void error(const std::string &what)
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
SamplerInsertIterator _make_comp_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
SamplerInsertIterator samplers(const PrimClex &primclex, SamplerInsertIterator result) const
Construct MonteSamplers as specified in the MonteSettings.
Eigen::Matrix3i simulation_cell_matrix() const
Supercell matrix defining the simulation cell.
const_iterator cbegin() const
Returns const_iterator to beginning of JSON object or JSON array.
double confidence() const
Given a settings jsonParser figure out the global tolerance (probably for == operator). Expects tolerance/value.
Sampler for site fraction.
SamplerInsertIterator _make_non_zero_eci_correlations_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
A Configuration represents the values of all degrees of freedom in a Supercell.
const Structure & get_prim() const
const Access to primitive Structure
const ECIContainer & eci(const ClexDescription &key) const
A sparse container of ECI values and their corresponding orbit indices.