QMCPACK
BackflowTransformation.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 // 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 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //
12 // File created by: Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 #ifndef QMCPLUSPLUS_BACKFLOW_TRANSFORMATION_H
17 #define QMCPLUSPLUS_BACKFLOW_TRANSFORMATION_H
18 
19 #include "Configuration.h"
20 #include <map>
21 #include <cmath>
22 #include "Particle/ParticleSet.h"
23 #include "DistanceTable.h"
26 #include "OhmmsPETE/OhmmsArray.h"
27 #include "OptimizableObject.h"
28 
29 namespace qmcplusplus
30 {
32 {
33 public:
35 
36  // All BF quantities should be real, so eliminating complex (ValueType) possibility
37  enum
38  {
40  };
42  using IndexType = int;
51 
53 
54  using PSetMap = std::map<std::string, const std::unique_ptr<ParticleSet>>;
55  //using GradArray_t = Array<GradType,3> ;
56  //using PosArray_t = Array<PosType,3> ;
57 
58  ///number of quantum particles
60 
61  /// active particle in pbyp moves
63 
64  /// quasiparticle coordinates
66 
67  // number of variational parameters
68  int numParams;
69 
70  /** current update mode */
72 
73  /** enum for a update mode */
74  enum
75  {
76  ORB_PBYP_RATIO, /*!< particle-by-particle ratio only */
77  ORB_PBYP_ALL, /*!< particle-by-particle, update Value-Gradient-Laplacian */
78  ORB_PBYP_PARTIAL, /*!< particle-by-particle, update Value and Grdient */
79  ORB_WALKER, /*!< walker update */
80  ORB_ALLWALKER /*!< all walkers update */
81  };
82 
83  // map index of variables from local arrays to outside world
84  std::map<int, int> optIndexMap;
85 
86  // cutoff of radial funtions
88 
89  // pos of first optimizable variable in global array
91 
92  /// Distance Table
93  const int myTableIndex_;
94 
95  // matrix of laplacians
96  // /vec{B(i)} = sum_{k} /grad_{k}^2 /vec{x_i}
98 
100 
101  // matrix of first derivatives
102  // A(i,j)[a,b] = (Grad_i)_a (x_j)_b
103  // i,j:particle index
104  // a,b=(x,y,z)
105  // notice that A(i,j) is a symmetric matrix, improve later
107 
108  // \nabla_a A_{i,j}^{\alpha,\beta}
109  // derivative of A matrix with respect to var. prms.
111 
112  // \sum_i \nabla_a B_{i,j}^{\alpha}
114 
115  // \nabla_a x_i^{\alpha}
117 
123 
124  // Identity
127 
128  std::vector<std::unique_ptr<BackflowFunctionBase>> bfFuns;
129 
130  std::map<std::string, int> sources;
131  std::vector<std::string> names;
132 
133  /// new qp coordinates for pbyp moves.
136 
137  //Vector<PosType> storeQP;
139 
140  /// store index of qp coordinates that changed during pbyp move
141  std::vector<int> indexQP, index;
142 
144 
146 
147  void copyFrom(const BackflowTransformation& tr, ParticleSet& targetPtcl);
148 
149  std::unique_ptr<BackflowTransformation> makeClone(ParticleSet& tqp) const;
150 
152 
153  bool put(xmlNodePtr cur) { return true; }
154 
155  void acceptMove(const ParticleSet& P, int iat);
156 
157  void restore(int iat = 0);
158 
159  bool isOptimizable() const;
160  void checkInVariables(opt_variables_type& active);
161  void checkOutVariables(const opt_variables_type& active);
162  void resetParameters(const opt_variables_type& active);
163  void reportStatus(std::ostream& os) final;
164 
165  // extractOptimizableObjectRefs is not enabled in BackflowTransformation.
166  // it is exposed as a whole to the opitmizer. Thus the underlying OptimizableObject are not explosed.
167  // Simply redirect existing implentation.
169  void resetParametersExclusive(const opt_variables_type& active) final { resetParameters(active); }
170 
171  void registerData(ParticleSet& P, WFBufferType& buf);
172 
173  void updateBuffer(ParticleSet& P, WFBufferType& buf, bool redo);
174 
175  void copyFromBuffer(ParticleSet& P, WFBufferType& buf);
176 
177  /** calculate quasi-particle coordinates only
178  */
179  void transformOnly(const ParticleSet& P);
180 
181  /** calculate new quasi-particle coordinates after pbyp move
182  */
183  void evaluatePbyP(const ParticleSet& P, int iat);
184 
185  /** calculate new quasi-particle coordinates after pbyp move
186  */
187  void evaluatePbyPWithGrad(const ParticleSet& P, int iat);
188 
189  /** calculate new quasi-particle coordinates after pbyp move
190  */
191  void evaluatePbyPAll(const ParticleSet& P, int iat);
192 
193  /** calculate only Bmat. Assume that QP and Amat are current
194  * This is used in pbyp moves, in updateBuffer()
195  */
196  void evaluateBmatOnly(const ParticleSet& P, int iat);
197 
198  /** calculate quasi-particle coordinates, Bmat and Amat
199  */
200  void evaluate(const ParticleSet& P);
201 
202  /** calculate quasi-particle coordinates and store in Pnew
203  */
204  void evaluate(const ParticleSet& P, ParticleSet& Pnew);
205 
206  void evaluateDerivatives(const ParticleSet& P);
207 
208  void testDeriv(const ParticleSet& P);
209 
210  void testPbyP(ParticleSet& P);
211 };
212 
213 } // namespace qmcplusplus
214 
215 #endif
void evaluateBmatOnly(const ParticleSet &P, int iat)
calculate only Bmat.
void evaluatePbyP(const ParticleSet &P, int iat)
calculate new quasi-particle coordinates after pbyp move
Declaration of OptimizableObject.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
ParticleSet::ParticlePos newQP
new qp coordinates for pbyp moves.
#define OHMMS_PRECISION
Definition: config.h:70
BackflowFunctionBase::WFBufferType WFBufferType
void resetParametersExclusive(const opt_variables_type &active) final
reset the parameters during optimizations.
void updateBuffer(ParticleSet &P, WFBufferType &buf, bool redo)
Attaches a unit to a Vector for IO.
void registerData(ParticleSet &P, WFBufferType &buf)
#define OHMMS_DIM
Definition: config.h:64
void evaluateDerivatives(const ParticleSet &P)
void evaluatePbyPAll(const ParticleSet &P, int iat)
calculate new quasi-particle coordinates after pbyp move
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
void checkOutVariables(const opt_variables_type &active)
void checkInVariablesExclusive(opt_variables_type &active) final
check in variational parameters to the global list of parameters used by the optimizer.
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
void checkInVariables(opt_variables_type &active)
int NumTargets
number of quantum particles
void reportStatus(std::ostream &os) final
print the state, e.g., optimizables
std::vector< std::unique_ptr< BackflowFunctionBase > > bfFuns
void copyFrom(const BackflowTransformation &tr, ParticleSet &targetPtcl)
void resetParameters(const opt_variables_type &active)
Declaraton of ParticleAttrib<T>
void evaluate(const ParticleSet &P)
calculate quasi-particle coordinates, Bmat and Amat
std::map< std::string, int > sources
void acceptMove(const ParticleSet &P, int iat)
std::map< std::string, const std::unique_ptr< ParticleSet > > PSetMap
void evaluatePbyPWithGrad(const ParticleSet &P, int iat)
calculate new quasi-particle coordinates after pbyp move
std::unique_ptr< BackflowTransformation > makeClone(ParticleSet &tqp) const
int activeParticle
active particle in pbyp moves
void copyFromBuffer(ParticleSet &P, WFBufferType &buf)
void transformOnly(const ParticleSet &P)
calculate quasi-particle coordinates only
ParticleSet QP
quasiparticle coordinates
std::vector< int > indexQP
store index of qp coordinates that changed during pbyp move