CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SuperlatticeEnumeratorIO.cc
Go to the documentation of this file.
2 
7 
8 namespace CASM {
10  json.put_obj();
11  json["min"] = props.begin_volume();
12  json["max"] = props.end_volume() - 1;
13  json["dirs"] = props.dirs();
14  json["unit_cell"] = props.generating_matrix();
15  return json;
16 }
17 
31  const jsonParser &json) {
32  jsonParser tjson{json};
34 
35  std::runtime_error error_if_invalid{
36  "Error reading xtal::ScelEnumProps from JSON"};
37  report_and_throw_if_invalid(parser, CASM::log(), error_if_invalid);
38 
39  return *parser.value;
40 }
41 
43 void from_json(xtal::ScelEnumProps &props, const jsonParser &json) {
45 }
46 
49  int min, max;
50  std::string dirs;
51  std::string default_dirs{"abc"};
52  Eigen::Matrix3i generating_matrix;
53  Eigen::Matrix3i default_matrix{Eigen::Matrix3i::Identity()};
54  parser.require(min, "min");
55  parser.require(max, "max");
56  parser.optional_else(dirs, "dirs", default_dirs);
57  parser.optional_else(generating_matrix, "unit_cell", default_matrix);
58  parser.value = notstd::make_unique<xtal::ScelEnumProps>(min, max + 1, dirs,
59  generating_matrix);
60 }
61 } // namespace CASM
RequiredType optional_else(fs::path option, const RequiredType &_default, Args &&... args)
std::unique_ptr< RequiredType > require(fs::path option, Args &&... args)
std::unique_ptr< T > value
Definition: InputParser.hh:234
jsonParser & put_obj()
Puts new empty JSON object.
Definition: jsonParser.hh:354
Data structure for holding supercell enumeration properties.
Eigen::Matrix3i generating_matrix() const
IdentitySymRepBuilder Identity()
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
Log & log()
Definition: Log.hh:424
void from_json(ClexDescription &desc, const jsonParser &json)
T min(const T &A, const T &B)
Definition: CASM_math.hh:88
void report_and_throw_if_invalid(KwargsParser const &parser, Log &log, ErrorType error)
void parse(InputParser< ConfigEnumOptions > &parser, std::string method_name, PrimClex const &primclex, DataFormatterDictionary< Configuration > const &dict)
T max(const T &A, const T &B)
Definition: CASM_math.hh:95
static ReturnType from_json(const jsonParser &json)
Default from_json is equivalent to.
Definition: jsonParser.hh:551