QMCPACK
EstimatorManagerCrowd Class Reference

Thread local estimator container/accumulator. More...

+ Collaboration diagram for EstimatorManagerCrowd:

Public Types

using MCPWalker = Walker< QMCTraits, PtclOnLatticeTraits >
 
using RealType = EstimatorManagerNew::RealType
 
using FullPrecRealType = EstimatorManagerNew::FullPrecRealType
 

Public Member Functions

 EstimatorManagerCrowd (EstimatorManagerNew &em)
 EstimatorManagerCrowd are always spawn of an EstimatorManagerNew. More...
 
 ~EstimatorManagerCrowd ()
 destructor More...
 
int size () const
 return the number of ScalarEstimators More...
 
void startBlock (int steps)
 start a block More...
 
void stopBlock ()
 
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. More...
 
ScalarEstimatorBaseget_main_estimator ()
 
RefVector< ScalarEstimatorBaseget_scalar_estimators ()
 
RefVector< qmcplusplus::OperatorEstBaseget_operator_estimators ()
 
RealType get_block_num_samples () const
 
RealType get_block_weight () const
 
void registerListeners (const RefVectorWithLeader< QMCHamiltonian > &ham_list)
 This registers the crowd lever estimators that require listeners into the QMCHamiltonianMultiWalkerResources We really only need a QMCHamiltonian leader but resource acquisition and release works better this way. More...
 

Private Attributes

RealType block_num_samples_
 number of samples accumulated in a block More...
 
RealType block_weight_
 total weight accumulated in a block More...
 
UPtr< ScalarEstimatorBasemain_estimator_
 
UPtrVector< ScalarEstimatorBasescalar_estimators_
 estimators of simple scalars More...
 
UPtrVector< OperatorEstBaseoperator_ests_
 

Detailed Description

Thread local estimator container/accumulator.

Stepping away from the CloneManger + clones design which creates EstimatorManagers Which operate differently based on internal switches.

see EstimatorManagerNew.h for full description of the new design.

Definition at line 38 of file EstimatorManagerCrowd.h.

Member Typedef Documentation

◆ FullPrecRealType

◆ MCPWalker

◆ RealType

Constructor & Destructor Documentation

◆ EstimatorManagerCrowd()

EstimatorManagerCrowd are always spawn of an EstimatorManagerNew.

Definition at line 16 of file EstimatorManagerCrowd.cpp.

References EstimatorManagerCrowd::main_estimator_, EstimatorManagerNew::main_estimator_, EstimatorManagerCrowd::operator_ests_, EstimatorManagerNew::operator_ests_, EstimatorManagerCrowd::scalar_estimators_, and EstimatorManagerNew::scalar_ests_.

17 {
18  main_estimator_ = UPtr<ScalarEstimatorBase>(em.main_estimator_->clone());
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 }
UPtrVector< ScalarEstimatorBase > scalar_estimators_
estimators of simple scalars
UPtr< ScalarEstimatorBase > main_estimator_
UPtrVector< OperatorEstBase > operator_ests_

◆ ~EstimatorManagerCrowd()

~EstimatorManagerCrowd ( )
inline

destructor

Definition at line 50 of file EstimatorManagerCrowd.h.

50 {};

Member Function Documentation

◆ accumulate()

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.

Not all estimators make use of all these arguments

Parameters
[in]walkerswalkers in crowd
[in]psetswalker particle sets
[in]wfnswalker wavefunctions
[in]hamswalker Hamiltonians
[in,out]rngcrowd scope RandomGenerator

walkers is especially questionable since its really just hiding the full sweep hamiltonian values from the most recent (maybe) QMCHamiltonian evaluate which are written into it by the QMCHamiltonians previous to the accumulate. walkers might additionally be useful because they hold another copy of the dynamic (electron) particle sets coords that could be inconsistent with psets.

As soon as the legacy Estimators are dropped this API should be reviewed with an eye to disentangling ParticleSet, Walker, and QMCHamiltonian.

Definition at line 25 of file EstimatorManagerCrowd.cpp.

References EstimatorManagerCrowd::block_num_samples_, EstimatorManagerCrowd::block_weight_, EstimatorManagerCrowd::main_estimator_, EstimatorManagerCrowd::operator_ests_, EstimatorManagerCrowd::scalar_estimators_, and qmcplusplus::hdf::walkers.

Referenced by Crowd::accumulate(), and qmcplusplus::TEST_CASE().

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 }
const char walkers[]
Definition: HDFVersion.h:36
Walker< QMCTraits, PtclOnLatticeTraits > MCPWalker
UPtrVector< ScalarEstimatorBase > scalar_estimators_
estimators of simple scalars
RealType block_num_samples_
number of samples accumulated in a block
RealType block_weight_
total weight accumulated in a block
UPtr< ScalarEstimatorBase > main_estimator_
UPtrVector< OperatorEstBase > operator_ests_
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...

