CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CompositionConverter_json_io.cc
Go to the documentation of this file.
2 
5 
6 namespace CASM {
7 
10  json = jsonParser::object();
11  json["components"] = f.components();
12  json["independent_compositions"] = f.independent_compositions();
13  json["origin"] = f.origin();
14  for (int i = 0; i < f.independent_compositions(); i++) {
16  }
17  json["mol_formula"] = f.mol_formula();
18  json["param_formula"] = f.param_formula();
19 
20  return json;
21 }
22 
24 void from_json(CompositionConverter &f, const jsonParser &json) {
25  std::vector<std::string> components;
26  Eigen::VectorXd origin;
27 
28  int independent_compositions;
29 
30  from_json(components, json["components"]);
31  from_json(origin, json["origin"]);
32 
33  from_json(independent_compositions, json["independent_compositions"]);
34  Eigen::MatrixXd end_members(components.size(), independent_compositions);
35  Eigen::VectorXd tvec;
36  for (int i = 0; i < independent_compositions; i++) {
38  end_members.col(i) = tvec;
39  }
40 
41  f = CompositionConverter(components.begin(), components.end(), origin,
42  end_members);
43  return;
44 }
45 
46 } // namespace CASM
Convert between number of species per unit cell and parametric composition.
Eigen::VectorXd end_member(size_type i) const
The mol composition of the parameteric composition axes end members.
std::string param_formula() const
Return formula for n->x.
static std::string comp_var(size_type i)
Composition variable names: "a", "b", ...
Eigen::VectorXd origin() const
The mol composition of the parameteric composition axes origin.
size_type independent_compositions() const
The dimensionality of the composition space.
std::string mol_formula() const
Return formula for x->n.
std::vector< std::string > components() const
The order of components in mol composition vectors.
static jsonParser object()
Returns an empty json object.
Definition: jsonParser.hh:395
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void from_json(ClexDescription &desc, const jsonParser &json)
Eigen::MatrixXd end_members(const ParamComposition::AllowedOccupants &_allowed_occs)
Serialize CompositionConverter to JSON.
Eigen::VectorXd VectorXd