CASM  1.1.0
A Clusters Approach to Statistical Mechanics
DoFTraits.hh
Go to the documentation of this file.
1 #ifndef CASM_DoFTraits
2 #define CASM_DoFTraits
3 
4 #include "casm/basis_set/DoF.hh"
10 
11 namespace CASM {
12 namespace xtal {
13 class Site;
14 class BasicStructure;
15 class SimpleStructure;
16 class UnitCellCoord;
17 struct SymOp;
18 } // namespace xtal
19 using xtal::BasicStructure;
20 using xtal::SimpleStructure;
21 using xtal::Site;
22 using xtal::UnitCellCoord;
23 
24 template <typename T>
25 class InputParser;
26 class jsonParser;
27 class PrimNeighborList;
28 struct BasisFunctionSpecs;
29 class BasisSet;
30 class Structure;
31 
32 template <typename T>
33 class ParsingDictionary;
34 
35 class ConfigDoF;
36 
37 namespace DoFType {
38 class Traits;
39 struct ParamAllocation;
40 
43 
48 
50 void register_traits(Traits const &_traits);
51 
53 Traits const &traits(std::string const &dof_key);
54 
56 DoF::BasicTraits const &basic_traits(std::string const &dof_key);
57 
59 class Traits {
60  public:
61  static std::string class_desc() { return "DoFType::Traits"; }
62 
63  Traits(AnisoValTraits const &_val_traits, bool _requires_site_basis = false)
64  : m_val_traits(_val_traits),
65  m_requires_site_basis(_requires_site_basis) {}
66 
67  AnisoValTraits const &val_traits() const { return m_val_traits; }
68 
69  std::string const &name() const { return val_traits().name(); }
70 
71  std::string site_basis_name() const { return name() + "_site_func"; }
72 
73  bool requires_site_basis() const { return m_requires_site_basis; }
74 
76  virtual ~Traits() {}
77 
82  virtual std::pair<Eigen::MatrixXd, std::set<std::string> > find_values(
83  std::map<std::string, Eigen::MatrixXd> const &values) const;
84 
87  virtual std::vector<BasisSet> construct_site_bases(
88  Structure const &_prim,
89  std::vector<Orbit<PrimPeriodicSymCompare<IntegralCluster> > > &_asym_unit,
90  BasisFunctionSpecs const &_basis_function_specs) const = 0;
91 
93  virtual void from_json(DoFSet &_in, jsonParser const &_json) const {}
94 
96  virtual void to_json(DoFSet const &_out, jsonParser &_json) const;
97 
100  virtual void apply_dof(ConfigDoF const &_dof,
101  BasicStructure const &_reference,
102  SimpleStructure &_struc) const;
103 
105  virtual jsonParser dof_to_json(ConfigDoF const &_dof,
106  BasicStructure const &_reference) const;
107 
108  // ** The following functionality is utilized for controlling clexulator
109  // printing. It only needs to be overridden in special cases **
110 
112  virtual std::vector<std::unique_ptr<FunctionVisitor> > site_function_visitors(
113  std::string const &nlist_specifier = "%n") const;
114 
115  virtual std::vector<std::unique_ptr<FunctionVisitor> >
116  clust_function_visitors() const;
117 
118  virtual std::string site_basis_description(BasisSet site_bset, Site site,
119  Index site_ix) const;
120 
121  virtual std::vector<ParamAllocation> param_pack_allocation(
122  Structure const &_prim, std::vector<BasisSet> const &_bases) const;
123 
124  virtual std::string clexulator_constructor_string(
125  Structure const &_prim, std::vector<BasisSet> const &site_bases,
126  std::string const &indent) const;
127 
128  virtual std::string clexulator_point_prepare_string(
129  Structure const &_prim,
130  std::map<UnitCellCoord, std::set<UnitCellCoord> > const &_nhood,
131  PrimNeighborList &_nlist, std::vector<BasisSet> const &site_bases,
132  std::string const &indent) const;
133 
134  virtual std::string clexulator_global_prepare_string(
135  Structure const &_prim,
136  std::map<UnitCellCoord, std::set<UnitCellCoord> > const &_nhood,
137  PrimNeighborList &_nlist, std::vector<BasisSet> const &site_bases,
138  std::string const &indent) const;
139 
140  virtual std::string clexulator_member_declarations_string(
141  Structure const &_prim, std::vector<BasisSet> const &site_bases,
142  std::string const &indent) const;
143 
145  Structure const &_prim, std::vector<BasisSet> const &site_bases,
146  std::string const &indent) const;
147 
149  Structure const &_prim, std::vector<BasisSet> const &site_bases,
150  std::string const &indent) const;
151 
153  Structure const &_prim, std::vector<BasisSet> const &site_bases,
154  std::string const &indent) const;
155 
157  Structure const &_prim, std::vector<BasisSet> const &site_bases,
158  std::string const &indent) const;
159 
180  Structure const &prim) const {}
181 
183  virtual void dof_specs_to_json(BasisFunctionSpecs const &basis_function_specs,
184  jsonParser &json,
185  Structure const &prim) const {}
186 
188  std::unique_ptr<Traits> clone() const {
189  return std::unique_ptr<Traits>(_clone());
190  }
191 
192  private:
193  virtual Traits *_clone() const = 0;
194 
197 };
198 
200  public:
201  ParamAllocation(std::string const &_param_name, Index _param_dim,
202  Index _num_param, bool _independent)
203  : param_name(_param_name),
204  param_dim(_param_dim),
205  num_param(_num_param),
206  independent(_independent) {}
207 
208  const std::string param_name;
211  const bool independent;
212 };
213 
214 } // namespace DoFType
215 
216 } // namespace CASM
217 #endif
Specifies traits of (possibly) anisotropic crystal properties.
std::string const & name() const
Const access of name.
Collection of all the traits specific to a DoF type.
Definition: DoFTraits.hh:59
virtual void parse_dof_specs(InputParser< BasisFunctionSpecs > &parser, Structure const &prim) const
Definition: DoFTraits.hh:179
AnisoValTraits const & val_traits() const
Definition: DoFTraits.hh:67
virtual std::string clexulator_private_method_definitions_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:307
virtual jsonParser dof_to_json(ConfigDoF const &_dof, BasicStructure const &_reference) const
Serialize type-specific DoF values from ConfigDoF.
Definition: DoFTraits.cc:105
virtual std::string clexulator_global_prepare_string(Structure const &_prim, std::map< UnitCellCoord, std::set< UnitCellCoord > > const &_nhood, PrimNeighborList &_nlist, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:200
virtual std::string clexulator_public_method_declarations_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:315
virtual Traits * _clone() const =0
virtual void apply_dof(ConfigDoF const &_dof, BasicStructure const &_reference, SimpleStructure &_struc) const
Transforms SimpleSructure.
Definition: DoFTraits.cc:99
virtual std::pair< Eigen::MatrixXd, std::set< std::string > > find_values(std::map< std::string, Eigen::MatrixXd > const &values) const
Retrieve the standard values for a DoF from dictionary of properties from properties....
Definition: DoFTraits.cc:58
virtual std::vector< BasisSet > construct_site_bases(Structure const &_prim, std::vector< Orbit< PrimPeriodicSymCompare< IntegralCluster > > > &_asym_unit, BasisFunctionSpecs const &_basis_function_specs) const =0
Construct the site basis (if DOF_MODE is LOCAL) for a DoF, given its site.
virtual void from_json(DoFSet &_in, jsonParser const &_json) const
Populate.
Definition: DoFTraits.hh:93
virtual std::string clexulator_private_method_declarations_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:331
virtual std::string clexulator_member_declarations_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:269
virtual std::string clexulator_point_prepare_string(Structure const &_prim, std::map< UnitCellCoord, std::set< UnitCellCoord > > const &_nhood, PrimNeighborList &_nlist, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:118
virtual std::string site_basis_description(BasisSet site_bset, Site site, Index site_ix) const
Definition: DoFTraits.cc:517
virtual ~Traits()
Allow destruction through base pointer.
Definition: DoFTraits.hh:76
virtual std::string clexulator_public_method_definitions_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:323
bool requires_site_basis() const
Definition: DoFTraits.hh:73
static std::string class_desc()
Definition: DoFTraits.hh:61
virtual std::vector< ParamAllocation > param_pack_allocation(Structure const &_prim, std::vector< BasisSet > const &_bases) const
Definition: DoFTraits.cc:443
Traits(AnisoValTraits const &_val_traits, bool _requires_site_basis=false)
Definition: DoFTraits.hh:63
virtual void to_json(DoFSet const &_out, jsonParser &_json) const
Output.
Definition: DoFTraits.cc:74
virtual void dof_specs_to_json(BasisFunctionSpecs const &basis_function_specs, jsonParser &json, Structure const &prim) const
Output DoF-specific basis function specs to json. Default does nothing.
Definition: DoFTraits.hh:183
virtual std::vector< std::unique_ptr< FunctionVisitor > > clust_function_visitors() const
Definition: DoFTraits.cc:499
virtual std::vector< std::unique_ptr< FunctionVisitor > > site_function_visitors(std::string const &nlist_specifier="%n") const
Definition: DoFTraits.cc:491
std::string site_basis_name() const
Definition: DoFTraits.hh:71
virtual std::string clexulator_constructor_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:479
AnisoValTraits m_val_traits
Definition: DoFTraits.hh:195
std::unique_ptr< Traits > clone() const
non-virtual method to obtain copy through Traits pointer
Definition: DoFTraits.hh:188
std::string const & name() const
Definition: DoFTraits.hh:69
An Orbit of Element.
Definition: Orbit.hh:43
Parsing dictionary for obtaining the correct MoleculeAttribute given a name.
The PrimNeighborList gives the coordinates of UnitCell that are neighbors of the origin UnitCell.
Definition: NeighborList.hh:39
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:30
BasicStructure specifies the lattice and atomic basis of a crystal.
Representation of a crystal of molecular and/or atomic occupants, and any additional properties....
Unit Cell Coordinates.
void register_traits(Traits const &_traits)
Insert new DoFType::Traits into the global dictionary.
Definition: DoFTraits.cc:44
TraitsDictionary & traits_dict()
Definition: DoFTraits.cc:39
Traits const & traits(std::string const &dof_key)
Lookup DoFType::Traits in the global dictionary.
Definition: DoFTraits.cc:46
DoF::BasicTraits const & basic_traits(std::string const &dof_key)
Access DoF::BasicTraits for a given DoF type.
Definition: DoFTraits.cc:50
Main CASM namespace.
Definition: APICommand.hh:8
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Specify how to construct basis functions.
const std::string param_name
Definition: DoFTraits.hh:208
ParamAllocation(std::string const &_param_name, Index _param_dim, Index _num_param, bool _independent)
Definition: DoFTraits.hh:201