QMCPACK
CollectablesEstimator Class Reference

Handle an ensemble average of Hamiltonian components. More...

+ Inheritance diagram for CollectablesEstimator:
+ Collaboration diagram for CollectablesEstimator:

Public Member Functions

 CollectablesEstimator (QMCHamiltonian &h)
 constructor More...
 
CollectablesEstimatorclone () override
 implement virtual function More...
 
void registerObservables (std::vector< ObservableHelper > &h5dec, hdf_archive &file) override
 add descriptors of observables to utilize hdf5 More...
 
void add2Record (RecordListType &record) override
 add the local energy, variance and all the Hamiltonian components to the scalar record container More...
 
void accumulate (const MCWalkerConfiguration &W, WalkerIterator first, WalkerIterator last, RealType wgt) override
 do nothing with accumulate More...
 
void accumulate (const RefVector< MCPWalker > &walkers) override
 a virtual function to accumulate observables or collectables More...
 
void accumulate_all (const MCWalkerConfiguration::Buffer_t &data, RealType wgt)
 accumulate the collectables More...
 
std::string getName () const override
 
const std::string & getSubTypeStr () const override
 String representation of the derived type of the ScalarEstimator. More...
 
- Public Member Functions inherited from ScalarEstimatorBase
 ScalarEstimatorBase ()
 
virtual ~ScalarEstimatorBase ()
 
virtual bool isMainEstimator () const
 Is this estimator a main estimator i.e. the estimator required for a particular driver. More...
 
RealType average (int i=0) const
 return average of the More...
 
RealType variance (int i=0) const
 return a variance More...
 
std::pair< RealType, RealTypeoperator[] (int i) const
 retrun mean and variance More...
 
virtual int size () const
 return the size of scalars it manages More...
 
void clear ()
 clear the scalars to collect More...
 
template<typename IT >
void takeBlockAverage (IT first)
 take block average and write to a common container More...
 
template<typename IT >
void takeBlockAverage (IT first, IT first_sq)
 take block average and write to common containers for values and squared values More...
 
template<typename IT >
void addAccumulated (IT first)
 add the block accumulated scalars More...
 
virtual void add2Record (RecordNamedProperty< RealType > &record)=0
 add the content of the scalar estimator to the record More...
 

Public Attributes

const std::string type_str = "ColletiblesEstimatorNotSupportedInBatchedVersion"
 
- Public Attributes inherited from ScalarEstimatorBase
int FirstIndex
 first index within an record of the first element handled by an object More...
 
int LastIndex
 last index within an record of the first element handled by an object More...
 
std::vector< accumulator_typescalars
 scalars to be measured More...
 
std::vector< accumulator_typescalars_saved
 scalars saved More...
 

Private Attributes

const QMCHamiltonianrefH
 save the reference hamiltonian More...
 

Additional Inherited Members

- Public Types inherited from ScalarEstimatorBase
using RealType = QMCTraits::FullPrecRealType
 
using accumulator_type = accumulator_set< RealType >
 
using Walker_t = MCWalkerConfiguration::Walker_t
 
using MCPWalker = Walker< QMCTraits, PtclOnLatticeTraits >
 
using WalkerIterator = MCWalkerConfiguration::const_iterator
 
using RecordListType = RecordNamedProperty< RealType >
 

Detailed Description

Handle an ensemble average of Hamiltonian components.

Definition at line 24 of file CollectablesEstimator.h.

Constructor & Destructor Documentation

◆ CollectablesEstimator()

constructor

Parameters
hQMCHamiltonian to define the components

Definition at line 20 of file CollectablesEstimator.cpp.

References ScalarEstimatorBase::scalars, ScalarEstimatorBase::scalars_saved, and QMCHamiltonian::sizeOfCollectables().

Referenced by CollectablesEstimator::clone().

20  : refH(h)
21 {
22  scalars.resize(h.sizeOfCollectables());
23  scalars_saved.resize(h.sizeOfCollectables());
24 }
std::vector< accumulator_type > scalars
scalars to be measured
std::vector< accumulator_type > scalars_saved
scalars saved
const QMCHamiltonian & refH
save the reference hamiltonian

Member Function Documentation

◆ accumulate() [1/2]

void accumulate ( const MCWalkerConfiguration W,
WalkerIterator  first,
WalkerIterator  last,
RealType  wgt 
)
inlineoverridevirtual

do nothing with accumulate

Implements ScalarEstimatorBase.

Definition at line 43 of file CollectablesEstimator.h.

43 {}

