CASM  1.1.0
A Clusters Approach to Statistical Mechanics
OccupantFunction.hh
Go to the documentation of this file.
1 #ifndef OCCUPANTFUNCTION_HH
2 #define OCCUPANTFUNCTION_HH
3 
4 #include <iostream>
5 #include <map>
6 #include <sstream>
7 
9 #include "casm/basis_set/DoF.hh"
11 
12 namespace CASM {
13 
14 class Function;
15 class FunctionOperation;
16 class InnerProduct;
17 class OccupantFunction;
18 
19 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 //
21 //
22 //
23 //
24 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 
26 class OccupantFunction : public Function,
27  public DerivedID<OccupantFunction, Function> {
28  public:
29  OccupantFunction(const DiscreteDoF &init_var,
30  const Eigen::VectorXd &init_eval, int _occ_func_ind,
31  int _basis_ind, SymGroupRepID _sym_rep_ID)
32  : m_var(init_var.clone()),
33  m_eval_table(init_eval),
34  m_sym_rep_ID(_sym_rep_ID),
35  m_occ_func_ind(_occ_func_ind),
36  m_basis_ind(_basis_ind) {}
37 
38  static int sclass_ID();
39  int class_ID() const override;
40 
41  std::string type_name() const override { return "OccupantFunction"; }
42 
43  Index occ_func_ind() const { return m_occ_func_ind; }
44 
45  Index basis_ind() const { return m_basis_ind; }
46 
47  void set_basis_ind(int new_ind) { m_basis_ind = new_ind; }
48 
49  const DiscreteDoF &dof() const { return *m_var; }
50 
51  Function *copy() const override;
52 
53  bool is_zero() const override;
54  Index num_terms() const override;
55 
56  const Eigen::VectorXd &eval_table() const { return m_eval_table; }
57 
58  double leading_coefficient() const override;
59  double leading_coefficient(Index &index) const override;
60  double get_coefficient(Index i) const override;
61 
62  void small_to_zero(double tol = TOL) override;
63  void scale(double scale_factor) override;
64  void make_formula() const override;
65 
66  int register_remotes(
67  const std::vector<DoF::RemoteHandle> &remote_handles) override;
68 
69  std::set<Index> dof_IDs() const override {
70  return std::set<Index>({dof().ID()});
71  }
72  bool compare(const OccupantFunction *RHS) const;
73 
74  static void fill_dispatch_table();
75  Eigen::VectorXd const *get_eigen_coeffs() const override;
76 
77  double discrete_eval(int state) const;
78 
79  double remote_eval() const override;
80 
81  double remote_deval(const DoF::RemoteHandle &dvar) const override;
82 
83  double cache_eval() const override { return remote_eval(); }
84 
85  double cache_deval(const DoF::RemoteHandle &dvar) const override {
86  return remote_deval(dvar);
87  }
88 
89  jsonParser &to_json(jsonParser &json) const override;
90  void from_json(const jsonParser &json);
91 
92  protected:
93  Function *_apply_sym(const SymOp &op) override;
94 
95  bool _accept(const FunctionVisitor &visitor,
96  BasisSet const *home_basis_ptr = NULL) override;
97 
98  bool _accept(const FunctionVisitor &visitor,
99  BasisSet const *home_basis_ptr = NULL) const override;
100 
101  bool _update_dof_IDs(const std::vector<Index> &before_IDs,
102  const std::vector<Index> &after_IDs) override;
103 
104  private:
105  //**Inherited from Function:**
106  // Index func_ID;
107  // Array<Function*> m_argument;
108  // mutable std::string m_formula, m_tex_formula;
109  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
110 
111  // Array<std::string> m_formula_bits; //mutable?
112 
117 
118  OccupantFunction() : m_var(nullptr) {} // no default construction
119 };
120 
121 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122 
124  public:
125  bool compare(Function const *LHS, Function const *RHS) const;
126 
127  // Function *multiply(Function const *LHS, Function const *RHS) const;
128  // Function *multiply_by(Function *LHS, Function const *RHS) const;
129 
130  // Function *add(Function const *LHS, Function const *RHS) const;
131  // Function *add_to(Function *LHS, Function const *RHS) const;
132 
133  // Function *subtract(Function const *LHS, Function const *RHS) const;
134  // Function *subtract_from(Function *LHS, Function const *RHS) const;
135 };
136 
137 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138 
139 jsonParser &to_json(const OccupantFunction &func, jsonParser &json);
140 void from_json(OccupantFunction &func, const jsonParser &json);
141 
142 } // namespace CASM
143 #endif
Index ID() const
Const access of integer ID.
Definition: DoF.hh:140
bool compare(Function const *LHS, Function const *RHS) const
const DiscreteDoF & dof() const
void small_to_zero(double tol=TOL) override
Eigen::VectorXd const * get_eigen_coeffs() const override
double get_coefficient(Index i) const override
std::string type_name() const override
Eigen::VectorXd m_eval_table
jsonParser & to_json(jsonParser &json) const override
bool _update_dof_IDs(const std::vector< Index > &before_IDs, const std::vector< Index > &after_IDs) override
notstd::cloneable_ptr< DiscreteDoF > m_var
double cache_deval(const DoF::RemoteHandle &dvar) const override
void from_json(const jsonParser &json)
void scale(double scale_factor) override
int class_ID() const override
double discrete_eval(int state) const
int register_remotes(const std::vector< DoF::RemoteHandle > &remote_handles) override
Function * _apply_sym(const SymOp &op) override
void make_formula() const override
double leading_coefficient() const override
void set_basis_ind(int new_ind)
bool compare(const OccupantFunction *RHS) const
bool is_zero() const override
const Eigen::VectorXd & eval_table() const
bool _accept(const FunctionVisitor &visitor, BasisSet const *home_basis_ptr=NULL) override
Function * copy() const override
std::set< Index > dof_IDs() const override
double cache_eval() const override
OccupantFunction(const DiscreteDoF &init_var, const Eigen::VectorXd &init_eval, int _occ_func_ind, int _basis_ind, SymGroupRepID _sym_rep_ID)
static void fill_dispatch_table()
Index num_terms() const override
double remote_eval() const override
double remote_deval(const DoF::RemoteHandle &dvar) const override
Type-safe ID object for communicating and accessing Symmetry representation info.
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
const double TOL
Definition: definitions.hh:30
void from_json(ClexDescription &desc, const jsonParser &json)
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd
std::unique_ptr< T > clone(const T &obj)