CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
SymPermutation.cc
Go to the documentation of this file.
2 
5 
6 namespace CASM {
7 
8  double SymPermutation::character() const {
9  int n_fix(0);
10  for(Index i = 0; i < m_permute.size(); i++) {
11  n_fix += int(i == m_permute[i]);
12  }
13  return n_fix;
14  }
15 
16  //*******************************************************************************************
17 
18  //Makes permutation matrix from m_permute
19  //Permute matrix P reorders elements of a column vector v via
20  // v' = P*v
21  //Therefore, we loop over m_permute and assign ones to the
22  //appropriate row/column
23 
25  m_mat.resize(m_permute.size(), m_permute.size());
26  m_mat.setZero();
27  for(Index i = 0; i < m_permute.size(); i++)
28  m_mat(i, m_permute[i]) = 1;
29  return;
30  }
31 
32  //*******************************************************************************************
33 
35  json.put_obj();
36 
37  // Members not included:
38  //
39  // From SymOpRepresentation:
40  // MasterSymGroup const *head_group;
41 
42  json["SymOpRep_type"] = "SymPermutation";
43 
44  json["op_index"] = index();
45  json["rep_ID"] = rep_ID();
46 
47  json["m_permute"] = m_permute;
48  if(m_has_mat)
49  json["m_mat"] = m_mat;
50  return json;
51  }
52 
53  //*******************************************************************************************
54 
56  try {
57  CASM::from_json(m_op_index, json["op_index"]);
58  CASM::from_json(m_rep_ID, json["rep_ID"]);
59 
60  CASM::from_json(m_permute, json["m_permute"]);
61  CASM::from_json(m_mat, json["m_mat"]);
62  }
63  catch(...) {
65  throw;
66  }
67  }
68 
69  //*******************************************************************************************
70 
72  return sym.to_json(json);
73  }
74 
75  //*******************************************************************************************
76 
77  void from_json(SymPermutation &sym, const jsonParser &json) {
78  try {
79  sym.from_json(json);
80  }
81  catch(...) {
83  throw;
84  }
85  }
86 
87 }
void _calc_mat() const
Generate the matrix of permutation, when m_permute is known.
void from_json(ClexDescription &desc, const jsonParser &json)
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
Index index() const
Index of this operation within the master_group.
Main CASM namespace.
Definition: complete.cpp:8
SymGroupRepID m_rep_ID
ID of this representation within the master_group. Default is uninitialized.
Index m_op_index
Index into MasterSymGroup that specifies the operation.
SymPermutation describes how a symmetry operation permutes a list of 'things' For example...
EigenIndex Index
For long integer indexing:
double character() const override
Calculates character of the representation (if well-defined)
Index size() const
Definition: Permutation.hh:53
jsonParser & to_json(jsonParser &json) const override
Eigen::MatrixXd m_mat
SymGroupRepID rep_ID() const
ID of representation that this operation belongs to within the master_group.
jsonParser & put_obj()
Puts new empty JSON object.
Definition: jsonParser.hh:276
void from_json(const jsonParser &json) override