CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SimpleStructure.cc
Go to the documentation of this file.
2 
4 
5 namespace CASM {
6 namespace xtal {
7 
8 std::vector<Index> SimpleStructure::Info::sort_by_name() {
9  std::vector<Index> permute;
10  permute.clear();
11  std::map<std::string, std::vector<Index> > smap;
12  for (Index i = 0; i < names.size(); ++i) {
13  smap[names[i]].push_back(i);
14  }
15  for (auto const &name : smap) {
16  permute.insert(permute.end(), name.second.begin(), name.second.end());
17  }
18  return permute;
19 }
20 
21 //***************************************************************************
22 
23 void SimpleStructure::within(double tol) {
24  if (mol_info.size())
25  mol_info.coords -=
27  Eigen::floor(
28  ((lat_column_mat.inverse() * mol_info.coords).array() + tol)
29  .array())
30  .matrix()
31  .eval();
32  if (atom_info.size())
33  atom_info.coords -=
35  Eigen::floor(
36  ((lat_column_mat.inverse() * atom_info.coords).array() + tol)
37  .array())
38  .matrix()
39  .eval();
40 }
41 
42 //***************************************************************************
43 
45  Eigen::Ref<const Eigen::Matrix3d> const &_F) {
47  if (mol_info.coords.rows() == 3) mol_info.coords = _F * mol_info.coords;
48  if (atom_info.coords.rows() == 3) atom_info.coords = _F * atom_info.coords;
49 }
50 
51 //***************************************************************************
52 
54  Eigen::Ref<const Eigen::Matrix3d> const &_R) {
56  if (mol_info.coords.rows() == 3) mol_info.coords = _R * mol_info.coords;
57  if (atom_info.coords.rows() == 3) atom_info.coords = _R * atom_info.coords;
58 }
59 
60 } // namespace xtal
61 } // namespace CASM
void deform_coords(Eigen::Ref< const Eigen::Matrix3d > const &_F)
Apply homogeneous deformation gradient tensor _F to lat_column_mat, mol_info, and atom_info.
void within(double tol=TOL)
Map all coordinates within the unit cell.
void rotate_coords(Eigen::Ref< const Eigen::Matrix3d > const &_R)
Apply homogeneous rotation matrix _R to lat_column_mat, mol_info, and atom_info.
Main CASM namespace.
Definition: APICommand.hh:8
GenericDatumFormatter< std::string, DataObject > name()
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::MatrixXd coords
(3 x names.size()) matrix of coordinates. coords.col(i) is Cartesian coordinate of site 'i'
std::vector< std::string > names
names[i] is name of species that occupies sites 'i'
Index size() const
Number of sites is defined as names.size()
std::vector< Index > sort_by_name()
permutation that results in sites sorted alphabetically by species Guaranteed stable: will not change...