CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SymGroup_json_io.cc
Go to the documentation of this file.
2 
7 #include "casm/misc/CASM_math.hh"
12 
13 namespace CASM {
14 
15 // --------- SymmetryIO Declarations
16 // --------------------------------------------------
17 
18 void write_symop(SymGroup const &grp, Index i, jsonParser &j) {
19  j = jsonParser::object();
20 
21  const SymOp &op = grp[i];
22 
23  j["master_group_index"] = op.master_group_index();
24 
25  to_json(op.matrix(), j["CART"]["matrix"]);
26  to_json_array(op.tau(), j["CART"]["tau"]);
27  to_json(op.time_reversal(), j["CART"]["time_reversal"]);
28 
29  to_json(grp.lattice().inv_lat_column_mat() * op.matrix() *
30  grp.lattice().lat_column_mat(),
31  j["FRAC"]["matrix"]);
33  j["FRAC"]["tau"]);
34  to_json(op.time_reversal(), j["FRAC"]["time_reversal"]);
35 
36  to_json(grp.class_of_op(i) + 1, j["info"]["conjugacy_class"]);
37  to_json(grp.ind_inverse(i) + 1, j["info"]["inverse_operation"]);
38 
39  to_json(grp.info(i), j["info"]);
40 
42  j["info"]["brief"]["CART"]);
44  j["info"]["brief"]["FRAC"]);
45 }
46 
47 void write_symgroup(SymGroup const &grp, jsonParser &json) {
48  json = jsonParser::object();
49  {
50  jsonParser &json_ops = json["group_operations"];
51  for (int i = 0; i < grp.size(); i++) {
52  std::string op_name = "op_" + to_sequential_string(i + 1, grp.size());
53  write_symop(grp, i, json_ops[op_name]);
54  }
55  }
56  {
57  jsonParser &json_info = json["group_classification"];
58  json_info["name"] = grp.get_name();
59  json_info["latex_name"] = grp.get_latex_name();
60  json_info["periodicity"] = grp.periodicity();
61  if (grp.periodicity() == PERIODIC)
62  json_info["possible_space_groups"] = grp.possible_space_groups();
63  }
64 
65  {
66  jsonParser &json_struc = json["group_structure"];
67  auto const &classes = grp.get_conjugacy_classes();
68 
69  for (Index c = 0; c < classes.size(); ++c) {
70  std::string class_name =
71  "class_" + to_sequential_string(c + 1, classes.size());
72  jsonParser &json_class = json_struc["conjugacy_classes"][class_name];
73 
74  SymInfo info = grp.info(classes[c][0]);
75  json_class["operation_type"] = info.op_type;
76  if (info.op_type == symmetry_type::rotation_op ||
79  json_class["rotation_angle"] = info.angle;
80  }
81  json_class["operations"].put_array();
82  for (Index o : classes[c]) {
83  json_class["operations"].push_back(o + 1);
84  }
85  }
86  auto multi_table = grp.get_multi_table();
87  for (auto &v : multi_table) {
88  for (auto &i : v) {
89  ++i;
90  }
91  }
92  json_struc["multiplication_table"] = multi_table;
93  }
94 
95  // Character table excluded for now. Will revisit after SymGroup is refactored
96  // json["character_table"] = grp.character_table();
97 }
98 
119  jsonParser &group_rep_json,
120  SymGroupRepID symgrouprep_id) {
121  group_rep_json = jsonParser::array();
122  for (auto const &op : grp) {
123  jsonParser op_rep_json = jsonParser::object();
124  SymBasisPermute const &op_rep = *op.get_basis_permute_rep(symgrouprep_id);
125  op_rep_json["master_group_index"] = op_rep.master_group_index();
126  op_rep_json["matrix"] = op_rep.matrix();
127  op_rep_json["sublattice_permute"] = jsonParser::array();
128  op_rep_json["sublattice_shift"] = jsonParser::array();
129  for (auto const integral_coordinate : op_rep.data()) {
130  op_rep_json["sublattice_permute"].push_back(
131  integral_coordinate.sublattice());
132 
133  jsonParser tjson;
134  to_json(integral_coordinate.unitcell(), tjson, jsonParser::as_flattest());
135  op_rep_json["sublattice_shift"].push_back(tjson);
136  }
137  group_rep_json.push_back(op_rep_json);
138  }
139 }
140 
146  std::vector<SymGroupRepID> occupant_symrep_IDs) {
147  json = jsonParser::array();
148  for (auto symrep_ID : occupant_symrep_IDs) {
149  jsonParser sublattice_json = jsonParser::array();
150  for (auto const &op : grp) {
151  Permutation const &permute = *op.get_permutation_rep(symrep_ID);
152  jsonParser permute_json;
153  to_json(permute, permute_json);
154  sublattice_json.push_back(permute_json);
155  }
156  json.push_back(sublattice_json);
157  }
158 }
159 
161  json = jsonParser::array();
162  for (Index i = 0; i < grp.size(); ++i) {
163  json.push_back(*grp[i]->MatrixXd());
164  }
165 }
166 
167 } // namespace CASM
SymBasisPermute describes how a symmetry operation permutes atoms in a basis.
const Eigen::Matrix3l & matrix() const
Get underlying integer transformation amtrix.
const std::vector< UnitCellCoord > & data() const
Get underlying data (data()[b] is the result of transforming (b,0,0,0))
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
const std::string & get_latex_name() const
Definition: SymGroup.cc:1687
PERIODICITY_TYPE periodicity() const
Definition: SymGroup.hh:191
const std::string & get_name() const
Definition: SymGroup.cc:1668
Index ind_inverse(Index i) const
Get index of operation that is inverse of operation at(i)
Definition: SymGroup.cc:1540
const std::vector< std::vector< Index > > & get_multi_table() const
Definition: SymGroup.cc:1633
Index class_of_op(Index i) const
Get conjugacy class index of operation at(i)
Definition: SymGroup.cc:1565
const std::vector< std::vector< Index > > & get_conjugacy_classes() const
Definition: SymGroup.cc:1661
std::string possible_space_groups() const
Definition: SymGroup.hh:193
SymInfo info(Index i) const
Definition: SymGroup.cc:942
const Lattice & lattice() const
Lattice used for periodic comparisons (for instance, to generate multiplcation table)
Definition: SymGroup.cc:950
Index size() const
Size of the associated SymGroupRep.
Definition: SymGroupRep.hh:210
Type-safe ID object for communicating and accessing Symmetry representation info.
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
const matrix_type & matrix() const
Const access of entire cartesian symmetry matrix.
Definition: SymOp.hh:60
bool time_reversal() const
Const access of the time-reversal flag (true if operation reverses time)
Definition: SymOp.hh:66
const vector_type & tau() const
Const access of the cartesian translation vector, 'tau'.
Definition: SymOp.hh:63
SymBasisPermute const * get_basis_permute_rep(SymGroupRepID _rep_ID) const
get pointer to BasisPermute representation corresponding to _rep_ID
Index master_group_index() const
Index of this operation within the master_group.
static jsonParser object()
Returns an empty json object.
Definition: jsonParser.hh:395
static jsonParser array()
Returns an empty json array.
Definition: jsonParser.hh:409
jsonParser & put_array()
Puts new empty JSON array.
Definition: jsonParser.hh:362
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
Definition: Lattice.hh:110
const Eigen::Matrix3d & inv_lat_column_mat() const
Inverse of Lattice::lat_column_mat() It is the transformation matrix 'C2F', such that f = C2F * c whe...
Definition: Lattice.hh:117
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
jsonParser & push_back(const T &value, Args &&... args)
Definition: jsonParser.hh:684
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
void write_matrix_rep(SymGroupRepHandle const &grp, jsonParser &json)
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
std::string to_brief_unicode(const SymInfo &info, SymInfoOptions opt=SymInfoOptions())
Print symmetry symbol to string.
const COORD_TYPE FRAC
Definition: enum.hh:8
std::string to_sequential_string(Index i, Index max_i, char prepend_char='0')
Definition: CASM_math.cc:248
const PERIODICITY_TYPE PERIODIC
Definition: enum.hh:20
void write_symop(SymGroup const &grp, Index i, jsonParser &j)
void write_symgroup(SymGroup const &grp, jsonParser &json)
void write_occ_permutation_rep(SymGroup const &grp, jsonParser &json, std::vector< SymGroupRepID > occupant_symrep_IDs)
void write_basis_permutation_rep(SymGroup const &grp, jsonParser &json, SymGroupRepID symgrouprep_id)
Describes how integral site coordinates transform under application of symmetry.
const COORD_TYPE CART
Definition: enum.hh:9
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Simple struct to be used as return type for SymOp::info().
Definition: SymInfo.hh:26
double angle
Definition: SymInfo.hh:42
symmetry_type op_type
Definition: SymInfo.hh:31
Options for printing SymInfo.