CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
SymOp.hh
Go to the documentation of this file.
1 #ifndef SYMOP_HH
2 #define SYMOP_HH
3 
4 #include <iostream>
5 #include <cmath>
6 
8 
9 
10 namespace CASM {
11 
23  class MasterSymGroup;
24 
28  class SymOp : public SymOpRepresentation {
29  public:
30 
32  typedef Eigen::Vector3d vector_type;
33 
35  static SymOp translation(const Eigen::Ref<const vector_type> &_tau) {
36  return SymOp(matrix_type::Identity(), _tau, TOL, 0, nullptr);
37  }
38 
41  SymOp(const Eigen::Ref<const matrix_type> &_mat = matrix_type::Identity(),
42  const Eigen::Ref<const vector_type> &_tau = vector_type::Zero(),
43  double _map_error = TOL) :
44  SymOp(_mat, _tau, _map_error, -1, nullptr) {
45  }
46 
49  SymOp(const Eigen::Ref<const matrix_type> &_mat,
50  double _map_error) :
51  SymOp(_mat, vector_type::Zero(), _map_error) {
52 
53  }
54 
56  inline
57  const matrix_type &matrix() const {
58  return m_mat;
59  }
60 
62  inline
63  const vector_type &tau() const {
64  return m_tau;
65  }
66 
68  inline
69  bool is_identity() const {
70  return matrix().isIdentity(TOL);
71  }
72 
75  void set_index(const MasterSymGroup &new_group, Index new_index);
76 
78  const double &map_error() const;
79  void set_map_error(const double &value);
80 
81  //Routines that relate symmetry options:
83  SymOp operator*(const SymOp &RHS) const;
84 
86  SymOp &operator+=(const Eigen::Ref<const vector_type> &RHS);
87  SymOp &operator-=(const Eigen::Ref<const vector_type> &RHS);
88 
90  SymOp inverse() const;
91 
93  SymOp no_trans() const;
94 
96  bool operator==(const SymOp &RHS) const;
97 
101  SymOp &apply_sym(const SymOp &op);
102 
104  double character() const override {
105  return matrix().trace();
106  }
107 
110  void print(std::ostream &stream, const Eigen::Ref<const matrix_type> &c2fmat = matrix_type::Identity()) const;
111 
115  void print_short(std::ostream &stream, const Eigen::Ref<const matrix_type> &c2fmat = matrix_type::Identity()) const;
116 
118  SymOpRepresentation *copy() const override {
119  return new SymOp(*this);
120  }
121 
123  return SymOp(matrix(), tau(), map_error());
124  }
125 
126  jsonParser &to_json(jsonParser &json) const override;
127 
128  void from_json(const jsonParser &json) override;
129 
130  private:
133  SymOp(const Eigen::Ref<const matrix_type> &_mat,
134  const Eigen::Ref<const vector_type> &_tau,
135  double _map_error,
136  Index _op_index,
137  MasterSymGroup const *_master_ptr) :
138  SymOpRepresentation(_master_ptr, SymGroupRepID(), _op_index),
139  m_mat(_mat),
140  m_tau(_tau),
141  m_map_error(_map_error) {
142  }
143 
144  /*** Inherited from SymOpRepresentation ***/
145  /*
147  Index m_op_index;
148 
149  SymGroupRepID m_rep_ID;
150 
152  MasterSymGroup const *m_master_group;
153  */
154 
158  matrix_type m_mat;
159 
162  vector_type m_tau;
163 
166  double m_map_error;
167 
168  };
169 
170 
171  jsonParser &to_json(const SymOp &sym, jsonParser &json);
172  void from_json(SymOp &sym, const jsonParser &json);
173 
174  //std::istream& operator>> (std::istream &stream, SymOp &op){op.read(stream); return stream;};
175  //std::ostream& operator<< (std::ostream &stream, SymOp &op){op.print(stream); return stream;};
176 
179 }
180 #endif
SymOp(const Eigen::Ref< const matrix_type > &_mat=matrix_type::Identity(), const Eigen::Ref< const vector_type > &_tau=vector_type::Zero(), double _map_error=TOL)
Definition: SymOp.hh:41
SymOp operator*(const SymOp &RHS) const
get a new SymOp that is equivalent to subsequent application of both SymOps
Definition: SymOp.cc:39
static SymOp translation(const Eigen::Ref< const vector_type > &_tau)
static method to create operation that describes pure translation
Definition: SymOp.hh:35
void from_json(ClexDescription &desc, const jsonParser &json)
Type-safe ID object for communicating and accessing Symmetry representation info. ...
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void set_index(const MasterSymGroup &new_group, Index new_index)
Definition: SymOp.cc:23
bool operator==(const SymOp &RHS) const
Check equality of SymOps, (matrix and translation). Does not necessarily return true for translationa...
Definition: SymOp.cc:103
SymOp & operator-=(const Eigen::Ref< const vector_type > &RHS)
Definition: SymOp.cc:73
Main CASM namespace.
Definition: complete.cpp:8
const double TOL
bool is_identity() const
returns true if matrix part of operation is identity
Definition: SymOp.hh:69
void set_map_error(const double &value)
Definition: SymOp.cc:15
jsonParser & to_json(jsonParser &json) const override
Definition: SymOp.cc:148
matrix_type m_mat
Definition: SymOp.hh:158
const matrix_type & matrix() const
Const access of entire cartesian symmetry matrix.
Definition: SymOp.hh:57
Eigen::Vector3d vector_type
Definition: SymOp.hh:32
void from_json(const jsonParser &json) override
Definition: SymOp.cc:179
SymOp(const Eigen::Ref< const matrix_type > &_mat, const Eigen::Ref< const vector_type > &_tau, double _map_error, Index _op_index, MasterSymGroup const *_master_ptr)
Definition: SymOp.hh:133
const double & map_error() const
Allows access to the map_error.
Definition: SymOp.cc:9
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
vector_type m_tau
Definition: SymOp.hh:162
EigenIndex Index
For long integer indexing:
void print_short(std::ostream &stream, const Eigen::Ref< const matrix_type > &c2fmat=matrix_type::Identity()) const
SymOp inverse() const
get the inverse of this SymOp
Definition: SymOp.cc:82
double character() const override
calculate and return character of this SymOp (neglecting tau)
Definition: SymOp.hh:104
SymOpRepresentation is the base class for anything describes a symmetry operation.
SymOp(const Eigen::Ref< const matrix_type > &_mat, double _map_error)
Definition: SymOp.hh:49
double m_map_error
Definition: SymOp.hh:166
Eigen::Matrix3d Matrix3d
Eigen::Matrix3d matrix_type
Definition: SymOp.hh:31
void print(std::ostream &stream, const Eigen::Ref< const matrix_type > &c2fmat=matrix_type::Identity()) const
Definition: SymOp.cc:118
SymOp no_trans() const
Get copy of the SymOp without translation.
Definition: SymOp.cc:97
SymOp & apply_sym(const SymOp &op)
Definition: SymOp.cc:111
const vector_type & tau() const
Const access of the cartesian translation vector, 'tau'.
Definition: SymOp.hh:63
SymOp unregistered_copy() const
Definition: SymOp.hh:122
SymOp & operator+=(const Eigen::Ref< const vector_type > &RHS)
Cartesian translation of the origin of the symmetry operation by Coordinate RHS.
Definition: SymOp.cc:66
SymOpRepresentation * copy() const override
Return pointer to a new copy of this SymOp.
Definition: SymOp.hh:118