1 #ifndef CASM_CanonicalSettings_impl
2 #define CASM_CanonicalSettings_impl
4 #include <boost/algorithm/string/trim.hpp>
20 template <
typename SamplerInsertIterator>
24 std::string prop_name;
25 std::string print_name;
31 std::string level1 =
"data";
32 std::string level2 =
"measurements";
33 jsonParser t_measurements = (*this)[level1][level2];
36 std::set<std::string> input_measurements;
37 for (
auto it = t_measurements.
cbegin(); it != t_measurements.
cend(); it++) {
38 input_measurements.insert((*it)[
"quantity"].get<std::string>());
41 std::vector<std::string> required = {
"potential_energy",
"formation_energy"};
44 for (
auto it = required.begin(); it != required.end(); ++it) {
45 if (
std::find(input_measurements.begin(), input_measurements.end(), *it) ==
46 input_measurements.end()) {
48 json[
"quantity"] = *it;
54 for (
auto it = t_measurements.
cbegin(); it != t_measurements.
cend(); it++) {
55 prop_name = (*it)[
"quantity"].
get<std::string>();
58 std::vector<std::string> scalar_possible = {
"formation_energy",
62 if (
std::find(scalar_possible.cbegin(), scalar_possible.cend(),
63 prop_name) != scalar_possible.cend()) {
81 std::vector<std::string> vector_possible = {
"all_correlations",
82 "non_zero_eci_correlations"};
85 if (
std::find(vector_possible.cbegin(), vector_possible.cend(),
86 prop_name) != vector_possible.cend()) {
88 if (prop_name ==
"all_correlations") {
94 else if (prop_name ==
"non_zero_eci_correlations") {
105 }
catch (std::runtime_error &e) {
108 "'MonteSettings::samplers(const PrimClex &primclex, "
109 "SamplerInsertIterator result)'");
110 err_log <<
"Error reading [\"" << level1 <<
"\"][\"" << level2 <<
"\"]\n"
118 template <
typename jsonParserIteratorType>
120 jsonParserIteratorType it)
const {
121 if (it->contains(
"precision")) {
122 return std::make_tuple(
true, (*it)[
"precision"].
template get<double>());
124 return std::make_tuple(
false, 0.0);
128 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
131 SamplerInsertIterator result)
const {
133 std::string prop_name;
134 std::string print_name;
163 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
164 SamplerInsertIterator
167 SamplerInsertIterator result)
const {
169 std::string prop_name;
170 std::string print_name;
204 template <
typename jsonParserIteratorType,
typename SamplerInsertIterator>
207 SamplerInsertIterator result)
const {
209 double must_converge;
211 std::string prop_name = (*it)[
"quantity"].template get<std::string>();
217 std::shared_ptr<FormatterType> formatter =
218 std::make_shared<FormatterType>(dict.parse(prop_name));
225 auto col = formatter->get().col_header(
config);
227 if (test.size() != col.size()) {
228 std::stringstream ss;
229 ss <<
"Error constructing Monte Carlo samplers from query: '" << prop_name
233 err_log <<
"headers: " << col << std::endl;
234 err_log <<
" Some queries may not be available for sampling at this time."
236 throw std::runtime_error(ss.str());
239 for (
int i = 0; i < col.size(); ++i) {
240 std::string print_name = col[i];
241 boost::algorithm::trim(print_name);
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
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.
std::tuple< bool, double > _get_precision(jsonParserIteratorType it) const
SamplerInsertIterator samplers(const PrimClex &primclex, SamplerInsertIterator result) const
Construct MonteSamplers as specified in the MonteSettings.
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
size_type max_data_length() const
Figure out how large data containers should be.
An abstract base class for sampling and storing data observations.
const PrimClex & primclex() const
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 individual elements of a vector property.
PrimClex is the top-level data structure for a CASM project.
QueryHandler< DataObject > & query_handler()
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.
ProjectSettings & settings()
ECIContainer const & eci(const ClexDescription &key) const
Clexulator clexulator(std::string const &basis_set_name) const
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.