CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SymOp.hh
Go to the documentation of this file.
1 #ifndef SYMOP_HH
2 #define SYMOP_HH
3 
4 #include <cmath>
5 #include <iostream>
6 
8 
9 namespace CASM {
10 
11 class Log;
12 
23 class MasterSymGroup;
24 
28 class SymOp : public SymOpRepresentation {
29  public:
31  typedef Eigen::Vector3d vector_type;
32 
34  static SymOp translation(const Eigen::Ref<const vector_type> &_tau) {
35  return SymOp(matrix_type::Identity(), _tau, false, TOL, 0, nullptr);
36  }
37 
40  return SymOp(matrix_type::Identity(), vector_type::Zero(), true, TOL, -1,
41  nullptr);
42  }
43 
45  static SymOp point_op(const Eigen::Ref<const matrix_type> &_mat,
46  double _map_error = TOL) {
47  return SymOp(_mat, vector_type::Zero(), false, _map_error, -1, nullptr);
48  }
49 
50  SymOp() : SymOp(matrix_type::Identity(), vector_type::Zero(), false, TOL) {}
51 
54  SymOp(const Eigen::Ref<const matrix_type> &_mat,
55  const Eigen::Ref<const vector_type> &_tau, bool _time_reversal,
56  double _map_error)
57  : SymOp(_mat, _tau, _time_reversal, _map_error, -1, nullptr) {}
58 
60  inline const matrix_type &matrix() const { return m_mat; }
61 
63  inline const vector_type &tau() const { return m_tau; }
64 
66  inline bool time_reversal() const { return m_time_reversal; }
67 
69  inline const vector_type &integral_tau() const {
71  return m_integral_tau;
72  }
73 
74  throw std::runtime_error("Error in SymOp::integral_tau(), not valid");
75  }
76 
78  inline bool is_identity() const {
79  return matrix().isIdentity(TOL) && !time_reversal();
80  }
81 
85  void set_index(const MasterSymGroup &new_group, Index new_index);
86 
88  const double &map_error() const;
89  void set_map_error(const double &value);
90 
91  // Routines that relate symmetry options:
94  SymOp operator*(const SymOp &RHS) const;
95 
98  SymOp &operator+=(const Eigen::Ref<const vector_type> &RHS);
99  SymOp &operator-=(const Eigen::Ref<const vector_type> &RHS);
100 
102  SymOp inverse() const;
103 
105  SymOp no_trans() const;
106 
109  bool operator==(const SymOp &RHS) const;
110 
114  SymOp &apply_sym(const SymOp &op);
115 
117  double character() const override { return matrix().trace(); }
118 
122  void print(std::ostream &stream, const Eigen::Ref<const matrix_type> &c2fmat =
123  matrix_type::Identity()) const;
124 
129  void print_short(std::ostream &stream,
130  const Eigen::Ref<const matrix_type> &c2fmat =
131  matrix_type::Identity()) const;
132 
134  SymOpRepresentation *copy() const override { return new SymOp(*this); }
135 
137  return SymOp(matrix(), tau(), time_reversal(), map_error());
138  }
139 
140  private:
143  SymOp(const Eigen::Ref<const matrix_type> &_mat,
144  const Eigen::Ref<const vector_type> &_tau, bool _time_reversal,
145  double _map_error, Index _op_index, MasterSymGroup const *_master_ptr)
146  : SymOpRepresentation(_master_ptr, SymGroupRepID(), _op_index),
147  m_mat(_mat),
148  m_tau(_tau),
149  m_time_reversal(_time_reversal),
150  m_map_error(_map_error) {
152  }
153 
154  /*** Inherited from SymOpRepresentation ***/
155  /*
157  Index m_op_index;
158 
159  SymGroupRepID m_rep_ID;
160 
162  MasterSymGroup const *m_master_group;
163  */
164 
166  // its MasterSymGroup correspondent
167  void _set_integral_tau() override;
168 
173 
177 
182 
186 
188 
192  double m_map_error;
193 };
194 
197 const SymOp::matrix_type &get_matrix(const SymOp &op);
200 const SymOp::vector_type &get_translation(const SymOp &op);
203 bool get_time_reversal(const SymOp &op);
204 
206 void print_matrix_tau_col(Log &log, const SymOp &op, Index prec);
207 
208 namespace adapter {
209 
210 template <typename ToType, typename FromType>
211 struct Adapter;
212 
222 template <typename FromType>
223 struct Adapter<SymOp, FromType> {
224  SymOp operator()(const FromType &adaptable) {
225  // TODO: How to get mapping error tol?
226  return SymOp(get_matrix(adaptable), get_translation(adaptable),
227  get_time_reversal(adaptable), CASM::TOL);
228  }
229 };
230 
235 template <>
236 struct Adapter<SymOp, SymOp> {
237  SymOp const &operator()(SymOp const &adaptable) const { return adaptable; }
238 
239  SymOp &operator()(SymOp &adaptable) const { return adaptable; }
240 };
241 } // namespace adapter
242 
245 } // namespace CASM
246 #endif
Definition: Log.hh:48
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
SymOp(const Eigen::Ref< const matrix_type > &_mat, const Eigen::Ref< const vector_type > &_tau, bool _time_reversal, double _map_error)
Definition: SymOp.hh:54
double character() const override
calculate and return character of this SymOp (neglecting tau)
Definition: SymOp.hh:117
void print(std::ostream &stream, const Eigen::Ref< const matrix_type > &c2fmat=matrix_type::Identity()) const
Definition: SymOp.cc:132
SymOp no_trans() const
Get copy of the SymOp without translation.
Definition: SymOp.cc:102
Eigen::Matrix3d matrix_type
Definition: SymOp.hh:30
SymOp & operator+=(const Eigen::Ref< const vector_type > &RHS)
Definition: SymOp.cc:71
SymOp operator*(const SymOp &RHS) const
Definition: SymOp.cc:40
const matrix_type & matrix() const
Const access of entire cartesian symmetry matrix.
Definition: SymOp.hh:60
Eigen::Vector3d vector_type
Definition: SymOp.hh:31
void set_index(const MasterSymGroup &new_group, Index new_index)
Definition: SymOp.cc:23
SymOp unregistered_copy() const
Definition: SymOp.hh:136
matrix_type m_mat
Definition: SymOp.hh:172
void print_short(std::ostream &stream, const Eigen::Ref< const matrix_type > &c2fmat=matrix_type::Identity()) const
Definition: SymOp.cc:124
bool is_identity() const
returns true if matrix part of operation is identity
Definition: SymOp.hh:78
const vector_type & integral_tau() const
Const access of the sym op's cartesian shift from its MasterSymGroup.
Definition: SymOp.hh:69
SymOp(const Eigen::Ref< const matrix_type > &_mat, const Eigen::Ref< const vector_type > &_tau, bool _time_reversal, double _map_error, Index _op_index, MasterSymGroup const *_master_ptr)
Definition: SymOp.hh:143
bool operator==(const SymOp &RHS) const
Definition: SymOp.cc:109
void set_map_error(const double &value)
Definition: SymOp.cc:16
SymOp inverse() const
get the inverse of this SymOp
Definition: SymOp.cc:87
SymOpRepresentation * copy() const override
Return pointer to a new copy of this SymOp.
Definition: SymOp.hh:134
bool m_time_reversal
Definition: SymOp.hh:181
bool time_reversal() const
Const access of the time-reversal flag (true if operation reverses time)
Definition: SymOp.hh:66
vector_type m_integral_tau
Definition: SymOp.hh:185
const double & map_error() const
Allows access to the map_error.
Definition: SymOp.cc:12
void _set_integral_tau() override
Set the difference between the translation of this compared to.
Definition: SymOp.cc:173
SymOp & operator-=(const Eigen::Ref< const vector_type > &RHS)
Definition: SymOp.cc:78
const vector_type & tau() const
Const access of the cartesian translation vector, 'tau'.
Definition: SymOp.hh:63
vector_type m_tau
Definition: SymOp.hh:176
static SymOp point_op(const Eigen::Ref< const matrix_type > &_mat, double _map_error=TOL)
static method to create point operation (no translation)
Definition: SymOp.hh:45
static SymOp translation(const Eigen::Ref< const vector_type > &_tau)
static method to create operation that describes pure translation
Definition: SymOp.hh:34
SymOp & apply_sym(const SymOp &op)
Definition: SymOp.cc:117
double m_map_error
Definition: SymOp.hh:192
static SymOp time_reversal_op()
static method to create time_reversal operation
Definition: SymOp.hh:39
bool m_valid_integral_tau
Definition: SymOp.hh:187
SymOpRepresentation is the base class for anything describes a symmetry operation.
const SymOp::matrix_type & get_matrix(const SymOp &op)
Definition: SymOp.cc:167
bool get_time_reversal(const SymOp &op)
Definition: SymOp.cc:171
const SymOp::vector_type & get_translation(const SymOp &op)
Definition: SymOp.cc:169
void print_matrix_tau_col(Log &log, const SymOp &op, Index prec)
Print formatted SymOp matrix and tau.
Definition: SymOp.cc:196
IdentitySymRepBuilder Identity()
Main CASM namespace.
Definition: APICommand.hh:8
Log & log()
Definition: Log.hh:424
Eigen::Matrix3d Matrix3d
const double TOL
Definition: definitions.hh:30
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
SymOp operator()(const FromType &adaptable)
Definition: SymOp.hh:224
SymOp const & operator()(SymOp const &adaptable) const
Definition: SymOp.hh:237
SymOp & operator()(SymOp &adaptable) const
Definition: SymOp.hh:239