CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SymInfo_json_io.cc
Go to the documentation of this file.
2 
8 
9 namespace CASM {
10 
12 
14  json.put_obj();
15  json[traits<COORD_TYPE>::name] = opt.coord_type;
16  json["tol"] = opt.tol;
17  json["prec"] = opt.prec;
18  json["print_matrix_tau"] = opt.print_matrix_tau;
19  return json;
20 }
21 
23 void from_json(SymInfoOptions &opt, const jsonParser &json) {
25  json.get_if(opt.tol, "tol");
26  json.get_if(opt.prec, "prec");
27  json.get_if(opt.print_matrix_tau, "print_matrix_tau");
28 }
29 
31  const jsonParser &json) {
32  SymInfoOptions res;
33  CASM::from_json(res, json);
34  return res;
35 }
36 
38 void to_json(const SymInfo &info, jsonParser &j) {
40  j["type"] = info.op_type;
41 
42  if (info.op_type == symmetry_type::rotation_op ||
45  to_json_array(info.axis.const_cart().normalized(),
46  j["rotation_axis"]["CART"]);
47  to_json_array(info.axis.const_frac().normalized(),
48  j["rotation_axis"]["FRAC"]);
49  j["rotation_angle"] = info.angle;
50  } else if (info.op_type == symmetry_type::mirror_op ||
52  to_json_array(info.axis.const_cart().normalized(),
53  j["mirror_normal"]["CART"]);
54  to_json_array(info.axis.const_frac().normalized(),
55  j["mirror_normal"]["FRAC"]);
56  }
57 
58  if (info.op_type == symmetry_type::screw_op ||
60  to_json_array(info.screw_glide_shift.const_cart(), j["shift"]["CART"]);
61  to_json_array(info.screw_glide_shift.const_frac(), j["shift"]["FRAC"]);
62  }
63 
64  if (info.op_type != symmetry_type::identity_op) {
65  to_json_array(info.location.const_cart(), j["invariant_point"]["CART"]);
66  to_json_array(info.location.const_frac(), j["invariant_point"]["FRAC"]);
67  }
68 }
69 
70 } // namespace CASM
#define ENUM_JSON_IO_DEF(ENUM)
Definition: json_io.hh:15
jsonParser & put_obj()
Puts new empty JSON object.
Definition: jsonParser.hh:354
const vector_type & const_frac() const
user override to force const Access the fractional coordinate vector
Definition: Coordinate.hh:68
const vector_type & const_cart() const
user override to force const Access the Cartesian coordinate vector
Definition: Coordinate.hh:90
symmetry_type
Definition: SymInfo.hh:14
bool get_if(T &t, const std::string &key, Args &&... args) const
Definition: jsonParser.hh:740
CASM::jsonParser & to_json_array(const Eigen::MatrixBase< Derived > &value, CASM::jsonParser &json)
Write Eigen Matrix with 1 row or 1 column to JSON array.
Definition: json_io.hh:313
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void from_json(ClexDescription &desc, const jsonParser &json)
Simple struct to be used as return type for SymOp::info().
Definition: SymInfo.hh:26
double angle
Definition: SymInfo.hh:42
xtal::Coordinate axis
Definition: SymInfo.hh:38
symmetry_type op_type
Definition: SymInfo.hh:31
xtal::Coordinate screw_glide_shift
Definition: SymInfo.hh:46
xtal::Coordinate location
A Cartesian coordinate that is invariant to the operation (if one exists)
Definition: SymInfo.hh:49
Options for printing SymInfo.
static ReturnType from_json(const jsonParser &json)
Default from_json is equivalent to.
Definition: jsonParser.hh:551