QMCPACK
to get/put observables

Functions

int addObservables (ParticleSet &P)
 add each term to the PropertyList for averages More...
 
void registerObservables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 register obsevables so that their averages can be dumped to hdf5 More...
 
void registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 register collectables so that their averages can be dumped to hdf5 More...
 
static void mw_registerKineticListener (QMCHamiltonian &ham_leader, ListenerVector< RealType > listener)
 Listener Registration This must be called on a QMCHamiltonian that has acquired multiwalker resources. More...
 
static void mw_registerLocalEnergyListener (QMCHamiltonian &ham_leader, ListenerVector< RealType > listener)
 
static void mw_registerLocalPotentialListener (QMCHamiltonian &ham_leader, ListenerVector< RealType > listener)
 
static void mw_registerLocalIonPotentialListener (QMCHamiltonian &ham_leader, ListenerVector< RealType > listener)
 
void informOperatorsOfListener ()
 Some Hamiltonian components need to be informed that they are in a per particle reporting situation so additional state can be added either to them or the objects they are strongly coupled with. More...
 
int startIndex () const
 retrun the starting index More...
 
int sizeOfObservables () const
 return the size of observables More...
 
int sizeOfCollectables () const
 return the size of collectables More...
 
RealType getObservable (int i) const
 return the value of the i-th observable More...
 
int getObservable (std::string Oname) const
 return the value of the observable with a set name if it exists More...
 
std::string getObservableName (int i) const
 return the name of the i-th observable More...
 
template<class IT , typename = std::enable_if_t<std::is_same<std::add_pointer<FullPrecRealType>::type, IT>::value>>
void saveProperty (IT first)
 save the values of Hamiltonian elements to the Properties More...
 

Detailed Description

Function Documentation

◆ addObservables()

int addObservables ( ParticleSet P)

add each term to the PropertyList for averages

add a number of properties to the ParticleSet

Parameters
plista set of properties to which this Hamiltonian add the observables add each term to P.PropertyList and P.mcObservables
Pparticle set to which observables are added
Returns
the number of observables
Parameters
PParticleSet to which multiple columns to be added

QMCHamiltonian can add any number of properties to a ParticleSet. Hindex contains the index map to the ParticleSet::PropertyList. This enables assigning the properties evaluated by each OperatorBase object to the correct property column.

Definition at line 223 of file QMCHamiltonian.cpp.

References RecordNamedProperty< T >::add(), qmcplusplus::app_log(), QMCHamiltonian::auxH, PooledData< T >::clear(), ParticleSet::Collectables, QMCHamiltonian::H, QMCHamiltonian::myIndex, QMCHamiltonian::numCollectables, QMCHamiltonian::Observables, ParticleSet::PropertyList, PooledData< T >::rewind(), and PooledData< T >::size().

Referenced by QMCHamiltonian::resetObservables(), and qmcplusplus::TEST_CASE().

224 {
225  //first add properties to Observables
226  Observables.clear();
227  //ParticleSet::mcObservables (large data, e.g. density) are accumulated while evaluations
228  P.Collectables.clear();
229  P.Collectables.rewind();
230  for (int i = 0; i < H.size(); ++i)
231  H[i]->addObservables(Observables, P.Collectables);
232  for (int i = 0; i < auxH.size(); ++i)
233  auxH[i]->addObservables(Observables, P.Collectables);
234  myIndex = P.PropertyList.add(Observables.Names[0]);
235  for (int i = 1; i < Observables.size(); ++i)
236  P.PropertyList.add(Observables.Names[i]);
237  numCollectables = P.Collectables.size();
238  app_log() << "\n QMCHamiltonian::add2WalkerProperty added"
239  << "\n " << Observables.size() << " to P::PropertyList "
240  << "\n " << P.Collectables.size() << " to P::Collectables "
241  << "\n starting Index of the observables in P::PropertyList = " << myIndex << std::endl;
242  return Observables.size();
243 }
int addObservables(ParticleSet &P)
add each term to the PropertyList for averages
std::ostream & app_log()
Definition: OutputManager.h:65
int myIndex
starting index
int numCollectables
starting index
std::vector< std::unique_ptr< OperatorBase > > H
vector of Hamiltonians
PropertySetType Observables
data
std::vector< std::unique_ptr< OperatorBase > > auxH
vector of Hamiltonians

◆ getObservable() [1/2]

◆ getObservable() [2/2]

int getObservable ( std::string  Oname) const
inline

return the value of the observable with a set name if it exists

Definition at line 174 of file QMCHamiltonian.h.

References QMCHamiltonian::Observables.

175  {
176  int rtval(-1);
177  for (int io = 0; io < Observables.size(); io++)
178  {
179  if (Observables.Names[io] == Oname)
180  return io;
181  }
182  return rtval;
183  }
PropertySetType Observables
data

◆ getObservableName()

◆ informOperatorsOfListener()

void informOperatorsOfListener ( )

Some Hamiltonian components need to be informed that they are in a per particle reporting situation so additional state can be added either to them or the objects they are strongly coupled with.

This includes evalation of hamiltonian components constants on a per particle basis and informing a components attached particle set that it needs to store per particle values for StructFact. This is a reason that the coupling between Hamiltonian components and particle sets can strong and must be correct.

This is not desirable and hopefully this state transformation message can be removed.

Definition at line 303 of file QMCHamiltonian.cpp.

References QMCHamiltonian::H.

Referenced by QMCDriverNew::initializeQMC(), and qmcplusplus::TEST_CASE().

304 {
305  for (int i = 0; i < H.size(); ++i)
306  H[i]->informOfPerParticleListener();
307 }
std::vector< std::unique_ptr< OperatorBase > > H
vector of Hamiltonians

◆ mw_registerKineticListener()

void mw_registerKineticListener ( QMCHamiltonian ham_leader,
ListenerVector< RealType listener 
)
static

Listener Registration This must be called on a QMCHamiltonian that has acquired multiwalker resources.

Definition at line 277 of file QMCHamiltonian.cpp.

References QMCHamiltonian::mw_res_handle_.

Referenced by qmcplusplus::TEST_CASE().

278 {
279  // This creates a state replication burder of unknown scope when operators are cloned.
280  ham_leader.mw_res_handle_.getResource().kinetic_listeners_.push_back(listener);
281 }

◆ mw_registerLocalEnergyListener()

void mw_registerLocalEnergyListener ( QMCHamiltonian ham_leader,
ListenerVector< RealType listener 
)
static

Definition at line 283 of file QMCHamiltonian.cpp.

References QMCHamiltonian::mw_res_handle_.

Referenced by PerParticleHamiltonianLogger::registerListeners(), and qmcplusplus::TEST_CASE().

284 {
285  // This creates a state replication burder of unknown scope when operators are cloned.
286  // A local energy listener listens to both the kinetic operator and all involved in the potential.
287  ham_leader.mw_res_handle_.getResource().kinetic_listeners_.push_back(listener);
288  ham_leader.mw_res_handle_.getResource().potential_listeners_.push_back(listener);
289 }

◆ mw_registerLocalIonPotentialListener()

void mw_registerLocalIonPotentialListener ( QMCHamiltonian ham_leader,
ListenerVector< RealType listener 
)
static

Definition at line 297 of file QMCHamiltonian.cpp.

References QMCHamiltonian::mw_res_handle_.

Referenced by qmcplusplus::TEST_CASE().

298 {
299  // This creates a state replication burder of unknown scope when operators are cloned.
300  ham_leader.mw_res_handle_.getResource().ion_potential_listeners_.push_back(listener);
301 }

◆ mw_registerLocalPotentialListener()

void mw_registerLocalPotentialListener ( QMCHamiltonian ham_leader,
ListenerVector< RealType listener 
)
static

Definition at line 291 of file QMCHamiltonian.cpp.

References QMCHamiltonian::mw_res_handle_.

Referenced by qmcplusplus::TEST_CASE().

292 {
293  // This creates a state replication burder of unknown scope when operators are cloned.
294  ham_leader.mw_res_handle_.getResource().potential_listeners_.push_back(listener);
295 }

◆ registerCollectables()

void registerCollectables ( std::vector< ObservableHelper > &  h5desc,
hdf_archive file 
) const

register collectables so that their averages can be dumped to hdf5

