QMCPACK
DMCRefEnergy.cpp
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) 2023 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include <cassert>
13 #include "DMCRefEnergy.h"
14 
15 namespace qmcplusplus
16 {
17 
19 
20 DMCRefEnergy::DMCRefEnergy(DMCRefEnergyScheme scheme, size_t history_limit)
21  : scheme_(scheme), energy_and_variance_(history_limit)
22 {}
23 
24 std::tuple<FullPrecReal, FullPrecReal> DMCRefEnergy::getEnergyVariance() const
25 {
27  {
29  return {avg[ENERGY], avg[VARIANCE]};
30  }
31  else
32  return {energy_hist_.mean(), variance_hist_.mean()};
33 }
34 
36 {
38  energy_and_variance_.push({weight, {ene, var}});
39  else
40  {
41  energy_hist_(ene);
42  variance_hist_(var);
43  }
44 }
45 
46 size_t DMCRefEnergy::count() const
47 {
49  return energy_and_variance_.size();
50  else
51  {
52  assert(energy_hist_.count() == variance_hist_.count());
53  return energy_hist_.count();
54  }
55 }
56 
57 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::tuple< FullPrecReal, FullPrecReal > getEnergyVariance() const
return energy and variance
DMCRefEnergy(DMCRefEnergyScheme scheme, size_t history_limit)
SizeLimitedDataQueue< FullPrecReal, DataLayout::DATA_SIZE > energy_and_variance_
Definition: DMCRefEnergy.h:48
QMCTraits::FullPrecRealType FullPrecReal
Definition: DMCRefEnergy.h:28
accumulator_set< FullPrecReal > variance_hist_
a simple accumulator for variance
Definition: DMCRefEnergy.h:45
DMCRefEnergyScheme scheme_
scheme
Definition: DMCRefEnergy.h:39
return_type mean() const
return the mean
Definition: accumulators.h:126
accumulator_set< FullPrecReal > energy_hist_
a simple accumulator for energy
Definition: DMCRefEnergy.h:43
DMCRefEnergyScheme
DMCRefEnergy schemes.
return_type count() const
return the count
Definition: accumulators.h:116
auto size() const
return the number of records
DMCRefEnergy::FullPrecReal FullPrecReal
void push(const value_type &val)
add a new record
auto weighted_avg() const
return weighted average
void pushWeightEnergyVariance(FullPrecReal weight, FullPrecReal ene, FullPrecReal var)
record weight, energy and variance.
size_t count() const
return record count.