QMCPACK
EstimatorManagerCrowd.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) 2022 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File refactored from: EstimatorManagerBase.cpp
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include "EstimatorManagerCrowd.h"
13 
14 namespace qmcplusplus
15 {
17 {
19  for (const auto& est : em.scalar_ests_)
20  scalar_estimators_.emplace_back(est->clone());
21  for (const auto& upeb : em.operator_ests_)
22  operator_ests_.emplace_back(upeb->spawnCrowdClone());
23 }
24 
26  const RefVector<ParticleSet>& psets,
27  const RefVector<TrialWaveFunction>& wfns,
28  const RefVector<QMCHamiltonian>& hams,
30 {
31  block_num_samples_ += walkers.size();
32  for (MCPWalker& awalker : walkers)
33  block_weight_ += awalker.Weight;
34  main_estimator_->accumulate(walkers);
35  int num_scalar_estimators = scalar_estimators_.size();
36  for (int i = 0; i < num_scalar_estimators; ++i)
38  for (int i = 0; i < operator_ests_.size(); ++i)
39  operator_ests_[i]->accumulate(walkers, psets, wfns, hams, rng);
40 }
41 
43 {
44  for (auto& estimator : operator_ests_)
45  if (estimator->isListenerRequired())
46  estimator->registerListeners(ham_list.getLeader());
47 }
48 
50 {
51  for (auto& uope : operator_ests_)
52  uope->startBlock(steps);
53  block_num_samples_ = 0.0;
54  block_weight_ = 0.0;
55 }
56 
58 {
59  // the main estimator does more here.
60 }
61 
62 
63 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::vector< std::unique_ptr< OperatorEstBase > > operator_ests_
OperatorEst Observables.
Class to manage a set of ScalarEstimators As a manager, this class handles the aggregation of data fr...
const char walkers[]
Definition: HDFVersion.h:36
void startBlock(int steps)
start a block
UPtrVector< ScalarEstimatorBase > scalar_estimators_
estimators of simple scalars
std::unique_ptr< T > UPtr
RealType block_num_samples_
number of samples accumulated in a block
RealType block_weight_
total weight accumulated in a block
UPtr< ScalarEstimatorBase > main_estimator_
main estimator i.e. some version of a local energy estimator.
std::vector< std::reference_wrapper< T > > RefVector
UPtr< ScalarEstimatorBase > main_estimator_
void registerListeners(const RefVectorWithLeader< QMCHamiltonian > &ham_list)
This registers the crowd lever estimators that require listeners into the QMCHamiltonianMultiWalkerRe...
EstimatorManagerCrowd(EstimatorManagerNew &em)
EstimatorManagerCrowd are always spawn of an EstimatorManagerNew.
A container class to represent a walker.
Definition: Walker.h:49
UPtrVector< OperatorEstBase > operator_ests_
std::vector< UPtr< ScalarEstimatorBase > > scalar_ests_
non main scalar estimators collecting simple scalars, are there any? with the removal of collectables...
void accumulate(const RefVector< MCPWalker > &walkers, const RefVector< ParticleSet > &psets, const RefVector< TrialWaveFunction > &wfns, const RefVector< QMCHamiltonian > &hams, RandomBase< FullPrecRealType > &rng)
Accumulate over all scalar estimators and operator estimators over all walkers in crowd...