CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ClusterInvariants.cc
Go to the documentation of this file.
2 
6 #include "casm/misc/CASM_math.hh"
7 
8 namespace CASM {
9 
12  // save size of cluster
13  m_size = cluster.size();
14 
15  // calculate distances between points
16  std::vector<double> disp;
17  for (int i = 0; i < m_size; i++) {
18  for (int j = i + 1; j < m_size; j++) {
19  m_disp.push_back(
20  (cluster.coordinate(i) - cluster.coordinate(j)).const_cart().norm());
21  }
22  }
23  std::sort(m_disp.begin(), m_disp.end());
24 }
25 
27 int ClusterInvariants::size() const { return m_size; }
28 
31 const std::vector<double> &ClusterInvariants::displacement() const {
32  return m_disp;
33 }
34 
37  double tol) {
38  return A.size() == B.size() &&
39  std::equal(A.displacement().cbegin(), A.displacement().cend(),
40  B.displacement().cbegin(), [&](double a, double b) {
41  return almost_equal(a, b, tol);
42  });
43 }
44 
53  double tol) {
54  // first sort by number of sites in cluster
55  if (A.size() < B.size()) {
56  return true;
57  }
58  if (A.size() > B.size()) {
59  return false;
60  }
61 
62  // all displacements
63  for (int i = A.displacement().size() - 1; i >= 0; i--) {
64  if (almost_equal(A.displacement()[i], B.displacement()[i], tol)) {
65  continue;
66  }
67  if (A.displacement()[i] < B.displacement()[i]) {
68  return true;
69  }
70  if (A.displacement()[i] > B.displacement()[i]) {
71  return false;
72  }
73  }
74  return false;
75 }
76 
80  IntegralCluster const &cluster, Eigen::Matrix3l const &transf_mat) {
82  xtal::Lattice scel_lat =
84 
85  // save size of cluster
86  m_size = cluster.size();
87 
88  // calculate distances between points
89  std::vector<xtal::Coordinate> coords;
90  for (int i = 0; i < m_size; ++i) {
91  coords.push_back(cluster.coordinate(i));
92  coords.back().set_lattice(scel_lat, CART);
93  }
94  std::vector<double> disp;
95  for (int i = 0; i < m_size; i++) {
96  for (int j = i + 1; j < m_size; j++) {
97  m_disp.push_back(coords[i].robust_min_dist(coords[j]));
98  }
99  }
100  std::sort(m_disp.begin(), m_disp.end());
101 }
102 
105 
108 std::vector<double> const &WithinScelClusterInvariants::displacement() const {
109  return m_disp;
110 }
111 
114  WithinScelClusterInvariants const &B, double tol) {
115  return A.size() == B.size() &&
116  std::equal(A.displacement().cbegin(), A.displacement().cend(),
117  B.displacement().cbegin(), [&](double a, double b) {
118  return almost_equal(a, b, tol);
119  });
120 }
121 
130  WithinScelClusterInvariants const &B, double tol) {
131  // first sort by number of sites in cluster
132  if (A.size() < B.size()) {
133  return true;
134  }
135  if (A.size() > B.size()) {
136  return false;
137  }
138 
139  // all displacements
140  for (int i = A.displacement().size() - 1; i >= 0; i--) {
141  if (almost_equal(A.displacement()[i], B.displacement()[i], tol)) {
142  continue;
143  }
144  if (A.displacement()[i] < B.displacement()[i]) {
145  return true;
146  }
147  if (A.displacement()[i] > B.displacement()[i]) {
148  return false;
149  }
150  }
151  return false;
152 }
153 
154 } // namespace CASM
Stores cluster invariants: number of sites and site distances.
int size() const
Number of elements in the cluster.
ClusterInvariants(IntegralCluster const &cluster)
Construct and calculate cluster invariants.
std::vector< double > const & displacement() const
const Access displacements between coordinates in the cluster, sorted in ascending order
int m_size
Number of UnitCellCoords in cluster.
std::vector< double > m_disp
Displacement between each pair of UnitCellCoords, sorted in ascending order.
size_type size() const
Number of elements in the cluster.
const PrimType & prim() const
xtal::Coordinate coordinate(size_type i) const
Return the coordinate corresponding to element(i)
const Lattice & lattice() const
Definition: Structure.hh:100
Stores cluster invariants: number of sites and site distances (using robust_min_dist)
std::vector< double > m_disp
Displacement between each pair of UnitCellCoords, sorted in ascending order.
WithinScelClusterInvariants(IntegralCluster const &cluster, Eigen::Matrix3l const &transf_mat)
Construct and calculate cluster invariants, using robust_min_dist in the supercell lattice.
int m_size
Number of UnitCellCoords in cluster.
int size() const
Number of elements in the cluster.
std::vector< double > const & displacement() const
const Access displacements between coordinates in the cluster, sorted in ascending order,...
Lattice make_superlattice(const Lattice &lat, const Eigen::Matrix< IntegralType, 3, 3, Options > &transf_mat)
Returns a super Lattice. Transformation matrix must be integer.
Definition: Lattice.hh:287
Eigen::Matrix3l transf_mat(const Lattice &prim_lat, const Lattice &super_lat)
Main CASM namespace.
Definition: APICommand.hh:8
bool almost_equal(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Check if ClusterInvariants are equal.
bool compare(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Compare ClusterInvariants.
const COORD_TYPE CART
Definition: enum.hh:9
Matrix< long int, 3, 3 > Matrix3l
Definition: eigen.hh:12