QMCPACK
WaveFunctionComponent.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) 2020 QMCPACK developers.
6 //
7 // File developed by: Ken Esler, kpesler@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 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 // Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
12 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
13 //
14 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
15 //////////////////////////////////////////////////////////////////////////////////////
16 
17 
18 #ifndef QMCPLUSPLUS_WAVEFUNCTIONCOMPONENT_H
19 #define QMCPLUSPLUS_WAVEFUNCTIONCOMPONENT_H
20 
21 #include <memory>
22 #include "Message/Communicate.h"
23 #include "Configuration.h"
24 #include "Particle/ParticleSet.h"
28 #include "OptimizableObject.h"
31 #include "TWFGrads.hpp"
32 
33 /**@file WaveFunctionComponent.h
34  *@brief Declaration of WaveFunctionComponent
35  */
36 namespace qmcplusplus
37 {
38 ///forward declaration
39 class WaveFunctionComponent;
40 class ResourceCollection;
41 class TWFFastDerivWrapper;
42 /**@defgroup WaveFunctionComponent group
43  * @brief Classes which constitute a many-body trial wave function
44  *
45  * A many-body trial wave function is
46  * \f[
47  \Psi(\{ {\bf R}\}) = \prod_i \psi_{i}(\{ {\bf R}\}),
48  * \f]
49  * where \f$\Psi\f$s are represented by
50  * the derived classes from WaveFunctionComponent.
51  */
52 /** @ingroup WaveFunctionComponent
53  * @brief An abstract class for a component of a many-body trial wave function
54  *
55  * mw_ prefix is a function name signature indicating it is for handling a batch of WaveFunctionComponent objects
56  * which are required to be base class pointers of the same derived class type.
57  * all the mw_ routines must be implemented in a way either stateless or maintains states of every walker.
58  */
60 {
61 public:
62  /** enum for a update mode */
63  enum
64  {
65  ORB_PBYP_RATIO, /*!< particle-by-particle ratio only */
66  ORB_PBYP_ALL, /*!< particle-by-particle, update Value-Gradient-Laplacian */
67  ORB_PBYP_PARTIAL, /*!< particle-by-particle, update Value and Grdient */
68  ORB_WALKER, /*!< walker update */
69  ORB_ALLWALKER /*!< all walkers update */
70  };
71 
81 
82  // the value type for log(psi)
83  using LogValue = std::complex<QTFull::RealType>;
84  // the value type for psi(r')/psi(r)
86 
87  /** current update mode */
89  ///list of variables this WaveFunctionComponent handles
91  ///Bytes in WFBuffer
93 
94 protected:
95  /** Name of the object
96  * It is required to be different for objects of the same derived type like multiple J1.
97  * It can be left empty for object which is unique per many-body WF.
98  */
99  const std::string my_name_;
100  /** Current \f$\log\phi \f$.
101  * Exception! Slater Determinant most of the time has inconsistent a log_value inconsistent with the determinants
102  * it contains dduring a move sequence. That case the log_value_ would be more safely calculated on the fly.
103  *
104  * There could be others.
105  */
107 
108 public:
109  const LogValue& get_log_value() const { return log_value_; }
110 
111  /// default constructor
112  WaveFunctionComponent(const std::string& obj_name = "");
113  ///default destructor
114  virtual ~WaveFunctionComponent();
115 
116  /// Validate the internal consistency of the object
117  virtual void checkSanity() const {}
118 
119  /// return object name
120  const std::string& getName() const { return my_name_; }
121 
122  /// return class name
123  virtual std::string getClassName() const = 0;
124 
125  ///assembles the full value
127 
128  /** true, if this component is fermionic */
129  virtual bool isFermionic() const { return false; }
130 
131  /** true, if this component is multi-determinant */
132  virtual bool isMultiDet() const { return false; }
133 
134  /** check out variational optimizable variables
135  * @param active a super set of optimizable variables
136  */
137  virtual void checkOutVariables(const opt_variables_type& active);
138 
139  /** Register the component with the TWFFastDerivWrapper wrapper.
140  */
141  virtual void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const;
142 
143  /** evaluate the value of the WaveFunctionComponent from scratch
144  * \param[in] P active ParticleSet
145  * \param[out] G Gradients, \f$\nabla\ln\Psi\f$
146  * \param[out] L Laplacians, \f$\nabla^2\ln\Psi\f$
147  * \return the log value
148  *
149  * Mainly for walker-by-walker move. The initial stage of particle-by-particle
150  * move also uses this. causes complete state update in WFC's
151  */
152  virtual LogValue evaluateLog(const ParticleSet& P,
155 
156  /** evaluate from scratch the same type WaveFunctionComponent of multiple walkers
157  * @param wfc_list the list of WaveFunctionComponent pointers of the same component in a walker batch
158  * @param p_list the list of ParticleSet pointers in a walker batch
159  * @param G_list the list of Gradients pointers in a walker batch, \f$\nabla\ln\Psi\f$
160  * @param L_list the list of Laplacians pointers in a walker batch, \f$\nabla^2\ln\Psi\f$
161  * @param values the log WF values of walkers in a batch
162  */
163  virtual void mw_evaluateLog(const RefVectorWithLeader<WaveFunctionComponent>& wfc_list,
164  const RefVectorWithLeader<ParticleSet>& p_list,
166  const RefVector<ParticleSet::ParticleLaplacian>& L_list) const;
167 
168  /** recompute the value of the WaveFunctionComponents which require critical accuracy.
169  * needed for Slater Determinants but not needed for most types of WaveFunctionComponents
170  */
171  virtual void recompute(const ParticleSet& P);
172 
173  virtual void mw_recompute(const RefVectorWithLeader<WaveFunctionComponent>& wfc_list,
174  const RefVectorWithLeader<ParticleSet>& p_list,
175  const std::vector<bool>& recompute) const;
176 
177  // virtual void evaluateHessian(ParticleSet& P, IndexType iat, HessType& grad_grad_psi)
178  // {
179  // APP_ABORT("WaveFunctionComponent::evaluateHessian is not implemented");
180  // }
181 
182  virtual void evaluateHessian(ParticleSet& P, HessVector& grad_grad_psi_all)
183  {
184  APP_ABORT("WaveFunctionComponent::evaluateHessian is not implemented in " + getClassName() + " class.");
185  }
186 
187  /** Prepare internal data for updating WFC correspond to a particle group
188  * It should be called before moving particles of a given group.
189  * This call can be used to handle the precomputation of data used for moving this group of particle.
190  * Such data should be static with respect to the moves of particles within this group.
191  * Particle groups usually correspond to determinants of different spins.
192  * @param P quantum particle set
193  * @param ig particle group index
194  */
195  virtual void prepareGroup(ParticleSet& P, int ig) {}
196 
197  virtual void mw_prepareGroup(const RefVectorWithLeader<WaveFunctionComponent>& wfc_list,
198  const RefVectorWithLeader<ParticleSet>& p_list,
199  int ig) const;
200 
201  /** return the current gradient for the iat-th particle
202  * @param P quantum particle set
203  * @param iat particle index
204  * @return the gradient of the iat-th particle
205  */
206  virtual GradType evalGrad(ParticleSet& P, int iat)
207  {
208  APP_ABORT("WaveFunctionComponent::evalGradient is not implemented in " + getClassName() + " class.");
209  return GradType();
210  }
211 
212 
213  /** return the current spin gradient for the iat-th particle
214  * Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin.
215  * @param P quantum particle set
216  * @param iat particle index
217  * @return the spin gradient of the iat-th particle
218  */
219  virtual GradType evalGradWithSpin(ParticleSet& P, int iat, ComplexType& spingrad) { return evalGrad(P, iat); }
220 
221  /** compute the current gradients for the iat-th particle of multiple walkers
222  * @param[out] grad_now the list of gradients in a walker batch, \f$\nabla\ln\Psi\f$
223  */
224  template<CoordsType CT>
226  const RefVectorWithLeader<ParticleSet>& p_list,
227  const int iat,
228  TWFGrads<CT>& grads_now) const;
229 
230  /** compute the current gradients for the iat-th particle of multiple walkers
231  * @param wfc_list the list of WaveFunctionComponent pointers of the same component in a walker batch
232  * @param p_list the list of ParticleSet pointers in a walker batch
233  * @param iat particle index
234  * @param grad_now the list of gradients in a walker batch, \f$\nabla\ln\Psi\f$
235  */
236  virtual void mw_evalGrad(const RefVectorWithLeader<WaveFunctionComponent>& wfc_list,
237  const RefVectorWithLeader<ParticleSet>& p_list,
238  int iat,
239  std::vector<GradType>& grad_now) const;
240 
241  /** return the logarithmic gradient for the iat-th particle
242  * of the source particleset
243  * @param Pquantum particle set
244  * @param iat particle index
245  * @return the gradient of the iat-th particle
246  */
247  virtual GradType evalGradSource(ParticleSet& P, ParticleSet& source, int iat)
248  {
249  // unit_test_hamiltonian calls this function incorrectly; do not abort for now
250  // APP_ABORT("WaveFunctionComponent::evalGradSource is not implemented");
251  return GradType();
252  }
253 
254  /** Adds the gradient w.r.t. the iat-th particle of the
255  * source particleset (ions) of the logarithmic gradient
256  * and laplacian w.r.t. the target paritlceset (electrons).
257  * @param P quantum particle set (electrons)
258  * @param source classical particle set (ions)
259  * @param iat particle index of source (ion)
260  * @param the ion gradient of the elctron gradient
261  * @param the ion gradient of the elctron laplacian.
262  * @return the log gradient of psi w.r.t. the source particle iat
263  */
265  ParticleSet& source,
266  int iat,
269  {
270  return GradType();
271  }
272 
273 
274  /** evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient
275  * @param P the active ParticleSet
276  * @param iat the index of a particle
277  * @param grad_iat Gradient for the active particle
278  */
279  virtual PsiValue ratioGrad(ParticleSet& P, int iat, GradType& grad_iat);
280 
281  /** evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient
282  * Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin.
283  * @param P the active ParticleSet
284  * @param iat the index of a particle
285  * @param grad_iat realspace gradient for the active particle
286  * @param spingrad_iat spin gradient for the active particle
287  */
288  virtual PsiValue ratioGradWithSpin(ParticleSet& P, int iat, GradType& grad_iat, ComplexType& spingrad_iat)
289  {
290  return ratioGrad(P, iat, grad_iat);
291  }
292 
293  template<CoordsType CT>
295  const RefVectorWithLeader<ParticleSet>& p_list,
296  int iat,
297  std::vector<PsiValue>& ratios,
298  TWFGrads<CT>& grad_new) const;
299 
300  /** compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers
301  * @param wfc_list the list of WaveFunctionComponent pointers of the same component in a walker batch
302  * @param p_list the list of ParticleSet pointers in a walker batch
303  * @param iat particle index
304  * @param ratios the list of WF ratios of a walker batch, \f$ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})\f$
305  * @param grad_now the list of new gradients in a walker batch, \f$\nabla\ln\Psi\f$
306  */
307  virtual void mw_ratioGrad(const RefVectorWithLeader<WaveFunctionComponent>& wfc_list,
308  const RefVectorWithLeader<ParticleSet>& p_list,
309  int iat,
310  std::vector<PsiValue>& ratios,
311  std::vector<GradType>& grad_new) const;
312 
313  /** a move for iat-th particle is accepted. Update the current content.
314  * @param P target ParticleSet
315  * @param iat index of the particle whose new position was proposed
316  * @param safe_to_delay if true, delayed accept is safe.
317  */
318  virtual void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) = 0;
319 
320  /** moves of the iat-th particle on some walkers in a batch is accepted. Update the current content.
321  * Note that all the lists only include accepted walkers.
322  * @param wfc_list the list of WaveFunctionComponent pointers of the same component in a walker batch
323  * @param p_list the list of ParticleSet pointers in a walker batch
324  * @param iat particle index
325  * @param safe_to_delay if true, delayed accept is safe.
326  */
328  const RefVectorWithLeader<ParticleSet>& p_list,
329  int iat,
330  const std::vector<bool>& isAccepted,
331  bool safe_to_delay = false) const;
332 
333  /** complete all the delayed or asynchronous operations before leaving the p-by-p move region.
334  * Must be called at the end of each substep if p-by-p move is used.
335  * This function was initially introduced for determinant delayed updates to complete all the delayed operations.
336  * It has been extended to handle asynchronous operations on accellerators before leaving the p-by-p move region.
337  */
338  virtual void completeUpdates() {}
339 
340  /** complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region.
341  */
342  virtual void mw_completeUpdates(const RefVectorWithLeader<WaveFunctionComponent>& wfc_list) const;
343 
344  /** If a move for iat-th particle is rejected, restore to the content.
345  * @param iat index of the particle whose new position was proposed
346  *
347  * Ye: hopefully we can gradually move away from restore
348  */
349  virtual void restore(int iat) = 0;
350 
351  /** evaluate the ratio of the new to old WaveFunctionComponent value
352  * @param P the active ParticleSet
353  * @param iat the index of a particle
354  * @return \f$ \psi( \{ {\bf R}^{'} \} )/ \psi( \{ {\bf R}\})\f$
355  *
356  * Specialized for particle-by-particle move
357  */
358  virtual PsiValue ratio(ParticleSet& P, int iat) = 0;
359 
360  /** compute the ratio of the new to old WaveFunctionComponent value of multiple walkers
361  * @param wfc_list the list of WaveFunctionComponent pointers of the same component in a walker batch
362  * @param p_list the list of ParticleSet pointers in a walker batch
363  * @param iat particle index
364  * @param ratios the list of WF ratios of a walker batch, \f$ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})\f$
365  */
366  virtual void mw_calcRatio(const RefVectorWithLeader<WaveFunctionComponent>& wfc_list,
367  const RefVectorWithLeader<ParticleSet>& p_list,
368  int iat,
369  std::vector<PsiValue>& ratios) const;
370 
371  /** compute gradients and laplacian of the TWF with respect to each particle.
372  * @param P particle set
373  * @param G Gradients, \f$\nabla\ln\Psi\f$
374  * @param L Laplacians, \f$\nabla^2\ln\Psi\f$
375  * @param fromscratch if true and this WFC is sensitive to numeical error accumulation,
376  * all the internal data are recomputed from scratch.
377  * @return log(psi)
378  */
379  virtual LogValue evaluateGL(const ParticleSet& P,
382  bool fromscratch);
383 
384  /** evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers
385  * @param wfc_list the list of WaveFunctionComponent pointers of the same component in a walker batch
386  * @param p_list the list of ParticleSet pointers in a walker batch
387  * @param G_list the list of Gradients pointers in a walker batch, \f$\nabla\ln\Psi\f$
388  * @param L_list the list of Laplacians pointers in a walker batch, \f$\nabla^2\ln\Psi\f$
389  * @param fromscratch if true and this WFC is sensitive to numerical error accumulation,
390  * all the internal data are recomputed from scratch.
391  */
392  virtual void mw_evaluateGL(const RefVectorWithLeader<WaveFunctionComponent>& wfc_list,
393  const RefVectorWithLeader<ParticleSet>& p_list,
396  bool fromscratch) const;
397 
398  /** For particle-by-particle move. Requests space in the buffer
399  * based on the data type sizes of the objects in this class.
400  * @param P particle set
401  * @param buf Anonymous storage
402  */
403  virtual void registerData(ParticleSet& P, WFBufferType& buf) = 0;
404 
405  /** For particle-by-particle move. Put the objects of this class
406  * in the walker buffer or forward the memory cursor.
407  * @param P particle set
408  * @param buf Anonymous storage
409  * @param fromscratch request recomputing the precision critical
410  * pieces of wavefunction from scratch
411  * @return log value of the wavefunction.
412  */
413  virtual LogValue updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) = 0;
414 
415  /** For particle-by-particle move. Copy data or attach memory
416  * from a walker buffer to the objects of this class.
417  * The log value, P.G and P.L contribution from the objects
418  * of this class are also added.
419  * @param P particle set
420  * @param buf Anonymous storage
421  */
422  virtual void copyFromBuffer(ParticleSet& P, WFBufferType& buf) = 0;
423 
424  /** initialize a shared resource and hand it to a collection
425  */
426  virtual void createResource(ResourceCollection& collection) const {}
427 
428  /** acquire a shared resource from a collection
429  */
430  virtual void acquireResource(ResourceCollection& collection,
431  const RefVectorWithLeader<WaveFunctionComponent>& wfc_list) const
432  {}
433 
434  /** return a shared resource to a collection
435  */
436  virtual void releaseResource(ResourceCollection& collection,
437  const RefVectorWithLeader<WaveFunctionComponent>& wfc_list) const
438  {}
439 
440  /** make clone
441  * @param tqp target Quantum ParticleSet
442  * @param deepcopy if true, make a decopy
443  *
444  * If not true, return a proxy class
445  */
446  virtual std::unique_ptr<WaveFunctionComponent> makeClone(ParticleSet& tqp) const;
447 
448  /** Return the Chiesa kinetic energy correction
449  */
450  virtual RealType KECorrection();
451 
452  /** if true, this contains optimizable components
453  */
454  virtual bool isOptimizable() const { return false; }
455 
456  /** extract underlying OptimizableObject references
457  * @param opt_obj_refs aggregated list of optimizable object references
458  */
459  virtual void extractOptimizableObjectRefs(UniqueOptObjRefs& opt_obj_refs);
460 
461  /** Compute the derivatives of both the log of the wavefunction and kinetic energy
462  * with respect to optimizable parameters.
463  * @param P particle set
464  * @param optvars optimizable parameters
465  * @param dlogpsi array of derivatives of the log of the wavefunction.
466  * Add the contribution from this component.
467  * @param dhpsioverpsi array of Hamiltonian derivatives.
468  * Add the kinetic energy derivatives contribution from this component.
469  * \f$ -\frac{1}{2}{\partial}_\alpha \tilde L - G \cdot {\partial}_\alpha \tilde G \f$.
470  * \f$ \tilde L \f$ and \f$ \tilde G \f$ are from this WaveFunctionComponent.
471  * \f$ G \f$ is from TrialWaveFunction. The 1/m factor is applied in TrialWaveFunction.
472  * This is a bug when the particle set doesn't hold equal mass particles.
473  */
474  virtual void evaluateDerivatives(ParticleSet& P,
475  const opt_variables_type& optvars,
476  Vector<ValueType>& dlogpsi,
477  Vector<ValueType>& dhpsioverpsi) = 0;
478 
479  /** Compute the derivatives of the log of the wavefunction with respect to optimizable parameters.
480  * parameters
481  * @param P particle set
482  * @param optvars optimizable parameters
483  * @param dlogpsi array of derivatives of the log of the wavefunction.
484  * Note: this function differs from the evaluateDerivatives function in the way that it only computes
485  * the derivative of the log of the wavefunction.
486  */
487  virtual void evaluateDerivativesWF(ParticleSet& P, const opt_variables_type& optvars, Vector<ValueType>& dlogpsi);
488 
489 
490  /** Calculates the derivatives of \f$ \nabla \textnormal{log} \psi_f \f$ with respect to
491  the optimizable parameters, and the dot product of this is then
492  performed with the passed-in G_in gradient vector. This object is then
493  returned as dgradlogpsi.
494  */
495 
496  virtual void evaluateGradDerivatives(const ParticleSet::ParticleGradient& G_in, std::vector<ValueType>& dgradlogpsi)
497  {
498  APP_ABORT("Need specialization of WaveFunctionComponent::evaluateGradDerivatives in " + getClassName() +
499  " class.\n");
500  }
501 
502  virtual void finalizeOptimization() {}
503 
504  /** evaluate the ratios of one virtual move with respect to all the particles
505  * @param P reference particleset
506  * @param ratios \f$ ratios[i]=\{{\bf R}\}\rightarrow {r_0,\cdots,r_i^p=pos,\cdots,r_{N-1}}\f$
507  */
508  virtual void evaluateRatiosAlltoOne(ParticleSet& P, std::vector<ValueType>& ratios);
509 
510  /** evaluate ratios to evaluate the non-local PP
511  * @param VP VirtualParticleSet
512  * @param ratios ratios with new positions VP.R[k] the VP.refPtcl
513  */
514  virtual void evaluateRatios(const VirtualParticleSet& VP, std::vector<ValueType>& ratios);
515 
516  /** Used by SOECPComponent for faster SOC evaluation
517  */
518  virtual void evaluateSpinorRatios(const VirtualParticleSet& VP, const std::pair<ValueVector, ValueVector>& spinor_multiplier, std::vector<ValueType>& ratios);
519 
520  /** evaluate ratios to evaluate the non-local PP multiple walkers
521  * @param wfc_list the list of WaveFunctionComponent references of the same component in a walker batch
522  * @param vp_list the list of VirtualParticleSet references in a walker batch
523  * @param ratios of all the virtual moves of all the walkers
524  */
527  std::vector<std::vector<ValueType>>& ratios) const;
528 
529  /** evaluate ratios to evaluate the non-local PP
530  * @param VP VirtualParticleSet
531  * @param ratios ratios with new positions VP.R[k] the VP.refPtcl
532  * @param dratios Nq x Num_param matrix. \f$\partial_{\alpha}(\ln \Psi ({\bf R}^{\prime}) - \ln \Psi ({\bf R})) \f$
533  */
534  virtual void evaluateDerivRatios(const VirtualParticleSet& VP,
535  const opt_variables_type& optvars,
536  std::vector<ValueType>& ratios,
537  Matrix<ValueType>& dratios);
538 
539  /** compute the current gradients and spin gradients for the iat-th particle of multiple walkers
540  * @param wfc_list the list of WaveFunctionComponent pointers of the same component in a walker batch
541  * @param p_list the list of ParticleSet pointers in a walker batch
542  * @param iat particle index
543  * @param grad_now the list of gradients in a walker batch, \f$\nabla\ln\Psi\f$
544  * @param spingrad_now the list of spin gradients in a walker batch, \f$\nabla_s\ln\Psi\f$
545  *
546  */
548  const RefVectorWithLeader<ParticleSet>& p_list,
549  int iat,
550  std::vector<GradType>& grad_now,
551  std::vector<ComplexType>& spingrad_now) const;
552 
553  /** compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of multiple walkers
554  * @param wfc_list the list of WaveFunctionComponent pointers of the same component in a walker batch
555  * @param p_list the list of ParticleSet pointers in a walker batch
556  * @param iat particle index
557  * @param ratios the list of WF ratios of a walker batch, \f$ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})\f$
558  * @param grad_now the list of new gradients in a walker batch, \f$\nabla\ln\Psi\f$
559  */
561  const RefVectorWithLeader<ParticleSet>& p_list,
562  int iat,
563  std::vector<PsiValue>& ratios,
564  std::vector<GradType>& grad_new,
565  std::vector<ComplexType>& spingrad_new) const;
566 
567 };
568 } // namespace qmcplusplus
569 #endif
virtual void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
return a shared resource to a collection
Walker< QMCTraits, PtclOnLatticeTraits > Walker_t
walker type
Definition: ParticleSet.h:59
const std::string & getName() const
return object name
Fixed-size array.
Definition: OhmmsTinyMeta.h:30
virtual bool isOptimizable() const
if true, this contains optimizable components
Declaration of OptimizableObject.
OrbitalSetTraits< ValueType >::ValueVector ValueVector
virtual LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)=0
evaluate the value of the WaveFunctionComponent from scratch
virtual void evaluateDerivRatios(const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios)
evaluate ratios to evaluate the non-local PP
WaveFunctionComponent::PsiValue PsiValue
Definition: SlaterDet.cpp:25
static T convert(const std::complex< T1 > &logpsi)
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
virtual LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false)=0
For particle-by-particle move.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::GradType GradType
Definition: Configuration.h:62
virtual void mw_prepareGroup(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
virtual void mw_recompute(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
virtual void registerTWFFastDerivWrapper(const ParticleSet &P, TWFFastDerivWrapper &twf) const
Register the component with the TWFFastDerivWrapper wrapper.
virtual void recompute(const ParticleSet &P)
recompute the value of the WaveFunctionComponents which require critical accuracy.
virtual void evaluateHessian(ParticleSet &P, HessVector &grad_grad_psi_all)
virtual std::string getClassName() const =0
return class name
virtual GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat)
return the logarithmic gradient for the iat-th particle of the source particleset ...
virtual LogValue evaluateGL(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch)
compute gradients and laplacian of the TWF with respect to each particle.
virtual bool isMultiDet() const
true, if this component is multi-determinant
RealType ValueType
Definition: QMCTypes.h:42
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
LatticeGaussianProduct::GradType GradType
virtual GradType evalGradWithSpin(ParticleSet &P, int iat, ComplexType &spingrad)
return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunc...
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
virtual void checkSanity() const
Validate the internal consistency of the object.
Attaches a unit to a Vector for IO.
TWFFastDerivWrapper is a wrapper class for TrialWavefunction that provides separate and low level acc...
virtual void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
acquire a shared resource from a collection
OrbitalSetTraits< ValueType >::HessType HessType
A proxy class to the quantum ParticleSet.
void mw_evalGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, TWFGrads< CT > &grads_now) const
compute the current gradients for the iat-th particle of multiple walkers
virtual void mw_evaluateGL(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list, bool fromscratch) const
evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers ...
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::complex< QTFull::RealType > LogValue
virtual void mw_ratioGradWithSpin(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new, std::vector< ComplexType > &spingrad_new) const
compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of ...
PooledMemory< FullPrecRealType > WFBuffer_t
Definition: Walker.h:80
An abstract class for a component of a many-body trial wave function.
virtual void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)=0
Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimi...
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
virtual void checkOutVariables(const opt_variables_type &active)
check out variational optimizable variables
virtual void registerData(ParticleSet &P, WFBufferType &buf)=0
For particle-by-particle move.
virtual void mw_completeUpdates(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the...
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
virtual void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
virtual void mw_evalGradWithSpin(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const
compute the current gradients and spin gradients for the iat-th particle of multiple walkers ...
virtual GradType evalGrad(ParticleSet &P, int iat)
return the current gradient for the iat-th particle
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
virtual void evaluateSpinorRatios(const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
Used by SOECPComponent for faster SOC evaluation.
virtual void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi)
Compute the derivatives of the log of the wavefunction with respect to optimizable parameters...
virtual PsiValue ratio(ParticleSet &P, int iat)=0
evaluate the ratio of the new to old WaveFunctionComponent value
virtual void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
evaluate ratios to evaluate the non-local PP
virtual void prepareGroup(ParticleSet &P, int ig)
Prepare internal data for updating WFC correspond to a particle group It should be called before movi...
virtual void mw_accept_rejectMove(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false) const
moves of the iat-th particle on some walkers in a batch is accepted.
std::vector< std::reference_wrapper< T > > RefVector
virtual void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs)
extract underlying OptimizableObject references
virtual void mw_evaluateLog(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const
evaluate from scratch the same type WaveFunctionComponent of multiple walkers
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
void mw_ratioGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const
virtual GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad)
Adds the gradient w.r.t.
virtual void mw_evaluateRatios(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const
evaluate ratios to evaluate the non-local PP multiple walkers
virtual void evaluateGradDerivatives(const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
Calculates the derivatives of with respect to the optimizable parameters, and the dot product of thi...
OrbitalSetTraits< ValueType >::HessVector HessVector
virtual PsiValue ratioGradWithSpin(ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad_iat)
evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default im...
virtual PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat)
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
virtual void copyFromBuffer(ParticleSet &P, WFBufferType &buf)=0
For particle-by-particle move.
virtual void completeUpdates()
complete all the delayed or asynchronous operations before leaving the p-by-p move region...
WaveFunctionComponent(const std::string &obj_name="")
default constructor
std::complex< double > LogValue
virtual void mw_calcRatio(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const
compute the ratio of the new to old WaveFunctionComponent value of multiple walkers ...
trait class to handel a set of Orbitals
traits for QMC variables
Definition: Configuration.h:49
virtual void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios)
evaluate the ratios of one virtual move with respect to all the particles
virtual void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false)=0
a move for iat-th particle is accepted.
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.
PooledData< RealType > Buffer_t
Definition: Walker.h:81
virtual RealType KECorrection()
Return the Chiesa kinetic energy correction.
virtual bool isFermionic() const
true, if this component is fermionic
virtual void restore(int iat)=0
If a move for iat-th particle is rejected, restore to the content.
virtual std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const
make clone
Declaration of a MCWalkerConfiguration.
A container class to represent a walker.
Definition: Walker.h:49
virtual ~WaveFunctionComponent()
default destructor
PsiValue getValue() const
assembles the full value