CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
Lattice_impl.hh
Go to the documentation of this file.
3 #include "casm/symmetry/SymOp.hh"
4 
5 namespace CASM {
6 
7  //********************************************************************
12  //********************************************************************
13 
14  template<typename CoordType, typename CoordType2>
15  Array<CoordType> Lattice::gridstruc_build(double max_radius, double min_radius, Array<CoordType> basis, CoordType2 lat_point) {
16  Eigen::Vector3i dim;
17  dim = enclose_sphere(max_radius);
18  EigenCounter<Eigen::Vector3i > grid_count(-dim, dim, Eigen::Vector3i(1));
19  double min_dist, dist;
20  Array<CoordType> gridstruc;
21  Eigen::Vector3i temp;
22 
23  do {
24  lat_point(FRAC) = grid_count();
25 
26  for(Index i = 0; i < basis.size(); i++) {
27  CoordType tatom(basis[i] + lat_point);
28  //get distance to closest basis site in the unit cell at the origin
29 
30  min_dist = 1e20;
31  for(Index j = 0; j < basis.size(); j++) {
32  dist = tatom.dist(basis[j]);
33  if(dist < min_dist)
34  min_dist = dist;
35  }
36  if(min_dist < min_radius) {
37  continue;
38  }
39  if(min_dist < max_radius) {
40  gridstruc.push_back(tatom);
41  // std::cout<<"tatom"<<tatom<<"\t Min Dist"<<min_dist<<"\n";
42  }
43  }
44  }
45  while(++grid_count);
46 
47  return gridstruc;
48  }
49 
50 
55  template<typename LatIterator, typename SymOpIterator>
56  Lattice superdupercell(LatIterator begin,
57  LatIterator end,
58  SymOpIterator op_begin,
59  SymOpIterator op_end) {
60 
61  Lattice best = *begin;
62  for(auto it = ++begin; it != end; ++it) {
63  Lattice tmp_best = superdupercell(best, *it);
64  for(auto op_it = op_begin; op_it != op_end; ++op_it) {
65  Lattice test = superdupercell(best, copy_apply(*op_it, *it));
66  if(std::abs(volume(test)) < std::abs(volume(tmp_best))) {
67  tmp_best = test;
68  }
69  }
70  best = tmp_best;
71  }
72  return best;
73  }
74 
76  template<typename SymOpIterator, typename SymOpOutputIterator>
77  SymOpOutputIterator Lattice::find_invariant_subgroup(
78  SymOpIterator begin,
79  SymOpIterator end,
80  SymOpOutputIterator result,
81  double pg_tol) const {
82 
83  LatticeIsEquivalent is_equiv(*this, pg_tol);
84  return std::copy_if(begin, end, result, is_equiv);
85  }
86 
87 
92  template<typename Object, typename OpIterator>
93  std::pair<OpIterator, Eigen::MatrixXi> is_supercell(
94  const Object &scel,
95  const Object &unit,
96  OpIterator begin,
97  OpIterator end,
98  double tol) {
99 
100  std::pair<bool, Eigen::MatrixXi> res;
101  for(auto it = begin; it != end; ++it) {
102  res = is_supercell(scel, copy_apply(*it, unit), tol);
103  if(res.first) {
104  return std::make_pair(it, res.second);
105  }
106  }
107  return std::make_pair(end, res.second);
108  }
109 }
110 
Lattice superdupercell(const Lattice &lat1, const Lattice &lat2)
returns Lattice that is smallest possible supercell of both input Lattice
Definition: Lattice.cc:1161
A Counter allows looping over many incrementing variables in one loop.
Definition: Counter.hh:71
Index size() const
Definition: Array.hh:145
void push_back(const T &toPush)
Definition: Array.hh:513
Object copy_apply(const Transform &f, Object obj, Args &&...args)
Definition: Common.hh:7
Main CASM namespace.
Definition: complete.cpp:8
Putting all the Lattice comparisons in one place.
double tol
Array< CoordType > gridstruc_build(double max_radius, double min_radius, Array< CoordType > basis, CoordType2 lat_point)
Make a grid of lattice sites such that min_radius <= distance <= max_radius from. ...
Definition: Lattice_impl.hh:15
EigenIndex Index
For long integer indexing:
SymOpOutputIterator find_invariant_subgroup(SymOpIterator begin, SymOpIterator end, SymOpOutputIterator result, double pg_tol=TOL) const
Output the SymOp that leave this lattice invariant.
Definition: Lattice_impl.hh:77
Eigen::Vector3i enclose_sphere(double radius) const
Definition: Lattice.cc:626
std::pair< bool, Eigen::MatrixXi > is_supercell(const Lattice &scel, const Lattice &unit, double tol)
Check if scel is a supercell of unitcell unit and some integer transformation matrix T...
Definition: Lattice.cc:1196
double volume(const Lattice &lat)
Returns the volume of a Lattice.
Definition: Lattice.hh:372