CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigDoF_impl.hh
Go to the documentation of this file.
1 #ifndef CASM_clex_ConfigDoF_impl
2 #define CASM_clex_ConfigDoF_impl
3 
4 #include <vector>
5 
6 #include "casm/clex/ConfigDoF.hh"
7 
8 namespace CASM {
9 
18 //
23 template <typename GlobalInfoContainerType, typename LocalInfoContainerType>
24 ConfigDoF::ConfigDoF(Index _N_sublat, Index _N_vol,
25  GlobalInfoContainerType const &global_dof_info,
26  LocalInfoContainerType const &local_dof_info,
27  std::vector<SymGroupRepID> const &occ_symrep_IDs,
28  double _tol)
29  : m_occupation(DoF::BasicTraits("occ"), _N_sublat, _N_vol, occ_symrep_IDs),
30  m_tol(_tol) {
31  for (auto const &dof : global_dof_info) {
32  DoF::BasicTraits ttraits(dof.first);
33 
34  if (!ttraits.global())
35  throw std::runtime_error(
36  "Attempting to initialize ConfigDoF global value using local DoF " +
37  dof.first);
38  m_global_dofs.emplace(
39  dof.first, GlobalContinuousConfigDoFValues(ttraits, _N_sublat, _N_vol,
40  dof.second));
41  }
42  for (auto const &dof : local_dof_info) {
43  DoF::BasicTraits ttraits(dof.first);
44  if (_N_sublat == 0) continue;
45  if (ttraits.global())
46  throw std::runtime_error(
47  "Attempting to initialize ConfigDoF local value using global DoF " +
48  dof.first);
49  if (_N_sublat != dof.second.size()) {
50  throw std::runtime_error(
51  "Attempting to initialize ConfigDoF local value '" + dof.first +
52  "' with improperly initialized parameter 'local_dof_info'.");
53  }
54 
55  m_local_dofs.emplace(
56  dof.first,
57  LocalContinuousConfigDoFValues(ttraits, _N_sublat, _N_vol, dof.second));
58  }
59 }
60 
61 } // namespace CASM
62 
63 #endif
Specifies traits of (possibly) anisotropic crystal properties.
bool global() const
Returns true if type is global.
ConfigDoF(Index _N_sublat, Index _N_vol, GlobalInfoContainerType const &global_dof_info, LocalInfoContainerType const &local_dof_info, std::vector< SymGroupRepID > const &occ_symrep_IDs, double _tol)
std::map< std::string, LocalContinuousConfigDoFValues > m_local_dofs
Definition: ConfigDoF.hh:205
std::map< std::string, GlobalContinuousConfigDoFValues > m_global_dofs
Definition: ConfigDoF.hh:203
AnisoValTraits BasicTraits
Definition: DoF.hh:34
Main CASM namespace.
Definition: APICommand.hh:8
std::map< DoFKey, std::vector< CASM::DoFSetInfo > > local_dof_info(Structure const &_struc)
Definition: Structure.cc:395
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
std::map< DoFKey, CASM::DoFSetInfo > global_dof_info(Structure const &_struc)
Definition: Structure.cc:384