QMCPACK
group

Classes which constitute a many-body trial wave function. More...

Classes

class  MultiSlaterDetTableMethod
 An AntiSymmetric WaveFunctionComponent composed of a linear combination of SlaterDeterminants. More...
 
class  J1OrbitalSoA< FT >
 Specialization for one-body Jastrow function using multiple functors. More...
 
struct  J1Spin< FT >
 Specialization for one-body Jastrow function using multiple functors. More...
 
class  JeeIOrbitalSoA< FT >
 Specialization for three-body Jastrow function using multiple functors. More...
 
class  TwoBodyJastrow< FT >
 Specialization for two-body Jastrow function using multiple functors. More...
 
class  WaveFunctionComponent
 An abstract class for a component of a many-body trial wave function. More...
 

Detailed Description

Classes which constitute a many-body trial wave function.

A many-body trial wave function is

\[ \Psi(\{ {\bf R}\}) = \prod_i \psi_{i}(\{ {\bf R}\}), \]

where $\Psi$s are represented by the derived classes from WaveFunctionComponent.


Class Documentation

◆ qmcplusplus::MultiSlaterDetTableMethod

class qmcplusplus::MultiSlaterDetTableMethod

An AntiSymmetric WaveFunctionComponent composed of a linear combination of SlaterDeterminants.

\[ *MSD({\bf R}) = \sum_n c_n S_n({\bf R}) *\]

.

The (S)ingle(P)article(O)rbitalSet template parameter is an engine which fills in single-particle orbital terms.

\[ \frac{\nabla_i\Psi}{\Psi} = \frac{\sum_{n=1}^M c_n \nabla_i D_n} {\sum_{n=1}^M c_n D_n} \]

\[ \frac{\sum_{n=1}^M c_n S_n(\sum_{j=1}^N(\nabla_i S^{ij}_n({\bf r_i}))(S^{-1})^{ji}_n}{\sum_{n=1}^M c_n S_n} \]

The Laplacian

\[ \frac{\nabla^2_i\Psi}{\Psi} = \frac{\sum_{n=1}^M c_n S_n(\sum_{j=1}^N (\nabla_i^2S^{ij}_n({\bf r_i}))(S^{-1})^{ji}_n}{\sum_{n=1}^M c_n S_n} \]

Definition at line 66 of file MultiSlaterDetTableMethod.h.

+ Inheritance diagram for MultiSlaterDetTableMethod:
+ Collaboration diagram for MultiSlaterDetTableMethod:

Public Types

template<typename DT >
using OffloadVector = Vector< DT, OffloadPinnedAllocator< DT > >
 
using SPOSetPtr = SPOSet *
 
using IndexVector = OrbitalSetTraits< ValueType >::IndexVector
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using GradVector = OrbitalSetTraits< ValueType >::GradVector
 
using HessMatrix = OrbitalSetTraits< ValueType >::HessMatrix
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessArray = Array< HessType, 3 >
 
using GGGType = TinyVector< HessType, OHMMS_DIM >
 
using GGGVector = Vector< GGGType >
 
using GGGMatrix = Matrix< GGGType >
 
using Walker_t = ParticleSet::Walker_t
 
- Public Types inherited from WaveFunctionComponent
enum  {
  ORB_PBYP_RATIO, ORB_PBYP_ALL, ORB_PBYP_PARTIAL, ORB_WALKER,
  ORB_ALLWALKER
}
 enum for a update mode More...
 
using Walker_t = ParticleSet::Walker_t
 
using WFBufferType = Walker_t::WFBuffer_t
 
using BufferType = Walker_t::Buffer_t
 
using RealMatrix_t = OrbitalSetTraits< RealType >::ValueMatrix
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using LogValue = std::complex< QTFull::RealType >
 
using PsiValue = QTFull::ValueType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 MultiSlaterDetTableMethod (ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
 constructor More...
 
 ~MultiSlaterDetTableMethod () override
 destructor More...
 
std::string getClassName () const override
 return class name More...
 
bool isFermionic () const final
 true, if this component is fermionic More...
 
bool isMultiDet () const final
 true, if this component is multi-determinant More...
 
bool isOptimizable () const override
 if true, this contains optimizable components More...
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) override
 extract underlying OptimizableObject references More...
 
void checkOutVariables (const opt_variables_type &active) override
 check out variational optimizable variables More...
 
void checkInVariablesExclusive (opt_variables_type &active) override
 check in variational parameters to the global list of parameters used by the optimizer. More...
 
void resetParametersExclusive (const opt_variables_type &active) override
 reset the parameters during optimizations. More...
 
void buildOptVariables ()
 
LogValue evaluate_vgl_impl (const ParticleSet &P, ParticleSet::ParticleGradient &g_tmp, ParticleSet::ParticleLaplacian &l_tmp)
 Compute VGL of this MultiSlaterDetTableMethod. More...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch More...
 
void calcIndividualDetRatios (Vector< ValueType > &ratios)
 Compute ratios of the individual Slater determinants and the total MSD value. More...
 
const std::vector< ValueType > & getLinearExpansionCoefs () const
 
void prepareGroup (ParticleSet &P, int ig) override
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const override
 
GradType evalGrad (ParticleSet &P, int iat) override
 return the current gradient for the iat-th particle More...
 
GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad) override
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &WFC_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, std::vector< GradType > &grad_now) const override
 compute the current gradients for the iat-th particle of multiple walkers More...
 
void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &WFC_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const override
 
void mw_calcRatio (const RefVectorWithLeader< WaveFunctionComponent > &WFC_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, std::vector< PsiValue > &ratios) const override
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient More...
 
PsiValue ratioGradWithSpin (ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad_iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios) override
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 a move for iat-th particle is accepted. More...
 
void restore (int iat) override
 If a move for iat-th particle is rejected, restore to the content. More...
 
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 override
 moves of the iat-th particle on some walkers in a batch is accepted. More...
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
 For particle-by-particle move. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 return a shared resource to a collection More...
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const override
 make clone More...
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi) override
 
void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
 
void initialize (std::unique_ptr< std::vector< std::vector< size_t >>> C2node_in, std::unique_ptr< std::vector< ValueType >> C_in, std::unique_ptr< opt_variables_type > myVars_in, std::unique_ptr< CSFData > csf_data_in, bool optimizable, bool CI_optimizable)
 initialize a few objects and states by the builder YL: it should be part of the constructor. More...
 
- Public Member Functions inherited from WaveFunctionComponent
const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
virtual void checkSanity () const
 Validate the internal consistency of the object. More...
 
const std::string & getName () const
 return object name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
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 More...
 
virtual void recompute (const ParticleSet &P)
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
virtual void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 
virtual void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi_all)
 
template<CoordsType CT>
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 More...
 
virtual GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat)
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
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. More...
 
template<CoordsType CT>
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 void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
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 p-by-p move region. More...
 
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 More...
 
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. More...
 
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 More...
 
virtual RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
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 optimizable parameters. More...
 
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. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void finalizeOptimization ()
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
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 More...
 
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 More...
 
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 More...
 
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 multiple walkers More...
 
- Public Member Functions inherited from OptimizableObject
 OptimizableObject (const std::string &name)
 
const std::string & getName () const
 
bool isOptimized () const
 
virtual void reportStatus (std::ostream &os)
 print the state, e.g., optimizables More...
 
void setOptimization (bool state)
 
virtual void writeVariationalParameters (hdf_archive &hout)
 Write the variational parameters for this object to the VP HDF file. More...
 
virtual void readVariationalParameters (hdf_archive &hin)
 Read the variational parameters for this object from the VP HDF file. More...
 

Public Attributes

NewTimerRatioTimer
 
NewTimeroffload_timer
 
NewTimerEvalGradTimer
 
NewTimerRatioGradTimer
 
NewTimerPrepareGroupTimer
 
NewTimerUpdateTimer
 
NewTimerAccRejTimer
 
NewTimerEvaluateTimer
 
- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 

Private Member Functions

int getDetID (const int iat) const
 
PsiValue evalGrad_impl (ParticleSet &P, int iat, bool newpos, GradType &g_at)
 an implementation shared by evalGrad and ratioGrad. More...
 
PsiValue evalGrad_impl_no_precompute (ParticleSet &P, int iat, bool newpos, GradType &g_at)
 an implementation shared by evalGrad and ratioGrad. More...
 
PsiValue evalGradWithSpin_impl (ParticleSet &P, int iat, bool newpos, GradType &g_at, ComplexType &sg_at)
 
PsiValue evalGradWithSpin_impl_no_precompute (ParticleSet &P, int iat, bool newpos, GradType &g_at, ComplexType &sg_at)
 
PsiValue computeRatio_NewMultiDet_to_NewRefDet (int det_id) const
 
void precomputeC_otherDs (const ParticleSet &P, int ig)
 precompute C_otherDs for a given particle group More...
 
void evaluateMultiDiracDeterminantDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
 
void evaluateMultiDiracDeterminantDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi)
 
void evaluateDerivativesMSD (Vector< ValueType > &dlogpsi, std::optional< std::pair< unsigned, PsiValue >> move=std::nullopt) const
 compute parameter derivatives of CI/CSF coefficients More...
 
RefVectorWithLeader< MultiDiracDeterminantextract_DetRef_list (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
 

Static Private Member Functions

static void mw_evalGrad_impl (const RefVectorWithLeader< WaveFunctionComponent > &WFC_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, bool newpos, std::vector< GradType > &grad_now, std::vector< PsiValue > &psi_list)
 multi walker version of evalGrad_impl More...
 

Private Attributes

std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
 determinant collection More...
 
std::shared_ptr< std::vector< std::vector< size_t > > > C2node
 map determinant in linear combination to unique det list map global det id to unique det id. More...
 
std::shared_ptr< std::vector< ValueType > > C
 CI coefficients. More...
 
bool CI_Optimizable
 if true, the CI coefficients are optimized More...
 
std::shared_ptr< opt_variables_typemyVars
 
std::shared_ptr< CSFDatacsf_data_
 CSF data set. If nullptr, not using CSF. More...
 
std::vector< int > Last
 the last particle of each group More...
 
const bool use_pre_computing_
 use pre-compute (fast) algorithm More...
 
PsiValue psi_ratio_to_ref_det_
 current psi over ref single det More...
 
PsiValue new_psi_ratio_to_new_ref_det_
 new psi over new ref single det when one particle is moved More...
 
size_t ActiveSpin
 
PsiValue curRatio
 
std::vector< OffloadVector< ValueType > > C_otherDs
 C_n x D^1_n x D^2_n ... D^3_n with one D removed. Summed by group. [spin, unique det id]. More...
 
ParticleSet::ParticleGradient myG
 
ParticleSet::ParticleGradient myG_temp
 
ParticleSet::ParticleLaplacian myL
 
ParticleSet::ParticleLaplacian myL_temp
 
std::vector< ValueVectorlaplSum
 
ParticleSet::ParticleGradient gmPG
 
std::vector< Matrix< RealType > > dpsia
 
std::vector< Matrix< RealType > > dLa
 
std::vector< Array< GradType, OHMMS_DIM > > dGa
 
ResourceHandle< MultiSlaterDetTableMethodMultiWalkerResourcemw_res_handle_
 

Additional Inherited Members

- Protected Attributes inherited from WaveFunctionComponent
const std::string my_name_
 Name of the object It is required to be different for objects of the same derived type like multiple J1. More...
 
LogValue log_value_
 Current $\log\phi $. More...
 

Member Typedef Documentation

◆ GGGMatrix

Definition at line 86 of file MultiSlaterDetTableMethod.h.

◆ GGGType

Definition at line 84 of file MultiSlaterDetTableMethod.h.

◆ GGGVector

Definition at line 85 of file MultiSlaterDetTableMethod.h.

◆ GradVector

◆ HessArray

using HessArray = Array<HessType, 3>

Definition at line 83 of file MultiSlaterDetTableMethod.h.

◆ HessMatrix

◆ HessType

◆ IndexVector

◆ OffloadVector

Definition at line 74 of file MultiSlaterDetTableMethod.h.

◆ SPOSetPtr

using SPOSetPtr = SPOSet*

Definition at line 76 of file MultiSlaterDetTableMethod.h.

◆ ValueMatrix

◆ ValueVector

◆ Walker_t

Definition at line 87 of file MultiSlaterDetTableMethod.h.

Constructor & Destructor Documentation

◆ MultiSlaterDetTableMethod()

MultiSlaterDetTableMethod ( ParticleSet targetPtcl,
std::vector< std::unique_ptr< MultiDiracDeterminant >> &&  dets,
bool  use_pre_computing 
)

constructor

Definition at line 42 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C_otherDs, MultiSlaterDetTableMethod::Dets, ParticleSet::getTotalNum(), ParticleSet::groups(), MultiSlaterDetTableMethod::Last, ParticleSet::last(), MultiSlaterDetTableMethod::myG, MultiSlaterDetTableMethod::myG_temp, MultiSlaterDetTableMethod::myL, MultiSlaterDetTableMethod::myL_temp, and Vector< T, Alloc >::resize().

45  : OptimizableObject("CI"),
48  EvalGradTimer(createGlobalTimer(getClassName() + "::evalGrad")),
49  RatioGradTimer(createGlobalTimer(getClassName() + "::ratioGrad")),
50  PrepareGroupTimer(createGlobalTimer(getClassName() + "::prepareGroup")),
51  UpdateTimer(createGlobalTimer(getClassName() + "::updateBuffer")),
52  AccRejTimer(createGlobalTimer(getClassName() + "::Accept_Reject")),
53  EvaluateTimer(createGlobalTimer(getClassName() + "::evaluate")),
54  CI_Optimizable(false),
55  use_pre_computing_(use_pre_computing)
56 {
57  Dets = std::move(dets);
58  C_otherDs.resize(Dets.size());
59  int NP = targetPtcl.getTotalNum();
60  myG.resize(NP);
61  myL.resize(NP);
62  myG_temp.resize(NP);
63  myL_temp.resize(NP);
64 
65  Last.resize(targetPtcl.groups());
66  for (int i = 0; i < Last.size(); ++i)
67  Last[i] = targetPtcl.last(i) - 1;
68 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
bool CI_Optimizable
if true, the CI coefficients are optimized
std::vector< OffloadVector< ValueType > > C_otherDs
C_n x D^1_n x D^2_n ... D^3_n with one D removed. Summed by group. [spin, unique det id]...
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
std::vector< int > Last
the last particle of each group
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
OptimizableObject(const std::string &name)
const bool use_pre_computing_
use pre-compute (fast) algorithm
std::string getClassName() const override
return class name

◆ ~MultiSlaterDetTableMethod()

~MultiSlaterDetTableMethod ( )
overridedefault

destructor

Member Function Documentation

◆ acceptMove()

void acceptMove ( ParticleSet P,
int  iat,
bool  safe_to_delay = false 
)
overridevirtual

a move for iat-th particle is accepted.

Update the current content.

Parameters
Ptarget ParticleSet
iatindex of the particle whose new position was proposed
safe_to_delayif true, delayed accept is safe.

Implements WaveFunctionComponent.

Definition at line 651 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::AccRejTimer, qmcplusplus::convertValueToLog(), MultiSlaterDetTableMethod::curRatio, MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::getDetID(), WaveFunctionComponent::log_value_, MultiSlaterDetTableMethod::new_psi_ratio_to_new_ref_det_, and MultiSlaterDetTableMethod::psi_ratio_to_ref_det_.

652 {
653  // this should depend on the type of update, ratio / ratioGrad
654  // for now is incorrect fot ratio(P,iat,dG,dL) updates
655  ScopedTimer local_timer(AccRejTimer);
656  // update psi_ratio_to_ref_det_,myG_temp,myL_temp
659  curRatio = 1.0;
660 
661  Dets[getDetID(iat)]->acceptMove(P, iat, safe_to_delay);
662 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
PsiValue new_psi_ratio_to_new_ref_det_
new psi over new ref single det when one particle is moved

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
overridevirtual

acquire a shared resource from a collection

Reimplemented from WaveFunctionComponent.

Definition at line 1229 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::extract_DetRef_list(), RefVectorWithLeader< T >::getCastedLeader(), ResourceCollection::lendResource(), and MultiSlaterDetTableMethod::mw_res_handle_.

1231 {
1232  auto& wfc_leader = wfc_list.getCastedLeader<MultiSlaterDetTableMethod>();
1233  wfc_leader.mw_res_handle_ = collection.lendResource<MultiSlaterDetTableMethodMultiWalkerResource>();
1234  for (int idet = 0; idet < Dets.size(); idet++)
1235  {
1236  const auto det_list(extract_DetRef_list(wfc_list, idet));
1237  Dets[idet]->acquireResource(collection, det_list);
1238  }
1239 }
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
RefVectorWithLeader< MultiDiracDeterminant > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ buildOptVariables()

void buildOptVariables ( )

Definition at line 1155 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C2node, and MultiSlaterDetTableMethod::Dets.

1156 {
1157  for (size_t id = 0; id < Dets.size(); id++)
1158  Dets[id]->buildOptVariables((*C2node)[id]);
1159 }
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
std::shared_ptr< std::vector< std::vector< size_t > > > C2node
map determinant in linear combination to unique det list map global det id to unique det id...

◆ calcIndividualDetRatios()

void calcIndividualDetRatios ( Vector< ValueType > &  ratios)

Compute ratios of the individual Slater determinants and the total MSD value.

\[ *ratio_n = Det_n / \frac{\sum_n c_n Det_n} *\]

.

Definition at line 1005 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::csf_data_, MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::psi_ratio_to_ref_det_, and Vector< T, Alloc >::resize().

Referenced by SelfHealingOverlap::accumulate(), and SelfHealingOverlapLegacy::evaluate().

1006 {
1007  ValueType psiinv = static_cast<ValueType>(PsiValue(1.0) / psi_ratio_to_ref_det_);
1008 
1009  // CI only for now
1010  assert(!csf_data_);
1011  ratios.resize(C->size());
1012  for (size_t i = 0; i < C->size(); i++)
1013  {
1014  ValueType cdet = psiinv;
1015  // assume that evaluateLog has been called in opt routine before
1016  for (size_t id = 0; id < Dets.size(); id++)
1017  cdet *= Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
1018  ratios[i] = cdet;
1019  }
1020 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue psi_ratio_to_ref_det_
current psi over ref single det

◆ checkInVariablesExclusive()

void checkInVariablesExclusive ( opt_variables_type active)
overridevirtual

check in variational parameters to the global list of parameters used by the optimizer.

Parameters
activea super set of optimizable variables

The existing checkInVariables implementation in WFC/SPO/.. are inclusive and it calls checkInVariables of its members class A: public SPOSet {} class B: public WFC { A objA; checkInVariables() { objA.checkInVariables(); } };

With OptimizableObject, class A: public OptimizableObject {} class B: public OptimizableObject { A objA; checkInVariablesExclusive() { // should not call objA.checkInVariablesExclusive() if objA has been extracted; } }; A vector of OptimizableObject, will be created by calling extractOptimizableObjects(). All the checkInVariablesExclusive() will be called through this vector and thus checkInVariablesExclusive implementation should only handle non-OptimizableObject members.

Implements OptimizableObject.

Definition at line 739 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::CI_Optimizable, VariableSet::insertFrom(), and MultiSlaterDetTableMethod::myVars.

740 {
741  if (CI_Optimizable && myVars->size())
742  {
743  myVars->setIndexDefault();
744  active.insertFrom(*myVars);
745  }
746 }
bool CI_Optimizable
if true, the CI coefficients are optimized
std::shared_ptr< opt_variables_type > myVars

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
overridevirtual

check out variational optimizable variables

Parameters
activea super set of optimizable variables

Reimplemented from WaveFunctionComponent.

Definition at line 748 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::CI_Optimizable, MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::isOptimizable(), and MultiSlaterDetTableMethod::myVars.

749 {
750  if (CI_Optimizable)
751  myVars->getIndex(active);
752 
753  for (size_t id = 0; id < Dets.size(); id++)
754  if (Dets[id]->isOptimizable())
755  Dets[id]->checkOutVariables(active);
756 }
bool CI_Optimizable
if true, the CI coefficients are optimized
std::shared_ptr< opt_variables_type > myVars
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
bool isOptimizable() const override
if true, this contains optimizable components
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables

◆ computeRatio_NewMultiDet_to_NewRefDet()

WaveFunctionComponent::PsiValue computeRatio_NewMultiDet_to_NewRefDet ( int  det_id) const
private

Definition at line 515 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::C_otherDs, MultiSlaterDetTableMethod::Dets, and MultiSlaterDetTableMethod::use_pre_computing_.

Referenced by MultiSlaterDetTableMethod::evaluateDerivRatios(), MultiSlaterDetTableMethod::evaluateRatios(), and MultiSlaterDetTableMethod::ratio().

516 {
517  const auto& detValues0 = Dets[det_id]->getNewRatiosToRefDet();
518 
519  PsiValue psi = 0;
520  if (use_pre_computing_)
521  {
522  // This function computes
523  // psi=Det_Coeff[i]*Det_Value[unique_det_up]*Det_Value[unique_det_dn]*Det_Value[unique_det_AnyOtherType]
524  // Since only one electron group is moved at the time, identified by det_id, We precompute:
525  // C_otherDs[det_id][i]=Det_Coeff[i]*Det_Value[unique_det_dn]*Det_Value[unique_det_AnyOtherType]
526  for (size_t i = 0; i < Dets[det_id]->getNumDets(); i++)
527  psi += detValues0[i] * C_otherDs[det_id][i];
528  }
529  else
530  {
531  const size_t* restrict det0 = (*C2node)[det_id].data();
532  const ValueType* restrict cptr = C->data();
533  const size_t nc = C->size();
534 
535  for (size_t i = 0; i < nc; ++i)
536  {
537  ValueType t = cptr[i];
538  for (size_t id = 0; id < Dets.size(); id++)
539  if (id != det_id)
540  t *= Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
541  t *= detValues0[det0[i]];
542  psi += t;
543  }
544  }
545  return psi;
546 }
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< OffloadVector< ValueType > > C_otherDs
C_n x D^1_n x D^2_n ... D^3_n with one D removed. Summed by group. [spin, unique det id]...
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
const bool use_pre_computing_
use pre-compute (fast) algorithm

◆ copyFromBuffer()

void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)
overridevirtual

For particle-by-particle move.

Copy data or attach memory from a walker buffer to the objects of this class. The log value, P.G and P.L contribution from the objects of this class are also added.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 723 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::Dets, PooledMemory< T_scalar, Alloc >::get(), WaveFunctionComponent::log_value_, and MultiSlaterDetTableMethod::psi_ratio_to_ref_det_.

724 {
725  for (size_t id = 0; id < Dets.size(); id++)
726  Dets[id]->copyFromBuffer(P, buf);
727 
728  buf.get(log_value_);
729  buf.get(psi_ratio_to_ref_det_);
730 }
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 1222 of file MultiSlaterDetTableMethod.cpp.

References ResourceCollection::addResource(), qmcplusplus::det(), and MultiSlaterDetTableMethod::Dets.

1223 {
1224  collection.addResource(std::make_unique<MultiSlaterDetTableMethodMultiWalkerResource>());
1225  for (auto& det : Dets)
1226  det->createResource(collection);
1227 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ evalGrad()

WaveFunctionComponent::GradType evalGrad ( ParticleSet P,
int  iat 
)
overridevirtual

return the current gradient for the iat-th particle

Parameters
Pquantum particle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented from WaveFunctionComponent.

Definition at line 385 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::evalGrad_impl(), MultiSlaterDetTableMethod::evalGrad_impl_no_precompute(), MultiSlaterDetTableMethod::EvalGradTimer, and MultiSlaterDetTableMethod::use_pre_computing_.

386 {
387  ScopedTimer local_timer(EvalGradTimer);
388 
389  GradType grad_iat;
390  if (use_pre_computing_)
391  evalGrad_impl(P, iat, false, grad_iat);
392  else
393  evalGrad_impl_no_precompute(P, iat, false, grad_iat);
394 
395  return grad_iat;
396 }
QTBase::GradType GradType
Definition: Configuration.h:62
PsiValue evalGrad_impl_no_precompute(ParticleSet &P, int iat, bool newpos, GradType &g_at)
an implementation shared by evalGrad and ratioGrad.
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const bool use_pre_computing_
use pre-compute (fast) algorithm
PsiValue evalGrad_impl(ParticleSet &P, int iat, bool newpos, GradType &g_at)
an implementation shared by evalGrad and ratioGrad.

◆ evalGrad_impl()

WaveFunctionComponent::PsiValue evalGrad_impl ( ParticleSet P,
int  iat,
bool  newpos,
GradType g_at 
)
private

an implementation shared by evalGrad and ratioGrad.

Use precomputed data

Parameters
newposto distinguish evalGrad(false) ratioGrad(true)

Definition at line 174 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C_otherDs, MultiSlaterDetTableMethod::Dets, and MultiSlaterDetTableMethod::getDetID().

Referenced by MultiSlaterDetTableMethod::evalGrad(), and MultiSlaterDetTableMethod::ratioGrad().

178 {
179  const int det_id = getDetID(iat);
180 
181  if (newpos)
182  Dets[det_id]->evaluateDetsAndGradsForPtclMove(P, iat);
183  else
184  Dets[det_id]->evaluateGrads(P, iat);
185 
186  const auto& grads = (newpos) ? Dets[det_id]->getNewGrads() : Dets[det_id]->getGrads();
187  const OffloadVector<ValueType>& detValues0 =
188  (newpos) ? Dets[det_id]->getNewRatiosToRefDet() : Dets[det_id]->getRatiosToRefDet();
189  const size_t noffset = Dets[det_id]->getFirstIndex();
190 
191  PsiValue psi(0);
192  // enforce full precision reduction due to numerical sensitivity
193  QTFull::GradType g_sum;
194  for (size_t i = 0; i < Dets[det_id]->getNumDets(); i++)
195  {
196  psi += detValues0[i] * C_otherDs[det_id][i];
197  g_sum += C_otherDs[det_id][i] * grads(i, iat - noffset);
198  }
199 
200  g_at = g_sum / psi;
201  return psi;
202 }
std::vector< OffloadVector< ValueType > > C_otherDs
C_n x D^1_n x D^2_n ... D^3_n with one D removed. Summed by group. [spin, unique det id]...
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
TinyVector< ValueType, DIM > GradType
Definition: QMCTypes.h:44

◆ evalGrad_impl_no_precompute()

WaveFunctionComponent::PsiValue evalGrad_impl_no_precompute ( ParticleSet P,
int  iat,
bool  newpos,
GradType g_at 
)
private

an implementation shared by evalGrad and ratioGrad.

No use of precomputed data

Parameters
newposto distinguish evalGrad(false) ratioGrad(true)

Definition at line 315 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::Dets, and MultiSlaterDetTableMethod::getDetID().

Referenced by MultiSlaterDetTableMethod::evalGrad(), and MultiSlaterDetTableMethod::ratioGrad().

319 {
320  const int det_id = getDetID(iat);
321 
322  if (newpos)
323  Dets[det_id]->evaluateDetsAndGradsForPtclMove(P, iat);
324  else
325  Dets[det_id]->evaluateGrads(P, iat);
326 
327  const auto& grads = (newpos) ? Dets[det_id]->getNewGrads() : Dets[det_id]->getGrads();
328  const auto& detValues0 = (newpos) ? Dets[det_id]->getNewRatiosToRefDet() : Dets[det_id]->getRatiosToRefDet();
329  const size_t* restrict det0 = (*C2node)[det_id].data();
330  const ValueType* restrict cptr = C->data();
331  const size_t nc = C->size();
332  const size_t noffset = Dets[det_id]->getFirstIndex();
333  PsiValue psi(0);
334  for (size_t i = 0; i < nc; ++i)
335  {
336  const size_t d0 = det0[i];
337  ValueType t = cptr[i];
338  for (size_t id = 0; id < Dets.size(); id++)
339  if (id != det_id)
340  t *= Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
341  psi += t * detValues0[d0];
342  g_at += t * grads(d0, iat - noffset);
343  }
344  g_at *= PsiValue(1.0) / psi;
345  return psi;
346 }
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ evalGradWithSpin()

WaveFunctionComponent::GradType evalGradWithSpin ( ParticleSet P,
int  iat,
ComplexType spingrad 
)
overridevirtual

return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin.

Parameters
Pquantum particle set
iatparticle index
Returns
the spin gradient of the iat-th particle

Reimplemented from WaveFunctionComponent.

Definition at line 398 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::EvalGradTimer, MultiSlaterDetTableMethod::evalGradWithSpin_impl(), MultiSlaterDetTableMethod::evalGradWithSpin_impl_no_precompute(), and MultiSlaterDetTableMethod::use_pre_computing_.

401 {
402  ScopedTimer local_timer(EvalGradTimer);
403 
404  GradType grad_iat;
405  ComplexType spingrad_iat;
406  if (use_pre_computing_)
407  evalGradWithSpin_impl(P, iat, false, grad_iat, spingrad_iat);
408  else
409  evalGradWithSpin_impl_no_precompute(P, iat, false, grad_iat, spingrad_iat);
410 
411  spingrad += spingrad_iat;
412 
413  return grad_iat;
414 }
QTBase::GradType GradType
Definition: Configuration.h:62
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
PsiValue evalGradWithSpin_impl_no_precompute(ParticleSet &P, int iat, bool newpos, GradType &g_at, ComplexType &sg_at)
PsiValue evalGradWithSpin_impl(ParticleSet &P, int iat, bool newpos, GradType &g_at, ComplexType &sg_at)
const bool use_pre_computing_
use pre-compute (fast) algorithm

◆ evalGradWithSpin_impl()

WaveFunctionComponent::PsiValue evalGradWithSpin_impl ( ParticleSet P,
int  iat,
bool  newpos,
GradType g_at,
ComplexType sg_at 
)
private

Definition at line 204 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C_otherDs, MultiSlaterDetTableMethod::Dets, and MultiSlaterDetTableMethod::getDetID().

Referenced by MultiSlaterDetTableMethod::evalGradWithSpin(), and MultiSlaterDetTableMethod::ratioGradWithSpin().

209 {
210  const int det_id = getDetID(iat);
211 
212  if (newpos)
213  Dets[det_id]->evaluateDetsAndGradsForPtclMoveWithSpin(P, iat);
214  else
215  Dets[det_id]->evaluateGradsWithSpin(P, iat);
216 
217  const auto& grads = (newpos) ? Dets[det_id]->getNewGrads() : Dets[det_id]->getGrads();
218  const OffloadVector<ValueType>& detValues0 =
219  (newpos) ? Dets[det_id]->getNewRatiosToRefDet() : Dets[det_id]->getRatiosToRefDet();
220  const Matrix<ValueType>& spingrads = (newpos) ? Dets[det_id]->getNewSpinGrads() : Dets[det_id]->getSpinGrads();
221  const size_t noffset = Dets[det_id]->getFirstIndex();
222 
223  PsiValue psi(0);
224  for (size_t i = 0; i < Dets[det_id]->getNumDets(); i++)
225  {
226  psi += detValues0[i] * C_otherDs[det_id][i];
227  g_at += C_otherDs[det_id][i] * grads(i, iat - noffset);
228  sg_at += C_otherDs[det_id][i] * spingrads(i, iat - noffset);
229  }
230  g_at *= PsiValue(1.0) / psi;
231  sg_at *= PsiValue(1.0) / psi;
232  return psi;
233 }
std::vector< OffloadVector< ValueType > > C_otherDs
C_n x D^1_n x D^2_n ... D^3_n with one D removed. Summed by group. [spin, unique det id]...
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ evalGradWithSpin_impl_no_precompute()

WaveFunctionComponent::PsiValue evalGradWithSpin_impl_no_precompute ( ParticleSet P,
int  iat,
bool  newpos,
GradType g_at,
ComplexType sg_at 
)
private

Definition at line 348 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::Dets, and MultiSlaterDetTableMethod::getDetID().

Referenced by MultiSlaterDetTableMethod::evalGradWithSpin(), and MultiSlaterDetTableMethod::ratioGradWithSpin().

353 {
354  const int det_id = getDetID(iat);
355 
356  if (newpos)
357  Dets[det_id]->evaluateDetsAndGradsForPtclMoveWithSpin(P, iat);
358  else
359  Dets[det_id]->evaluateGradsWithSpin(P, iat);
360 
361  const auto& grads = (newpos) ? Dets[det_id]->getNewGrads() : Dets[det_id]->getGrads();
362  const auto& detValues0 = (newpos) ? Dets[det_id]->getNewRatiosToRefDet() : Dets[det_id]->getRatiosToRefDet();
363  const auto& spingrads = (newpos) ? Dets[det_id]->getNewSpinGrads() : Dets[det_id]->getSpinGrads();
364  const size_t* restrict det0 = (*C2node)[det_id].data();
365  const ValueType* restrict cptr = C->data();
366  const size_t nc = C->size();
367  const size_t noffset = Dets[det_id]->getFirstIndex();
368  PsiValue psi(0);
369  for (size_t i = 0; i < nc; ++i)
370  {
371  const size_t d0 = det0[i];
372  ValueType t = cptr[i];
373  for (size_t id = 0; id < Dets.size(); id++)
374  if (id != det_id)
375  t *= Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
376  psi += t * detValues0[d0];
377  g_at += t * grads(d0, iat - noffset);
378  sg_at += t * spingrads(d0, iat - noffset);
379  }
380  g_at *= PsiValue(1.0) / psi;
381  sg_at *= PsiValue(1.0) / psi;
382  return psi;
383 }
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ evaluate_vgl_impl()

Compute VGL of this MultiSlaterDetTableMethod.

THis is introduced to remove redundant code in

  • evaluate(P,G,L)
  • evaluateLog(P,G,L,buf,fillbuffer) Miguel's note: can this change over time??? I don't know yet

Definition at line 111 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C_otherDs, qmcplusplus::convertValueToLog(), BLAS::czero, MultiSlaterDetTableMethod::Dets, qmcplusplus::n, MultiSlaterDetTableMethod::precomputeC_otherDs(), and MultiSlaterDetTableMethod::psi_ratio_to_ref_det_.

Referenced by MultiSlaterDetTableMethod::evaluateLog(), and MultiSlaterDetTableMethod::updateBuffer().

114 {
115  const ValueType czero(0);
117  g_tmp = czero;
118  l_tmp = czero;
119 
120  for (size_t ig = 0; ig < Dets.size(); ig++)
121  precomputeC_otherDs(P, ig);
122 
123  for (size_t i = 0; i < Dets[0]->getNumDets(); ++i)
124  psi_ratio_to_ref_det_ += C_otherDs[0][i] * Dets[0]->getRatiosToRefDet()[i];
125 
126  for (size_t id = 0; id < Dets.size(); id++)
127  for (size_t i = 0; i < Dets[id]->getNumDets(); ++i)
128  for (int k = 0, n = Dets[id]->getFirstIndex(); k < Dets[id]->getNumPtcls(); k++, n++)
129  {
130  g_tmp[n] += C_otherDs[id][i] * Dets[id]->getGrads()(i, k);
131  l_tmp[n] += C_otherDs[id][i] * Dets[id]->getLapls()(i, k);
132  }
133 
134  ValueType psiinv = static_cast<ValueType>(PsiValue(1.0) / psi_ratio_to_ref_det_);
135  g_tmp *= psiinv;
136  l_tmp *= psiinv;
138  for (size_t id = 0; id < Dets.size(); id++)
139  log_psi += Dets[id]->getLogValueRefDet();
140  return log_psi;
141 }
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
void precomputeC_otherDs(const ParticleSet &P, int ig)
precompute C_otherDs for a given particle group
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
std::complex< QTFull::RealType > LogValue
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< OffloadVector< ValueType > > C_otherDs
C_n x D^1_n x D^2_n ... D^3_n with one D removed. Summed by group. [spin, unique det id]...
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue psi_ratio_to_ref_det_
current psi over ref single det

◆ evaluateDerivatives()

void evaluateDerivatives ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
override

Definition at line 802 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::C_otherDs, MultiSlaterDetTableMethod::CI_Optimizable, MultiSlaterDetTableMethod::csf_data_, MultiSlaterDetTableMethod::Dets, qmcplusplus::dot(), MultiSlaterDetTableMethod::evaluateDerivativesWF(), MultiSlaterDetTableMethod::evaluateMultiDiracDeterminantDerivatives(), ParticleSet::G, ParticleSet::getTotalNum(), MultiSlaterDetTableMethod::laplSum, MultiSlaterDetTableMethod::myG_temp, MultiSlaterDetTableMethod::myVars, MultiSlaterDetTableMethod::psi_ratio_to_ref_det_, and VariableSet::recompute().

806 {
807  evaluateDerivativesWF(P, optvars, dlogpsi);
808  if (CI_Optimizable)
809  {
810  bool recalculate(false);
811  for (int k = 0; k < myVars->size(); ++k)
812  {
813  int kk = myVars->where(k);
814  if (kk < 0)
815  continue;
816  if (optvars.recompute(kk))
817  recalculate = true;
818  }
819  // need to modify for CSF later on, right now assume Slater Det basis
820  if (recalculate)
821  {
822  ValueType psiinv = static_cast<ValueType>(PsiValue(1.0) / psi_ratio_to_ref_det_);
823  laplSum.resize(Dets.size());
824  for (size_t id = 0; id < Dets.size(); id++)
825  {
826  laplSum[id].resize(Dets[id]->getNumDets());
827  // assume that evaluateLog has been called in opt routine before
828  // Dets[id]->evaluateForWalkerMove(P);
829  // myG,myL should already be calculated
830  for (size_t i = 0; i < laplSum[id].size(); i++)
831  {
832  laplSum[id][i] = 0.0;
833  for (size_t k = 0; k < Dets[id]->getNumPtcls(); k++)
834  laplSum[id][i] += Dets[id]->getLapls()[i][k];
835  }
836  }
837 
838  ValueType lapl_sum = 0.0;
839  myG_temp = 0.0;
840  for (size_t id = 0; id < Dets.size(); id++)
841  for (size_t i = 0; i < Dets[id]->getNumDets(); i++)
842  {
843  // assume C_otherDs prepared by evaluateLog already
844  ValueType tmp = C_otherDs[id][i] * psiinv;
845  lapl_sum += tmp * laplSum[id][i];
846  for (size_t k = 0, j = Dets[id]->getFirstIndex(); k < Dets[id]->getNumPtcls(); k++, j++)
847  myG_temp[j] += tmp * Dets[id]->getGrads()(i, k);
848  }
849 
850  ValueType gg = 0.0;
851  for (size_t i = 0; i < P.getTotalNum(); i++)
852  gg += dot(myG_temp[i], myG_temp[i]) - dot(P.G[i], myG_temp[i]);
853 
854  if (csf_data_)
855  {
856  const int num = csf_data_->coeffs.size() - 1;
857  int cnt = 0;
858  // this one is not optable
859  cnt += csf_data_->dets_per_csf[0];
860  int ip(1);
861  for (int i = 0; i < num; i++, ip++)
862  {
863  int kk = myVars->where(i);
864  if (kk < 0)
865  {
866  cnt += csf_data_->dets_per_csf[ip];
867  continue;
868  }
869  ValueType q0 = 0.0;
870  std::vector<ValueType> v(Dets.size());
871  const RealType* restrict CSFexpansion_p = csf_data_->expansion.data();
872  for (int k = 0; k < csf_data_->dets_per_csf[ip]; k++)
873  {
874  for (size_t id = 0; id < Dets.size(); id++)
875  {
876  const auto& grads_spin = Dets[id]->getGrads();
877  size_t spinC = (*C2node)[id][cnt];
878  ValueType tmp = CSFexpansion_p[cnt] * psiinv;
879  for (size_t other_id = 0; other_id < Dets.size(); other_id++)
880  {
881  if (id == other_id)
882  continue;
883  const OffloadVector<ValueType>& detValues_otherspin = Dets[other_id]->getRatiosToRefDet();
884  size_t otherspinC = (*C2node)[other_id][cnt];
885  tmp *= detValues_otherspin[otherspinC];
886  }
887  q0 += tmp * laplSum[id][spinC];
888  for (size_t l = 0, j = Dets[id]->getFirstIndex(); l < Dets[id]->getNumPtcls(); l++, j++)
889  v[id] += tmp *
890  static_cast<ValueType>(dot(P.G[j], grads_spin(spinC, l)) - dot(myG_temp[j], grads_spin(spinC, l)));
891  }
892  cnt++;
893  }
894  ValueType dhpsi = (RealType)-0.5 * (q0 - dlogpsi[kk] * lapl_sum) - dlogpsi[kk] * gg;
895  for (size_t id = 0; id < Dets.size(); id++)
896  dhpsi -= v[id];
897  dhpsioverpsi[kk] = dhpsi;
898  }
899  }
900  else
901  { //usingDETS
902  for (size_t i = 1; i < C->size(); i++)
903  {
904  int kk = myVars->where(i - 1);
905  if (kk < 0)
906  continue;
907 
908  ValueType q0 = 0.0;
909  std::vector<ValueType> v(Dets.size());
910  for (size_t id = 0; id < Dets.size(); id++)
911  {
912  const auto& grads_spin = Dets[id]->getGrads();
913  size_t spinC = (*C2node)[id][i];
914  ValueType tmp = psiinv;
915  for (size_t other_id = 0; other_id < Dets.size(); other_id++)
916  {
917  if (id == other_id)
918  continue;
919  size_t otherspinC = (*C2node)[other_id][i];
920  tmp *= Dets[other_id]->getRatiosToRefDet()[otherspinC];
921  }
922  q0 += tmp * laplSum[id][spinC];
923  for (size_t l = 0, j = Dets[id]->getFirstIndex(); l < Dets[id]->getNumPtcls(); l++, j++)
924  v[id] += tmp *
925  static_cast<ValueType>(dot(P.G[j], grads_spin(spinC, l)) - dot(myG_temp[j], grads_spin(spinC, l)));
926  }
927  ValueType dhpsi = (RealType)-0.5 * (q0 - dlogpsi[kk] * lapl_sum) - dlogpsi[kk] * gg;
928  for (size_t id = 0; id < Dets.size(); id++)
929  dhpsi -= v[id];
930  dhpsioverpsi[kk] = dhpsi;
931  }
932  }
933  }
934  }
935 
936  evaluateMultiDiracDeterminantDerivatives(P, optvars, dlogpsi, dhpsioverpsi);
937 }
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
bool CI_Optimizable
if true, the CI coefficients are optimized
void evaluateMultiDiracDeterminantDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
QTBase::RealType RealType
Definition: Configuration.h:58
std::shared_ptr< opt_variables_type > myVars
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< OffloadVector< ValueType > > C_otherDs
C_n x D^1_n x D^2_n ... D^3_n with one D removed. Summed by group. [spin, unique det id]...
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
QMCTraits::RealType RealType
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi) override
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)

◆ evaluateDerivativesMSD()

void evaluateDerivativesMSD ( Vector< ValueType > &  dlogpsi,
std::optional< std::pair< unsigned, PsiValue >>  move = std::nullopt 
) const
private

compute parameter derivatives of CI/CSF coefficients

Parameters
dlogpsisaved derivatives
movewhen one electron virtual move was proposed, pass the determinant group of the moved electron and the ratio of multideterminant and the reference single determinant

Definition at line 1030 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::csf_data_, MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::psi_ratio_to_ref_det_, and Vector< T, Alloc >::resize().

Referenced by MultiSlaterDetTableMethod::evaluateDerivativesWF(), and MultiSlaterDetTableMethod::evaluateDerivRatios().

1031 {
1032  // when not using a new position, the result doesn't get affected by det_id, thus choose 0.
1033  const unsigned det_id = move? move->first : 0;
1034  const auto& detValues0 = move? Dets[det_id]->getNewRatiosToRefDet() : Dets[det_id]->getRatiosToRefDet();
1035  const ValueType psiinv = static_cast<ValueType>(PsiValue(1.0) / (move? move->second : psi_ratio_to_ref_det_));
1036 
1037  if (csf_data_) // CSF
1038  {
1039  dlogpsi.resize(csf_data_->coeffs.size() - 1);
1040  // this one is not optimizable
1041  int cnt = csf_data_->dets_per_csf[0];
1042  for (int i = 1; i < csf_data_->coeffs.size(); i++)
1043  {
1044  ValueType cdet = 0.0;
1045  for (int k = 0; k < csf_data_->dets_per_csf[i]; k++)
1046  {
1047  ValueType t = csf_data_->expansion[cnt] * psiinv * detValues0[(*C2node)[det_id][cnt]];
1048  // assume that evaluateLog has been called in opt routine before
1049  for (size_t id = 0; id < Dets.size(); id++)
1050  if (id != det_id)
1051  t *= Dets[id]->getRatiosToRefDet()[(*C2node)[id][cnt]];
1052  cdet += t;
1053  cnt++;
1054  }
1055  dlogpsi[i - 1] = cdet;
1056  }
1057  }
1058  else // CI
1059  {
1060  dlogpsi.resize(C->size() - 1);
1061  for (size_t i = 1; i < C->size(); i++)
1062  {
1063  ValueType cdet = psiinv * detValues0[(*C2node)[det_id][i]];
1064  // assume that evaluateLog has been called in opt routine before
1065  for (size_t id = 0; id < Dets.size(); id++)
1066  if (id != det_id)
1067  cdet *= Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
1068  dlogpsi[i - 1] = cdet;
1069  }
1070  }
1071 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue psi_ratio_to_ref_det_
current psi over ref single det

◆ evaluateDerivativesWF()

void evaluateDerivativesWF ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi 
)
override

Definition at line 969 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::CI_Optimizable, MultiSlaterDetTableMethod::csf_data_, MultiSlaterDetTableMethod::evaluateDerivativesMSD(), MultiSlaterDetTableMethod::evaluateMultiDiracDeterminantDerivativesWF(), MultiSlaterDetTableMethod::myVars, VariableSet::recompute(), and Vector< T, Alloc >::size().

Referenced by MultiSlaterDetTableMethod::evaluateDerivatives().

972 {
973  if (CI_Optimizable)
974  {
975  bool recalculate(false);
976  for (int k = 0; k < myVars->size(); ++k)
977  {
978  int kk = myVars->where(k);
979  if (kk < 0)
980  continue;
981  if (optvars.recompute(kk))
982  recalculate = true;
983  }
984 
985  if (recalculate)
986  {
987  Vector<ValueType> dlogpsi_local;
988  evaluateDerivativesMSD(dlogpsi_local);
989 
990  const size_t nparams = csf_data_ ? csf_data_->coeffs.size() - 1 : C->size() - 1;
991  assert(dlogpsi_local.size() == nparams);
992  for (int i = 0; i < nparams; i++)
993  {
994  int kk = myVars->where(i);
995  if (kk < 0)
996  continue;
997  dlogpsi[kk] = dlogpsi_local[i];
998  }
999  }
1000  }
1001 
1002  evaluateMultiDiracDeterminantDerivativesWF(P, optvars, dlogpsi);
1003 }
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
bool CI_Optimizable
if true, the CI coefficients are optimized
std::shared_ptr< opt_variables_type > myVars
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
void evaluateDerivativesMSD(Vector< ValueType > &dlogpsi, std::optional< std::pair< unsigned, PsiValue >> move=std::nullopt) const
compute parameter derivatives of CI/CSF coefficients
void evaluateMultiDiracDeterminantDerivativesWF(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi)

◆ evaluateDerivRatios()

void evaluateDerivRatios ( const VirtualParticleSet VP,
const opt_variables_type optvars,
std::vector< ValueType > &  ratios,
Matrix< ValueType > &  dratios 
)
override

Definition at line 1073 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::CI_Optimizable, MultiSlaterDetTableMethod::computeRatio_NewMultiDet_to_NewRefDet(), MultiSlaterDetTableMethod::csf_data_, MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::evaluateDerivativesMSD(), MultiSlaterDetTableMethod::getDetID(), VirtualParticleSet::getTotalNum(), MultiSlaterDetTableMethod::myVars, MultiSlaterDetTableMethod::psi_ratio_to_ref_det_, VariableSet::recompute(), VirtualParticleSet::refPtcl, and Vector< T, Alloc >::size().

1077 {
1078  const unsigned det_id = getDetID(VP.refPtcl);
1079 
1080  bool recalculate(false);
1081  if (CI_Optimizable)
1082  for (int k = 0; k < myVars->size(); ++k)
1083  {
1084  int kk = myVars->where(k);
1085  if (kk < 0)
1086  continue;
1087  if (optvars.recompute(kk))
1088  recalculate = true;
1089  }
1090 
1091  // calculate derivatives based on the reference electron position
1092  Vector<ValueType> dlogpsi_ref, dlogpsi_vp;
1093  if (recalculate)
1094  evaluateDerivativesMSD(dlogpsi_ref);
1095 
1096  for (size_t iat = 0; iat < VP.getTotalNum(); ++iat)
1097  {
1098  Dets[det_id]->evaluateDetsForPtclMove(VP, iat, VP.refPtcl);
1099  const OffloadVector<ValueType>& detValues0 = Dets[det_id]->getNewRatiosToRefDet();
1100 
1101  // calculate VP ratios
1103  ratios[iat] = Dets[det_id]->getRefDetRatio();
1104  if (ratios[iat] != ValueType(0))
1105  ratios[iat] *= psiNew / psi_ratio_to_ref_det_;
1106 
1107  // calculate VP ratios derivatives
1108  if (recalculate)
1109  {
1110  evaluateDerivativesMSD(dlogpsi_vp, std::make_pair(det_id, psiNew));
1111 
1112  const size_t nparams = csf_data_ ? csf_data_->coeffs.size() - 1 : C->size() - 1;
1113  assert(dlogpsi_vp.size() == nparams);
1114 
1115  for (int i = 0; i < nparams; i++)
1116  {
1117  int kk = myVars->where(i);
1118  if (kk < 0)
1119  continue;
1120  dratios[iat][kk] = dlogpsi_vp[i] - dlogpsi_ref[i];
1121  }
1122  }
1123  }
1124 }
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
bool CI_Optimizable
if true, the CI coefficients are optimized
std::shared_ptr< opt_variables_type > myVars
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
void evaluateDerivativesMSD(Vector< ValueType > &dlogpsi, std::optional< std::pair< unsigned, PsiValue >> move=std::nullopt) const
compute parameter derivatives of CI/CSF coefficients
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
PsiValue computeRatio_NewMultiDet_to_NewRefDet(int det_id) const

◆ evaluateLog()

evaluate the value of the WaveFunctionComponent from scratch

Parameters
[in]Pactive ParticleSet
[out]GGradients, $\nabla\ln\Psi$
[out]LLaplacians, $\nabla^2\ln\Psi$
Returns
the log value

Mainly for walker-by-walker move. The initial stage of particle-by-particle move also uses this. causes complete state update in WFC's

Implements WaveFunctionComponent.

Definition at line 143 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::Dets, qmcplusplus::dot(), MultiSlaterDetTableMethod::evaluate_vgl_impl(), MultiSlaterDetTableMethod::EvaluateTimer, ParticleSet::isSpinor(), WaveFunctionComponent::log_value_, MultiSlaterDetTableMethod::myG, MultiSlaterDetTableMethod::myL, and Vector< T, Alloc >::size().

146 {
147  ScopedTimer local_timer(EvaluateTimer);
148  for (size_t id = 0; id < Dets.size(); id++)
149  {
150  if (P.isSpinor())
151  Dets[id]->evaluateForWalkerMoveWithSpin(P);
152  else
153  Dets[id]->evaluateForWalkerMove(P);
154  }
156 
157  G += myG;
158  for (size_t i = 0; i < L.size(); i++)
159  L[i] += myL[i] - dot(myG[i], myG[i]);
160 
161  return log_value_;
162 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
LogValue evaluate_vgl_impl(const ParticleSet &P, ParticleSet::ParticleGradient &g_tmp, ParticleSet::ParticleLaplacian &l_tmp)
Compute VGL of this MultiSlaterDetTableMethod.

◆ evaluateMultiDiracDeterminantDerivatives()

void evaluateMultiDiracDeterminantDerivatives ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
private

Definition at line 939 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::C2node, qmcplusplus::det(), MultiSlaterDetTableMethod::Dets, and MultiSlaterDetTableMethod::psi_ratio_to_ref_det_.

Referenced by MultiSlaterDetTableMethod::evaluateDerivatives().

943 {
944  //Currently, the MultiDiracDeterminant::evaluateDerivatives works with a legacy design, essentially requiring only up and down determinants.
945  //e.g. for spinor cases, we only have one determinant so this interface doesn't work.
946  //Here we throw an error only if the optimization is turned on for MultiDiracDeterminants until the code is updated
947  for (auto const& det : Dets)
948  if (!det->isOptimizable())
949  return;
950 
951  if (Dets.size() != 2)
952  {
953  throw std::runtime_error(
954  "MultiSlaterDetTableMethod::evaluateDerivatives only compatible with two quantum particle types.");
955  }
956  else
957  {
958  Dets[0]->evaluateDerivatives(P, optvars, dlogpsi, dhpsioverpsi, *Dets[1],
959  static_cast<ValueType>(psi_ratio_to_ref_det_), *C, (*C2node)[0], (*C2node)[1]);
960  Dets[1]->evaluateDerivatives(P, optvars, dlogpsi, dhpsioverpsi, *Dets[0],
961  static_cast<ValueType>(psi_ratio_to_ref_det_), *C, (*C2node)[1], (*C2node)[0]);
962  }
963 
964  //note: the future redesign of MultiDiracDeterminant::evaluateDerivatives should look something like this
965  //for (size_t id = 0; id < Dets.size(); id++)
966  // Dets[id]->evaluateDerivatives(P, optvars, dlogpsi, dhpsioverpsi, *Dets, static_cast<ValueType>(psi_ratio_to_ref_det_), *C, *C2node, id);
967 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
std::shared_ptr< std::vector< std::vector< size_t > > > C2node
map determinant in linear combination to unique det list map global det id to unique det id...
PsiValue psi_ratio_to_ref_det_
current psi over ref single det

◆ evaluateMultiDiracDeterminantDerivativesWF()

void evaluateMultiDiracDeterminantDerivativesWF ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi 
)
private

Definition at line 1126 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::C2node, qmcplusplus::det(), MultiSlaterDetTableMethod::Dets, and MultiSlaterDetTableMethod::psi_ratio_to_ref_det_.

Referenced by MultiSlaterDetTableMethod::evaluateDerivativesWF().

1129 {
1130  //Currently, the MultiDiracDeterminant::evaluateDerivativesWF works with a legacy design, essentially requiring only up and down determinants.
1131  //e.g. for spinor cases, we only have one determinant so this interface doesn't work.
1132  //Here we throw an error only if the optimization is turned on for MultiDiracDeterminants until the code is updated
1133  for (auto const& det : Dets)
1134  if (!det->isOptimizable())
1135  return;
1136 
1137  if (Dets.size() != 2)
1138  {
1139  throw std::runtime_error(
1140  "MultiSlaterDetTableMethod::evaluateDerivativesWF only compatible with two quantum particle types.");
1141  }
1142  else
1143  {
1144  // FIXME this needs to be fixed by SPF to separate evaluateDerivatives and evaluateDerivativesWF for orbital rotation matrix
1145  Dets[0]->evaluateDerivativesWF(P, optvars, dlogpsi, *Dets[1], psi_ratio_to_ref_det_, *C, (*C2node)[0],
1146  (*C2node)[1]);
1147  Dets[1]->evaluateDerivativesWF(P, optvars, dlogpsi, *Dets[0], psi_ratio_to_ref_det_, *C, (*C2node)[1],
1148  (*C2node)[0]);
1149  }
1150  //note: the future redesign of MultiDiracDeterminant::evaluateDerivativesWF should look something like this
1151  // for (size_t id = 0; id < Dets.size(); id++)
1152  // Dets[id]->evaluateDerivativesWF(P, optvars, dlogpsi, *Dets, psi_ratio_to_ref_det_, *C, *C2node, id);
1153 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
std::shared_ptr< std::vector< std::vector< size_t > > > C2node
map determinant in linear combination to unique det list map global det id to unique det id...
PsiValue psi_ratio_to_ref_det_
current psi over ref single det

◆ evaluateRatios()

void evaluateRatios ( const VirtualParticleSet VP,
std::vector< ValueType > &  ratios 
)
override

Definition at line 633 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::computeRatio_NewMultiDet_to_NewRefDet(), MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::getDetID(), VirtualParticleSet::getTotalNum(), MultiSlaterDetTableMethod::psi_ratio_to_ref_det_, MultiSlaterDetTableMethod::RatioTimer, and VirtualParticleSet::refPtcl.

634 {
635  ScopedTimer local_timer(RatioTimer);
636 
637  const int det_id = getDetID(VP.refPtcl);
638 
639  for (size_t iat = 0; iat < VP.getTotalNum(); ++iat)
640  {
641  Dets[det_id]->evaluateDetsForPtclMove(VP, iat, VP.refPtcl);
642  const OffloadVector<ValueType>& detValues0 = Dets[det_id]->getNewRatiosToRefDet();
643 
645  ratios[iat] = Dets[det_id]->getRefDetRatio();
646  if (ratios[iat] != ValueType(0))
647  ratios[iat] *= psiNew / psi_ratio_to_ref_det_;
648  }
649 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
PsiValue computeRatio_NewMultiDet_to_NewRefDet(int det_id) const

◆ evaluateRatiosAlltoOne()

void evaluateRatiosAlltoOne ( ParticleSet P,
std::vector< ValueType > &  ratios 
)
inlineoverride

Definition at line 160 of file MultiSlaterDetTableMethod.h.

161  {
162  // the base class routine may probably work, just never tested.
163  // it can also be highly optimized with a specialized implementation.
164  throw std::runtime_error(" Need to implement MultiSlaterDetTableMethod::evaluateRatiosAlltoOne. \n");
165  }

◆ extract_DetRef_list()

RefVectorWithLeader<MultiDiracDeterminant> extract_DetRef_list ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
int  det_id 
) const
inlineprivate

Definition at line 321 of file MultiSlaterDetTableMethod.h.

References MultiSlaterDetTableMethod::Dets, and RefVectorWithLeader< T >::getCastedLeader().

Referenced by MultiSlaterDetTableMethod::acquireResource(), MultiSlaterDetTableMethod::mw_accept_rejectMove(), and MultiSlaterDetTableMethod::releaseResource().

324  {
325  RefVectorWithLeader<MultiDiracDeterminant> det_list(
326  *wfc_list.getCastedLeader<MultiSlaterDetTableMethod>().Dets[det_id]);
327  det_list.reserve(wfc_list.size());
328  for (WaveFunctionComponent& wfc : wfc_list)
329  det_list.push_back(*static_cast<MultiSlaterDetTableMethod&>(wfc).Dets[det_id]);
330  return det_list;
331  }
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
WaveFunctionComponent(const std::string &obj_name="")
default constructor

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
overridevirtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented from WaveFunctionComponent.

Definition at line 732 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::Dets, and UniqueOptObjRefs::push_back().

733 {
734  opt_obj_refs.push_back(*this);
735  for (int i = 0; i < Dets.size(); i++)
736  Dets[i]->extractOptimizableObjectRefs(opt_obj_refs);
737 }
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 98 of file MultiSlaterDetTableMethod.h.

98 { return "MultiSlaterDetTableMethod"; }

◆ getDetID()

◆ getLinearExpansionCoefs()

const std::vector< WaveFunctionComponent::ValueType > & getLinearExpansionCoefs ( ) const

Definition at line 1022 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, and MultiSlaterDetTableMethod::csf_data_.

Referenced by SelfHealingOverlap::SelfHealingOverlap(), and SelfHealingOverlapLegacy::SelfHealingOverlapLegacy().

1023 {
1024  // CI only for now
1025  assert(!csf_data_);
1026  return *C;
1027 }
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.

◆ initialize()

void initialize ( std::unique_ptr< std::vector< std::vector< size_t >>>  C2node_in,
std::unique_ptr< std::vector< ValueType >>  C_in,
std::unique_ptr< opt_variables_type myVars_in,
std::unique_ptr< CSFData csf_data_in,
bool  optimizable,
bool  CI_optimizable 
)

initialize a few objects and states by the builder YL: it should be part of the constructor.

It cannot be added to the constructor because the constructor is used by makeClone. The right way of fix needs:

  1. implement a copy constructor and reroute makeClone to it.
  2. merge initialize() into the constructor.

Definition at line 70 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::C2node, MultiSlaterDetTableMethod::CI_Optimizable, MultiSlaterDetTableMethod::csf_data_, and MultiSlaterDetTableMethod::myVars.

76 {
77  C2node = std::move(C2node_in);
78  C = std::move(C_in);
79  myVars = std::move(myVars_in);
80  csf_data_ = std::move(csf_data_in);
81  CI_Optimizable = CI_optimizable;
82 }
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
bool CI_Optimizable
if true, the CI coefficients are optimized
std::shared_ptr< opt_variables_type > myVars
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
std::shared_ptr< std::vector< std::vector< size_t > > > C2node
map determinant in linear combination to unique det list map global det id to unique det id...

◆ isFermionic()

bool isFermionic ( ) const
inlinefinalvirtual

true, if this component is fermionic

Reimplemented from WaveFunctionComponent.

Definition at line 99 of file MultiSlaterDetTableMethod.h.

99 { return true; }

◆ isMultiDet()

bool isMultiDet ( ) const
inlinefinalvirtual

true, if this component is multi-determinant

Reimplemented from WaveFunctionComponent.

Definition at line 100 of file MultiSlaterDetTableMethod.h.

100 { return true; }

◆ isOptimizable()

bool isOptimizable ( ) const
inlineoverridevirtual

if true, this contains optimizable components

Reimplemented from WaveFunctionComponent.

Definition at line 101 of file MultiSlaterDetTableMethod.h.

Referenced by MultiSlaterDetTableMethod::checkOutVariables().

101 { return true; }

◆ makeClone()

std::unique_ptr< WaveFunctionComponent > makeClone ( ParticleSet tqp) const
overridevirtual

make clone

Parameters
tqptarget Quantum ParticleSet
deepcopyif true, make a decopy

If not true, return a proxy class

Reimplemented from WaveFunctionComponent.

Definition at line 86 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::C2node, MultiSlaterDetTableMethod::CI_Optimizable, qmcplusplus::clone, MultiSlaterDetTableMethod::csf_data_, qmcplusplus::det(), MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::myVars, and MultiSlaterDetTableMethod::use_pre_computing_.

87 {
88  std::vector<std::unique_ptr<MultiDiracDeterminant>> dets_clone;
89  for (auto& det : Dets)
90  dets_clone.emplace_back(std::make_unique<MultiDiracDeterminant>(*det));
91 
92  auto clone = std::make_unique<MultiSlaterDetTableMethod>(tqp, std::move(dets_clone), use_pre_computing_);
93 
94  clone->CI_Optimizable = CI_Optimizable;
95  clone->C2node = C2node;
96  clone->C = C;
97  clone->myVars = myVars;
98 
99  clone->csf_data_ = csf_data_;
100 
101  return clone;
102 }
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
bool CI_Optimizable
if true, the CI coefficients are optimized
std::shared_ptr< opt_variables_type > myVars
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
std::shared_ptr< std::vector< std::vector< size_t > > > C2node
map determinant in linear combination to unique det list map global det id to unique det id...
const bool use_pre_computing_
use pre-compute (fast) algorithm

◆ mw_accept_rejectMove()

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
overridevirtual

moves of the iat-th particle on some walkers in a batch is accepted.

Update the current content. Note that all the lists only include accepted walkers.

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
safe_to_delayif true, delayed accept is safe.

Reimplemented from WaveFunctionComponent.

Definition at line 671 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::AccRejTimer, qmcplusplus::convertValueToLog(), qmcplusplus::det(), MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::extract_DetRef_list(), RefVectorWithLeader< T >::getCastedElement(), and MultiSlaterDetTableMethod::getDetID().

676 {
677  ScopedTimer local_timer(AccRejTimer);
678  for (size_t iw = 0; iw < isAccepted.size(); iw++)
679  {
680  auto& det = wfc_list.getCastedElement<MultiSlaterDetTableMethod>(iw);
681  if (isAccepted[iw])
682  {
683  det.psi_ratio_to_ref_det_ = det.new_psi_ratio_to_new_ref_det_;
684  det.log_value_ += convertValueToLog(det.curRatio);
685  }
686  det.curRatio = 1.0;
687  }
688  const auto det_id = getDetID(iat);
689  const auto det_list(extract_DetRef_list(wfc_list, det_id));
690  Dets[det_id]->mw_accept_rejectMove(det_list, p_list, iat, isAccepted);
691 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
RefVectorWithLeader< MultiDiracDeterminant > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ mw_calcRatio()

void mw_calcRatio ( const RefVectorWithLeader< WaveFunctionComponent > &  WFC_list,
const RefVectorWithLeader< ParticleSet > &  P_list,
int  iat,
std::vector< PsiValue > &  ratios 
) const
override

Definition at line 564 of file MultiSlaterDetTableMethod.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), MultiSlaterDetTableMethod::getDetID(), WaveFunctionComponent::mw_calcRatio(), WaveFunctionComponent::ORB_PBYP_RATIO, and MultiSlaterDetTableMethod::use_pre_computing_.

568 {
569  if (!use_pre_computing_)
570  {
571  WaveFunctionComponent::mw_calcRatio(WFC_list, P_list, iat, ratios);
572  return;
573  }
574 
575 
576  auto& det_leader = WFC_list.getCastedLeader<MultiSlaterDetTableMethod>();
577  ScopedTimer local_timer(det_leader.RatioTimer);
578 
579  const int det_id = getDetID(iat);
580  const int nw = WFC_list.size();
581  const int ndets = det_leader.Dets[det_id]->getNumDets();
582 
583  RefVectorWithLeader<MultiDiracDeterminant> det_list(*det_leader.Dets[det_id]);
584  det_list.reserve(WFC_list.size());
585  for (int iw = 0; iw < WFC_list.size(); iw++)
586  {
587  auto& det = WFC_list.getCastedElement<MultiSlaterDetTableMethod>(iw);
588  det_list.push_back(*det.Dets[det_id]);
589  }
590 
591  det_leader.Dets[det_id]->mw_evaluateDetsForPtclMove(det_list, P_list, iat);
592 
593  auto& mw_res = det_leader.mw_res_handle_.getResource();
594  auto& det_value_ptr_list = mw_res.det_value_ptr_list;
595  det_value_ptr_list.resize(nw);
596  for (size_t iw = 0; iw < nw; iw++)
597  {
598  auto& det = WFC_list.getCastedElement<MultiSlaterDetTableMethod>(iw);
599  det.UpdateMode = ORB_PBYP_RATIO;
600 
601  det_value_ptr_list[iw] = det.Dets[det_id]->getNewRatiosToRefDet().device_data();
602  }
603 
604  std::vector<PsiValue> psi_list(nw, 0);
605  auto* psi_list_ptr = psi_list.data();
606  auto* C_otherDs_ptr_list_ptr = mw_res.C_otherDs_ptr_list.data();
607  auto* det_value_ptr_list_ptr = det_value_ptr_list.data();
608  {
609  ScopedTimer local_timer(det_leader.offload_timer);
610  PRAGMA_OFFLOAD("omp target teams distribute map(always,from: psi_list_ptr[:nw]) \
611  map(always, to: det_value_ptr_list_ptr[:nw])")
612  for (uint32_t iw = 0; iw < nw; iw++)
613  {
614  PsiValue psi_local(0);
615  PRAGMA_OFFLOAD("omp parallel for reduction(+ : psi_local)")
616  for (uint32_t i = 0; i < ndets; i++)
617  psi_local += det_value_ptr_list_ptr[iw][i] * C_otherDs_ptr_list_ptr[iw][i];
618  psi_list_ptr[iw] = psi_local;
619  }
620  }
621 
622  for (size_t iw = 0; iw < nw; iw++)
623  {
624  auto& det = WFC_list.getCastedElement<MultiSlaterDetTableMethod>(iw);
625  det.new_psi_ratio_to_new_ref_det_ = psi_list[iw];
626  det.curRatio = det.Dets[det_id]->getRefDetRatio();
627  if (det.curRatio != PsiValue(0))
628  det.curRatio *= psi_list[iw] / det.psi_ratio_to_ref_det_;
629  ratios[iw] = det.curRatio;
630  }
631 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
const bool use_pre_computing_
use pre-compute (fast) algorithm
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 ...

◆ mw_evalGrad()

void mw_evalGrad ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< GradType > &  grad_now 
) const
overridevirtual

compute the current gradients for the iat-th particle of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
grad_nowthe list of gradients in a walker batch, $\nabla\ln\Psi$

Reimplemented from WaveFunctionComponent.

Definition at line 416 of file MultiSlaterDetTableMethod.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), WaveFunctionComponent::mw_evalGrad(), MultiSlaterDetTableMethod::mw_evalGrad_impl(), and MultiSlaterDetTableMethod::use_pre_computing_.

420 {
421  if (!use_pre_computing_)
422  {
423  WaveFunctionComponent::mw_evalGrad(WFC_list, P_list, iat, grad_now);
424  return;
425  }
426 
427  auto& det_leader = WFC_list.getCastedLeader<MultiSlaterDetTableMethod>();
428  ScopedTimer local_timer(det_leader.EvalGradTimer);
429 
430  const int nw = WFC_list.size();
431 
432  std::vector<PsiValue> psi_list(nw, 0);
433  mw_evalGrad_impl(WFC_list, P_list, iat, false, grad_now, psi_list);
434 }
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
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
static void mw_evalGrad_impl(const RefVectorWithLeader< WaveFunctionComponent > &WFC_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, bool newpos, std::vector< GradType > &grad_now, std::vector< PsiValue > &psi_list)
multi walker version of evalGrad_impl
const bool use_pre_computing_
use pre-compute (fast) algorithm

◆ mw_evalGrad_impl()

void mw_evalGrad_impl ( const RefVectorWithLeader< WaveFunctionComponent > &  WFC_list,
const RefVectorWithLeader< ParticleSet > &  P_list,
int  iat,
bool  newpos,
std::vector< GradType > &  grad_now,
std::vector< PsiValue > &  psi_list 
)
staticprivate

multi walker version of evalGrad_impl

Definition at line 235 of file MultiSlaterDetTableMethod.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), and MultiSlaterDetTableMethod::getDetID().

Referenced by MultiSlaterDetTableMethod::mw_evalGrad(), and MultiSlaterDetTableMethod::mw_ratioGrad().

241 {
242  auto& det_leader = WFC_list.getCastedLeader<MultiSlaterDetTableMethod>();
243  const int det_id = det_leader.getDetID(iat);
244  const int nw = WFC_list.size();
245  const int ndets = det_leader.Dets[det_id]->getNumDets();
246 
247  RefVectorWithLeader<MultiDiracDeterminant> det_list(*det_leader.Dets[det_id]);
248  det_list.reserve(WFC_list.size());
249  for (int iw = 0; iw < WFC_list.size(); iw++)
250  {
251  auto& det = WFC_list.getCastedElement<MultiSlaterDetTableMethod>(iw);
252  det_list.push_back(*det.Dets[det_id]);
253  }
254 
255  auto& mw_res = det_leader.mw_res_handle_.getResource();
256  auto& mw_grads = mw_res.mw_grads;
257  mw_grads.resize(3 * nw, ndets);
258  if (newpos)
259  det_leader.Dets[det_id]->mw_evaluateDetsAndGradsForPtclMove(det_list, P_list, iat, mw_grads);
260  else
261  det_leader.Dets[det_id]->mw_evaluateGrads(det_list, P_list, iat, mw_grads);
262 
263  auto& det_value_ptr_list = mw_res.det_value_ptr_list;
264  det_value_ptr_list.resize(nw);
265  for (size_t iw = 0; iw < nw; iw++)
266  {
267  auto& det = WFC_list.getCastedElement<MultiSlaterDetTableMethod>(iw);
268  det_value_ptr_list[iw] = (newpos) ? det.Dets[det_id]->getNewRatiosToRefDet().device_data()
269  : det.Dets[det_id]->getRatiosToRefDet().device_data();
270  }
271 
272  std::vector<ValueType> grad_now_list(nw * 3, 0);
273  auto* grad_now_list_ptr = grad_now_list.data();
274  auto* mw_grads_ptr = mw_grads.data();
275  auto* psi_list_ptr = psi_list.data();
276  auto* C_otherDs_ptr_list_ptr = mw_res.C_otherDs_ptr_list.data();
277  auto* det_value_ptr_list_ptr = det_value_ptr_list.data();
278  {
279  ScopedTimer local_timer(det_leader.offload_timer);
280  PRAGMA_OFFLOAD("omp target teams distribute map(from: psi_list_ptr[:nw]) \
281  map(from: grad_now_list_ptr[:3 * nw]) \
282  map(always, to: det_value_ptr_list_ptr[:nw]) \
283  map(to: mw_grads_ptr[:mw_grads.size()])")
284  for (uint32_t iw = 0; iw < nw; iw++)
285  {
286  // enforce full precision reduction due to numerical sensitivity
287  PsiValue psi_local(0);
288  PsiValue grad_local_x(0);
289  PsiValue grad_local_y(0);
290  PsiValue grad_local_z(0);
291  PRAGMA_OFFLOAD("omp parallel for reduction(+:psi_local, grad_local_x, grad_local_y, grad_local_z)")
292  for (uint32_t i = 0; i < ndets; i++)
293  {
294  psi_local += det_value_ptr_list_ptr[iw][i] * C_otherDs_ptr_list_ptr[iw][i];
295  grad_local_x += C_otherDs_ptr_list_ptr[iw][i] * mw_grads_ptr[(3 * iw + 0) * ndets + i];
296  grad_local_y += C_otherDs_ptr_list_ptr[iw][i] * mw_grads_ptr[(3 * iw + 1) * ndets + i];
297  grad_local_z += C_otherDs_ptr_list_ptr[iw][i] * mw_grads_ptr[(3 * iw + 2) * ndets + i];
298  }
299  psi_list_ptr[iw] = psi_local;
300  grad_now_list_ptr[iw * 3 + 0] = grad_local_x;
301  grad_now_list_ptr[iw * 3 + 1] = grad_local_y;
302  grad_now_list_ptr[iw * 3 + 2] = grad_local_z;
303  }
304  }
305 
306  for (size_t iw = 0; iw < nw; iw++)
307  {
308  auto psi_inv = static_cast<ValueType>(PsiValue(1.0) / psi_list[iw]);
309  grad_now[iw][0] = grad_now_list[iw * 3 + 0] * psi_inv;
310  grad_now[iw][1] = grad_now_list[iw * 3 + 1] * psi_inv;
311  grad_now[iw][2] = grad_now_list[iw * 3 + 2] * psi_inv;
312  }
313 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
QTBase::ValueType ValueType
Definition: Configuration.h:60

◆ mw_prepareGroup()

void mw_prepareGroup ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  ig 
) const
overridevirtual

Reimplemented from WaveFunctionComponent.

Definition at line 1168 of file MultiSlaterDetTableMethod.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), and MultiSlaterDetTableMethod::use_pre_computing_.

1171 {
1172  if (!use_pre_computing_)
1173  return;
1174 
1175  auto& det_leader = wfc_list.getCastedLeader<MultiSlaterDetTableMethod>();
1176  const size_t nw = wfc_list.size();
1177  assert(this == &det_leader);
1178 
1179  auto& C_otherDs_ptr_list = det_leader.mw_res_handle_.getResource().C_otherDs_ptr_list;
1180  C_otherDs_ptr_list.resize(nw);
1181  for (int iw = 0; iw < nw; iw++)
1182  {
1183  auto& det = wfc_list.getCastedElement<MultiSlaterDetTableMethod>(iw);
1184  det.prepareGroup(p_list[iw], ig);
1185  C_otherDs_ptr_list[iw] = det.C_otherDs[ig].device_data();
1186  }
1187  C_otherDs_ptr_list.updateTo();
1188 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
const bool use_pre_computing_
use pre-compute (fast) algorithm

◆ mw_ratioGrad()

void mw_ratioGrad ( const RefVectorWithLeader< WaveFunctionComponent > &  WFC_list,
const RefVectorWithLeader< ParticleSet > &  P_list,
int  iat,
std::vector< PsiValue > &  ratios,
std::vector< GradType > &  grad_new 
) const
override

Definition at line 480 of file MultiSlaterDetTableMethod.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), MultiSlaterDetTableMethod::getDetID(), MultiSlaterDetTableMethod::mw_evalGrad_impl(), WaveFunctionComponent::mw_ratioGrad(), and MultiSlaterDetTableMethod::use_pre_computing_.

485 {
486  if (!use_pre_computing_)
487  {
488  WaveFunctionComponent::mw_ratioGrad(WFC_list, P_list, iat, ratios, grad_new);
489  return;
490  }
491 
492  auto& det_leader = WFC_list.getCastedLeader<MultiSlaterDetTableMethod>();
493  const int nw = WFC_list.size();
494 
495  ScopedTimer local_timer(det_leader.RatioGradTimer);
496  std::vector<PsiValue> psi_list(nw, 0);
497  std::vector<GradType> dummy;
498  dummy.resize(nw);
499 
500  mw_evalGrad_impl(WFC_list, P_list, iat, true, dummy, psi_list);
501 
502  const int det_id = getDetID(iat);
503  for (size_t iw = 0; iw < nw; iw++)
504  {
505  auto& det = WFC_list.getCastedElement<MultiSlaterDetTableMethod>(iw);
506  det.new_psi_ratio_to_new_ref_det_ = psi_list[iw];
507  grad_new[iw] += dummy[iw];
508  det.curRatio = det.Dets[det_id]->getRefDetRatio();
509  if (det.curRatio != PsiValue(0))
510  det.curRatio *= psi_list[iw] / det.psi_ratio_to_ref_det_;
511  ratios[iw] = det.curRatio;
512  }
513 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static void mw_evalGrad_impl(const RefVectorWithLeader< WaveFunctionComponent > &WFC_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, bool newpos, std::vector< GradType > &grad_now, std::vector< PsiValue > &psi_list)
multi walker version of evalGrad_impl
const bool use_pre_computing_
use pre-compute (fast) algorithm
void mw_ratioGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const

◆ precomputeC_otherDs()

void precomputeC_otherDs ( const ParticleSet P,
int  ig 
)
private

precompute C_otherDs for a given particle group

Parameters
Pa particle set
iggroup id

Definition at line 1191 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::C_otherDs, MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::PrepareGroupTimer, and qmcplusplus::MatrixOperators::product().

Referenced by MultiSlaterDetTableMethod::evaluate_vgl_impl(), and MultiSlaterDetTableMethod::prepareGroup().

1192 {
1193  // This function computes
1194  // C_otherDs[det_id][i]=Det_Coeff[i]*Det_Value[unique_det_dn]*Det_Value[unique_det_AnyOtherType]
1195  // Since only one electron group is moved at the time, identified by det_id, We precompute C_otherDs[det_id][i]:
1196  // psi=Det_Coeff[i]*Det_Value[unique_det_up]*Det_Value[unique_det_dn]*Det_Value[unique_det_AnyOtherType]
1197  // becomes:
1198  // psi=Det_Value[unique_det_up]*C_otherDs[det_id][i]
1199  // ig is the id of the group electron being moved. In this function, we compute the other groups
1200  // of electrons.
1201  // We loop over the number of type of determinants (up, diwn, positrons, etc), but we only multiply for ll types BUT ig
1202  // C_otherDs(0, :) stores C x D_dn x D_pos
1203  // C_otherDs(1, :) stores C x D_up x D_pos
1204  // C_otherDs(2, :) stores C x D_up x D_dn
1205 
1206  ScopedTimer local_timer(PrepareGroupTimer);
1207  C_otherDs[ig].resize(Dets[ig]->getNumDets());
1208  std::fill(C_otherDs[ig].begin(), C_otherDs[ig].end(), ValueType(0));
1209  for (size_t i = 0; i < C->size(); i++)
1210  {
1211  // enforce full precision reduction on C_otherDs due to numerical sensitivity
1212  PsiValue product = (*C)[i];
1213  for (size_t id = 0; id < Dets.size(); id++)
1214  if (id != ig)
1215  product *= Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
1216  C_otherDs[ig][(*C2node)[ig][i]] += product;
1217  }
1218  //put C_otherDs in device
1219  C_otherDs[ig].updateTo();
1220 }
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
QTBase::ValueType ValueType
Definition: Configuration.h:60
void product(const Matrix< T > &A, const Matrix< T > &B, Matrix< T > &C)
static function to perform C=AB for real matrices
std::vector< OffloadVector< ValueType > > C_otherDs
C_n x D^1_n x D^2_n ... D^3_n with one D removed. Summed by group. [spin, unique det id]...
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ prepareGroup()

void prepareGroup ( ParticleSet P,
int  ig 
)
overridevirtual

Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group.

This call can be used to handle the precomputation of data used for moving this group of particle. Such data should be static with respect to the moves of particles within this group. Particle groups usually correspond to determinants of different spins.

Parameters
Pquantum particle set
igparticle group index

Reimplemented from WaveFunctionComponent.

Definition at line 1161 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::precomputeC_otherDs(), and MultiSlaterDetTableMethod::use_pre_computing_.

1162 {
1163  if (!use_pre_computing_)
1164  return;
1165  precomputeC_otherDs(P, ig);
1166 }
void precomputeC_otherDs(const ParticleSet &P, int ig)
precompute C_otherDs for a given particle group
const bool use_pre_computing_
use pre-compute (fast) algorithm

◆ ratio()

WaveFunctionComponent::PsiValue ratio ( ParticleSet P,
int  iat 
)
overridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value

Parameters
Pthe active ParticleSet
iatthe index of a particle
Returns
$ \psi( \{ {\bf R}^{'} \} )/ \psi( \{ {\bf R}\})$

Specialized for particle-by-particle move

Implements WaveFunctionComponent.

Definition at line 549 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::computeRatio_NewMultiDet_to_NewRefDet(), MultiSlaterDetTableMethod::curRatio, MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::getDetID(), MultiSlaterDetTableMethod::new_psi_ratio_to_new_ref_det_, WaveFunctionComponent::ORB_PBYP_RATIO, MultiSlaterDetTableMethod::psi_ratio_to_ref_det_, MultiSlaterDetTableMethod::RatioTimer, and WaveFunctionComponent::UpdateMode.

550 {
551  ScopedTimer local_timer(RatioTimer);
553 
554  const int det_id = getDetID(iat);
555  Dets[det_id]->evaluateDetsForPtclMove(P, iat);
556 
558  curRatio = Dets[det_id]->getRefDetRatio();
559  if (curRatio != PsiValue(0))
561  return curRatio;
562 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
PsiValue computeRatio_NewMultiDet_to_NewRefDet(int det_id) const
PsiValue new_psi_ratio_to_new_ref_det_
new psi over new ref single det when one particle is moved

◆ ratioGrad()

WaveFunctionComponent::PsiValue ratioGrad ( ParticleSet P,
int  iat,
GradType grad_iat 
)
overridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient

Parameters
Pthe active ParticleSet
iatthe index of a particle
grad_iatGradient for the active particle

Reimplemented from WaveFunctionComponent.

Definition at line 437 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::curRatio, MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::evalGrad_impl(), MultiSlaterDetTableMethod::evalGrad_impl_no_precompute(), MultiSlaterDetTableMethod::getDetID(), MultiSlaterDetTableMethod::new_psi_ratio_to_new_ref_det_, WaveFunctionComponent::ORB_PBYP_PARTIAL, MultiSlaterDetTableMethod::psi_ratio_to_ref_det_, MultiSlaterDetTableMethod::RatioGradTimer, WaveFunctionComponent::UpdateMode, and MultiSlaterDetTableMethod::use_pre_computing_.

438 {
439  ScopedTimer local_timer(RatioGradTimer);
441 
442  GradType dummy;
443  if (use_pre_computing_)
444  new_psi_ratio_to_new_ref_det_ = evalGrad_impl(P, iat, true, dummy);
445  else
447 
448  const int det_id = getDetID(iat);
449  curRatio = Dets[det_id]->getRefDetRatio();
450  if (curRatio != PsiValue(0))
452  grad_iat += dummy;
453  return curRatio;
454 }
QTBase::GradType GradType
Definition: Configuration.h:62
PsiValue evalGrad_impl_no_precompute(ParticleSet &P, int iat, bool newpos, GradType &g_at)
an implementation shared by evalGrad and ratioGrad.
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
const bool use_pre_computing_
use pre-compute (fast) algorithm
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
PsiValue evalGrad_impl(ParticleSet &P, int iat, bool newpos, GradType &g_at)
an implementation shared by evalGrad and ratioGrad.
PsiValue new_psi_ratio_to_new_ref_det_
new psi over new ref single det when one particle is moved

◆ ratioGradWithSpin()

WaveFunctionComponent::PsiValue ratioGradWithSpin ( ParticleSet P,
int  iat,
GradType grad_iat,
ComplexType spingrad_iat 
)
overridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin.

Parameters
Pthe active ParticleSet
iatthe index of a particle
grad_iatrealspace gradient for the active particle
spingrad_iatspin gradient for the active particle

Reimplemented from WaveFunctionComponent.

Definition at line 456 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::curRatio, MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::evalGradWithSpin_impl(), MultiSlaterDetTableMethod::evalGradWithSpin_impl_no_precompute(), MultiSlaterDetTableMethod::getDetID(), MultiSlaterDetTableMethod::new_psi_ratio_to_new_ref_det_, WaveFunctionComponent::ORB_PBYP_PARTIAL, MultiSlaterDetTableMethod::psi_ratio_to_ref_det_, MultiSlaterDetTableMethod::RatioGradTimer, WaveFunctionComponent::UpdateMode, and MultiSlaterDetTableMethod::use_pre_computing_.

460 {
461  ScopedTimer local_timer(RatioGradTimer);
463 
464  GradType dummy;
465  ComplexType spindummy;
466  if (use_pre_computing_)
467  new_psi_ratio_to_new_ref_det_ = evalGradWithSpin_impl(P, iat, true, dummy, spindummy);
468  else
469  new_psi_ratio_to_new_ref_det_ = evalGradWithSpin_impl_no_precompute(P, iat, true, dummy, spindummy);
470 
471  const int det_id = getDetID(iat);
472  curRatio = Dets[det_id]->getRefDetRatio();
473  if (curRatio != PsiValue(0))
475  grad_iat += dummy;
476  spingrad_iat += spindummy;
477  return curRatio;
478 }
QTBase::GradType GradType
Definition: Configuration.h:62
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
PsiValue evalGradWithSpin_impl_no_precompute(ParticleSet &P, int iat, bool newpos, GradType &g_at, ComplexType &sg_at)
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue evalGradWithSpin_impl(ParticleSet &P, int iat, bool newpos, GradType &g_at, ComplexType &sg_at)
const bool use_pre_computing_
use pre-compute (fast) algorithm
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
PsiValue new_psi_ratio_to_new_ref_det_
new psi over new ref single det when one particle is moved

◆ registerData()

void registerData ( ParticleSet P,
WFBufferType buf 
)
overridevirtual

For particle-by-particle move.

Requests space in the buffer based on the data type sizes of the objects in this class.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 693 of file MultiSlaterDetTableMethod.cpp.

References PooledMemory< T_scalar, Alloc >::add(), MultiSlaterDetTableMethod::Dets, WaveFunctionComponent::log_value_, and MultiSlaterDetTableMethod::psi_ratio_to_ref_det_.

694 {
695  for (size_t id = 0; id < Dets.size(); id++)
696  Dets[id]->registerData(P, buf);
697 
698  buf.add(log_value_);
699  buf.add(psi_ratio_to_ref_det_);
700 }
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
PsiValue psi_ratio_to_ref_det_
current psi over ref single det

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
overridevirtual

return a shared resource to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 1241 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::Dets, MultiSlaterDetTableMethod::extract_DetRef_list(), RefVectorWithLeader< T >::getCastedLeader(), and ResourceCollection::takebackResource().

1243 {
1244  auto& wfc_leader = wfc_list.getCastedLeader<MultiSlaterDetTableMethod>();
1245  collection.takebackResource(wfc_leader.mw_res_handle_);
1246  for (int idet = 0; idet < Dets.size(); idet++)
1247  {
1248  const auto det_list(extract_DetRef_list(wfc_list, idet));
1249  Dets[idet]->releaseResource(collection, det_list);
1250  }
1251 }
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
RefVectorWithLeader< MultiDiracDeterminant > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ resetParametersExclusive()

void resetParametersExclusive ( const opt_variables_type active)
overridevirtual

reset the parameters during optimizations.

Exclusive, see checkInVariablesExclusive

Implements OptimizableObject.

Definition at line 758 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::C, MultiSlaterDetTableMethod::CI_Optimizable, MultiSlaterDetTableMethod::csf_data_, and MultiSlaterDetTableMethod::myVars.

759 {
760  if (CI_Optimizable)
761  {
762  if (csf_data_)
763  {
764  ValueType* restrict CSFcoeff_p = csf_data_->coeffs.data();
765  for (int i = 0; i < csf_data_->coeffs.size() - 1; i++)
766  {
767  int loc = myVars->where(i);
768  if (loc >= 0)
769  {
770  CSFcoeff_p[i + 1] = (*myVars)[i] = active[loc];
771  }
772  }
773  int cnt = 0;
774  ValueType* restrict C_p = C->data();
775  const RealType* restrict CSFexpansion_p = csf_data_->expansion.data();
776  for (int i = 0; i < csf_data_->dets_per_csf.size(); i++)
777  {
778  for (int k = 0; k < csf_data_->dets_per_csf[i]; k++)
779  {
780  C_p[cnt] = CSFcoeff_p[i] * CSFexpansion_p[cnt];
781  cnt++;
782  }
783  }
784  //for(int i=0; i<Dets.size(); i++) Dets[i]->resetParameters(active);
785  }
786  else
787  {
788  ValueType* restrict C_p = C->data();
789  for (int i = 0; i < C->size() - 1; i++)
790  {
791  int loc = myVars->where(i);
792  if (loc >= 0)
793  {
794  C_p[i + 1] = (*myVars)[i] = active[loc];
795  }
796  }
797  //for(int i=0; i<Dets.size(); i++) Dets[i]->resetParameters(active);
798  }
799  }
800 }
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
bool CI_Optimizable
if true, the CI coefficients are optimized
std::shared_ptr< opt_variables_type > myVars
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
QTBase::ValueType ValueType
Definition: Configuration.h:60
QMCTraits::RealType RealType

◆ restore()

void restore ( int  iat)
overridevirtual

If a move for iat-th particle is rejected, restore to the content.

Parameters
iatindex of the particle whose new position was proposed

Ye: hopefully we can gradually move away from restore

Implements WaveFunctionComponent.

Definition at line 664 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::AccRejTimer, MultiSlaterDetTableMethod::curRatio, MultiSlaterDetTableMethod::Dets, and MultiSlaterDetTableMethod::getDetID().

665 {
666  ScopedTimer local_timer(AccRejTimer);
667  Dets[getDetID(iat)]->restore(iat);
668  curRatio = 1.0;
669 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection

◆ updateBuffer()

WaveFunctionComponent::LogValue updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)
overridevirtual

For particle-by-particle move.

Put the objects of this class in the walker buffer or forward the memory cursor.

Parameters
Pparticle set
bufAnonymous storage
fromscratchrequest recomputing the precision critical pieces of wavefunction from scratch
Returns
log value of the wavefunction.

Implements WaveFunctionComponent.

Definition at line 702 of file MultiSlaterDetTableMethod.cpp.

References MultiSlaterDetTableMethod::Dets, qmcplusplus::dot(), MultiSlaterDetTableMethod::evaluate_vgl_impl(), ParticleSet::G, ParticleSet::L, WaveFunctionComponent::log_value_, MultiSlaterDetTableMethod::myG, MultiSlaterDetTableMethod::myL, MultiSlaterDetTableMethod::psi_ratio_to_ref_det_, PooledMemory< T_scalar, Alloc >::put(), and MultiSlaterDetTableMethod::UpdateTimer.

705 {
706  ScopedTimer local_timer(UpdateTimer);
707 
708  for (size_t id = 0; id < Dets.size(); id++)
709  Dets[id]->updateBuffer(P, buf, fromscratch);
710 
712 
713  P.G += myG;
714  for (int i = 0; i < P.L.size(); i++)
715  P.L[i] += myL[i] - dot(myG[i], myG[i]);
716 
717  buf.put(log_value_);
718  buf.put(psi_ratio_to_ref_det_);
719 
720  return log_value_;
721 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
LogValue evaluate_vgl_impl(const ParticleSet &P, ParticleSet::ParticleGradient &g_tmp, ParticleSet::ParticleLaplacian &l_tmp)
Compute VGL of this MultiSlaterDetTableMethod.

Member Data Documentation

◆ AccRejTimer

◆ ActiveSpin

size_t ActiveSpin
private

Definition at line 301 of file MultiSlaterDetTableMethod.h.

◆ C

◆ C2node

std::shared_ptr<std::vector<std::vector<size_t> > > C2node
private

◆ C_otherDs

◆ CI_Optimizable

◆ csf_data_

◆ curRatio

◆ Dets

std::vector<std::unique_ptr<MultiDiracDeterminant> > Dets
private

determinant collection

Definition at line 275 of file MultiSlaterDetTableMethod.h.

Referenced by MultiSlaterDetTableMethod::acceptMove(), MultiSlaterDetTableMethod::acquireResource(), MultiSlaterDetTableMethod::buildOptVariables(), MultiSlaterDetTableMethod::calcIndividualDetRatios(), MultiSlaterDetTableMethod::checkOutVariables(), MultiSlaterDetTableMethod::computeRatio_NewMultiDet_to_NewRefDet(), MultiSlaterDetTableMethod::copyFromBuffer(), MultiSlaterDetTableMethod::createResource(), MultiSlaterDetTableMethod::evalGrad_impl(), MultiSlaterDetTableMethod::evalGrad_impl_no_precompute(), MultiSlaterDetTableMethod::evalGradWithSpin_impl(), MultiSlaterDetTableMethod::evalGradWithSpin_impl_no_precompute(), MultiSlaterDetTableMethod::evaluate_vgl_impl(), MultiSlaterDetTableMethod::evaluateDerivatives(), MultiSlaterDetTableMethod::evaluateDerivativesMSD(), MultiSlaterDetTableMethod::evaluateDerivRatios(), MultiSlaterDetTableMethod::evaluateLog(), MultiSlaterDetTableMethod::evaluateMultiDiracDeterminantDerivatives(), MultiSlaterDetTableMethod::evaluateMultiDiracDeterminantDerivativesWF(), MultiSlaterDetTableMethod::evaluateRatios(), MultiSlaterDetTableMethod::extract_DetRef_list(), MultiSlaterDetTableMethod::extractOptimizableObjectRefs(), MultiSlaterDetTableMethod::makeClone(), MultiSlaterDetTableMethod::MultiSlaterDetTableMethod(), MultiSlaterDetTableMethod::mw_accept_rejectMove(), MultiSlaterDetTableMethod::precomputeC_otherDs(), MultiSlaterDetTableMethod::ratio(), MultiSlaterDetTableMethod::ratioGrad(), MultiSlaterDetTableMethod::ratioGradWithSpin(), MultiSlaterDetTableMethod::registerData(), MultiSlaterDetTableMethod::releaseResource(), MultiSlaterDetTableMethod::restore(), and MultiSlaterDetTableMethod::updateBuffer().

◆ dGa

std::vector<Array<GradType, OHMMS_DIM> > dGa
private

Definition at line 315 of file MultiSlaterDetTableMethod.h.

◆ dLa

std::vector<Matrix<RealType> > dLa
private

Definition at line 314 of file MultiSlaterDetTableMethod.h.

◆ dpsia

std::vector<Matrix<RealType> > dpsia
private

Definition at line 314 of file MultiSlaterDetTableMethod.h.

◆ EvalGradTimer

◆ EvaluateTimer

NewTimer & EvaluateTimer

Definition at line 71 of file MultiSlaterDetTableMethod.h.

Referenced by MultiSlaterDetTableMethod::evaluateLog().

◆ gmPG

Definition at line 313 of file MultiSlaterDetTableMethod.h.

◆ laplSum

std::vector<ValueVector> laplSum
private

◆ Last

std::vector<int> Last
private

the last particle of each group

Definition at line 292 of file MultiSlaterDetTableMethod.h.

Referenced by MultiSlaterDetTableMethod::getDetID(), and MultiSlaterDetTableMethod::MultiSlaterDetTableMethod().

◆ mw_res_handle_

◆ myG

◆ myG_temp

◆ myL

◆ myL_temp

◆ myVars

◆ new_psi_ratio_to_new_ref_det_

PsiValue new_psi_ratio_to_new_ref_det_
private

◆ offload_timer

NewTimer & offload_timer

Definition at line 69 of file MultiSlaterDetTableMethod.h.

◆ PrepareGroupTimer

NewTimer& PrepareGroupTimer

◆ psi_ratio_to_ref_det_

◆ RatioGradTimer

◆ RatioTimer

◆ UpdateTimer

NewTimer & UpdateTimer

Definition at line 71 of file MultiSlaterDetTableMethod.h.

Referenced by MultiSlaterDetTableMethod::updateBuffer().

◆ use_pre_computing_

◆ qmcplusplus::J1OrbitalSoA

class qmcplusplus::J1OrbitalSoA

template<class FT>
class qmcplusplus::J1OrbitalSoA< FT >

Specialization for one-body Jastrow function using multiple functors.

Definition at line 46 of file J1OrbitalSoA.h.

+ Inheritance diagram for J1OrbitalSoA< FT >:
+ Collaboration diagram for J1OrbitalSoA< FT >:

Public Member Functions

 J1OrbitalSoA (const std::string &obj_name, const ParticleSet &ions, ParticleSet &els, bool use_offload)
 
 J1OrbitalSoA (const J1OrbitalSoA &rhs)=delete
 
 ~J1OrbitalSoA ()
 
std::string getClassName () const override
 return class name More...
 
void initialize (const ParticleSet &els)
 
void addFunc (int source_type, std::unique_ptr< FT > afunc, int target_type=-1)
 
void checkSanity () const override
 Validate the internal consistency of the object. More...
 
const auto & getFunctors () const
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 return a shared resource to a collection More...
 
void recompute (const ParticleSet &P) override
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch More...
 
void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi) override
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
 
void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const override
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios) override
 
GradType evalGrad (ParticleSet &P, int iat) override
 compute the gradient during particle-by-particle update More...
 
PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat) override
 compute the gradient during particle-by-particle update More...
 
void restore (int iat) override
 Rejected move. More...
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 Accpted move. More...
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
 For particle-by-particle move. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const override
 make clone More...
 
void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int isrc) override
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int isrc, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad) override
 Adds the gradient w.r.t. More...
 
bool isOptimizable () const override
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) override
 extract underlying OptimizableObject references More...
 
void checkOutVariables (const opt_variables_type &active) override
 check out variational optimizable variables More...
 
- Public Member Functions inherited from WaveFunctionComponent
const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
const std::string & getName () const
 return object name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual bool isFermionic () const
 true, if this component is fermionic More...
 
virtual bool isMultiDet () const
 true, if this component is multi-determinant More...
 
virtual void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
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 More...
 
virtual void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 
virtual void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
virtual GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad)
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
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 implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
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. More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
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 p-by-p move region. More...
 
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 More...
 
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 More...
 
virtual RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
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 optimizable parameters. More...
 
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. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void finalizeOptimization ()
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
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 More...
 
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 More...
 
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 More...
 
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 multiple walkers More...
 

Protected Attributes

std::vector< std::unique_ptr< FT > > J1UniqueFunctors
 container for the unique Jastrow functions More...
 
- Protected Attributes inherited from WaveFunctionComponent
const std::string my_name_
 Name of the object It is required to be different for objects of the same derived type like multiple J1. More...
 
LogValue log_value_
 Current $\log\phi $. More...
 

Private Types

using FuncType = FT
 alias FuncType More...
 
using valT = typename FT::real_type
 type of each component U, dU, d2U; More...
 
using posT = TinyVector< valT, OHMMS_DIM >
 element position type More...
 
using DistRow = DistanceTable::DistRow
 use the same container More...
 
using DisplRow = DistanceTable::DisplRow
 
using GradDerivVec = ParticleAttrib< QTFull::GradType >
 
using ValueDerivVec = ParticleAttrib< QTFull::ValueType >
 

Private Member Functions

void resizeWFOptVectors ()
 
QTFull::RealType computeGL (ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
 compute G and L from internally stored data More...
 
LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch=false) override
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
valT accumulateGL (const valT *restrict du, const valT *restrict d2u, const DisplRow &displ, posT &grad) const
 compute gradient and lap More...
 
valT computeU (const DistRow &dist)
 
void computeU3 (const ParticleSet &P, int iat, const DistRow &dist)
 compute U, dU and d2U More...
 

Private Attributes

const bool use_offload_
 if true use offload More...
 
const int myTableID
 table index More...
 
const int Nions
 number of ions More...
 
const int Nelec
 number of electrons More...
 
const int NumGroups
 number of ion groups More...
 
const ParticleSetIons
 reference to the sources (ions) More...
 
Vector< int, OffloadPinnedAllocator< int > > grp_ids
 the group_id of each particle More...
 
opt_variables_type myVars
 variables handled by this orbital More...
 
valT curAt
 
valT curLap
 
posT curGrad
 
Vector< valTVat
 $Vat[i] = sum_(j) u_{i,j}$ More...
 
aligned_vector< valTU
 
aligned_vector< valTdU
 
aligned_vector< valTd2U
 
aligned_vector< valTd3U
 
aligned_vector< valTDistCompressed
 
aligned_vector< int > DistIndice
 
Vector< posTGrad
 
Vector< valTLap
 
std::vector< FT * > J1Functors
 Container for $F[ig*NIons+jg]$. More...
 
std::vector< FT * > GroupFunctors
 functor for each ion group Conceptually, this is different from unique functions. More...
 
std::vector< std::pair< int, int > > OffSet
 
Vector< RealTypedLogPsi
 
std::vector< GradDerivVecgradLogPsi
 
std::vector< ValueDerivVeclapLogPsi
 
ResourceHandle< J1OrbitalSoAMultiWalkerMem< RealType > > mw_mem_handle_
 

Additional Inherited Members

- Public Types inherited from WaveFunctionComponent
enum  {
  ORB_PBYP_RATIO, ORB_PBYP_ALL, ORB_PBYP_PARTIAL, ORB_WALKER,
  ORB_ALLWALKER
}
 enum for a update mode More...
 
using Walker_t = ParticleSet::Walker_t
 
using WFBufferType = Walker_t::WFBuffer_t
 
using BufferType = Walker_t::Buffer_t
 
using RealMatrix_t = OrbitalSetTraits< RealType >::ValueMatrix
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using LogValue = std::complex< QTFull::RealType >
 
using PsiValue = QTFull::ValueType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 
- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 

Member Typedef Documentation

◆ DisplRow

Definition at line 56 of file J1OrbitalSoA.h.

◆ DistRow

use the same container

Definition at line 55 of file J1OrbitalSoA.h.

◆ FuncType

using FuncType = FT
private

alias FuncType

Definition at line 49 of file J1OrbitalSoA.h.

◆ GradDerivVec

Definition at line 58 of file J1OrbitalSoA.h.

◆ posT

using posT = TinyVector<valT, OHMMS_DIM>
private

element position type

Definition at line 53 of file J1OrbitalSoA.h.

◆ valT

using valT = typename FT::real_type
private

type of each component U, dU, d2U;

Definition at line 51 of file J1OrbitalSoA.h.

◆ ValueDerivVec

Definition at line 59 of file J1OrbitalSoA.h.

Constructor & Destructor Documentation

◆ J1OrbitalSoA() [1/2]

J1OrbitalSoA ( const std::string &  obj_name,
const ParticleSet ions,
ParticleSet els,
bool  use_offload 
)

Definition at line 48 of file J1OrbitalSoA.cpp.

References qmcplusplus::ALL_OFF, qmcplusplus::DC_POS_OFFLOAD, ParticleSet::first(), ParticleSet::getCoordinates(), DynamicCoordinates::getKind(), J1OrbitalSoA< FT >::grp_ids, J1OrbitalSoA< FT >::initialize(), ParticleSet::last(), WaveFunctionComponent::my_name_, qmcplusplus::NEED_VP_FULL_TABLE_ON_HOST, J1OrbitalSoA< FT >::Nions, J1OrbitalSoA< FT >::NumGroups, and J1OrbitalSoA< FT >::use_offload_.

49  : WaveFunctionComponent(obj_name),
50  use_offload_(use_offload),
51  myTableID(els.addTable(ions, use_offload ? DTModes::ALL_OFF : DTModes::NEED_VP_FULL_TABLE_ON_HOST)),
52  Nions(ions.getTotalNum()),
53  Nelec(els.getTotalNum()),
54  NumGroups(ions.groups()),
55  Ions(ions)
56 {
57  if (my_name_.empty())
58  throw std::runtime_error("J1OrbitalSoA object name cannot be empty!");
59 
60  if (use_offload_)
61  assert(ions.getCoordinates().getKind() == DynamicCoordinateKind::DC_POS_OFFLOAD);
62 
63  initialize(els);
64 
65  // set up grp_ids
66  grp_ids.resize(Nions);
67  int count = 0;
68  for (int ig = 0; ig < NumGroups; ig++)
69  for (int j = ions.first(ig); j < ions.last(ig); j++)
70  grp_ids[count++] = ig;
71  assert(count == Nions);
72  grp_ids.updateTo();
73 }
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
const int NumGroups
number of ion groups
Definition: J1OrbitalSoA.h:71
For distance tables of virtual particle (VP) sets constructed based on this table, whether full table is needed on host The corresponding DT of VP need to set MW_EVALUATE_RESULT_NO_TRANSFER_TO_HOST accordingly.
const bool use_offload_
if true use offload
Definition: J1OrbitalSoA.h:62
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
void initialize(const ParticleSet &els)
Definition: J1OrbitalSoA.h:202
const int Nions
number of ions
Definition: J1OrbitalSoA.h:67
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1OrbitalSoA.h:73
Vector< int, OffloadPinnedAllocator< int > > grp_ids
the group_id of each particle
Definition: J1OrbitalSoA.h:75
WaveFunctionComponent(const std::string &obj_name="")
default constructor
const int myTableID
table index
Definition: J1OrbitalSoA.h:65

◆ J1OrbitalSoA() [2/2]

J1OrbitalSoA ( const J1OrbitalSoA< FT > &  rhs)
delete

◆ ~J1OrbitalSoA()

~J1OrbitalSoA ( )
default

Member Function Documentation

◆ acceptMove()

void acceptMove ( ParticleSet P,
int  iat,
bool  safe_to_delay = false 
)
inlineoverridevirtual

Accpted move.

Update Vat[iat],Grad[iat] and Lap[iat]

Implements WaveFunctionComponent.

Definition at line 458 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::accumulateGL(), J1OrbitalSoA< FT >::computeU3(), J1OrbitalSoA< FT >::curAt, J1OrbitalSoA< FT >::curGrad, J1OrbitalSoA< FT >::curLap, J1OrbitalSoA< FT >::d2U, J1OrbitalSoA< FT >::dU, ParticleSet::getDistTableAB(), DistanceTableAB::getTempDispls(), DistanceTableAB::getTempDists(), J1OrbitalSoA< FT >::Grad, J1OrbitalSoA< FT >::Lap, WaveFunctionComponent::log_value_, J1OrbitalSoA< FT >::myTableID, WaveFunctionComponent::ORB_PBYP_RATIO, WaveFunctionComponent::UpdateMode, and J1OrbitalSoA< FT >::Vat.

459  {
460  if (UpdateMode == ORB_PBYP_RATIO)
461  {
462  computeU3(P, iat, P.getDistTableAB(myTableID).getTempDists());
463  curLap = accumulateGL(dU.data(), d2U.data(), P.getDistTableAB(myTableID).getTempDispls(), curGrad);
464  }
465 
466  log_value_ += Vat[iat] - curAt;
467  Vat[iat] = curAt;
468  Grad[iat] = curGrad;
469  Lap[iat] = curLap;
470  }
aligned_vector< valT > dU
Definition: J1OrbitalSoA.h:86
valT accumulateGL(const valT *restrict du, const valT *restrict d2u, const DisplRow &displ, posT &grad) const
compute gradient and lap
Definition: J1OrbitalSoA.h:136
const int myTableID
table index
Definition: J1OrbitalSoA.h:65
aligned_vector< valT > d2U
Definition: J1OrbitalSoA.h:86
void computeU3(const ParticleSet &P, int iat, const DistRow &dist)
compute U, dU and d2U
Definition: J1OrbitalSoA.h:172

◆ accumulateGL()

valT accumulateGL ( const valT *restrict  du,
const valT *restrict  d2u,
const DisplRow displ,
posT grad 
) const
inlineprivate

compute gradient and lap

Returns
lap

Definition at line 136 of file J1OrbitalSoA.h.

References VectorSoaContainer< T, D, Alloc >::data(), J1OrbitalSoA< FT >::Nions, OHMMS_DIM, and qmcplusplus::Units::time::s.

Referenced by J1OrbitalSoA< FT >::acceptMove(), J1OrbitalSoA< FT >::ratioGrad(), and J1OrbitalSoA< FT >::recompute().

137  {
138  valT lap(0);
139  constexpr valT lapfac = OHMMS_DIM - RealType(1);
140  //#pragma omp simd reduction(+:lap)
141  for (int jat = 0; jat < Nions; ++jat)
142  lap += d2u[jat] + lapfac * du[jat];
143  for (int idim = 0; idim < OHMMS_DIM; ++idim)
144  {
145  const valT* restrict dX = displ.data(idim);
146  valT s = valT();
147  //#pragma omp simd reduction(+:s)
148  for (int jat = 0; jat < Nions; ++jat)
149  s += du[jat] * dX[jat];
150  grad[idim] = s;
151  }
152  return lap;
153  }
QTBase::RealType RealType
Definition: Configuration.h:58
#define OHMMS_DIM
Definition: config.h:64
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1OrbitalSoA.h:51
const int Nions
number of ions
Definition: J1OrbitalSoA.h:67

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
overridevirtual

acquire a shared resource from a collection

Reimplemented from WaveFunctionComponent.

Definition at line 94 of file J1OrbitalSoA.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), ResourceCollection::lendResource(), and J1OrbitalSoA< FT >::mw_mem_handle_.

96 {
97  auto& wfc_leader = wfc_list.getCastedLeader<J1OrbitalSoA<FT>>();
98  wfc_leader.mw_mem_handle_ = collection.lendResource<J1OrbitalSoAMultiWalkerMem<RealType>>();
99 }

◆ addFunc()

void addFunc ( int  source_type,
std::unique_ptr< FT >  afunc,
int  target_type = -1 
)
inline

Definition at line 219 of file J1OrbitalSoA.h.

References ParticleSet::getGroupID(), J1OrbitalSoA< FT >::GroupFunctors, J1OrbitalSoA< FT >::Ions, J1OrbitalSoA< FT >::J1Functors, and J1OrbitalSoA< FT >::J1UniqueFunctors.

220  {
221  for (int i = 0; i < J1Functors.size(); i++)
222  if (Ions.getGroupID(i) == source_type)
223  J1Functors[i] = afunc.get();
224  GroupFunctors[source_type] = afunc.get();
225  J1UniqueFunctors[source_type] = std::move(afunc);
226  }
std::vector< FT * > GroupFunctors
functor for each ion group Conceptually, this is different from unique functions. ...
Definition: J1OrbitalSoA.h:98
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1OrbitalSoA.h:73
std::vector< FT * > J1Functors
Container for .
Definition: J1OrbitalSoA.h:92
int getGroupID(int iat) const
return the group id of a given particle in the particle set.
Definition: ParticleSet.h:520

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
inlineoverridevirtual

check out variational optimizable variables

Parameters
activea super set of optimizable variables

Reimplemented from WaveFunctionComponent.

Definition at line 533 of file J1OrbitalSoA.h.

References VariableSet::clear(), VariableSet::getIndex(), VariableSet::Index, VariableSet::insertFrom(), J1OrbitalSoA< FT >::J1Functors, J1OrbitalSoA< FT >::J1UniqueFunctors, J1OrbitalSoA< FT >::myVars, qmcplusplus::n, J1OrbitalSoA< FT >::OffSet, and VariableSet::size().

534  {
535  myVars.clear();
536  for (int i = 0; i < J1UniqueFunctors.size(); ++i)
537  {
538  if (J1UniqueFunctors[i])
539  {
540  J1UniqueFunctors[i]->myVars.getIndex(active);
542  }
543  }
544  myVars.getIndex(active);
545  const size_t NumVars = myVars.size();
546  if (NumVars)
547  {
548  OffSet.resize(J1Functors.size());
549  int varoffset = myVars.Index[0];
550  for (int i = 0; i < J1Functors.size(); ++i)
551  {
552  if (J1Functors[i] != nullptr)
553  {
554  OffSet[i].first = J1Functors[i]->myVars.Index.front() - varoffset;
555  OffSet[i].second = J1Functors[i]->myVars.Index.size() + OffSet[i].first;
556  }
557  }
558  }
559  for (size_t i = 0, n = J1UniqueFunctors.size(); i < n; ++i)
560  if (J1UniqueFunctors[i] != nullptr)
561  J1UniqueFunctors[i]->checkOutVariables(active);
562  }
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
std::vector< std::pair< int, int > > OffSet
Definition: J1OrbitalSoA.h:100
std::vector< int > Index
store locator of the named variable
Definition: VariableSet.h:65
opt_variables_type myVars
variables handled by this orbital
Definition: J1OrbitalSoA.h:78
void clear()
clear the variable set
Definition: VariableSet.cpp:28
size_type size() const
return the size
Definition: VariableSet.h:88
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
Definition: VariableSet.cpp:37
std::vector< FT * > J1Functors
Container for .
Definition: J1OrbitalSoA.h:92
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter

◆ checkSanity()

void checkSanity ( ) const
overridevirtual

Validate the internal consistency of the object.

Reimplemented from WaveFunctionComponent.

Definition at line 79 of file J1OrbitalSoA.cpp.

References qmcplusplus::app_warning().

80 {
81  if (std::any_of(J1Functors.begin(), J1Functors.end(), [](auto* ptr) { return ptr == nullptr; }))
82  app_warning() << "One-body Jastrow \"" << my_name_ << "\" doesn't cover all the particle pairs. "
83  << "Consider fusing multiple entries if they are of the same type for optimal code performance."
84  << std::endl;
85 }
std::ostream & app_warning()
Definition: OutputManager.h:69
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
std::vector< FT * > J1Functors
Container for .
Definition: J1OrbitalSoA.h:92

◆ computeGL()

QTFull::RealType computeGL ( ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
) const
inlineprivate

compute G and L from internally stored data

Definition at line 115 of file J1OrbitalSoA.h.

References qmcplusplus::simd::accumulate_n(), Vector< T, Alloc >::data(), J1OrbitalSoA< FT >::Grad, J1OrbitalSoA< FT >::Lap, J1OrbitalSoA< FT >::Nelec, and J1OrbitalSoA< FT >::Vat.

Referenced by J1OrbitalSoA< FT >::evaluateGL(), J1OrbitalSoA< FT >::evaluateLog(), and J1OrbitalSoA< FT >::updateBuffer().

116  {
117  for (size_t iat = 0; iat < Nelec; ++iat)
118  {
119  G[iat] += Grad[iat];
120  L[iat] -= Lap[iat];
121  }
123  }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
Precision RealType
Definition: QMCTypes.h:37

◆ computeU()

valT computeU ( const DistRow dist)
inlineprivate

Definition at line 155 of file J1OrbitalSoA.h.

References Vector< T, Alloc >::data(), J1OrbitalSoA< FT >::DistCompressed, ParticleSet::first(), J1OrbitalSoA< FT >::Ions, J1OrbitalSoA< FT >::J1UniqueFunctors, ParticleSet::last(), and J1OrbitalSoA< FT >::NumGroups.

Referenced by J1OrbitalSoA< FT >::evaluateRatios(), and J1OrbitalSoA< FT >::ratio().

156  {
157  valT curVat(0);
158  for (int jg = 0; jg < NumGroups; ++jg)
159  {
160  if (J1UniqueFunctors[jg] != nullptr)
161  curVat +=
162  J1UniqueFunctors[jg]->evaluateV(-1, Ions.first(jg), Ions.last(jg), dist.data(), DistCompressed.data());
163  }
164  return curVat;
165  }
const int NumGroups
number of ion groups
Definition: J1OrbitalSoA.h:71
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
aligned_vector< valT > DistCompressed
Definition: J1OrbitalSoA.h:87
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1OrbitalSoA.h:51
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1OrbitalSoA.h:73

◆ computeU3()

void computeU3 ( const ParticleSet P,
int  iat,
const DistRow dist 
)
inlineprivate

compute U, dU and d2U

Parameters
Pquantum particleset
iatthe moving particle
diststarting address of the distances of the ions wrt the iat-th particle

Definition at line 172 of file J1OrbitalSoA.h.

References BLAS::czero, J1OrbitalSoA< FT >::d2U, Vector< T, Alloc >::data(), J1OrbitalSoA< FT >::DistCompressed, J1OrbitalSoA< FT >::DistIndice, J1OrbitalSoA< FT >::dU, OMPstd::fill_n(), ParticleSet::first(), J1OrbitalSoA< FT >::Ions, J1OrbitalSoA< FT >::J1UniqueFunctors, ParticleSet::last(), J1OrbitalSoA< FT >::Nions, J1OrbitalSoA< FT >::NumGroups, and J1OrbitalSoA< FT >::U.

Referenced by J1OrbitalSoA< FT >::acceptMove(), J1OrbitalSoA< FT >::ratioGrad(), and J1OrbitalSoA< FT >::recompute().

173  {
174  constexpr valT czero(0);
175  std::fill_n(U.data(), Nions, czero);
176  std::fill_n(dU.data(), Nions, czero);
177  std::fill_n(d2U.data(), Nions, czero);
178 
179  for (int jg = 0; jg < NumGroups; ++jg)
180  {
181  if (J1UniqueFunctors[jg] == nullptr)
182  continue;
183  J1UniqueFunctors[jg]->evaluateVGL(-1, Ions.first(jg), Ions.last(jg), dist.data(), U.data(), dU.data(), d2U.data(),
184  DistCompressed.data(), DistIndice.data());
185  }
186  }
const int NumGroups
number of ion groups
Definition: J1OrbitalSoA.h:71
void fill_n(T *x, size_t count, const T &value)
Definition: OMPstd.hpp:21
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
aligned_vector< valT > DistCompressed
Definition: J1OrbitalSoA.h:87
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
aligned_vector< valT > dU
Definition: J1OrbitalSoA.h:86
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1OrbitalSoA.h:51
aligned_vector< int > DistIndice
Definition: J1OrbitalSoA.h:88
const int Nions
number of ions
Definition: J1OrbitalSoA.h:67
aligned_vector< valT > U
Definition: J1OrbitalSoA.h:86
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1OrbitalSoA.h:73
aligned_vector< valT > d2U
Definition: J1OrbitalSoA.h:86

◆ copyFromBuffer()

void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)
inlineoverridevirtual

For particle-by-particle move.

Copy data or attach memory from a walker buffer to the objects of this class. The log value, P.G and P.L contribution from the objects of this class are also added.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 500 of file J1OrbitalSoA.h.

References Vector< T, Alloc >::attachReference(), J1OrbitalSoA< FT >::Grad, J1OrbitalSoA< FT >::Lap, PooledMemory< T_scalar, Alloc >::lendReference(), J1OrbitalSoA< FT >::Nelec, and J1OrbitalSoA< FT >::Vat.

501  {
502  Vat.attachReference(buf.lendReference<valT>(Nelec), Nelec);
503  Grad.attachReference(buf.lendReference<posT>(Nelec), Nelec);
504  Lap.attachReference(buf.lendReference<valT>(Nelec), Nelec);
505  }
TinyVector< valT, OHMMS_DIM > posT
element position type
Definition: J1OrbitalSoA.h:53
void attachReference(T *ref, size_type n)
Definition: OhmmsVector.h:131
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1OrbitalSoA.h:51

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 88 of file J1OrbitalSoA.cpp.

References ResourceCollection::addResource().

89 {
90  collection.addResource(std::make_unique<J1OrbitalSoAMultiWalkerMem<RealType>>());
91 }

◆ evalGrad()

GradType evalGrad ( ParticleSet P,
int  iat 
)
inlineoverridevirtual

compute the gradient during particle-by-particle update

Parameters
Pquantum particleset
iatparticle index

Reimplemented from WaveFunctionComponent.

Definition at line 435 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::Grad.

435 { return GradType(Grad[iat]); }
QTBase::GradType GradType
Definition: Configuration.h:62

◆ evalGradSource() [1/2]

GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat 
)
inlineoverridevirtual

return the logarithmic gradient for the iat-th particle of the source particleset

Parameters
Pquantumparticle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented from WaveFunctionComponent.

Definition at line 626 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::d2U, J1OrbitalSoA< FT >::d3U, J1OrbitalSoA< FT >::dU, ParticleSet::getDistTableAB(), ParticleSet::getGroupID(), J1OrbitalSoA< FT >::J1UniqueFunctors, J1OrbitalSoA< FT >::myTableID, J1OrbitalSoA< FT >::Nelec, and J1OrbitalSoA< FT >::U.

627  {
628  GradType g_return(0.0);
629  const auto& d_ie(P.getDistTableAB(myTableID));
630  for (int iat = 0; iat < Nelec; ++iat)
631  {
632  const auto& dist = d_ie.getDistRow(iat);
633  const auto& displ = d_ie.getDisplRow(iat);
634  int gid = source.getGroupID(isrc);
635  RealType r = dist[isrc];
636  RealType rinv = 1.0 / r;
637  PosType dr = displ[isrc];
638 
639  if (J1UniqueFunctors[gid] != nullptr)
640  {
641  U[isrc] = J1UniqueFunctors[gid]->evaluate(dist[isrc], dU[isrc], d2U[isrc], d3U[isrc]);
642  g_return -= dU[isrc] * rinv * dr;
643  }
644  }
645  return g_return;
646  }
QTBase::GradType GradType
Definition: Configuration.h:62
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
QMCTraits::PosType PosType
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
aligned_vector< valT > dU
Definition: J1OrbitalSoA.h:86
aligned_vector< valT > U
Definition: J1OrbitalSoA.h:86
QMCTraits::RealType RealType
aligned_vector< valT > d3U
Definition: J1OrbitalSoA.h:86
const int myTableID
table index
Definition: J1OrbitalSoA.h:65
aligned_vector< valT > d2U
Definition: J1OrbitalSoA.h:86

◆ evalGradSource() [2/2]

GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat,
TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &  grad_grad,
TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &  lapl_grad 
)
inlineoverridevirtual

Adds the gradient w.r.t.

the iat-th particle of the source particleset (ions) of the logarithmic gradient and laplacian w.r.t. the target paritlceset (electrons).

Parameters
Pquantum particle set (electrons)
sourceclassical particle set (ions)
iatparticle index of source (ion)
theion gradient of the elctron gradient
theion gradient of the elctron laplacian.
Returns
the log gradient of psi w.r.t. the source particle iat

Reimplemented from WaveFunctionComponent.

Definition at line 648 of file J1OrbitalSoA.h.

References APP_ABORT, J1OrbitalSoA< FT >::d2U, J1OrbitalSoA< FT >::d3U, J1OrbitalSoA< FT >::dU, ParticleSet::getDistTableAB(), ParticleSet::getGroupID(), J1OrbitalSoA< FT >::J1UniqueFunctors, J1OrbitalSoA< FT >::myTableID, J1OrbitalSoA< FT >::Nelec, OHMMS_DIM, and J1OrbitalSoA< FT >::U.

653  {
654  GradType g_return(0.0);
655  const auto& d_ie(P.getDistTableAB(myTableID));
656  for (int iat = 0; iat < Nelec; ++iat)
657  {
658  const auto& dist = d_ie.getDistRow(iat);
659  const auto& displ = d_ie.getDisplRow(iat);
660  int gid = source.getGroupID(isrc);
661  RealType r = dist[isrc];
662  RealType rinv = 1.0 / r;
663  PosType dr = displ[isrc];
664 
665  if (J1UniqueFunctors[gid] != nullptr)
666  {
667  U[isrc] = J1UniqueFunctors[gid]->evaluate(dist[isrc], dU[isrc], d2U[isrc], d3U[isrc]);
668  }
669  else
670  {
671  APP_ABORT("J1OrbitalSoa::evaluateGradSource: J1UniqueFunctors[gid]==nullptr")
672  }
673 
674  g_return -= dU[isrc] * rinv * dr;
675 
676  //The following terms depend only on the radial component r. Thus,
677  //we compute them and mix with position vectors to acquire the full
678  //cartesian vector objects.
679  valT grad_component = (d2U[isrc] - dU[isrc] * rinv);
680  valT lapl_component = d3U[isrc] + 2 * rinv * grad_component;
681 
682  for (int idim = 0; idim < OHMMS_DIM; idim++)
683  {
684  grad_grad[idim][iat] += dr[idim] * dr * rinv * rinv * grad_component;
685  grad_grad[idim][iat][idim] += rinv * dU[isrc];
686 
687  lapl_grad[idim][iat] -= lapl_component * rinv * dr[idim];
688  }
689  }
690  return g_return;
691  }
QTBase::GradType GradType
Definition: Configuration.h:62
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
#define OHMMS_DIM
Definition: config.h:64
QMCTraits::PosType PosType
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
aligned_vector< valT > dU
Definition: J1OrbitalSoA.h:86
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1OrbitalSoA.h:51
aligned_vector< valT > U
Definition: J1OrbitalSoA.h:86
QMCTraits::RealType RealType
aligned_vector< valT > d3U
Definition: J1OrbitalSoA.h:86
const int myTableID
table index
Definition: J1OrbitalSoA.h:65
aligned_vector< valT > d2U
Definition: J1OrbitalSoA.h:86

◆ evaluateDerivatives()

void evaluateDerivatives ( ParticleSet P,
const opt_variables_type active,
Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
inlineoverride

Definition at line 305 of file J1OrbitalSoA.h.

References qmcplusplus::Dot(), J1OrbitalSoA< FT >::evaluateDerivativesWF(), ParticleSet::G, J1OrbitalSoA< FT >::gradLogPsi, J1OrbitalSoA< FT >::lapLogPsi, J1OrbitalSoA< FT >::myVars, VariableSet::recompute(), VariableSet::size(), qmcplusplus::Sum(), and VariableSet::where().

309  {
310  evaluateDerivativesWF(P, active, dlogpsi);
311  bool recalculate(false);
312  std::vector<bool> rcsingles(myVars.size(), false);
313  for (int k = 0; k < myVars.size(); ++k)
314  {
315  int kk = myVars.where(k);
316  if (kk < 0)
317  continue;
318  if (active.recompute(kk))
319  recalculate = true;
320  rcsingles[k] = true;
321  }
322  if (recalculate)
323  {
324  for (int k = 0; k < myVars.size(); ++k)
325  {
326  int kk = myVars.where(k);
327  if (kk < 0)
328  continue;
329  if (rcsingles[k])
330  {
331  dhpsioverpsi[kk] = -RealType(0.5) * ValueType(Sum(lapLogPsi[k])) - ValueType(Dot(P.G, gradLogPsi[k]));
332  }
333  }
334  }
335  }
T Sum(const ParticleAttrib< T > &pa)
QTBase::RealType RealType
Definition: Configuration.h:58
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
std::vector< ValueDerivVec > lapLogPsi
Definition: J1OrbitalSoA.h:103
opt_variables_type myVars
variables handled by this orbital
Definition: J1OrbitalSoA.h:78
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
Definition: J1OrbitalSoA.h:337
QTBase::ValueType ValueType
Definition: Configuration.h:60
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_type size() const
return the size
Definition: VariableSet.h:88
std::vector< GradDerivVec > gradLogPsi
Definition: J1OrbitalSoA.h:102

◆ evaluateDerivativesWF()

void evaluateDerivativesWF ( ParticleSet P,
const opt_variables_type active,
Vector< ValueType > &  dlogpsi 
)
inlineoverride

Definition at line 337 of file J1OrbitalSoA.h.

References BLAS::cone, J1OrbitalSoA< FT >::dLogPsi, DistanceTableAB::getDisplRow(), DistanceTableAB::getDistRow(), ParticleSet::getDistTableAB(), ParticleSet::getTotalNum(), J1OrbitalSoA< FT >::gradLogPsi, J1OrbitalSoA< FT >::J1Functors, J1OrbitalSoA< FT >::lapLogPsi, J1OrbitalSoA< FT >::myTableID, J1OrbitalSoA< FT >::myVars, qmcplusplus::Units::time::ns, J1OrbitalSoA< FT >::OffSet, OHMMS_DIM, VariableSet::recompute(), J1OrbitalSoA< FT >::resizeWFOptVectors(), qmcplusplus::Units::second, VariableSet::size(), and VariableSet::where().

Referenced by J1OrbitalSoA< FT >::evaluateDerivatives().

338  {
340  bool recalculate(false);
341  std::vector<bool> rcsingles(myVars.size(), false);
342  for (int k = 0; k < myVars.size(); ++k)
343  {
344  int kk = myVars.where(k);
345  if (kk < 0)
346  continue;
347  if (active.recompute(kk))
348  recalculate = true;
349  rcsingles[k] = true;
350  }
351  if (recalculate)
352  {
353  const size_t NumVars = myVars.size();
354  for (int p = 0; p < NumVars; ++p)
355  {
356  gradLogPsi[p] = 0.0;
357  lapLogPsi[p] = 0.0;
358  }
359  dLogPsi = 0.0;
360 
361  const auto& d_table = P.getDistTableAB(myTableID);
362  std::vector<TinyVector<RealType, 3>> derivs(NumVars);
363 
364  constexpr RealType cone(1);
365  constexpr RealType lapfac(OHMMS_DIM - cone);
366  const size_t ns = d_table.sources();
367  const size_t nt = P.getTotalNum();
368 
369  aligned_vector<int> iadj(nt);
370  aligned_vector<RealType> dist(nt);
371  std::vector<PosType> displ(nt);
372 
373  for (size_t i = 0; i < ns; ++i)
374  {
375  FT* func = J1Functors[i];
376  if (func == nullptr)
377  continue;
378  int first(OffSet[i].first);
379  int last(OffSet[i].second);
380  bool recalcFunc(false);
381  for (int rcs = first; rcs < last; rcs++)
382  if (rcsingles[rcs] == true)
383  recalcFunc = true;
384  if (recalcFunc)
385  {
386  for (size_t j = 0; j < nt; ++j)
387  {
388  std::fill(derivs.begin(), derivs.end(), 0);
389  auto dist = P.getDistTableAB(myTableID).getDistRow(j)[i];
390  if (!func->evaluateDerivatives(dist, derivs))
391  continue;
392  RealType rinv(cone / dist);
393  const PosType& dr = P.getDistTableAB(myTableID).getDisplRow(j)[i];
394  for (int p = first, ip = 0; p < last; ++p, ++ip)
395  {
396  dLogPsi[p] -= derivs[ip][0];
397  RealType dudr(rinv * derivs[ip][1]);
398  gradLogPsi[p][j] += dudr * dr;
399  lapLogPsi[p][j] -= derivs[ip][2] + lapfac * dudr;
400  }
401  }
402  }
403  }
404  for (int k = 0; k < myVars.size(); ++k)
405  {
406  int kk = myVars.where(k);
407  if (kk < 0)
408  continue;
409  if (rcsingles[k])
410  {
411  dlogpsi[kk] = ValueType(dLogPsi[k]);
412  }
413  }
414  }
415  }
constexpr std::complex< float > cone
Definition: BLAS.hpp:50
std::vector< std::pair< int, int > > OffSet
Definition: J1OrbitalSoA.h:100
#define OHMMS_DIM
Definition: config.h:64
std::vector< ValueDerivVec > lapLogPsi
Definition: J1OrbitalSoA.h:103
opt_variables_type myVars
variables handled by this orbital
Definition: J1OrbitalSoA.h:78
QMCTraits::PosType PosType
QTBase::ValueType ValueType
Definition: Configuration.h:60
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_type size() const
return the size
Definition: VariableSet.h:88
QMCTraits::RealType RealType
Vector< RealType > dLogPsi
Definition: J1OrbitalSoA.h:101
std::vector< GradDerivVec > gradLogPsi
Definition: J1OrbitalSoA.h:102
std::vector< FT * > J1Functors
Container for .
Definition: J1OrbitalSoA.h:92
const int myTableID
table index
Definition: J1OrbitalSoA.h:65

◆ evaluateDerivRatios()

void evaluateDerivRatios ( const VirtualParticleSet VP,
const opt_variables_type optvars,
std::vector< ValueType > &  ratios,
Matrix< ValueType > &  dratios 
)
inlineoverride

Definition at line 566 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::evaluateRatios(), DistanceTableAB::getDistRow(), ParticleSet::getDistTableAB(), VirtualParticleSet::getRefPS(), VirtualParticleSet::getTotalNum(), J1OrbitalSoA< FT >::J1Functors, J1OrbitalSoA< FT >::myTableID, J1OrbitalSoA< FT >::myVars, qmcplusplus::Units::time::ns, J1OrbitalSoA< FT >::OffSet, VariableSet::recompute(), VirtualParticleSet::refPtcl, qmcplusplus::Units::second, VariableSet::size(), and VariableSet::where().

570  {
571  evaluateRatios(VP, ratios);
572  bool recalculate(false);
573  std::vector<bool> rcsingles(myVars.size(), false);
574  for (int k = 0; k < myVars.size(); ++k)
575  {
576  const int kk = myVars.where(k);
577  if (kk < 0)
578  continue;
579  if (optvars.recompute(kk))
580  recalculate = true;
581  rcsingles[k] = true;
582  }
583 
584  if (recalculate)
585  {
586  const size_t NumVars = myVars.size();
587  const auto& d_table = VP.getDistTableAB(myTableID);
588  std::vector<RealType> derivs_ref(NumVars);
589  std::vector<RealType> derivs(NumVars);
590 
591  const size_t ns = d_table.sources();
592  const size_t nt = VP.getTotalNum();
593 
594  const auto& dist_ref = VP.getRefPS().getDistTableAB(myTableID).getDistRow(VP.refPtcl);
595 
596  for (size_t i = 0; i < ns; ++i)
597  {
598  FT* func = J1Functors[i];
599  if (func == nullptr)
600  continue;
601  int first(OffSet[i].first);
602  int last(OffSet[i].second);
603  bool recalcFunc(false);
604  for (int rcs = first; rcs < last; rcs++)
605  if (rcsingles[rcs] == true)
606  recalcFunc = true;
607  if (recalcFunc)
608  {
609  //first calculate the old derivatives VP.refPctl.
610  std::fill(derivs_ref.begin(), derivs_ref.end(), 0);
611  func->evaluateDerivatives(dist_ref[i], derivs_ref);
612  for (size_t j = 0; j < nt; ++j)
613  {
614  std::fill(derivs.begin(), derivs.end(), 0);
615  //first calculate the new derivatives
616  func->evaluateDerivatives(VP.getDistTableAB(myTableID).getDistRow(j)[i], derivs);
617  //compute the new derivatives - old derivatives
618  for (int ip = 0, p = func->myVars.Index.front(); ip < func->myVars.Index.size(); ++ip, ++p)
619  dratios[j][p] += derivs_ref[ip] - derivs[ip];
620  }
621  }
622  }
623  }
624  }
std::vector< std::pair< int, int > > OffSet
Definition: J1OrbitalSoA.h:100
opt_variables_type myVars
variables handled by this orbital
Definition: J1OrbitalSoA.h:78
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_type size() const
return the size
Definition: VariableSet.h:88
void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
Definition: J1OrbitalSoA.h:295
std::vector< FT * > J1Functors
Container for .
Definition: J1OrbitalSoA.h:92
const int myTableID
table index
Definition: J1OrbitalSoA.h:65

◆ evaluateGL()

LogValue evaluateGL ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L,
bool  fromscratch = false 
)
inlineoverrideprivatevirtual

compute gradients and laplacian of the TWF with respect to each particle.

Parameters
Pparticle set
GGradients, $\nabla\ln\Psi$
LLaplacians, $\nabla^2\ln\Psi$
fromscratchif true and this WFC is sensitive to numeical error accumulation, all the internal data are recomputed from scratch.
Returns
log(psi)

Reimplemented from WaveFunctionComponent.

Definition at line 125 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::computeGL(), and WaveFunctionComponent::log_value_.

129  {
130  return log_value_ = computeGL(G, L);
131  }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
Definition: J1OrbitalSoA.h:115

◆ evaluateHessian()

void evaluateHessian ( ParticleSet P,
HessVector grad_grad_psi 
)
inlineoverridevirtual

Reimplemented from WaveFunctionComponent.

Definition at line 259 of file J1OrbitalSoA.h.

References Tensor< T, D >::diagonal(), ParticleSet::getDistTableAB(), ParticleSet::getGroupID(), J1OrbitalSoA< FT >::Ions, J1OrbitalSoA< FT >::J1UniqueFunctors, J1OrbitalSoA< FT >::myTableID, J1OrbitalSoA< FT >::Nelec, J1OrbitalSoA< FT >::Nions, and qmcplusplus::outerProduct().

260  {
261  const auto& d_ie(P.getDistTableAB(myTableID));
262  valT dudr, d2udr2;
263 
264  Tensor<valT, DIM> ident;
265  grad_grad_psi = 0.0;
266  ident.diagonal(1.0);
267 
268  for (int iel = 0; iel < Nelec; ++iel)
269  {
270  const auto& dist = d_ie.getDistRow(iel);
271  const auto& displ = d_ie.getDisplRow(iel);
272  for (int iat = 0; iat < Nions; iat++)
273  {
274  int gid = Ions.getGroupID(iat);
275  auto* func = J1UniqueFunctors[gid].get();
276  if (func != nullptr)
277  {
278  RealType r = dist[iat];
279  RealType rinv = 1.0 / r;
280  PosType dr = displ[iat];
281  func->evaluate(r, dudr, d2udr2);
282  grad_grad_psi[iel] -= rinv * rinv * outerProduct(dr, dr) * (d2udr2 - dudr * rinv) + ident * dudr * rinv;
283  }
284  }
285  }
286  }
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
QMCTraits::PosType PosType
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > outerProduct(const TinyVector< T1, D > &lhs, const TinyVector< T2, D > &rhs)
Definition: TinyVector.h:211
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1OrbitalSoA.h:51
const int Nions
number of ions
Definition: J1OrbitalSoA.h:67
QMCTraits::RealType RealType
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1OrbitalSoA.h:73
const int myTableID
table index
Definition: J1OrbitalSoA.h:65
int getGroupID(int iat) const
return the group id of a given particle in the particle set.
Definition: ParticleSet.h:520

◆ evaluateLog()

LogValue evaluateLog ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
)
inlineoverridevirtual

evaluate the value of the WaveFunctionComponent from scratch

Parameters
[in]Pactive ParticleSet
[out]GGradients, $\nabla\ln\Psi$
[out]LLaplacians, $\nabla^2\ln\Psi$
Returns
the log value

Mainly for walker-by-walker move. The initial stage of particle-by-particle move also uses this. causes complete state update in WFC's

Implements WaveFunctionComponent.

Definition at line 251 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::computeGL(), WaveFunctionComponent::log_value_, and J1OrbitalSoA< FT >::recompute().

254  {
255  recompute(P);
256  return log_value_ = computeGL(G, L);
257  }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
Definition: J1OrbitalSoA.h:115
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
Definition: J1OrbitalSoA.h:240

◆ evaluateRatios()

void evaluateRatios ( const VirtualParticleSet VP,
std::vector< ValueType > &  ratios 
)
inlineoverride

Definition at line 295 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::computeU(), qmcplusplus::exp(), DistanceTableAB::getDistRow(), ParticleSet::getDistTableAB(), J1OrbitalSoA< FT >::myTableID, VirtualParticleSet::refPtcl, and J1OrbitalSoA< FT >::Vat.

Referenced by J1OrbitalSoA< FT >::evaluateDerivRatios().

296  {
297  for (int k = 0; k < ratios.size(); ++k)
298  ratios[k] = std::exp(Vat[VP.refPtcl] - computeU(VP.getDistTableAB(myTableID).getDistRow(k)));
299  }
valT computeU(const DistRow &dist)
Definition: J1OrbitalSoA.h:155
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
const int myTableID
table index
Definition: J1OrbitalSoA.h:65

◆ evaluateRatiosAlltoOne()

void evaluateRatiosAlltoOne ( ParticleSet P,
std::vector< ValueType > &  ratios 
)
inlineoverride

Definition at line 417 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::curAt, J1OrbitalSoA< FT >::DistCompressed, qmcplusplus::exp(), ParticleSet::first(), ParticleSet::getDistTableAB(), DistanceTableAB::getTempDists(), J1OrbitalSoA< FT >::Ions, J1OrbitalSoA< FT >::J1UniqueFunctors, ParticleSet::last(), J1OrbitalSoA< FT >::myTableID, J1OrbitalSoA< FT >::Nelec, J1OrbitalSoA< FT >::NumGroups, and J1OrbitalSoA< FT >::Vat.

418  {
419  const auto& dist = P.getDistTableAB(myTableID).getTempDists();
420  curAt = valT(0);
421  for (int jg = 0; jg < NumGroups; ++jg)
422  {
423  if (J1UniqueFunctors[jg] != nullptr)
424  curAt += J1UniqueFunctors[jg]->evaluateV(-1, Ions.first(jg), Ions.last(jg), dist.data(), DistCompressed.data());
425  }
426 
427  for (int i = 0; i < Nelec; ++i)
428  ratios[i] = std::exp(Vat[i] - curAt);
429  }
const int NumGroups
number of ion groups
Definition: J1OrbitalSoA.h:71
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
aligned_vector< valT > DistCompressed
Definition: J1OrbitalSoA.h:87
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1OrbitalSoA.h:51
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1OrbitalSoA.h:73
const int myTableID
table index
Definition: J1OrbitalSoA.h:65

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
inlineoverridevirtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented from WaveFunctionComponent.

Definition at line 526 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::J1UniqueFunctors, and UniqueOptObjRefs::push_back().

527  {
528  for (auto& functor : J1UniqueFunctors)
529  if (functor)
530  opt_obj_refs.push_back(*functor);
531  }
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 199 of file J1OrbitalSoA.h.

199 { return "J1OrbitalSoA"; }

◆ getFunctors()

const auto& getFunctors ( ) const
inline

Definition at line 230 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::J1Functors.

230 { return J1Functors; }
std::vector< FT * > J1Functors
Container for .
Definition: J1OrbitalSoA.h:92

◆ initialize()

void initialize ( const ParticleSet els)
inline

Definition at line 202 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::d2U, J1OrbitalSoA< FT >::d3U, J1OrbitalSoA< FT >::DistCompressed, J1OrbitalSoA< FT >::DistIndice, J1OrbitalSoA< FT >::dU, ParticleSet::getSpeciesSet(), SpeciesSet::getTotalNum(), J1OrbitalSoA< FT >::Grad, J1OrbitalSoA< FT >::GroupFunctors, J1OrbitalSoA< FT >::Ions, J1OrbitalSoA< FT >::J1Functors, J1OrbitalSoA< FT >::J1UniqueFunctors, J1OrbitalSoA< FT >::Lap, J1OrbitalSoA< FT >::Nelec, J1OrbitalSoA< FT >::Nions, J1OrbitalSoA< FT >::NumGroups, Vector< T, Alloc >::resize(), J1OrbitalSoA< FT >::U, and J1OrbitalSoA< FT >::Vat.

Referenced by J1OrbitalSoA< FT >::J1OrbitalSoA().

203  {
204  J1Functors.resize(Nions, nullptr);
205  GroupFunctors.resize(NumGroups, nullptr);
207  Vat.resize(Nelec);
208  Grad.resize(Nelec);
209  Lap.resize(Nelec);
210 
211  U.resize(Nions);
212  dU.resize(Nions);
213  d2U.resize(Nions);
214  d3U.resize(Nions);
215  DistCompressed.resize(Nions);
216  DistIndice.resize(Nions);
217  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
const int NumGroups
number of ion groups
Definition: J1OrbitalSoA.h:71
std::vector< FT * > GroupFunctors
functor for each ion group Conceptually, this is different from unique functions. ...
Definition: J1OrbitalSoA.h:98
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
aligned_vector< valT > DistCompressed
Definition: J1OrbitalSoA.h:87
int getTotalNum() const
return the number of species
Definition: SpeciesSet.h:55
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
aligned_vector< valT > dU
Definition: J1OrbitalSoA.h:86
aligned_vector< int > DistIndice
Definition: J1OrbitalSoA.h:88
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
const int Nions
number of ions
Definition: J1OrbitalSoA.h:67
aligned_vector< valT > U
Definition: J1OrbitalSoA.h:86
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1OrbitalSoA.h:73
aligned_vector< valT > d3U
Definition: J1OrbitalSoA.h:86
std::vector< FT * > J1Functors
Container for .
Definition: J1OrbitalSoA.h:92
aligned_vector< valT > d2U
Definition: J1OrbitalSoA.h:86

◆ isOptimizable()

bool isOptimizable ( ) const
inlineoverridevirtual

WaveFunctionComponent virtual functions that are not essential for the development

Reimplemented from WaveFunctionComponent.

Definition at line 524 of file J1OrbitalSoA.h.

524 { return true; }

◆ makeClone()

std::unique_ptr<WaveFunctionComponent> makeClone ( ParticleSet tqp) const
inlineoverridevirtual

make clone

Parameters
tqptarget Quantum ParticleSet
deepcopyif true, make a decopy

If not true, return a proxy class

Reimplemented from WaveFunctionComponent.

Definition at line 507 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::Ions, J1OrbitalSoA< FT >::J1UniqueFunctors, WaveFunctionComponent::my_name_, J1OrbitalSoA< FT >::myVars, qmcplusplus::n, J1OrbitalSoA< FT >::OffSet, and J1OrbitalSoA< FT >::use_offload_.

508  {
509  auto j1copy = std::make_unique<J1OrbitalSoA<FT>>(my_name_, Ions, tqp, use_offload_);
510  for (size_t i = 0, n = J1UniqueFunctors.size(); i < n; ++i)
511  {
512  if (J1UniqueFunctors[i] != nullptr)
513  {
514  auto fc = std::make_unique<FT>(*J1UniqueFunctors[i].get());
515  j1copy->addFunc(i, std::move(fc));
516  }
517  }
518  j1copy->myVars = myVars;
519  j1copy->OffSet = OffSet;
520  return j1copy;
521  }
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functions
Definition: J1OrbitalSoA.h:190
std::vector< std::pair< int, int > > OffSet
Definition: J1OrbitalSoA.h:100
const bool use_offload_
if true use offload
Definition: J1OrbitalSoA.h:62
opt_variables_type myVars
variables handled by this orbital
Definition: J1OrbitalSoA.h:78
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1OrbitalSoA.h:73

◆ mw_evaluateRatios()

void mw_evaluateRatios ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< const VirtualParticleSet > &  vp_list,
std::vector< std::vector< ValueType >> &  ratios 
) const
override

Definition at line 110 of file J1OrbitalSoA.cpp.

References qmcplusplus::exp(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), VirtualParticleSet::getTotalNum(), WaveFunctionComponent::mw_evaluateRatios(), and J1OrbitalSoA< FT >::mw_mem_handle_.

113 {
114  if (!use_offload_)
115  {
116  WaveFunctionComponent::mw_evaluateRatios(wfc_list, vp_list, ratios);
117  return;
118  }
119 
120  // add early return to prevent from accessing vp_list[0]
121  if (wfc_list.size() == 0)
122  return;
123  auto& wfc_leader = wfc_list.getCastedLeader<J1OrbitalSoA<FT>>();
124  auto& vp_leader = vp_list.getLeader();
125  const auto& mw_refPctls = vp_leader.getMultiWalkerRefPctls();
126  auto& mw_mem = wfc_leader.mw_mem_handle_.getResource();
127  auto& mw_vals = mw_mem.mw_vals;
128  auto& mw_minus_one = mw_mem.mw_minus_one;
129  const int nw = wfc_list.size();
130 
131  const size_t nVPs = mw_refPctls.size();
132  mw_vals.resize(nVPs);
133  mw_mem.resize_minus_one(nVPs);
134 
135  const auto& dt_leader(vp_leader.getDistTableAB(wfc_leader.myTableID));
136 
137  FT::mw_evaluateV(NumGroups, GroupFunctors.data(), wfc_leader.Nions, grp_ids.data(), nVPs, mw_minus_one.data(),
138  dt_leader.getMultiWalkerDataPtr(), dt_leader.getPerTargetPctlStrideSize(), mw_vals.data(),
139  mw_mem.transfer_buffer);
140 
141  size_t ivp = 0;
142  for (int iw = 0; iw < nw; ++iw)
143  {
144  const VirtualParticleSet& vp = vp_list[iw];
145  auto& wfc = wfc_list.getCastedElement<J1OrbitalSoA<FT>>(iw);
146  for (int k = 0; k < vp.getTotalNum(); ++k, ivp++)
147  ratios[iw][k] = std::exp(wfc.Vat[mw_refPctls[ivp]] - mw_vals[ivp]);
148  }
149  assert(ivp == nVPs);
150 }
const int NumGroups
number of ion groups
Definition: J1OrbitalSoA.h:71
std::vector< FT * > GroupFunctors
functor for each ion group Conceptually, this is different from unique functions. ...
Definition: J1OrbitalSoA.h:98
const bool use_offload_
if true use offload
Definition: J1OrbitalSoA.h:62
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
Vector< int, OffloadPinnedAllocator< int > > grp_ids
the group_id of each particle
Definition: J1OrbitalSoA.h:75
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

◆ ratio()

PsiValue ratio ( ParticleSet P,
int  iat 
)
inlineoverridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value

Parameters
Pthe active ParticleSet
iatthe index of a particle
Returns
$ \psi( \{ {\bf R}^{'} \} )/ \psi( \{ {\bf R}\})$

Specialized for particle-by-particle move

Implements WaveFunctionComponent.

Definition at line 288 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::computeU(), J1OrbitalSoA< FT >::curAt, qmcplusplus::exp(), ParticleSet::getDistTableAB(), DistanceTableAB::getTempDists(), J1OrbitalSoA< FT >::myTableID, WaveFunctionComponent::ORB_PBYP_RATIO, WaveFunctionComponent::UpdateMode, and J1OrbitalSoA< FT >::Vat.

289  {
291  curAt = computeU(P.getDistTableAB(myTableID).getTempDists());
292  return std::exp(static_cast<PsiValue>(Vat[iat] - curAt));
293  }
valT computeU(const DistRow &dist)
Definition: J1OrbitalSoA.h:155
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
const int myTableID
table index
Definition: J1OrbitalSoA.h:65

◆ ratioGrad()

PsiValue ratioGrad ( ParticleSet P,
int  iat,
GradType grad_iat 
)
inlineoverridevirtual

compute the gradient during particle-by-particle update

Parameters
Pquantum particleset
iatparticle index

Using getTempDists(). curAt, curGrad and curLap are computed.

Reimplemented from WaveFunctionComponent.

Definition at line 443 of file J1OrbitalSoA.h.

References qmcplusplus::simd::accumulate_n(), J1OrbitalSoA< FT >::accumulateGL(), J1OrbitalSoA< FT >::computeU3(), J1OrbitalSoA< FT >::curAt, J1OrbitalSoA< FT >::curGrad, J1OrbitalSoA< FT >::curLap, J1OrbitalSoA< FT >::d2U, J1OrbitalSoA< FT >::dU, qmcplusplus::exp(), ParticleSet::getDistTableAB(), DistanceTableAB::getTempDispls(), DistanceTableAB::getTempDists(), J1OrbitalSoA< FT >::myTableID, J1OrbitalSoA< FT >::Nions, WaveFunctionComponent::ORB_PBYP_PARTIAL, J1OrbitalSoA< FT >::U, WaveFunctionComponent::UpdateMode, and J1OrbitalSoA< FT >::Vat.

444  {
446 
447  computeU3(P, iat, P.getDistTableAB(myTableID).getTempDists());
448  curLap = accumulateGL(dU.data(), d2U.data(), P.getDistTableAB(myTableID).getTempDispls(), curGrad);
449  curAt = simd::accumulate_n(U.data(), Nions, valT());
450  grad_iat += curGrad;
451  return std::exp(static_cast<PsiValue>(Vat[iat] - curAt));
452  }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
aligned_vector< valT > dU
Definition: J1OrbitalSoA.h:86
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1OrbitalSoA.h:51
const int Nions
number of ions
Definition: J1OrbitalSoA.h:67
aligned_vector< valT > U
Definition: J1OrbitalSoA.h:86
valT accumulateGL(const valT *restrict du, const valT *restrict d2u, const DisplRow &displ, posT &grad) const
compute gradient and lap
Definition: J1OrbitalSoA.h:136
const int myTableID
table index
Definition: J1OrbitalSoA.h:65
aligned_vector< valT > d2U
Definition: J1OrbitalSoA.h:86
void computeU3(const ParticleSet &P, int iat, const DistRow &dist)
compute U, dU and d2U
Definition: J1OrbitalSoA.h:172

◆ recompute()

void recompute ( const ParticleSet P)
inlineoverridevirtual

recompute the value of the WaveFunctionComponents which require critical accuracy.

needed for Slater Determinants but not needed for most types of WaveFunctionComponents

Reimplemented from WaveFunctionComponent.

Definition at line 240 of file J1OrbitalSoA.h.

References qmcplusplus::simd::accumulate_n(), J1OrbitalSoA< FT >::accumulateGL(), J1OrbitalSoA< FT >::computeU3(), J1OrbitalSoA< FT >::d2U, J1OrbitalSoA< FT >::dU, ParticleSet::getDistTableAB(), J1OrbitalSoA< FT >::Grad, J1OrbitalSoA< FT >::Lap, J1OrbitalSoA< FT >::myTableID, J1OrbitalSoA< FT >::Nelec, J1OrbitalSoA< FT >::Nions, J1OrbitalSoA< FT >::U, and J1OrbitalSoA< FT >::Vat.

Referenced by J1OrbitalSoA< FT >::evaluateLog().

241  {
242  const auto& d_ie(P.getDistTableAB(myTableID));
243  for (int iat = 0; iat < Nelec; ++iat)
244  {
245  computeU3(P, iat, d_ie.getDistRow(iat));
246  Vat[iat] = simd::accumulate_n(U.data(), Nions, valT());
247  Lap[iat] = accumulateGL(dU.data(), d2U.data(), d_ie.getDisplRow(iat), Grad[iat]);
248  }
249  }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
aligned_vector< valT > dU
Definition: J1OrbitalSoA.h:86
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1OrbitalSoA.h:51
const int Nions
number of ions
Definition: J1OrbitalSoA.h:67
aligned_vector< valT > U
Definition: J1OrbitalSoA.h:86
valT accumulateGL(const valT *restrict du, const valT *restrict d2u, const DisplRow &displ, posT &grad) const
compute gradient and lap
Definition: J1OrbitalSoA.h:136
const int myTableID
table index
Definition: J1OrbitalSoA.h:65
aligned_vector< valT > d2U
Definition: J1OrbitalSoA.h:86
void computeU3(const ParticleSet &P, int iat, const DistRow &dist)
compute U, dU and d2U
Definition: J1OrbitalSoA.h:172

◆ registerData()

void registerData ( ParticleSet P,
WFBufferType buf 
)
inlineoverridevirtual

For particle-by-particle move.

Requests space in the buffer based on the data type sizes of the objects in this class.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 473 of file J1OrbitalSoA.h.

References PooledMemory< T_scalar, Alloc >::add(), Vector< T, Alloc >::begin(), WaveFunctionComponent::Bytes_in_WFBuffer, PooledMemory< T_scalar, Alloc >::current(), Vector< T, Alloc >::end(), PooledMemory< T_scalar, Alloc >::forward(), Vector< T, Alloc >::free(), J1OrbitalSoA< FT >::Grad, J1OrbitalSoA< FT >::Lap, and J1OrbitalSoA< FT >::Vat.

474  {
475  if (Bytes_in_WFBuffer == 0)
476  {
477  Bytes_in_WFBuffer = buf.current();
478  buf.add(Vat.begin(), Vat.end());
479  buf.add(Grad.begin(), Grad.end());
480  buf.add(Lap.begin(), Lap.end());
481  Bytes_in_WFBuffer = buf.current() - Bytes_in_WFBuffer;
482  // free local space
483  Vat.free();
484  Grad.free();
485  Lap.free();
486  }
487  else
488  {
489  buf.forward(Bytes_in_WFBuffer);
490  }
491  }
void free()
free
Definition: OhmmsVector.h:196
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
overridevirtual

return a shared resource to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 102 of file J1OrbitalSoA.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), and ResourceCollection::takebackResource().

104 {
105  auto& wfc_leader = wfc_list.getCastedLeader<J1OrbitalSoA<FT>>();
106  collection.takebackResource(wfc_leader.mw_mem_handle_);
107 }

◆ resizeWFOptVectors()

void resizeWFOptVectors ( )
inlineprivate

Definition at line 107 of file J1OrbitalSoA.h.

References J1OrbitalSoA< FT >::dLogPsi, J1OrbitalSoA< FT >::gradLogPsi, J1OrbitalSoA< FT >::lapLogPsi, J1OrbitalSoA< FT >::myVars, J1OrbitalSoA< FT >::Nelec, Vector< T, Alloc >::resize(), and VariableSet::size().

Referenced by J1OrbitalSoA< FT >::evaluateDerivativesWF().

108  {
112  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::vector< ValueDerivVec > lapLogPsi
Definition: J1OrbitalSoA.h:103
opt_variables_type myVars
variables handled by this orbital
Definition: J1OrbitalSoA.h:78
ParticleAttrib< QTFull::GradType > GradDerivVec
Definition: J1OrbitalSoA.h:58
const int Nelec
number of electrons
Definition: J1OrbitalSoA.h:69
size_type size() const
return the size
Definition: VariableSet.h:88
Vector< RealType > dLogPsi
Definition: J1OrbitalSoA.h:101
std::vector< GradDerivVec > gradLogPsi
Definition: J1OrbitalSoA.h:102
ParticleAttrib< QTFull::ValueType > ValueDerivVec
Definition: J1OrbitalSoA.h:59

◆ restore()

void restore ( int  iat)
inlineoverridevirtual

Rejected move.

Nothing to do

Implements WaveFunctionComponent.

Definition at line 455 of file J1OrbitalSoA.h.

455 {}

◆ updateBuffer()

LogValue updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)
inlineoverridevirtual

For particle-by-particle move.

Put the objects of this class in the walker buffer or forward the memory cursor.

Parameters
Pparticle set
bufAnonymous storage
fromscratchrequest recomputing the precision critical pieces of wavefunction from scratch
Returns
log value of the wavefunction.

Implements WaveFunctionComponent.

Definition at line 493 of file J1OrbitalSoA.h.

References WaveFunctionComponent::Bytes_in_WFBuffer, J1OrbitalSoA< FT >::computeGL(), PooledMemory< T_scalar, Alloc >::forward(), ParticleSet::G, ParticleSet::L, and WaveFunctionComponent::log_value_.

494  {
495  log_value_ = computeGL(P.G, P.L);
496  buf.forward(Bytes_in_WFBuffer);
497  return log_value_;
498  }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
Definition: J1OrbitalSoA.h:115
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

Member Data Documentation

◆ curAt

◆ curGrad

posT curGrad
private

Definition at line 82 of file J1OrbitalSoA.h.

Referenced by J1OrbitalSoA< FT >::acceptMove(), and J1OrbitalSoA< FT >::ratioGrad().

◆ curLap

valT curLap
private

Definition at line 81 of file J1OrbitalSoA.h.

Referenced by J1OrbitalSoA< FT >::acceptMove(), and J1OrbitalSoA< FT >::ratioGrad().

◆ d2U

◆ d3U

aligned_vector<valT> d3U
private

◆ DistCompressed

◆ DistIndice

aligned_vector<int> DistIndice
private

Definition at line 88 of file J1OrbitalSoA.h.

Referenced by J1OrbitalSoA< FT >::computeU3(), and J1OrbitalSoA< FT >::initialize().

◆ dLogPsi

◆ dU

◆ Grad

◆ gradLogPsi

◆ GroupFunctors

std::vector<FT*> GroupFunctors
private

functor for each ion group Conceptually, this is different from unique functions.

In a spin polarized system, two species may share the same J1 functor. FIXME However this is not supported right now. Each species needs its dedicated function.

Definition at line 98 of file J1OrbitalSoA.h.

Referenced by J1OrbitalSoA< FT >::addFunc(), and J1OrbitalSoA< FT >::initialize().

◆ grp_ids

Vector<int, OffloadPinnedAllocator<int> > grp_ids
private

the group_id of each particle

Definition at line 75 of file J1OrbitalSoA.h.

Referenced by J1OrbitalSoA< FT >::J1OrbitalSoA().

◆ Ions

◆ J1Functors

◆ J1UniqueFunctors

◆ Lap

◆ lapLogPsi

◆ mw_mem_handle_

◆ myTableID

◆ myVars

◆ Nelec

◆ Nions

◆ NumGroups

◆ OffSet

◆ U

◆ use_offload_

const bool use_offload_
private

if true use offload

Definition at line 62 of file J1OrbitalSoA.h.

Referenced by J1OrbitalSoA< FT >::J1OrbitalSoA(), and J1OrbitalSoA< FT >::makeClone().

◆ Vat

◆ qmcplusplus::J1Spin

struct qmcplusplus::J1Spin

template<class FT>
struct qmcplusplus::J1Spin< FT >

Specialization for one-body Jastrow function using multiple functors.

Definition at line 34 of file J1Spin.h.

+ Inheritance diagram for J1Spin< FT >:
+ Collaboration diagram for J1Spin< FT >:

Public Types

using FuncType = FT
 alias FuncType More...
 
using valT = typename FT::real_type
 type of each component U, dU, d2U; More...
 
using posT = TinyVector< valT, OHMMS_DIM >
 element position type More...
 
using DistRow = DistanceTable::DistRow
 use the same container More...
 
using DisplRow = DistanceTable::DisplRow
 
using GradDerivVec = ParticleAttrib< QTFull::GradType >
 
using ValueDerivVec = ParticleAttrib< QTFull::ValueType >
 
- Public Types inherited from WaveFunctionComponent
enum  {
  ORB_PBYP_RATIO, ORB_PBYP_ALL, ORB_PBYP_PARTIAL, ORB_WALKER,
  ORB_ALLWALKER
}
 enum for a update mode More...
 
using Walker_t = ParticleSet::Walker_t
 
using WFBufferType = Walker_t::WFBuffer_t
 
using BufferType = Walker_t::Buffer_t
 
using RealMatrix_t = OrbitalSetTraits< RealType >::ValueMatrix
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using LogValue = std::complex< QTFull::RealType >
 
using PsiValue = QTFull::ValueType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

void resizeWFOptVectors ()
 
 J1Spin (const std::string &obj_name, const ParticleSet &ions, ParticleSet &els, bool use_offload)
 
 J1Spin (const J1Spin &rhs)=delete
 
 J1Spin (const J1Spin &rhs, ParticleSet &tqp)
 
std::string getClassName () const override
 return class name More...
 
void initialize (ParticleSet &els)
 
void addFunc (int source_type, std::unique_ptr< FT > afunc, int target_type=-1)
 
void recompute (const ParticleSet &P) override
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch More...
 
void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi) override
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
 
valT computeU (const ParticleSet &P, int iat, const DistRow &dist)
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios) override
 
QTFull::RealType computeGL (ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
 compute G and L from internally stored data More...
 
LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch=false) override
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
valT accumulateGL (const valT *restrict du, const valT *restrict d2u, const DisplRow &displ, posT &grad) const
 compute gradient and lap More...
 
void computeU3 (const ParticleSet &P, int iat, const DistRow &dist)
 compute U, dU and d2U More...
 
GradType evalGrad (ParticleSet &P, int iat) override
 compute the gradient during particle-by-particle update More...
 
PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat) override
 compute the gradient during particle-by-particle update More...
 
void restore (int iat) override
 Rejected move. More...
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 Accpted move. More...
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
 For particle-by-particle move. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const override
 make clone More...
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int isrc) override
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int isrc, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad) override
 Adds the gradient w.r.t. More...
 
bool isOptimizable () const override
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) override
 extract underlying OptimizableObject references More...
 
void checkOutVariables (const opt_variables_type &active) override
 check out variational optimizable variables More...
 
- Public Member Functions inherited from WaveFunctionComponent
const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
virtual void checkSanity () const
 Validate the internal consistency of the object. More...
 
const std::string & getName () const
 return object name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual bool isFermionic () const
 true, if this component is fermionic More...
 
virtual bool isMultiDet () const
 true, if this component is multi-determinant More...
 
virtual void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
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 More...
 
virtual void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 
virtual void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
virtual GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad)
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
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 implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
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. More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
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 p-by-p move region. More...
 
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 More...
 
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 More...
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 acquire a shared resource from a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 return a shared resource to a collection More...
 
virtual RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
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 optimizable parameters. More...
 
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. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void finalizeOptimization ()
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
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 More...
 
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 More...
 
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 More...
 
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 multiple walkers More...
 

Public Attributes

const int myTableID
 table index More...
 
const int Nions
 number of ions More...
 
const int Nelec
 number of electrons More...
 
const int NumGroups
 
const int NumTargetGroups
 
const ParticleSetIons
 reference to the sources (ions) More...
 
opt_variables_type myVars
 variables handled by this orbital More...
 
valT curAt
 
valT curLap
 
posT curGrad
 
Vector< valTVat
 $Vat[i] = sum_(j) u_{i,j}$ More...
 
aligned_vector< valTU
 
aligned_vector< valTdU
 
aligned_vector< valTd2U
 
aligned_vector< valTd3U
 
aligned_vector< valTDistCompressed
 
aligned_vector< int > DistIndice
 
Vector< posTGrad
 
Vector< valTLap
 
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
 container for the unique Jastrow functors (size NumGroups x NumTargetGroups) More...
 
std::vector< std::pair< int, int > > OffSet
 
Vector< RealTypedLogPsi
 
std::vector< GradDerivVecgradLogPsi
 
std::vector< ValueDerivVeclapLogPsi
 
- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 

Additional Inherited Members

- Protected Attributes inherited from WaveFunctionComponent
const std::string my_name_
 Name of the object It is required to be different for objects of the same derived type like multiple J1. More...
 
LogValue log_value_
 Current $\log\phi $. More...
 

Member Typedef Documentation

◆ DisplRow

Definition at line 44 of file J1Spin.h.

◆ DistRow

use the same container

Definition at line 43 of file J1Spin.h.

◆ FuncType

using FuncType = FT

alias FuncType

Definition at line 37 of file J1Spin.h.

◆ GradDerivVec

Definition at line 46 of file J1Spin.h.

◆ posT

element position type

Definition at line 41 of file J1Spin.h.

◆ valT

using valT = typename FT::real_type

type of each component U, dU, d2U;

Definition at line 39 of file J1Spin.h.

◆ ValueDerivVec

Definition at line 47 of file J1Spin.h.

Constructor & Destructor Documentation

◆ J1Spin() [1/3]

J1Spin ( const std::string &  obj_name,
const ParticleSet ions,
ParticleSet els,
bool  use_offload 
)
inline

Definition at line 93 of file J1Spin.h.

References J1Spin< FT >::initialize(), and WaveFunctionComponent::my_name_.

94  : WaveFunctionComponent(obj_name),
96  Nions(ions.getTotalNum()),
97  Nelec(els.getTotalNum()),
98  NumGroups(ions.groups()),
99  NumTargetGroups(els.groups()),
100  Ions(ions)
101  {
102  if (my_name_.empty())
103  throw std::runtime_error("J1Spin object name cannot be empty!");
104  initialize(els);
105  }
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
const int NumGroups
Definition: J1Spin.h:58
For distance tables of virtual particle (VP) sets constructed based on this table, whether full table is needed on host The corresponding DT of VP need to set MW_EVALUATE_RESULT_NO_TRANSFER_TO_HOST accordingly.
const int NumTargetGroups
Definition: J1Spin.h:60
const int Nelec
number of electrons
Definition: J1Spin.h:54
const int Nions
number of ions
Definition: J1Spin.h:52
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1Spin.h:62
void initialize(ParticleSet &els)
Definition: J1Spin.h:133
WaveFunctionComponent(const std::string &obj_name="")
default constructor
const int myTableID
table index
Definition: J1Spin.h:50

◆ J1Spin() [2/3]

J1Spin ( const J1Spin< FT > &  rhs)
delete

◆ J1Spin() [3/3]

J1Spin ( const J1Spin< FT > &  rhs,
ParticleSet tqp 
)
inline

Definition at line 109 of file J1Spin.h.

References J1Spin< FT >::addFunc(), J1Spin< FT >::initialize(), J1Spin< FT >::J1UniqueFunctors, J1Spin< FT >::myVars, J1Spin< FT >::NumGroups, J1Spin< FT >::NumTargetGroups, and J1Spin< FT >::OffSet.

110  : WaveFunctionComponent(rhs.my_name_),
111  myTableID(rhs.myTableID),
112  Nions(rhs.Nions),
113  Nelec(rhs.Nelec),
114  NumGroups(rhs.NumGroups),
115  NumTargetGroups(rhs.NumTargetGroups),
116  Ions(rhs.Ions)
117  {
118  initialize(tqp);
119  for (int i = 0; i < NumGroups; i++)
120  for (int j = 0; j < NumTargetGroups; j++)
121  if (rhs.J1UniqueFunctors[i * NumTargetGroups + j])
122  {
123  auto fc = std::make_unique<FT>(*rhs.J1UniqueFunctors[i * NumTargetGroups + j].get());
124  addFunc(i, std::move(fc), j);
125  }
126  myVars = rhs.myVars;
127  OffSet = rhs.OffSet;
128  }
const int NumGroups
Definition: J1Spin.h:58
std::vector< std::pair< int, int > > OffSet
Definition: J1Spin.h:81
opt_variables_type myVars
variables handled by this orbital
Definition: J1Spin.h:65
const int NumTargetGroups
Definition: J1Spin.h:60
const int Nelec
number of electrons
Definition: J1Spin.h:54
const int Nions
number of ions
Definition: J1Spin.h:52
void addFunc(int source_type, std::unique_ptr< FT > afunc, int target_type=-1)
Definition: J1Spin.h:148
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1Spin.h:62
void initialize(ParticleSet &els)
Definition: J1Spin.h:133
WaveFunctionComponent(const std::string &obj_name="")
default constructor
const int myTableID
table index
Definition: J1Spin.h:50

Member Function Documentation

◆ acceptMove()

void acceptMove ( ParticleSet P,
int  iat,
bool  safe_to_delay = false 
)
inlineoverridevirtual

Accpted move.

Update Vat[iat],Grad[iat] and Lap[iat]

Implements WaveFunctionComponent.

Definition at line 458 of file J1Spin.h.

References J1Spin< FT >::accumulateGL(), J1Spin< FT >::computeU3(), J1Spin< FT >::curAt, J1Spin< FT >::curGrad, J1Spin< FT >::curLap, J1Spin< FT >::d2U, J1Spin< FT >::dU, ParticleSet::getDistTableAB(), DistanceTableAB::getTempDispls(), DistanceTableAB::getTempDists(), J1Spin< FT >::Grad, J1Spin< FT >::Lap, WaveFunctionComponent::log_value_, J1Spin< FT >::myTableID, WaveFunctionComponent::ORB_PBYP_RATIO, WaveFunctionComponent::UpdateMode, and J1Spin< FT >::Vat.

459  {
460  if (UpdateMode == ORB_PBYP_RATIO)
461  {
462  computeU3(P, iat, P.getDistTableAB(myTableID).getTempDists());
463  curLap = accumulateGL(dU.data(), d2U.data(), P.getDistTableAB(myTableID).getTempDispls(), curGrad);
464  }
465 
466  log_value_ += Vat[iat] - curAt;
467  Vat[iat] = curAt;
468  Grad[iat] = curGrad;
469  Lap[iat] = curLap;
470  }
Vector< posT > Grad
Definition: J1Spin.h:76
Vector< valT > Lap
Definition: J1Spin.h:77
aligned_vector< valT > dU
Definition: J1Spin.h:73
Vector< valT > Vat
Definition: J1Spin.h:72
valT accumulateGL(const valT *restrict du, const valT *restrict d2u, const DisplRow &displ, posT &grad) const
compute gradient and lap
Definition: J1Spin.h:391
const int myTableID
table index
Definition: J1Spin.h:50
aligned_vector< valT > d2U
Definition: J1Spin.h:73
void computeU3(const ParticleSet &P, int iat, const DistRow &dist)
compute U, dU and d2U
Definition: J1Spin.h:415

◆ accumulateGL()

valT accumulateGL ( const valT *restrict  du,
const valT *restrict  d2u,
const DisplRow displ,
posT grad 
) const
inline

compute gradient and lap

Returns
lap

Definition at line 391 of file J1Spin.h.

References VectorSoaContainer< T, D, Alloc >::data(), J1Spin< FT >::Nions, OHMMS_DIM, and qmcplusplus::Units::time::s.

Referenced by J1Spin< FT >::acceptMove(), J1Spin< FT >::ratioGrad(), and J1Spin< FT >::recompute().

392  {
393  valT lap(0);
394  constexpr valT lapfac = OHMMS_DIM - RealType(1);
395  //#pragma omp simd reduction(+:lap)
396  for (int jat = 0; jat < Nions; ++jat)
397  lap += d2u[jat] + lapfac * du[jat];
398  for (int idim = 0; idim < OHMMS_DIM; ++idim)
399  {
400  const valT* restrict dX = displ.data(idim);
401  valT s = valT();
402  //#pragma omp simd reduction(+:s)
403  for (int jat = 0; jat < Nions; ++jat)
404  s += du[jat] * dX[jat];
405  grad[idim] = s;
406  }
407  return lap;
408  }
QTBase::RealType RealType
Definition: Configuration.h:58
#define OHMMS_DIM
Definition: config.h:64
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1Spin.h:39
const int Nions
number of ions
Definition: J1Spin.h:52

◆ addFunc()

void addFunc ( int  source_type,
std::unique_ptr< FT >  afunc,
int  target_type = -1 
)
inline

Definition at line 148 of file J1Spin.h.

References J1Spin< FT >::J1UniqueFunctors, and J1Spin< FT >::NumTargetGroups.

Referenced by J1Spin< FT >::J1Spin().

149  {
150  // if target type is not specified J1UniqueFunctors[i*NumTargetGroups + (0:NumTargetGroups)] is assigned
151  // if target type is specified J1UniqueFunctors[i*NumTargetGroups + j] is assigned
152  assert(target_type < NumTargetGroups);
153  if (target_type == -1)
154  throw std::runtime_error(
155  "J1Spin::addFunc is not compatible with spin independent Jastrow factors (target_type == -1");
156  else
157  J1UniqueFunctors[source_type * NumTargetGroups + target_type] = std::move(afunc);
158  }
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
const int NumTargetGroups
Definition: J1Spin.h:60

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
inlineoverridevirtual

check out variational optimizable variables

Parameters
activea super set of optimizable variables

Reimplemented from WaveFunctionComponent.

Definition at line 522 of file J1Spin.h.

References VariableSet::clear(), VariableSet::getIndex(), VariableSet::Index, VariableSet::insertFrom(), J1Spin< FT >::J1UniqueFunctors, J1Spin< FT >::myVars, J1Spin< FT >::OffSet, VariableSet::print(), and VariableSet::size().

523  {
524  myVars.clear();
525  for (auto& J1UniqueFunctor : J1UniqueFunctors)
526  {
527  if (J1UniqueFunctor)
528  {
529  J1UniqueFunctor->myVars.getIndex(active);
530  myVars.insertFrom(J1UniqueFunctor->myVars);
531  }
532  }
533  myVars.getIndex(active);
534  const size_t NumVars = myVars.size();
535  myVars.print(std::cout);
536  if (NumVars)
537  {
538  OffSet.resize(J1UniqueFunctors.size());
539  // Find first active variable for the starting offset
540  int varoffset = -1;
541  for (int i = 0; i < myVars.size(); i++)
542  {
543  varoffset = myVars.Index[i];
544  if (varoffset != -1)
545  break;
546  }
547 
548  for (int i = 0; i < J1UniqueFunctors.size(); ++i)
549  {
550  if (J1UniqueFunctors[i] && J1UniqueFunctors[i]->myVars.Index.size())
551  {
552  OffSet[i].first = J1UniqueFunctors[i]->myVars.Index.front() - varoffset;
553  OffSet[i].second = J1UniqueFunctors[i]->myVars.Index.size() + OffSet[i].first;
554  }
555  else
556  {
557  OffSet[i].first = OffSet[i].second = -1;
558  }
559  }
560  }
561  for (auto& J1UniqueFunctor : J1UniqueFunctors)
562  if (J1UniqueFunctor != nullptr)
563  J1UniqueFunctor->checkOutVariables(active);
564  }
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
std::vector< std::pair< int, int > > OffSet
Definition: J1Spin.h:81
std::vector< int > Index
store locator of the named variable
Definition: VariableSet.h:65
opt_variables_type myVars
variables handled by this orbital
Definition: J1Spin.h:65
void clear()
clear the variable set
Definition: VariableSet.cpp:28
size_type size() const
return the size
Definition: VariableSet.h:88
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
Definition: VariableSet.cpp:37
void print(std::ostream &os, int leftPadSpaces=0, bool printHeader=false) const
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter

◆ computeGL()

compute G and L from internally stored data

Definition at line 370 of file J1Spin.h.

References qmcplusplus::simd::accumulate_n(), Vector< T, Alloc >::data(), J1Spin< FT >::Grad, J1Spin< FT >::Lap, J1Spin< FT >::Nelec, and J1Spin< FT >::Vat.

Referenced by J1Spin< FT >::evaluateGL(), J1Spin< FT >::evaluateLog(), and J1Spin< FT >::updateBuffer().

371  {
372  for (size_t iat = 0; iat < Nelec; ++iat)
373  {
374  G[iat] += Grad[iat];
375  L[iat] -= Lap[iat];
376  }
378  }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
const int Nelec
number of electrons
Definition: J1Spin.h:54
Vector< posT > Grad
Definition: J1Spin.h:76
Vector< valT > Lap
Definition: J1Spin.h:77
Vector< valT > Vat
Definition: J1Spin.h:72
Precision RealType
Definition: QMCTypes.h:37

◆ computeU()

valT computeU ( const ParticleSet P,
int  iat,
const DistRow dist 
)
inline

Definition at line 337 of file J1Spin.h.

References Vector< T, Alloc >::data(), J1Spin< FT >::DistCompressed, ParticleSet::first(), ParticleSet::getGroupID(), J1Spin< FT >::Ions, J1Spin< FT >::J1UniqueFunctors, ParticleSet::last(), J1Spin< FT >::NumGroups, and J1Spin< FT >::NumTargetGroups.

Referenced by J1Spin< FT >::evaluateRatios(), and J1Spin< FT >::ratio().

338  {
339  valT curVat(0);
340  for (int jg = 0; jg < NumGroups; ++jg)
341  {
342  auto gid = jg * NumTargetGroups + P.getGroupID(iat);
343  if (J1UniqueFunctors[gid])
344  curVat +=
345  J1UniqueFunctors[gid]->evaluateV(-1, Ions.first(jg), Ions.last(jg), dist.data(), DistCompressed.data());
346  }
347  return curVat;
348  }
const int NumGroups
Definition: J1Spin.h:58
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
aligned_vector< valT > DistCompressed
Definition: J1Spin.h:74
const int NumTargetGroups
Definition: J1Spin.h:60
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1Spin.h:39
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1Spin.h:62

◆ computeU3()

void computeU3 ( const ParticleSet P,
int  iat,
const DistRow dist 
)
inline

compute U, dU and d2U

Parameters
Pquantum particleset
iatthe moving particle
diststarting address of the distances of the ions wrt the iat-th particle

Definition at line 415 of file J1Spin.h.

References BLAS::czero, J1Spin< FT >::d2U, Vector< T, Alloc >::data(), J1Spin< FT >::DistCompressed, J1Spin< FT >::DistIndice, J1Spin< FT >::dU, OMPstd::fill_n(), ParticleSet::first(), ParticleSet::getGroupID(), J1Spin< FT >::Ions, J1Spin< FT >::J1UniqueFunctors, ParticleSet::last(), J1Spin< FT >::Nions, J1Spin< FT >::NumGroups, J1Spin< FT >::NumTargetGroups, and J1Spin< FT >::U.

Referenced by J1Spin< FT >::acceptMove(), J1Spin< FT >::ratioGrad(), and J1Spin< FT >::recompute().

416  {
417  constexpr valT czero(0);
418  std::fill_n(U.data(), Nions, czero);
419  std::fill_n(dU.data(), Nions, czero);
420  std::fill_n(d2U.data(), Nions, czero);
421 
422  for (int jg = 0; jg < NumGroups; ++jg)
423  {
424  auto gid = NumTargetGroups * jg + P.getGroupID(iat);
425  if (J1UniqueFunctors[gid])
426  J1UniqueFunctors[gid]->evaluateVGL(-1, Ions.first(jg), Ions.last(jg), dist.data(), U.data(), dU.data(),
427  d2U.data(), DistCompressed.data(), DistIndice.data());
428  }
429  }
const int NumGroups
Definition: J1Spin.h:58
void fill_n(T *x, size_t count, const T &value)
Definition: OMPstd.hpp:21
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
aligned_vector< valT > DistCompressed
Definition: J1Spin.h:74
const int NumTargetGroups
Definition: J1Spin.h:60
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
aligned_vector< valT > dU
Definition: J1Spin.h:73
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1Spin.h:39
aligned_vector< int > DistIndice
Definition: J1Spin.h:75
const int Nions
number of ions
Definition: J1Spin.h:52
aligned_vector< valT > U
Definition: J1Spin.h:73
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1Spin.h:62
aligned_vector< valT > d2U
Definition: J1Spin.h:73

◆ copyFromBuffer()

void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)
inlineoverridevirtual

For particle-by-particle move.

Copy data or attach memory from a walker buffer to the objects of this class. The log value, P.G and P.L contribution from the objects of this class are also added.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 500 of file J1Spin.h.

References Vector< T, Alloc >::attachReference(), J1Spin< FT >::Grad, J1Spin< FT >::Lap, PooledMemory< T_scalar, Alloc >::lendReference(), J1Spin< FT >::Nelec, and J1Spin< FT >::Vat.

501  {
502  Vat.attachReference(buf.lendReference<valT>(Nelec), Nelec);
503  Grad.attachReference(buf.lendReference<posT>(Nelec), Nelec);
504  Lap.attachReference(buf.lendReference<valT>(Nelec), Nelec);
505  }
TinyVector< valT, OHMMS_DIM > posT
element position type
Definition: J1Spin.h:41
void attachReference(T *ref, size_type n)
Definition: OhmmsVector.h:131
const int Nelec
number of electrons
Definition: J1Spin.h:54
Vector< posT > Grad
Definition: J1Spin.h:76
Vector< valT > Lap
Definition: J1Spin.h:77
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1Spin.h:39
Vector< valT > Vat
Definition: J1Spin.h:72

◆ evalGrad()

GradType evalGrad ( ParticleSet P,
int  iat 
)
inlineoverridevirtual

compute the gradient during particle-by-particle update

Parameters
Pquantum particleset
iatparticle index

Reimplemented from WaveFunctionComponent.

Definition at line 435 of file J1Spin.h.

References J1Spin< FT >::Grad.

435 { return GradType(Grad[iat]); }
QTBase::GradType GradType
Definition: Configuration.h:62
Vector< posT > Grad
Definition: J1Spin.h:76

◆ evalGradSource() [1/2]

GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat 
)
inlineoverridevirtual

return the logarithmic gradient for the iat-th particle of the source particleset

Parameters
Pquantumparticle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented from WaveFunctionComponent.

Definition at line 568 of file J1Spin.h.

References J1Spin< FT >::d2U, J1Spin< FT >::d3U, J1Spin< FT >::dU, ParticleSet::getDistTableAB(), ParticleSet::getGroupID(), J1Spin< FT >::J1UniqueFunctors, J1Spin< FT >::myTableID, J1Spin< FT >::Nelec, J1Spin< FT >::NumTargetGroups, and J1Spin< FT >::U.

569  {
570  GradType g_return(0.0);
571  const auto& d_ie(P.getDistTableAB(myTableID));
572  for (int iat = 0; iat < Nelec; ++iat)
573  {
574  const auto& dist = d_ie.getDistRow(iat);
575  const auto& displ = d_ie.getDisplRow(iat);
576  RealType r = dist[isrc];
577  RealType rinv = 1.0 / r;
578  PosType dr = displ[isrc];
579  auto gid = source.getGroupID(isrc) * NumTargetGroups + P.getGroupID(iat);
580  if (J1UniqueFunctors[gid] != nullptr)
581  {
582  U[isrc] = J1UniqueFunctors[gid]->evaluate(dist[isrc], dU[isrc], d2U[isrc], d3U[isrc]);
583  g_return -= dU[isrc] * rinv * dr;
584  }
585  }
586  return g_return;
587  }
QTBase::GradType GradType
Definition: Configuration.h:62
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
const int NumTargetGroups
Definition: J1Spin.h:60
QMCTraits::PosType PosType
const int Nelec
number of electrons
Definition: J1Spin.h:54
aligned_vector< valT > dU
Definition: J1Spin.h:73
aligned_vector< valT > U
Definition: J1Spin.h:73
QMCTraits::RealType RealType
aligned_vector< valT > d3U
Definition: J1Spin.h:73
const int myTableID
table index
Definition: J1Spin.h:50
aligned_vector< valT > d2U
Definition: J1Spin.h:73

◆ evalGradSource() [2/2]

GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat,
TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &  grad_grad,
TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &  lapl_grad 
)
inlineoverridevirtual

Adds the gradient w.r.t.

the iat-th particle of the source particleset (ions) of the logarithmic gradient and laplacian w.r.t. the target paritlceset (electrons).

Parameters
Pquantum particle set (electrons)
sourceclassical particle set (ions)
iatparticle index of source (ion)
theion gradient of the elctron gradient
theion gradient of the elctron laplacian.
Returns
the log gradient of psi w.r.t. the source particle iat

Reimplemented from WaveFunctionComponent.

Definition at line 589 of file J1Spin.h.

References J1Spin< FT >::d2U, J1Spin< FT >::d3U, J1Spin< FT >::dU, ParticleSet::getDistTableAB(), ParticleSet::getGroupID(), J1Spin< FT >::J1UniqueFunctors, J1Spin< FT >::myTableID, J1Spin< FT >::Nelec, J1Spin< FT >::NumTargetGroups, OHMMS_DIM, and J1Spin< FT >::U.

594  {
595  GradType g_return(0.0);
596  const auto& d_ie(P.getDistTableAB(myTableID));
597  for (int iat = 0; iat < Nelec; ++iat)
598  {
599  const auto& dist = d_ie.getDistRow(iat);
600  const auto& displ = d_ie.getDisplRow(iat);
601  RealType r = dist[isrc];
602  RealType rinv = 1.0 / r;
603  PosType dr = displ[isrc];
604  auto gid = source.getGroupID(isrc) * NumTargetGroups + P.getGroupID(iat);
605  if (J1UniqueFunctors[gid] != nullptr)
606  U[isrc] = J1UniqueFunctors[gid]->evaluate(dist[isrc], dU[isrc], d2U[isrc], d3U[isrc]);
607  else
608  throw std::runtime_error("J1OrbitalSoa::evaluateGradSource: J1UniqueFunctors[gid]==nullptr");
609 
610  g_return -= dU[isrc] * rinv * dr;
611 
612  //The following terms depend only on the radial component r. Thus,
613  //we compute them and mix with position vectors to acquire the full
614  //cartesian vector objects.
615  valT grad_component = (d2U[isrc] - dU[isrc] * rinv);
616  valT lapl_component = d3U[isrc] + 2 * rinv * grad_component;
617 
618  for (int idim = 0; idim < OHMMS_DIM; idim++)
619  {
620  grad_grad[idim][iat] += dr[idim] * dr * rinv * rinv * grad_component;
621  grad_grad[idim][iat][idim] += rinv * dU[isrc];
622 
623  lapl_grad[idim][iat] -= lapl_component * rinv * dr[idim];
624  }
625  }
626  return g_return;
627  }
QTBase::GradType GradType
Definition: Configuration.h:62
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
#define OHMMS_DIM
Definition: config.h:64
const int NumTargetGroups
Definition: J1Spin.h:60
QMCTraits::PosType PosType
const int Nelec
number of electrons
Definition: J1Spin.h:54
aligned_vector< valT > dU
Definition: J1Spin.h:73
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1Spin.h:39
aligned_vector< valT > U
Definition: J1Spin.h:73
QMCTraits::RealType RealType
aligned_vector< valT > d3U
Definition: J1Spin.h:73
const int myTableID
table index
Definition: J1Spin.h:50
aligned_vector< valT > d2U
Definition: J1Spin.h:73

◆ evaluateDerivatives()

void evaluateDerivatives ( ParticleSet P,
const opt_variables_type active,
Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
inlineoverride

Definition at line 222 of file J1Spin.h.

References qmcplusplus::Dot(), J1Spin< FT >::evaluateDerivativesWF(), ParticleSet::G, J1Spin< FT >::gradLogPsi, J1Spin< FT >::lapLogPsi, J1Spin< FT >::myVars, VariableSet::recompute(), VariableSet::size(), qmcplusplus::Sum(), and VariableSet::where().

226  {
227  evaluateDerivativesWF(P, active, dlogpsi);
228  bool recalculate(false);
229  std::vector<bool> rcsingles(myVars.size(), false);
230  for (int k = 0; k < myVars.size(); ++k)
231  {
232  int kk = myVars.where(k);
233  if (kk < 0)
234  continue;
235  if (active.recompute(kk))
236  recalculate = true;
237  rcsingles[k] = true;
238  }
239  if (recalculate)
240  {
241  for (int k = 0; k < myVars.size(); ++k)
242  {
243  int kk = myVars.where(k);
244  if (kk < 0)
245  continue;
246  if (rcsingles[k])
247  {
248  dhpsioverpsi[kk] = -RealType(0.5) * ValueType(Sum(lapLogPsi[k])) - ValueType(Dot(P.G, gradLogPsi[k]));
249  }
250  }
251  }
252  }
T Sum(const ParticleAttrib< T > &pa)
QTBase::RealType RealType
Definition: Configuration.h:58
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
std::vector< ValueDerivVec > lapLogPsi
Definition: J1Spin.h:84
opt_variables_type myVars
variables handled by this orbital
Definition: J1Spin.h:65
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
Definition: J1Spin.h:254
QTBase::ValueType ValueType
Definition: Configuration.h:60
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_type size() const
return the size
Definition: VariableSet.h:88
std::vector< GradDerivVec > gradLogPsi
Definition: J1Spin.h:83

◆ evaluateDerivativesWF()

void evaluateDerivativesWF ( ParticleSet P,
const opt_variables_type active,
Vector< ValueType > &  dlogpsi 
)
inlineoverride

Definition at line 254 of file J1Spin.h.

References BLAS::cone, J1Spin< FT >::dLogPsi, DistanceTableAB::getDisplRow(), DistanceTableAB::getDistRow(), ParticleSet::getDistTableAB(), ParticleSet::getGroupID(), ParticleSet::getTotalNum(), J1Spin< FT >::gradLogPsi, J1Spin< FT >::Ions, J1Spin< FT >::J1UniqueFunctors, J1Spin< FT >::lapLogPsi, J1Spin< FT >::myTableID, J1Spin< FT >::myVars, qmcplusplus::Units::time::ns, J1Spin< FT >::NumTargetGroups, J1Spin< FT >::OffSet, OHMMS_DIM, VariableSet::recompute(), J1Spin< FT >::resizeWFOptVectors(), qmcplusplus::Units::second, VariableSet::size(), and VariableSet::where().

Referenced by J1Spin< FT >::evaluateDerivatives().

255  {
257 
258  bool recalculate(false);
259  std::vector<bool> rcsingles(myVars.size(), false);
260  for (int k = 0; k < myVars.size(); ++k)
261  {
262  int kk = myVars.where(k);
263  if (kk < 0)
264  continue;
265  if (active.recompute(kk))
266  recalculate = true;
267  rcsingles[k] = true;
268  }
269  if (recalculate)
270  {
271  const size_t NumVars = myVars.size();
272  for (int p = 0; p < NumVars; ++p)
273  {
274  gradLogPsi[p] = 0.0;
275  lapLogPsi[p] = 0.0;
276  }
277  dLogPsi = 0.0;
278 
279  const auto& d_table = P.getDistTableAB(myTableID);
280  std::vector<TinyVector<RealType, 3>> derivs(NumVars);
281 
282  constexpr RealType cone(1);
283  constexpr RealType lapfac(OHMMS_DIM - cone);
284  const size_t ns = d_table.sources();
285  const size_t nt = P.getTotalNum();
286 
287  aligned_vector<int> iadj(nt);
288  aligned_vector<RealType> dist(nt);
289  std::vector<PosType> displ(nt);
290 
291  for (size_t i = 0; i < ns; ++i)
292  {
293  for (size_t j = 0; j < nt; ++j)
294  {
295  const auto functor_idx = Ions.getGroupID(i) * NumTargetGroups + P.getGroupID(j);
296  const int first(OffSet[functor_idx].first);
297  const int last(OffSet[functor_idx].second);
298  bool recalcFunc(false);
299  for (int rcs = first; rcs < last; rcs++)
300  if (rcsingles[rcs] == true)
301  recalcFunc = true;
302  if (recalcFunc)
303  {
304  auto* func = J1UniqueFunctors[functor_idx].get();
305  if (func == nullptr)
306  continue;
307  std::fill(derivs.begin(), derivs.end(), 0);
308  auto dist = P.getDistTableAB(myTableID).getDistRow(j)[i];
309  if (!func->evaluateDerivatives(dist, derivs))
310  continue;
311  RealType rinv(cone / dist);
312  const PosType& dr = P.getDistTableAB(myTableID).getDisplRow(j)[i];
313  for (int p = first, ip = 0; p < last; ++p, ++ip)
314  {
315  dLogPsi[p] -= derivs[ip][0];
316  RealType dudr(rinv * derivs[ip][1]);
317  gradLogPsi[p][j] += dudr * dr;
318  lapLogPsi[p][j] -= derivs[ip][2] + lapfac * dudr;
319  }
320  }
321  }
322  }
323  for (int k = 0; k < myVars.size(); ++k)
324  {
325  int kk = myVars.where(k);
326  if (kk < 0)
327  continue;
328  if (rcsingles[k])
329  {
330  dlogpsi[kk] = ValueType(dLogPsi[k]);
331  }
332  }
333  }
334  }
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
constexpr std::complex< float > cone
Definition: BLAS.hpp:50
std::vector< std::pair< int, int > > OffSet
Definition: J1Spin.h:81
#define OHMMS_DIM
Definition: config.h:64
std::vector< ValueDerivVec > lapLogPsi
Definition: J1Spin.h:84
opt_variables_type myVars
variables handled by this orbital
Definition: J1Spin.h:65
const int NumTargetGroups
Definition: J1Spin.h:60
QMCTraits::PosType PosType
QTBase::ValueType ValueType
Definition: Configuration.h:60
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_type size() const
return the size
Definition: VariableSet.h:88
void resizeWFOptVectors()
Definition: J1Spin.h:86
QMCTraits::RealType RealType
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1Spin.h:62
Vector< RealType > dLogPsi
Definition: J1Spin.h:82
std::vector< GradDerivVec > gradLogPsi
Definition: J1Spin.h:83
const int myTableID
table index
Definition: J1Spin.h:50
int getGroupID(int iat) const
return the group id of a given particle in the particle set.
Definition: ParticleSet.h:520

◆ evaluateGL()

LogValue evaluateGL ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L,
bool  fromscratch = false 
)
inlineoverridevirtual

compute gradients and laplacian of the TWF with respect to each particle.

Parameters
Pparticle set
GGradients, $\nabla\ln\Psi$
LLaplacians, $\nabla^2\ln\Psi$
fromscratchif true and this WFC is sensitive to numeical error accumulation, all the internal data are recomputed from scratch.
Returns
log(psi)

Reimplemented from WaveFunctionComponent.

Definition at line 380 of file J1Spin.h.

References J1Spin< FT >::computeGL(), and WaveFunctionComponent::log_value_.

384  {
385  return log_value_ = computeGL(G, L);
386  }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
Definition: J1Spin.h:370

◆ evaluateHessian()

void evaluateHessian ( ParticleSet P,
HessVector grad_grad_psi 
)
inlineoverridevirtual

Reimplemented from WaveFunctionComponent.

Definition at line 179 of file J1Spin.h.

References Tensor< T, D >::diagonal(), ParticleSet::getDistTableAB(), ParticleSet::getGroupID(), J1Spin< FT >::Ions, J1Spin< FT >::J1UniqueFunctors, J1Spin< FT >::myTableID, J1Spin< FT >::Nelec, J1Spin< FT >::Nions, J1Spin< FT >::NumTargetGroups, and qmcplusplus::outerProduct().

180  {
181  const auto& d_ie(P.getDistTableAB(myTableID));
182  valT dudr, d2udr2;
183 
184  Tensor<valT, DIM> ident;
185  grad_grad_psi = 0.0;
186  ident.diagonal(1.0);
187 
188  for (int iel = 0; iel < Nelec; ++iel)
189  {
190  const auto& dist = d_ie.getDistRow(iel);
191  const auto& displ = d_ie.getDisplRow(iel);
192  for (int iat = 0; iat < Nions; iat++)
193  {
194  auto gid = Ions.getGroupID(iat) * NumTargetGroups + P.getGroupID(iel);
195  auto* func = J1UniqueFunctors[gid].get();
196  if (func != nullptr)
197  {
198  RealType r = dist[iat];
199  RealType rinv = 1.0 / r;
200  PosType dr = displ[iat];
201  func->evaluate(r, dudr, d2udr2);
202  grad_grad_psi[iel] -= rinv * rinv * outerProduct(dr, dr) * (d2udr2 - dudr * rinv) + ident * dudr * rinv;
203  }
204  }
205  }
206  }
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
const int NumTargetGroups
Definition: J1Spin.h:60
QMCTraits::PosType PosType
const int Nelec
number of electrons
Definition: J1Spin.h:54
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > outerProduct(const TinyVector< T1, D > &lhs, const TinyVector< T2, D > &rhs)
Definition: TinyVector.h:211
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1Spin.h:39
const int Nions
number of ions
Definition: J1Spin.h:52
QMCTraits::RealType RealType
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1Spin.h:62
const int myTableID
table index
Definition: J1Spin.h:50
int getGroupID(int iat) const
return the group id of a given particle in the particle set.
Definition: ParticleSet.h:520

◆ evaluateLog()

LogValue evaluateLog ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
)
inlineoverridevirtual

evaluate the value of the WaveFunctionComponent from scratch

Parameters
[in]Pactive ParticleSet
[out]GGradients, $\nabla\ln\Psi$
[out]LLaplacians, $\nabla^2\ln\Psi$
Returns
the log value

Mainly for walker-by-walker move. The initial stage of particle-by-particle move also uses this. causes complete state update in WFC's

Implements WaveFunctionComponent.

Definition at line 171 of file J1Spin.h.

References J1Spin< FT >::computeGL(), WaveFunctionComponent::log_value_, and J1Spin< FT >::recompute().

174  {
175  recompute(P);
176  return log_value_ = computeGL(G, L);
177  }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
Definition: J1Spin.h:370
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
Definition: J1Spin.h:160

◆ evaluateRatios()

void evaluateRatios ( const VirtualParticleSet VP,
std::vector< ValueType > &  ratios 
)
inlineoverride

Definition at line 215 of file J1Spin.h.

References J1Spin< FT >::computeU(), qmcplusplus::exp(), DistanceTableAB::getDistRow(), ParticleSet::getDistTableAB(), VirtualParticleSet::getRefPS(), J1Spin< FT >::myTableID, VirtualParticleSet::refPtcl, and J1Spin< FT >::Vat.

216  {
217  for (int k = 0; k < ratios.size(); ++k)
218  ratios[k] =
219  std::exp(Vat[VP.refPtcl] - computeU(VP.getRefPS(), VP.refPtcl, VP.getDistTableAB(myTableID).getDistRow(k)));
220  }
valT computeU(const ParticleSet &P, int iat, const DistRow &dist)
Definition: J1Spin.h:337
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
Vector< valT > Vat
Definition: J1Spin.h:72
const int myTableID
table index
Definition: J1Spin.h:50

◆ evaluateRatiosAlltoOne()

void evaluateRatiosAlltoOne ( ParticleSet P,
std::vector< ValueType > &  ratios 
)
inlineoverride

Definition at line 350 of file J1Spin.h.

References J1Spin< FT >::curAt, J1Spin< FT >::DistCompressed, qmcplusplus::exp(), ParticleSet::first(), ParticleSet::getDistTableAB(), DistanceTableAB::getTempDists(), J1Spin< FT >::Ions, J1Spin< FT >::J1UniqueFunctors, ParticleSet::last(), J1Spin< FT >::myTableID, J1Spin< FT >::Nelec, J1Spin< FT >::NumGroups, J1Spin< FT >::NumTargetGroups, and J1Spin< FT >::Vat.

351  {
352  const auto& dist = P.getDistTableAB(myTableID).getTempDists();
353  curAt = valT(0);
354  for (int ig = 0; ig < NumGroups; ++ig)
355  {
356  for (int jg = 0; jg < NumTargetGroups; ++jg)
357  {
358  auto gid = ig * NumTargetGroups + jg;
359  if (J1UniqueFunctors[gid] != nullptr)
360  curAt +=
361  J1UniqueFunctors[gid]->evaluateV(-1, Ions.first(ig), Ions.last(ig), dist.data(), DistCompressed.data());
362  }
363  }
364 
365  for (int i = 0; i < Nelec; ++i)
366  ratios[i] = std::exp(Vat[i] - curAt);
367  }
const int NumGroups
Definition: J1Spin.h:58
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
aligned_vector< valT > DistCompressed
Definition: J1Spin.h:74
const int NumTargetGroups
Definition: J1Spin.h:60
const int Nelec
number of electrons
Definition: J1Spin.h:54
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1Spin.h:39
Vector< valT > Vat
Definition: J1Spin.h:72
const ParticleSet & Ions
reference to the sources (ions)
Definition: J1Spin.h:62
const int myTableID
table index
Definition: J1Spin.h:50

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
inlineoverridevirtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented from WaveFunctionComponent.

Definition at line 516 of file J1Spin.h.

References J1Spin< FT >::J1UniqueFunctors, and UniqueOptObjRefs::push_back().

517  {
518  for (auto& functor : J1UniqueFunctors)
519  opt_obj_refs.push_back(*functor);
520  }
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 130 of file J1Spin.h.

130 { return "J1Spin"; }

◆ initialize()

void initialize ( ParticleSet els)
inline

Definition at line 133 of file J1Spin.h.

References J1Spin< FT >::d2U, J1Spin< FT >::d3U, J1Spin< FT >::DistCompressed, J1Spin< FT >::DistIndice, J1Spin< FT >::dU, J1Spin< FT >::Grad, J1Spin< FT >::J1UniqueFunctors, J1Spin< FT >::Lap, J1Spin< FT >::Nelec, J1Spin< FT >::Nions, J1Spin< FT >::NumGroups, J1Spin< FT >::NumTargetGroups, Vector< T, Alloc >::resize(), J1Spin< FT >::U, and J1Spin< FT >::Vat.

Referenced by J1Spin< FT >::J1Spin().

134  {
136  Vat.resize(Nelec);
137  Grad.resize(Nelec);
138  Lap.resize(Nelec);
139 
140  U.resize(Nions);
141  dU.resize(Nions);
142  d2U.resize(Nions);
143  d3U.resize(Nions);
144  DistCompressed.resize(Nions);
145  DistIndice.resize(Nions);
146  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
const int NumGroups
Definition: J1Spin.h:58
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
Definition: J1Spin.h:79
aligned_vector< valT > DistCompressed
Definition: J1Spin.h:74
const int NumTargetGroups
Definition: J1Spin.h:60
const int Nelec
number of electrons
Definition: J1Spin.h:54
Vector< posT > Grad
Definition: J1Spin.h:76
Vector< valT > Lap
Definition: J1Spin.h:77
aligned_vector< valT > dU
Definition: J1Spin.h:73
Vector< valT > Vat
Definition: J1Spin.h:72
aligned_vector< int > DistIndice
Definition: J1Spin.h:75
const int Nions
number of ions
Definition: J1Spin.h:52
aligned_vector< valT > U
Definition: J1Spin.h:73
aligned_vector< valT > d3U
Definition: J1Spin.h:73
aligned_vector< valT > d2U
Definition: J1Spin.h:73

◆ isOptimizable()

bool isOptimizable ( ) const
inlineoverridevirtual

WaveFunctionComponent virtual functions that are not essential for the development

Reimplemented from WaveFunctionComponent.

Definition at line 514 of file J1Spin.h.

514 { return true; }

◆ makeClone()

std::unique_ptr<WaveFunctionComponent> makeClone ( ParticleSet tqp) const
inlineoverridevirtual

make clone

Parameters
tqptarget Quantum ParticleSet
deepcopyif true, make a decopy

If not true, return a proxy class

Reimplemented from WaveFunctionComponent.

Definition at line 507 of file J1Spin.h.

508  {
509  auto cloned_J1Spin = std::make_unique<J1Spin<FT>>(*this, tqp);
510  return cloned_J1Spin;
511  }

◆ ratio()

PsiValue ratio ( ParticleSet P,
int  iat 
)
inlineoverridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value

Parameters
Pthe active ParticleSet
iatthe index of a particle
Returns
$ \psi( \{ {\bf R}^{'} \} )/ \psi( \{ {\bf R}\})$

Specialized for particle-by-particle move

Implements WaveFunctionComponent.

Definition at line 208 of file J1Spin.h.

References J1Spin< FT >::computeU(), J1Spin< FT >::curAt, qmcplusplus::exp(), ParticleSet::getDistTableAB(), DistanceTableAB::getTempDists(), J1Spin< FT >::myTableID, WaveFunctionComponent::ORB_PBYP_RATIO, WaveFunctionComponent::UpdateMode, and J1Spin< FT >::Vat.

209  {
211  curAt = computeU(P, iat, P.getDistTableAB(myTableID).getTempDists());
212  return std::exp(static_cast<PsiValue>(Vat[iat] - curAt));
213  }
valT computeU(const ParticleSet &P, int iat, const DistRow &dist)
Definition: J1Spin.h:337
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
Vector< valT > Vat
Definition: J1Spin.h:72
const int myTableID
table index
Definition: J1Spin.h:50

◆ ratioGrad()

PsiValue ratioGrad ( ParticleSet P,
int  iat,
GradType grad_iat 
)
inlineoverridevirtual

compute the gradient during particle-by-particle update

Parameters
Pquantum particleset
iatparticle index

Using getTempDists(). curAt, curGrad and curLap are computed.

Reimplemented from WaveFunctionComponent.

Definition at line 443 of file J1Spin.h.

References qmcplusplus::simd::accumulate_n(), J1Spin< FT >::accumulateGL(), J1Spin< FT >::computeU3(), J1Spin< FT >::curAt, J1Spin< FT >::curGrad, J1Spin< FT >::curLap, J1Spin< FT >::d2U, J1Spin< FT >::dU, qmcplusplus::exp(), ParticleSet::getDistTableAB(), DistanceTableAB::getTempDispls(), DistanceTableAB::getTempDists(), J1Spin< FT >::myTableID, J1Spin< FT >::Nions, WaveFunctionComponent::ORB_PBYP_PARTIAL, J1Spin< FT >::U, WaveFunctionComponent::UpdateMode, and J1Spin< FT >::Vat.

444  {
446 
447  computeU3(P, iat, P.getDistTableAB(myTableID).getTempDists());
448  curLap = accumulateGL(dU.data(), d2U.data(), P.getDistTableAB(myTableID).getTempDispls(), curGrad);
449  curAt = simd::accumulate_n(U.data(), Nions, valT());
450  grad_iat += curGrad;
451  return std::exp(static_cast<PsiValue>(Vat[iat] - curAt));
452  }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
aligned_vector< valT > dU
Definition: J1Spin.h:73
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1Spin.h:39
Vector< valT > Vat
Definition: J1Spin.h:72
const int Nions
number of ions
Definition: J1Spin.h:52
aligned_vector< valT > U
Definition: J1Spin.h:73
valT accumulateGL(const valT *restrict du, const valT *restrict d2u, const DisplRow &displ, posT &grad) const
compute gradient and lap
Definition: J1Spin.h:391
const int myTableID
table index
Definition: J1Spin.h:50
aligned_vector< valT > d2U
Definition: J1Spin.h:73
void computeU3(const ParticleSet &P, int iat, const DistRow &dist)
compute U, dU and d2U
Definition: J1Spin.h:415

◆ recompute()

void recompute ( const ParticleSet P)
inlineoverridevirtual

recompute the value of the WaveFunctionComponents which require critical accuracy.

needed for Slater Determinants but not needed for most types of WaveFunctionComponents

Reimplemented from WaveFunctionComponent.

Definition at line 160 of file J1Spin.h.

References qmcplusplus::simd::accumulate_n(), J1Spin< FT >::accumulateGL(), J1Spin< FT >::computeU3(), J1Spin< FT >::d2U, J1Spin< FT >::dU, ParticleSet::getDistTableAB(), J1Spin< FT >::Grad, J1Spin< FT >::Lap, J1Spin< FT >::myTableID, J1Spin< FT >::Nelec, J1Spin< FT >::Nions, J1Spin< FT >::U, and J1Spin< FT >::Vat.

Referenced by J1Spin< FT >::evaluateLog().

161  {
162  const auto& d_ie(P.getDistTableAB(myTableID));
163  for (int iat = 0; iat < Nelec; ++iat)
164  {
165  computeU3(P, iat, d_ie.getDistRow(iat));
166  Vat[iat] = simd::accumulate_n(U.data(), Nions, valT());
167  Lap[iat] = accumulateGL(dU.data(), d2U.data(), d_ie.getDisplRow(iat), Grad[iat]);
168  }
169  }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
const int Nelec
number of electrons
Definition: J1Spin.h:54
Vector< posT > Grad
Definition: J1Spin.h:76
Vector< valT > Lap
Definition: J1Spin.h:77
aligned_vector< valT > dU
Definition: J1Spin.h:73
typename FT::real_type valT
type of each component U, dU, d2U;
Definition: J1Spin.h:39
Vector< valT > Vat
Definition: J1Spin.h:72
const int Nions
number of ions
Definition: J1Spin.h:52
aligned_vector< valT > U
Definition: J1Spin.h:73
valT accumulateGL(const valT *restrict du, const valT *restrict d2u, const DisplRow &displ, posT &grad) const
compute gradient and lap
Definition: J1Spin.h:391
const int myTableID
table index
Definition: J1Spin.h:50
aligned_vector< valT > d2U
Definition: J1Spin.h:73
void computeU3(const ParticleSet &P, int iat, const DistRow &dist)
compute U, dU and d2U
Definition: J1Spin.h:415

◆ registerData()

void registerData ( ParticleSet P,
WFBufferType buf 
)
inlineoverridevirtual

For particle-by-particle move.

Requests space in the buffer based on the data type sizes of the objects in this class.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 473 of file J1Spin.h.

References PooledMemory< T_scalar, Alloc >::add(), Vector< T, Alloc >::begin(), WaveFunctionComponent::Bytes_in_WFBuffer, PooledMemory< T_scalar, Alloc >::current(), Vector< T, Alloc >::end(), PooledMemory< T_scalar, Alloc >::forward(), Vector< T, Alloc >::free(), J1Spin< FT >::Grad, J1Spin< FT >::Lap, and J1Spin< FT >::Vat.

474  {
475  if (Bytes_in_WFBuffer == 0)
476  {
477  Bytes_in_WFBuffer = buf.current();
478  buf.add(Vat.begin(), Vat.end());
479  buf.add(Grad.begin(), Grad.end());
480  buf.add(Lap.begin(), Lap.end());
481  Bytes_in_WFBuffer = buf.current() - Bytes_in_WFBuffer;
482  // free local space
483  Vat.free();
484  Grad.free();
485  Lap.free();
486  }
487  else
488  {
489  buf.forward(Bytes_in_WFBuffer);
490  }
491  }
void free()
free
Definition: OhmmsVector.h:196
Vector< posT > Grad
Definition: J1Spin.h:76
Vector< valT > Lap
Definition: J1Spin.h:77
Vector< valT > Vat
Definition: J1Spin.h:72
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

◆ resizeWFOptVectors()

void resizeWFOptVectors ( )
inline

Definition at line 86 of file J1Spin.h.

References J1Spin< FT >::dLogPsi, J1Spin< FT >::gradLogPsi, J1Spin< FT >::lapLogPsi, J1Spin< FT >::myVars, J1Spin< FT >::Nelec, Vector< T, Alloc >::resize(), and VariableSet::size().

Referenced by J1Spin< FT >::evaluateDerivativesWF().

87  {
91  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::vector< ValueDerivVec > lapLogPsi
Definition: J1Spin.h:84
opt_variables_type myVars
variables handled by this orbital
Definition: J1Spin.h:65
ParticleAttrib< QTFull::GradType > GradDerivVec
Definition: J1Spin.h:46
const int Nelec
number of electrons
Definition: J1Spin.h:54
size_type size() const
return the size
Definition: VariableSet.h:88
Vector< RealType > dLogPsi
Definition: J1Spin.h:82
std::vector< GradDerivVec > gradLogPsi
Definition: J1Spin.h:83
ParticleAttrib< QTFull::ValueType > ValueDerivVec
Definition: J1Spin.h:47

◆ restore()

void restore ( int  iat)
inlineoverridevirtual

Rejected move.

Nothing to do

Implements WaveFunctionComponent.

Definition at line 455 of file J1Spin.h.

455 {}

◆ updateBuffer()

LogValue updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)
inlineoverridevirtual

For particle-by-particle move.

Put the objects of this class in the walker buffer or forward the memory cursor.

Parameters
Pparticle set
bufAnonymous storage
fromscratchrequest recomputing the precision critical pieces of wavefunction from scratch
Returns
log value of the wavefunction.

Implements WaveFunctionComponent.

Definition at line 493 of file J1Spin.h.

References WaveFunctionComponent::Bytes_in_WFBuffer, J1Spin< FT >::computeGL(), PooledMemory< T_scalar, Alloc >::forward(), ParticleSet::G, ParticleSet::L, and WaveFunctionComponent::log_value_.

494  {
495  log_value_ = computeGL(P.G, P.L);
496  buf.forward(Bytes_in_WFBuffer);
497  return log_value_;
498  }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
Definition: J1Spin.h:370
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

Member Data Documentation

◆ curAt

◆ curGrad

posT curGrad

Definition at line 69 of file J1Spin.h.

Referenced by J1Spin< FT >::acceptMove(), and J1Spin< FT >::ratioGrad().

◆ curLap

valT curLap

Definition at line 68 of file J1Spin.h.

Referenced by J1Spin< FT >::acceptMove(), and J1Spin< FT >::ratioGrad().

◆ d2U

◆ d3U

Definition at line 73 of file J1Spin.h.

Referenced by J1Spin< FT >::evalGradSource(), and J1Spin< FT >::initialize().

◆ DistCompressed

◆ DistIndice

aligned_vector<int> DistIndice

Definition at line 75 of file J1Spin.h.

Referenced by J1Spin< FT >::computeU3(), and J1Spin< FT >::initialize().

◆ dLogPsi

Vector<RealType> dLogPsi

◆ dU

◆ Grad

◆ gradLogPsi

◆ Ions

◆ J1UniqueFunctors

◆ Lap

◆ lapLogPsi

◆ myTableID

◆ myVars

◆ Nelec

◆ Nions

◆ NumGroups

◆ NumTargetGroups

◆ OffSet

std::vector<std::pair<int, int> > OffSet

◆ U

◆ Vat

◆ qmcplusplus::JeeIOrbitalSoA

class qmcplusplus::JeeIOrbitalSoA

template<class FT>
class qmcplusplus::JeeIOrbitalSoA< FT >

Specialization for three-body Jastrow function using multiple functors.

Each pair-type can have distinct function $u(r_{ij})$. For electrons, distinct pair correlation functions are used for spins up-up/down-down and up-down/down-up.

Definition at line 36 of file JeeIOrbitalSoA.h.

+ Inheritance diagram for JeeIOrbitalSoA< FT >:
+ Collaboration diagram for JeeIOrbitalSoA< FT >:

Public Types

using FuncType = FT
 alias FuncType More...
 
- Public Types inherited from WaveFunctionComponent
enum  {
  ORB_PBYP_RATIO, ORB_PBYP_ALL, ORB_PBYP_PARTIAL, ORB_WALKER,
  ORB_ALLWALKER
}
 enum for a update mode More...
 
using Walker_t = ParticleSet::Walker_t
 
using WFBufferType = Walker_t::WFBuffer_t
 
using BufferType = Walker_t::Buffer_t
 
using RealMatrix_t = OrbitalSetTraits< RealType >::ValueMatrix
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using LogValue = std::complex< QTFull::RealType >
 
using PsiValue = QTFull::ValueType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 JeeIOrbitalSoA (const std::string &obj_name, const ParticleSet &ions, ParticleSet &elecs)
 
std::string getClassName () const override
 return class name More...
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &elecs) const override
 make clone More...
 
void init (ParticleSet &p)
 
void addFunc (int iSpecies, int eSpecies1, int eSpecies2, std::unique_ptr< FT > j)
 
void check_complete ()
 check that correlation information is complete More...
 
bool isOptimizable () const override
 if true, this contains optimizable components More...
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) override
 extract underlying OptimizableObject references More...
 
void checkOutVariables (const opt_variables_type &active) override
 check out optimizable variables More...
 
void build_compact_list (const ParticleSet &P)
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch More...
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios) override
 
GradType evalGrad (ParticleSet &P, int iat) override
 return the current gradient for the iat-th particle More...
 
PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient More...
 
void restore (int iat) override
 If a move for iat-th particle is rejected, restore to the content. More...
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 a move for iat-th particle is accepted. More...
 
void recompute (const ParticleSet &P) override
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
valT computeU (const ParticleSet &P, int jel, int jg, const DistRow &distjI, const DistRow &distjk, std::vector< int > &ions_nearby)
 
void computeU3_engine (const ParticleSet &P, const FT &feeI, int kel_counter, valT &Uj, posT &dUj, valT &d2Uj, Vector< valT > &Uk, gContainer_type &dUk, Vector< valT > &d2Uk)
 
void computeU3 (const ParticleSet &P, int jel, const DistRow &distjI, const DisplRow &displjI, const DistRow &distjk, const DisplRow &displjk, valT &Uj, posT &dUj, valT &d2Uj, Vector< valT > &Uk, gContainer_type &dUk, Vector< valT > &d2Uk, std::vector< int > &ions_nearby, bool triangle=false)
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
 For particle-by-particle move. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch=false) override
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi) override
 
void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int isrc) override
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int isrc, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad) override
 Adds the gradient w.r.t. More...
 
- Public Member Functions inherited from WaveFunctionComponent
const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
virtual void checkSanity () const
 Validate the internal consistency of the object. More...
 
const std::string & getName () const
 return object name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual bool isFermionic () const
 true, if this component is fermionic More...
 
virtual bool isMultiDet () const
 true, if this component is multi-determinant More...
 
virtual void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
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 More...
 
virtual void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 
virtual void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi_all)
 
virtual void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
virtual GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad)
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
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 implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
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. More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
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 p-by-p move region. More...
 
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 More...
 
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 More...
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 acquire a shared resource from a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 return a shared resource to a collection More...
 
virtual RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
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 optimizable parameters. More...
 
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. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void finalizeOptimization ()
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
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 More...
 
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 More...
 
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 More...
 
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 multiple walkers More...
 

Private Types

using valT = typename FT::real_type
 type of each component U, dU, d2U; More...
 
using posT = TinyVector< valT, OHMMS_DIM >
 element position type More...
 
using DistRow = DistanceTable::DistRow
 use the same container More...
 
using DisplRow = DistanceTable::DisplRow
 
using gContainer_type = VectorSoaContainer< valT, OHMMS_DIM >
 $dUat[i] = sum_(j) du_{i,j}$ More...
 

Private Member Functions

void resizeWFOptVectors ()
 
QTFull::RealType computeGL (ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
 compute G and L from internally stored data More...
 

Private Attributes

const int ee_Table_ID_
 table index for el-el More...
 
const int ei_Table_ID_
 table index for i-el More...
 
int Nelec
 
int Nion
 
size_t Nelec_padded
 number of particles + padded More...
 
int eGroups
 
int iGroups
 
const ParticleSetIons
 reference to the sources (ions) More...
 
RealType DiffVal
 diff value More...
 
Vector< valTUat
 $Uat[i] = sum_(j) u_{i,j}$ More...
 
Vector< valToldUk
 
Vector< valTnewUk
 
gContainer_type dUat
 
gContainer_type olddUk
 
gContainer_type newdUk
 
Vector< valTd2Uat
 $d2Uat[i] = sum_(j) d2u_{i,j}$ More...
 
Vector< valToldd2Uk
 
Vector< valTnewd2Uk
 
valT cur_Uat
 current values during PbyP More...
 
valT cur_d2Uat
 
posT cur_dUat
 
posT dUat_temp
 
Array< FT *, 3 > F
 container for the Jastrow functions More...
 
std::map< std::string, std::unique_ptr< FT > > J3Unique
 
std::map< FT *, int > J3UniqueIndex
 
std::vector< valTIon_cutoff
 the cutoff for e-I pairs More...
 
Array< std::vector< int >, 2 > elecs_inside
 the electrons around ions within the cutoff radius, grouped by species More...
 
Array< std::vector< valT >, 2 > elecs_inside_dist
 
Array< std::vector< posT >, 2 > elecs_inside_displ
 
std::vector< int > ions_nearby_old
 the ids of ions within the cutoff radius of an electron on which a move is proposed More...
 
std::vector< int > ions_nearby_new
 
size_t Nbuffer
 work buffer size More...
 
aligned_vector< valTDistjk_Compressed
 compressed distances More...
 
aligned_vector< valTDistkI_Compressed
 
aligned_vector< valTDistjI_Compressed
 
std::vector< int > DistIndice_k
 
gContainer_type Disp_jk_Compressed
 compressed displacements More...
 
gContainer_type Disp_jI_Compressed
 
gContainer_type Disp_kI_Compressed
 
VectorSoaContainer< valT, 9 > mVGL
 work result buffer More...
 
Array< std::pair< int, int >, 3 > VarOffset
 
Vector< RealTypedLogPsi
 
Array< PosType, 2 > gradLogPsi
 
Array< RealType, 2 > lapLogPsi
 
std::vector< std::vector< RealType > > du_dalpha
 
std::vector< std::vector< PosType > > dgrad_dalpha
 
std::vector< std::vector< Tensor< RealType, 3 > > > dhess_dalpha
 

Additional Inherited Members

- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 
- Protected Attributes inherited from WaveFunctionComponent
const std::string my_name_
 Name of the object It is required to be different for objects of the same derived type like multiple J1. More...
 
LogValue log_value_
 Current $\log\phi $. More...
 

Member Typedef Documentation

◆ DisplRow

Definition at line 44 of file JeeIOrbitalSoA.h.

◆ DistRow

use the same container

Definition at line 43 of file JeeIOrbitalSoA.h.

◆ FuncType

using FuncType = FT

alias FuncType

Definition at line 146 of file JeeIOrbitalSoA.h.

◆ gContainer_type

$dUat[i] = sum_(j) du_{i,j}$

Definition at line 63 of file JeeIOrbitalSoA.h.

◆ posT

using posT = TinyVector<valT, OHMMS_DIM>
private

element position type

Definition at line 41 of file JeeIOrbitalSoA.h.

◆ valT

using valT = typename FT::real_type
private

type of each component U, dU, d2U;

Definition at line 39 of file JeeIOrbitalSoA.h.

Constructor & Destructor Documentation

◆ JeeIOrbitalSoA()

JeeIOrbitalSoA ( const std::string &  obj_name,
const ParticleSet ions,
ParticleSet elecs 
)
inline

Definition at line 148 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::init(), and WaveFunctionComponent::my_name_.

149  : WaveFunctionComponent(obj_name),
152  Ions(ions)
153  {
154  if (my_name_.empty())
155  throw std::runtime_error("JeeIOrbitalSoA object name cannot be empty!");
156  init(elecs);
157  }
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
const int ee_Table_ID_
table index for el-el
For distance tables of virtual particle (VP) sets constructed based on this table, whether full table is needed on host The corresponding DT of VP need to set MW_EVALUATE_RESULT_NO_TRANSFER_TO_HOST accordingly.
const int ei_Table_ID_
table index for i-el
const ParticleSet & Ions
reference to the sources (ions)
whether full table needs to be ready at anytime or not during PbyP Optimization can be implemented du...
WaveFunctionComponent(const std::string &obj_name="")
default constructor
void init(ParticleSet &p)
whether temporary data set on the host is updated or not when a move is proposed. ...

Member Function Documentation

◆ acceptMove()

void acceptMove ( ParticleSet P,
int  iat,
bool  safe_to_delay = false 
)
inlineoverridevirtual

a move for iat-th particle is accepted.

Update the current content.

Parameters
Ptarget ParticleSet
iatindex of the particle whose new position was proposed
safe_to_delayif true, delayed accept is safe.

Implements WaveFunctionComponent.

Definition at line 453 of file JeeIOrbitalSoA.h.

References qmcplusplus::abs(), Array< T, D, ALLOC >::begin(), JeeIOrbitalSoA< FT >::computeU3(), JeeIOrbitalSoA< FT >::cur_d2Uat, JeeIOrbitalSoA< FT >::cur_dUat, JeeIOrbitalSoA< FT >::cur_Uat, JeeIOrbitalSoA< FT >::d2Uat, VectorSoaContainer< T, D, Alloc >::data(), JeeIOrbitalSoA< FT >::dUat, JeeIOrbitalSoA< FT >::dUat_temp, JeeIOrbitalSoA< FT >::ee_Table_ID_, JeeIOrbitalSoA< FT >::ei_Table_ID_, JeeIOrbitalSoA< FT >::elecs_inside, JeeIOrbitalSoA< FT >::elecs_inside_displ, JeeIOrbitalSoA< FT >::elecs_inside_dist, ParticleSet::getDistTableAA(), ParticleSet::getDistTableAB(), ParticleSet::GroupID, JeeIOrbitalSoA< FT >::Ion_cutoff, JeeIOrbitalSoA< FT >::ions_nearby_new, JeeIOrbitalSoA< FT >::ions_nearby_old, WaveFunctionComponent::log_value_, JeeIOrbitalSoA< FT >::Nelec, JeeIOrbitalSoA< FT >::newd2Uk, JeeIOrbitalSoA< FT >::newdUk, JeeIOrbitalSoA< FT >::newUk, OHMMS_DIM, JeeIOrbitalSoA< FT >::oldd2Uk, JeeIOrbitalSoA< FT >::olddUk, JeeIOrbitalSoA< FT >::oldUk, WaveFunctionComponent::ORB_PBYP_RATIO, JeeIOrbitalSoA< FT >::Uat, and WaveFunctionComponent::UpdateMode.

454  {
455  const auto& eI_table = P.getDistTableAB(ei_Table_ID_);
456  const auto& ee_table = P.getDistTableAA(ee_Table_ID_);
457  // get the old value, grad, lapl
458  computeU3(P, iat, eI_table.getDistRow(iat), eI_table.getDisplRow(iat), ee_table.getOldDists(),
459  ee_table.getOldDispls(), Uat[iat], dUat_temp, d2Uat[iat], oldUk, olddUk, oldd2Uk, ions_nearby_old);
460  if (UpdateMode == ORB_PBYP_RATIO)
461  { //ratio-only during the move; need to compute derivatives
462  computeU3(P, iat, eI_table.getTempDists(), eI_table.getTempDispls(), ee_table.getTempDists(),
463  ee_table.getTempDispls(), cur_Uat, cur_dUat, cur_d2Uat, newUk, newdUk, newd2Uk, ions_nearby_new);
464  }
465 
466 #pragma omp simd
467  for (int jel = 0; jel < Nelec; jel++)
468  {
469  Uat[jel] += newUk[jel] - oldUk[jel];
470  d2Uat[jel] += newd2Uk[jel] - oldd2Uk[jel];
471  }
472  for (int idim = 0; idim < OHMMS_DIM; ++idim)
473  {
474  valT* restrict save_g = dUat.data(idim);
475  const valT* restrict new_g = newdUk.data(idim);
476  const valT* restrict old_g = olddUk.data(idim);
477 #pragma omp simd aligned(save_g, new_g, old_g : QMC_SIMD_ALIGNMENT)
478  for (int jel = 0; jel < Nelec; jel++)
479  save_g[jel] += new_g[jel] - old_g[jel];
480  }
481 
482  log_value_ += Uat[iat] - cur_Uat;
483  Uat[iat] = cur_Uat;
484  dUat(iat) = cur_dUat;
485  d2Uat[iat] = cur_d2Uat;
486 
487  const int ig = P.GroupID[iat];
488  // update compact list elecs_inside
489  // if the old position exists in elecs_inside
490  for (int iind = 0; iind < ions_nearby_old.size(); iind++)
491  {
492  int jat = ions_nearby_old[iind];
493  auto iter = std::find(elecs_inside(ig, jat).begin(), elecs_inside(ig, jat).end(), iat);
494  auto iter_dist = elecs_inside_dist(ig, jat).begin() + std::distance(elecs_inside(ig, jat).begin(), iter);
495  auto iter_displ = elecs_inside_displ(ig, jat).begin() + std::distance(elecs_inside(ig, jat).begin(), iter);
496 // sentinel code
497 #ifndef NDEBUG
498  if (iter == elecs_inside(ig, jat).end())
499  {
500  std::cerr << std::setprecision(std::numeric_limits<valT>::digits10 + 1) << "updating electron iat = " << iat
501  << " near ion " << jat << " dist " << eI_table.getDistRow(iat)[jat] << std::endl;
502  throw std::runtime_error("BUG electron not found in elecs_inside");
503  }
504  else if (std::abs(eI_table.getDistRow(iat)[jat] - *iter_dist) >= std::numeric_limits<valT>::epsilon())
505  {
506  std::cerr << std::setprecision(std::numeric_limits<valT>::digits10 + 1) << "inconsistent electron iat = " << iat
507  << " near ion " << jat << " dist " << eI_table.getDistRow(iat)[jat]
508  << " stored value = " << *iter_dist << std::endl;
509  throw std::runtime_error("BUG eI distance stored value elecs_inside_dist not matching distance table");
510  }
511 #endif
512 
513  if (eI_table.getTempDists()[jat] < Ion_cutoff[jat]) // the new position is still inside
514  {
515  *iter_dist = eI_table.getTempDists()[jat];
516  *iter_displ = eI_table.getTempDispls()[jat];
517  *std::find(ions_nearby_new.begin(), ions_nearby_new.end(), jat) = -1;
518  }
519  else
520  {
521  *iter = elecs_inside(ig, jat).back();
522  elecs_inside(ig, jat).pop_back();
523  *iter_dist = elecs_inside_dist(ig, jat).back();
524  elecs_inside_dist(ig, jat).pop_back();
525  *iter_displ = elecs_inside_displ(ig, jat).back();
526  elecs_inside_displ(ig, jat).pop_back();
527  }
528  }
529 
530  // if the old position doesn't exist in elecs_inside but the new position do
531  for (int iind = 0; iind < ions_nearby_new.size(); iind++)
532  {
533  int jat = ions_nearby_new[iind];
534  if (jat >= 0)
535  {
536  elecs_inside(ig, jat).push_back(iat);
537  elecs_inside_dist(ig, jat).push_back(eI_table.getTempDists()[jat]);
538  elecs_inside_displ(ig, jat).push_back(eI_table.getTempDispls()[jat]);
539  }
540  }
541  }
const int ee_Table_ID_
table index for el-el
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::vector< int > ions_nearby_old
the ids of ions within the cutoff radius of an electron on which a move is proposed ...
#define OHMMS_DIM
Definition: config.h:64
Array< std::vector< posT >, 2 > elecs_inside_displ
Array< std::vector< valT >, 2 > elecs_inside_dist
std::vector< valT > Ion_cutoff
the cutoff for e-I pairs
void computeU3(const ParticleSet &P, int jel, const DistRow &distjI, const DisplRow &displjI, const DistRow &distjk, const DisplRow &displjk, valT &Uj, posT &dUj, valT &d2Uj, Vector< valT > &Uk, gContainer_type &dUk, Vector< valT > &d2Uk, std::vector< int > &ions_nearby, bool triangle=false)
const int ei_Table_ID_
table index for i-el
typename FT::real_type valT
type of each component U, dU, d2U;
std::vector< int > ions_nearby_new
Array< std::vector< int >, 2 > elecs_inside
the electrons around ions within the cutoff radius, grouped by species
Container_t::iterator begin()
Definition: OhmmsArray.h:80
valT cur_Uat
current values during PbyP

◆ addFunc()

void addFunc ( int  iSpecies,
int  eSpecies1,
int  eSpecies2,
std::unique_ptr< FT >  j 
)
inline

Definition at line 226 of file JeeIOrbitalSoA.h.

References APP_ABORT, JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::F, ParticleSet::GroupID, JeeIOrbitalSoA< FT >::Ion_cutoff, JeeIOrbitalSoA< FT >::Ions, JeeIOrbitalSoA< FT >::J3Unique, and JeeIOrbitalSoA< FT >::Nion.

227  {
228  if (eSpecies1 == eSpecies2)
229  {
230  //if only up-up is specified, assume spin-unpolarized correlations
231  if (eSpecies1 == 0)
232  for (int eG1 = 0; eG1 < eGroups; eG1++)
233  for (int eG2 = 0; eG2 < eGroups; eG2++)
234  {
235  if (F(iSpecies, eG1, eG2) == 0)
236  F(iSpecies, eG1, eG2) = j.get();
237  }
238  }
239  else
240  {
241  F(iSpecies, eSpecies1, eSpecies2) = j.get();
242  F(iSpecies, eSpecies2, eSpecies1) = j.get();
243  }
244  if (j)
245  {
246  RealType rcut = 0.5 * j->cutoff_radius;
247  for (int i = 0; i < Nion; i++)
248  if (Ions.GroupID[i] == iSpecies)
249  Ion_cutoff[i] = rcut;
250  }
251  else
252  {
253  APP_ABORT("JeeIOrbitalSoA::addFunc Jastrow function pointer is NULL");
254  }
255  std::stringstream aname;
256  aname << iSpecies << "_" << eSpecies1 << "_" << eSpecies2;
257  J3Unique.emplace(aname.str(), std::move(j));
258  }
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
std::vector< valT > Ion_cutoff
the cutoff for e-I pairs
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::map< std::string, std::unique_ptr< FT > > J3Unique
QMCTraits::RealType RealType
const ParticleSet & Ions
reference to the sources (ions)
Array< FT *, 3 > F
container for the Jastrow functions

◆ build_compact_list()

void build_compact_list ( const ParticleSet P)
inline

Definition at line 354 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::ei_Table_ID_, JeeIOrbitalSoA< FT >::elecs_inside, JeeIOrbitalSoA< FT >::elecs_inside_displ, JeeIOrbitalSoA< FT >::elecs_inside_dist, ParticleSet::first(), DistanceTableAB::getDisplacements(), DistanceTableAB::getDistances(), ParticleSet::getDistTableAB(), JeeIOrbitalSoA< FT >::Ion_cutoff, ParticleSet::last(), and JeeIOrbitalSoA< FT >::Nion.

Referenced by JeeIOrbitalSoA< FT >::copyFromBuffer(), JeeIOrbitalSoA< FT >::evalGradSource(), JeeIOrbitalSoA< FT >::evaluateDerivatives(), JeeIOrbitalSoA< FT >::evaluateDerivativesWF(), and JeeIOrbitalSoA< FT >::recompute().

355  {
356  const auto& eI_dists = P.getDistTableAB(ei_Table_ID_).getDistances();
357  const auto& eI_displs = P.getDistTableAB(ei_Table_ID_).getDisplacements();
358 
359  for (int iat = 0; iat < Nion; ++iat)
360  for (int jg = 0; jg < eGroups; ++jg)
361  {
362  elecs_inside(jg, iat).clear();
363  elecs_inside_dist(jg, iat).clear();
364  elecs_inside_displ(jg, iat).clear();
365  }
366 
367  for (int jg = 0; jg < eGroups; ++jg)
368  for (int jel = P.first(jg); jel < P.last(jg); jel++)
369  for (int iat = 0; iat < Nion; ++iat)
370  if (eI_dists[jel][iat] < Ion_cutoff[iat])
371  {
372  elecs_inside(jg, iat).push_back(jel);
373  elecs_inside_dist(jg, iat).push_back(eI_dists[jel][iat]);
374  elecs_inside_displ(jg, iat).push_back(eI_displs[jel][iat]);
375  }
376  }
Array< std::vector< posT >, 2 > elecs_inside_displ
Array< std::vector< valT >, 2 > elecs_inside_dist
std::vector< valT > Ion_cutoff
the cutoff for e-I pairs
const int ei_Table_ID_
table index for i-el
Array< std::vector< int >, 2 > elecs_inside
the electrons around ions within the cutoff radius, grouped by species

◆ check_complete()

void check_complete ( )
inline

check that correlation information is complete

Definition at line 263 of file JeeIOrbitalSoA.h.

References APP_ABORT, qmcplusplus::app_log(), JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::F, ParticleSet::GroupID, JeeIOrbitalSoA< FT >::iGroups, JeeIOrbitalSoA< FT >::Ion_cutoff, JeeIOrbitalSoA< FT >::Ions, and JeeIOrbitalSoA< FT >::Nion.

264  {
265  //check that correlation pointers are either all 0 or all assigned
266  bool complete = true;
267  for (int i = 0; i < iGroups; ++i)
268  {
269  int nfilled = 0;
270  bool partial;
271  for (int e1 = 0; e1 < eGroups; ++e1)
272  for (int e2 = 0; e2 < eGroups; ++e2)
273  if (F(i, e1, e2) != 0)
274  nfilled++;
275  partial = nfilled > 0 && nfilled < eGroups * eGroups;
276  if (partial)
277  app_log() << "J3 eeI is missing correlation for ion " << i << std::endl;
278  complete = complete && !partial;
279  }
280  if (!complete)
281  {
282  APP_ABORT("JeeIOrbitalSoA::check_complete J3 eeI is missing correlation components\n see preceding messages "
283  "for details");
284  }
285  //first set radii
286  for (int i = 0; i < Nion; ++i)
287  {
288  FT* f = F(Ions.GroupID[i], 0, 0);
289  if (f != 0)
290  Ion_cutoff[i] = .5 * f->cutoff_radius;
291  }
292  //then check radii
293  bool all_radii_match = true;
294  for (int i = 0; i < iGroups; ++i)
295  {
296  if (F(i, 0, 0) != 0)
297  {
298  bool radii_match = true;
299  RealType rcut = F(i, 0, 0)->cutoff_radius;
300  for (int e1 = 0; e1 < eGroups; ++e1)
301  for (int e2 = 0; e2 < eGroups; ++e2)
302  radii_match = radii_match && F(i, e1, e2)->cutoff_radius == rcut;
303  if (!radii_match)
304  app_log() << "eeI functors for ion species " << i << " have different radii" << std::endl;
305  all_radii_match = all_radii_match && radii_match;
306  }
307  }
308  if (!all_radii_match)
309  {
310  APP_ABORT("JeeIOrbitalSoA::check_radii J3 eeI are inconsistent for some ion species\n see preceding messages "
311  "for details");
312  }
313  }
std::ostream & app_log()
Definition: OutputManager.h:65
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
std::vector< valT > Ion_cutoff
the cutoff for e-I pairs
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
QMCTraits::RealType RealType
const ParticleSet & Ions
reference to the sources (ions)
Array< FT *, 3 > F
container for the Jastrow functions

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
inlineoverridevirtual

check out optimizable variables

Reimplemented from WaveFunctionComponent.

Definition at line 325 of file JeeIOrbitalSoA.h.

References VariableSet::clear(), JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::F, VariableSet::getIndex(), JeeIOrbitalSoA< FT >::iGroups, VariableSet::Index, VariableSet::insertFrom(), JeeIOrbitalSoA< FT >::J3Unique, qmcplusplus::Units::mass::kg, WaveFunctionComponent::myVars, Array< T, D, ALLOC >::resize(), Array< T, D, ALLOC >::size(), VariableSet::size(), and JeeIOrbitalSoA< FT >::VarOffset.

326  {
327  myVars.clear();
328 
329  for (auto& ftPair : J3Unique)
330  {
331  ftPair.second->myVars.getIndex(active);
332  myVars.insertFrom(ftPair.second->myVars);
333  }
334 
335  myVars.getIndex(active);
336  const size_t NumVars = myVars.size();
337  if (NumVars)
338  {
340  int varoffset = myVars.Index[0];
341  for (int ig = 0; ig < iGroups; ig++)
342  for (int jg = 0; jg < eGroups; jg++)
343  for (int kg = 0; kg < eGroups; kg++)
344  {
345  FT* func_ijk = F(ig, jg, kg);
346  if (func_ijk == nullptr)
347  continue;
348  VarOffset(ig, jg, kg).first = func_ijk->myVars.Index.front() - varoffset;
349  VarOffset(ig, jg, kg).second = func_ijk->myVars.Index.size() + VarOffset(ig, jg, kg).first;
350  }
351  }
352  }
std::vector< int > Index
store locator of the named variable
Definition: VariableSet.h:65
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
size_t size() const
Definition: OhmmsArray.h:57
std::map< std::string, std::unique_ptr< FT > > J3Unique
Array< std::pair< int, int >, 3 > VarOffset
void clear()
clear the variable set
Definition: VariableSet.cpp:28
size_type size() const
return the size
Definition: VariableSet.h:88
Array< FT *, 3 > F
container for the Jastrow functions
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
Definition: VariableSet.cpp:37
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter

◆ computeGL()

QTFull::RealType computeGL ( ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
) const
inlineprivate

compute G and L from internally stored data

Definition at line 133 of file JeeIOrbitalSoA.h.

References qmcplusplus::simd::accumulate_n(), JeeIOrbitalSoA< FT >::d2Uat, Vector< T, Alloc >::data(), JeeIOrbitalSoA< FT >::dUat, JeeIOrbitalSoA< FT >::Nelec, and JeeIOrbitalSoA< FT >::Uat.

Referenced by JeeIOrbitalSoA< FT >::evaluateGL(), JeeIOrbitalSoA< FT >::evaluateLog(), and JeeIOrbitalSoA< FT >::updateBuffer().

134  {
135  for (int iat = 0; iat < Nelec; ++iat)
136  {
137  G[iat] += dUat[iat];
138  L[iat] += d2Uat[iat];
139  }
140  return -0.5 * simd::accumulate_n(Uat.data(), Nelec, QTFull::RealType());
141  }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
Precision RealType
Definition: QMCTypes.h:37

◆ computeU()

valT computeU ( const ParticleSet P,
int  jel,
int  jg,
const DistRow distjI,
const DistRow distjk,
std::vector< int > &  ions_nearby 
)
inline

Definition at line 574 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::DistjI_Compressed, JeeIOrbitalSoA< FT >::Distjk_Compressed, JeeIOrbitalSoA< FT >::DistkI_Compressed, JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::elecs_inside, JeeIOrbitalSoA< FT >::elecs_inside_dist, JeeIOrbitalSoA< FT >::F, ParticleSet::GroupID, JeeIOrbitalSoA< FT >::Ion_cutoff, JeeIOrbitalSoA< FT >::Ions, qmcplusplus::Units::mass::kg, JeeIOrbitalSoA< FT >::Nbuffer, JeeIOrbitalSoA< FT >::Nion, and Array< T, D, ALLOC >::size().

Referenced by JeeIOrbitalSoA< FT >::evaluateRatios(), JeeIOrbitalSoA< FT >::evaluateRatiosAlltoOne(), and JeeIOrbitalSoA< FT >::ratio().

580  {
581  ions_nearby.clear();
582  for (int iat = 0; iat < Nion; ++iat)
583  if (distjI[iat] < Ion_cutoff[iat])
584  ions_nearby.push_back(iat);
585 
586  valT Uj = valT(0);
587  for (int kg = 0; kg < eGroups; ++kg)
588  {
589  int kel_counter = 0;
590  for (int iind = 0; iind < ions_nearby.size(); ++iind)
591  {
592  const int iat = ions_nearby[iind];
593  const int ig = Ions.GroupID[iat];
594  const valT r_jI = distjI[iat];
595  for (int kind = 0; kind < elecs_inside(kg, iat).size(); kind++)
596  {
597  const int kel = elecs_inside(kg, iat)[kind];
598  if (kel != jel)
599  {
600  DistkI_Compressed[kel_counter] = elecs_inside_dist(kg, iat)[kind];
601  Distjk_Compressed[kel_counter] = distjk[kel];
602  DistjI_Compressed[kel_counter] = r_jI;
603  kel_counter++;
604  if (kel_counter == Nbuffer)
605  {
606  const FT& feeI(*F(ig, jg, kg));
607  Uj += feeI.evaluateV(kel_counter, Distjk_Compressed.data(), DistjI_Compressed.data(),
608  DistkI_Compressed.data());
609  kel_counter = 0;
610  }
611  }
612  }
613  if ((iind + 1 == ions_nearby.size() || ig != Ions.GroupID[ions_nearby[iind + 1]]) && kel_counter > 0)
614  {
615  const FT& feeI(*F(ig, jg, kg));
616  Uj +=
617  feeI.evaluateV(kel_counter, Distjk_Compressed.data(), DistjI_Compressed.data(), DistkI_Compressed.data());
618  kel_counter = 0;
619  }
620  }
621  }
622  return Uj;
623  }
aligned_vector< valT > DistjI_Compressed
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
Array< std::vector< valT >, 2 > elecs_inside_dist
std::vector< valT > Ion_cutoff
the cutoff for e-I pairs
size_t size() const
Definition: OhmmsArray.h:57
size_t Nbuffer
work buffer size
typename FT::real_type valT
type of each component U, dU, d2U;
const ParticleSet & Ions
reference to the sources (ions)
Array< FT *, 3 > F
container for the Jastrow functions
Array< std::vector< int >, 2 > elecs_inside
the electrons around ions within the cutoff radius, grouped by species
aligned_vector< valT > DistkI_Compressed
aligned_vector< valT > Distjk_Compressed
compressed distances

◆ computeU3()

void computeU3 ( const ParticleSet P,
int  jel,
const DistRow distjI,
const DisplRow displjI,
const DistRow distjk,
const DisplRow displjk,
valT Uj,
posT dUj,
valT d2Uj,
Vector< valT > &  Uk,
gContainer_type dUk,
Vector< valT > &  d2Uk,
std::vector< int > &  ions_nearby,
bool  triangle = false 
)
inline

Definition at line 713 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::computeU3_engine(), BLAS::czero, Vector< T, Alloc >::data(), VectorSoaContainer< T, D, Alloc >::data(), JeeIOrbitalSoA< FT >::Disp_jI_Compressed, JeeIOrbitalSoA< FT >::Disp_jk_Compressed, JeeIOrbitalSoA< FT >::Disp_kI_Compressed, JeeIOrbitalSoA< FT >::DistIndice_k, JeeIOrbitalSoA< FT >::DistjI_Compressed, JeeIOrbitalSoA< FT >::Distjk_Compressed, JeeIOrbitalSoA< FT >::DistkI_Compressed, JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::elecs_inside, JeeIOrbitalSoA< FT >::elecs_inside_displ, JeeIOrbitalSoA< FT >::elecs_inside_dist, JeeIOrbitalSoA< FT >::F, OMPstd::fill_n(), ParticleSet::GroupID, JeeIOrbitalSoA< FT >::Ion_cutoff, JeeIOrbitalSoA< FT >::Ions, qmcplusplus::Units::mass::kg, JeeIOrbitalSoA< FT >::Nbuffer, JeeIOrbitalSoA< FT >::Nelec, JeeIOrbitalSoA< FT >::Nion, OHMMS_DIM, and Array< T, D, ALLOC >::size().

Referenced by JeeIOrbitalSoA< FT >::acceptMove(), JeeIOrbitalSoA< FT >::ratioGrad(), and JeeIOrbitalSoA< FT >::recompute().

727  {
728  constexpr valT czero(0);
729 
730  Uj = czero;
731  dUj = posT();
732  d2Uj = czero;
733 
734  const int jg = P.GroupID[jel];
735 
736  const int kelmax = triangle ? jel : Nelec;
737  std::fill_n(Uk.data(), kelmax, czero);
738  std::fill_n(d2Uk.data(), kelmax, czero);
739  for (int idim = 0; idim < OHMMS_DIM; ++idim)
740  std::fill_n(dUk.data(idim), kelmax, czero);
741 
742  ions_nearby.clear();
743  for (int iat = 0; iat < Nion; ++iat)
744  if (distjI[iat] < Ion_cutoff[iat])
745  ions_nearby.push_back(iat);
746 
747  for (int kg = 0; kg < eGroups; ++kg)
748  {
749  int kel_counter = 0;
750  for (int iind = 0; iind < ions_nearby.size(); ++iind)
751  {
752  const int iat = ions_nearby[iind];
753  const int ig = Ions.GroupID[iat];
754  const valT r_jI = distjI[iat];
755  const posT disp_Ij = displjI[iat];
756  for (int kind = 0; kind < elecs_inside(kg, iat).size(); kind++)
757  {
758  const int kel = elecs_inside(kg, iat)[kind];
759  if (kel < kelmax && kel != jel)
760  {
761  DistkI_Compressed[kel_counter] = elecs_inside_dist(kg, iat)[kind];
762  DistjI_Compressed[kel_counter] = r_jI;
763  Distjk_Compressed[kel_counter] = distjk[kel];
764  Disp_kI_Compressed(kel_counter) = elecs_inside_displ(kg, iat)[kind];
765  Disp_jI_Compressed(kel_counter) = disp_Ij;
766  Disp_jk_Compressed(kel_counter) = displjk[kel];
767  DistIndice_k[kel_counter] = kel;
768  kel_counter++;
769  if (kel_counter == Nbuffer)
770  {
771  const FT& feeI(*F(ig, jg, kg));
772  computeU3_engine(P, feeI, kel_counter, Uj, dUj, d2Uj, Uk, dUk, d2Uk);
773  kel_counter = 0;
774  }
775  }
776  }
777  if ((iind + 1 == ions_nearby.size() || ig != Ions.GroupID[ions_nearby[iind + 1]]) && kel_counter > 0)
778  {
779  const FT& feeI(*F(ig, jg, kg));
780  computeU3_engine(P, feeI, kel_counter, Uj, dUj, d2Uj, Uk, dUk, d2Uk);
781  kel_counter = 0;
782  }
783  }
784  }
785  }
gContainer_type Disp_kI_Compressed
std::vector< int > DistIndice_k
void fill_n(T *x, size_t count, const T &value)
Definition: OMPstd.hpp:21
gContainer_type Disp_jk_Compressed
compressed displacements
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
TinyVector< valT, OHMMS_DIM > posT
element position type
aligned_vector< valT > DistjI_Compressed
#define OHMMS_DIM
Definition: config.h:64
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
Array< std::vector< posT >, 2 > elecs_inside_displ
Array< std::vector< valT >, 2 > elecs_inside_dist
std::vector< valT > Ion_cutoff
the cutoff for e-I pairs
gContainer_type Disp_jI_Compressed
size_t size() const
Definition: OhmmsArray.h:57
size_t Nbuffer
work buffer size
void computeU3_engine(const ParticleSet &P, const FT &feeI, int kel_counter, valT &Uj, posT &dUj, valT &d2Uj, Vector< valT > &Uk, gContainer_type &dUk, Vector< valT > &d2Uk)
typename FT::real_type valT
type of each component U, dU, d2U;
const ParticleSet & Ions
reference to the sources (ions)
Array< FT *, 3 > F
container for the Jastrow functions
Array< std::vector< int >, 2 > elecs_inside
the electrons around ions within the cutoff radius, grouped by species
aligned_vector< valT > DistkI_Compressed
aligned_vector< valT > Distjk_Compressed
compressed distances

◆ computeU3_engine()

void computeU3_engine ( const ParticleSet P,
const FT &  feeI,
int  kel_counter,
valT Uj,
posT dUj,
valT d2Uj,
Vector< valT > &  Uk,
gContainer_type dUk,
Vector< valT > &  d2Uk 
)
inline

Definition at line 625 of file JeeIOrbitalSoA.h.

References qmcplusplus::simd::accumulate_n(), BLAS::cone, BLAS::czero, VectorSoaContainer< T, D, Alloc >::data(), JeeIOrbitalSoA< FT >::Disp_jI_Compressed, JeeIOrbitalSoA< FT >::Disp_jk_Compressed, JeeIOrbitalSoA< FT >::Disp_kI_Compressed, JeeIOrbitalSoA< FT >::DistIndice_k, JeeIOrbitalSoA< FT >::DistjI_Compressed, JeeIOrbitalSoA< FT >::Distjk_Compressed, JeeIOrbitalSoA< FT >::DistkI_Compressed, OMPstd::fill_n(), JeeIOrbitalSoA< FT >::mVGL, and OHMMS_DIM.

Referenced by JeeIOrbitalSoA< FT >::computeU3().

634  {
635  constexpr valT czero(0);
636  constexpr valT cone(1);
637  constexpr valT ctwo(2);
638  constexpr valT lapfac = OHMMS_DIM - cone;
639 
640  valT* restrict val = mVGL.data(0);
641  valT* restrict gradF0 = mVGL.data(1);
642  valT* restrict gradF1 = mVGL.data(2);
643  valT* restrict gradF2 = mVGL.data(3);
644  valT* restrict hessF00 = mVGL.data(4);
645  valT* restrict hessF11 = mVGL.data(5);
646  valT* restrict hessF22 = mVGL.data(6);
647  valT* restrict hessF01 = mVGL.data(7);
648  valT* restrict hessF02 = mVGL.data(8);
649 
650  feeI.evaluateVGL(kel_counter, Distjk_Compressed.data(), DistjI_Compressed.data(), DistkI_Compressed.data(), val,
651  gradF0, gradF1, gradF2, hessF00, hessF11, hessF22, hessF01, hessF02);
652 
653  // compute the contribution to jel, kel
654  Uj = simd::accumulate_n(val, kel_counter, Uj);
655  valT gradF0_sum = simd::accumulate_n(gradF0, kel_counter, czero);
656  valT gradF1_sum = simd::accumulate_n(gradF1, kel_counter, czero);
657  valT hessF00_sum = simd::accumulate_n(hessF00, kel_counter, czero);
658  valT hessF11_sum = simd::accumulate_n(hessF11, kel_counter, czero);
659  d2Uj -= hessF00_sum + hessF11_sum + lapfac * (gradF0_sum + gradF1_sum);
660  std::fill_n(hessF11, kel_counter, czero);
661  for (int idim = 0; idim < OHMMS_DIM; ++idim)
662  {
663  valT* restrict jk = Disp_jk_Compressed.data(idim);
664  valT* restrict jI = Disp_jI_Compressed.data(idim);
665  valT* restrict kI = Disp_kI_Compressed.data(idim);
666  valT dUj_x(0);
667 #pragma omp simd aligned(gradF0, gradF1, gradF2, hessF11, jk, jI, kI : QMC_SIMD_ALIGNMENT) reduction(+ : dUj_x)
668  for (int kel_index = 0; kel_index < kel_counter; kel_index++)
669  {
670  // recycle hessF11
671  hessF11[kel_index] += kI[kel_index] * jk[kel_index];
672  dUj_x += gradF1[kel_index] * jI[kel_index];
673  // destroy jk, kI
674  const valT temp = jk[kel_index] * gradF0[kel_index];
675  dUj_x += temp;
676  jk[kel_index] *= jI[kel_index];
677  kI[kel_index] = kI[kel_index] * gradF2[kel_index] - temp;
678  }
679  dUj[idim] += dUj_x;
680 
681  valT* restrict jk0 = Disp_jk_Compressed.data(0);
682  if (idim > 0)
683  {
684 #pragma omp simd aligned(jk, jk0 : QMC_SIMD_ALIGNMENT)
685  for (int kel_index = 0; kel_index < kel_counter; kel_index++)
686  jk0[kel_index] += jk[kel_index];
687  }
688 
689  valT* restrict dUk_x = dUk.data(idim);
690  for (int kel_index = 0; kel_index < kel_counter; kel_index++)
691  dUk_x[DistIndice_k[kel_index]] += kI[kel_index];
692  }
693  valT sum(0);
694  valT* restrict jk0 = Disp_jk_Compressed.data(0);
695 #pragma omp simd aligned(jk0, hessF01 : QMC_SIMD_ALIGNMENT) reduction(+ : sum)
696  for (int kel_index = 0; kel_index < kel_counter; kel_index++)
697  sum += hessF01[kel_index] * jk0[kel_index];
698  d2Uj -= ctwo * sum;
699 
700 #pragma omp simd aligned(hessF00, hessF22, gradF0, gradF2, hessF02, hessF11 : QMC_SIMD_ALIGNMENT)
701  for (int kel_index = 0; kel_index < kel_counter; kel_index++)
702  hessF00[kel_index] = hessF00[kel_index] + hessF22[kel_index] + lapfac * (gradF0[kel_index] + gradF2[kel_index]) -
703  ctwo * hessF02[kel_index] * hessF11[kel_index];
704 
705  for (int kel_index = 0; kel_index < kel_counter; kel_index++)
706  {
707  const int kel = DistIndice_k[kel_index];
708  Uk[kel] += val[kel_index];
709  d2Uk[kel] -= hessF00[kel_index];
710  }
711  }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
gContainer_type Disp_kI_Compressed
std::vector< int > DistIndice_k
void fill_n(T *x, size_t count, const T &value)
Definition: OMPstd.hpp:21
gContainer_type Disp_jk_Compressed
compressed displacements
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
constexpr std::complex< float > cone
Definition: BLAS.hpp:50
aligned_vector< valT > DistjI_Compressed
#define OHMMS_DIM
Definition: config.h:64
gContainer_type Disp_jI_Compressed
VectorSoaContainer< valT, 9 > mVGL
work result buffer
typename FT::real_type valT
type of each component U, dU, d2U;
aligned_vector< valT > DistkI_Compressed
aligned_vector< valT > Distjk_Compressed
compressed distances

◆ copyFromBuffer()

void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)
inlineoverridevirtual

For particle-by-particle move.

Copy data or attach memory from a walker buffer to the objects of this class. The log value, P.G and P.L contribution from the objects of this class are also added.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 814 of file JeeIOrbitalSoA.h.

References Vector< T, Alloc >::attachReference(), VectorSoaContainer< T, D, Alloc >::attachReference(), JeeIOrbitalSoA< FT >::build_compact_list(), JeeIOrbitalSoA< FT >::d2Uat, JeeIOrbitalSoA< FT >::dUat, PooledMemory< T_scalar, Alloc >::lendReference(), JeeIOrbitalSoA< FT >::Nelec, JeeIOrbitalSoA< FT >::Nelec_padded, OHMMS_DIM, and JeeIOrbitalSoA< FT >::Uat.

815  {
816  Uat.attachReference(buf.lendReference<valT>(Nelec), Nelec);
818  d2Uat.attachReference(buf.lendReference<valT>(Nelec), Nelec);
820  }
size_t Nelec_padded
number of particles + padded
void build_compact_list(const ParticleSet &P)
#define OHMMS_DIM
Definition: config.h:64
void attachReference(T *ref, size_type n)
Definition: OhmmsVector.h:131
typename FT::real_type valT
type of each component U, dU, d2U;
void attachReference(size_type n, size_type n_padded, T *ptr)
attach to pre-allocated data

◆ evalGrad()

GradType evalGrad ( ParticleSet P,
int  iat 
)
inlineoverridevirtual

return the current gradient for the iat-th particle

Parameters
Pquantum particle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented from WaveFunctionComponent.

Definition at line 436 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::dUat.

436 { return GradType(dUat[iat]); }
QTBase::GradType GradType
Definition: Configuration.h:62

◆ evalGradSource() [1/2]

GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat 
)
inlineoverridevirtual

return the logarithmic gradient for the iat-th particle of the source particleset

Parameters
Pquantumparticle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented from WaveFunctionComponent.

Definition at line 1120 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::build_compact_list(), JeeIOrbitalSoA< FT >::evaluateLog(), ParticleSet::getTotalNum(), ParticleSet::R, Vector< T, Alloc >::resize(), and ParticleSet::update().

1121  {
1124  tempG.resize(P.getTotalNum());
1125  tempL.resize(P.getTotalNum());
1126  QTFull::RealType delta = 0.00001;
1127  QTFull::RealType c1 = 1.0 / delta / 2.0;
1128  QTFull::RealType c2 = 1.0 / delta / delta;
1129 
1130  GradType g_return(0.0);
1131  // GRAD TEST COMPUTATION
1132  PosType rI = source.R[isrc];
1133  for (int iondim = 0; iondim < 3; iondim++)
1134  {
1135  source.R[isrc][iondim] = rI[iondim] + delta;
1136  source.update();
1137  P.update();
1138 
1139  LogValue log_p = evaluateLog(P, tempG, tempL);
1140 
1141  source.R[isrc][iondim] = rI[iondim] - delta;
1142  source.update();
1143  P.update();
1144  LogValue log_m = evaluateLog(P, tempG, tempL);
1145 
1146  QTFull::RealType log_p_r(0.0), log_m_r(0.0);
1147 
1148  log_p_r = log_p.real();
1149  log_m_r = log_m.real();
1150  //symmetric finite difference formula for gradient.
1151  g_return[iondim] = c1 * (log_p_r - log_m_r);
1152 
1153  //reset everything to how it was.
1154  source.R[isrc][iondim] = rI[iondim];
1155  }
1156  // this last one makes sure the distance tables and internal neighbourlist correspond to unperturbed source.
1157  source.update();
1158  P.update();
1159  build_compact_list(P);
1160  return g_return;
1161  }
QTBase::GradType GradType
Definition: Configuration.h:62
void build_compact_list(const ParticleSet &P)
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
std::complex< QTFull::RealType > LogValue
QMCTraits::PosType PosType
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
Precision RealType
Definition: QMCTypes.h:37
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95

◆ evalGradSource() [2/2]

GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat,
TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &  grad_grad,
TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &  lapl_grad 
)
inlineoverridevirtual

Adds the gradient w.r.t.

the iat-th particle of the source particleset (ions) of the logarithmic gradient and laplacian w.r.t. the target paritlceset (electrons).

Parameters
Pquantum particle set (electrons)
sourceclassical particle set (ions)
iatparticle index of source (ion)
theion gradient of the elctron gradient
theion gradient of the elctron laplacian.
Returns
the log gradient of psi w.r.t. the source particle iat

Reimplemented from WaveFunctionComponent.

Definition at line 1163 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::build_compact_list(), JeeIOrbitalSoA< FT >::evaluateLog(), ParticleSet::getTotalNum(), ParticleSet::R, Vector< T, Alloc >::resize(), and ParticleSet::update().

1168  {
1169  ParticleSet::ParticleGradient Gp, Gm, dG;
1170  ParticleSet::ParticleLaplacian Lp, Lm, dL;
1171  Gp.resize(P.getTotalNum());
1172  Gm.resize(P.getTotalNum());
1173  dG.resize(P.getTotalNum());
1174  Lp.resize(P.getTotalNum());
1175  Lm.resize(P.getTotalNum());
1176  dL.resize(P.getTotalNum());
1177 
1178  QTFull::RealType delta = 0.00001;
1179  QTFull::RealType c1 = 1.0 / delta / 2.0;
1180  QTFull::RealType c2 = 1.0 / delta / delta;
1181  GradType g_return(0.0);
1182  // GRAD TEST COMPUTATION
1183  PosType rI = source.R[isrc];
1184  for (int iondim = 0; iondim < 3; iondim++)
1185  {
1186  Lp = 0;
1187  Gp = 0;
1188  Lm = 0;
1189  Gm = 0;
1190  source.R[isrc][iondim] = rI[iondim] + delta;
1191  source.update();
1192  P.update();
1193 
1194  LogValue log_p = evaluateLog(P, Gp, Lp);
1195 
1196  source.R[isrc][iondim] = rI[iondim] - delta;
1197  source.update();
1198  P.update();
1199  LogValue log_m = evaluateLog(P, Gm, Lm);
1200  QTFull::RealType log_p_r(0.0), log_m_r(0.0);
1201 
1202  log_p_r = log_p.real();
1203  log_m_r = log_m.real();
1204  dG = Gp - Gm;
1205  dL = Lp - Lm;
1206  //symmetric finite difference formula for gradient.
1207  g_return[iondim] = c1 * (log_p_r - log_m_r);
1208  grad_grad[iondim] += c1 * dG;
1209  lapl_grad[iondim] += c1 * dL;
1210  //reset everything to how it was.
1211  source.R[isrc][iondim] = rI[iondim];
1212  }
1213  // this last one makes sure the distance tables and internal neighbourlist correspond to unperturbed source.
1214  source.update();
1215  P.update();
1216  build_compact_list(P);
1217  return g_return;
1218  }
QTBase::GradType GradType
Definition: Configuration.h:62
void build_compact_list(const ParticleSet &P)
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
std::complex< QTFull::RealType > LogValue
QMCTraits::PosType PosType
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
Precision RealType
Definition: QMCTypes.h:37
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95

◆ evaluateDerivatives()

void evaluateDerivatives ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
inlineoverride

Definition at line 830 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::build_compact_list(), BLAS::cone, BLAS::czero, JeeIOrbitalSoA< FT >::dgrad_dalpha, JeeIOrbitalSoA< FT >::dhess_dalpha, JeeIOrbitalSoA< FT >::dLogPsi, qmcplusplus::dot(), JeeIOrbitalSoA< FT >::du_dalpha, JeeIOrbitalSoA< FT >::ee_Table_ID_, JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::elecs_inside, JeeIOrbitalSoA< FT >::elecs_inside_displ, JeeIOrbitalSoA< FT >::elecs_inside_dist, JeeIOrbitalSoA< FT >::F, ParticleSet::G, DistanceTableAA::getDistances(), ParticleSet::getDistTableAA(), JeeIOrbitalSoA< FT >::gradLogPsi, ParticleSet::GroupID, JeeIOrbitalSoA< FT >::Ions, JeeIOrbitalSoA< FT >::J3UniqueIndex, qmcplusplus::Units::mass::kg, JeeIOrbitalSoA< FT >::lapLogPsi, WaveFunctionComponent::myVars, JeeIOrbitalSoA< FT >::Nelec, JeeIOrbitalSoA< FT >::Nion, OHMMS_DIM, VariableSet::recompute(), JeeIOrbitalSoA< FT >::resizeWFOptVectors(), Array< T, D, ALLOC >::size(), VariableSet::size(), JeeIOrbitalSoA< FT >::VarOffset, and VariableSet::where().

834  {
836 
837  bool recalculate(false);
838  for (int k = 0; k < myVars.size(); ++k)
839  {
840  int kk = myVars.where(k);
841  if (kk < 0)
842  continue;
843  if (optvars.recompute(kk))
844  recalculate = true;
845  }
846 
847  if (recalculate)
848  {
849  constexpr valT czero(0);
850  constexpr valT cone(1);
851  constexpr valT cminus(-1);
852  constexpr valT ctwo(2);
853  constexpr valT lapfac = OHMMS_DIM - cone;
854 
855  const auto& ee_table = P.getDistTableAA(ee_Table_ID_);
856  const auto& ee_dists = ee_table.getDistances();
857  const auto& ee_displs = ee_table.getDisplacements();
858 
860 
861  dLogPsi = czero;
862  gradLogPsi = PosType();
863  lapLogPsi = czero;
864 
865  for (int iat = 0; iat < Nion; ++iat)
866  {
867  const int ig = Ions.GroupID[iat];
868  for (int jg = 0; jg < eGroups; ++jg)
869  for (int jind = 0; jind < elecs_inside(jg, iat).size(); jind++)
870  {
871  const int jel = elecs_inside(jg, iat)[jind];
872  const valT r_Ij = elecs_inside_dist(jg, iat)[jind];
873  const posT disp_Ij = cminus * elecs_inside_displ(jg, iat)[jind];
874  const valT r_Ij_inv = cone / r_Ij;
875 
876  for (int kg = 0; kg < eGroups; ++kg)
877  for (int kind = 0; kind < elecs_inside(kg, iat).size(); kind++)
878  {
879  const int kel = elecs_inside(kg, iat)[kind];
880  if (kel < jel)
881  {
882  const valT r_Ik = elecs_inside_dist(kg, iat)[kind];
883  const posT disp_Ik = cminus * elecs_inside_displ(kg, iat)[kind];
884  const valT r_Ik_inv = cone / r_Ik;
885 
886  const valT r_jk = ee_dists[jel][kel];
887  const posT disp_jk = ee_displs[jel][kel];
888  const valT r_jk_inv = cone / r_jk;
889 
890  FT& func = *F(ig, jg, kg);
891  int idx = J3UniqueIndex[F(ig, jg, kg)];
892  func.evaluateDerivatives(r_jk, r_Ij, r_Ik, du_dalpha[idx], dgrad_dalpha[idx], dhess_dalpha[idx]);
893  int first = VarOffset(ig, jg, kg).first;
894  int last = VarOffset(ig, jg, kg).second;
895  std::vector<RealType>& dlog = du_dalpha[idx];
896  std::vector<PosType>& dgrad = dgrad_dalpha[idx];
897  std::vector<Tensor<RealType, 3>>& dhess = dhess_dalpha[idx];
898 
899  for (int p = first, ip = 0; p < last; p++, ip++)
900  {
901  RealType& dval = dlog[ip];
902  PosType& dg = dgrad[ip];
903  Tensor<RealType, 3>& dh = dhess[ip];
904 
905  dg[0] *= r_jk_inv;
906  dg[1] *= r_Ij_inv;
907  dg[2] *= r_Ik_inv;
908 
909  PosType gr_ee = dg[0] * disp_jk;
910 
911  gradLogPsi(p, jel) -= dg[1] * disp_Ij - gr_ee;
912  lapLogPsi(p, jel) -=
913  (dh(0, 0) + lapfac * dg[0] - ctwo * dh(0, 1) * dot(disp_jk, disp_Ij) * r_jk_inv * r_Ij_inv +
914  dh(1, 1) + lapfac * dg[1]);
915 
916  gradLogPsi(p, kel) -= dg[2] * disp_Ik + gr_ee;
917  lapLogPsi(p, kel) -=
918  (dh(0, 0) + lapfac * dg[0] + ctwo * dh(0, 2) * dot(disp_jk, disp_Ik) * r_jk_inv * r_Ik_inv +
919  dh(2, 2) + lapfac * dg[2]);
920 
921  dLogPsi[p] -= dval;
922  }
923  }
924  }
925  }
926  }
927 
928  for (int k = 0; k < myVars.size(); ++k)
929  {
930  int kk = myVars.where(k);
931  if (kk < 0)
932  continue;
933  dlogpsi[kk] = (ValueType)dLogPsi[k];
934  RealType sum = 0.0;
935  for (int i = 0; i < Nelec; i++)
936  {
937 #if defined(QMC_COMPLEX)
938  sum -= 0.5 * lapLogPsi(k, i);
939  for (int jdim = 0; jdim < OHMMS_DIM; ++jdim)
940  sum -= P.G[i][jdim].real() * gradLogPsi(k, i)[jdim];
941 #else
942  sum -= 0.5 * lapLogPsi(k, i) + dot(P.G[i], gradLogPsi(k, i));
943 #endif
944  }
945  dhpsioverpsi[kk] = (ValueType)sum;
946  }
947  }
948  }
std::map< FT *, int > J3UniqueIndex
Array< RealType, 2 > lapLogPsi
const int ee_Table_ID_
table index for el-el
void build_compact_list(const ParticleSet &P)
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
constexpr std::complex< float > cone
Definition: BLAS.hpp:50
TinyVector< valT, OHMMS_DIM > posT
element position type
#define OHMMS_DIM
Definition: config.h:64
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
QMCTraits::PosType PosType
Array< std::vector< posT >, 2 > elecs_inside_displ
QTBase::ValueType ValueType
Definition: Configuration.h:60
Array< std::vector< valT >, 2 > elecs_inside_dist
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_t size() const
Definition: OhmmsArray.h:57
QTBase::PosType PosType
Definition: Configuration.h:61
typename FT::real_type valT
type of each component U, dU, d2U;
Array< std::pair< int, int >, 3 > VarOffset
size_type size() const
return the size
Definition: VariableSet.h:88
QMCTraits::RealType RealType
const ParticleSet & Ions
reference to the sources (ions)
std::vector< std::vector< Tensor< RealType, 3 > > > dhess_dalpha
Array< FT *, 3 > F
container for the Jastrow functions
Vector< RealType > dLogPsi
Array< std::vector< int >, 2 > elecs_inside
the electrons around ions within the cutoff radius, grouped by species
std::vector< std::vector< PosType > > dgrad_dalpha
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< std::vector< RealType > > du_dalpha
Array< PosType, 2 > gradLogPsi

◆ evaluateDerivativesWF()

void evaluateDerivativesWF ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi 
)
inlineoverride

Definition at line 950 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::build_compact_list(), BLAS::cone, BLAS::czero, JeeIOrbitalSoA< FT >::dgrad_dalpha, JeeIOrbitalSoA< FT >::dhess_dalpha, JeeIOrbitalSoA< FT >::dLogPsi, JeeIOrbitalSoA< FT >::du_dalpha, JeeIOrbitalSoA< FT >::ee_Table_ID_, JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::elecs_inside, JeeIOrbitalSoA< FT >::elecs_inside_displ, JeeIOrbitalSoA< FT >::elecs_inside_dist, JeeIOrbitalSoA< FT >::F, DistanceTableAA::getDistances(), ParticleSet::getDistTableAA(), JeeIOrbitalSoA< FT >::gradLogPsi, ParticleSet::GroupID, JeeIOrbitalSoA< FT >::Ions, JeeIOrbitalSoA< FT >::J3UniqueIndex, qmcplusplus::Units::mass::kg, JeeIOrbitalSoA< FT >::lapLogPsi, WaveFunctionComponent::myVars, JeeIOrbitalSoA< FT >::Nion, OHMMS_DIM, VariableSet::recompute(), JeeIOrbitalSoA< FT >::resizeWFOptVectors(), Array< T, D, ALLOC >::size(), VariableSet::size(), JeeIOrbitalSoA< FT >::VarOffset, and VariableSet::where().

951  {
953 
954  bool recalculate(false);
955  for (int k = 0; k < myVars.size(); ++k)
956  {
957  int kk = myVars.where(k);
958  if (kk < 0)
959  continue;
960  if (optvars.recompute(kk))
961  recalculate = true;
962  }
963 
964  if (recalculate)
965  {
966  constexpr valT czero(0);
967  constexpr valT cone(1);
968  constexpr valT cminus(-1);
969  constexpr valT ctwo(2);
970  constexpr valT lapfac = OHMMS_DIM - cone;
971 
972  const auto& ee_table = P.getDistTableAA(ee_Table_ID_);
973  const auto& ee_dists = ee_table.getDistances();
974  const auto& ee_displs = ee_table.getDisplacements();
975 
977 
978  dLogPsi = czero;
979  gradLogPsi = PosType();
980  lapLogPsi = czero;
981 
982  for (int iat = 0; iat < Nion; ++iat)
983  {
984  const int ig = Ions.GroupID[iat];
985  for (int jg = 0; jg < eGroups; ++jg)
986  for (int jind = 0; jind < elecs_inside(jg, iat).size(); jind++)
987  {
988  const int jel = elecs_inside(jg, iat)[jind];
989  const valT r_Ij = elecs_inside_dist(jg, iat)[jind];
990  const posT disp_Ij = cminus * elecs_inside_displ(jg, iat)[jind];
991  const valT r_Ij_inv = cone / r_Ij;
992 
993  for (int kg = 0; kg < eGroups; ++kg)
994  for (int kind = 0; kind < elecs_inside(kg, iat).size(); kind++)
995  {
996  const int kel = elecs_inside(kg, iat)[kind];
997  if (kel < jel)
998  {
999  const valT r_Ik = elecs_inside_dist(kg, iat)[kind];
1000  const posT disp_Ik = cminus * elecs_inside_displ(kg, iat)[kind];
1001  const valT r_Ik_inv = cone / r_Ik;
1002 
1003  const valT r_jk = ee_dists[jel][kel];
1004  const posT disp_jk = ee_displs[jel][kel];
1005  const valT r_jk_inv = cone / r_jk;
1006 
1007  FT& func = *F(ig, jg, kg);
1008  int idx = J3UniqueIndex[F(ig, jg, kg)];
1009  func.evaluateDerivatives(r_jk, r_Ij, r_Ik, du_dalpha[idx], dgrad_dalpha[idx], dhess_dalpha[idx]);
1010  int first = VarOffset(ig, jg, kg).first;
1011  int last = VarOffset(ig, jg, kg).second;
1012  std::vector<RealType>& dlog = du_dalpha[idx];
1013 
1014  for (int p = first, ip = 0; p < last; p++, ip++)
1015  {
1016  RealType& dval = dlog[ip];
1017  dLogPsi[p] -= dval;
1018  }
1019  }
1020  }
1021  }
1022  }
1023 
1024  for (int k = 0; k < myVars.size(); ++k)
1025  {
1026  int kk = myVars.where(k);
1027  if (kk < 0)
1028  continue;
1029  dlogpsi[kk] = (ValueType)dLogPsi[k];
1030  }
1031  }
1032  }
std::map< FT *, int > J3UniqueIndex
Array< RealType, 2 > lapLogPsi
const int ee_Table_ID_
table index for el-el
void build_compact_list(const ParticleSet &P)
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
constexpr std::complex< float > cone
Definition: BLAS.hpp:50
TinyVector< valT, OHMMS_DIM > posT
element position type
#define OHMMS_DIM
Definition: config.h:64
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
Array< std::vector< posT >, 2 > elecs_inside_displ
QTBase::ValueType ValueType
Definition: Configuration.h:60
Array< std::vector< valT >, 2 > elecs_inside_dist
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_t size() const
Definition: OhmmsArray.h:57
QTBase::PosType PosType
Definition: Configuration.h:61
typename FT::real_type valT
type of each component U, dU, d2U;
Array< std::pair< int, int >, 3 > VarOffset
size_type size() const
return the size
Definition: VariableSet.h:88
QMCTraits::RealType RealType
const ParticleSet & Ions
reference to the sources (ions)
std::vector< std::vector< Tensor< RealType, 3 > > > dhess_dalpha
Array< FT *, 3 > F
container for the Jastrow functions
Vector< RealType > dLogPsi
Array< std::vector< int >, 2 > elecs_inside
the electrons around ions within the cutoff radius, grouped by species
std::vector< std::vector< PosType > > dgrad_dalpha
std::vector< std::vector< RealType > > du_dalpha
Array< PosType, 2 > gradLogPsi

◆ evaluateDerivRatios()

void evaluateDerivRatios ( const VirtualParticleSet VP,
const opt_variables_type optvars,
std::vector< ValueType > &  ratios,
Matrix< ValueType > &  dratios 
)
inlineoverride

Definition at line 1034 of file JeeIOrbitalSoA.h.

References BLAS::czero, JeeIOrbitalSoA< FT >::dLogPsi, JeeIOrbitalSoA< FT >::ee_Table_ID_, JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::ei_Table_ID_, JeeIOrbitalSoA< FT >::elecs_inside, JeeIOrbitalSoA< FT >::elecs_inside_dist, JeeIOrbitalSoA< FT >::evaluateRatios(), JeeIOrbitalSoA< FT >::F, DistanceTableAA::getDistances(), DistanceTableAB::getDistances(), ParticleSet::getDistTableAA(), ParticleSet::getDistTableAB(), ParticleSet::getGroupID(), VirtualParticleSet::getRefPS(), VirtualParticleSet::getTotalNum(), JeeIOrbitalSoA< FT >::Ions, qmcplusplus::Units::mass::kg, WaveFunctionComponent::myVars, JeeIOrbitalSoA< FT >::Nion, VariableSet::recompute(), VirtualParticleSet::refPtcl, Vector< T, Alloc >::resize(), Array< T, D, ALLOC >::size(), VariableSet::size(), JeeIOrbitalSoA< FT >::VarOffset, and VariableSet::where().

1038  {
1039  assert(VP.getTotalNum() == ratios.size());
1040  evaluateRatios(VP, ratios);
1041 
1042  bool recalculate(false);
1043  for (int k = 0; k < myVars.size(); ++k)
1044  {
1045  int kk = myVars.where(k);
1046  if (kk < 0)
1047  continue;
1048  if (optvars.recompute(kk))
1049  recalculate = true;
1050  }
1051 
1052  if (recalculate)
1053  {
1054  constexpr valT czero(0);
1055 
1056  const auto& refPS = VP.getRefPS();
1057  const auto& ee_dists = refPS.getDistTableAA(ee_Table_ID_).getDistances();
1058  const auto& ei_dists = refPS.getDistTableAB(ei_Table_ID_).getDistances();
1059 
1060  const auto& vpe_dists = VP.getDistTableAB(ee_Table_ID_).getDistances();
1061  const auto& vpi_dists = VP.getDistTableAB(ei_Table_ID_).getDistances();
1062 
1063  const int nVP = VP.getTotalNum();
1064  std::vector<Vector<RealType>> dLogPsi_vp(nVP);
1065  for (auto& dLogPsi : dLogPsi_vp)
1066  {
1068  dLogPsi = czero;
1069  }
1070 
1071  const int kel = VP.refPtcl;
1072  const int kg = refPS.getGroupID(kel);
1073 
1074  for (int iat = 0; iat < Nion; ++iat)
1075  {
1076  const int ig = Ions.getGroupID(iat);
1077  for (int jg = 0; jg < eGroups; ++jg)
1078  {
1079  FT& func = *F(ig, jg, kg);
1080  const size_t nparams = func.getNumParameters();
1081  std::vector<RealType> dlog_ref(nparams), dlog(nparams);
1082  for (int jind = 0; jind < elecs_inside(jg, iat).size(); jind++)
1083  {
1084  const int jel = elecs_inside(jg, iat)[jind];
1085  if (jel == kel)
1086  continue;
1087  const valT r_Ij = elecs_inside_dist(jg, iat)[jind];
1088  const valT r_Ik_ref = ei_dists[kel][iat];
1089  const valT r_jk_ref = jel < kel ? ee_dists[kel][jel] : ee_dists[jel][kel];
1090 
1091  if (!func.evaluateDerivatives(r_jk_ref, r_Ij, r_Ik_ref, dlog_ref))
1092  std::fill(dlog_ref.begin(), dlog_ref.end(), czero);
1093 
1094  for (int ivp = 0; ivp < nVP; ivp++)
1095  {
1096  const valT r_Ik = vpi_dists[ivp][iat];
1097  const valT r_jk = vpe_dists[ivp][jel];
1098  if (!func.evaluateDerivatives(r_jk, r_Ij, r_Ik, dlog))
1099  std::fill(dlog.begin(), dlog.end(), czero);
1100  const int first = VarOffset(ig, jg, kg).first;
1101  const int last = VarOffset(ig, jg, kg).second;
1102  for (int p = first, ip = 0; p < last; p++, ip++)
1103  dLogPsi_vp[ivp][p] -= dlog[ip] - dlog_ref[ip];
1104  }
1105  }
1106  }
1107  }
1108 
1109  for (int k = 0; k < myVars.size(); ++k)
1110  {
1111  int kk = myVars.where(k);
1112  if (kk < 0)
1113  continue;
1114  for (int ivp = 0; ivp < nVP; ivp++)
1115  dratios[ivp][kk] = (ValueType)dLogPsi_vp[ivp][k];
1116  }
1117  }
1118  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
const int ee_Table_ID_
table index for el-el
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
QTBase::ValueType ValueType
Definition: Configuration.h:60
Array< std::vector< valT >, 2 > elecs_inside_dist
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_t size() const
Definition: OhmmsArray.h:57
const int ei_Table_ID_
table index for i-el
typename FT::real_type valT
type of each component U, dU, d2U;
Array< std::pair< int, int >, 3 > VarOffset
size_type size() const
return the size
Definition: VariableSet.h:88
const ParticleSet & Ions
reference to the sources (ions)
Array< FT *, 3 > F
container for the Jastrow functions
Vector< RealType > dLogPsi
void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
Array< std::vector< int >, 2 > elecs_inside
the electrons around ions within the cutoff radius, grouped by species
int getGroupID(int iat) const
return the group id of a given particle in the particle set.
Definition: ParticleSet.h:520

◆ evaluateGL()

LogValue evaluateGL ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L,
bool  fromscratch = false 
)
inlineoverridevirtual

compute gradients and laplacian of the TWF with respect to each particle.

Parameters
Pparticle set
GGradients, $\nabla\ln\Psi$
LLaplacians, $\nabla^2\ln\Psi$
fromscratchif true and this WFC is sensitive to numeical error accumulation, all the internal data are recomputed from scratch.
Returns
log(psi)

Reimplemented from WaveFunctionComponent.

Definition at line 822 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::computeGL(), and WaveFunctionComponent::log_value_.

826  {
827  return log_value_ = computeGL(G, L);
828  }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data

◆ evaluateLog()

LogValue evaluateLog ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
)
inlineoverridevirtual

evaluate the value of the WaveFunctionComponent from scratch

Parameters
[in]Pactive ParticleSet
[out]GGradients, $\nabla\ln\Psi$
[out]LLaplacians, $\nabla^2\ln\Psi$
Returns
the log value

Mainly for walker-by-walker move. The initial stage of particle-by-particle move also uses this. causes complete state update in WFC's

Implements WaveFunctionComponent.

Definition at line 378 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::computeGL(), WaveFunctionComponent::log_value_, and JeeIOrbitalSoA< FT >::recompute().

Referenced by JeeIOrbitalSoA< FT >::evalGradSource().

381  {
382  recompute(P);
383  return log_value_ = computeGL(G, L);
384  }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.

◆ evaluateRatios()

void evaluateRatios ( const VirtualParticleSet VP,
std::vector< ValueType > &  ratios 
)
inlineoverride

Definition at line 397 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::computeU(), JeeIOrbitalSoA< FT >::ee_Table_ID_, JeeIOrbitalSoA< FT >::ei_Table_ID_, qmcplusplus::exp(), DistanceTableAB::getDistRow(), ParticleSet::getDistTableAB(), VirtualParticleSet::getRefPS(), VirtualParticleSet::getTotalNum(), ParticleSet::GroupID, JeeIOrbitalSoA< FT >::ions_nearby_old, VirtualParticleSet::refPtcl, and JeeIOrbitalSoA< FT >::Uat.

Referenced by JeeIOrbitalSoA< FT >::evaluateDerivRatios().

398  {
399  assert(VP.getTotalNum() == ratios.size());
400  for (int k = 0; k < ratios.size(); ++k)
401  ratios[k] = std::exp(Uat[VP.refPtcl] -
402  computeU(VP.getRefPS(), VP.refPtcl, VP.getRefPS().GroupID[VP.refPtcl],
403  VP.getDistTableAB(ei_Table_ID_).getDistRow(k),
404  VP.getDistTableAB(ee_Table_ID_).getDistRow(k), ions_nearby_old));
405  }
const int ee_Table_ID_
table index for el-el
std::vector< int > ions_nearby_old
the ids of ions within the cutoff radius of an electron on which a move is proposed ...
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
const int ei_Table_ID_
table index for i-el
valT computeU(const ParticleSet &P, int jel, int jg, const DistRow &distjI, const DistRow &distjk, std::vector< int > &ions_nearby)

◆ evaluateRatiosAlltoOne()

void evaluateRatiosAlltoOne ( ParticleSet P,
std::vector< ValueType > &  ratios 
)
inlineoverride

Definition at line 407 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::computeU(), JeeIOrbitalSoA< FT >::ee_Table_ID_, JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::ei_Table_ID_, qmcplusplus::exp(), JeeIOrbitalSoA< FT >::F, ParticleSet::first(), DistanceTableAB::getDistances(), ParticleSet::getDistTableAA(), ParticleSet::getDistTableAB(), ParticleSet::GroupID, JeeIOrbitalSoA< FT >::Ion_cutoff, JeeIOrbitalSoA< FT >::Ions, JeeIOrbitalSoA< FT >::ions_nearby_new, ParticleSet::last(), JeeIOrbitalSoA< FT >::Nion, and JeeIOrbitalSoA< FT >::Uat.

408  {
409  const auto& eI_table = P.getDistTableAB(ei_Table_ID_);
410  const auto& eI_dists = eI_table.getDistances();
411  const auto& ee_table = P.getDistTableAA(ee_Table_ID_);
412 
413  for (int jg = 0; jg < eGroups; ++jg)
414  {
415  const valT sumU = computeU(P, -1, jg, eI_table.getTempDists(), ee_table.getTempDists(), ions_nearby_new);
416 
417  for (int j = P.first(jg); j < P.last(jg); ++j)
418  {
419  // remove self-interaction
420  valT Uself(0);
421  for (int iat = 0; iat < Nion; ++iat)
422  {
423  const valT& r_Ij = eI_table.getTempDists()[iat];
424  const valT& r_Ik = eI_dists[j][iat];
425  if (r_Ij < Ion_cutoff[iat] && r_Ik < Ion_cutoff[iat])
426  {
427  const int ig = Ions.GroupID[iat];
428  Uself += F(ig, jg, jg)->evaluate(ee_table.getTempDists()[j], r_Ij, r_Ik);
429  }
430  }
431  ratios[j] = std::exp(Uat[j] + Uself - sumU);
432  }
433  }
434  }
const int ee_Table_ID_
table index for el-el
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
std::vector< valT > Ion_cutoff
the cutoff for e-I pairs
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
const int ei_Table_ID_
table index for i-el
typename FT::real_type valT
type of each component U, dU, d2U;
std::vector< int > ions_nearby_new
const ParticleSet & Ions
reference to the sources (ions)
Array< FT *, 3 > F
container for the Jastrow functions
valT computeU(const ParticleSet &P, int jel, int jg, const DistRow &distjI, const DistRow &distjk, std::vector< int > &ions_nearby)

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
inlineoverridevirtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented from WaveFunctionComponent.

Definition at line 317 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::J3Unique, and UniqueOptObjRefs::push_back().

318  {
319  for (auto& [key, functor] : J3Unique)
320  opt_obj_refs.push_back(*functor);
321  }
std::map< std::string, std::unique_ptr< FT > > J3Unique

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 159 of file JeeIOrbitalSoA.h.

159 { return "JeeIOrbitalSoA"; }

◆ init()

void init ( ParticleSet p)
inline

Definition at line 186 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::d2Uat, JeeIOrbitalSoA< FT >::Disp_jI_Compressed, JeeIOrbitalSoA< FT >::Disp_jk_Compressed, JeeIOrbitalSoA< FT >::Disp_kI_Compressed, JeeIOrbitalSoA< FT >::DistIndice_k, JeeIOrbitalSoA< FT >::DistjI_Compressed, JeeIOrbitalSoA< FT >::Distjk_Compressed, JeeIOrbitalSoA< FT >::DistkI_Compressed, JeeIOrbitalSoA< FT >::dUat, JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::elecs_inside, JeeIOrbitalSoA< FT >::elecs_inside_displ, JeeIOrbitalSoA< FT >::elecs_inside_dist, JeeIOrbitalSoA< FT >::F, ParticleSet::getSpeciesSet(), SpeciesSet::getTotalNum(), ParticleSet::getTotalNum(), ParticleSet::groups(), JeeIOrbitalSoA< FT >::iGroups, JeeIOrbitalSoA< FT >::Ion_cutoff, JeeIOrbitalSoA< FT >::Ions, JeeIOrbitalSoA< FT >::ions_nearby_new, JeeIOrbitalSoA< FT >::ions_nearby_old, JeeIOrbitalSoA< FT >::mVGL, JeeIOrbitalSoA< FT >::Nbuffer, JeeIOrbitalSoA< FT >::Nelec, JeeIOrbitalSoA< FT >::Nelec_padded, JeeIOrbitalSoA< FT >::newd2Uk, JeeIOrbitalSoA< FT >::newdUk, JeeIOrbitalSoA< FT >::newUk, JeeIOrbitalSoA< FT >::Nion, JeeIOrbitalSoA< FT >::oldd2Uk, JeeIOrbitalSoA< FT >::olddUk, JeeIOrbitalSoA< FT >::oldUk, Array< T, D, ALLOC >::resize(), VectorSoaContainer< T, D, Alloc >::resize(), Vector< T, Alloc >::resize(), and JeeIOrbitalSoA< FT >::Uat.

Referenced by JeeIOrbitalSoA< FT >::JeeIOrbitalSoA().

187  {
188  Nelec = p.getTotalNum();
189  Nelec_padded = getAlignedSize<valT>(Nelec);
190  Nion = Ions.getTotalNum();
192  eGroups = p.groups();
193 
194  Uat.resize(Nelec);
195  dUat.resize(Nelec);
196  d2Uat.resize(Nelec);
197 
198  oldUk.resize(Nelec);
201  newUk.resize(Nelec);
204 
206  F = nullptr;
210  ions_nearby_old.resize(Nion);
211  ions_nearby_new.resize(Nion);
212  Ion_cutoff.resize(Nion, 0.0);
213 
214  //initialize buffers
215  Nbuffer = Nelec;
217  Distjk_Compressed.resize(Nbuffer);
218  DistjI_Compressed.resize(Nbuffer);
219  DistkI_Compressed.resize(Nbuffer);
223  DistIndice_k.resize(Nbuffer);
224  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
gContainer_type Disp_kI_Compressed
size_t Nelec_padded
number of particles + padded
std::vector< int > DistIndice_k
size_t getTotalNum() const
Definition: ParticleSet.h:493
gContainer_type Disp_jk_Compressed
compressed displacements
std::vector< int > ions_nearby_old
the ids of ions within the cutoff radius of an electron on which a move is proposed ...
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
aligned_vector< valT > DistjI_Compressed
int getTotalNum() const
return the number of species
Definition: SpeciesSet.h:55
Array< std::vector< posT >, 2 > elecs_inside_displ
Array< std::vector< valT >, 2 > elecs_inside_dist
std::vector< valT > Ion_cutoff
the cutoff for e-I pairs
gContainer_type Disp_jI_Compressed
VectorSoaContainer< valT, 9 > mVGL
work result buffer
size_t Nbuffer
work buffer size
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
std::vector< int > ions_nearby_new
const ParticleSet & Ions
reference to the sources (ions)
Array< FT *, 3 > F
container for the Jastrow functions
Array< std::vector< int >, 2 > elecs_inside
the electrons around ions within the cutoff radius, grouped by species
aligned_vector< valT > DistkI_Compressed
aligned_vector< valT > Distjk_Compressed
compressed distances
void resize(size_type n)
resize myData

◆ isOptimizable()

bool isOptimizable ( ) const
inlineoverridevirtual

if true, this contains optimizable components

Reimplemented from WaveFunctionComponent.

Definition at line 315 of file JeeIOrbitalSoA.h.

315 { return true; }

◆ makeClone()

std::unique_ptr<WaveFunctionComponent> makeClone ( ParticleSet tqp) const
inlineoverridevirtual

make clone

Parameters
tqptarget Quantum ParticleSet
deepcopyif true, make a decopy

If not true, return a proxy class

Reimplemented from WaveFunctionComponent.

Definition at line 161 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::eGroups, JeeIOrbitalSoA< FT >::F, JeeIOrbitalSoA< FT >::iGroups, JeeIOrbitalSoA< FT >::Ions, WaveFunctionComponent::my_name_, WaveFunctionComponent::myVars, and JeeIOrbitalSoA< FT >::VarOffset.

162  {
163  auto eeIcopy = std::make_unique<JeeIOrbitalSoA<FT>>(my_name_, Ions, elecs);
164  std::map<const FT*, FT*> fcmap;
165  for (int iG = 0; iG < iGroups; iG++)
166  for (int eG1 = 0; eG1 < eGroups; eG1++)
167  for (int eG2 = 0; eG2 < eGroups; eG2++)
168  {
169  if (F(iG, eG1, eG2) == nullptr)
170  continue;
171  auto fit = fcmap.find(F(iG, eG1, eG2));
172  if (fit == fcmap.end())
173  {
174  auto fc = std::make_unique<FT>(*F(iG, eG1, eG2));
175  fcmap[F(iG, eG1, eG2)] = fc.get();
176  eeIcopy->addFunc(iG, eG1, eG2, std::move(fc));
177  }
178  }
179  // Ye: I don't like the following memory allocated by default.
180  eeIcopy->myVars.clear();
181  eeIcopy->myVars.insertFrom(myVars);
182  eeIcopy->VarOffset = VarOffset;
183  return eeIcopy;
184  }
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
Array< std::pair< int, int >, 3 > VarOffset
const ParticleSet & Ions
reference to the sources (ions)
Array< FT *, 3 > F
container for the Jastrow functions

◆ ratio()

PsiValue ratio ( ParticleSet P,
int  iat 
)
inlineoverridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value

Parameters
Pthe active ParticleSet
iatthe index of a particle
Returns
$ \psi( \{ {\bf R}^{'} \} )/ \psi( \{ {\bf R}\})$

Specialized for particle-by-particle move

Implements WaveFunctionComponent.

Definition at line 386 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::computeU(), JeeIOrbitalSoA< FT >::cur_Uat, JeeIOrbitalSoA< FT >::DiffVal, JeeIOrbitalSoA< FT >::ee_Table_ID_, JeeIOrbitalSoA< FT >::ei_Table_ID_, qmcplusplus::exp(), ParticleSet::getDistTableAA(), ParticleSet::getDistTableAB(), ParticleSet::GroupID, JeeIOrbitalSoA< FT >::ions_nearby_new, WaveFunctionComponent::ORB_PBYP_RATIO, JeeIOrbitalSoA< FT >::Uat, and WaveFunctionComponent::UpdateMode.

387  {
389 
390  const auto& eI_table = P.getDistTableAB(ei_Table_ID_);
391  const auto& ee_table = P.getDistTableAA(ee_Table_ID_);
392  cur_Uat = computeU(P, iat, P.GroupID[iat], eI_table.getTempDists(), ee_table.getTempDists(), ions_nearby_new);
393  DiffVal = Uat[iat] - cur_Uat;
394  return std::exp(static_cast<PsiValue>(DiffVal));
395  }
const int ee_Table_ID_
table index for el-el
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
const int ei_Table_ID_
table index for i-el
std::vector< int > ions_nearby_new
valT cur_Uat
current values during PbyP
RealType DiffVal
diff value
valT computeU(const ParticleSet &P, int jel, int jg, const DistRow &distjI, const DistRow &distjk, std::vector< int > &ions_nearby)

◆ ratioGrad()

PsiValue ratioGrad ( ParticleSet P,
int  iat,
GradType grad_iat 
)
inlineoverridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient

Parameters
Pthe active ParticleSet
iatthe index of a particle
grad_iatGradient for the active particle

Reimplemented from WaveFunctionComponent.

Definition at line 438 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::computeU3(), JeeIOrbitalSoA< FT >::cur_d2Uat, JeeIOrbitalSoA< FT >::cur_dUat, JeeIOrbitalSoA< FT >::cur_Uat, JeeIOrbitalSoA< FT >::DiffVal, JeeIOrbitalSoA< FT >::ee_Table_ID_, JeeIOrbitalSoA< FT >::ei_Table_ID_, qmcplusplus::exp(), ParticleSet::getDistTableAA(), ParticleSet::getDistTableAB(), JeeIOrbitalSoA< FT >::ions_nearby_new, JeeIOrbitalSoA< FT >::newd2Uk, JeeIOrbitalSoA< FT >::newdUk, JeeIOrbitalSoA< FT >::newUk, WaveFunctionComponent::ORB_PBYP_PARTIAL, JeeIOrbitalSoA< FT >::Uat, and WaveFunctionComponent::UpdateMode.

439  {
441 
442  const auto& eI_table = P.getDistTableAB(ei_Table_ID_);
443  const auto& ee_table = P.getDistTableAA(ee_Table_ID_);
444  computeU3(P, iat, eI_table.getTempDists(), eI_table.getTempDispls(), ee_table.getTempDists(),
445  ee_table.getTempDispls(), cur_Uat, cur_dUat, cur_d2Uat, newUk, newdUk, newd2Uk, ions_nearby_new);
446  DiffVal = Uat[iat] - cur_Uat;
447  grad_iat += cur_dUat;
448  return std::exp(static_cast<PsiValue>(DiffVal));
449  }
const int ee_Table_ID_
table index for el-el
void computeU3(const ParticleSet &P, int jel, const DistRow &distjI, const DisplRow &displjI, const DistRow &distjk, const DisplRow &displjk, valT &Uj, posT &dUj, valT &d2Uj, Vector< valT > &Uk, gContainer_type &dUk, Vector< valT > &d2Uk, std::vector< int > &ions_nearby, bool triangle=false)
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
const int ei_Table_ID_
table index for i-el
std::vector< int > ions_nearby_new
valT cur_Uat
current values during PbyP
RealType DiffVal
diff value

◆ recompute()

void recompute ( const ParticleSet P)
inlineoverridevirtual

recompute the value of the WaveFunctionComponents which require critical accuracy.

needed for Slater Determinants but not needed for most types of WaveFunctionComponents

Reimplemented from WaveFunctionComponent.

Definition at line 543 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::build_compact_list(), JeeIOrbitalSoA< FT >::computeU3(), JeeIOrbitalSoA< FT >::d2Uat, VectorSoaContainer< T, D, Alloc >::data(), JeeIOrbitalSoA< FT >::dUat, JeeIOrbitalSoA< FT >::dUat_temp, JeeIOrbitalSoA< FT >::ee_Table_ID_, JeeIOrbitalSoA< FT >::ei_Table_ID_, ParticleSet::getDistTableAA(), ParticleSet::getDistTableAB(), JeeIOrbitalSoA< FT >::ions_nearby_new, JeeIOrbitalSoA< FT >::Nelec, JeeIOrbitalSoA< FT >::newd2Uk, JeeIOrbitalSoA< FT >::newdUk, JeeIOrbitalSoA< FT >::newUk, OHMMS_DIM, and JeeIOrbitalSoA< FT >::Uat.

Referenced by JeeIOrbitalSoA< FT >::evaluateLog().

544  {
545  const auto& eI_table = P.getDistTableAB(ei_Table_ID_);
546  const auto& ee_table = P.getDistTableAA(ee_Table_ID_);
547 
549 
550  for (int jel = 0; jel < Nelec; ++jel)
551  {
552  computeU3(P, jel, eI_table.getDistRow(jel), eI_table.getDisplRow(jel), ee_table.getDistRow(jel),
553  ee_table.getDisplRow(jel), Uat[jel], dUat_temp, d2Uat[jel], newUk, newdUk, newd2Uk, ions_nearby_new,
554  true);
555  dUat(jel) = dUat_temp;
556 // add the contribution from the upper triangle
557 #pragma omp simd
558  for (int kel = 0; kel < jel; kel++)
559  {
560  Uat[kel] += newUk[kel];
561  d2Uat[kel] += newd2Uk[kel];
562  }
563  for (int idim = 0; idim < OHMMS_DIM; ++idim)
564  {
565  valT* restrict save_g = dUat.data(idim);
566  const valT* restrict new_g = newdUk.data(idim);
567 #pragma omp simd aligned(save_g, new_g : QMC_SIMD_ALIGNMENT)
568  for (int kel = 0; kel < jel; kel++)
569  save_g[kel] += new_g[kel];
570  }
571  }
572  }
const int ee_Table_ID_
table index for el-el
void build_compact_list(const ParticleSet &P)
#define OHMMS_DIM
Definition: config.h:64
void computeU3(const ParticleSet &P, int jel, const DistRow &distjI, const DisplRow &displjI, const DistRow &distjk, const DisplRow &displjk, valT &Uj, posT &dUj, valT &d2Uj, Vector< valT > &Uk, gContainer_type &dUk, Vector< valT > &d2Uk, std::vector< int > &ions_nearby, bool triangle=false)
const int ei_Table_ID_
table index for i-el
typename FT::real_type valT
type of each component U, dU, d2U;
std::vector< int > ions_nearby_new

◆ registerData()

void registerData ( ParticleSet P,
WFBufferType buf 
)
inlineoverridevirtual

For particle-by-particle move.

Requests space in the buffer based on the data type sizes of the objects in this class.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 787 of file JeeIOrbitalSoA.h.

References PooledMemory< T_scalar, Alloc >::add(), Vector< T, Alloc >::begin(), WaveFunctionComponent::Bytes_in_WFBuffer, PooledMemory< T_scalar, Alloc >::current(), JeeIOrbitalSoA< FT >::d2Uat, VectorSoaContainer< T, D, Alloc >::data(), JeeIOrbitalSoA< FT >::dUat, Vector< T, Alloc >::end(), VectorSoaContainer< T, D, Alloc >::end(), PooledMemory< T_scalar, Alloc >::forward(), VectorSoaContainer< T, D, Alloc >::free(), Vector< T, Alloc >::free(), and JeeIOrbitalSoA< FT >::Uat.

788  {
789  if (Bytes_in_WFBuffer == 0)
790  {
791  Bytes_in_WFBuffer = buf.current();
792  buf.add(Uat.begin(), Uat.end());
793  buf.add(dUat.data(), dUat.end());
794  buf.add(d2Uat.begin(), d2Uat.end());
795  Bytes_in_WFBuffer = buf.current() - Bytes_in_WFBuffer;
796  // free local space
797  Uat.free();
798  dUat.free();
799  d2Uat.free();
800  }
801  else
802  {
803  buf.forward(Bytes_in_WFBuffer);
804  }
805  }
void free()
free
Definition: OhmmsVector.h:196
void free()
free allocated memory and clear status variables
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

◆ resizeWFOptVectors()

void resizeWFOptVectors ( )
inlineprivate

Definition at line 109 of file JeeIOrbitalSoA.h.

References JeeIOrbitalSoA< FT >::dgrad_dalpha, JeeIOrbitalSoA< FT >::dhess_dalpha, JeeIOrbitalSoA< FT >::dLogPsi, JeeIOrbitalSoA< FT >::du_dalpha, JeeIOrbitalSoA< FT >::gradLogPsi, JeeIOrbitalSoA< FT >::J3Unique, JeeIOrbitalSoA< FT >::J3UniqueIndex, JeeIOrbitalSoA< FT >::lapLogPsi, WaveFunctionComponent::myVars, JeeIOrbitalSoA< FT >::Nelec, Array< T, D, ALLOC >::resize(), Vector< T, Alloc >::resize(), and VariableSet::size().

Referenced by JeeIOrbitalSoA< FT >::evaluateDerivatives(), and JeeIOrbitalSoA< FT >::evaluateDerivativesWF().

110  {
112  gradLogPsi.resize(myVars.size(), Nelec);
114 
115  du_dalpha.resize(J3Unique.size());
116  dgrad_dalpha.resize(J3Unique.size());
117  dhess_dalpha.resize(J3Unique.size());
118 
119  int ifunc = 0;
120  for (auto& j3UniquePair : J3Unique)
121  {
122  auto functorPtr = j3UniquePair.second.get();
123  J3UniqueIndex[functorPtr] = ifunc;
124  const int numParams = functorPtr->getNumParameters();
125  du_dalpha[ifunc].resize(numParams);
126  dgrad_dalpha[ifunc].resize(numParams);
127  dhess_dalpha[ifunc].resize(numParams);
128  ifunc++;
129  }
130  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::map< FT *, int > J3UniqueIndex
Array< RealType, 2 > lapLogPsi
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::map< std::string, std::unique_ptr< FT > > J3Unique
size_type size() const
return the size
Definition: VariableSet.h:88
std::vector< std::vector< Tensor< RealType, 3 > > > dhess_dalpha
Vector< RealType > dLogPsi
std::vector< std::vector< PosType > > dgrad_dalpha
std::vector< std::vector< RealType > > du_dalpha
Array< PosType, 2 > gradLogPsi

◆ restore()

void restore ( int  iat)
inlineoverridevirtual

If a move for iat-th particle is rejected, restore to the content.

Parameters
iatindex of the particle whose new position was proposed

Ye: hopefully we can gradually move away from restore

Implements WaveFunctionComponent.

Definition at line 451 of file JeeIOrbitalSoA.h.

451 {}

◆ updateBuffer()

LogValue updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)
inlineoverridevirtual

For particle-by-particle move.

Put the objects of this class in the walker buffer or forward the memory cursor.

Parameters
Pparticle set
bufAnonymous storage
fromscratchrequest recomputing the precision critical pieces of wavefunction from scratch
Returns
log value of the wavefunction.

Implements WaveFunctionComponent.

Definition at line 807 of file JeeIOrbitalSoA.h.

References WaveFunctionComponent::Bytes_in_WFBuffer, JeeIOrbitalSoA< FT >::computeGL(), PooledMemory< T_scalar, Alloc >::forward(), ParticleSet::G, ParticleSet::L, and WaveFunctionComponent::log_value_.

808  {
809  log_value_ = computeGL(P.G, P.L);
810  buf.forward(Bytes_in_WFBuffer);
811  return log_value_;
812  }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

Member Data Documentation

◆ cur_d2Uat

valT cur_d2Uat
private

◆ cur_dUat

posT cur_dUat
private

◆ cur_Uat

valT cur_Uat
private

current values during PbyP

Definition at line 68 of file JeeIOrbitalSoA.h.

Referenced by JeeIOrbitalSoA< FT >::acceptMove(), JeeIOrbitalSoA< FT >::ratio(), and JeeIOrbitalSoA< FT >::ratioGrad().

◆ d2Uat

◆ dgrad_dalpha

std::vector<std::vector<PosType> > dgrad_dalpha
private

◆ dhess_dalpha

std::vector<std::vector<Tensor<RealType, 3> > > dhess_dalpha
private

◆ DiffVal

RealType DiffVal
private

diff value

Definition at line 58 of file JeeIOrbitalSoA.h.

Referenced by JeeIOrbitalSoA< FT >::ratio(), and JeeIOrbitalSoA< FT >::ratioGrad().

◆ Disp_jI_Compressed

◆ Disp_jk_Compressed

gContainer_type Disp_jk_Compressed
private

compressed displacements

Definition at line 92 of file JeeIOrbitalSoA.h.

Referenced by JeeIOrbitalSoA< FT >::computeU3(), JeeIOrbitalSoA< FT >::computeU3_engine(), and JeeIOrbitalSoA< FT >::init().

◆ Disp_kI_Compressed

◆ DistIndice_k

std::vector<int> DistIndice_k
private

◆ DistjI_Compressed

◆ Distjk_Compressed

◆ DistkI_Compressed

◆ dLogPsi

◆ du_dalpha

◆ dUat

◆ dUat_temp

posT dUat_temp
private

◆ ee_Table_ID_

◆ eGroups

◆ ei_Table_ID_

◆ elecs_inside

◆ elecs_inside_displ

◆ elecs_inside_dist

◆ F

◆ gradLogPsi

◆ iGroups

◆ Ion_cutoff

◆ Ions

◆ ions_nearby_new

◆ ions_nearby_old

std::vector<int> ions_nearby_old
private

the ids of ions within the cutoff radius of an electron on which a move is proposed

Definition at line 84 of file JeeIOrbitalSoA.h.

Referenced by JeeIOrbitalSoA< FT >::acceptMove(), JeeIOrbitalSoA< FT >::evaluateRatios(), and JeeIOrbitalSoA< FT >::init().

◆ J3Unique

◆ J3UniqueIndex

◆ lapLogPsi

◆ mVGL

VectorSoaContainer<valT, 9> mVGL
private

work result buffer

Definition at line 94 of file JeeIOrbitalSoA.h.

Referenced by JeeIOrbitalSoA< FT >::computeU3_engine(), and JeeIOrbitalSoA< FT >::init().

◆ Nbuffer

size_t Nbuffer
private

◆ Nelec

◆ Nelec_padded

size_t Nelec_padded
private

number of particles + padded

Definition at line 52 of file JeeIOrbitalSoA.h.

Referenced by JeeIOrbitalSoA< FT >::copyFromBuffer(), and JeeIOrbitalSoA< FT >::init().

◆ newd2Uk

◆ newdUk

◆ newUk

◆ Nion

◆ oldd2Uk

Vector<valT> oldd2Uk
private

◆ olddUk

gContainer_type olddUk
private

◆ oldUk

Vector<valT> oldUk
private

◆ Uat

◆ VarOffset

◆ qmcplusplus::TwoBodyJastrow

class qmcplusplus::TwoBodyJastrow

template<class FT>
class qmcplusplus::TwoBodyJastrow< FT >

Specialization for two-body Jastrow function using multiple functors.

Each pair-type can have distinct function $u(r_{ij})$. For electrons, distinct pair correlation functions are used for spins up-up/down-down and up-down/down-up.

Based on TwoBodyJastrow.h with these considerations

  • DistanceTable using SoA containers
  • support mixed precision: FT::real_type != OHMMS_PRECISION
  • loops over the groups: elminated PairID
  • support simd function
  • double the loop counts
  • Memory use is O(N).

Definition at line 56 of file TwoBodyJastrow.h.

+ Inheritance diagram for TwoBodyJastrow< FT >:
+ Collaboration diagram for TwoBodyJastrow< FT >:

Public Types

using FuncType = FT
 alias FuncType More...
 
using valT = typename FT::real_type
 type of each component U, dU, d2U; More...
 
using posT = TinyVector< valT, DIM >
 element position type More...
 
using DistRow = DistanceTable::DistRow
 use the same container More...
 
using DisplRow = DistanceTable::DisplRow
 
using GradDerivVec = ParticleAttrib< QTFull::GradType >
 
using ValueDerivVec = ParticleAttrib< QTFull::ValueType >
 
- Public Types inherited from WaveFunctionComponent
enum  {
  ORB_PBYP_RATIO, ORB_PBYP_ALL, ORB_PBYP_PARTIAL, ORB_WALKER,
  ORB_ALLWALKER
}
 enum for a update mode More...
 
using Walker_t = ParticleSet::Walker_t
 
using WFBufferType = Walker_t::WFBuffer_t
 
using BufferType = Walker_t::Buffer_t
 
using RealMatrix_t = OrbitalSetTraits< RealType >::ValueMatrix
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using LogValue = std::complex< QTFull::RealType >
 
using PsiValue = QTFull::ValueType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 TwoBodyJastrow (const std::string &obj_name, ParticleSet &p, bool use_offload)
 
 TwoBodyJastrow (const TwoBodyJastrow &rhs)=delete
 
 ~TwoBodyJastrow () override
 
void addFunc (int ia, int ib, std::unique_ptr< FT > j)
 add functor for (ia,ib) pair More...
 
void checkSanity () const override
 Validate the internal consistency of the object. More...
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 return a shared resource to a collection More...
 
std::string getClassName () const override
 return class name More...
 
bool isOptimizable () const override
 if true, this contains optimizable components More...
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) override
 extract underlying OptimizableObject references More...
 
void checkOutVariables (const opt_variables_type &active) override
 check out optimizable variables More...
 
void finalizeOptimization () override
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const override
 make clone More...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch More...
 
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 override
 evaluate from scratch the same type WaveFunctionComponent of multiple walkers More...
 
void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi) override
 
void recompute (const ParticleSet &P) override
 recompute internal data assuming distance table is fully ready More...
 
void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const override
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
void mw_calcRatio (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const override
 
void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios) override
 
void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const override
 
GradType evalGrad (ParticleSet &P, int iat) override
 return the current gradient for the iat-th particle More...
 
PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient More...
 
void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const override
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 a move for iat-th particle is accepted. More...
 
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 override
 moves of the iat-th particle on some walkers in a batch is accepted. More...
 
void restore (int iat) override
 If a move for iat-th particle is rejected, restore to the content. More...
 
LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch=false) override
 compute G and L after the sweep More...
 
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 override
 evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers More...
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
 For particle-by-particle move. More...
 
RealType ChiesaKEcorrection ()
 
RealType KECorrection () override
 Return the Chiesa kinetic energy correction. More...
 
const std::vector< FT * > & getPairFunctions () const
 
std::pair< int, int > getComponentOffset (int index)
 
opt_variables_typegetComponentVars ()
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
 
void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
 
- Public Member Functions inherited from WaveFunctionComponent
const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
const std::string & getName () const
 return object name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual bool isFermionic () const
 true, if this component is fermionic More...
 
virtual bool isMultiDet () const
 true, if this component is multi-determinant More...
 
virtual void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
virtual void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
virtual GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad)
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat)
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
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. More...
 
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 implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
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 p-by-p move region. More...
 
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 More...
 
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 optimizable parameters. More...
 
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. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
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 More...
 
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 More...
 
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 More...
 
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 multiple walkers More...
 

Protected Attributes

const size_t N
 number of particles More...
 
const size_t NumGroups
 number of groups of the target particleset More...
 
const size_t ndim
 number of spatial dimensions More...
 
const valT lapfac
 laplacian prefactor More...
 
- Protected Attributes inherited from WaveFunctionComponent
const std::string my_name_
 Name of the object It is required to be different for objects of the same derived type like multiple J1. More...
 
LogValue log_value_
 Current $\log\phi $. More...
 

Private Member Functions

void resizeInternalStorage ()
 initialize storage Uat,dUat, d2Uat More...
 
void resizeWFOptVectors ()
 
QTFull::RealType computeGL (ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
 compute G and L from internally stored data More...
 
valT computeU (const ParticleSet &P, int iat, const DistRow &dist)
 
void computeU3 (const ParticleSet &P, int iat, const DistRow &dist, RealType *restrict u, RealType *restrict du, RealType *restrict d2u, bool triangle=false)
 intenal function to compute $\sum_j u(r_j), du/dr, d2u/dr2$ More...
 
posT accumulateG (const valT *restrict du, const DisplRow &displ) const
 compute gradient More...
 

Private Attributes

const bool use_offload_
 if true use offload More...
 
const size_t N_padded
 number of particles + padded More...
 
Vector< int, OffloadPinnedAllocator< int > > grp_ids
 the group_id of each particle More...
 
RealType DiffVal
 diff value More...
 
RealType KEcorr
 Correction. More...
 
Vector< valT, aligned_allocator< valT > > Uat
 $Uat[i] = sum_(j) u_{i,j}$ More...
 
VectorSoaContainer< valT, DIM, aligned_allocator< valT > > dUat
 $dUat[i] = sum_(j) du_{i,j}$ More...
 
Vector< valT, aligned_allocator< valT > > d2Uat
 $d2Uat[i] = sum_(j) d2u_{i,j}$ More...
 
valT cur_Uat
 
aligned_vector< valTcur_u
 
aligned_vector< valTcur_du
 
aligned_vector< valTcur_d2u
 
aligned_vector< valTold_u
 
aligned_vector< valTold_du
 
aligned_vector< valTold_d2u
 
aligned_vector< valTDistCompressed
 
aligned_vector< int > DistIndice
 
std::map< std::string, std::unique_ptr< FT > > J2Unique
 Uniquue J2 set for cleanup. More...
 
std::vector< FT * > F
 Container for $F[ig*NumGroups+jg]$. treat every pointer as a reference. More...
 
const int my_table_ID_
 e-e table ID More...
 
J2KECorrection< RealType, FT > j2_ke_corr_helper
 
std::vector< std::pair< int, int > > OffSet
 Map indices from subcomponent variables to component variables. More...
 
Vector< RealTypedLogPsi
 
std::vector< GradDerivVecgradLogPsi
 
std::vector< ValueDerivVeclapLogPsi
 
ResourceHandle< TwoBodyJastrowMultiWalkerMem< RealType > > mw_mem_handle_
 

Additional Inherited Members

- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 

Member Typedef Documentation

◆ DisplRow

Definition at line 67 of file TwoBodyJastrow.h.

◆ DistRow

use the same container

Definition at line 66 of file TwoBodyJastrow.h.

◆ FuncType

using FuncType = FT

alias FuncType

Definition at line 60 of file TwoBodyJastrow.h.

◆ GradDerivVec

Definition at line 69 of file TwoBodyJastrow.h.

◆ posT

using posT = TinyVector<valT, DIM>

element position type

Definition at line 64 of file TwoBodyJastrow.h.

◆ valT

using valT = typename FT::real_type

type of each component U, dU, d2U;

Definition at line 62 of file TwoBodyJastrow.h.

◆ ValueDerivVec

Definition at line 70 of file TwoBodyJastrow.h.

Constructor & Destructor Documentation

◆ TwoBodyJastrow() [1/2]

TwoBodyJastrow ( const std::string &  obj_name,
ParticleSet p,
bool  use_offload 
)

Definition at line 292 of file TwoBodyJastrow.cpp.

References TwoBodyJastrow< FT >::F, ParticleSet::first(), TwoBodyJastrow< FT >::grp_ids, TwoBodyJastrow< FT >::KEcorr, ParticleSet::last(), WaveFunctionComponent::my_name_, TwoBodyJastrow< FT >::N, TwoBodyJastrow< FT >::NumGroups, and TwoBodyJastrow< FT >::resizeInternalStorage().

293  : WaveFunctionComponent(obj_name),
294  N(p.getTotalNum()),
295  NumGroups(p.groups()),
296  ndim(p.getLattice().ndim),
297  lapfac(ndim - RealType(1)),
298  use_offload_(use_offload),
299  N_padded(getAlignedSize<valT>(N)),
300  my_table_ID_(p.addTable(p)),
301  j2_ke_corr_helper(p, F)
302 {
303  if (my_name_.empty())
304  throw std::runtime_error("TwoBodyJastrow object name cannot be empty!");
305 
306  F.resize(NumGroups * NumGroups, nullptr);
307 
308  // set up grp_ids
309  grp_ids.resize(N);
310  int count = 0;
311  for (int ig = 0; ig < NumGroups; ig++)
312  for (int j = p.first(ig); j < p.last(ig); j++)
313  grp_ids[count++] = ig;
314  assert(count == N);
315  grp_ids.updateTo();
316 
318 
319  KEcorr = 0.0;
320 }
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
QTBase::RealType RealType
Definition: Configuration.h:58
const bool use_offload_
if true use offload
void resizeInternalStorage()
initialize storage Uat,dUat, d2Uat
std::vector< FT * > F
Container for . treat every pointer as a reference.
const size_t ndim
number of spatial dimensions
const int my_table_ID_
e-e table ID
const size_t N_padded
number of particles + padded
const valT lapfac
laplacian prefactor
Vector< int, OffloadPinnedAllocator< int > > grp_ids
the group_id of each particle
const size_t NumGroups
number of groups of the target particleset
J2KECorrection< RealType, FT > j2_ke_corr_helper
WaveFunctionComponent(const std::string &obj_name="")
default constructor
RealType KEcorr
Correction.
const size_t N
number of particles

◆ TwoBodyJastrow() [2/2]

TwoBodyJastrow ( const TwoBodyJastrow< FT > &  rhs)
delete

◆ ~TwoBodyJastrow()

~TwoBodyJastrow ( )
overridedefault

Member Function Documentation

◆ acceptMove()

void acceptMove ( ParticleSet P,
int  iat,
bool  safe_to_delay = false 
)
overridevirtual

a move for iat-th particle is accepted.

Update the current content.

Parameters
Ptarget ParticleSet
iatindex of the particle whose new position was proposed
safe_to_delayif true, delayed accept is safe.

Implements WaveFunctionComponent.

Definition at line 583 of file TwoBodyJastrow.cpp.

References TinyVector< T, D >::data(), ParticleSet::getDistTableAA(), DistanceTableAA::getTempDists(), and qmcplusplus::Units::force::N.

584 {
585  // get the old u, du, d2u
586  const auto& d_table = P.getDistTableAA(my_table_ID_);
587  computeU3(P, iat, d_table.getOldDists(), old_u.data(), old_du.data(), old_d2u.data());
588  if (UpdateMode == ORB_PBYP_RATIO)
589  { //ratio-only during the move; need to compute derivatives
590  const auto& dist = d_table.getTempDists();
591  computeU3(P, iat, dist, cur_u.data(), cur_du.data(), cur_d2u.data());
592  }
593 
594  valT cur_d2Uat(0);
595  const auto& new_dr = d_table.getTempDispls();
596  const auto& old_dr = d_table.getOldDispls();
597 #pragma omp simd reduction(+ : cur_d2Uat)
598  for (int jat = 0; jat < N; jat++)
599  {
600  const valT du = cur_u[jat] - old_u[jat];
601  const valT newl = cur_d2u[jat] + lapfac * cur_du[jat];
602  const valT dl = old_d2u[jat] + lapfac * old_du[jat] - newl;
603  Uat[jat] += du;
604  d2Uat[jat] += dl;
605  cur_d2Uat -= newl;
606  }
607  posT cur_dUat;
608  for (int idim = 0; idim < ndim; ++idim)
609  {
610  const valT* restrict new_dX = new_dr.data(idim);
611  const valT* restrict old_dX = old_dr.data(idim);
612  const valT* restrict cur_du_pt = cur_du.data();
613  const valT* restrict old_du_pt = old_du.data();
614  valT* restrict save_g = dUat.data(idim);
615  valT cur_g = cur_dUat[idim];
616 #pragma omp simd reduction(+ : cur_g) aligned(old_dX, new_dX, save_g, cur_du_pt, old_du_pt : QMC_SIMD_ALIGNMENT)
617  for (int jat = 0; jat < N; jat++)
618  {
619  const valT newg = cur_du_pt[jat] * new_dX[jat];
620  const valT dg = newg - old_du_pt[jat] * old_dX[jat];
621  save_g[jat] -= dg;
622  cur_g += newg;
623  }
624  cur_dUat[idim] = cur_g;
625  }
626  log_value_ += Uat[iat] - cur_Uat;
627  Uat[iat] = cur_Uat;
628  dUat(iat) = cur_dUat;
629  d2Uat[iat] = cur_d2Uat;
630 }
Vector< valT, aligned_allocator< valT > > d2Uat
aligned_vector< valT > cur_u
const size_t ndim
number of spatial dimensions
aligned_vector< valT > cur_du
aligned_vector< valT > old_du
aligned_vector< valT > cur_d2u
const int my_table_ID_
e-e table ID
typename FT::real_type valT
type of each component U, dU, d2U;
void computeU3(const ParticleSet &P, int iat, const DistRow &dist, RealType *restrict u, RealType *restrict du, RealType *restrict d2u, bool triangle=false)
intenal function to compute
const valT lapfac
laplacian prefactor
aligned_vector< valT > old_u
VectorSoaContainer< valT, DIM, aligned_allocator< valT > > dUat
TinyVector< valT, DIM > posT
element position type
const size_t N
number of particles
aligned_vector< valT > old_d2u
Vector< valT, aligned_allocator< valT > > Uat

◆ accumulateG()

TwoBodyJastrow< FT >::posT accumulateG ( const valT *restrict  du,
const DisplRow displ 
) const
private

compute gradient

Definition at line 275 of file TwoBodyJastrow.cpp.

References VectorSoaContainer< T, D, Alloc >::data(), qmcplusplus::Units::force::N, and qmcplusplus::Units::time::s.

276 {
277  posT grad;
278  for (int idim = 0; idim < ndim; ++idim)
279  {
280  const valT* restrict dX = displ.data(idim);
281  valT s = valT();
282 
283 #pragma omp simd reduction(+ : s) aligned(du, dX : QMC_SIMD_ALIGNMENT)
284  for (int jat = 0; jat < N; ++jat)
285  s += du[jat] * dX[jat];
286  grad[idim] = s;
287  }
288  return grad;
289 }
const size_t ndim
number of spatial dimensions
typename FT::real_type valT
type of each component U, dU, d2U;
TinyVector< valT, DIM > posT
element position type
const size_t N
number of particles

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
overridevirtual

acquire a shared resource from a collection

Reimplemented from WaveFunctionComponent.

Definition at line 57 of file TwoBodyJastrow.cpp.

References qmcplusplus::ewaldref::DIM, VectorSoaContainer< T, D, Alloc >::free(), Vector< T, Alloc >::free(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), ResourceCollection::lendResource(), TwoBodyJastrow< FT >::mw_mem_handle_, and qmcplusplus::Units::force::N.

59 {
60  auto& wfc_leader = wfc_list.getCastedLeader<TwoBodyJastrow<FT>>();
61  wfc_leader.mw_mem_handle_ = collection.lendResource<TwoBodyJastrowMultiWalkerMem<RealType>>();
62  const size_t nw = wfc_list.size();
63  auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
64  mw_allUat.resize(N_padded * (DIM + 2) * nw);
65  for (size_t iw = 0; iw < nw; iw++)
66  {
67  // copy per walker Uat, dUat, d2Uat to shared buffer and attach buffer
68  auto& wfc = wfc_list.getCastedElement<TwoBodyJastrow<FT>>(iw);
69 
70  Vector<valT, aligned_allocator<valT>> Uat_view(mw_allUat.data() + iw * N_padded, N);
71  Uat_view = wfc.Uat;
72  wfc.Uat.free();
73  wfc.Uat.attachReference(mw_allUat.data() + iw * N_padded, N);
74 
75  VectorSoaContainer<valT, DIM, aligned_allocator<valT>> dUat_view(mw_allUat.data() + nw * N_padded +
76  iw * N_padded * DIM,
77  N, N_padded);
78  dUat_view = wfc.dUat;
79  wfc.dUat.free();
80  wfc.dUat.attachReference(N, N_padded, mw_allUat.data() + nw * N_padded + iw * N_padded * DIM);
81 
82  Vector<valT, aligned_allocator<valT>> d2Uat_view(mw_allUat.data() + nw * N_padded * (DIM + 1) + iw * N_padded, N);
83  d2Uat_view = wfc.d2Uat;
84  wfc.d2Uat.free();
85  wfc.d2Uat.attachReference(mw_allUat.data() + nw * N_padded * (DIM + 1) + iw * N_padded, N);
86  }
87  wfc_leader.mw_mem_handle_.getResource().mw_cur_allu.resize(N_padded * 3 * nw);
88 }
const size_t N_padded
number of particles + padded
const size_t N
number of particles

◆ addFunc()

void addFunc ( int  ia,
int  ib,
std::unique_ptr< FT >  j 
)

add functor for (ia,ib) pair

Definition at line 352 of file TwoBodyJastrow.cpp.

References qmcplusplus::Units::force::N.

Referenced by qmcplusplus::TEST_CASE().

353 {
354  assert(ia < NumGroups);
355  assert(ib < NumGroups);
356  if (ia == ib)
357  {
358  if (ia == 0) //first time, assign everything
359  {
360  int ij = 0;
361  for (int ig = 0; ig < NumGroups; ++ig)
362  for (int jg = 0; jg < NumGroups; ++jg, ++ij)
363  if (F[ij] == nullptr)
364  F[ij] = j.get();
365  }
366  else
367  F[ia * NumGroups + ib] = j.get();
368  }
369  else
370  {
371  // a very special case, 1 particle of each type (e.g. 1 up + 1 down)
372  // uu/dd/etc. was prevented by the builder
373  if (N == NumGroups)
374  for (int ig = 0; ig < NumGroups; ++ig)
375  F[ig * NumGroups + ig] = j.get();
376  // generic case
377  F[ia * NumGroups + ib] = j.get();
378  F[ib * NumGroups + ia] = j.get();
379  }
380  std::stringstream aname;
381  aname << ia << ib;
382  J2Unique[aname.str()] = std::move(j);
383 }
std::map< std::string, std::unique_ptr< FT > > J2Unique
Uniquue J2 set for cleanup.
std::vector< FT * > F
Container for . treat every pointer as a reference.
const size_t NumGroups
number of groups of the target particleset
const size_t N
number of particles

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
overridevirtual

check out optimizable variables

Reimplemented from WaveFunctionComponent.

Definition at line 130 of file TwoBodyJastrow.cpp.

Referenced by qmcplusplus::TEST_CASE().

131 {
132  myVars.clear();
133  for (auto& [key, functor] : J2Unique)
134  {
135  functor->myVars.getIndex(active);
136  myVars.insertFrom(functor->myVars);
137  }
138  // Remove inactive variables so the mappings are correct
140 
141  myVars.getIndex(active);
142 
143  const size_t NumVars = myVars.size();
144  if (NumVars)
145  {
146  OffSet.resize(F.size());
147 
148  // Find first active variable for the starting offset
149  int varoffset = -1;
150  for (int i = 0; i < myVars.size(); i++)
151  {
152  varoffset = myVars.Index[i];
153  if (varoffset != -1)
154  break;
155  }
156 
157  for (int i = 0; i < F.size(); ++i)
158  if (F[i] && F[i]->myVars.Index.size())
159  {
160  OffSet[i].first = F[i]->myVars.Index.front() - varoffset;
161  OffSet[i].second = F[i]->myVars.Index.size() + OffSet[i].first;
162  }
163  else
164  OffSet[i].first = OffSet[i].second = -1;
165  }
166 }
std::vector< std::pair< int, int > > OffSet
Map indices from subcomponent variables to component variables.
std::vector< int > Index
store locator of the named variable
Definition: VariableSet.h:65
std::map< std::string, std::unique_ptr< FT > > J2Unique
Uniquue J2 set for cleanup.
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::vector< FT * > F
Container for . treat every pointer as a reference.
void clear()
clear the variable set
Definition: VariableSet.cpp:28
size_type size() const
return the size
Definition: VariableSet.h:88
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
Definition: VariableSet.cpp:37
void removeInactive()
remove inactive variables and trim the internal data
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter

◆ checkSanity()

void checkSanity ( ) const
overridevirtual

Validate the internal consistency of the object.

Reimplemented from WaveFunctionComponent.

Definition at line 326 of file TwoBodyJastrow.cpp.

References qmcplusplus::app_warning().

327 {
328  if (std::any_of(F.begin(), F.end(), [](auto* ptr) { return ptr == nullptr; }))
329  app_warning() << "Two-body Jastrow \"" << my_name_ << "\" doesn't cover all the particle pairs. "
330  << "Consider fusing multiple entries if they are of the same type for optimal code performance."
331  << std::endl;
332 }
std::ostream & app_warning()
Definition: OutputManager.h:69
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
std::vector< FT * > F
Container for . treat every pointer as a reference.

◆ ChiesaKEcorrection()

RealType ChiesaKEcorrection ( )
inline

◆ computeGL()

compute G and L from internally stored data

Definition at line 771 of file TwoBodyJastrow.cpp.

References qmcplusplus::simd::accumulate_n(), and qmcplusplus::Units::force::N.

773 {
774  for (int iat = 0; iat < N; ++iat)
775  {
776  G[iat] += dUat[iat];
777  L[iat] += d2Uat[iat];
778  }
779  return -0.5 * simd::accumulate_n(Uat.data(), N, QTFull::RealType());
780 }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
Vector< valT, aligned_allocator< valT > > d2Uat
VectorSoaContainer< valT, DIM, aligned_allocator< valT > > dUat
Precision RealType
Definition: QMCTypes.h:37
const size_t N
number of particles
Vector< valT, aligned_allocator< valT > > Uat

◆ computeU()

TwoBodyJastrow< FT >::valT computeU ( const ParticleSet P,
int  iat,
const DistRow dist 
)
private

Definition at line 259 of file TwoBodyJastrow.cpp.

References Vector< T, Alloc >::data(), ParticleSet::first(), ParticleSet::GroupID, and ParticleSet::last().

260 {
261  valT curUat(0);
262  const int igt = P.GroupID[iat] * NumGroups;
263  for (int jg = 0; jg < NumGroups; ++jg)
264  if (F[igt + jg])
265  {
266  const FuncType& f2(*F[igt + jg]);
267  int iStart = P.first(jg);
268  int iEnd = P.last(jg);
269  curUat += f2.evaluateV(iat, iStart, iEnd, dist.data(), DistCompressed.data());
270  }
271  return curUat;
272 }
aligned_vector< valT > DistCompressed
std::vector< FT * > F
Container for . treat every pointer as a reference.
typename FT::real_type valT
type of each component U, dU, d2U;
const size_t NumGroups
number of groups of the target particleset
FT FuncType
alias FuncType

◆ computeU3()

void computeU3 ( const ParticleSet P,
int  iat,
const DistRow dist,
RealType *restrict  u,
RealType *restrict  du,
RealType *restrict  d2u,
bool  triangle = false 
)
private

intenal function to compute $\sum_j u(r_j), du/dr, d2u/dr2$

Parameters
Pparticleset
iatparticle index
diststarting distance
ustarting value
dustarting first deriv
d2ustarting second deriv

Definition at line 422 of file TwoBodyJastrow.cpp.

References BLAS::czero, Vector< T, Alloc >::data(), OMPstd::fill_n(), ParticleSet::first(), ParticleSet::GroupID, ParticleSet::last(), omptarget::min(), and qmcplusplus::Units::force::N.

429 {
430  const int jelmax = triangle ? iat : N;
431  constexpr valT czero(0);
432  std::fill_n(u, jelmax, czero);
433  std::fill_n(du, jelmax, czero);
434  std::fill_n(d2u, jelmax, czero);
435 
436  const int igt = P.GroupID[iat] * NumGroups;
437  for (int jg = 0; jg < NumGroups; ++jg)
438  if (F[igt + jg])
439  {
440  const FuncType& f2(*F[igt + jg]);
441  int iStart = P.first(jg);
442  int iEnd = std::min(jelmax, P.last(jg));
443  f2.evaluateVGL(iat, iStart, iEnd, dist.data(), u, du, d2u, DistCompressed.data(), DistIndice.data());
444  }
445  //u[iat]=czero;
446  //du[iat]=czero;
447  //d2u[iat]=czero;
448 }
void fill_n(T *x, size_t count, const T &value)
Definition: OMPstd.hpp:21
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
aligned_vector< valT > DistCompressed
T min(T a, T b)
std::vector< FT * > F
Container for . treat every pointer as a reference.
typename FT::real_type valT
type of each component U, dU, d2U;
aligned_vector< int > DistIndice
const size_t NumGroups
number of groups of the target particleset
FT FuncType
alias FuncType
const size_t N
number of particles

◆ copyFromBuffer()

void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)
overridevirtual

For particle-by-particle move.

Copy data or attach memory from a walker buffer to the objects of this class. The log value, P.G and P.L contribution from the objects of this class are also added.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 241 of file TwoBodyJastrow.cpp.

References qmcplusplus::ewaldref::DIM, PooledMemory< T_scalar, Alloc >::lendReference(), and qmcplusplus::Units::force::N.

242 {
243  Uat.attachReference(buf.lendReference<valT>(N), N);
244  dUat.attachReference(N, N_padded, buf.lendReference<valT>(N_padded * DIM));
245  d2Uat.attachReference(buf.lendReference<valT>(N), N);
246 }
Vector< valT, aligned_allocator< valT > > d2Uat
const size_t N_padded
number of particles + padded
typename FT::real_type valT
type of each component U, dU, d2U;
VectorSoaContainer< valT, DIM, aligned_allocator< valT > > dUat
const size_t N
number of particles
Vector< valT, aligned_allocator< valT > > Uat

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 51 of file TwoBodyJastrow.cpp.

References ResourceCollection::addResource().

52 {
53  collection.addResource(std::make_unique<TwoBodyJastrowMultiWalkerMem<RealType>>());
54 }

◆ evalGrad()

TwoBodyJastrow< FT >::GradType evalGrad ( ParticleSet P,
int  iat 
)
overridevirtual

return the current gradient for the iat-th particle

Parameters
Pquantum particle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented from WaveFunctionComponent.

Definition at line 526 of file TwoBodyJastrow.cpp.

527 {
528  return GradType(dUat[iat]);
529 }
QTBase::GradType GradType
Definition: Configuration.h:62
VectorSoaContainer< valT, DIM, aligned_allocator< valT > > dUat

◆ evaluateDerivatives()

void evaluateDerivatives ( ParticleSet P,
const opt_variables_type active,
Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
override

Definition at line 847 of file TwoBodyJastrow.cpp.

References qmcplusplus::Dot(), ParticleSet::G, VariableSet::recompute(), and qmcplusplus::Sum().

Referenced by qmcplusplus::TEST_CASE().

851 {
852  if (myVars.size() == 0)
853  return;
854 
855  evaluateDerivativesWF(P, active, dlogpsi);
856  bool recalculate(false);
857  std::vector<bool> rcsingles(myVars.size(), false);
858  for (int k = 0; k < myVars.size(); ++k)
859  {
860  int kk = myVars.where(k);
861  if (kk < 0)
862  continue;
863  if (active.recompute(kk))
864  recalculate = true;
865  rcsingles[k] = true;
866  }
867  if (recalculate)
868  {
869  for (int k = 0; k < myVars.size(); ++k)
870  {
871  int kk = myVars.where(k);
872  if (kk < 0)
873  continue;
874  if (rcsingles[k])
875  {
876  dhpsioverpsi[kk] = -RealType(0.5) * ValueType(Sum(lapLogPsi[k])) - ValueType(Dot(P.G, gradLogPsi[k]));
877  }
878  }
879  }
880 }
T Sum(const ParticleAttrib< T > &pa)
QTBase::RealType RealType
Definition: Configuration.h:58
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
std::vector< ValueDerivVec > lapLogPsi
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
QTBase::ValueType ValueType
Definition: Configuration.h:60
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_type size() const
return the size
Definition: VariableSet.h:88
std::vector< GradDerivVec > gradLogPsi

◆ evaluateDerivativesWF()

void evaluateDerivativesWF ( ParticleSet P,
const opt_variables_type active,
Vector< ValueType > &  dlogpsi 
)
override

precomputed recalculation switch

Definition at line 883 of file TwoBodyJastrow.cpp.

References BLAS::cone, ParticleSet::getDistTableAA(), ParticleSet::GroupID, ParticleSet::groups(), qmcplusplus::n, and VariableSet::recompute().

Referenced by qmcplusplus::TEST_CASE().

886 {
887  if (myVars.size() == 0)
888  return;
889 
891 
892  bool recalculate(false);
893  std::vector<bool> rcsingles(myVars.size(), false);
894  for (int k = 0; k < myVars.size(); ++k)
895  {
896  int kk = myVars.where(k);
897  if (kk < 0)
898  continue;
899  if (active.recompute(kk))
900  recalculate = true;
901  rcsingles[k] = true;
902  }
903  if (recalculate)
904  {
905  ///precomputed recalculation switch
906  std::vector<bool> RecalcSwitch(F.size(), false);
907  for (int i = 0; i < F.size(); ++i)
908  {
909  if (OffSet[i].first < 0)
910  {
911  // nothing to optimize
912  RecalcSwitch[i] = false;
913  }
914  else
915  {
916  bool recalcFunc(false);
917  for (int rcs = OffSet[i].first; rcs < OffSet[i].second; rcs++)
918  if (rcsingles[rcs] == true)
919  recalcFunc = true;
920  RecalcSwitch[i] = recalcFunc;
921  }
922  }
923  dLogPsi = 0.0;
924  const size_t NumVars = myVars.size();
925  for (int p = 0; p < NumVars; ++p)
926  {
927  gradLogPsi[p] = 0.0;
928  lapLogPsi[p] = 0.0;
929  }
930  std::vector<TinyVector<RealType, 3>> derivs(NumVars);
931  const auto& d_table = P.getDistTableAA(my_table_ID_);
932  constexpr RealType cone(1);
933  const size_t n = d_table.sources();
934  const size_t ng = P.groups();
935  for (size_t i = 1; i < n; ++i)
936  {
937  const size_t ig = P.GroupID[i] * ng;
938  const auto& dist = d_table.getDistRow(i);
939  const auto& displ = d_table.getDisplRow(i);
940  for (size_t j = 0; j < i; ++j)
941  {
942  const size_t ptype = ig + P.GroupID[j];
943  if (RecalcSwitch[ptype])
944  {
945  std::fill(derivs.begin(), derivs.end(), 0.0);
946  if (!F[ptype]->evaluateDerivatives(dist[j], derivs))
947  continue;
948  RealType rinv(cone / dist[j]);
949  PosType dr(displ[j]);
950  if (ndim < 3)
951  dr[2] = 0;
952  for (int p = OffSet[ptype].first, ip = 0; p < OffSet[ptype].second; ++p, ++ip)
953  {
954  RealType dudr(rinv * derivs[ip][1]);
955  RealType lap(derivs[ip][2] + lapfac * dudr);
956  PosType gr(dudr * dr);
957  dLogPsi[p] -= derivs[ip][0];
958  gradLogPsi[p][i] += gr;
959  gradLogPsi[p][j] -= gr;
960  lapLogPsi[p][i] -= lap;
961  lapLogPsi[p][j] -= lap;
962  }
963  }
964  }
965  }
966  for (int k = 0; k < myVars.size(); ++k)
967  {
968  int kk = myVars.where(k);
969  if (kk < 0)
970  continue;
971  if (rcsingles[k])
972  {
973  dlogpsi[kk] = dLogPsi[k];
974  }
975  //optVars.setDeriv(p,dLogPsi[ip],-0.5*Sum(lapLogPsi[ip])-Dot(P.G,gradLogPsi[ip]));
976  }
977  }
978 }
constexpr std::complex< float > cone
Definition: BLAS.hpp:50
std::vector< std::pair< int, int > > OffSet
Map indices from subcomponent variables to component variables.
std::vector< ValueDerivVec > lapLogPsi
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::vector< FT * > F
Container for . treat every pointer as a reference.
QMCTraits::PosType PosType
const size_t ndim
number of spatial dimensions
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
const int my_table_ID_
e-e table ID
size_type size() const
return the size
Definition: VariableSet.h:88
const valT lapfac
laplacian prefactor
QMCTraits::RealType RealType
Vector< RealType > dLogPsi
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
std::vector< GradDerivVec > gradLogPsi

◆ evaluateDerivRatios()

void evaluateDerivRatios ( const VirtualParticleSet VP,
const opt_variables_type optvars,
std::vector< ValueType > &  ratios,
Matrix< ValueType > &  dratios 
)
override

precomputed recalculation switch

Definition at line 981 of file TwoBodyJastrow.cpp.

References DistanceTableAA::getDistRow(), ParticleSet::getDistTableAA(), ParticleSet::getDistTableAB(), VirtualParticleSet::getRefPS(), VirtualParticleSet::getTotalNum(), ParticleSet::GroupID, ParticleSet::groups(), qmcplusplus::n, VariableSet::recompute(), and VirtualParticleSet::refPtcl.

985 {
986  evaluateRatios(VP, ratios);
987  if (myVars.size() == 0)
988  return;
989 
990  bool recalculate(false);
991  std::vector<bool> rcsingles(myVars.size(), false);
992  for (int k = 0; k < myVars.size(); ++k)
993  {
994  int kk = myVars.where(k);
995  if (kk < 0)
996  continue;
997  if (optvars.recompute(kk))
998  recalculate = true;
999  rcsingles[k] = true;
1000  }
1001 
1002  if (recalculate)
1003  {
1004  ///precomputed recalculation switch
1005  std::vector<bool> RecalcSwitch(F.size(), false);
1006  for (int i = 0; i < F.size(); ++i)
1007  {
1008  if (OffSet[i].first < 0)
1009  {
1010  // nothing to optimize
1011  RecalcSwitch[i] = false;
1012  }
1013  else
1014  {
1015  bool recalcFunc(false);
1016  for (int rcs = OffSet[i].first; rcs < OffSet[i].second; rcs++)
1017  if (rcsingles[rcs] == true)
1018  recalcFunc = true;
1019  RecalcSwitch[i] = recalcFunc;
1020  }
1021  }
1022  const size_t NumVars = myVars.size();
1023  std::vector<RealType> derivs_ref(NumVars);
1024  std::vector<RealType> derivs(NumVars);
1025  const auto& d_table = VP.getDistTableAB(my_table_ID_);
1026  const size_t n = d_table.sources();
1027  const size_t nt = VP.getTotalNum();
1028  for (size_t i = 0; i < n; ++i)
1029  {
1030  if (i == VP.refPtcl)
1031  continue;
1032  const size_t ptype = VP.getRefPS().GroupID[i] * VP.getRefPS().groups() + VP.getRefPS().GroupID[VP.refPtcl];
1033  if (!RecalcSwitch[ptype])
1034  continue;
1035  const auto dist_ref = i < VP.refPtcl ? VP.getRefPS().getDistTableAA(my_table_ID_).getDistRow(VP.refPtcl)[i]
1036  : VP.getRefPS().getDistTableAA(my_table_ID_).getDistRow(i)[VP.refPtcl];
1037  //first calculate the old derivatives VP.refPtcl.
1038  std::fill(derivs_ref.begin(), derivs_ref.end(), 0.0);
1039  F[ptype]->evaluateDerivatives(dist_ref, derivs_ref);
1040  for (size_t j = 0; j < nt; ++j)
1041  {
1042  std::fill(derivs.begin(), derivs.end(), 0.0);
1043  F[ptype]->evaluateDerivatives(d_table.getDistRow(j)[i], derivs);
1044  for (int ip = 0, p = F[ptype]->myVars.Index.front(); ip < F[ptype]->myVars.Index.size(); ++ip, ++p)
1045  dratios[j][p] += derivs_ref[ip] - derivs[ip];
1046  }
1047  }
1048  }
1049 }
std::vector< std::pair< int, int > > OffSet
Map indices from subcomponent variables to component variables.
std::vector< int > Index
store locator of the named variable
Definition: VariableSet.h:65
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::vector< FT * > F
Container for . treat every pointer as a reference.
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
const int my_table_ID_
e-e table ID
size_type size() const
return the size
Definition: VariableSet.h:88
void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override

◆ evaluateGL()

WaveFunctionComponent::LogValue evaluateGL ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L,
bool  fromscratch = false 
)
overridevirtual

compute G and L after the sweep

Reimplemented from WaveFunctionComponent.

Definition at line 783 of file TwoBodyJastrow.cpp.

787 {
788  return log_value_ = computeGL(G, L);
789 }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data

◆ evaluateHessian()

void evaluateHessian ( ParticleSet P,
HessVector grad_grad_psi 
)
overridevirtual

Reimplemented from WaveFunctionComponent.

Definition at line 813 of file TwoBodyJastrow.cpp.

References Tensor< T, D >::diagonal(), ParticleSet::getDistTableAA(), ParticleSet::GroupID, qmcplusplus::Units::force::N, and qmcplusplus::outerProduct().

814 {
815  if (ndim < 3)
816  throw std::runtime_error("double check! See 2d jastrow test.");
817  log_value_ = 0.0;
818  const auto& d_ee(P.getDistTableAA(my_table_ID_));
819  valT dudr, d2udr2;
820 
821  Tensor<valT, DIM> ident;
822  grad_grad_psi = 0.0;
823  ident.diagonal(1.0);
824 
825  for (int i = 1; i < N; ++i)
826  {
827  const auto& dist = d_ee.getDistRow(i);
828  const auto& displ = d_ee.getDisplRow(i);
829  auto ig = P.GroupID[i];
830  const int igt = ig * NumGroups;
831  for (int j = 0; j < i; ++j)
832  {
833  auto r = dist[j];
834  auto rinv = 1.0 / r;
835  auto dr = displ[j];
836  auto jg = P.GroupID[j];
837  auto uij = F[igt + jg]->evaluate(r, dudr, d2udr2);
838  log_value_ -= uij;
839  auto hess = rinv * rinv * outerProduct(dr, dr) * (d2udr2 - dudr * rinv) + ident * dudr * rinv;
840  grad_grad_psi[i] -= hess;
841  grad_grad_psi[j] -= hess;
842  }
843  }
844 }
std::vector< FT * > F
Container for . treat every pointer as a reference.
const size_t ndim
number of spatial dimensions
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > outerProduct(const TinyVector< T1, D > &lhs, const TinyVector< T2, D > &rhs)
Definition: TinyVector.h:211
const int my_table_ID_
e-e table ID
typename FT::real_type valT
type of each component U, dU, d2U;
const size_t NumGroups
number of groups of the target particleset
const size_t N
number of particles

◆ evaluateLog()

TwoBodyJastrow< FT >::LogValue evaluateLog ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
)
overridevirtual

evaluate the value of the WaveFunctionComponent from scratch

Parameters
[in]Pactive ParticleSet
[out]GGradients, $\nabla\ln\Psi$
[out]LLaplacians, $\nabla^2\ln\Psi$
Returns
the log value

Mainly for walker-by-walker move. The initial stage of particle-by-particle move also uses this. causes complete state update in WFC's

Implements WaveFunctionComponent.

Definition at line 737 of file TwoBodyJastrow.cpp.

740 {
741  recompute(P);
742  return log_value_ = computeGL(G, L);
743 }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
void recompute(const ParticleSet &P) override
recompute internal data assuming distance table is fully ready

◆ evaluateRatios()

void evaluateRatios ( const VirtualParticleSet VP,
std::vector< ValueType > &  ratios 
)
override

Definition at line 169 of file TwoBodyJastrow.cpp.

References qmcplusplus::exp(), DistanceTableAB::getDistRow(), ParticleSet::getDistTableAB(), VirtualParticleSet::getRefPS(), and VirtualParticleSet::refPtcl.

170 {
171  for (int k = 0; k < ratios.size(); ++k)
172  ratios[k] =
173  std::exp(Uat[VP.refPtcl] - computeU(VP.getRefPS(), VP.refPtcl, VP.getDistTableAB(my_table_ID_).getDistRow(k)));
174 }
valT computeU(const ParticleSet &P, int iat, const DistRow &dist)
const int my_table_ID_
e-e table ID
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
Vector< valT, aligned_allocator< valT > > Uat

◆ evaluateRatiosAlltoOne()

void evaluateRatiosAlltoOne ( ParticleSet P,
std::vector< ValueType > &  ratios 
)
override

Definition at line 498 of file TwoBodyJastrow.cpp.

References qmcplusplus::exp(), ParticleSet::first(), ParticleSet::getDistTableAA(), DistanceTableAA::getTempDists(), and ParticleSet::last().

499 {
500  const auto& d_table = P.getDistTableAA(my_table_ID_);
501  const auto& dist = d_table.getTempDists();
502 
503  for (int ig = 0; ig < NumGroups; ++ig)
504  {
505  const int igt = ig * NumGroups;
506  valT sumU(0);
507  for (int jg = 0; jg < NumGroups; ++jg)
508  if (F[igt + jg])
509  {
510  const FuncType& f2(*F[igt + jg]);
511  int iStart = P.first(jg);
512  int iEnd = P.last(jg);
513  sumU += f2.evaluateV(-1, iStart, iEnd, dist.data(), DistCompressed.data());
514  }
515 
516  for (int i = P.first(ig); i < P.last(ig); ++i)
517  {
518  // remove self-interaction
519  const valT Uself = F[igt + ig]->evaluate(dist[i]);
520  ratios[i] = std::exp(Uat[i] + Uself - sumU);
521  }
522  }
523 }
aligned_vector< valT > DistCompressed
std::vector< FT * > F
Container for . treat every pointer as a reference.
const int my_table_ID_
e-e table ID
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
typename FT::real_type valT
type of each component U, dU, d2U;
const size_t NumGroups
number of groups of the target particleset
FT FuncType
alias FuncType
Vector< valT, aligned_allocator< valT > > Uat

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
overridevirtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented from WaveFunctionComponent.

Definition at line 123 of file TwoBodyJastrow.cpp.

References UniqueOptObjRefs::push_back().

Referenced by qmcplusplus::TEST_CASE().

124 {
125  for (auto& [key, functor] : J2Unique)
126  opt_obj_refs.push_back(*functor);
127 }
std::map< std::string, std::unique_ptr< FT > > J2Unique
Uniquue J2 set for cleanup.

◆ finalizeOptimization()

void finalizeOptimization ( )
inlineoverridevirtual

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 170 of file TwoBodyJastrow.h.

170 { return "TwoBodyJastrow"; }

◆ getComponentOffset()

std::pair<int, int> getComponentOffset ( int  index)
inline

Definition at line 253 of file TwoBodyJastrow.h.

References TwoBodyJastrow< FT >::OffSet.

Referenced by qmcplusplus::TEST_CASE().

253 { return OffSet.at(index); }
std::vector< std::pair< int, int > > OffSet
Map indices from subcomponent variables to component variables.

◆ getComponentVars()

opt_variables_type& getComponentVars ( )
inline

Definition at line 255 of file TwoBodyJastrow.h.

References WaveFunctionComponent::myVars.

255 { return myVars; }
opt_variables_type myVars
list of variables this WaveFunctionComponent handles

◆ getPairFunctions()

const std::vector<FT*>& getPairFunctions ( ) const
inline

Definition at line 250 of file TwoBodyJastrow.h.

References TwoBodyJastrow< FT >::F.

Referenced by qmcplusplus::TEST_CASE().

250 { return F; }
std::vector< FT * > F
Container for . treat every pointer as a reference.

◆ isOptimizable()

bool isOptimizable ( ) const
inlineoverridevirtual

if true, this contains optimizable components

Reimplemented from WaveFunctionComponent.

Definition at line 171 of file TwoBodyJastrow.h.

171 { return true; }

◆ KECorrection()

RealType KECorrection ( )
inlineoverridevirtual

Return the Chiesa kinetic energy correction.

Reimplemented from WaveFunctionComponent.

Definition at line 248 of file TwoBodyJastrow.h.

References TwoBodyJastrow< FT >::KEcorr.

248 { return KEcorr; }
RealType KEcorr
Correction.

◆ makeClone()

std::unique_ptr< WaveFunctionComponent > makeClone ( ParticleSet tqp) const
overridevirtual

make clone

Parameters
tqptarget Quantum ParticleSet
deepcopyif true, make a decopy

If not true, return a proxy class

Reimplemented from WaveFunctionComponent.

Definition at line 386 of file TwoBodyJastrow.cpp.

387 {
388  auto j2copy = std::make_unique<TwoBodyJastrow<FT>>(my_name_, tqp, use_offload_);
389  std::map<const FT*, FT*> fcmap;
390  for (int ig = 0; ig < NumGroups; ++ig)
391  for (int jg = ig; jg < NumGroups; ++jg)
392  {
393  int ij = ig * NumGroups + jg;
394  if (F[ij] == 0)
395  continue;
396  typename std::map<const FT*, FT*>::iterator fit = fcmap.find(F[ij]);
397  if (fit == fcmap.end())
398  {
399  auto fc = std::make_unique<FT>(*F[ij]);
400  fcmap[F[ij]] = fc.get();
401  j2copy->addFunc(ig, jg, std::move(fc));
402  }
403  }
404  j2copy->KEcorr = KEcorr;
405 
406  j2copy->myVars.clear();
407  j2copy->myVars.insertFrom(myVars);
408  j2copy->OffSet = OffSet;
409 
410  return j2copy;
411 }
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
std::vector< std::pair< int, int > > OffSet
Map indices from subcomponent variables to component variables.
const bool use_offload_
if true use offload
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::vector< FT * > F
Container for . treat every pointer as a reference.
const size_t NumGroups
number of groups of the target particleset
RealType KEcorr
Correction.

◆ mw_accept_rejectMove()

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
overridevirtual

moves of the iat-th particle on some walkers in a batch is accepted.

Update the current content. Note that all the lists only include accepted walkers.

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
safe_to_delayif true, delayed accept is safe.

Reimplemented from WaveFunctionComponent.

Definition at line 633 of file TwoBodyJastrow.cpp.

References RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), WaveFunctionComponent::log_value_, WaveFunctionComponent::mw_accept_rejectMove(), and TwoBodyJastrow< FT >::N.

638 {
639  if (!use_offload_)
640  {
641  WaveFunctionComponent::mw_accept_rejectMove(wfc_list, p_list, iat, isAccepted, safe_to_delay);
642  return;
643  }
644 
645  assert(this == &wfc_list.getLeader());
646  auto& wfc_leader = wfc_list.getCastedLeader<TwoBodyJastrow<FT>>();
647  auto& p_leader = p_list.getLeader();
648  const auto& dt_leader = p_leader.getDistTableAA(my_table_ID_);
649  const int nw = wfc_list.size();
650 
651  auto& mw_vgl = wfc_leader.mw_mem_handle_.getResource().mw_vgl;
652 
653  auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
654  auto& mw_cur_allu = wfc_leader.mw_mem_handle_.getResource().mw_cur_allu;
655 
656  for (int iw = 0; iw < nw; iw++)
657  {
658  auto& wfc = wfc_list.getCastedElement<TwoBodyJastrow<FT>>(iw);
659  wfc.log_value_ += wfc.Uat[iat] - mw_vgl[iw][0];
660  }
661 
662  // this call may go asynchronous, then need to wait at mw_calcRatio mw_ratioGrad and mw_completeUpdates
663  FT::mw_updateVGL(iat, isAccepted, NumGroups, F.data() + p_leader.GroupID[iat] * NumGroups, wfc_leader.N,
664  grp_ids.data(), nw, mw_vgl.data(), N_padded, dt_leader.getMultiWalkerTempDataPtr(), mw_allUat.data(),
665  mw_cur_allu.data(), wfc_leader.mw_mem_handle_.getResource().mw_update_buffer);
666 }
const bool use_offload_
if true use offload
std::vector< FT * > F
Container for . treat every pointer as a reference.
const int my_table_ID_
e-e table ID
const size_t N_padded
number of particles + padded
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.
Vector< int, OffloadPinnedAllocator< int > > grp_ids
the group_id of each particle
const size_t NumGroups
number of groups of the target particleset

◆ mw_calcRatio()

void mw_calcRatio ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios 
) const
override

Definition at line 460 of file TwoBodyJastrow.cpp.

References TwoBodyJastrow< FT >::cur_Uat, qmcplusplus::ewaldref::DIM, qmcplusplus::exp(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), WaveFunctionComponent::mw_calcRatio(), and TwoBodyJastrow< FT >::N.

464 {
465  if (!use_offload_)
466  {
467  WaveFunctionComponent::mw_calcRatio(wfc_list, p_list, iat, ratios);
468  return;
469  }
470 
471  //right now. Directly use FT::mw_evaluateVGL implementation.
472  assert(this == &wfc_list.getLeader());
473  auto& wfc_leader = wfc_list.getCastedLeader<TwoBodyJastrow<FT>>();
474  auto& p_leader = p_list.getLeader();
475  const auto& dt_leader = p_leader.getDistTableAA(my_table_ID_);
476  const int nw = wfc_list.size();
477 
478  auto& mw_vgl = wfc_leader.mw_mem_handle_.getResource().mw_vgl;
479  mw_vgl.resize(nw, DIM + 2);
480 
481  auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
482  auto& mw_cur_allu = wfc_leader.mw_mem_handle_.getResource().mw_cur_allu;
483 
484  FT::mw_evaluateVGL(iat, NumGroups, F.data() + p_leader.GroupID[iat] * NumGroups, wfc_leader.N, grp_ids.data(), nw,
485  mw_vgl.data(), N_padded, dt_leader.getMultiWalkerTempDataPtr(), mw_cur_allu.data(),
486  wfc_leader.mw_mem_handle_.getResource().mw_ratiograd_buffer);
487 
488  for (int iw = 0; iw < nw; iw++)
489  {
490  auto& wfc = wfc_list.getCastedElement<TwoBodyJastrow<FT>>(iw);
491  wfc.cur_Uat = mw_vgl[iw][0];
492  ratios[iw] = std::exp(static_cast<PsiValue>(wfc.Uat[iat] - wfc.cur_Uat));
493  }
494 }
const bool use_offload_
if true use offload
std::vector< FT * > F
Container for . treat every pointer as a reference.
const int my_table_ID_
e-e table ID
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
const size_t N_padded
number of particles + padded
Vector< int, OffloadPinnedAllocator< int > > grp_ids
the group_id of each particle
const size_t NumGroups
number of groups of the target particleset
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 ...

◆ mw_evaluateGL()

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
overridevirtual

evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
G_listthe list of Gradients pointers in a walker batch, $\nabla\ln\Psi$
L_listthe list of Laplacians pointers in a walker batch, $\nabla^2\ln\Psi$
fromscratchif true and this WFC is sensitive to numerical error accumulation, all the internal data are recomputed from scratch.

Reimplemented from WaveFunctionComponent.

Definition at line 792 of file TwoBodyJastrow.cpp.

References RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getLeader(), WaveFunctionComponent::log_value_, and WaveFunctionComponent::mw_evaluateGL().

797 {
798  if (!use_offload_)
799  {
800  WaveFunctionComponent::mw_evaluateGL(wfc_list, p_list, G_list, L_list, fromscratch);
801  return;
802  }
803 
804  assert(this == &wfc_list.getLeader());
805  for (int iw = 0; iw < wfc_list.size(); iw++)
806  {
807  auto& wfc = wfc_list.getCastedElement<TwoBodyJastrow<FT>>(iw);
808  wfc.log_value_ = wfc.computeGL(G_list[iw], L_list[iw]);
809  }
810 }
const bool use_offload_
if true use offload
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 ...

◆ mw_evaluateLog()

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
overridevirtual

evaluate from scratch the same type WaveFunctionComponent of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
G_listthe list of Gradients pointers in a walker batch, $\nabla\ln\Psi$
L_listthe list of Laplacians pointers in a walker batch, $\nabla^2\ln\Psi$
valuesthe log WF values of walkers in a batch

Reimplemented from WaveFunctionComponent.

Definition at line 746 of file TwoBodyJastrow.cpp.

References RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getLeader(), WaveFunctionComponent::log_value_, and WaveFunctionComponent::mw_evaluateLog().

751 {
752  if (!use_offload_)
753  {
754  WaveFunctionComponent::mw_evaluateLog(wfc_list, p_list, G_list, L_list);
755  return;
756  }
757 
758  assert(this == &wfc_list.getLeader());
759  const std::vector<bool> recompute_all(wfc_list.size(), true);
760  mw_recompute(wfc_list, p_list, recompute_all);
761 
762  for (int iw = 0; iw < wfc_list.size(); iw++)
763  {
764  auto& wfc = wfc_list.getCastedElement<TwoBodyJastrow<FT>>(iw);
765  wfc.log_value_ = wfc.computeGL(G_list[iw], L_list[iw]);
766  }
767 }
const bool use_offload_
if true use offload
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
void mw_recompute(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const override

◆ mw_evaluateRatios()

void mw_evaluateRatios ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< const VirtualParticleSet > &  vp_list,
std::vector< std::vector< ValueType >> &  ratios 
) const
override

Definition at line 177 of file TwoBodyJastrow.cpp.

References qmcplusplus::exp(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), VirtualParticleSet::getTotalNum(), WaveFunctionComponent::mw_evaluateRatios(), and TwoBodyJastrow< FT >::mw_mem_handle_.

180 {
181  if (!use_offload_)
182  {
183  WaveFunctionComponent::mw_evaluateRatios(wfc_list, vp_list, ratios);
184  return;
185  }
186 
187  // add early return to prevent from accessing vp_list[0]
188  if (wfc_list.size() == 0)
189  return;
190  auto& wfc_leader = wfc_list.getCastedLeader<TwoBodyJastrow<FT>>();
191  auto& vp_leader = vp_list.getLeader();
192  const auto& mw_refPctls = vp_leader.getMultiWalkerRefPctls();
193  auto& mw_vals = wfc_leader.mw_mem_handle_.getResource().mw_vals;
194  const int nw = wfc_list.size();
195 
196  const size_t nVPs = mw_refPctls.size();
197  mw_vals.resize(nVPs);
198 
199  // need to access the spin group of refPtcl. vp_leader doesn't necessary be a member of the list.
200  // for this reason, refPtcl must be access from [0].
201  const int igt = vp_leader.getRefPS().getGroupID(vp_list[0].refPtcl);
202  const auto& dt_leader(vp_leader.getDistTableAB(wfc_leader.my_table_ID_));
203 
204  FT::mw_evaluateV(NumGroups, F.data() + igt * NumGroups, wfc_leader.N, grp_ids.data(), nVPs, mw_refPctls.data(),
205  dt_leader.getMultiWalkerDataPtr(), dt_leader.getPerTargetPctlStrideSize(), mw_vals.data(),
206  wfc_leader.mw_mem_handle_.getResource().transfer_buffer);
207 
208  size_t ivp = 0;
209  for (int iw = 0; iw < nw; ++iw)
210  {
211  const VirtualParticleSet& vp = vp_list[iw];
212  const auto& wfc = wfc_list.getCastedElement<TwoBodyJastrow<FT>>(iw);
213  for (int k = 0; k < vp.getTotalNum(); ++k, ivp++)
214  ratios[iw][k] = std::exp(wfc.Uat[mw_refPctls[ivp]] - mw_vals[ivp]);
215  }
216  assert(ivp == nVPs);
217 }
const bool use_offload_
if true use offload
std::vector< FT * > F
Container for . treat every pointer as a reference.
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
Vector< int, OffloadPinnedAllocator< int > > grp_ids
the group_id of each particle
const size_t NumGroups
number of groups of the target particleset
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

◆ mw_ratioGrad()

void mw_ratioGrad ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios,
std::vector< GradType > &  grad_new 
) const
override

Definition at line 544 of file TwoBodyJastrow.cpp.

References TwoBodyJastrow< FT >::cur_Uat, qmcplusplus::ewaldref::DIM, qmcplusplus::exp(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), WaveFunctionComponent::mw_ratioGrad(), and TwoBodyJastrow< FT >::N.

549 {
550  if (!use_offload_)
551  {
552  WaveFunctionComponent::mw_ratioGrad(wfc_list, p_list, iat, ratios, grad_new);
553  return;
554  }
555 
556  assert(this == &wfc_list.getLeader());
557  auto& wfc_leader = wfc_list.getCastedLeader<TwoBodyJastrow<FT>>();
558  auto& p_leader = p_list.getLeader();
559  const auto& dt_leader = p_leader.getDistTableAA(my_table_ID_);
560  const int nw = wfc_list.size();
561 
562  auto& mw_vgl = wfc_leader.mw_mem_handle_.getResource().mw_vgl;
563  mw_vgl.resize(nw, DIM + 2);
564 
565  auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
566  auto& mw_cur_allu = wfc_leader.mw_mem_handle_.getResource().mw_cur_allu;
567 
568  FT::mw_evaluateVGL(iat, NumGroups, F.data() + p_leader.GroupID[iat] * NumGroups, wfc_leader.N, grp_ids.data(), nw,
569  mw_vgl.data(), N_padded, dt_leader.getMultiWalkerTempDataPtr(), mw_cur_allu.data(),
570  wfc_leader.mw_mem_handle_.getResource().mw_ratiograd_buffer);
571 
572  for (int iw = 0; iw < nw; iw++)
573  {
574  auto& wfc = wfc_list.getCastedElement<TwoBodyJastrow<FT>>(iw);
575  wfc.cur_Uat = mw_vgl[iw][0];
576  ratios[iw] = std::exp(static_cast<PsiValue>(wfc.Uat[iat] - wfc.cur_Uat));
577  for (int idim = 0; idim < ndim; idim++)
578  grad_new[iw][idim] += mw_vgl[iw][idim + 1];
579  }
580 }
const bool use_offload_
if true use offload
std::vector< FT * > F
Container for . treat every pointer as a reference.
const size_t ndim
number of spatial dimensions
const int my_table_ID_
e-e table ID
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
const size_t N_padded
number of particles + padded
Vector< int, OffloadPinnedAllocator< int > > grp_ids
the group_id of each particle
void mw_ratioGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const
const size_t NumGroups
number of groups of the target particleset

◆ mw_recompute()

void mw_recompute ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const std::vector< bool > &  recompute 
) const
overridevirtual

Reimplemented from WaveFunctionComponent.

Definition at line 718 of file TwoBodyJastrow.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), and WaveFunctionComponent::mw_recompute().

721 {
722  if (!use_offload_)
723  {
725  return;
726  }
727 
728  auto& wfc_leader = wfc_list.getCastedLeader<TwoBodyJastrow<FT>>();
729  assert(this == &wfc_leader);
730  for (int iw = 0; iw < wfc_list.size(); iw++)
731  if (recompute[iw])
732  wfc_list[iw].recompute(p_list[iw]);
733  wfc_leader.mw_mem_handle_.getResource().mw_allUat.updateTo();
734 }
virtual void mw_recompute(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
const bool use_offload_
if true use offload
void recompute(const ParticleSet &P) override
recompute internal data assuming distance table is fully ready

◆ ratio()

TwoBodyJastrow< FT >::PsiValue ratio ( ParticleSet P,
int  iat 
)
overridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value

Parameters
Pthe active ParticleSet
iatthe index of a particle
Returns
$ \psi( \{ {\bf R}^{'} \} )/ \psi( \{ {\bf R}\})$

Specialized for particle-by-particle move

Implements WaveFunctionComponent.

Definition at line 451 of file TwoBodyJastrow.cpp.

References qmcplusplus::exp(), ParticleSet::getDistTableAA(), and DistanceTableAA::getTempDists().

452 {
453  //only ratio, ready to compute it again
455  cur_Uat = computeU(P, iat, P.getDistTableAA(my_table_ID_).getTempDists());
456  return std::exp(static_cast<PsiValue>(Uat[iat] - cur_Uat));
457 }
valT computeU(const ParticleSet &P, int iat, const DistRow &dist)
const int my_table_ID_
e-e table ID
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
Vector< valT, aligned_allocator< valT > > Uat

◆ ratioGrad()

TwoBodyJastrow< FT >::PsiValue ratioGrad ( ParticleSet P,
int  iat,
GradType grad_iat 
)
overridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient

Parameters
Pthe active ParticleSet
iatthe index of a particle
grad_iatGradient for the active particle

Reimplemented from WaveFunctionComponent.

Definition at line 532 of file TwoBodyJastrow.cpp.

References qmcplusplus::simd::accumulate_n(), Vector< T, Alloc >::data(), qmcplusplus::exp(), ParticleSet::getDistTableAA(), DistanceTableAA::getTempDispls(), DistanceTableAA::getTempDists(), and qmcplusplus::Units::force::N.

533 {
535 
536  computeU3(P, iat, P.getDistTableAA(my_table_ID_).getTempDists(), cur_u.data(), cur_du.data(), cur_d2u.data());
537  cur_Uat = simd::accumulate_n(cur_u.data(), N, valT());
538  DiffVal = Uat[iat] - cur_Uat;
539  grad_iat += accumulateG(cur_du.data(), P.getDistTableAA(my_table_ID_).getTempDispls());
540  return std::exp(static_cast<PsiValue>(DiffVal));
541 }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
aligned_vector< valT > cur_u
posT accumulateG(const valT *restrict du, const DisplRow &displ) const
compute gradient
aligned_vector< valT > cur_du
aligned_vector< valT > cur_d2u
const int my_table_ID_
e-e table ID
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
typename FT::real_type valT
type of each component U, dU, d2U;
void computeU3(const ParticleSet &P, int iat, const DistRow &dist, RealType *restrict u, RealType *restrict du, RealType *restrict d2u, bool triangle=false)
intenal function to compute
RealType DiffVal
diff value
const size_t N
number of particles
Vector< valT, aligned_allocator< valT > > Uat

◆ recompute()

void recompute ( const ParticleSet P)
overridevirtual

recompute internal data assuming distance table is fully ready

Reimplemented from WaveFunctionComponent.

Definition at line 669 of file TwoBodyJastrow.cpp.

References qmcplusplus::simd::accumulate_n(), ParticleSet::first(), ParticleSet::getDistTableAA(), ParticleSet::last(), and qmcplusplus::Units::time::s.

670 {
671  const auto& d_table = P.getDistTableAA(my_table_ID_);
672  for (int ig = 0; ig < NumGroups; ++ig)
673  {
674  for (int iat = P.first(ig), last = P.last(ig); iat < last; ++iat)
675  {
676  computeU3(P, iat, d_table.getDistRow(iat), cur_u.data(), cur_du.data(), cur_d2u.data(), true);
677  Uat[iat] = simd::accumulate_n(cur_u.data(), iat, valT());
678  posT grad;
679  valT lap(0);
680  const valT* restrict u = cur_u.data();
681  const valT* restrict du = cur_du.data();
682  const valT* restrict d2u = cur_d2u.data();
683  const auto& displ = d_table.getDisplRow(iat);
684 #pragma omp simd reduction(+ : lap) aligned(du, d2u : QMC_SIMD_ALIGNMENT)
685  for (int jat = 0; jat < iat; ++jat)
686  lap += d2u[jat] + lapfac * du[jat];
687  for (int idim = 0; idim < ndim; ++idim)
688  {
689  const valT* restrict dX = displ.data(idim);
690  valT s = valT();
691 #pragma omp simd reduction(+ : s) aligned(du, dX : QMC_SIMD_ALIGNMENT)
692  for (int jat = 0; jat < iat; ++jat)
693  s += du[jat] * dX[jat];
694  grad[idim] = s;
695  }
696  dUat(iat) = grad;
697  d2Uat[iat] = -lap;
698 // add the contribution from the upper triangle
699 #pragma omp simd aligned(u, du, d2u : QMC_SIMD_ALIGNMENT)
700  for (int jat = 0; jat < iat; jat++)
701  {
702  Uat[jat] += u[jat];
703  d2Uat[jat] -= d2u[jat] + lapfac * du[jat];
704  }
705  for (int idim = 0; idim < ndim; ++idim)
706  {
707  valT* restrict save_g = dUat.data(idim);
708  const valT* restrict dX = displ.data(idim);
709 #pragma omp simd aligned(save_g, du, dX : QMC_SIMD_ALIGNMENT)
710  for (int jat = 0; jat < iat; jat++)
711  save_g[jat] -= du[jat] * dX[jat];
712  }
713  }
714  }
715 }
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
Definition: algorithm.hpp:26
Vector< valT, aligned_allocator< valT > > d2Uat
aligned_vector< valT > cur_u
const size_t ndim
number of spatial dimensions
aligned_vector< valT > cur_du
aligned_vector< valT > cur_d2u
const int my_table_ID_
e-e table ID
typename FT::real_type valT
type of each component U, dU, d2U;
void computeU3(const ParticleSet &P, int iat, const DistRow &dist, RealType *restrict u, RealType *restrict du, RealType *restrict d2u, bool triangle=false)
intenal function to compute
const valT lapfac
laplacian prefactor
const size_t NumGroups
number of groups of the target particleset
VectorSoaContainer< valT, DIM, aligned_allocator< valT > > dUat
TinyVector< valT, DIM > posT
element position type
Vector< valT, aligned_allocator< valT > > Uat

◆ registerData()

void registerData ( ParticleSet P,
WFBufferType buf 
)
overridevirtual

For particle-by-particle move.

Requests space in the buffer based on the data type sizes of the objects in this class.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 220 of file TwoBodyJastrow.cpp.

References PooledMemory< T_scalar, Alloc >::add(), PooledMemory< T_scalar, Alloc >::current(), and PooledMemory< T_scalar, Alloc >::forward().

221 {
222  if (Bytes_in_WFBuffer == 0)
223  {
224  Bytes_in_WFBuffer = buf.current();
225  buf.add(Uat.begin(), Uat.end());
226  buf.add(dUat.data(), dUat.end());
227  buf.add(d2Uat.begin(), d2Uat.end());
228  Bytes_in_WFBuffer = buf.current() - Bytes_in_WFBuffer;
229  // free local space
230  Uat.free();
231  dUat.free();
232  d2Uat.free();
233  }
234  else
235  {
236  buf.forward(Bytes_in_WFBuffer);
237  }
238 }
Vector< valT, aligned_allocator< valT > > d2Uat
VectorSoaContainer< valT, DIM, aligned_allocator< valT > > dUat
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.
Vector< valT, aligned_allocator< valT > > Uat

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
overridevirtual

return a shared resource to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 91 of file TwoBodyJastrow.cpp.

References qmcplusplus::ewaldref::DIM, VectorSoaContainer< T, D, Alloc >::free(), Vector< T, Alloc >::free(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), qmcplusplus::Units::force::N, and ResourceCollection::takebackResource().

93 {
94  auto& wfc_leader = wfc_list.getCastedLeader<TwoBodyJastrow<FT>>();
95  const size_t nw = wfc_list.size();
96  auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
97  for (size_t iw = 0; iw < nw; iw++)
98  {
99  // detach buffer and copy per walker Uat, dUat, d2Uat from shared buffer
100  auto& wfc = wfc_list.getCastedElement<TwoBodyJastrow<FT>>(iw);
101 
102  Vector<valT, aligned_allocator<valT>> Uat_view(mw_allUat.data() + iw * N_padded, N);
103  wfc.Uat.free();
104  wfc.Uat.resize(N);
105  wfc.Uat = Uat_view;
106 
107  VectorSoaContainer<valT, DIM, aligned_allocator<valT>> dUat_view(mw_allUat.data() + nw * N_padded +
108  iw * N_padded * DIM,
109  N, N_padded);
110  wfc.dUat.free();
111  wfc.dUat.resize(N);
112  wfc.dUat = dUat_view;
113 
114  Vector<valT, aligned_allocator<valT>> d2Uat_view(mw_allUat.data() + nw * N_padded * (DIM + 1) + iw * N_padded, N);
115  wfc.d2Uat.free();
116  wfc.d2Uat.resize(N);
117  wfc.d2Uat = d2Uat_view;
118  }
119  collection.takebackResource(wfc_leader.mw_mem_handle_);
120 }
const size_t N_padded
number of particles + padded
const size_t N
number of particles

◆ resizeInternalStorage()

void resizeInternalStorage ( )
private

initialize storage Uat,dUat, d2Uat

Definition at line 335 of file TwoBodyJastrow.cpp.

References qmcplusplus::Units::force::N.

Referenced by TwoBodyJastrow< FT >::TwoBodyJastrow().

336 {
337  Uat.resize(N);
338  dUat.resize(N);
339  d2Uat.resize(N);
340  // resize scratch compute
341  cur_u.resize(N);
342  cur_du.resize(N);
343  cur_d2u.resize(N);
344  old_u.resize(N);
345  old_du.resize(N);
346  old_d2u.resize(N);
347  DistCompressed.resize(N);
348  DistIndice.resize(N);
349 }
Vector< valT, aligned_allocator< valT > > d2Uat
aligned_vector< valT > DistCompressed
aligned_vector< valT > cur_u
aligned_vector< valT > cur_du
aligned_vector< valT > old_du
aligned_vector< valT > cur_d2u
aligned_vector< int > DistIndice
aligned_vector< valT > old_u
VectorSoaContainer< valT, DIM, aligned_allocator< valT > > dUat
const size_t N
number of particles
aligned_vector< valT > old_d2u
Vector< valT, aligned_allocator< valT > > Uat

◆ resizeWFOptVectors()

void resizeWFOptVectors ( )
inlineprivate

Definition at line 126 of file TwoBodyJastrow.h.

References TwoBodyJastrow< FT >::dLogPsi, TwoBodyJastrow< FT >::gradLogPsi, TwoBodyJastrow< FT >::lapLogPsi, WaveFunctionComponent::myVars, TwoBodyJastrow< FT >::N, Vector< T, Alloc >::resize(), and VariableSet::size().

127  {
129  gradLogPsi.resize(myVars.size(), GradDerivVec(N));
130  lapLogPsi.resize(myVars.size(), ValueDerivVec(N));
131  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::vector< ValueDerivVec > lapLogPsi
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
ParticleAttrib< QTFull::GradType > GradDerivVec
size_type size() const
return the size
Definition: VariableSet.h:88
Vector< RealType > dLogPsi
std::vector< GradDerivVec > gradLogPsi
ParticleAttrib< QTFull::ValueType > ValueDerivVec
const size_t N
number of particles

◆ restore()

void restore ( int  iat)
inlineoverridevirtual

If a move for iat-th particle is rejected, restore to the content.

Parameters
iatindex of the particle whose new position was proposed

Ye: hopefully we can gradually move away from restore

Implements WaveFunctionComponent.

Definition at line 226 of file TwoBodyJastrow.h.

226 {}

◆ updateBuffer()

TwoBodyJastrow< FT >::LogValue updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)
overridevirtual

For particle-by-particle move.

Put the objects of this class in the walker buffer or forward the memory cursor.

Parameters
Pparticle set
bufAnonymous storage
fromscratchrequest recomputing the precision critical pieces of wavefunction from scratch
Returns
log value of the wavefunction.

Implements WaveFunctionComponent.

Definition at line 249 of file TwoBodyJastrow.cpp.

References PooledMemory< T_scalar, Alloc >::forward(), ParticleSet::G, and ParticleSet::L.

252 {
253  log_value_ = computeGL(P.G, P.L);
254  buf.forward(Bytes_in_WFBuffer);
255  return log_value_;
256 }
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

Member Data Documentation

◆ cur_d2u

aligned_vector<valT> cur_d2u
private

Definition at line 104 of file TwoBodyJastrow.h.

◆ cur_du

aligned_vector<valT> cur_du
private

Definition at line 104 of file TwoBodyJastrow.h.

◆ cur_u

aligned_vector<valT> cur_u
private

Definition at line 104 of file TwoBodyJastrow.h.

◆ cur_Uat

valT cur_Uat
private

◆ d2Uat

Vector<valT, aligned_allocator<valT> > d2Uat
private

$d2Uat[i] = sum_(j) d2u_{i,j}$

Definition at line 102 of file TwoBodyJastrow.h.

◆ DiffVal

RealType DiffVal
private

diff value

Definition at line 94 of file TwoBodyJastrow.h.

◆ DistCompressed

aligned_vector<valT> DistCompressed
private

Definition at line 106 of file TwoBodyJastrow.h.

◆ DistIndice

aligned_vector<int> DistIndice
private

Definition at line 107 of file TwoBodyJastrow.h.

◆ dLogPsi

Vector<RealType> dLogPsi
private

Definition at line 119 of file TwoBodyJastrow.h.

Referenced by TwoBodyJastrow< FT >::resizeWFOptVectors().

◆ dUat

$dUat[i] = sum_(j) du_{i,j}$

Definition at line 100 of file TwoBodyJastrow.h.

◆ F

std::vector<FT*> F
private

Container for $F[ig*NumGroups+jg]$. treat every pointer as a reference.

Definition at line 111 of file TwoBodyJastrow.h.

Referenced by TwoBodyJastrow< FT >::getPairFunctions(), and TwoBodyJastrow< FT >::TwoBodyJastrow().

◆ gradLogPsi

std::vector<GradDerivVec> gradLogPsi
private

Definition at line 121 of file TwoBodyJastrow.h.

Referenced by TwoBodyJastrow< FT >::resizeWFOptVectors().

◆ grp_ids

Vector<int, OffloadPinnedAllocator<int> > grp_ids
private

the group_id of each particle

Definition at line 92 of file TwoBodyJastrow.h.

Referenced by TwoBodyJastrow< FT >::TwoBodyJastrow().

◆ j2_ke_corr_helper

J2KECorrection<RealType, FT> j2_ke_corr_helper
private

◆ J2Unique

std::map<std::string, std::unique_ptr<FT> > J2Unique
private

Uniquue J2 set for cleanup.

Definition at line 109 of file TwoBodyJastrow.h.

◆ KEcorr

◆ lapfac

const valT lapfac
protected

laplacian prefactor

Definition at line 80 of file TwoBodyJastrow.h.

◆ lapLogPsi

std::vector<ValueDerivVec> lapLogPsi
private

Definition at line 122 of file TwoBodyJastrow.h.

Referenced by TwoBodyJastrow< FT >::resizeWFOptVectors().

◆ mw_mem_handle_

◆ my_table_ID_

const int my_table_ID_
private

e-e table ID

Definition at line 113 of file TwoBodyJastrow.h.

◆ N

◆ N_padded

const size_t N_padded
private

number of particles + padded

Definition at line 90 of file TwoBodyJastrow.h.

◆ ndim

const size_t ndim
protected

number of spatial dimensions

Definition at line 78 of file TwoBodyJastrow.h.

◆ NumGroups

const size_t NumGroups
protected

number of groups of the target particleset

Definition at line 76 of file TwoBodyJastrow.h.

Referenced by TwoBodyJastrow< FT >::TwoBodyJastrow().

◆ OffSet

std::vector<std::pair<int, int> > OffSet
private

Map indices from subcomponent variables to component variables.

Definition at line 118 of file TwoBodyJastrow.h.

Referenced by TwoBodyJastrow< FT >::getComponentOffset().

◆ old_d2u

aligned_vector<valT> old_d2u
private

Definition at line 105 of file TwoBodyJastrow.h.

◆ old_du

aligned_vector<valT> old_du
private

Definition at line 105 of file TwoBodyJastrow.h.

◆ old_u

aligned_vector<valT> old_u
private

Definition at line 105 of file TwoBodyJastrow.h.

◆ Uat

Vector<valT, aligned_allocator<valT> > Uat
private

$Uat[i] = sum_(j) u_{i,j}$

Definition at line 98 of file TwoBodyJastrow.h.

◆ use_offload_

const bool use_offload_
private

if true use offload

Definition at line 84 of file TwoBodyJastrow.h.

◆ qmcplusplus::WaveFunctionComponent

class qmcplusplus::WaveFunctionComponent

An abstract class for a component of a many-body trial wave function.

mw_ prefix is a function name signature indicating it is for handling a batch of WaveFunctionComponent objects which are required to be base class pointers of the same derived class type. all the mw_ routines must be implemented in a way either stateless or maintains states of every walker.

Definition at line 59 of file WaveFunctionComponent.h.

+ Inheritance diagram for WaveFunctionComponent:
+ Collaboration diagram for WaveFunctionComponent:

Public Types

enum  {
  ORB_PBYP_RATIO, ORB_PBYP_ALL, ORB_PBYP_PARTIAL, ORB_WALKER,
  ORB_ALLWALKER
}
 enum for a update mode More...
 
using Walker_t = ParticleSet::Walker_t
 
using WFBufferType = Walker_t::WFBuffer_t
 
using BufferType = Walker_t::Buffer_t
 
using RealMatrix_t = OrbitalSetTraits< RealType >::ValueMatrix
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using LogValue = std::complex< QTFull::RealType >
 
using PsiValue = QTFull::ValueType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
virtual void checkSanity () const
 Validate the internal consistency of the object. More...
 
const std::string & getName () const
 return object name More...
 
virtual std::string getClassName () const =0
 return class name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual bool isFermionic () const
 true, if this component is fermionic More...
 
virtual bool isMultiDet () const
 true, if this component is multi-determinant More...
 
virtual void checkOutVariables (const opt_variables_type &active)
 check out variational optimizable variables More...
 
virtual void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
virtual LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)=0
 evaluate the value of the WaveFunctionComponent from scratch More...
 
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 More...
 
virtual void recompute (const ParticleSet &P)
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
virtual void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 
virtual void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi_all)
 
virtual void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
virtual GradType evalGrad (ParticleSet &P, int iat)
 return the current gradient for the iat-th particle More...
 
virtual GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad)
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat)
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
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. More...
 
virtual PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat)
 evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient More...
 
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 implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
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 void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
virtual void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false)=0
 a move for iat-th particle is accepted. More...
 
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. More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
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 p-by-p move region. More...
 
virtual void restore (int iat)=0
 If a move for iat-th particle is rejected, restore to the content. More...
 
virtual PsiValue ratio (ParticleSet &P, int iat)=0
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
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 More...
 
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. More...
 
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 More...
 
virtual void registerData (ParticleSet &P, WFBufferType &buf)=0
 For particle-by-particle move. More...
 
virtual LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false)=0
 For particle-by-particle move. More...
 
virtual void copyFromBuffer (ParticleSet &P, WFBufferType &buf)=0
 For particle-by-particle move. More...
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 acquire a shared resource from a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 return a shared resource to a collection More...
 
virtual std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const
 make clone More...
 
virtual RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
virtual bool isOptimizable () const
 if true, this contains optimizable components More...
 
virtual void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs)
 extract underlying OptimizableObject references More...
 
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 optimizable parameters. More...
 
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. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void finalizeOptimization ()
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
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 More...
 
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 More...
 
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 More...
 
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 multiple walkers More...
 

Public Attributes

int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 

Protected Attributes

const std::string my_name_
 Name of the object It is required to be different for objects of the same derived type like multiple J1. More...
 
LogValue log_value_
 Current $\log\phi $. More...
 

Member Typedef Documentation

◆ BufferType

Definition at line 74 of file WaveFunctionComponent.h.

◆ GradMatrix

◆ HessType

Definition at line 79 of file WaveFunctionComponent.h.

◆ HessVector

◆ LogValue

using LogValue = std::complex<QTFull::RealType>

Definition at line 83 of file WaveFunctionComponent.h.

◆ PsiValue

Definition at line 85 of file WaveFunctionComponent.h.

◆ RealMatrix_t

◆ ValueMatrix

◆ ValueVector

◆ Walker_t

Definition at line 72 of file WaveFunctionComponent.h.

◆ WFBufferType

Definition at line 73 of file WaveFunctionComponent.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

enum for a update mode

Enumerator
ORB_PBYP_RATIO 

particle-by-particle ratio only

ORB_PBYP_ALL 

particle-by-particle, update Value-Gradient-Laplacian

ORB_PBYP_PARTIAL 

particle-by-particle, update Value and Grdient

ORB_WALKER 

walker update

ORB_ALLWALKER 

all walkers update

Definition at line 63 of file WaveFunctionComponent.h.

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  };

Constructor & Destructor Documentation

◆ WaveFunctionComponent()

WaveFunctionComponent ( const std::string &  obj_name = "")

default constructor

Definition at line 25 of file WaveFunctionComponent.cpp.

27 {}
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

◆ ~WaveFunctionComponent()

~WaveFunctionComponent ( )
virtualdefault

default destructor

Member Function Documentation

◆ acceptMove()

virtual void acceptMove ( ParticleSet P,
int  iat,
bool  safe_to_delay = false 
)
pure virtual

◆ acquireResource()

virtual void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
inlinevirtual

acquire a shared resource from a collection

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, J1OrbitalSoA< FT >, DiracDeterminant< DU_TYPE >, MultiSlaterDetTableMethod, TwoBodyJastrow< FT >, and SlaterDet.

Definition at line 430 of file WaveFunctionComponent.h.

432  {}

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
virtual

check out variational optimizable variables

Parameters
activea super set of optimizable variables

Reimplemented in J1OrbitalSoA< FT >, J1Spin< FT >, JeeIOrbitalSoA< FT >, TwoBodyJastrow< FT >, kSpaceJastrow, MultiDiracDeterminant, CountingJastrow< RegionType >, MultiSlaterDetTableMethod, DiracDeterminantBase, RPAJastrow, SlaterDet, SlaterDetWithBackflow, and ExampleHeComponent.

Definition at line 205 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::getClassName(), and WaveFunctionComponent::isOptimizable().

Referenced by RPAJastrow::checkOutVariables(), and qmcplusplus::test_J3_polynomial3D().

206 {
207  if (isOptimizable())
208  throw std::logic_error("Bug!! " + getClassName() +
209  "::checkOutVariables "
210  "must be overloaded when the WFC is optimizable.");
211 }
virtual bool isOptimizable() const
if true, this contains optimizable components
virtual std::string getClassName() const =0
return class name

◆ checkSanity()

virtual void checkSanity ( ) const
inlinevirtual

Validate the internal consistency of the object.

Reimplemented in J1OrbitalSoA< FT >, and TwoBodyJastrow< FT >.

Definition at line 117 of file WaveFunctionComponent.h.

117 {}

◆ completeUpdates()

virtual void completeUpdates ( )
inlinevirtual

complete all the delayed or asynchronous operations before leaving the p-by-p move region.

Must be called at the end of each substep if p-by-p move is used. This function was initially introduced for determinant delayed updates to complete all the delayed operations. It has been extended to handle asynchronous operations on accellerators before leaving the p-by-p move region.

Reimplemented in SlaterDet, DiracDeterminantBatched< PL, VT, FPVT >, and DiracDeterminant< DU_TYPE >.

Definition at line 338 of file WaveFunctionComponent.h.

Referenced by WaveFunctionComponent::mw_completeUpdates().

338 {}

◆ copyFromBuffer()

virtual void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)
pure virtual

For particle-by-particle move.

Copy data or attach memory from a walker buffer to the objects of this class. The log value, P.G and P.L contribution from the objects of this class are also added.

Parameters
Pparticle set
bufAnonymous storage

Implemented in JeeIOrbitalSoA< FT >, J1OrbitalSoA< FT >, J1Spin< FT >, CountingJastrow< RegionType >, TwoBodyJastrow< FT >, MultiDiracDeterminant, kSpaceJastrow, MultiSlaterDetTableMethod, DiracDeterminantBatched< PL, VT, FPVT >, SlaterDet, DiracDeterminant< DU_TYPE >, RPAJastrow, DiracDeterminantWithBackflow, DummyDiracDetWithoutMW, LinearOrbital, ExampleHeComponent, LatticeGaussianProduct, SlaterDetWithBackflow, AGPDeterminant, and ConstantOrbital.

◆ createResource()

virtual void createResource ( ResourceCollection collection) const
inlinevirtual

initialize a shared resource and hand it to a collection

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, J1OrbitalSoA< FT >, MultiDiracDeterminant, DiracDeterminant< DU_TYPE >, MultiSlaterDetTableMethod, TwoBodyJastrow< FT >, and SlaterDet.

Definition at line 426 of file WaveFunctionComponent.h.

Referenced by qmcplusplus::test_J3_polynomial3D().

426 {}

◆ evalGrad()

virtual GradType evalGrad ( ParticleSet P,
int  iat 
)
inlinevirtual

return the current gradient for the iat-th particle

Parameters
Pquantum particle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented in JeeIOrbitalSoA< FT >, J1OrbitalSoA< FT >, J1Spin< FT >, CountingJastrow< RegionType >, MultiDiracDeterminant, TwoBodyJastrow< FT >, DiracDeterminantBatched< PL, VT, FPVT >, kSpaceJastrow, SlaterDet, MultiSlaterDetTableMethod, DiracDeterminant< DU_TYPE >, DiracDeterminantWithBackflow, SlaterDetWithBackflow, RPAJastrow, LatticeGaussianProduct, LinearOrbital, ExampleHeComponent, ConstantOrbital, and DummyDiracDetWithoutMW.

Definition at line 206 of file WaveFunctionComponent.h.

References APP_ABORT, and WaveFunctionComponent::getClassName().

Referenced by WaveFunctionComponent::evalGradWithSpin(), and WaveFunctionComponent::mw_evalGrad().

207  {
208  APP_ABORT("WaveFunctionComponent::evalGradient is not implemented in " + getClassName() + " class.");
209  return GradType();
210  }
QTBase::GradType GradType
Definition: Configuration.h:62
virtual std::string getClassName() const =0
return class name
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ evalGradSource() [1/2]

virtual GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat 
)
inlinevirtual

return the logarithmic gradient for the iat-th particle of the source particleset

Parameters
Pquantumparticle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented in JeeIOrbitalSoA< FT >, J1OrbitalSoA< FT >, J1Spin< FT >, DiracDeterminantBatched< PL, VT, FPVT >, SlaterDet, DiracDeterminant< DU_TYPE >, DiracDeterminantWithBackflow, and SlaterDetWithBackflow.

Definition at line 247 of file WaveFunctionComponent.h.

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  }
QTBase::GradType GradType
Definition: Configuration.h:62

◆ evalGradSource() [2/2]

virtual GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat,
TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &  grad_grad,
TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &  lapl_grad 
)
inlinevirtual

Adds the gradient w.r.t.

the iat-th particle of the source particleset (ions) of the logarithmic gradient and laplacian w.r.t. the target paritlceset (electrons).

Parameters
Pquantum particle set (electrons)
sourceclassical particle set (ions)
iatparticle index of source (ion)
theion gradient of the elctron gradient
theion gradient of the elctron laplacian.
Returns
the log gradient of psi w.r.t. the source particle iat

Reimplemented in JeeIOrbitalSoA< FT >, J1OrbitalSoA< FT >, J1Spin< FT >, DiracDeterminantBatched< PL, VT, FPVT >, SlaterDet, DiracDeterminant< DU_TYPE >, and SlaterDetWithBackflow.

Definition at line 264 of file WaveFunctionComponent.h.

269  {
270  return GradType();
271  }
QTBase::GradType GradType
Definition: Configuration.h:62

◆ evalGradWithSpin()

virtual GradType evalGradWithSpin ( ParticleSet P,
int  iat,
ComplexType spingrad 
)
inlinevirtual

return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin.

Parameters
Pquantum particle set
iatparticle index
Returns
the spin gradient of the iat-th particle

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, DiracDeterminantBase, SlaterDet, MultiSlaterDetTableMethod, DiracDeterminant< DU_TYPE >, and DummyDiracDetWithoutMW.

Definition at line 219 of file WaveFunctionComponent.h.

References WaveFunctionComponent::evalGrad().

219 { return evalGrad(P, iat); }
virtual GradType evalGrad(ParticleSet &P, int iat)
return the current gradient for the iat-th particle

◆ evaluateDerivatives()

virtual void evaluateDerivatives ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
pure virtual

Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimizable parameters.

Parameters
Pparticle set
optvarsoptimizable parameters
dlogpsiarray of derivatives of the log of the wavefunction. Add the contribution from this component.
dhpsioverpsiarray of Hamiltonian derivatives. Add the kinetic energy derivatives contribution from this component. $ -\frac{1}{2}{\partial}_\alpha \tilde L - G \cdot {\partial}_\alpha \tilde G $. $ \tilde L $ and $ \tilde G $ are from this WaveFunctionComponent. $ G $ is from TrialWaveFunction. The 1/m factor is applied in TrialWaveFunction. This is a bug when the particle set doesn't hold equal mass particles.

Implemented in SlaterDet, SlaterDetWithBackflow, AGPDeterminant, RPAJastrow, DummyDiracDetWithoutMW, LinearOrbital, DiracDeterminant< DU_TYPE >, DiracDeterminantWithBackflow, ConstantOrbital, and ExampleHeComponent.

Referenced by qmcplusplus::test_J3_polynomial3D().

◆ evaluateDerivativesWF()

void evaluateDerivativesWF ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi 
)
virtual

Compute the derivatives of the log of the wavefunction with respect to optimizable parameters.

parameters

Parameters
Pparticle set
optvarsoptimizable parameters
dlogpsiarray of derivatives of the log of the wavefunction. Note: this function differs from the evaluateDerivatives function in the way that it only computes the derivative of the log of the wavefunction.

Reimplemented in SlaterDet, DiracDeterminantBatched< PL, VT, FPVT >, DiracDeterminantBase, and DiracDeterminant< DU_TYPE >.

Definition at line 213 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::getClassName().

Referenced by qmcplusplus::test_J3_polynomial3D().

216 {
217  throw std::runtime_error("WaveFunctionComponent::evaluateDerivativesWF is not implemented by " + getClassName());
218 }
virtual std::string getClassName() const =0
return class name

◆ evaluateDerivRatios()

void evaluateDerivRatios ( const VirtualParticleSet VP,
const opt_variables_type optvars,
std::vector< ValueType > &  ratios,
Matrix< ValueType > &  dratios 
)
virtual

evaluate ratios to evaluate the non-local PP

Parameters
VPVirtualParticleSet
ratiosratios with new positions VP.R[k] the VP.refPtcl
dratiosNq x Num_param matrix. $\partial_{\alpha}(\ln \Psi ({\bf R}^{\prime}) - \ln \Psi ({\bf R})) $

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, DiracDeterminant< DU_TYPE >, and SlaterDet.

Definition at line 259 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::evaluateRatios().

Referenced by qmcplusplus::test_J3_polynomial3D().

263 {
264  //default is only ratios and zero derivatives
265  evaluateRatios(VP, ratios);
266 }
virtual void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
evaluate ratios to evaluate the non-local PP

◆ evaluateGL()

WaveFunctionComponent::LogValue evaluateGL ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L,
bool  fromscratch 
)
virtual

compute gradients and laplacian of the TWF with respect to each particle.

Parameters
Pparticle set
GGradients, $\nabla\ln\Psi$
LLaplacians, $\nabla^2\ln\Psi$
fromscratchif true and this WFC is sensitive to numeical error accumulation, all the internal data are recomputed from scratch.
Returns
log(psi)

Reimplemented in JeeIOrbitalSoA< FT >, J1Spin< FT >, DiracDeterminantBatched< PL, VT, FPVT >, TwoBodyJastrow< FT >, DiracDeterminant< DU_TYPE >, J1OrbitalSoA< FT >, and SlaterDet.

Definition at line 178 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::evaluateLog().

Referenced by WaveFunctionComponent::mw_evaluateGL().

182 {
183  return evaluateLog(P, G, L);
184 }
virtual LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)=0
evaluate the value of the WaveFunctionComponent from scratch

◆ evaluateGradDerivatives()

virtual void evaluateGradDerivatives ( const ParticleSet::ParticleGradient G_in,
std::vector< ValueType > &  dgradlogpsi 
)
inlinevirtual

Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector.

This object is then returned as dgradlogpsi.

Reimplemented in SlaterDet.

Definition at line 496 of file WaveFunctionComponent.h.

References APP_ABORT, and WaveFunctionComponent::getClassName().

497  {
498  APP_ABORT("Need specialization of WaveFunctionComponent::evaluateGradDerivatives in " + getClassName() +
499  " class.\n");
500  }
virtual std::string getClassName() const =0
return class name
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ evaluateHessian()

virtual void evaluateHessian ( ParticleSet P,
HessVector grad_grad_psi_all 
)
inlinevirtual

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, J1OrbitalSoA< FT >, DiracDeterminant< DU_TYPE >, TwoBodyJastrow< FT >, J1Spin< FT >, and SlaterDet.

Definition at line 182 of file WaveFunctionComponent.h.

References APP_ABORT, and WaveFunctionComponent::getClassName().

183  {
184  APP_ABORT("WaveFunctionComponent::evaluateHessian is not implemented in " + getClassName() + " class.");
185  }
virtual std::string getClassName() const =0
return class name
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ evaluateLog()

◆ evaluateRatios()

void evaluateRatios ( const VirtualParticleSet VP,
std::vector< ValueType > &  ratios 
)
virtual

evaluate ratios to evaluate the non-local PP

Parameters
VPVirtualParticleSet
ratiosratios with new positions VP.R[k] the VP.refPtcl

Reimplemented in DiracDeterminant< DU_TYPE >, and SlaterDet.

Definition at line 238 of file WaveFunctionComponent.cpp.

References APP_ABORT, and WaveFunctionComponent::getClassName().

Referenced by WaveFunctionComponent::evaluateDerivRatios(), WaveFunctionComponent::evaluateSpinorRatios(), WaveFunctionComponent::mw_evaluateRatios(), and qmcplusplus::test_J3_polynomial3D().

239 {
240  std::ostringstream o;
241  o << "WaveFunctionComponent::evaluateRatios is not implemented by " << getClassName();
242  APP_ABORT(o.str());
243 }
virtual std::string getClassName() const =0
return class name
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ evaluateRatiosAlltoOne()

void evaluateRatiosAlltoOne ( ParticleSet P,
std::vector< ValueType > &  ratios 
)
virtual

evaluate the ratios of one virtual move with respect to all the particles

Parameters
Preference particleset
ratios$ ratios[i]=\{{\bf R}\}\rightarrow {r_0,\cdots,r_i^p=pos,\cdots,r_{N-1}}$

Reimplemented in SlaterDet, DiracDeterminant< DU_TYPE >, SlaterDetWithBackflow, and DiracDeterminantWithBackflow.

Definition at line 231 of file WaveFunctionComponent.cpp.

References ParticleSet::getTotalNum(), and WaveFunctionComponent::ratio().

Referenced by qmcplusplus::test_J3_polynomial3D().

232 {
233  assert(P.getTotalNum() == ratios.size());
234  for (int i = 0; i < P.getTotalNum(); ++i)
235  ratios[i] = ratio(P, i);
236 }
virtual PsiValue ratio(ParticleSet &P, int iat)=0
evaluate the ratio of the new to old WaveFunctionComponent value

◆ evaluateSpinorRatios()

void evaluateSpinorRatios ( const VirtualParticleSet VP,
const std::pair< ValueVector, ValueVector > &  spinor_multiplier,
std::vector< ValueType > &  ratios 
)
virtual

Used by SOECPComponent for faster SOC evaluation.

Reimplemented in DiracDeterminant< DU_TYPE >, and SlaterDet.

Definition at line 245 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::evaluateRatios().

246 {
247  evaluateRatios(P, ratios);
248 }
virtual void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
evaluate ratios to evaluate the non-local PP

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
virtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented in J1OrbitalSoA< FT >, J1Spin< FT >, JeeIOrbitalSoA< FT >, TwoBodyJastrow< FT >, kSpaceJastrow, MultiDiracDeterminant, CountingJastrow< RegionType >, MultiSlaterDetTableMethod, DiracDeterminantBase, RPAJastrow, SlaterDet, SlaterDetWithBackflow, and ExampleHeComponent.

Definition at line 197 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::getClassName(), and WaveFunctionComponent::isOptimizable().

Referenced by RPAJastrow::extractOptimizableObjectRefs(), and qmcplusplus::test_J3_polynomial3D().

198 {
199  if (isOptimizable())
200  throw std::logic_error("Bug!! " + getClassName() +
201  "::extractOptimizableObjectRefs "
202  "must be overloaded when the WFC is optimizable.");
203 }
virtual bool isOptimizable() const
if true, this contains optimizable components
virtual std::string getClassName() const =0
return class name

◆ finalizeOptimization()

virtual void finalizeOptimization ( )
inlinevirtual

Reimplemented in TwoBodyJastrow< FT >.

Definition at line 502 of file WaveFunctionComponent.h.

502 {}

◆ get_log_value()

const LogValue& get_log_value ( ) const
inline

◆ getClassName()

◆ getName()

const std::string& getName ( ) const
inline

return object name

Definition at line 120 of file WaveFunctionComponent.h.

References WaveFunctionComponent::my_name_.

120 { return my_name_; }
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...

◆ getValue()

PsiValue getValue ( ) const
inline

assembles the full value

Definition at line 126 of file WaveFunctionComponent.h.

References LogToValue< T >::convert(), and WaveFunctionComponent::log_value_.

static T convert(const std::complex< T1 > &logpsi)

◆ isFermionic()

virtual bool isFermionic ( ) const
inlinevirtual

true, if this component is fermionic

Reimplemented in MultiDiracDeterminant, MultiSlaterDetTableMethod, DiracDeterminantBase, SlaterDet, and SlaterDetWithBackflow.

Definition at line 129 of file WaveFunctionComponent.h.

129 { return false; }

◆ isMultiDet()

virtual bool isMultiDet ( ) const
inlinevirtual

true, if this component is multi-determinant

Reimplemented in MultiSlaterDetTableMethod.

Definition at line 132 of file WaveFunctionComponent.h.

132 { return false; }

◆ isOptimizable()

◆ KECorrection()

WaveFunctionComponent::RealType KECorrection ( )
virtual

Return the Chiesa kinetic energy correction.

Reimplemented in TwoBodyJastrow< FT >.

Definition at line 229 of file WaveFunctionComponent.cpp.

229 { return 0; }

◆ makeClone()

std::unique_ptr< WaveFunctionComponent > makeClone ( ParticleSet tqp) const
virtual

make clone

Parameters
tqptarget Quantum ParticleSet
deepcopyif true, make a decopy

If not true, return a proxy class

Reimplemented in J1OrbitalSoA< FT >, J1Spin< FT >, CountingJastrow< RegionType >, SlaterDet, MultiDiracDeterminant, kSpaceJastrow, MultiSlaterDetTableMethod, TwoBodyJastrow< FT >, JeeIOrbitalSoA< FT >, DiracDeterminantBase, SlaterDetWithBackflow, AGPDeterminant, RPAJastrow, ExampleHeComponent, LatticeGaussianProduct, and ConstantOrbital.

Definition at line 223 of file WaveFunctionComponent.cpp.

References APP_ABORT, and WaveFunctionComponent::getClassName().

Referenced by qmcplusplus::test_J3_polynomial3D().

224 {
225  APP_ABORT("Implement WaveFunctionComponent::makeClone " + getClassName() + " class.");
226  return std::unique_ptr<WaveFunctionComponent>();
227 }
virtual std::string getClassName() const =0
return class name
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ mw_accept_rejectMove()

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
virtual

moves of the iat-th particle on some walkers in a batch is accepted.

Update the current content. Note that all the lists only include accepted walkers.

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
safe_to_delayif true, delayed accept is safe.

Reimplemented in TwoBodyJastrow< FT >, DiracDeterminantBatched< PL, VT, FPVT >, SlaterDet, MultiSlaterDetTableMethod, and DiracDeterminant< DU_TYPE >.

Definition at line 157 of file WaveFunctionComponent.cpp.

References RefVectorWithLeader< T >::getLeader().

Referenced by TwoBodyJastrow< FT >::mw_accept_rejectMove().

162 {
163  assert(this == &wfc_list.getLeader());
164  for (int iw = 0; iw < wfc_list.size(); iw++)
165  if (isAccepted[iw])
166  wfc_list[iw].acceptMove(p_list[iw], iat, safe_to_delay);
167  else
168  wfc_list[iw].restore(iat);
169 }

◆ mw_calcRatio()

void mw_calcRatio ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios 
) const
virtual

compute the ratio of the new to old WaveFunctionComponent value of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
ratiosthe list of WF ratios of a walker batch, $ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})$

Reimplemented in SlaterDet.

Definition at line 104 of file WaveFunctionComponent.cpp.

References RefVectorWithLeader< T >::getLeader(), and WaveFunctionComponent::ratio().

Referenced by MultiSlaterDetTableMethod::mw_calcRatio(), and TwoBodyJastrow< FT >::mw_calcRatio().

108 {
109  assert(this == &wfc_list.getLeader());
110  for (int iw = 0; iw < wfc_list.size(); iw++)
111  ratios[iw] = wfc_list[iw].ratio(p_list[iw], iat);
112 }
virtual PsiValue ratio(ParticleSet &P, int iat)=0
evaluate the ratio of the new to old WaveFunctionComponent value

◆ mw_completeUpdates()

void mw_completeUpdates ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list) const
virtual

complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region.

Reimplemented in SlaterDet, DiracDeterminantBatched< PL, VT, FPVT >, and DiracDeterminant< DU_TYPE >.

Definition at line 171 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::completeUpdates(), and RefVectorWithLeader< T >::getLeader().

172 {
173  assert(this == &wfc_list.getLeader());
174  for (int iw = 0; iw < wfc_list.size(); iw++)
175  wfc_list[iw].completeUpdates();
176 }
virtual void completeUpdates()
complete all the delayed or asynchronous operations before leaving the p-by-p move region...

◆ mw_evalGrad() [1/2]

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

Parameters
[out]grad_nowthe list of gradients in a walker batch, $\nabla\ln\Psi$

Definition at line 69 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::mw_evalGradWithSpin(), and qmcplusplus::POS_SPIN.

Referenced by MultiSlaterDetTableMethod::mw_evalGrad().

73 {
74  if constexpr (CT == CoordsType::POS_SPIN)
75  mw_evalGradWithSpin(wfc_list, p_list, iat, grad_now.grads_positions, grad_now.grads_spins);
76  else
77  mw_evalGrad(wfc_list, p_list, iat, grad_now.grads_positions);
78 }
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_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 ...

◆ mw_evalGrad() [2/2]

void mw_evalGrad ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< GradType > &  grad_now 
) const
virtual

compute the current gradients for the iat-th particle of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
grad_nowthe list of gradients in a walker batch, $\nabla\ln\Psi$

Reimplemented in SlaterDet, MultiSlaterDetTableMethod, and DummyDiracDetWithMW.

Definition at line 80 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::evalGrad(), and RefVectorWithLeader< T >::getLeader().

84 {
85  assert(this == &wfc_list.getLeader());
86  for (int iw = 0; iw < wfc_list.size(); iw++)
87  grad_now[iw] = wfc_list[iw].evalGrad(p_list[iw], iat);
88 }
virtual GradType evalGrad(ParticleSet &P, int iat)
return the current gradient for the iat-th particle

◆ mw_evalGradWithSpin()

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
virtual

compute the current gradients and spin gradients for the iat-th particle of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
grad_nowthe list of gradients in a walker batch, $\nabla\ln\Psi$
spingrad_nowthe list of spin gradients in a walker batch, $\nabla_s\ln\Psi$

Reimplemented in SlaterDet, and DummyDiracDetWithMW.

Definition at line 90 of file WaveFunctionComponent.cpp.

References RefVectorWithLeader< T >::getLeader().

Referenced by WaveFunctionComponent::mw_evalGrad().

95 {
96  assert(this == &wfc_list.getLeader());
97  for (int iw = 0; iw < wfc_list.size(); iw++)
98  {
99  spingrad_now[iw] = 0;
100  grad_now[iw] = wfc_list[iw].evalGradWithSpin(p_list[iw], iat, spingrad_now[iw]);
101  }
102 }

◆ mw_evaluateGL()

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
virtual

evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
G_listthe list of Gradients pointers in a walker batch, $\nabla\ln\Psi$
L_listthe list of Laplacians pointers in a walker batch, $\nabla^2\ln\Psi$
fromscratchif true and this WFC is sensitive to numerical error accumulation, all the internal data are recomputed from scratch.

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, TwoBodyJastrow< FT >, and SlaterDet.

Definition at line 186 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::evaluateGL(), and RefVectorWithLeader< T >::getLeader().

Referenced by TwoBodyJastrow< FT >::mw_evaluateGL().

191 {
192  assert(this == &wfc_list.getLeader());
193  for (int iw = 0; iw < wfc_list.size(); iw++)
194  wfc_list[iw].evaluateGL(p_list[iw], G_list[iw], L_list[iw], fromscratch);
195 }
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.

◆ mw_evaluateLog()

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
virtual

evaluate from scratch the same type WaveFunctionComponent of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
G_listthe list of Gradients pointers in a walker batch, $\nabla\ln\Psi$
L_listthe list of Laplacians pointers in a walker batch, $\nabla^2\ln\Psi$
valuesthe log WF values of walkers in a batch

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, TwoBodyJastrow< FT >, and SlaterDet.

Definition at line 31 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::evaluateLog(), and RefVectorWithLeader< T >::getLeader().

Referenced by TwoBodyJastrow< FT >::mw_evaluateLog().

35 {
36  assert(this == &wfc_list.getLeader());
37  for (int iw = 0; iw < wfc_list.size(); iw++)
38  wfc_list[iw].evaluateLog(p_list[iw], G_list[iw], L_list[iw]);
39 }
virtual LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)=0
evaluate the value of the WaveFunctionComponent from scratch

◆ mw_evaluateRatios()

void mw_evaluateRatios ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< const VirtualParticleSet > &  vp_list,
std::vector< std::vector< ValueType >> &  ratios 
) const
virtual

evaluate ratios to evaluate the non-local PP multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent references of the same component in a walker batch
vp_listthe list of VirtualParticleSet references in a walker batch
ratiosof all the virtual moves of all the walkers

Reimplemented in SlaterDet, and DiracDeterminant< DU_TYPE >.

Definition at line 250 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::evaluateRatios(), and RefVectorWithLeader< T >::getLeader().

Referenced by TwoBodyJastrow< FT >::mw_evaluateRatios(), J1OrbitalSoA< FT >::mw_evaluateRatios(), and qmcplusplus::test_J3_polynomial3D().

253 {
254  assert(this == &wfc_list.getLeader());
255  for (int iw = 0; iw < wfc_list.size(); iw++)
256  wfc_list[iw].evaluateRatios(vp_list[iw], ratios[iw]);
257 }
virtual void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
evaluate ratios to evaluate the non-local PP

◆ mw_prepareGroup()

void mw_prepareGroup ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  ig 
) const
virtual

Reimplemented in MultiSlaterDetTableMethod.

Definition at line 59 of file WaveFunctionComponent.cpp.

References RefVectorWithLeader< T >::getLeader(), and WaveFunctionComponent::prepareGroup().

62 {
63  assert(this == &wfc_list.getLeader());
64  for (int iw = 0; iw < wfc_list.size(); iw++)
65  wfc_list[iw].prepareGroup(p_list[iw], ig);
66 }
virtual void prepareGroup(ParticleSet &P, int ig)
Prepare internal data for updating WFC correspond to a particle group It should be called before movi...

◆ mw_ratioGrad() [1/2]

void mw_ratioGrad ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios,
TWFGrads< CT > &  grad_new 
) const

Definition at line 122 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::mw_ratioGradWithSpin(), and qmcplusplus::POS_SPIN.

Referenced by MultiSlaterDetTableMethod::mw_ratioGrad(), and TwoBodyJastrow< FT >::mw_ratioGrad().

127 {
128  if constexpr (CT == CoordsType::POS_SPIN)
129  mw_ratioGradWithSpin(wfc_list, p_list, iat, ratios, grad_new.grads_positions, grad_new.grads_spins);
130  else
131  mw_ratioGrad(wfc_list, p_list, iat, ratios, grad_new.grads_positions);
132 }
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 ...
void mw_ratioGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const

◆ mw_ratioGrad() [2/2]

void mw_ratioGrad ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios,
std::vector< GradType > &  grad_new 
) const
virtual

compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
ratiosthe list of WF ratios of a walker batch, $ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})$
grad_nowthe list of new gradients in a walker batch, $\nabla\ln\Psi$

Reimplemented in SlaterDet, DiracDeterminant< DU_TYPE >, and DummyDiracDetWithMW.

Definition at line 134 of file WaveFunctionComponent.cpp.

References RefVectorWithLeader< T >::getLeader(), and WaveFunctionComponent::ratioGrad().

139 {
140  assert(this == &wfc_list.getLeader());
141  for (int iw = 0; iw < wfc_list.size(); iw++)
142  ratios[iw] = wfc_list[iw].ratioGrad(p_list[iw], iat, grad_new[iw]);
143 }
virtual PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat)
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...

◆ mw_ratioGradWithSpin()

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
virtual

compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
ratiosthe list of WF ratios of a walker batch, $ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})$
grad_nowthe list of new gradients in a walker batch, $\nabla\ln\Psi$

Reimplemented in SlaterDet, and DummyDiracDetWithMW.

Definition at line 145 of file WaveFunctionComponent.cpp.

References RefVectorWithLeader< T >::getLeader(), and WaveFunctionComponent::ratioGradWithSpin().

Referenced by WaveFunctionComponent::mw_ratioGrad().

151 {
152  assert(this == &wfc_list.getLeader());
153  for (int iw = 0; iw < wfc_list.size(); iw++)
154  ratios[iw] = wfc_list[iw].ratioGradWithSpin(p_list[iw], iat, grad_new[iw], spingrad_new[iw]);
155 }
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...

◆ mw_recompute()

void mw_recompute ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const std::vector< bool > &  recompute 
) const
virtual

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, TwoBodyJastrow< FT >, and SlaterDet.

Definition at line 49 of file WaveFunctionComponent.cpp.

References RefVectorWithLeader< T >::getLeader(), and WaveFunctionComponent::recompute().

Referenced by TwoBodyJastrow< FT >::mw_recompute(), and qmcplusplus::test_J3_polynomial3D().

52 {
53  assert(this == &wfc_list.getLeader());
54  for (int iw = 0; iw < wfc_list.size(); iw++)
55  if (recompute[iw])
56  wfc_list[iw].recompute(p_list[iw]);
57 }
virtual void recompute(const ParticleSet &P)
recompute the value of the WaveFunctionComponents which require critical accuracy.

◆ prepareGroup()

virtual void prepareGroup ( ParticleSet P,
int  ig 
)
inlinevirtual

Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group.

This call can be used to handle the precomputation of data used for moving this group of particle. Such data should be static with respect to the moves of particles within this group. Particle groups usually correspond to determinants of different spins.

Parameters
Pquantum particle set
igparticle group index

Reimplemented in MultiSlaterDetTableMethod.

Definition at line 195 of file WaveFunctionComponent.h.

Referenced by WaveFunctionComponent::mw_prepareGroup().

195 {}

◆ ratio()

◆ ratioGrad()

PsiValue ratioGrad ( ParticleSet P,
int  iat,
GradType grad_iat 
)
virtual

evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient

Parameters
Pthe active ParticleSet
iatthe index of a particle
grad_iatGradient for the active particle

Reimplemented in J1OrbitalSoA< FT >, J1Spin< FT >, JeeIOrbitalSoA< FT >, CountingJastrow< RegionType >, MultiDiracDeterminant, TwoBodyJastrow< FT >, kSpaceJastrow, MultiSlaterDetTableMethod, SlaterDet, DiracDeterminant< DU_TYPE >, DiracDeterminantWithBackflow, RPAJastrow, LatticeGaussianProduct, SlaterDetWithBackflow, LinearOrbital, DummyDiracDetWithoutMW, ExampleHeComponent, and ConstantOrbital.

Definition at line 115 of file WaveFunctionComponent.cpp.

References APP_ABORT, and WaveFunctionComponent::getClassName().

Referenced by WaveFunctionComponent::mw_ratioGrad(), and WaveFunctionComponent::ratioGradWithSpin().

116 {
117  APP_ABORT("WaveFunctionComponent::ratioGrad is not implemented in " + getClassName() + " class.");
118  return ValueType();
119 }
virtual std::string getClassName() const =0
return class name
QTBase::ValueType ValueType
Definition: Configuration.h:60
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ ratioGradWithSpin()

virtual PsiValue ratioGradWithSpin ( ParticleSet P,
int  iat,
GradType grad_iat,
ComplexType spingrad_iat 
)
inlinevirtual

evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin.

Parameters
Pthe active ParticleSet
iatthe index of a particle
grad_iatrealspace gradient for the active particle
spingrad_iatspin gradient for the active particle

Reimplemented in MultiSlaterDetTableMethod, DiracDeterminantBase, SlaterDet, DiracDeterminant< DU_TYPE >, and DummyDiracDetWithoutMW.

Definition at line 288 of file WaveFunctionComponent.h.

References WaveFunctionComponent::ratioGrad().

Referenced by WaveFunctionComponent::mw_ratioGradWithSpin().

289  {
290  return ratioGrad(P, iat, grad_iat);
291  }
virtual PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat)
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...

◆ recompute()

void recompute ( const ParticleSet P)
virtual

recompute the value of the WaveFunctionComponents which require critical accuracy.

needed for Slater Determinants but not needed for most types of WaveFunctionComponents

Reimplemented in JeeIOrbitalSoA< FT >, DiracDeterminantBatched< PL, VT, FPVT >, J1OrbitalSoA< FT >, CountingJastrow< RegionType >, TwoBodyJastrow< FT >, DiracDeterminant< DU_TYPE >, J1Spin< FT >, and SlaterDet.

Definition at line 41 of file WaveFunctionComponent.cpp.

References WaveFunctionComponent::evaluateLog(), and ParticleSet::getTotalNum().

Referenced by WaveFunctionComponent::mw_recompute().

42 {
43  ParticleSet::ParticleGradient temp_G(P.getTotalNum());
44  ParticleSet::ParticleLaplacian temp_L(P.getTotalNum());
45 
46  evaluateLog(P, temp_G, temp_L);
47 }
virtual LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)=0
evaluate the value of the WaveFunctionComponent from scratch
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95

◆ registerData()

virtual void registerData ( ParticleSet P,
WFBufferType buf 
)
pure virtual

◆ registerTWFFastDerivWrapper()

void registerTWFFastDerivWrapper ( const ParticleSet P,
TWFFastDerivWrapper twf 
) const
virtual

Register the component with the TWFFastDerivWrapper wrapper.

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, DiracDeterminant< DU_TYPE >, DiracDeterminantBase, and SlaterDet.

Definition at line 268 of file WaveFunctionComponent.cpp.

References APP_ABORT, and WaveFunctionComponent::getClassName().

269 {
270  std::ostringstream o;
271  o << "WaveFunctionComponent::registerTWFFastDerivWrapper is not implemented by " << getClassName();
272  APP_ABORT(o.str());
273 }
virtual std::string getClassName() const =0
return class name
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ releaseResource()

virtual void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
inlinevirtual

return a shared resource to a collection

Reimplemented in DiracDeterminantBatched< PL, VT, FPVT >, J1OrbitalSoA< FT >, DiracDeterminant< DU_TYPE >, MultiSlaterDetTableMethod, TwoBodyJastrow< FT >, and SlaterDet.

Definition at line 436 of file WaveFunctionComponent.h.

438  {}

◆ restore()

virtual void restore ( int  iat)
pure virtual

◆ updateBuffer()

virtual LogValue updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)
pure virtual

For particle-by-particle move.

Put the objects of this class in the walker buffer or forward the memory cursor.

Parameters
Pparticle set
bufAnonymous storage
fromscratchrequest recomputing the precision critical pieces of wavefunction from scratch
Returns
log value of the wavefunction.

Implemented in JeeIOrbitalSoA< FT >, J1OrbitalSoA< FT >, J1Spin< FT >, CountingJastrow< RegionType >, TwoBodyJastrow< FT >, MultiDiracDeterminant, kSpaceJastrow, MultiSlaterDetTableMethod, DiracDeterminantBatched< PL, VT, FPVT >, SlaterDet, DiracDeterminant< DU_TYPE >, RPAJastrow, DiracDeterminantWithBackflow, DummyDiracDetWithoutMW, LinearOrbital, ExampleHeComponent, LatticeGaussianProduct, SlaterDetWithBackflow, AGPDeterminant, and ConstantOrbital.

Member Data Documentation

◆ Bytes_in_WFBuffer

◆ log_value_

LogValue log_value_
protected

Current $\log\phi $.

Exception! Slater Determinant most of the time has inconsistent a log_value inconsistent with the determinants it contains dduring a move sequence. That case the log_value_ would be more safely calculated on the fly.

There could be others.

Definition at line 106 of file WaveFunctionComponent.h.

Referenced by AGPDeterminant::acceptMove(), DiracDeterminantWithBackflow::acceptMove(), MultiSlaterDetTableMethod::acceptMove(), SlaterDet::acceptMove(), CountingJastrow< RegionType >::acceptMove(), JeeIOrbitalSoA< FT >::acceptMove(), J1OrbitalSoA< FT >::acceptMove(), J1Spin< FT >::acceptMove(), AGPDeterminant::copyFromBuffer(), DiracDeterminantWithBackflow::copyFromBuffer(), MultiSlaterDetTableMethod::copyFromBuffer(), DiracDeterminantWithBackflow::dummyEvalLi(), CountingJastrow< RegionType >::evalGrad(), DiracDeterminantWithBackflow::evaluateDerivatives(), SlaterDet::evaluateGL(), J1OrbitalSoA< FT >::evaluateGL(), J1Spin< FT >::evaluateGL(), JeeIOrbitalSoA< FT >::evaluateGL(), LinearOrbital::evaluateLog(), ExampleHeComponent::evaluateLog(), LatticeGaussianProduct::evaluateLog(), SlaterDet::evaluateLog(), SlaterDetWithBackflow::evaluateLog(), RPAJastrow::evaluateLog(), AGPDeterminant::evaluateLog(), DiracDeterminantWithBackflow::evaluateLog(), MultiSlaterDetTableMethod::evaluateLog(), J1Spin< FT >::evaluateLog(), CountingJastrow< RegionType >::evaluateLog(), J1OrbitalSoA< FT >::evaluateLog(), JeeIOrbitalSoA< FT >::evaluateLog(), LatticeGaussianProduct::evaluateLogAndStore(), AGPDeterminant::evaluateLogAndStore(), WaveFunctionComponent::get_log_value(), WaveFunctionComponent::getValue(), SlaterDet::mw_accept_rejectMove(), TwoBodyJastrow< FT >::mw_accept_rejectMove(), SlaterDet::mw_evaluateGL(), TwoBodyJastrow< FT >::mw_evaluateGL(), SlaterDet::mw_evaluateLog(), TwoBodyJastrow< FT >::mw_evaluateLog(), DiracDeterminantWithBackflow::ratio(), DiracDeterminantWithBackflow::ratioGrad(), CountingJastrow< RegionType >::recompute(), AGPDeterminant::registerData(), DiracDeterminantWithBackflow::registerData(), MultiSlaterDetTableMethod::registerData(), kSpaceJastrow::registerData(), DiracDeterminantWithBackflow::testDerivFjj(), DiracDeterminantWithBackflow::testL(), AGPDeterminant::updateBuffer(), SlaterDetWithBackflow::updateBuffer(), LatticeGaussianProduct::updateBuffer(), DiracDeterminantWithBackflow::updateBuffer(), RPAJastrow::updateBuffer(), SlaterDet::updateBuffer(), MultiSlaterDetTableMethod::updateBuffer(), kSpaceJastrow::updateBuffer(), J1OrbitalSoA< FT >::updateBuffer(), J1Spin< FT >::updateBuffer(), and JeeIOrbitalSoA< FT >::updateBuffer().

◆ my_name_

const std::string my_name_
protected

Name of the object It is required to be different for objects of the same derived type like multiple J1.

It can be left empty for object which is unique per many-body WF.

Definition at line 99 of file WaveFunctionComponent.h.

Referenced by WaveFunctionComponent::getName(), J1OrbitalSoA< FT >::J1OrbitalSoA(), J1Spin< FT >::J1Spin(), JeeIOrbitalSoA< FT >::JeeIOrbitalSoA(), JeeIOrbitalSoA< FT >::makeClone(), J1OrbitalSoA< FT >::makeClone(), RPAJastrow::makeShortRange(), and TwoBodyJastrow< FT >::TwoBodyJastrow().

◆ myVars

◆ UpdateMode