CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SymTools.cc
Go to the documentation of this file.
2 
3 #include <iterator>
4 #include <memory>
5 
13 #include "casm/symmetry/SymOp.hh"
16 
17 namespace {
18 CASM::SymGroup subgroup_from_indices(
19  const CASM::SymGroup &super_group,
20  const std::vector<CASM::Index> &subgroup_indices) {
21  std::vector<CASM::SymOp> subgroup_operations;
22  for (auto ix : subgroup_indices) {
23  subgroup_operations.push_back(super_group[ix]);
24  }
25 
26  return CASM::SymGroup(subgroup_operations, &(super_group.lattice()),
27  super_group.periodicity());
28 }
29 
30 //*******************************************************************************************
31 } // namespace
32 namespace CASM {
33 namespace sym {
35  const xtal::Lattice &lat) {
36  auto subgroup_operation_indices =
37  xtal::invariant_subgroup_indices(lat, super_group);
38  return subgroup_from_indices(super_group, subgroup_operation_indices);
39 }
40 
41 template <>
43 copy_apply<CASM::SymOp, xtal::UnitCellCoord, xtal::Lattice, SymGroupRepID>(
44  const CASM::SymOp &op, xtal::UnitCellCoord copied_ucc,
45  const xtal::Lattice &prim_lattice, const SymGroupRepID &prim_symrep_ID) {
46  // transform using stored SymBasisPermute representation
47  const SymBasisPermute &rep = *op.get_basis_permute_rep(prim_symrep_ID);
48  xtal::UnitCell new_unitcell = rep.matrix() * copied_ucc.unitcell() +
49  rep[copied_ucc.sublattice()].unitcell();
50  auto new_sublattice = rep[copied_ucc.sublattice()].sublattice();
51 
52  // additional translations (such as needed for supercell factor groups),
53  // are stored in SymOp::integral_tau() (in cartesian coordinates)
54  // this converts that to fractional coordinates and adds it to the unitcell()
55  new_unitcell += lround(prim_lattice.inv_lat_column_mat() * op.integral_tau());
56 
57  return xtal::UnitCellCoord(new_sublattice, new_unitcell);
58 }
59 
60 template <>
62  SymGroupRepID>(const CASM::SymOp &op,
63  xtal::UnitCellCoord &mutating_ucc,
64  const xtal::Lattice &prim_lattice,
65  const SymGroupRepID &prim_symrep_ID) {
66  auto ucc_after_apply =
67  copy_apply(op, mutating_ucc, prim_lattice, prim_symrep_ID);
68  std::swap(ucc_after_apply, mutating_ucc);
69  return mutating_ucc;
70 }
71 
72 template <>
73 xtal::UnitCellCoord copy_apply<CASM::SymOp, xtal::UnitCellCoord, Structure>(
74  const CASM::SymOp &op, xtal::UnitCellCoord copied_ucc,
75  const Structure &prim) {
76  sym::apply(op, copied_ucc, prim.lattice(),
78  return copied_ucc;
79 }
80 
81 template <>
82 xtal::UnitCellCoord &apply<CASM::SymOp, xtal::UnitCellCoord, Structure>(
83  const CASM::SymOp &op, xtal::UnitCellCoord &mutating_ucc,
84  const Structure &prim) {
85  sym::apply(op, mutating_ucc, prim.lattice(),
87  return mutating_ucc;
88 }
89 
90 //*******************************************
91 template <>
92 xtal::Coordinate &apply<CASM::SymOp, xtal::Coordinate>(
93  const CASM::SymOp &op, xtal::Coordinate &mutating_coord) {
94  return mutating_coord;
95 }
96 
97 } // namespace sym
98 } // namespace CASM
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:30
const Lattice & lattice() const
Definition: Structure.hh:100
SymGroupRepID basis_permutation_symrep_ID() const
Definition: Structure.cc:122
SymBasisPermute describes how a symmetry operation permutes atoms in a basis.
const Eigen::Matrix3l & matrix() const
Get underlying integer transformation amtrix.
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
PERIODICITY_TYPE periodicity() const
Definition: SymGroup.hh:191
virtual void push_back(const SymOp &new_op)
Definition: SymGroup.cc:818
const Lattice & lattice() const
Lattice used for periodic comparisons (for instance, to generate multiplcation table)
Definition: SymGroup.cc:950
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
const vector_type & integral_tau() const
Const access of the sym op's cartesian shift from its MasterSymGroup.
Definition: SymOp.hh:69
SymBasisPermute const * get_basis_permute_rep(SymGroupRepID _rep_ID) const
get pointer to BasisPermute representation corresponding to _rep_ID
Represents cartesian and fractional coordinates.
Definition: Coordinate.hh:34
const Eigen::Matrix3d & inv_lat_column_mat() const
Inverse of Lattice::lat_column_mat() It is the transformation matrix 'C2F', such that f = C2F * c whe...
Definition: Lattice.hh:117
Unit Cell Coordinates.
const UnitCell & unitcell() const
Unit Cell Indices.
Eigen::CwiseUnaryOp< decltype(Local::lround_l< typename Derived::Scalar >), const Derived > lround(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd to Eigen::MatrixXl.
xtal::Coordinate copy_apply(const xtal::SymOp &op, xtal::Coordinate coord)
Copy and apply SymOp to a Coordinate.
Definition: Coordinate.cc:354
xtal::Coordinate & apply(const xtal::SymOp &op, xtal::Coordinate &coord)
apply SymOp to a Coordinate
Definition: Coordinate.cc:347
SymGroup invariant_subgroup(const SymGroup &super_group, const xtal::Lattice &lat)
Returns the subgroup of the given group that keeps the lattice invariant.
Definition: SymTools.cc:34
std::vector< Index > invariant_subgroup_indices(const Lattice &lat, SymOpVector const &super_grp)
Construct indices of the subgroup that leaves a lattice unchanged.
Main CASM namespace.
Definition: APICommand.hh:8
void swap(ConfigDoF &A, ConfigDoF &B)
Definition: ConfigDoF.cc:260