CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
SymOpRepresentation.cc
Go to the documentation of this file.
5 
6 namespace CASM {
7 
8  //*******************************************************************************************
10  assert(has_valid_master() && !_rep_ID.empty());
11  return (master_group().representation(_rep_ID)[index()])->get_MatrixXd();
12  }
13 
14  //*******************************************************************************************
15 
17  assert(has_valid_master() && !_rep_ID.empty());
18  return (master_group().representation(_rep_ID)[index()])->get_ucc_permutation();
19  }
20  //*******************************************************************************************
21 
23  assert(has_valid_master() && !_rep_ID.empty());
24  return (master_group().representation(_rep_ID)[index()])->get_permutation();
25  }
26 
27  //*******************************************************************************************
28 
31  for(Index i = 0; i < _rep_IDs.size(); i++) {
32  tmat.push_back(get_matrix_rep(_rep_IDs[i]));
33 
34  }
35  return tmat;
36  }
37 
38  //**********************************************************
39  void SymOpRepresentation::set_rep(SymGroupRepID _rep_ID, const SymOpRepresentation &op_rep) const {
40  assert(has_valid_master() && !_rep_ID.empty());
41  return master_group().representation(_rep_ID).set_rep(index(), op_rep);
42  }
43 
44  //*******************************************************************************************
45 
47  m_master_group = &new_group;
48  m_rep_ID = new_rep_ID;
49  SymGroupRep const &trep(new_group.representation(m_rep_ID));
50  Index i;
51  for(i = 0; i < trep.size(); i++) {
52  if(this == trep[i]) {
53  m_op_index = i;
54  break;
55  }
56  }
57 
58  if(i == new_group.size())
59  m_op_index = -1;
60 
61  return;
62  }
63 
64  //*******************************************************************************************
65 
66  void SymOpRepresentation::set_identifiers(const MasterSymGroup &new_group, SymGroupRepID new_rep_ID, Index new_op_index) {
67  m_master_group = &new_group;
68  m_rep_ID = new_rep_ID;
69  m_op_index = new_op_index;
70 
71  return;
72  }
73 
74  //*******************************************************************************************
75 
77  assert(has_valid_master() && "In SymOpRepresentation::ind_inverse(), head_group is uninitialized!!");
78  return master_group().ind_inverse(index());
79  }
80 
81  //*******************************************************************************************
82 
84  assert(has_valid_master() && "In SymOpRepresentation::ind_prod(), head_group is uninitialized!!");
85  return master_group().ind_prod(index(), RHS.index());
86  }
87 
88  //*******************************************************************************************
89 
90 
93  return rep->to_json(json);
94  }
95 
96  //*******************************************************************************************
97 
99  void from_json(SymOpRepresentation *rep, const jsonParser &json) {
100  try {
101  if(json["SymOpRep_type"] == "SymPermutation") {
102 
103  // prepare a SymPermutation and then read from json
104  Array<Index> perm;
105  SymPermutation trep(perm);
106  CASM::from_json(trep, json);
107 
108  // copy to rep
109  rep = new SymPermutation(trep);
110 
111  }
112  else if(json["SymOpRep_type"] == "SymMatrixXd") {
113 
114  // prepare a SymMatrixXd and then read from json
115  SymMatrixXd *op_ptr = new SymMatrixXd(Eigen::MatrixXd::Identity(1, 1));
116 
117  CASM::from_json(*op_ptr, json);
118 
119  // copy to rep
120  rep = op_ptr;
121 
122  }
123  else if(json["SymOpRep_type"] == "SymOp") {
124  // prepare a SymOp and then read from json
125  SymOp *op_ptr = new SymOp();
126 
127  CASM::from_json(*op_ptr, json);
128 
129  // copy to rep
130  rep = op_ptr;
131 
132  }
133  else {
134  std::cout << "Error in 'void from_json(SymOpRepresentation *rep, const jsonParser &json)'" << std::endl;
135  std::cout << "Unrecognized 'SymOpRep_type': '" << json["SymOpRep_type"] << "'." << std::endl;
136  std::cout << "Options are: 'SymPermutation', 'SymMatrixXd', or 'SymOp'." << std::endl;
137  exit(1);
138  }
139  }
140  catch(...) {
142  throw;
143  }
144  }
145 
146 }
Eigen::MatrixXd MatrixXd
void set_rep(SymGroupRepID _rep_ID, const SymOpRepresentation &op_rep) const
set representation for SymOp corresponding to _rep_ID
virtual Eigen::MatrixXd const * get_MatrixXd() const
void from_json(ClexDescription &desc, const jsonParser &json)
Index size() const
Definition: Array.hh:145
Type-safe ID object for communicating and accessing Symmetry representation info. ...
bool empty() const
Returns true if SymGroupRepID has not been initialized with valid group_index or rep_index.
bool has_valid_master() const
check if this representation is registered with a MasterSymGroup
void push_back(const T &toPush)
Definition: Array.hh:513
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
MasterSymGroup const * m_master_group
Pointer to the MasterSymGroup where prototype of this SymOp lives.
SymBasisPermute describes how a symmetry operation permutes atoms in a basis.
Index index() const
Index of this operation within the master_group.
SymBasisPermute const * get_basis_permute_rep(SymGroupRepID _rep_ID) const
get pointer to BasisPermute representation corresponding to _rep_ID
Main CASM namespace.
Definition: complete.cpp:8
SymGroupRepID m_rep_ID
ID of this representation within the master_group. Default is uninitialized.
Index ind_inverse(Index i) const
Get index of operation that is inverse of operation at(i)
Definition: SymGroup.cc:3046
Index m_op_index
Index into MasterSymGroup that specifies the operation.
void set_identifiers(const MasterSymGroup &new_group, SymGroupRepID new_rep_ID)
Change m_master_group and determine op_index.
Permutation const * get_permutation_rep(SymGroupRepID _rep_ID) const
get pointer to permutation representation corresponding to _rep_ID
SymPermutation describes how a symmetry operation permutes a list of 'things' For example...
virtual SymBasisPermute const * get_ucc_permutation() const
Eigen::MatrixXd const * get_matrix_rep(SymGroupRepID _rep_ID) const
get pointer to matrix representation corresponding to rep_ID
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
virtual Permutation const * get_permutation() const
virtual jsonParser & to_json(jsonParser &json) const =0
EigenIndex Index
For long integer indexing:
const MasterSymGroup & master_group() const
const access of head group
Index ind_inverse() const
Get the operation index of the inverse of this operation, using the master_group's multiplication tab...
SymOpRepresentation is the base class for anything describes a symmetry operation.
Generalized symmetry matrix representation for arbitrary dimension Can be used to describe applicatio...
Definition: SymMatrixXd.hh:22
SymGroupRep is an alternative representation of a SymGroup for something other than real space...
Definition: SymGroupRep.hh:30
Index ind_prod(const SymOpRepresentation &RHS) const
Array< Eigen::MatrixXd const * > get_matrix_reps(Array< SymGroupRepID > _rep_IDs) const
get array of pointers to matrix representations for representations corresponding to _rep_IDs ...
Index ind_prod(Index i, Index j) const
Get index of operation that is result of multiplication of at(i)*at(j)
Definition: SymGroup.cc:3055
Basic std::vector like container (deprecated)
SymGroupRep const & representation(SymGroupRepID i) const
Const access of alternate Representations of a SymGroup.
Definition: SymGroup.cc:375
void set_rep(const SymOpRepresentation &base_rep, const SymOpRepresentation &new_rep) const
Definition: SymGroupRep.cc:82