CASM  1.1.0
A Clusters Approach to Statistical Mechanics
AnisoValTraits.hh
Go to the documentation of this file.
1 #ifndef CASM_AnisoValTraits
2 #define CASM_AnisoValTraits
3 
4 #include <memory>
5 #include <set>
6 #include <string>
7 #include <vector>
8 
11 #include "casm/global/eigen.hh"
12 
13 // Defines notstd::make_unique<>()
16 
17 namespace CASM {
18 
19 class AnisoValTraits;
20 
21 template <>
22 ParsingDictionary<AnisoValTraits> make_parsing_dictionary<AnisoValTraits>();
23 
26  public:
27  static const unsigned char LOCAL = 0;
28  static const unsigned char GLOBAL = (1u << 0);
29  static const unsigned char UNIT_LENGTH = (1u << 1);
30  static const unsigned char DESCRIBES_ORIENTATION = (1u << 2);
31  static const unsigned char EXTENSIVE = (1u << 3);
32 
34  static AnisoValTraits null();
35 
37  static AnisoValTraits occ();
38 
40  static AnisoValTraits energy();
41 
43  static AnisoValTraits cost();
44 
47 
49  static AnisoValTraits disp();
50 
52  static AnisoValTraits coordinate();
53 
55  static AnisoValTraits latvec();
56 
58  static AnisoValTraits force();
59 
61  static AnisoValTraits isometry();
62 
64  static AnisoValTraits strain(std::string const &_metric);
65 
67  static AnisoValTraits SOmagspin();
68 
72 
74  static AnisoValTraits NCmagspin();
75 
79 
81  static AnisoValTraits Cmagspin();
82 
85 
88 
91 
98  static std::string name_suffix(std::string const &_name, char delim = '_') {
99  std::string result;
100  for (char c : _name) {
101  if (c == delim)
102  result.clear();
103  else
104  result.push_back(c);
105  }
106  return result;
107  }
108 
111  std::string const &_name, std::vector<std::string> const &_std_var_names,
112  unsigned char _options,
113  SymRepBuilderInterface const &_symrep_builder = NullSymRepBuilder(),
114  std::set<std::string> const &_incompatible = {},
115  std::set<std::string> const &_must_apply_before = {},
116  std::set<std::string> const &_must_apply_after = {},
117  std::vector<std::string> const &_variable_descriptions = {},
118  bool _default = false);
119 
121  AnisoValTraits(std::string const &_name);
122 
124  static std::string class_desc() { return "AnisoValTraits"; }
125 
128  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
129  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal) const {
130  if (m_symrep_builder != nullptr) {
131  return m_symrep_builder->symop_to_matrix(_matrix, _tau, time_reversal,
132  dim());
133  }
134  // else
135  return Eigen::MatrixXd::Identity(dim(), dim());
136  }
137 
139  std::string const &name() const { return m_name; }
140 
143  bool is_default() const { return m_default; }
144 
146  unsigned char options() const { return m_opt; }
147 
149  bool extensive() const { return m_opt & EXTENSIVE; }
150 
151  // Please use !AnisoValTraits::global() instead of implementing
152  // AnisoValTraits::local()
153  // bool local()const {
154  // return !global();
155  //}
156 
158  bool global() const { return m_opt & GLOBAL; }
159 
161  bool unit_length() const { return m_opt & UNIT_LENGTH; }
162 
164  bool time_reversal_active() const {
165  return m_symrep_builder->time_reversal_active();
166  }
167 
171  return m_opt & DESCRIBES_ORIENTATION;
172  }
173 
175  Index dim() const { return standard_var_names().size(); }
176 
178  bool operator==(std::string const &other_name) const {
179  return name() == other_name;
180  }
181 
183  bool operator<(std::string const &other_name) const {
184  return name() < other_name;
185  }
186 
188  operator std::string const &() const { return name(); }
189 
191  std::vector<std::string> const &standard_var_names() const {
192  return m_standard_var_names;
193  }
194 
196  std::vector<std::string> const &variable_descriptions() const {
198  }
199 
202  std::set<std::string> const &incompatible() const { return m_incompatible; }
203 
206  std::set<std::string> const &must_apply_before() const {
207  return m_apply_before;
208  }
209 
212  std::set<std::string> const &must_apply_after() const {
213  return m_apply_after;
214  }
215 
217  std::unique_ptr<AnisoValTraits> clone() const {
218  return notstd::make_unique<AnisoValTraits>(*this);
219  }
220 
222  std::string symrep_builder_name() const {
223  if (m_symrep_builder)
224  return m_symrep_builder->name();
225  else
226  return "NULL";
227  }
228 
229  protected:
230  std::string m_name;
231  bool m_default;
232  std::vector<std::string> m_standard_var_names;
233  std::vector<std::string> m_variable_descriptions;
234  unsigned char m_opt;
236  std::set<std::string> m_incompatible;
237  std::set<std::string> m_apply_before;
238  std::set<std::string> m_apply_after;
239 };
240 
245 inline bool identical(AnisoValTraits const &A, AnisoValTraits const &B) {
246  return (A.name() == B.name() && A.is_default() == B.is_default() &&
249  A.options() == B.options() &&
251  A.must_apply_after() == B.must_apply_after() &&
252  A.incompatible() == B.incompatible());
253 }
254 
255 } // namespace CASM
256 
257 #endif
Specifies traits of (possibly) anisotropic crystal properties.
static AnisoValTraits strain(std::string const &_metric)
Named constructor for global strain AnisoValTraits.
std::unique_ptr< AnisoValTraits > clone() const
Clone this object.
static AnisoValTraits SOmagspin()
Non-collinear magnetic spin, with spin-orbit coupling.
std::vector< std::string > const & standard_var_names() const
Return standard coordinate axes for continuous variable space.
std::set< std::string > const & must_apply_after() const
When used as a DoF, this is a set of DoFs that must be applied after this DoF is applied.
std::set< std::string > const & must_apply_before() const
When used as a DoF, this is a set of DoFs that must be applied before this DoF is applied.
bool extensive() const
Returns true if type is extensive.
static AnisoValTraits force()
Named constructor for site force AnisoValTraits.
unsigned char options() const
Return 'options' bitflag.
static AnisoValTraits NCunitmagspin()
Non-collinear magnetic spin, without spin-orbit coupling, constrained to unit length.
static AnisoValTraits isometry()
Named constructor for global 'isometry' AnisoValTraits.
bool is_default() const
Return true if *this has 'default' designation, meaning it can be overridden.
bool operator<(std::string const &other_name) const
Lexicographic comparison of name.
static AnisoValTraits Cmagspin()
Collinear magnetic spin.
std::set< std::string > m_apply_before
static AnisoValTraits disp()
Named constructor for site displacement AnisoValTraits.
static const unsigned char EXTENSIVE
static AnisoValTraits latvec()
Named constructor for lattice vector AnisoValTraits.
std::vector< std::string > m_standard_var_names
static std::string class_desc()
Returns "AnisoValTraits".
bool time_reversal_active() const
Returns true if time-reversal changes the value.
std::string const & name() const
Const access of name.
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal) const
Generate a symmetry representation for the supporting vector space.
static AnisoValTraits selective_dynamics()
Named constructor for selective_dynamics AnisoValTraits.
static const unsigned char LOCAL
static const unsigned char UNIT_LENGTH
static AnisoValTraits NCmagspin()
Non-collinear magnetic spin, without spin-orbit coupling.
static AnisoValTraits d_orbital_occupation_spin_polarized()
Named constructor for spin-polarized d-orbital occupation AnisoValTraits.
static AnisoValTraits Cunitmagspin()
Collinear magnetic spin, constrained to unit length.
std::vector< std::string > const & variable_descriptions() const
Returns expanded description of each standard_var_name.
static AnisoValTraits SOunitmagspin()
Non-collinear magnetic spin, with spin-orbit coupling, constrained to unit length.
std::string symrep_builder_name() const
Return name of the SymRepBuilderInterface.
std::set< std::string > m_incompatible
Index dim() const
Conventional dimensionality of this type, returns -1 if always variable.
std::set< std::string > const & incompatible() const
When used as a DoF, this is a set of DoFs that are incompatible with this type of DoF.
static AnisoValTraits d_orbital_occupation()
Named constructor for d-orbital occupation AnisoValTraits.
static AnisoValTraits coordinate()
Named constructor for site coordinate AnisoValTraits.
static const unsigned char GLOBAL
notstd::cloneable_ptr< const SymRepBuilderInterface > m_symrep_builder
static AnisoValTraits occ()
Named constructor for discrete site occupation AnisoValTraits.
bool operator==(std::string const &other_name) const
Equality comparison of name.
static const unsigned char DESCRIBES_ORIENTATION
bool global() const
Returns true if type is global.
AnisoValTraits(std::string const &_name, std::vector< std::string > const &_std_var_names, unsigned char _options, SymRepBuilderInterface const &_symrep_builder=NullSymRepBuilder(), std::set< std::string > const &_incompatible={}, std::set< std::string > const &_must_apply_before={}, std::set< std::string > const &_must_apply_after={}, std::vector< std::string > const &_variable_descriptions={}, bool _default=false)
Explicit constructor for AnisoValTraits.
static AnisoValTraits cost()
Named constructor for mapping cost AnisoValTraits.
bool describes_occupant_orientation() const
bool unit_length() const
Returns true if type must always have unit length.
static std::string name_suffix(std::string const &_name, char delim='_')
std::set< std::string > m_apply_after
std::vector< std::string > m_variable_descriptions
static AnisoValTraits energy()
Named constructor for total energy AnisoValTraits.
Un-cloneable class for specifying absence of valid SymRepBuilder.
Abstract base class that provides interface for converting cartesian isometry to specialized transfor...
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
IdentitySymRepBuilder Identity()
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
ParsingDictionary< AnisoValTraits > make_parsing_dictionary< AnisoValTraits >()
bool identical(AnisoValTraits const &A, AnisoValTraits const &B)
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39