QMCPACK
SlaterDetWithBackflow.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 // Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
10 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 #ifndef QMCPLUSPLUS_SLATERDETERMINANT_WITHBACKFLOW_H
17 #define QMCPLUSPLUS_SLATERDETERMINANT_WITHBACKFLOW_H
21 #include <cmath>
22 
23 namespace qmcplusplus
24 {
26 {
27 public:
29  /** constructor
30  * @param targetPtcl target Particleset
31  * @param rn release node
32  */
34  std::vector<std::unique_ptr<Determinant_t>> dets,
35  std::unique_ptr<BackflowTransformation> BF);
36 
37  ///destructor
38  ~SlaterDetWithBackflow() override;
39 
40  std::string getClassName() const override { return "SlaterDetWithBackflow"; }
41  bool isFermionic() const final { return true; }
42  bool isOptimizable() const override;
43 
44  void extractOptimizableObjectRefs(UniqueOptObjRefs& opt_obj_refs) override;
45 
46  void checkOutVariables(const opt_variables_type& active) override
47  {
48  //if(Optimizable) {
49  if (BFTrans->isOptimizable())
50  {
51  BFTrans->checkOutVariables(active);
52  for (int i = 0; i < Dets.size(); i++)
53  Dets[i]->checkOutVariables(active);
54  }
55  }
56 
59  ParticleSet::ParticleLaplacian& L) override;
60 
61  void registerData(ParticleSet& P, WFBufferType& buf) override;
62  LogValue updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) override;
63  void copyFromBuffer(ParticleSet& P, WFBufferType& buf) override;
64 
65  inline PsiValue ratioGrad(ParticleSet& P, int iat, GradType& grad_iat) override
66  {
67  BFTrans->evaluatePbyPWithGrad(P, iat);
68  //BFTrans->evaluate(P);
69  PsiValue psi = 1.0;
70  for (int i = 0; i < Dets.size(); ++i)
71  psi *= Dets[i]->ratioGrad(P, iat, grad_iat);
72  return psi;
73  }
74 
75  GradType evalGrad(ParticleSet& P, int iat) override
76  {
78  for (int i = 0; i < Dets.size(); ++i)
79  g += Dets[i]->evalGrad(P, iat);
80  return g;
81  }
82 
83  GradType evalGradSource(ParticleSet& P, ParticleSet& src, int iat) override
84  {
85  APP_ABORT("Need to implement SlaterDetWithBackflow::evalGradSource() \n");
86  return ValueType();
87  }
88 
90  ParticleSet& src,
91  int iat,
94  {
95  APP_ABORT("Need to implement SlaterDetWithBackflow::evalGradSource() \n");
96  return GradType();
97  }
98 
99  inline void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) override
100  {
101  BFTrans->acceptMove(P, iat);
102  for (int i = 0; i < Dets.size(); i++)
103  Dets[i]->acceptMove(P, iat);
104  }
105 
106  inline void restore(int iat) override
107  {
108  BFTrans->restore(iat);
109  for (int i = 0; i < Dets.size(); i++)
110  Dets[i]->restore(iat);
111  }
112 
113 
114  inline PsiValue ratio(ParticleSet& P, int iat) override
115  {
116  BFTrans->evaluatePbyP(P, iat);
117  //BFTrans->evaluate(P);
118  PsiValue ratio = 1.0;
119  for (int i = 0; i < Dets.size(); ++i)
120  ratio *= Dets[i]->ratio(P, iat);
121  return ratio;
122  }
123 
124  std::unique_ptr<WaveFunctionComponent> makeClone(ParticleSet& tqp) const override;
125 
126  SPOSetPtr getPhi(int i = 0) const { return Dets[i]->getPhi(); }
127 
128  void evaluateRatiosAlltoOne(ParticleSet& P, std::vector<ValueType>& ratios) override;
129 
131  const opt_variables_type& optvars,
132  Vector<ValueType>& dlogpsi,
133  Vector<ValueType>& dhpsioverpsi) override;
134 
135  void testDerivGL(ParticleSet& P);
136 
137 private:
138  ///container for the DiracDeterminants
139  const std::vector<std::unique_ptr<Determinant_t>> Dets;
140  /// backflow transformation
141  const std::unique_ptr<BackflowTransformation> BFTrans;
142 };
143 } // namespace qmcplusplus
144 #endif
base class for Single-particle orbital sets
Definition: SPOSet.h:46
Fixed-size array.
Definition: OhmmsTinyMeta.h:30
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::GradType GradType
Definition: Configuration.h:62
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimi...
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
a move for iat-th particle is accepted.
~SlaterDetWithBackflow() override
destructor
GradType evalGradSource(ParticleSet &P, ParticleSet &src, int iat, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad) override
Adds the gradient w.r.t.
Attaches a unit to a Vector for IO.
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const override
make clone
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios) override
evaluate the ratios of one virtual move with respect to all the particles
void restore(int iat) override
If a move for iat-th particle is rejected, restore to the content.
An abstract class for a component of a many-body trial wave function.
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
std::string getClassName() const override
return class name
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
QTBase::ValueType ValueType
Definition: Configuration.h:60
SlaterDetWithBackflow(ParticleSet &targetPtcl, std::vector< std::unique_ptr< Determinant_t >> dets, std::unique_ptr< BackflowTransformation > BF)
constructor
bool isFermionic() const final
true, if this component is fermionic
bool isOptimizable() const override
if true, this contains optimizable components
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
class to handle determinants with backflow
GradType evalGradSource(ParticleSet &P, ParticleSet &src, int iat) override
return the logarithmic gradient for the iat-th particle of the source particleset ...
std::complex< double > LogValue
Declaration of DiracDeterminantWithBackflow with a S(ingle)P(article)O(rbital)Set.
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...