QMCPACK
ScalarEstimatorInputs.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 // File refactored from: EstimatorManagerNew.h
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef QMCPLUSPLUS_SCALAR_ESTIMATOR_INPUTS_H
13 #define QMCPLUSPLUS_SCALAR_ESTIMATOR_INPUTS_H
14 
15 #include "InputSection.h"
16 
17 /** \file
18  * This file contains the input classes for the
19  * supported "main estimator" classes derived from ScalarEstimatorBase.
20  *
21  * see: LocalEnergyEstimator.h, CSEnergyEstimator.h, RMCLocalEnergyEstimator.h
22  *
23  * The legacy input format used the <estimator> name attribute instead of the type attribute
24  * to indicate the type of the scalar estimators. There would otherwise be no reason to
25  * retain the name attribute reading or native input variable.
26  *
27  * The current implementation sets the native type_ or name_ equal in value to
28  * match if only name or attribute is present in input. If both are present name is
29  * ignored and only type is used for type determination. The name can be set to anything
30  * as is typical of name attributes in the input but at the moment that name is not
31  * used in output or anywhere else.
32  *
33  * EstimatorManagerInput will delegate parsing of scalar estimator inputs to these
34  * classes based on the type of the estimator as determined by reading the type attribute in the
35  * raw input. We still fixup the name_ and type_ in the implementation to create input classes
36  * consistent with the expected "input state."
37  */
38 
39 namespace qmcplusplus
40 {
41 
42 class LocalEnergyEstimator;
43 
45 {
47  {
48  public:
50  {
51  section_name = "LocalEnergy";
52  section_name_alternates = {"elocal"};
53  attributes = {"name", "type", "hdf5"};
54  bools = {"hdf5"};
55  strings = {"name", "type"};
56  };
57  };
58 
59 public:
61  // required because legacy code using LocalEnergyEstimator does not use input object.
62  // LocalEnergyInput must be trivially constructable.
63  LocalEnergyInput() = default;
64  LocalEnergyInput(xmlNodePtr cur);
65  bool get_use_hdf5() const { return use_hdf5_; }
66  const std::string& get_name() const { return name_; }
67  const std::string& get_type() const { return type_; }
68 
69 private:
70  std::string name_;
71  std::string type_ = "LocalEnergy";
73  bool use_hdf5_ = true;
74 };
75 
76 struct CSEnergyEstimator;
77 
79 {
81  {
82  public:
84  {
85  section_name = "CSLocalEnergy";
86  attributes = {"name", "npsi", "type"};
87  integers = {"npsi"};
88  strings = {"name", "type"};
89  }
90  };
91 
92 public:
94  // required because legacy code using CSEnergyEstimator does not use input object.
95  // So CSLocalEnergyInput must be trivially constructable.
96  CSLocalEnergyInput() = default;
97  CSLocalEnergyInput(xmlNodePtr cur);
98  int get_n_psi() const { return n_psi_; }
99  const std::string& get_name() const { return name_; }
100  const std::string& get_type() const { return type_; }
101 
102 private:
103  std::string name_;
104  std::string type_ = "CSLocalEnergy";
106  int n_psi_ = 1;
107 };
108 
110 
112 {
114  {
115  public:
117  {
118  section_name = "RMCLocalEnergy";
119  section_name_alternates = {"rmc"};
120  attributes = {"name", "nobs", "type"};
121  integers = {"nobs"};
122  strings = {"name", "type"};
123  }
124  };
125 
126 public:
128  // required because legacy code using RMCLocalEnergyEstimator does not use input object.
129  // So RMCLocalEnergyInput must be trivially constructable.
130 
131  RMCLocalEnergyInput() = default;
132  RMCLocalEnergyInput(xmlNodePtr cur);
133  int get_n_obs() const { return n_obs_; }
134  const std::string& get_name() const { return name_; }
135  const std::string& get_type() const { return type_; }
136 
137 private:
138  std::string name_;
139  std::string type_ = "RMCLocalEnergy";
141  int n_obs_ = 1;
142 };
143 
144 } // namespace qmcplusplus
145 
146 #endif
std::unordered_set< std::string > strings
Definition: InputSection.h:67
const std::string & get_type() const
CSLocalEnergyInputSection input_section_
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Class to accumulate the local energy and components.
std::vector< std::string > section_name_alternates
For historical reasons some sections must recognize several different names. Assign them to this vari...
Definition: InputSection.h:60
const std::string & get_type() const
Class to accumulate the local energy and components.
const std::string & get_type() const
const std::string & get_name() const
LocalEnergyInputSection input_section_
RMCLocalEnergyInputSection input_section_
const std::string & get_name() const
std::unordered_set< std::string > integers
Definition: InputSection.h:71
std::unordered_set< std::string > attributes
Definition: InputSection.h:62
std::unordered_set< std::string > bools
Definition: InputSection.h:70
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
const std::string & get_name() const