QMCPACK
ConservedEnergy.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: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 // Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 #ifndef QMCPLUSPLUS_CONSERVEDENERGY_H
17 #define QMCPLUSPLUS_CONSERVEDENERGY_H
18 
19 #include "Particle/ParticleSet.h"
22 
23 namespace qmcplusplus
24 {
26 
27 /** A fake Hamiltonian to check the sampling of the trial function.
28  *
29  * Integrating the expression
30  \f[
31  {\bf \nabla} \cdot (\Psi_T({\bf R}) {\bf \nabla}
32  \Psi_T({\bf R})) = \Psi_T({\bf R}) \nabla^2
33  \Psi_T({\bf R}) + ({\bf \nabla} \Psi_T({\bf R}))^2
34  \f]
35  leads to (using the divergence theorem)
36  \f[
37  0 = \int d^3 {\bf R} \: \left[\Psi_T({\bf R}) \nabla^2
38  \Psi_T({\bf R}) + ({\bf \nabla} \Psi_T({\bf R}))^2\right]
39  \f]
40  or, written in terms of the probability distribution
41  \f$ |\Psi_T({\bf R})|^2 \f$
42  \f[ 0 = \int d^3 {\bf R} \: |\Psi_T({\bf R})|^2
43  \left[\frac{\nabla^2 \Psi_T({\bf R})}{\Psi_T({\bf R})} +
44  \left(\frac{{\bf \nabla} \Psi_T({\bf R})}{\Psi_T({\bf R})}
45  \right)^2\right],
46  \f]
47  where
48  \f[
49  \frac{\nabla^2 \Psi_T({\bf R})}{\Psi_T({\bf R})} =
50  \nabla^2 \ln \Psi_T({\bf R}) +
51  ({\bf \nabla} \ln \Psi_T({\bf R}))^2
52  \f]
53  \f[
54  \frac{{\bf \nabla} \Psi_T({\bf R})}{\Psi_T({\bf R})} =
55  {\bf \nabla} \ln \Psi_T({\bf R})
56  \f]
57  it is possible to check the sampling and the evaluation
58  of \f$ \Psi_T, \f$ e.g. the gradient and laplacian.
59  The expectation value of this estimator should fluctuate
60  around zero.
61 
62  For complex wavefunctions, the
63  \f[ \nabla \Psi_T \cdot \nabla \Psi_T^* \f] term from the divergence
64  theorem should use the complex conjugate.
65  The \f[ \nabla \Psi_T \cdot \nabla \Psi_T \f] term from expressing
66  \f[\Psi\f] in terms of \f[\ln \Psi\] should use normal complex
67  multiplication.
68 */
69 struct ConservedEnergy : public OperatorBase
70 {
71  ConservedEnergy() {}
72  ~ConservedEnergy() override {}
73 
74  void resetTargetParticleSet(ParticleSet& P) override {}
75 
76  std::string getClassName() const override { return "ConservedEnergy"; }
77 
78  Return_t evaluate(ParticleSet& P) override
79  {
80  RealType gradsq = Dot(P.G, P.G);
81  RealType lap = Sum(P.L);
82 #ifdef QMC_COMPLEX
83  RealType gradsq_cc = Dot_CC(P.G, P.G);
84  value_ = lap + gradsq + gradsq_cc;
85 #else
86  value_ = lap + 2 * gradsq;
87 #endif
88  return 0.0;
89  }
90 
91  /** Do nothing */
92  bool put(xmlNodePtr cur) override { return true; }
93 
94  bool get(std::ostream& os) const override
95  {
96  os << "ConservedEnergy";
97  return true;
98  }
99 
100  std::unique_ptr<OperatorBase> makeClone(ParticleSet& qp, TrialWaveFunction& psi) final
101  {
102  return std::make_unique<ConservedEnergy>();
103  }
104 };
105 } // namespace qmcplusplus
106 #endif
T Sum(const ParticleAttrib< T > &pa)
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Declaration of OperatorBase.
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
WalkerProperties::Indexes WP
Definition: ParticleSet.cpp:34
QMCTraits::RealType RealType
double Dot_CC(const ParticleAttrib< TinyVector< std::complex< double >, D >> &pa, const ParticleAttrib< TinyVector< std::complex< double >, D >> &pb)
Indexes
an enum denoting index of physical properties
Declaraton of ParticleAttrib<T>
void evaluate(Matrix< T, Alloc > &lhs, const Op &op, const Expression< RHS > &rhs)
Definition: OhmmsMatrix.h:514
BareKineticEnergy::Return_t Return_t