1 #ifndef CASM_GrandCanonicalSettings_impl
2 #define CASM_GrandCanonicalSettings_impl
4 #include <boost/algorithm/string/trim.hpp>
21 template <
typename SamplerInsertIterator>
29 std::string prop_name;
30 std::string print_name;
36 std::string level1 =
"data";
37 std::string level2 =
"measurements";
38 jsonParser t_measurements = (*this)[level1][level2];
41 std::set<std::string> input_measurements;
42 for (
auto it = t_measurements.
cbegin(); it != t_measurements.
cend(); it++) {
43 input_measurements.insert((*it)[
"quantity"].get<std::string>());
46 std::vector<std::string> required = {
"potential_energy",
"formation_energy",
50 for (
auto it = required.begin(); it != required.end(); ++it) {
51 if (
std::find(input_measurements.begin(), input_measurements.end(), *it) ==
52 input_measurements.end()) {
54 json[
"quantity"] = *it;
60 for (
auto it = t_measurements.
cbegin(); it != t_measurements.
cend(); it++) {
61 prop_name = (*it)[
"quantity"].
get<std::string>();
64 std::vector<std::string> scalar_possible = {
"formation_energy",
68 if (
std::find(scalar_possible.cbegin(), scalar_possible.cend(),
69 prop_name) != scalar_possible.cend()) {
87 std::vector<std::string> vector_possible = {
88 "comp",
"comp_n",
"site_frac",
89 "atom_frac",
"all_correlations",
"non_zero_eci_correlations"};
92 if (
std::find(vector_possible.cbegin(), vector_possible.cend(),
93 prop_name) != vector_possible.cend()) {
95 if (prop_name ==
"comp") {
101 else if (prop_name ==
"comp_n") {
107 else if (prop_name ==
"site_frac") {
113 else if (prop_name ==
"atom_frac") {
119 else if (prop_name ==
"all_correlations") {
125 else if (prop_name ==
"non_zero_eci_correlations") {
136 }
catch (std::runtime_error &e) {
139 "'MonteSettings::samplers(const PrimClex &primclex, "
140 "SamplerInsertIterator result)'");
141 err_log <<
"Error reading [\"" << level1 <<
"\"][\"" << level2 <<
"\"]\n"
149 template <
typename jsonParserIteratorType>
151 jsonParserIteratorType it)
const {
152 if (it->contains(
"precision")) {
153 return std::make_tuple(
true, (*it)[
"precision"].
template get<double>());
155 return std::make_tuple(
false, 0.0);
159 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
162 SamplerInsertIterator result)
const {
164 std::string print_name;
172 std::string(
"comp(") + std::string(1, (
char)(i + ((
int)
'a'))) +
")";
192 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
195 SamplerInsertIterator result)
const {
197 std::string prop_name;
198 std::string print_name;
205 prop_name =
"comp_n";
207 print_name = std::string(
"comp_n(") +
228 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
231 SamplerInsertIterator result)
const {
233 std::string print_name;
241 print_name = std::string(
"site_frac(") +
263 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
266 SamplerInsertIterator result)
const {
268 std::string print_name;
290 print_name = std::string(
"atom_frac(") +
312 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
315 SamplerInsertIterator result)
const {
317 std::string prop_name;
318 std::string print_name;
347 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
348 SamplerInsertIterator
351 SamplerInsertIterator result)
const {
353 std::string prop_name;
354 std::string print_name;
388 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
391 SamplerInsertIterator result)
const {
393 double must_converge;
395 std::string prop_name = (*it)[
"quantity"].template get<std::string>();
401 std::shared_ptr<FormatterType> formatter =
402 std::make_shared<FormatterType>(dict.parse(prop_name));
409 auto col = formatter->get().col_header(
config);
411 if (test.size() != col.size()) {
412 std::stringstream ss;
413 ss <<
"Error constructing Monte Carlo samplers from query: '" << prop_name
417 err_log <<
"headers: " << col << std::endl;
418 err_log <<
" Some queries may not be available for sampling at this time."
420 throw std::runtime_error(ss.str());
423 for (
int i = 0; i < col.size(); ++i) {
424 std::string print_name = col[i];
425 boost::algorithm::trim(print_name);
std::vector< std::string > components() const
The order of components in mol composition vectors.
A sparse container of ECI values and their corresponding orbit indices.
const std::vector< size_type > & index() const
const Access orbit indices of ECI values
void error(const std::string &what)
static const int standard
Sampler for atom fraction.
Sampler for parametric composition.
size_type max_data_length() const
Figure out how large data containers should be.
SamplerInsertIterator _make_atom_frac_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
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
SamplerInsertIterator _make_site_frac_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
SamplerInsertIterator _make_comp_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
SamplerInsertIterator samplers(const PrimClex &primclex, SamplerInsertIterator result) const
Construct Samplers as specified in the Settings.
std::tuple< bool, double > _get_precision(jsonParserIteratorType it) const
SamplerInsertIterator _make_comp_n_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
SamplerInsertIterator _make_non_zero_eci_correlations_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
ClexDescription formation_energy(const PrimClex &primclex) const
Get formation energy cluster expansion.
An abstract base class for sampling and storing data observations.
const PrimClex & primclex() const
Monte::METHOD method() const
Return type of Monte Carlo method.
double confidence() const
Given a settings jsonParser figure out the global tolerance (probably for == operator)....
Eigen::Matrix3l simulation_cell_matrix() const
Supercell matrix defining the simulation cell.
Sampler for individual elements of a vector property.
Sampler for a scalar property.
Sampler for site fraction.
Sampler for individual elements of a vector property.
PrimClex is the top-level data structure for a CASM project.
QueryHandler< DataObject > & query_handler()
const std::vector< xtal::Site > & basis() const
Represents a supercell of the primitive parent crystal structure.
json_spirit::mObject::size_type size_type
const_iterator cend() const
Returns const_iterator to end of JSON object or JSON array.
const_iterator cbegin() const
Returns const_iterator to beginning of JSON object or JSON array.
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
std::string to_string(ENUM val)
Return string representation of enum class.
bool is_vacancy(const std::string &name)
A vacancy is any Specie/Molecule with (name == "VA" || name == "va" || name == "Va")
ProjectSettings & settings()
ECIContainer const & eci(const ClexDescription &key) const
Clexulator clexulator(std::string const &basis_set_name) const
const CompositionConverter & composition_axes() const
const Access CompositionConverter object
const PrimType & prim() const
const Access to primitive Structure
jsonParser & push_back(const T &value, Args &&... args)
T get(Args &&... args) const
Get data from json, using one of several alternatives.
ConfigIO::GenericConfigFormatter< jsonParser > config()
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.