CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigMapping_json_io.cc
Go to the documentation of this file.
2 
6 
7 namespace CASM {
8 
9 //--ConfigMapping::Settings------------------------------------------------
10 
12  _json["lattice_weight"] = _set.lattice_weight;
13  _json["ideal"] = _set.ideal;
14  _json["strict"] = _set.strict;
15  _json["primitive_only"] = _set.primitive_only;
16  _json["robust"] = _set.robust;
17  _json["fix_volume"] = _set.fix_volume;
18  _json["fix_lattice"] = _set.fix_lattice;
19  _json["k_best"] = _set.k_best;
20  if (!_set.forced_lattices.empty())
21  _json["forced_lattices"] = _set.forced_lattices;
22  if (!_set.filter.empty()) _json["filter"] = _set.filter;
23  _json["cost_tol"] = _set.cost_tol;
24  _json["min_va_frac"] = _set.min_va_frac;
25  _json["max_va_frac"] = _set.max_va_frac;
26  _json["max_vol_change"] = _set.max_vol_change;
27 
28  return _json;
29 }
30 
32  jsonParser const &_json) {
33  _set.set_default();
34 
35  if (_json.contains("lattice_weight"))
36  _set.lattice_weight = _json["lattice_weight"].get<double>();
37 
38  if (_json.contains("ideal")) _set.ideal = _json["ideal"].get<bool>();
39 
40  if (_json.contains("strict")) _set.strict = _json["strict"].get<bool>();
41 
42  if (_json.contains("robust")) _set.robust = _json["robust"].get<bool>();
43 
44  if (_json.contains("primitive_only"))
45  _set.primitive_only = _json["primitive_only"].get<bool>();
46 
47  if (_json.contains("fix_volume"))
48  _set.fix_volume = _json["fix_volume"].get<bool>();
49 
50  if (_json.contains("fix_lattice"))
51  _set.fix_lattice = _json["fix_lattice"].get<bool>();
52 
53  if (_json.contains("k_best")) {
54  _set.k_best = _json["k_best"].get<Index>();
55  }
56 
57  if (_json.contains("forced_lattices"))
58  _set.forced_lattices =
59  _json["forced_lattices"].get<std::vector<std::string> >();
60 
61  if (_json.contains("filter"))
62  _set.filter = _json["filter"].get<std::string>();
63 
64  if (_json.contains("cost_tol"))
65  _set.cost_tol = _json["cost_tol"].get<double>();
66 
67  if (_json.contains("min_va_frac"))
68  _set.min_va_frac = _json["min_va_frac"].get<double>();
69 
70  if (_json.contains("max_va_frac"))
71  _set.max_va_frac = _json["max_va_frac"].get<double>();
72 
73  if (_json.contains("max_vol_change"))
74  _set.max_vol_change = _json["max_vol_change"].get<double>();
75 
76  return _json;
77 }
78 
79 } // namespace CASM
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
Definition: jsonParser.cc:601
T get(Args &&... args) const
Get data from json, using one of several alternatives.
Definition: jsonParser.hh:716
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void from_json(ClexDescription &desc, const jsonParser &json)
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Struct with optional parameters for Config Mapping Specifies default parameters for all values,...
double cost_tol
Tolerance used to determine if two mappings have identical cost.
std::vector< std::string > forced_lattices