1 #ifndef CASM_CanonicalSettings
2 #define CASM_CanonicalSettings
10 class CanonicalConditions;
47 template<
typename SamplerInsertIterator>
61 template<
typename jsonParserIteratorType>
62 std::tuple<bool, double>
_get_precision(jsonParserIteratorType it)
const;
64 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
67 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
70 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
81 template<
typename SamplerInsertIterator>
84 SamplerInsertIterator result)
const {
87 std::string prop_name;
88 std::string print_name;
94 std::string level1 =
"data";
95 std::string level2 =
"measurements";
96 jsonParser t_measurements = (*this)[level1][level2];
99 std::set<std::string> input_measurements;
100 for(
auto it = t_measurements.
cbegin(); it != t_measurements.
cend(); it++) {
101 input_measurements.insert((*it)[
"quantity"].get<std::string>());
104 std::vector<std::string> required = {
110 for(
auto it = required.begin(); it != required.end(); ++it) {
111 if(
std::find(input_measurements.begin(), input_measurements.end(), *it) == input_measurements.end()) {
113 json[
"quantity"] = *it;
122 for(
auto it = t_measurements.
cbegin(); it != t_measurements.
cend(); it++) {
124 prop_name = (*it)[
"quantity"].
get<std::string>();
127 std::vector<std::string> scalar_possible = {
133 if(
std::find(scalar_possible.cbegin(), scalar_possible.cend(), prop_name) != scalar_possible.cend()) {
150 std::vector<std::string> vector_possible = {
152 "non_zero_eci_correlations"
156 if(
std::find(vector_possible.cbegin(), vector_possible.cend(), prop_name) != vector_possible.cend()) {
159 if(prop_name ==
"all_correlations") {
166 else if(prop_name ==
"non_zero_eci_correlations") {
180 catch(std::runtime_error &e) {
182 err_log.
error<
Log::standard>(
"'MonteSettings::samplers(const PrimClex &primclex, SamplerInsertIterator result)'");
183 err_log <<
"Error reading [\"" << level1 <<
"\"][\"" << level2 <<
"\"]\n" << std::endl;
190 template<
typename jsonParserIteratorType>
192 if(it->contains(
"precision")) {
193 return std::make_tuple(
true, (*it)[
"precision"].
template get<double>());
196 return std::make_tuple(
false, 0.0);
200 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
203 jsonParserIteratorType it,
204 SamplerInsertIterator result)
const {
207 std::string prop_name;
208 std::string print_name;
235 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
238 jsonParserIteratorType it,
239 SamplerInsertIterator result)
const {
242 std::string prop_name;
243 std::string print_name;
277 template<
typename jsonParserIteratorType,
typename SamplerInsertIterator>
280 jsonParserIteratorType it,
281 SamplerInsertIterator result)
const {
284 double must_converge;
286 std::string prop_name = (*it)[
"quantity"].template get<std::string>();
292 std::shared_ptr<FormatterType> formatter = std::make_shared<FormatterType>(
293 dict.parse(prop_name));
300 auto col = formatter->get().col_header(config);
302 if(test.size() != col.size()) {
303 std::stringstream ss;
304 ss <<
"Error constructing Monte Carlo samplers from query: '" << prop_name <<
"'";
305 primclex.
err_log() << ss.str();
306 primclex.
err_log() <<
"headers: " << col << std::endl;
307 primclex.
err_log() <<
" Some queries may not be available for sampling at this time." << std::endl;
308 throw std::runtime_error(ss.str());
311 for(
int i = 0; i < col.size(); ++i) {
313 std::string print_name = col[i];
314 boost::algorithm::trim(print_name);
Clexulator clexulator(const ClexDescription &key) const
CanonicalConditions _conditions(std::string name) const
CanonicalSettings()
Default constructor.
Specifies a particular cluster expansion.
void init_occupation()
Set occupant variables to background structure.
const PrimClex & primclex() const
bool all_correlations() const
Return true if all correlations should be sampled.
CanonicalConditions initial_conditions() const
Expects initial_conditions.
size_type max_data_length() const
Figure out how large data containers should be.
ClexDescription formation_energy(const PrimClex &primclex) const
Get formation energy cluster expansion.
Sampler for a scalar property.
An abstract base class for sampling and storing data observations.
size_type corr_size() const
Number of correlations.
SamplerInsertIterator samplers(const PrimClex &primclex, SamplerInsertIterator result) const
Construct MonteSamplers as specified in the MonteSettings.
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.
std::vector< CanonicalConditions > custom_conditions() const
Expects custom_conditions.
T get(Args...args) const
Get data from json, using one of several alternatives.
static const int standard
CanonicalConditions incremental_conditions() const
Expects incremental_conditions.
json_spirit::mObject::size_type size_type
CanonicalConditions final_conditions() const
Expects final_conditions.
QueryHandler< DataObject > & query_handler()
SamplerInsertIterator _make_non_zero_eci_correlations_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
Sampler for individual elements of a vector property.
std::tuple< bool, double > _get_precision(jsonParserIteratorType it) const
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.
SamplerInsertIterator _make_all_correlations_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
CompositionConverter m_comp_converter
Convert between number of species per unit cell and parametric composition.
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...
void error(const std::string &what)
SamplerInsertIterator _make_query_samplers(const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
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.
A Configuration represents the values of all degrees of freedom in a Supercell.
const ECIContainer & eci(const ClexDescription &key) const
A sparse container of ECI values and their corresponding orbit indices.