◆ get_block_num_samples()

RealType get_block_num_samples ( ) const
inline

Definition at line 89 of file EstimatorManagerCrowd.h.

References EstimatorManagerCrowd::block_num_samples_.

89 { return block_num_samples_; }
RealType block_num_samples_
number of samples accumulated in a block

◆ get_block_weight()

RealType get_block_weight ( ) const
inline

Definition at line 90 of file EstimatorManagerCrowd.h.

References EstimatorManagerCrowd::block_weight_.

90 { return block_weight_; }
RealType block_weight_
total weight accumulated in a block

◆ get_main_estimator()

ScalarEstimatorBase& get_main_estimator ( )
inline

Definition at line 85 of file EstimatorManagerCrowd.h.

References EstimatorManagerCrowd::main_estimator_.

85 { return *main_estimator_; }
UPtr< ScalarEstimatorBase > main_estimator_

◆ get_operator_estimators()

RefVector<qmcplusplus::OperatorEstBase> get_operator_estimators ( )
inline

Definition at line 87 of file EstimatorManagerCrowd.h.

References qmcplusplus::convertUPtrToRefVector(), and EstimatorManagerCrowd::operator_ests_.

static RefVector< T > convertUPtrToRefVector(const UPtrVector< T > &ptr_list)
convert a vector of std::unique_ptrs<T> to a refvector<T>
UPtrVector< OperatorEstBase > operator_ests_

◆ get_scalar_estimators()

RefVector<ScalarEstimatorBase> get_scalar_estimators ( )
inline

Definition at line 86 of file EstimatorManagerCrowd.h.

References qmcplusplus::convertUPtrToRefVector(), and EstimatorManagerCrowd::scalar_estimators_.

static RefVector< T > convertUPtrToRefVector(const UPtrVector< T > &ptr_list)
convert a vector of std::unique_ptrs<T> to a refvector<T>
UPtrVector< ScalarEstimatorBase > scalar_estimators_
estimators of simple scalars

◆ registerListeners()

void registerListeners ( const RefVectorWithLeader< QMCHamiltonian > &  ham_list)

This registers the crowd lever estimators that require listeners into the QMCHamiltonianMultiWalkerResources We really only need a QMCHamiltonian leader but resource acquisition and release works better this way.

Definition at line 42 of file EstimatorManagerCrowd.cpp.

References RefVectorWithLeader< T >::getLeader(), and EstimatorManagerCrowd::operator_ests_.

Referenced by Crowd::Crowd(), and qmcplusplus::TEST_CASE().

43 {
44  for (auto& estimator : operator_ests_)
45  if (estimator->isListenerRequired())
46  estimator->registerListeners(ham_list.getLeader());
47 }
UPtrVector< OperatorEstBase > operator_ests_

◆ size()

int size ( void  ) const
inline

return the number of ScalarEstimators

Definition at line 53 of file EstimatorManagerCrowd.h.

References EstimatorManagerCrowd::scalar_estimators_.

53 { return scalar_estimators_.size(); }
UPtrVector< ScalarEstimatorBase > scalar_estimators_
estimators of simple scalars

◆ startBlock()

void startBlock ( int  steps)

start a block

Parameters
stepsnumber of steps in a block

Definition at line 49 of file EstimatorManagerCrowd.cpp.

References EstimatorManagerCrowd::block_num_samples_, EstimatorManagerCrowd::block_weight_, and EstimatorManagerCrowd::operator_ests_.

Referenced by Crowd::startBlock().

50 {
51  for (auto& uope : operator_ests_)
52  uope->startBlock(steps);
53  block_num_samples_ = 0.0;
54  block_weight_ = 0.0;
55 }
RealType block_num_samples_
number of samples accumulated in a block
RealType block_weight_
total weight accumulated in a block
UPtrVector< OperatorEstBase > operator_ests_

◆ stopBlock()

void stopBlock ( )

Definition at line 57 of file EstimatorManagerCrowd.cpp.

Referenced by Crowd::stopBlock().

58 {
59  // the main estimator does more here.
60 }

Member Data Documentation

◆ block_num_samples_

RealType block_num_samples_
private

number of samples accumulated in a block

Definition at line 99 of file EstimatorManagerCrowd.h.

Referenced by EstimatorManagerCrowd::accumulate(), EstimatorManagerCrowd::get_block_num_samples(), and EstimatorManagerCrowd::startBlock().

◆ block_weight_

RealType block_weight_
private

◆ main_estimator_

◆ operator_ests_

◆ scalar_estimators_


The documentation for this class was generated from the following files: