QMCPACK
SpeciesKineticEnergy Class Reference

SpeciesKineticEnergy evaluate the kinetic energy of each species in the target particle set separately instead of sum over every particle in the set such as BareKinetic <![CDATA][<estimator type="specieskinetic" name="skinetic">]]> By default skinetic_u, skinetic_d, etc. More...

+ Inheritance diagram for SpeciesKineticEnergy:
+ Collaboration diagram for SpeciesKineticEnergy:

Public Member Functions

 SpeciesKineticEnergy (ParticleSet &P)
 
std::string getClassName () const override
 return class name More...
 
bool put (xmlNodePtr cur) override
 Read the input parameter. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) final
 
void addObservables (PropertySetType &plist, BufferType &collectables) override
 named values to the property list Default implementaton uses addValue(plist_) More...
 
void setObservables (PropertySetType &plist) override
 Set the values evaluated by this object to plist Default implementation is to assign Value which is updated by evaluate function using my_index_. More...
 
void registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const override
 
- Public Member Functions inherited from OperatorBase
 OperatorBase ()
 Construct a new Operator Base object Default and unique empty constructor. More...
 
virtual ~OperatorBase ()=default
 
virtual bool dependsOnWaveFunction () const
 return true if this operator depends on a wavefunction More...
 
std::bitset< 8 > & getUpdateMode () noexcept
 get update_mode_ reference More...
 
Return_t getValue () const noexcept
 get a copy of value_ More...
 
std::string getName () const noexcept
 getter a copy of my_name_, rvalue small string optimization More...
 
void setName (const std::string name) noexcept
 Set my_name member, uses small string optimization (pass by value) More...
 
TraceRequestgetRequest () noexcept
 Get request_ member. More...
 
virtual void registerObservables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 add to observable descriptor for hdf5 The default implementation is to register a scalar for this->value_ More...
 
virtual void setParticlePropertyList (PropertySetType &plist, int offset)
 
virtual void setHistories (Walker_t &ThisWalker)
 
virtual Return_t evaluateDeterministic (ParticleSet &P)
 Evaluate the local energy contribution of this component, deterministically based on current state. More...
 
