QMCPACK
LocalEnergyOnlyEstimator.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #ifndef QMCPLUSPLUS_LOCALENERGY_ONLY_ESTIMATOR_H
16 #define QMCPLUSPLUS_LOCALENERGY_ONLY_ESTIMATOR_H
18 namespace qmcplusplus
19 {
20 /** Estimator for local energy only
21  */
23 {
25 
27  {
28  scalars.resize(2);
29  scalars_saved.resize(2);
30  }
31 
32  std::string getName() const override { return "LocalEnergyOnlyEstimator"; }
33 
34  inline void accumulate(const MCWalkerConfiguration& W,
35  WalkerIterator first,
36  WalkerIterator last,
37  RealType wgt) override
38  {
39  for (; first != last; ++first)
40  {
41  scalars[0]((*first)->Properties(WP::LOCALENERGY), wgt);
42  scalars[1]((*first)->Properties(WP::LOCALPOTENTIAL), wgt);
43  }
44  }
45 
46  inline void accumulate(const RefVector<MCPWalker>& walkers) override
47  {
48  for (MCPWalker& walker : walkers)
49  {
50  scalars[0](walker.Properties(WP::LOCALENERGY), 1.0);
51  scalars[1](walker.Properties(WP::LOCALPOTENTIAL), 1.0);
52  }
53  }
54 
55  void registerObservables(std::vector<ObservableHelper>& h5dec, hdf_archive& file) override {}
56 
57  /** add the local energy, variance and all the Hamiltonian components to the scalar record container
58  * @param record storage of scalar records (name,value)
59  */
60  inline void add2Record(RecordListType& record) override
61  {
62  FirstIndex = record.add("LocalEnergy");
63  int s1 = record.add("LocalPotential");
64  LastIndex = FirstIndex + 2;
65  // int s2=record.add("KineticEnergy");
66  //LastIndex = FirstIndex+3;
67  clear();
68  }
69 
71 
72  const std::string type_str = "LocalEnergyOnlyEstimatorNotSupportedInBatchedVersion";
73  const std::string& getSubTypeStr() const override { return type_str; }
74 };
75 } // namespace qmcplusplus
76 #endif
A set of walkers that are to be advanced by Metropolis Monte Carlo.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Estimator for local energy only.
void accumulate(const MCWalkerConfiguration &W, WalkerIterator first, WalkerIterator last, RealType wgt) override
a virtual function to accumulate observables or collectables
class to handle hdf file
Definition: hdf_archive.h:51
const char walkers[]
Definition: HDFVersion.h:36
int FirstIndex
first index within an record of the first element handled by an object
QMCTraits::FullPrecRealType RealType
std::vector< accumulator_type > scalars
scalars to be measured
int add(const std::string &aname)
void add2Record(RecordListType &record) override
add the local energy, variance and all the Hamiltonian components to the scalar record container ...
std::vector< accumulator_type > scalars_saved
scalars saved
void clear()
clear the scalars to collect
const std::string & getSubTypeStr() const override
String representation of the derived type of the ScalarEstimator.
std::vector< std::reference_wrapper< T > > RefVector
Indexes
an enum denoting index of physical properties
MCWalkerConfiguration::const_iterator WalkerIterator
void accumulate(const RefVector< MCPWalker > &walkers) override
a virtual function to accumulate observables or collectables
LocalEnergyOnlyEstimator * clone() override
clone the object
Abstract class for an estimator of a scalar operator.
int LastIndex
last index within an record of the first element handled by an object
void registerObservables(std::vector< ObservableHelper > &h5dec, hdf_archive &file) override
add descriptors of observables to utilize hdf5
A container class to represent a walker.
Definition: Walker.h:49