QMCPACK
BareKineticEnergy.h
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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
10 // Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
11 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
12 //
13 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 #ifndef QMCPLUSPLUS_BAREKINETICENERGY_H
18 #define QMCPLUSPLUS_BAREKINETICENERGY_H
19 
21 #include <ResourceCollection.h>
22 #include <ResourceHandle.h>
23 
24 namespace qmcplusplus
25 {
26 
27 /** @ingroup hamiltonian
28  @brief Evaluate the kinetic energy with a single mass
29 
30  *The unit of the mass is AU, i.e., the electron mass \f$ m_e = 1 \f$.
31  * To evaluate the Bare Kinetic part of the local energy
32  \f$E_L({\bf R}) = \Psi^{-1}({\bf R})\hat{H}\Psi({\bf R}),\f$
33  it is useful to use the following trick
34  \f{eqnarray*}
35  \nabla^2\Psi({\bf R}) &=& \nabla^2(\exp(\ln \Psi({\bf R})))\\
36  &=&\nabla\cdot(\nabla\exp(\ln \Psi({\bf R}))) \\
37  &=&\nabla\cdot(\nabla\ln \Psi({\bf R}))\exp(\ln \Psi({\bf R}))\\
38  -\frac{1}{2}\frac{\nabla^2\Psi({\bf R})}{\Psi({\bf R})} &=&
39  -\frac{1}{2}\nabla^2\ln \Psi({\bf R})
40  -\frac{1}{2}(\nabla\ln \Psi({\bf R}))^2
41  \f}
42  */
44 {
45 public:
46  /** constructor with particleset
47  * @param target particleset
48  *
49  * Store mass per species and use SameMass to choose the methods.
50  * if SameMass, probably faster and easy to vectorize but no impact on the performance.
51  */
53  ///destructor
54  ~BareKineticEnergy() override;
55 
56  bool dependsOnWaveFunction() const override;
57  std::string getClassName() const override;
58  void resetTargetParticleSet(ParticleSet& p) override;
59 
60 #if !defined(REMOVE_TRACEMANAGER)
61  void contributeParticleQuantities() override;
62  void checkoutParticleQuantities(TraceManager& tm) override;
63  void deleteParticleQuantities() override;
64 #endif
65 
66  Return_t evaluate(ParticleSet& P) override;
67 
69  const opt_variables_type& optvars,
70  const Vector<ValueType>& dlogpsi,
71  Vector<ValueType>& dhpsioverpsi) override;
72 
75  const opt_variables_type& optvars,
76  const RecordArray<ValueType>& dlogpsi,
77  RecordArray<ValueType>& dhpsioverpsi) const override;
78 
79  /** Evaluate the contribution of this component for multiple walkers reporting
80  * to registered listeners from Estimators.
81  */
85  const std::vector<ListenerVector<RealType>>& listeners,
86  const std::vector<ListenerVector<RealType>>& ion_listeners) const override;
87 
88  /** For BareKineticEnergy since it does override any Toperator evals this needs to decay to
89  * mw_evaluatePerParticle.
90  *
91  * This method must be overrideen since the default behavior is to decay to mw_evaluateWithToperator
92  * and its default behavior is to call mw_evaluate.
93  */
97  const std::vector<ListenerVector<RealType>>& listeners,
98  const std::vector<ListenerVector<RealType>>& ion_listeners) const override;
99 
100  /**@brief Function to compute the value, direct ionic gradient terms, and pulay terms for the local kinetic energy.
101  *
102  * This general function represents the OperatorBase interface for computing. For an operator \hat{O}, this
103  * function will return \frac{\hat{O}\Psi_T}{\Psi_T}, \frac{\partial(\hat{O})\Psi_T}{\Psi_T}, and
104  * \frac{\hat{O}\partial\Psi_T}{\Psi_T} - \frac{\hat{O}\Psi_T}{\Psi_T}\frac{\partial \Psi_T}{\Psi_T}. These are
105  * referred to as Value, HF term, and pulay term respectively.
106  *
107  * @param P electron particle set.
108  * @param ions ion particle set
109  * @param psi Trial wave function object.
110  * @param hf_terms 3Nion dimensional object. All direct force terms, or ionic gradient of operator itself.
111  * Contribution of this operator is ADDED onto hf_terms.
112  * @param pulay_terms The terms coming from ionic gradients of trial wavefunction. Contribution of this operator is
113  * ADDED onto pulay_terms.
114  * @return Value of kinetic energy operator at electron/ion positions given by P and ions. The force contributions from
115  * this operator are added into hf_terms and pulay_terms.
116  */
118  ParticleSet& ions,
119  TrialWaveFunction& psi,
120  ParticleSet::ParticlePos& hf_terms,
121  ParticleSet::ParticlePos& pulay_terms) override;
122 
123  void evaluateOneBodyOpMatrix(ParticleSet& P, const TWFFastDerivWrapper& psi, std::vector<ValueMatrix>& B) override;
124 
126  ParticleSet& source,
127  const TWFFastDerivWrapper& psi,
128  const int iat,
129  std::vector<std::vector<ValueMatrix>>& Bforce) override;
130 
131 #if !defined(REMOVE_TRACEMANAGER)
133 #endif
134 
136 
137  /** implements the virtual function.
138  *
139  * Nothing is done but should check the mass
140  */
141  bool put(xmlNodePtr) override;
142 
143  bool get(std::ostream& os) const override;
144 
145  std::unique_ptr<OperatorBase> makeClone(ParticleSet& qp, TrialWaveFunction& psi) final;
146 
147  /** initialize a shared resource and hand it to a collection
148  */
149  void createResource(ResourceCollection& collection) const override;
150 
151  /** acquire a shared resource from a collection
152  */
153  void acquireResource(ResourceCollection& collection, const RefVectorWithLeader<OperatorBase>& o_list) const override;
154 
155  /** return a shared resource to a collection
156  */
157  void releaseResource(ResourceCollection& collection, const RefVectorWithLeader<OperatorBase>& o_list) const override;
158 
159 private:
160  ///true, if all the species have the same mass
162 
163  ///mass of the particle
165 
166  ///\f$ 1/(2 m^*) \f$
168  ///minus_over_2m_[i] = \f$ -1/2m[i]\f$ for the ith species
169  std::vector<FullPrecRealType> minus_over_2m_;
170 
171 #if !defined(REMOVE_TRACEMANAGER)
175 #endif
176 
178 
181 
183 };
184 
185 } // namespace qmcplusplus
186 #endif
~BareKineticEnergy() override
destructor
HamiltonianRef::FullPrecRealType FullPrecRealType
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
bool dependsOnWaveFunction() const override
return true if this operator depends on a wavefunction
void resetTargetParticleSet(ParticleSet &p) override
Reset the data with the target ParticleSet.
Return_t evaluate_orig(ParticleSet &P)
FullPrecRealType particle_mass_
mass of the particle
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
acquire a shared resource from a collection
std::unique_ptr< OperatorBase > makeClone(ParticleSet &qp, TrialWaveFunction &psi) final
ResourceHandle manages the temporary resource referenced from a collection.
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
return a shared resource to a collection
Declaration of OperatorBase.
std::string getClassName() const override
return class name
An object of this type is a listener expecting a callback to the report function with a vector of val...
Definition: Listener.hpp:38
void evaluateOneBodyOpMatrixForceDeriv(ParticleSet &P, ParticleSet &source, const TWFFastDerivWrapper &psi, const int iat, std::vector< std::vector< ValueMatrix >> &Bforce) override
Evaluate "dB/dR" matrices for observable.
Return_t evaluateWithIonDerivs(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms) override
Function to compute the value, direct ionic gradient terms, and pulay terms for the local kinetic ene...
Attaches a unit to a Vector for IO.
TWFFastDerivWrapper is a wrapper class for TrialWavefunction that provides separate and low level acc...
bool same_mass_
true, if all the species have the same mass
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
void evaluateOneBodyOpMatrix(ParticleSet &P, const TWFFastDerivWrapper &psi, std::vector< ValueMatrix > &B) override
Evaluate "B" matrix for observable.
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
Array< TraceComp, 1 > * t_sample_comp_
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
void checkoutParticleQuantities(TraceManager &tm) override
Return_t evaluateValueAndDerivatives(ParticleSet &P, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
An abstract class for Local Energy operators.
Definition: OperatorBase.h:59
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Array< TraceComp, 2 > * p_sample_
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 >> &ion_listeners) const override
For BareKineticEnergy since it does override any Toperator evals this needs to decay to mw_evaluatePe...
BareKineticEnergy(ParticleSet &p, TrialWaveFunction &psi)
constructor with particleset
ResourceHandle< MultiWalkerResource > mw_res_
Class to represent a many-body trial wave function.
Return_t evaluate(ParticleSet &P) override
Evaluate the local energy contribution of this component.
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species
bool put(xmlNodePtr) override
implements the virtual function.
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 >> &ion_listeners) const override
Evaluate the contribution of this component for multiple walkers reporting to registered listeners fr...
void contributeParticleQuantities() override
double B(double x, int k, int i, const std::vector< double > &t)
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 override
Return_t evaluate_sp(ParticleSet &P)
Evaluate the kinetic energy with a single mass.
Array< TraceReal, 1 > * t_sample_