virtual void mw_evaluate (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 Evaluate the contribution of this component of multiple walkers. More...
 
virtual void mw_evaluatePerParticle (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &listeners_ions) const
 Evaluate the contribution of this component of multiple walkers per particle and report to registerd listeners from objects in Estimators. More...
 
virtual void mw_evaluateWithParameterDerivatives (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< ParticleSet > &p_list, const opt_variables_type &optvars, const RecordArray< ValueType > &dlogpsi, RecordArray< ValueType > &dhpsioverpsi) const
 TODO: add docs. More...
 
virtual Return_t rejectedMove (ParticleSet &P)
 TODO: add docs. More...
 
virtual Return_t evaluateWithToperator (ParticleSet &P)
 Evaluate the local energy contribution of this component with Toperators updated if requested. More...
 
virtual void mw_evaluateWithToperator (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 Evaluate the contribution of this component of multiple walkers. More...
 
virtual void mw_evaluatePerParticleWithToperator (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &listeners_ions) const
 Evaluate the contribution of this component of multiple walkers per particle and report to registerd listeners from objects in Estimators. More...
 
virtual Return_t evaluateValueAndDerivatives (ParticleSet &P, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
 Evaluate value and derivatives wrt the optimizables. More...
 
virtual Return_t evaluateWithIonDerivs (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_term, ParticleSet::ParticlePos &pulay_term)
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
virtual Return_t evaluateWithIonDerivsDeterministic (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_term, ParticleSet::ParticlePos &pulay_term)
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
virtual void evaluateOneBodyOpMatrix (ParticleSet &P, const TWFFastDerivWrapper &psi, std::vector< ValueMatrix > &B)
 Evaluate "B" matrix for observable. More...
 
virtual void evaluateOneBodyOpMatrixForceDeriv (ParticleSet &P, ParticleSet &source, const TWFFastDerivWrapper &psi, const int iat, std::vector< std::vector< ValueMatrix >> &Bforce)
 Evaluate "dB/dR" matrices for observable. More...
 
virtual void updateSource (ParticleSet &s)
 Update data associated with a particleset. More...
 
virtual Return_t getEnsembleAverage ()
 Return an average value by collective operation. More...
 
virtual void createResource (ResourceCollection &collection) const
 Initialize a shared resource and hand it to a collection. More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const
 Acquire a shared resource from a collection. More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const
 Return a shared resource to a collection. More...
 
virtual void setRandomGenerator (RandomBase< FullPrecRealType > *rng)
 Set the Random Generator object TODO: add docs. More...
 
virtual void add2Hamiltonian (ParticleSet &qp, TrialWaveFunction &psi, QMCHamiltonian &targetH)
 TODO: add docs. More...
 
virtual void getRequiredTraces (TraceManager &tm)
 TODO: add docs. More...
 
virtual void informOfPerParticleListener ()
 
bool isClassical () const noexcept
 
bool isQuantum () const noexcept
 
bool isClassicalClassical () const noexcept
 
bool isQuantumClassical () const noexcept
 
bool isQuantumQuantum () const noexcept
 
bool getMode (const int i) const noexcept
 Return the mode i. More...
 
bool isNonLocal () const noexcept
 TODO: add docs. More...
 
bool hasListener () const noexcept
 
void contributeTraceQuantities ()
 Make trace quantities available. More...
 
void checkoutTraceQuantities (TraceManager &tm)
 Checkout trace arrays Derived classes must guard individual checkouts using request info. More...
 
void collectScalarTraces ()
 Collect scalar trace data. More...
 
void deleteTraceQuantities ()
 delete trace arrays More...
 

Private Attributes

ParticleSettpset
 
int num_species
 
std::vector< std::string > species_names
 
std::vector< RealTypespecies_kinetic
 
std::vector< RealTypevec_minus_over_2m
 
bool hdf5_out
 
int h5_index
 

Additional Inherited Members

- Public Types inherited from OperatorBase
enum  EnergyDomains { KINETIC = 0, POTENTIAL, NO_ENERGY_DOMAIN }
 enum to denote energy domain of operators More...
 
enum  QuantumDomains {
  NO_QUANTUM_DOMAIN = 0, CLASSICAL, QUANTUM, CLASSICAL_CLASSICAL,
  QUANTUM_CLASSICAL, QUANTUM_QUANTUM
}
 
enum  {
  PRIMARY = 0, OPTIMIZABLE = 1, RATIOUPDATE = 2, PHYSICAL = 3,
  COLLECTABLE = 4, NONLOCAL = 5
}
 enum for update_mode More...
 
using Return_t = FullPrecRealType
 type of return value of evaluate More...
 
using ValueMatrix = SPOSet::ValueMatrix
 For fast derivative evaluation. More...
 
using GradMatrix = SPOSet::GradMatrix
 
using BufferType = ParticleSet::Buffer_t
 typedef for the serialized buffer More...
 
using Walker_t = ParticleSet::Walker_t
 typedef for the walker More...
 
using ParticleScalar = ParticleSet::Scalar_t
 typedef for the ParticleScalar More...
 
using SPOMap = SPOSet::SPOMap
 typedef for SPOMap More...
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 
- Protected Member Functions inherited from OperatorBase
virtual void contributeScalarQuantities ()
 
virtual void checkoutScalarQuantities (TraceManager &tm)
 
virtual void collectScalarQuantities ()
 
virtual void deleteScalarQuantities ()
 
virtual void contributeParticleQuantities ()
 
virtual void checkoutParticleQuantities (TraceManager &tm)
 
virtual void deleteParticleQuantities ()
 
virtual void setComputeForces (bool compute)
 
void setEnergyDomain (EnergyDomains edomain)
 Set the Energy Domain. More...
 
void setQuantumDomain (QuantumDomains qdomain)
 set quantum domain More...
 
void oneBodyQuantumDomain (const ParticleSet &P)
 set quantum domain for one-body operator More...
 
void twoBodyQuantumDomain (const ParticleSet &P)
 set quantum domain for two-body operator More...
 
void twoBodyQuantumDomain (const ParticleSet &P1, const ParticleSet &P2)
 set quantum domain for two-body operator More...
 
void addValue (PropertySetType &plist)
 named values to the property list More...
 
- Protected Attributes inherited from OperatorBase
std::bitset< 8 > update_mode_
 set the current update mode More...
 
Return_t value_
 current value More...
 
std::string name_
 name of this object More...
 
TraceRequest request_
 whether traces are being collected More...
 
int my_index_
 starting index of this object More...
 
Return_t new_value_
 a new value for a proposed move More...
 
Walker_tt_walker_
 reference to the current walker More...
 
bool streaming_particles_
 
bool have_required_traces_
 

Detailed Description

SpeciesKineticEnergy evaluate the kinetic energy of each species in the target particle set separately instead of sum over every particle in the set such as BareKinetic <![CDATA][<estimator type="specieskinetic" name="skinetic">]]> By default skinetic_u, skinetic_d, etc.

columns will be added to scalar.dat. If hdf5="yes", then data will be added to stat.h5 as well. The sum of every column that starts with skinetic should be equivalent to the Kinetic column.

Definition at line 26 of file SpeciesKineticEnergy.h.

Constructor & Destructor Documentation

◆ SpeciesKineticEnergy()

Definition at line 18 of file SpeciesKineticEnergy.cpp.

References qmcplusplus::app_log(), SpeciesSet::getAttribute(), ParticleSet::getSpeciesSet(), SpeciesKineticEnergy::num_species, SpeciesKineticEnergy::species_kinetic, SpeciesKineticEnergy::species_names, and SpeciesKineticEnergy::vec_minus_over_2m.

18  : tpset(P), hdf5_out(false)
19 {
20  SpeciesSet& tspecies(P.getSpeciesSet());
21  int massind = tspecies.getAttribute("mass");
22 
23  num_species = tspecies.size();
24  app_log() << "SpeciesKineticEnergy is tracking " << num_species << " species." << std::endl;
25 
28  species_names.resize(num_species);
29  for (int ispec = 0; ispec < num_species; ispec++)
30  {
31  species_names[ispec] = tspecies.speciesName[ispec];
32  RealType mass = tspecies(massind, ispec);
33  vec_minus_over_2m[ispec] = -1. / (2. * mass);
34  app_log() << " " << species_names[ispec] << " mass = " << mass << std::endl;
35  }
36 };
std::vector< std::string > species_names
std::ostream & app_log()
Definition: OutputManager.h:65
QMCTraits::RealType RealType
std::vector< RealType > vec_minus_over_2m
std::vector< RealType > species_kinetic

Member Function Documentation

◆ addObservables()

void addObservables ( PropertySetType plist,
BufferType collectables 
)
overridevirtual

named values to the property list Default implementaton uses addValue(plist_)

Parameters
plistRecordNameProperty
collectablesObservables that are accumulated by evaluate

Reimplemented from OperatorBase.

Definition at line 67 of file SpeciesKineticEnergy.cpp.

References PooledData< T >::add(), RecordNamedProperty< T >::add(), SpeciesKineticEnergy::h5_index, SpeciesKineticEnergy::hdf5_out, OperatorBase::my_index_, OperatorBase::name_, SpeciesKineticEnergy::num_species, PooledData< T >::size(), RecordNamedProperty< T >::size(), and SpeciesKineticEnergy::species_names.

68 {
69  my_index_ = plist.size();
70  for (int ispec = 0; ispec < num_species; ispec++)
71  { // make columns named "$myName_u", "$myName_d" etc.
72  plist.add(name_ + "_" + species_names[ispec]);
73  }
74  if (hdf5_out)
75  { // make room in h5 file and save its index
76  h5_index = collectables.size();
77  std::vector<RealType> tmp(num_species);
78  collectables.add(tmp.begin(), tmp.end());
79  }
80 }
std::vector< std::string > species_names
int my_index_
starting index of this object
Definition: OperatorBase.h:535
std::string name_
name of this object
Definition: OperatorBase.h:527

◆ evaluate()

SpeciesKineticEnergy::Return_t evaluate ( ParticleSet P)
overridevirtual

Evaluate the local energy contribution of this component.

Parameters
Pinput configuration containing N particles
Returns
the value of the Hamiltonian component

Implements OperatorBase.

Definition at line 98 of file SpeciesKineticEnergy.cpp.

References ParticleSet::Collectables, ParticleSet::G, ParticleSet::getTotalNum(), ParticleSet::GroupID, SpeciesKineticEnergy::h5_index, SpeciesKineticEnergy::hdf5_out, ParticleSet::L, qmcplusplus::laplacian(), SpeciesKineticEnergy::species_kinetic, OperatorBase::t_walker_, OperatorBase::value_, SpeciesKineticEnergy::vec_minus_over_2m, and Walker< t_traits, p_traits >::Weight.

99 {
100  std::fill(species_kinetic.begin(), species_kinetic.end(), 0.0);
101  RealType wgt = t_walker_->Weight;
102 
103  for (int iat = 0; iat < P.getTotalNum(); iat++)
104  {
105  int ispec = P.GroupID[iat];
106  RealType my_kinetic = vec_minus_over_2m[ispec] * laplacian(P.G[iat], P.L[iat]);
107  if (hdf5_out)
108  {
109  P.Collectables[h5_index + ispec] += my_kinetic * wgt;
110  }
111  species_kinetic[ispec] += my_kinetic;
112  }
113 
114  value_ = 0.0; // Value is no longer used
115  return value_;
116 }
Walker_t * t_walker_
reference to the current walker
Definition: OperatorBase.h:541
T laplacian(const TinyVector< T, D > &g, T l)
compute real(laplacian)
QMCTraits::RealType RealType
Return_t value_
current value
Definition: OperatorBase.h:524
FullPrecRealType Weight
Weight of the walker.
Definition: Walker.h:102
std::vector< RealType > vec_minus_over_2m
std::vector< RealType > species_kinetic

◆ get()

bool get ( std::ostream &  os) const
overridevirtual

write about the class

Implements OperatorBase.

Definition at line 61 of file SpeciesKineticEnergy.cpp.

References OperatorBase::name_.

62 { // class description
63  os << "SpeciesKineticEnergy: " << name_;
64  return true;
65 }
std::string name_
name of this object
Definition: OperatorBase.h:527

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 31 of file SpeciesKineticEnergy.h.

31 { return "SpeciesKineticEnergy"; }

◆ makeClone()

std::unique_ptr< OperatorBase > makeClone ( ParticleSet qp,
TrialWaveFunction psi 
)
finalvirtual

Implements OperatorBase.

Definition at line 118 of file SpeciesKineticEnergy.cpp.

119 {
120  return std::make_unique<SpeciesKineticEnergy>(*this);
121 }

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

Read the input parameter.

Parameters
curxml node for a OperatorBase object

Implements OperatorBase.

Definition at line 38 of file SpeciesKineticEnergy.cpp.

References OhmmsAttributeSet::add(), APP_ABORT, OperatorBase::COLLECTABLE, SpeciesKineticEnergy::hdf5_out, OhmmsAttributeSet::put(), and OperatorBase::update_mode_.

39 {
40  // read hdf5="yes" or "no"
41  OhmmsAttributeSet attrib;
42  std::string hdf5_flag = "no";
43  attrib.add(hdf5_flag, "hdf5");
44  attrib.put(cur);
45 
46  if (hdf5_flag == "yes")
47  hdf5_out = true;
48  else if (hdf5_flag == "no")
49  hdf5_out = false;
50  else
51  APP_ABORT("SpeciesKineticEnergy::put() - Please choose \"yes\" or \"no\" for hdf5 flag");
52  // end if
53 
54  if (hdf5_out)
55  { // add this estimator to stat.h5
56  update_mode_.set(COLLECTABLE, 1);
57  }
58  return true;
59 }
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521

◆ registerCollectables()

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

Reimplemented from OperatorBase.

Definition at line 82 of file SpeciesKineticEnergy.cpp.

References SpeciesKineticEnergy::h5_index, SpeciesKineticEnergy::hdf5_out, OperatorBase::name_, and SpeciesKineticEnergy::num_species.

83 {
84  if (!hdf5_out)
85  return;
86 
87  std::vector<int> ndim(1, num_species);
88  h5desc.emplace_back(hdf_path{name_});
89  auto& h5o = h5desc.back();
90  h5o.set_dimensions(ndim, h5_index);
91 }
std::string name_
name of this object
Definition: OperatorBase.h:527

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
inlineoverridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 38 of file SpeciesKineticEnergy.h.

38 {} // required

◆ setObservables()

void setObservables ( PropertySetType plist)
overridevirtual

Set the values evaluated by this object to plist Default implementation is to assign Value which is updated by evaluate function using my_index_.

Parameters
plistRecordNameProperty

Reimplemented from OperatorBase.

Definition at line 93 of file SpeciesKineticEnergy.cpp.

References RecordNamedProperty< T >::begin(), copy(), OperatorBase::my_index_, and SpeciesKineticEnergy::species_kinetic.

94 { // slots in plist must be allocated by addObservables() first
95  copy(species_kinetic.begin(), species_kinetic.end(), plist.begin() + my_index_);
96 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
std::vector< RealType > species_kinetic

Member Data Documentation

◆ h5_index

◆ hdf5_out

◆ num_species

◆ species_kinetic

◆ species_names

std::vector<std::string> species_names
private

◆ tpset

ParticleSet& tpset
private

Definition at line 50 of file SpeciesKineticEnergy.h.

◆ vec_minus_over_2m

std::vector<RealType> vec_minus_over_2m
private

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