CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigIsEquivalent.hh
Go to the documentation of this file.
1 #ifndef CASM_ConfigIsEquivalent
2 #define CASM_ConfigIsEquivalent
3 
5 #include "casm/clex/Supercell.hh"
6 
7 namespace CASM {
8 
21  public:
23 
27  ConfigIsEquivalent(const Configuration &_config, double _tol,
28  std::set<std::string> const &_which_dofs = {"all"})
29  : m_config(&_config) {
30  bool all_dofs = false;
31  if (_which_dofs.count("all")) {
32  all_dofs = true;
33  }
34 
35  for (auto const &dof : config().configdof().global_dofs()) {
36  if (all_dofs || _which_dofs.count(dof.first)) {
37  m_global_equivs.push_back(
38  notstd::make_cloneable<ConfigDoFIsEquivalent::Global>(
39  _config, dof.first, _tol));
40  }
41  }
42 
43  if (all_dofs || _which_dofs.count("occ")) {
44  if (config().supercell().sym_info().has_aniso_occs())
45  m_local_equivs.push_back(
46  notstd::make_cloneable<ConfigDoFIsEquivalent::AnisoOccupation>(
47  _config.configdof()));
48  else if (config().supercell().sym_info().has_occupation_dofs())
49  m_local_equivs.push_back(
50  notstd::make_cloneable<ConfigDoFIsEquivalent::Occupation>(
51  _config.configdof()));
52  }
53 
54  for (auto const &dof : config().configdof().local_dofs()) {
55  if (all_dofs || _which_dofs.count(dof.first)) {
56  m_local_equivs.push_back(
57  notstd::make_cloneable<ConfigDoFIsEquivalent::Local>(
58  _config, dof.first, _tol));
59  }
60  }
61  }
62 
64  std::set<std::string> const &_which_dofs = {"all"})
65  : ConfigIsEquivalent(_config, _config.crystallography_tol(),
66  _which_dofs) {}
67 
68  const Configuration &config() const { return *m_config; }
69 
70  std::vector<EquivPtr> const &local_equivs() const { return m_local_equivs; }
71 
72  std::vector<EquivPtr> const &global_equivs() const { return m_global_equivs; }
73 
77  bool is_less() const { return m_less; }
78 
82  bool operator()(const Configuration &other) const {
83  if (&config() == &other) {
84  return true;
85  }
86 
87  if (config().supercell() != other.supercell()) {
88  m_less = config().supercell() < other.supercell();
89  return false;
90  }
91 
92  for (const auto &eq : global_equivs()) {
93  // check if config == other, for this global DoF type
94  // std::cout << "Checking global...\n";
95  if (!(*eq)(other.configdof())) {
96  m_less = eq->is_less();
97  return false;
98  }
99  }
100 
101  for (const auto &eq : local_equivs()) {
102  // check if config == other, for this local DoF type
103  if (!(*eq)(other.configdof())) {
104  m_less = eq->is_less();
105  return false;
106  }
107  }
108 
109  return true;
110  }
111 
113  bool operator()(const PermuteIterator &A) const {
114  // std::cout << "A.factor_group_index() " << A.factor_group_index() << ";
115  // translation_index() " << A.translation_index() << std::endl;
116 
117  for (const auto &eq : global_equivs()) {
118  // check if config == A*config, for this global DoF type
119  if (!(*eq)(A)) {
120  m_less = eq->is_less();
121  return false;
122  }
123  }
124 
125  for (const auto &eq : local_equivs()) {
126  // check if config == A*config, for this local DoF type
127  if (!(*eq)(A)) {
128  m_less = eq->is_less();
129  return false;
130  }
131  }
132  return true;
133  }
134 
136  bool operator()(const PermuteIterator &A, const PermuteIterator &B) const {
137  if (A.factor_group_index() != B.factor_group_index()) {
138  for (const auto &eq : global_equivs()) {
139  // check if config == other, for this global DoF type
140  if (!(*eq)(A, B)) {
141  m_less = eq->is_less();
142  return false;
143  }
144  }
145  }
146 
147  for (const auto &eq : local_equivs()) {
148  // check if config == other, for this local DoF type
149  if (!(*eq)(A, B)) {
150  m_less = eq->is_less();
151  return false;
152  }
153  }
154 
155  return true;
156  }
157 
159  bool operator()(const PermuteIterator &A, const Configuration &other) const {
160  for (const auto &eq : global_equivs()) {
161  // check if config == other, for this global DoF type
162  if (!(*eq)(A, other.configdof())) {
163  m_less = eq->is_less();
164  return false;
165  }
166  }
167 
168  for (const auto &eq : local_equivs()) {
169  // check if config == other, for this local DoF type
170  if (!(*eq)(A, other.configdof())) {
171  m_less = eq->is_less();
172  return false;
173  }
174  }
175 
176  return true;
177  }
178 
180  bool operator()(const PermuteIterator &A, const PermuteIterator &B,
181  const Configuration &other) const {
182  for (const auto &eq : global_equivs()) {
183  // check if config == other, for this global DoF type
184  if (!(*eq)(A, B, other.configdof())) {
185  m_less = eq->is_less();
186  return false;
187  }
188  }
189 
190  for (const auto &eq : local_equivs()) {
191  // check if config == other, for this local DoF type
192  if (!(*eq)(A, B, other.configdof())) {
193  m_less = eq->is_less();
194  return false;
195  }
196  }
197 
198  return true;
199  }
200 
201  private:
203  std::vector<EquivPtr> m_global_equivs;
204  std::vector<EquivPtr> m_local_equivs;
205  mutable bool m_less;
206 };
207 
209 } // namespace CASM
210 
211 #endif
Class for comparison of Configurations (with the same Supercell)
bool operator()(const PermuteIterator &A) const
Check if config == A*config, store config < A*config.
std::vector< EquivPtr > m_local_equivs
bool is_less() const
Returns less than comparison.
const Configuration * m_config
bool operator()(const PermuteIterator &A, const PermuteIterator &B) const
Check if A*config == B*config, store A*config < B*config.
bool operator()(const PermuteIterator &A, const Configuration &other) const
Check if config == A*other, store config < A*other.
ConfigIsEquivalent(const Configuration &_config, std::set< std::string > const &_which_dofs={"all"})
bool operator()(const PermuteIterator &A, const PermuteIterator &B, const Configuration &other) const
Check if A*config == B*other, store A*config < B*other.
std::vector< EquivPtr > const & global_equivs() const
std::vector< EquivPtr > const & local_equivs() const
const Configuration & config() const
bool operator()(const Configuration &other) const
Check if config == other, store config < other.
std::vector< EquivPtr > m_global_equivs
ConfigIsEquivalent(const Configuration &_config, double _tol, std::set< std::string > const &_which_dofs={"all"})
const ConfigDoF & configdof() const
const Access the DoF
const Supercell & supercell() const
Get the Supercell for this Configuration.
Index factor_group_index() const
Return the supercell factor group index.
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
Main CASM namespace.
Definition: APICommand.hh:8