Parameters
h5deschas observable_helper for each h5 group
gidh5 group id to which the observable groups are added.

Add observable_helper information for the data stored in ParticleSet::mcObservables.

Definition at line 270 of file QMCHamiltonian.cpp.

References QMCHamiltonian::auxH.

Referenced by CollectablesEstimator::registerObservables().

271 {
272  //The physical operators cannot add to collectables
273  for (int i = 0; i < auxH.size(); ++i)
274  auxH[i]->registerCollectables(h5desc, file);
275 }
void registerCollectables(std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
register collectables so that their averages can be dumped to hdf5
std::vector< std::unique_ptr< OperatorBase > > auxH
vector of Hamiltonians

◆ registerObservables()

void registerObservables ( std::vector< ObservableHelper > &  h5desc,
hdf_archive file 
) const

register obsevables so that their averages can be dumped to hdf5

Parameters
h5deschas observable_helper for each h5 group
gidh5 group id to which the observable groups are added.

Definition at line 262 of file QMCHamiltonian.cpp.

References QMCHamiltonian::auxH, and QMCHamiltonian::H.

Referenced by LocalEnergyEstimator::registerObservables().

263 {
264  for (int i = 0; i < H.size(); ++i)
265  H[i]->registerObservables(h5desc, file);
266  for (int i = 0; i < auxH.size(); ++i)
267  auxH[i]->registerObservables(h5desc, file);
268 }
void registerObservables(std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
register obsevables so that their averages can be dumped to hdf5
std::vector< std::unique_ptr< OperatorBase > > H
vector of Hamiltonians
std::vector< std::unique_ptr< OperatorBase > > auxH
vector of Hamiltonians

◆ saveProperty()

void saveProperty ( IT  first)
inline

save the values of Hamiltonian elements to the Properties

This creates a hard dependence on Walker using WalkerProperties to index its Properties. It also assumes no one else is sticking things into Walker's Properties and that It can access into it as if it were a raw FullPrecRealType array.

Definition at line 195 of file QMCHamiltonian.h.

References copy(), QMCHamiltonian::KineticEnergy, QMCHamiltonian::LocalEnergy, QMCHamiltonian::myIndex, and QMCHamiltonian::Observables.

Referenced by SOVMCUpdateAll::advanceWalker(), DMCUpdateAllWithRejection::advanceWalker(), SODMCUpdatePbyPWithRejectionFast::advanceWalker(), VMCUpdateAll::advanceWalker(), VMCUpdatePbyP::advanceWalker(), DMCUpdatePbyPWithRejectionFast::advanceWalker(), SOVMCUpdatePbyP::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), DMCUpdateAllWithKill::advanceWalker(), VMCBatched::advanceWalkers(), RMCUpdatePbyPWithDrift::advanceWalkersRMC(), RMCUpdateAllWithDrift::advanceWalkersRMC(), RMCUpdatePbyPWithDrift::advanceWalkersVMC(), RMCUpdateAllWithDrift::advanceWalkersVMC(), QMCDriverNew::initialLogEvaluation(), RMCUpdateAllWithDrift::initWalkers(), QMCUpdateBase::initWalkers(), QMCUpdateBase::initWalkersForPbyP(), WaveFunctionTester::runRatioTest(), WaveFunctionTester::runRatioTest2(), and qmcplusplus::TEST_CASE().

196  {
197  first[WP::LOCALPOTENTIAL] = LocalEnergy - KineticEnergy;
198  copy(Observables.begin(), Observables.end(), first + myIndex);
199  }
FullPrecRealType KineticEnergy
Current Kinetic Energy.
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
int myIndex
starting index
FullPrecRealType LocalEnergy
Current Local Energy.
PropertySetType Observables
data

◆ sizeOfCollectables()

int sizeOfCollectables ( ) const
inline

return the size of collectables

Definition at line 170 of file QMCHamiltonian.h.

References QMCHamiltonian::numCollectables.

Referenced by CollectablesEstimator::CollectablesEstimator(), and EstimatorManagerBase::put().

170 { return numCollectables; }
int numCollectables
starting index

◆ sizeOfObservables()

◆ startIndex()

int startIndex ( ) const
inline