◆ accumulate() [2/2]

void accumulate ( const RefVector< MCPWalker > &  )
inlineoverridevirtual

a virtual function to accumulate observables or collectables

Parameters
global_walkers_walkers per ranks or walkers total?
RefVectorof MCPWalkers
wgtweight or maybe norm

Implements ScalarEstimatorBase.

Definition at line 45 of file CollectablesEstimator.h.

45 {}

◆ accumulate_all()

void accumulate_all ( const MCWalkerConfiguration::Buffer_t data,
RealType  wgt 
)
inline

accumulate the collectables

Definition at line 48 of file CollectablesEstimator.h.

References ScalarEstimatorBase::scalars, and PooledData< T >::size().

49  {
50  for (int i = 0; i < data.size(); ++i)
51  scalars[i](data[i], wgt);
52  }
std::vector< accumulator_type > scalars
scalars to be measured

◆ add2Record()

void add2Record ( RecordListType record)
override

add the local energy, variance and all the Hamiltonian components to the scalar record container

Parameters
recordstorage of scalar records (name,value)

Do not add Collectables to record

Definition at line 41 of file CollectablesEstimator.cpp.

References ScalarEstimatorBase::clear(), ScalarEstimatorBase::FirstIndex, ScalarEstimatorBase::LastIndex, ScalarEstimatorBase::scalars, and RecordNamedProperty< T >::size().

42 {
43  FirstIndex = record.size();
44  LastIndex = FirstIndex + scalars.size();
45  //FirstIndex = record.size();
46  //for(int i=0; i<refH.sizeOfCollectables(); ++i)
47  //{
48  // std::ostringstream o;
49  // o<<"a"<<i;
50  // int dummy=record.add(o.str());
51  //}
52  //LastIndex = record.size();
53  clear();
54 }
int FirstIndex
first index within an record of the first element handled by an object
std::vector< accumulator_type > scalars
scalars to be measured
void clear()
clear the scalars to collect
int LastIndex
last index within an record of the first element handled by an object

◆ clone()

CollectablesEstimator * clone ( )
overridevirtual

implement virtual function

Implements ScalarEstimatorBase.

Definition at line 34 of file CollectablesEstimator.cpp.

References CollectablesEstimator::CollectablesEstimator().

34 { return new CollectablesEstimator(*this); }
CollectablesEstimator(QMCHamiltonian &h)
constructor

◆ getName()

std::string getName ( ) const
inlineoverridevirtual

Implements ScalarEstimatorBase.

Definition at line 54 of file CollectablesEstimator.h.

54 { return "CollectiblesEstimator"; }

◆ getSubTypeStr()

const std::string& getSubTypeStr ( ) const
inlineoverridevirtual

String representation of the derived type of the ScalarEstimator.

Implements ScalarEstimatorBase.

Definition at line 57 of file CollectablesEstimator.h.

References CollectablesEstimator::type_str.

57 { return type_str; }

◆ registerObservables()

void registerObservables ( std::vector< ObservableHelper > &  h5dec,
hdf_archive file 
)
overridevirtual

add descriptors of observables to utilize hdf5

Parameters
h5descdescriptor of a data stored in a h5 group
filefile to which each statistical data will be stored

Implements ScalarEstimatorBase.

Definition at line 26 of file CollectablesEstimator.cpp.

References ScalarEstimatorBase::FirstIndex, qmcplusplus::lower_bound(), CollectablesEstimator::refH, and QMCHamiltonian::registerCollectables().

27 {
28  int loc = h5desc.size();
29  refH.registerCollectables(h5desc, file);
30  for (int i = loc; i < h5desc.size(); ++i)
31  h5desc[i].lower_bound += FirstIndex;
32 }
void registerCollectables(std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
register collectables so that their averages can be dumped to hdf5
int FirstIndex
first index within an record of the first element handled by an object
TinyVector< T, 3 > lower_bound(const TinyVector< T, 3 > &a, const TinyVector< T, 3 > &b)
helper function to determine the lower bound of a domain (need to move up)
const QMCHamiltonian & refH
save the reference hamiltonian

Member Data Documentation

◆ refH

const QMCHamiltonian& refH
private

save the reference hamiltonian

Definition at line 27 of file CollectablesEstimator.h.

Referenced by CollectablesEstimator::registerObservables().

◆ type_str

const std::string type_str = "ColletiblesEstimatorNotSupportedInBatchedVersion"

Definition at line 56 of file CollectablesEstimator.h.

Referenced by CollectablesEstimator::getSubTypeStr().


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