QMCPACK
DiracDeterminantWithBackflow.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: Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File created by: Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 /**@file
16  * @brief Declaration of DiracDeterminantWithBackflow with a S(ingle)P(article)O(rbital)Set
17  */
18 #ifndef QMCPLUSPLUS_DIRACDETERMINANTWITHBACKFLOW_H
19 #define QMCPLUSPLUS_DIRACDETERMINANTWITHBACKFLOW_H
20 
23 #include "Utilities/TimerManager.h"
25 #include "OhmmsPETE/OhmmsArray.h"
26 
27 namespace qmcplusplus
28 {
29 class BackflowTransformation;
30 
31 /** class to handle determinants with backflow
32  */
34 {
35 public:
43 
44 
45  /** constructor
46  *@param spos the single-particle orbital set
47  *@param first index of the first particle
48  */
49  DiracDeterminantWithBackflow(std::unique_ptr<SPOSet>&& spos, BackflowTransformation& BF, int first, int last);
50 
51  ///default destructor
53 
54  // copy constructor and assign operator disabled
57 
58  std::string getClassName() const override { return "DiracDeterminantWithBackflow"; }
59 
60  // in general, assume that P is the quasiparticle set
62  const opt_variables_type& active,
63  Vector<ValueType>& dlogpsi,
64  Vector<ValueType>& dhpsioverpsi) override;
65 
67  const opt_variables_type& active,
68  std::vector<RealType>& dlogpsi,
69  std::vector<RealType>& dhpsioverpsi,
72  int k);
73 
75  const opt_variables_type& active,
76  int offset,
77  Matrix<RealType>& dlogpsi,
79  Matrix<RealType>& dL) override;
80 
81  void registerData(ParticleSet& P, WFBufferType& buf) override;
82 
83  LogValue updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) override;
84 
85  void copyFromBuffer(ParticleSet& P, WFBufferType& buf) override;
86 
87  /** return the ratio only for the iat-th partcle move
88  * @param P current configuration
89  * @param iat the particle thas is being moved
90  */
91  PsiValue ratio(ParticleSet& P, int iat) override;
92 
93  void evaluateRatiosAlltoOne(ParticleSet& P, std::vector<ValueType>& ratios) override;
94 
95  PsiValue ratioGrad(ParticleSet& P, int iat, GradType& grad_iat) override;
96  GradType evalGrad(ParticleSet& P, int iat) override;
97  GradType evalGradSource(ParticleSet& P, ParticleSet& source, int iat) override;
98 
100  ParticleSet& source,
101  int iat,
104 
105  /** move was accepted, update the real container
106  */
107  void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) override;
108 
109  /** move was rejected. copy the real container to the temporary to move on
110  */
111  void restore(int iat) override;
112 
115  ParticleSet::ParticleLaplacian& L) override;
116 
117  /** cloning function
118  * @param tqp target particleset
119  * @param spo spo set
120  *
121  * This interface is exposed only to SlaterDet and its derived classes
122  * can overwrite to clone itself correctly.
123  */
124  std::unique_ptr<DiracDeterminantWithBackflow> makeCopyWithBF(std::unique_ptr<SPOSet>&& spo,
125  BackflowTransformation& BF) const;
126  [[noreturn]] std::unique_ptr<DiracDeterminantBase> makeCopy(std::unique_ptr<SPOSet>&& spo) const override
127  {
128  throw std::runtime_error("makeCopy spo should not be called.");
129  }
130 
131  void testDerivFjj(ParticleSet& P, int pa);
132  void testGGG(ParticleSet& P);
133  void testGG(ParticleSet& P);
134  void testDerivLi(ParticleSet& P, int pa);
135  void testL(ParticleSet& P);
136 
138 
139 private:
140  ///reset the size: with the number of particles and number of orbtials
141  void resize(int nel, int morb);
142 
144  {
145  ValueType ret(0);
146  for (int i(0); i < OHMMS_DIM; i++)
147  ret += lhs[i] * rhs[i];
148  return ret;
149  };
150 
151 #ifdef QMC_COMPLEX
153  {
154  ValueType ret(0);
155  for (int i(0); i < OHMMS_DIM; i++)
156  ret += lhs[i] * rhs[i];
157  return ret;
158  };
159 #endif
160 
161  ///total number of particles. Ye: used to track first time allocation but I still feel it very strange.
162  int NP;
175 
176  /////Current determinant value
177  //ValueType CurrentDet;
178  /// psiM(j,i) \f$= \psi_j({\bf r}_i)\f$
180 
181  /// temporary container for testing
183 
184  /// dpsiM(i,j) \f$= \nabla_i \psi_j({\bf r}_i)\f$
186 
187  /// value of single-particle orbital for particle-by-particle update
191 
197 
200 
206 
209 
210  void dummyEvalLi(ValueType& L1, ValueType& L2, ValueType& L3);
211 
212  void evaluate_SPO(ValueMatrix& logdet, GradMatrix& dlogdet, HessMatrix& grad_grad_logdet);
213  void evaluate_SPO(ValueMatrix& logdet,
214  GradMatrix& dlogdet,
215  HessMatrix& grad_grad_logdet,
216  GGGMatrix& grad_grad_grad_logdet);
217 };
218 
219 
220 } // namespace qmcplusplus
221 #endif
OrbitalSetTraits< ValueType >::HessVector HessVector
Definition: SPOSet.h:53
Declaration of DiracDeterminantBase with a S(ingle)P(article)O(rbital)Set.
Fixed-size array.
Definition: OhmmsTinyMeta.h:30
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat) override
return the logarithmic gradient for the iat-th particle of the source particleset ...
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimi...
DiracDeterminantWithBackflow & operator=(const DiracDeterminantWithBackflow &s)=delete
WaveFunctionComponent::PsiValue PsiValue
Definition: SlaterDet.cpp:25
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
timer_manager class.
ValueVector psiV
value of single-particle orbital for particle-by-particle update
void dummyEvalLi(ValueType &L1, ValueType &L2, ValueType &L3)
std::unique_ptr< DiracDeterminantWithBackflow > makeCopyWithBF(std::unique_ptr< SPOSet > &&spo, BackflowTransformation &BF) const
cloning function
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
Definition: SPOSet.h:50
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
LatticeGaussianProduct::GradType GradType
ValueMatrix psiMinv
temporary container for testing
Attaches a unit to a Vector for IO.
QTFull::ValueType SingleParticleValue
Definition: Configuration.h:97
#define OHMMS_DIM
Definition: config.h:64
void evaluate_SPO(ValueMatrix &logdet, GradMatrix &dlogdet, HessMatrix &grad_grad_logdet)
replace of SPOSet::evaluate function with the removal of t_logpsi
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
Definition: SPOSet.h:52
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
std::string getClassName() const override
return class name
DiracDeterminantWithBackflow(std::unique_ptr< SPOSet > &&spos, BackflowTransformation &BF, int first, int last)
constructor
std::unique_ptr< DiracDeterminantBase > makeCopy(std::unique_ptr< SPOSet > &&spo) const override
cloning function
OrbitalSetTraits< ValueType >::ValueVector ValueVector
Definition: SPOSet.h:49
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
PsiValue ratio(ParticleSet &P, int iat) override
return the ratio only for the iat-th partcle move
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
move was accepted, update the real container
class to handle determinants with backflow
ParticleSet::SingleParticleValue * LastAddressOfG
OrbitalSetTraits< ValueType >::GradVector GradVector
Definition: SPOSet.h:51
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
LatticeGaussianProduct::ValueType ValueType
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
void resize(int nel, int morb)
reset the size: with the number of particles and number of orbtials
Declaration of WaveFunctionComponent.
std::complex< double > LogValue
OrbitalSetTraits< ValueType >::GradHessMatrix GGGMatrix
Definition: SPOSet.h:56
A D-dimensional Array class based on PETE.
Definition: OhmmsArray.h:25
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios) override
evaluate the ratios of one virtual move with respect to all the particles
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
void restore(int iat) override
move was rejected.
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
Calculate the log value of the Dirac determinant for particles.
ParticleSet::SingleParticleValue * FirstAddressOfG
ValueType rcdot(TinyVector< RealType, OHMMS_DIM > &lhs, TinyVector< ValueType, OHMMS_DIM > &rhs)
OrbitalSetTraits< ValueType >::HessMatrix HessMatrix
Definition: SPOSet.h:54
int NP
total number of particles. Ye: used to track first time allocation but I still feel it very strange...