CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
SymBasisPermute.hh
Go to the documentation of this file.
1 #ifndef SYMBASISPERMUTE_HH
2 #define SYMBASISPERMUTE_HH
3 
7 #include "casm/symmetry/SymOp.hh"
9 
10 namespace CASM {
11  class MasterSymGroup;
12  class Lattice;
13 
18  class SymBasisPermute: public SymOpRepresentation {
29  private:
30 
33  std::vector<UnitCellCoord> m_ucc_permute;
34 
37 
38 
39  public:
40 
41  typedef Index size_type;
42 
44  template<typename StrucType>
45  SymBasisPermute(const SymOp &op, const StrucType &struc, double tol);
46 
49  value.unitcell() = m_point_mat * value.unitcell() +
50  m_ucc_permute[value.sublat()].unitcell();
51  value.sublat() = m_ucc_permute[value.sublat()].sublat();
52  return value;
53  }
54 
57  return apply(value);
58  }
59 
61  SymOpRepresentation *copy() const override {
62  return new SymBasisPermute(*this);
63  };
64 
66  size_type size() const {
67  return m_ucc_permute.size();
68  }
69 
72  return m_ucc_permute[b];
73  }
74 
76  UnitCellCoord at(Index b) const {
77  return m_ucc_permute.at(b);
78  }
79 
81  SymBasisPermute const *get_ucc_permutation() const override {
82  return this;
83  };
84 
86  const std::vector<UnitCellCoord> &data() const {
87  return m_ucc_permute;
88  }
89 
91  const Eigen::Matrix3l &matrix() const {
92  return m_point_mat;
93  }
94 
95  jsonParser &to_json(jsonParser &json) const override {
96  return json;
97  };
98  void from_json(const jsonParser &json) override {};
99 
100  };
101 
103  template<typename BasisPermutable>
104  UnitCellCoord &apply(const SymOp &op, UnitCellCoord &value, const BasisPermutable &obj);
105 
107  inline UnitCellCoord &apply(const SymBasisPermute &op, UnitCellCoord &value) {
108  return op.apply(value);
109  }
110 
111 
112  // ---- SymBasisPermute Definitions --------------------
113 
115  template<typename StrucType>
116  SymBasisPermute::SymBasisPermute(const SymOp &op, const StrucType &struc, double tol) {
117  SymOp::matrix_type frac_op(cart2frac(op.matrix(), struc.lattice()));
118  if(!is_integer(frac_op, tol)) {
119  throw std::runtime_error(
120  std::string("Error in 'SymBasisPermute(const SymOp& op, const StrucType& struc, double tol)'\n") +
121  " Could not get integer point transformation matrix.");
122  }
123 
124  m_point_mat = lround(frac_op);
125 
126  // Determine how basis sites transform from the origin unit cell
127  for(int b = 0; b < struc.basis.size(); b++) {
128  m_ucc_permute.push_back(UnitCellCoord(CASM::copy_apply(op, struc.basis[b]), struc, tol));
129  }
130  }
131 
132 
141  template<typename BasisPermutable>
142  UnitCellCoord &apply(const SymOp &op, UnitCellCoord &value, const BasisPermutable &obj) {
143 
144  return op.get_basis_permute_rep(obj.basis_permutation_symrep_ID())->apply(value);
145  }
146 
148 }
149 #endif
UnitCellCoord at(Index b) const
Return UnitCellCoord that (b,0,0,0) transforms to.
Object copy_apply(const Transform &f, Object obj, Args &&...args)
Eigen::Matrix3d cart2frac(const Eigen::Ref< const Eigen::Matrix3d > &cart_mat, const Lattice &lat)
Returns 'frac_mat' which is transformation of 'cart_mat' if cart_vec_after = cart_mat*cart_vec then f...
Definition: Lattice.hh:341
Unit Cell Coordinates.
SymBasisPermute describes how a symmetry operation permutes atoms in a basis.
SymBasisPermute const * get_basis_permute_rep(SymGroupRepID _rep_ID) const
get pointer to BasisPermute representation corresponding to _rep_ID
Eigen::Matrix3l m_point_mat
Transform fractional coordinates, integer version of SymOp::matrix()
Main CASM namespace.
Definition: complete.cpp:8
void from_json(const jsonParser &json) override
UnitCellCoord & apply(UnitCellCoord &value) const
Apply to a UnitCellCoord, in place.
size_type size() const
Return number of basis sites.
double tol
const matrix_type & matrix() const
Const access of entire cartesian symmetry matrix.
Definition: SymOp.hh:57
SymOpRepresentation * copy() const override
Return pointer to a copy of this SymBasisPermute.
SymBasisPermute const * get_ucc_permutation() const override
Get this from a SymOp.
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
const std::vector< UnitCellCoord > & data() const
Get underlying data (data()[b] is the result of transforming (b,0,0,0))
jsonParser & to_json(jsonParser &json) const override
EigenIndex Index
For long integer indexing:
Eigen::CwiseUnaryOp< decltype(std::ptr_fun(boost::math::lround< typename Derived::Scalar >)), const Derived > lround(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd to Eigen::MatrixXl.
UnitCell & unitcell()
SymOpRepresentation is the base class for anything describes a symmetry operation.
bool is_integer(const Eigen::MatrixBase< Derived > &M, double tol)
Check if Eigen::Matrix is integer.
SymBasisPermute(const SymOp &op, const StrucType &struc, double tol)
Construct SymBasisPermute.
UnitCellCoord copy_apply(UnitCellCoord value) const
Copy UnitCellCoord and apply.
Eigen::Matrix3d matrix_type
Definition: SymOp.hh:31
UnitCellCoord operator[](Index b) const
Return UnitCellCoord that (b,0,0,0) transforms to.
Matrix< long int, 3, 3 > Matrix3l
const Eigen::Matrix3l & matrix() const
Get underlying integer transformation amtrix.
std::vector< UnitCellCoord > m_ucc_permute
Object & apply(const Transform &f, Object &obj, Args &&...args)