CASM  1.1.0
A Clusters Approach to Statistical Mechanics
AnisoValTraits.cc
Go to the documentation of this file.
2 
3 #include <map>
4 #include <string>
5 
7 namespace CASM {
8 
105 
106 template <>
109 
121 
122  return dict;
123 }
124 
125 namespace Local {
126 
127 static std::map<std::string, AnisoValTraits> &traits_map() {
128  static std::map<std::string, AnisoValTraits> map;
129  return map;
130 }
131 
132 static void register_traits(AnisoValTraits new_traits) {
133  auto it = traits_map().find(new_traits.name());
134  // Potential name collisiont if there is already entry with new_traits.name()
135  // AND it does not carry 'default' designation. If it has 'default'
136  // designation, it can be overridden
137  if (it != traits_map().end() && !(it->second).is_default()) {
138  // If new_traits has 'default' designation or if new_traits is identical to
139  // the existing traits of the same name, then we do nothing. Otherwise,
140  // throw an exception
141  if (!(new_traits.is_default() || identical(new_traits, it->second))) {
142  throw std::runtime_error(
143  "Name collision: Attempting to register new AnisoValTraits '" +
144  new_traits.name() +
145  "' but an incompatible AnisoValTraits with that type already "
146  "exists.");
147  }
148  } else {
149  traits_map().emplace(
150  std::make_pair(new_traits.name(), std::move(new_traits)));
151  }
152 }
153 
154 static int initialize() {
175  return 1;
176 }
177 
178 static AnisoValTraits const &traits(std::string const &name) {
179  static int i = initialize();
180  auto it = traits_map().find(name);
181  if (it == traits_map().end()) {
182  throw std::runtime_error(
183  "Attempted to construct AnisoValTraits '" + name +
184  "' but no AnisoValTraits with that name is known.");
185  }
186  return it->second;
187 }
188 } // namespace Local
189 
195 AnisoValTraits::AnisoValTraits(std::string const &_name) {
196  *this = Local::traits(name_suffix(_name));
197 }
198 
230  std::string const &_name, std::vector<std::string> const &_std_var_names,
231  unsigned char _options,
232  SymRepBuilderInterface const &_symrep_builder /*= NullSymRepBuilder()*/,
233  std::set<std::string> const &_incompatible /*= {}*/,
234  std::set<std::string> const &_must_apply_before /*= {}*/,
235  std::set<std::string> const &_must_apply_after /*= {}*/,
236  std::vector<std::string> const &_variable_descriptions /*= {}*/,
237  bool _default /*= false*/)
238  : m_name(name_suffix(_name)),
239  m_default(_default),
240  m_standard_var_names(_std_var_names),
241  m_variable_descriptions(_variable_descriptions),
242  m_opt(_options),
243  m_symrep_builder(_symrep_builder.clone()),
244  m_incompatible(_incompatible),
245  m_apply_before(_must_apply_before),
246  m_apply_after(_must_apply_after) {
247  if (m_name != _name) {
248  throw std::runtime_error(
249  "Attempting to initialize AnisoValTraits object that does not satisfy "
250  "naming constraints. Name '" +
251  _name + "' was reduced to '" + m_name + "'." +
252  " Note: The underscore character '_' is not allowed.\n");
253  }
254  if (m_variable_descriptions.empty())
256 
257  Local::register_traits(*this);
258 }
259 
267  return AnisoValTraits("NULL", {}, LOCAL, NullSymRepBuilder(), {}, {}, {});
268 }
269 
277  return AnisoValTraits("occ", {}, LOCAL);
278 }
279 
289  return AnisoValTraits("energy", {"E"}, GLOBAL, SymRepBuilder::Identity(), {},
290  {}, {}, {}, true);
291 }
292 
304  return AnisoValTraits("cost", {"C"}, GLOBAL, SymRepBuilder::Identity(), {},
305  {}, {}, {}, true);
306 }
307 
317  return AnisoValTraits("selectivedynamics", {"xflag", "yflag", "zflag"}, LOCAL,
318  SymRepBuilder::Identity(), {}, {}, {}, {}, true);
319 }
320 
331  return AnisoValTraits("disp", {"dx", "dy", "dz"}, LOCAL,
332  CartesianSymRepBuilder(), {}, {}, {"atomize"}, {},
333  true);
334 }
335 
346  return AnisoValTraits("coordinate", {"cx", "cy", "cz"}, LOCAL,
347  CartesianSymRepBuilder(), {}, {}, {"atomize"}, {},
348  true);
349 }
350 
365  return AnisoValTraits(
366  "latvec", {"L1x", "L1y", "L1z", "L2x", "L2y", "L2z", "L3x", "L3y", "L3z"},
367  GLOBAL,
369  3>("Rank2AsymTensor"),
370  {}, {}, {"atomize"}, {}, true);
371 }
372 
383  return AnisoValTraits("force", {"fx", "fy", "fz"}, LOCAL | EXTENSIVE,
384  CartesianSymRepBuilder(), {}, {"atomize"}, {}, {},
385  true);
386 }
387 
402  return AnisoValTraits(
403  "isometry",
404  {"S11", "S21", "S31", "S12", "S22", "S32", "S13", "S23", "S33"}, GLOBAL,
406  3>("Rank2AsymTensor"),
407  {}, {"atomize", "disp"}, {}, {}, true);
408 }
409 
428 AnisoValTraits AnisoValTraits::strain(std::string const &_prefix) {
429  return AnisoValTraits(
430  _prefix + "strain", {"e_1", "e_2", "e_3", "e_4", "e_5", "e_6"}, GLOBAL,
431  Rank2TensorSymRepBuilder(), {}, {"atomize", "disp"}, {},
432  {"Exx", "Eyy", "Ezz", "sqrt(2)Exz", "sqrt(2)Eyz", "sqrt(2)Exy"}, true);
433 }
434 
448  return AnisoValTraits("SOmagspin", {"sx", "sy", "sz"}, LOCAL | EXTENSIVE,
449  AngularMomentumSymRepBuilder(), {}, {"atomize"}, {}, {},
450  true);
451 }
452 
464  return AnisoValTraits(
465  "SOunitmagspin", {"sx", "sy", "sz"}, LOCAL | UNIT_LENGTH | EXTENSIVE,
466  AngularMomentumSymRepBuilder(), {}, {"atomize"}, {}, {}, true);
467 }
468 
479  return AnisoValTraits("NCmagspin", {"sx", "sy", "sz"}, LOCAL | EXTENSIVE,
480  TimeReversalSymRepBuilder(), {}, {"atomize"}, {}, {},
481  true);
482 }
483 
496  return AnisoValTraits(
497  "NCunitmagspin", {"sx", "sy", "sz"}, LOCAL | UNIT_LENGTH | EXTENSIVE,
498  TimeReversalSymRepBuilder(), {}, {"atomize"}, {}, {}, true);
499 }
500 
511  return AnisoValTraits("Cmagspin", {"m"}, LOCAL | EXTENSIVE,
512  TimeReversalSymRepBuilder(), {}, {"atomize"}, {}, {},
513  true);
514 }
515 
526  return AnisoValTraits("Cunitmagspin", {"m"}, LOCAL | UNIT_LENGTH | EXTENSIVE,
527  TimeReversalSymRepBuilder(), {}, {"atomize"}, {}, {},
528  true);
529 }
530 
541  return AnisoValTraits("dorbitaloccupation",
542  {"v_1", "v_2", "v_3", "v_4", "v_5", "v_6", "v_7", "v_8",
543  "v_9", "v_10", "v_11", "v_12", "v_13", "v_14", "v_15"},
545  {"atomize"});
546 }
547 
561  return AnisoValTraits(
562  "dorbitaloccupationspinpolarized",
563  {"u_1", "u_2", "u_3", "u_4", "u_5", "u_6", "u_7", "u_8",
564  "u_9", "u_10", "u_11", "u_12", "u_13", "u_14", "u_15", "d_1",
565  "d_2", "d_3", "d_4", "d_5", "d_6", "d_7", "d_8", "d_9",
566  "d_10", "d_11", "d_12", "d_13", "d_14", "d_15"},
568 }
569 
570 } // namespace CASM
Builds symmetry representation that is the angular momentum symmetry representation of provided symop...
Specifies traits of (possibly) anisotropic crystal properties.
static AnisoValTraits strain(std::string const &_metric)
Named constructor for global strain AnisoValTraits.
static AnisoValTraits SOmagspin()
Non-collinear magnetic spin, with spin-orbit coupling.
static AnisoValTraits force()
Named constructor for site force AnisoValTraits.
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.
static AnisoValTraits Cmagspin()
Collinear magnetic spin.
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
std::string const & name() const
Const access of name.
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.
static AnisoValTraits SOunitmagspin()
Non-collinear magnetic spin, with spin-orbit coupling, constrained to unit length.
static AnisoValTraits null()
Named constructor for uninitialized AnisoValTraits.
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
static AnisoValTraits occ()
Named constructor for discrete site occupation AnisoValTraits.
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.
static std::string name_suffix(std::string const &_name, char delim='_')
std::vector< std::string > m_variable_descriptions
static AnisoValTraits energy()
Named constructor for total energy AnisoValTraits.
Builds symmetry representation as the Cartesian matrix of povided SymOp.
Builds symmetry representation as the 'dim' x 'dim' identity matrix, regardless of symop.
Builds symmetry representation as the Kronecker product of two other representations.
Un-cloneable class for specifying absence of valid SymRepBuilder.
Parsing dictionary for obtaining the correct MoleculeAttribute given a name.
std::pair< iterator, bool > insert(const value_type &value)
Insert single value.
Definition: unique_map.hh:149
Build 6x6 symmetry representation for a rank 2 Cartesian tensor represented in Kelvin notation.
Abstract base class that provides interface for converting cartesian isometry to specialized transfor...
Builds symmetry representation that is 'dim'x'dim' +Identity (-Identity) matrix if time_reversal is f...
static AnisoValTraits const & traits(std::string const &name)
static void register_traits(AnisoValTraits new_traits)
static std::map< std::string, AnisoValTraits > & traits_map()
static int initialize()
IdentitySymRepBuilder Identity()
Main CASM namespace.
Definition: APICommand.hh:8
ParsingDictionary< AnisoValTraits > make_parsing_dictionary< AnisoValTraits >()
GenericDatumFormatter< std::string, DataObject > name()
bool identical(AnisoValTraits const &A, AnisoValTraits const &B)
std::unique_ptr< T > clone(const T &obj)