CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
OccupantFunction.hh
Go to the documentation of this file.
1 #ifndef OCCUPANTFUNCTION_HH
2 #define OCCUPANTFUNCTION_HH
3 
4 #include <iostream>
5 #include <sstream>
6 #include <map>
8 #include "casm/basis_set/DoF.hh"
9 
10 namespace CASM {
11 
12  class Function;
13  class FunctionOperation;
14  class InnerProduct;
15  class OccupantFunction;
16 
17  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18  //
19  //
20  //
21  //
22  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 
24 
26  public Function, public DerivedID<OccupantFunction, Function> {
27  public:
28  OccupantFunction(const DiscreteDoF &init_var, const Eigen::VectorXd &init_eval, int _occ_func_ind, int _basis_ind, SymGroupRepID _sym_rep_ID):
29  m_var(init_var.copy()), m_eval_table(init_eval), m_sym_rep_ID(_sym_rep_ID), m_occ_func_ind(_occ_func_ind), m_basis_ind(_basis_ind) { }
30 
33 
35  if(m_var)
36  delete m_var;
37  }
38 
39  static int sclass_ID();
40  int class_ID() const;
41 
42  std::string type_name() const {
43  return "OccupantFunction";
44  }
45 
47  return m_occ_func_ind;
48  }
49 
50  Index basis_ind()const {
51  return m_basis_ind;
52  }
53 
54  void set_basis_ind(int new_ind) {
55  m_basis_ind = new_ind;
56  }
57 
58  const DiscreteDoF &dof() const {
59  return *m_var;
60  }
61 
62 
63  Function *copy() const;
64 
65  bool is_zero() const;
66  Index num_terms() const;
67 
68  const Eigen::VectorXd &eval_table() const {
69  return m_eval_table;
70  }
71 
72  double leading_coefficient() const;
73  double leading_coefficient(Index &index) const;
74  double get_coefficient(Index i) const;
75 
76 
77  void small_to_zero(double tol = TOL);
78  void scale(double scale_factor);
79  void make_formula() const;
80 
81  int register_remotes(const std::string &dof_name, const Array<DoF::RemoteHandle> &remote_handles);
82 
83  bool compare(const OccupantFunction *RHS) const;
84 
85  static void fill_dispatch_table();
86  Eigen::VectorXd const *get_eigen_coeffs() const;
87 
88  double remote_eval() const;
89 
90  double remote_deval(const DoF::RemoteHandle &dvar) const;
91 
92  double cache_eval() const {
93  return remote_eval();
94  }
95 
96  double cache_deval(const DoF::RemoteHandle &dvar)const {
97  return remote_deval(dvar);
98  }
99 
100  double eval(const Array<Index> &dof_IDs, const Array<Index> &var_states) const;
101 
102  jsonParser &to_json(jsonParser &json) const;
103  void from_json(const jsonParser &json);
104  protected:
105  Function *_apply_sym(const SymOp &op);
106 
107  bool _accept(const FunctionVisitor &visitor, BasisSet const *home_basis_ptr = NULL);
108 
109  bool _update_dof_IDs(const Array<Index> &before_IDs, const Array<Index> &after_IDs);
110 
111  private:
112  //**Inherited from Function:**
113  // Index func_ID;
114  // Array<Function*> m_argument;
115  // mutable std::string m_formula, m_tex_formula;
116  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
117 
118  //Array<std::string> m_formula_bits; //mutable?
119 
124 
125  OccupantFunction() : m_var(nullptr) {} // no default construction
126 
127  };
128 
129  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130 
132  public:
133  bool compare(Function const *LHS, Function const *RHS) const;
134 
135  //Function *multiply(Function const *LHS, Function const *RHS) const;
136  //Function *multiply_by(Function *LHS, Function const *RHS) const;
137 
138  //Function *add(Function const *LHS, Function const *RHS) const;
139  //Function *add_to(Function *LHS, Function const *RHS) const;
140 
141  //Function *subtract(Function const *LHS, Function const *RHS) const;
142  //Function *subtract_from(Function *LHS, Function const *RHS) const;
143  };
144 
145  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146 
147 
148 
149  jsonParser &to_json(const OccupantFunction &func, jsonParser &json);
150  void from_json(OccupantFunction &func, const jsonParser &json);
151 
152 
153 }
154 #endif
double cache_eval() const
Function * _apply_sym(const SymOp &op)
void from_json(ClexDescription &desc, const jsonParser &json)
double leading_coefficient() const
Type-safe ID object for communicating and accessing Symmetry representation info. ...
bool compare(const OccupantFunction *RHS) const
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void scale(double scale_factor)
double cache_deval(const DoF::RemoteHandle &dvar) const
OccupantFunction(const DiscreteDoF &init_var, const Eigen::VectorXd &init_eval, int _occ_func_ind, int _basis_ind, SymGroupRepID _sym_rep_ID)
Main CASM namespace.
Definition: complete.cpp:8
double eval(const Array< Index > &dof_IDs, const Array< Index > &var_states) const
const double TOL
OccupantFunction(const OccupantFunction &RHS)
double tol
void from_json(const jsonParser &json)
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
bool compare(Function const *LHS, Function const *RHS) const
EigenIndex Index
For long integer indexing:
Eigen::VectorXd VectorXd
bool _accept(const FunctionVisitor &visitor, BasisSet const *home_basis_ptr=NULL)
void set_basis_ind(int new_ind)
Eigen::VectorXd const * get_eigen_coeffs() const
void small_to_zero(double tol=TOL)
const Eigen::VectorXd & eval_table() const
Function * copy() const
double remote_eval() const
int register_remotes(const std::string &dof_name, const Array< DoF::RemoteHandle > &remote_handles)
Index occ_func_ind() const
Eigen::VectorXd m_eval_table
bool _update_dof_IDs(const Array< Index > &before_IDs, const Array< Index > &after_IDs)
double remote_deval(const DoF::RemoteHandle &dvar) const
Basic std::vector like container (deprecated)
jsonParser & to_json(jsonParser &json) const
const DiscreteDoF & dof() const
static void fill_dispatch_table()
double get_coefficient(Index i) const
std::string type_name() const