QMCPACK
BackflowFunctionBase.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 // Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
9 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
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_BACKFLOW_FUNCTIONBASE_H
17 #define QMCPLUSPLUS_BACKFLOW_FUNCTIONBASE_H
19 #include "OptimizableObject.h"
20 #include "Configuration.h"
21 #include "OhmmsPETE/OhmmsArray.h"
22 #include "Particle/ParticleSet.h"
23 
24 namespace qmcplusplus
25 {
26 /** Base class for backflow transformations.
27  * FT is an optimizable functor class that implements the radial function
28  * Any class used for Jastrow functions should work
29  */
30 class BackflowFunctionBase //: public OrbitalSetTraits<QMCTraits::ValueType>
31 {
32 public:
35 
36  // All BF quantities should be real, so eliminating complex (ValueType) possibility
37  enum
38  {
40  };
42  using IndexType = int;
51 
53  //using GradArray_t = Array<GradType,3> ;
54  //using PosArray_t = Array<PosType,3> ;
55 
56  /** enum for a update mode */
57  enum
58  {
59  ORB_PBYP_RATIO, /*!< particle-by-particle ratio only */
60  ORB_PBYP_ALL, /*!< particle-by-particle, update Value-Gradient-Laplacian */
61  ORB_PBYP_PARTIAL, /*!< particle-by-particle, update Value and Grdient */
62  ORB_WALKER, /*!< walker update */
63  ORB_ALLWALKER /*!< all walkers update */
64  };
65 
66  ///Reference to the center
68  ///number of centers, e.g., ions
70  ///number of quantum particles
72  // number of variational parameters own by the radial function
73  int numParams;
74  // index of first parameter in derivative array
76  // temporary storage for derivatives
77  std::vector<TinyVector<RealType, 3>> derivs;
78 
79  // mmorales: all quantities produced by BF transformations
80  // should be real, so change everything here to ???<RealType>
83 
86 
89 
93 
96 
98  : CenterSys(ions), numParams(0), indexOfFirstParam(-1), uniqueFunctions(false)
99  {
100  NumCenters = CenterSys.getTotalNum(); // in case
101  NumTargets = els.getTotalNum();
102  }
103 
104  void resize(int NT, int NC)
105  {
106  NumTargets = NT;
107  NumCenters = NC;
108  UIJ.resize(NumTargets, NumCenters);
109  UIJ = 0;
111  AIJ = 0;
113  BIJ = 0;
114  UIJ_temp.resize(NumCenters);
115  UIJ_temp = 0;
117  AIJ_temp = 0;
119  BIJ_temp = 0;
120  }
121 
122  virtual std::unique_ptr<BackflowFunctionBase> makeClone(ParticleSet& tqp) const = 0;
123 
125 
126  virtual void acceptMove(int iat, int UpdateType) = 0;
127 
128  virtual void restore(int iat, int UpdateType) = 0;
129 
130  virtual void reportStatus(std::ostream& os) = 0;
131 
132  virtual void resetParameters(const opt_variables_type& active) = 0;
133 
134  virtual void checkInVariables(opt_variables_type& active) = 0;
135 
136  virtual void checkOutVariables(const opt_variables_type& active) = 0;
137 
138  virtual bool isOptimizable() = 0;
139 
140  virtual int indexOffset() = 0;
141 
142  // Note: numParams should be set in Builder class, so it is known here
143  inline int setParamIndex(int n)
144  {
146  return numParams;
147  }
148 
149  virtual void registerData(WFBufferType& buf) = 0;
150 
152  {
153  buf.put(FirstOfU, LastOfU);
154  buf.put(FirstOfA, LastOfA);
155  buf.put(FirstOfB, LastOfB);
156  }
157 
159  {
160  buf.get(FirstOfU, LastOfU);
161  buf.get(FirstOfA, LastOfA);
162  buf.get(FirstOfB, LastOfB);
163  }
164 
165  /** calculate quasi-particle coordinates only
166  */
167  virtual void evaluate(const ParticleSet& P, ParticleSet& QP) = 0;
168 
169  /** calculate quasi-particle coordinates, Bmat and Amat
170  */
171  virtual void evaluate(const ParticleSet& P, ParticleSet& QP, GradMatrix& Bmat, HessMatrix& Amat) = 0;
172 
173  /** calculate quasi-particle coordinates after pbyp move
174  */
175  virtual void evaluatePbyP(const ParticleSet& P, ParticleSet::ParticlePos& newQP, const std::vector<int>& index) = 0;
176 
177  /** calculate quasi-particle coordinates and Amat after pbyp move
178  */
179  virtual void evaluatePbyP(const ParticleSet& P,
181  const std::vector<int>& index,
182  HessMatrix& Amat) = 0;
183 
184  /** calculate quasi-particle coordinates, Bmat and Amat after pbyp move
185  */
186  virtual void evaluatePbyP(const ParticleSet& P,
188  const std::vector<int>& index,
189  GradMatrix& Bmat,
190  HessMatrix& Amat) = 0;
191 
192  /** calculate quasi-particle coordinates after pbyp move
193  */
194  virtual void evaluatePbyP(const ParticleSet& P, int iat, ParticleSet::ParticlePos& newQP) = 0;
195 
196  /** calculate quasi-particle coordinates and Amat after pbyp move
197  */
198  virtual void evaluatePbyP(const ParticleSet& P, int iat, ParticleSet::ParticlePos& newQP, HessMatrix& Amat) = 0;
199 
200  /** calculate quasi-particle coordinates, Bmat and Amat after pbyp move
201  */
202  virtual void evaluatePbyP(const ParticleSet& P,
203  int iat,
205  GradMatrix& Bmat,
206  HessMatrix& Amat) = 0;
207 
208  /** calculate only Bmat
209  * This is used in pbyp moves, in updateBuffer()
210  */
211  virtual void evaluateBmatOnly(const ParticleSet& P, GradMatrix& Bmat_full) = 0;
212 
213  /** calculate quasi-particle coordinates, Bmat and Amat
214  * calculate derivatives wrt to variational parameters
215  */
216  virtual void evaluateWithDerivatives(const ParticleSet& P,
217  ParticleSet& QP,
218  GradMatrix& Bmat,
219  HessMatrix& Amat,
220  GradMatrix& Cmat,
221  GradMatrix& Ymat,
222  HessArray& Xmat) = 0;
223 };
224 
225 } // namespace qmcplusplus
226 
227 #endif
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
virtual std::unique_ptr< BackflowFunctionBase > makeClone(ParticleSet &tqp) const =0
int NumTargets
number of quantum particles
Walker< QMCTraits, PtclOnLatticeTraits > Walker_t
walker type
Definition: ParticleSet.h:59
Declaration of OptimizableObject.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
size_t getTotalNum() const
Definition: ParticleSet.h:493
#define OHMMS_PRECISION
Definition: config.h:70
Base class for backflow transformations.
virtual void checkInVariables(opt_variables_type &active)=0
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
Attaches a unit to a Vector for IO.
int NumCenters
number of centers, e.g., ions
#define OHMMS_DIM
Definition: config.h:64
virtual void evaluateBmatOnly(const ParticleSet &P, GradMatrix &Bmat_full)=0
calculate only Bmat This is used in pbyp moves, in updateBuffer()
PooledMemory< FullPrecRealType > WFBuffer_t
Definition: Walker.h:80
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
virtual void reportStatus(std::ostream &os)=0
void copyFromBuffer(WFBufferType &buf)
virtual void evaluatePbyP(const ParticleSet &P, ParticleSet::ParticlePos &newQP, const std::vector< int > &index)=0
calculate quasi-particle coordinates after pbyp move
virtual void acceptMove(int iat, int UpdateType)=0
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
virtual void checkOutVariables(const opt_variables_type &active)=0
virtual void restore(int iat, int UpdateType)=0
ParticleSet & CenterSys
Reference to the center.
virtual void evaluateWithDerivatives(const ParticleSet &P, ParticleSet &QP, GradMatrix &Bmat, HessMatrix &Amat, GradMatrix &Cmat, GradMatrix &Ymat, HessArray &Xmat)=0
calculate quasi-particle coordinates, Bmat and Amat calculate derivatives wrt to variational paramete...
std::vector< TinyVector< RealType, 3 > > derivs
BackflowFunctionBase(ParticleSet &ions, ParticleSet &els)
virtual void evaluate(const ParticleSet &P, ParticleSet &QP)=0
calculate quasi-particle coordinates only
A container class to represent a walker.
Definition: Walker.h:49
virtual void resetParameters(const opt_variables_type &active)=0
void put(std::complex< T1 > &x)
Definition: PooledMemory.h:165
virtual void registerData(WFBufferType &buf)=0
void get(std::complex< T1 > &x)
Definition: PooledMemory.h:132