QMCPACK
OneBodyDensityMatricesInput.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2022 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8 //
9 // Some code refactored from: DensityMatrices1b.h
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef QMCPLUSPLUS_ONE_BODY_DENSITY_MATRICES_INPUT_H
13 #define QMCPLUSPLUS_ONE_BODY_DENSITY_MATRICES_INPUT_H
14 
15 #include "Configuration.h"
16 #include "InputSection.h"
17 
18 namespace qmcplusplus
19 {
20 namespace testing
21 {
22 template<typename T>
23 class OneBodyDensityMatricesTests;
24 }
25 
26 class OneBodyDensityMatrices;
27 
28 /** Native representation for DensityMatrices1B Estimator's inputs
29  */
31 {
32 public:
34 
35  enum class Integrator
36  {
38  UNIFORM,
39  DENSITY
40  };
41 
42  enum class Evaluator
43  {
44  LOOP,
45  MATRIX
46  };
47 
48  /** mapping for enumerated options of OneBodyDensityMatrices
49  * This data object is the basis of input enum string values
50  * translation to native C++ scoped enums. This boiler plate is
51  * generated by utils/code_tools/qmcpack-elisp-generators.el
52  * qmcp-add-enum-string-map
53  *
54  * This plus the virtual assignAnyEnum method are needed by InputSection to
55  * validate and assign enum values from input.
56  *
57  * In testing code we assume this map is bidirectional.
58  */
59  inline static const std::unordered_map<std::string, std::any>
60  lookup_input_enum_value{{"integrator-uniform_grid", Integrator::UNIFORM_GRID},
61  {"integrator-uniform", Integrator::UNIFORM},
62  {"integrator-density", Integrator::DENSITY},
63  {"evaluator-loop", Evaluator::LOOP},
64  {"evaluator-matrix", Evaluator::MATRIX}};
65 
67  {
68  public:
69  /** parse time definition of input parameters */
71  {
72  // clang-format off
73  section_name = "OneBodyDensityMatrices";
74  attributes = {"name", "type"};
75  parameters = {"basis", "energy_matrix", "integrator", "evaluator", "scale",
76  "corner", "center", "points", "samples", "warmup", "timestep",
77  "use_drift", "check_overlap", "check_derivatives", "acceptance_ratio", "rstats",
78  "normalized", "volumed_normed"};
79  bools = {"energy_matrix", "use_drift", "normalized", "volume_normed",
80  "check_overlap", "check_derivatives", "rstats", "acceptance_ratio"};
81  enums = {"integrator", "evaluator"};
82  strings = {"name", "type"};
83  multi_strings = {"basis"};
84  integers = {"points", "samples"};
85  reals = {"scale", "timestep"};
86  positions = {"center", "corner"};
87  required = {"name", "basis"};
88  // I'd much rather see the default defined in simple native c++ as below
89  // clang-format on
90  }
92  /** do parse time checks of input */
93  void checkParticularValidity() override;
94  std::any assignAnyEnum(const std::string& name) const override;
95  };
96 
99 
100  /** default copy constructor
101  * This is required due to OBDMI being part of a variant used as a vector element.
102  */
104  OneBodyDensityMatricesInput(xmlNodePtr cur);
105 
106 private:
108 
109  // Default parameters for OneBodyDensityMatrices
110  bool energy_matrix_ = false;
111  bool use_drift_ = false;
112  bool normalized_ = true;
113  bool volume_normalized_ = true;
114  bool check_overlap_ = false;
115  bool check_derivatives_ = false;
116  bool rstats_ = false;
118  /// This flag is derived from input so if you construct an OBDMI directly with center it must be set.
119  bool center_defined_ = false;
120  bool corner_defined_ = false;
123  Real scale_ = 1.0;
124  /// center_ does not have a default. The estimator sets if from input Lattice if it isn't set
128  int points_ = 10;
129  int samples_ = 10;
130  int warmup_samples_ = 30;
131  std::vector<std::string> basis_sets_;
132 
133 public:
134  bool get_energy_matrix() const { return energy_matrix_; }
135  bool get_use_drift() const { return use_drift_; }
136  bool get_normalized() const { return normalized_; }
137  bool get_volume_normalized() const { return volume_normalized_; }
138  bool get_check_overlap() const { return check_overlap_; }
139  bool get_check_derivatives() const { return check_derivatives_; }
140  bool get_rstats() const { return rstats_; }
143  Evaluator get_evaluator() const { return evaluator_; }
144  Real get_scale() const { return scale_; }
145  Position get_center() const { return center_; }
146  Position get_corner() const { return corner_; }
147  bool get_center_defined() const { return center_defined_; }
148  bool get_corner_defined() const { return corner_defined_; }
149  Real get_timestep() const { return timestep_; }
150  int get_points() const { return points_; }
151  int get_samples() const { return samples_; }
152  int get_warmup_samples() const { return warmup_samples_; }
153  const std::vector<std::string>& get_basis_sets() const { return basis_sets_; }
154  template<typename T>
156 };
157 
158 extern template bool InputSection::setIfInInput<qmcplusplus::OneBodyDensityMatricesInput::Integrator>(
160  const std::string& tag);
161 
162 } // namespace qmcplusplus
163 
164 #endif
std::unordered_set< std::string > strings
Definition: InputSection.h:67
std::unordered_set< std::string > reals
Definition: InputSection.h:72
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::unordered_set< std::string > parameters
Definition: InputSection.h:63
Per crowd Estimator for OneBodyDensityMatrices aka 1RDM DensityMatrices1B.
std::unordered_set< std::string > positions
Definition: InputSection.h:73
Position center_
center_ does not have a default. The estimator sets if from input Lattice if it isn&#39;t set ...
Native representation for DensityMatrices1B Estimator&#39;s inputs.
std::unordered_set< std::string > integers
Definition: InputSection.h:71
OneBodyDensityMatricesInput(const OneBodyDensityMatricesInput &)=default
default copy constructor This is required due to OBDMI being part of a variant used as a vector eleme...
std::unordered_set< std::string > attributes
Definition: InputSection.h:62
bool center_defined_
This flag is derived from input so if you construct an OBDMI directly with center it must be set...
static const std::unordered_map< std::string, std::any > lookup_input_enum_value
mapping for enumerated options of OneBodyDensityMatrices This data object is the basis of input enum ...
std::unordered_set< std::string > required
Definition: InputSection.h:65
const std::vector< std::string > & get_basis_sets() const
OneBodyDensityMatricesInputSection input_section_
std::unordered_set< std::string > multi_strings
Definition: InputSection.h:68
std::unordered_set< std::string > bools
Definition: InputSection.h:70
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
Input section provides basic parsing and a uniform method of access to the raw parsed input...
Definition: InputSection.h:37
std::string section_name
"Name" of the input section, you must define this in the subtype and the ename, name, type, or method must match.
Definition: InputSection.h:57
std::unordered_set< std::string > enums
list of enum inputs which allow a finite set of strings to map to enum values The enum class types an...
Definition: InputSection.h:78
std::any assignAnyEnum(const std::string &name) const override
Derived class overrides this to get proper assignment of scoped enum values.