QMCPACK
DiracDeterminant< DU_TYPE > Class Template Reference
+ Inheritance diagram for DiracDeterminant< DU_TYPE >:
+ Collaboration diagram for DiracDeterminant< DU_TYPE >:

Public Types

using ValueVector = SPOSet::ValueVector
 
using ValueMatrix = SPOSet::ValueMatrix
 
using GradVector = SPOSet::GradVector
 
using GradMatrix = SPOSet::GradMatrix
 
using HessMatrix = SPOSet::HessMatrix
 
using HessVector = SPOSet::HessVector
 
using mValueType = QMCTraits::QTFull::ValueType
 
using mGradType = TinyVector< mValueType, DIM >
 
- 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

 DiracDeterminant (std::unique_ptr< SPOSet > &&spos, int first, int last, int ndelay=1, DetMatInvertor matrix_inverter_kind=DetMatInvertor::ACCEL)
 constructor More...
 
 DiracDeterminant (const DiracDeterminant &s)=delete
 
DiracDeterminantoperator= (const DiracDeterminant &s)=delete
 
std::string getClassName () const override
 return class name More...
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimizable parameters. More...
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi) override
 Compute the derivatives of the log of the wavefunction with respect to optimizable parameters. More...
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
void updateAfterSweep (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)
 
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 registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const final
 Finds the SPOSet associated with this determinant, and registers it with WFN wrapper. More...
 
PsiValue ratio (ParticleSet &P, int iat) override
 return the ratio only for the iat-th partcle move More...
 
void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
 compute multiple ratios for a particle move More...
 
void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multipler, std::vector< ValueType > &ratios) override
 Used by SOECPComponent for faster SOC evaluation. More...
 
void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const override
 evaluate ratios to evaluate the non-local PP multiple walkers More...
 
void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
 evaluate ratios to evaluate the non-local PP 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) final
 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 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
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
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) final
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat) override
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad) override
 Adds the gradient w.r.t. More...
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 move was accepted, update the real container 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 completeUpdates () override
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
void mw_completeUpdates (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region. More...
 
void restore (int iat) override
 move was rejected. More...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate log of a determinant for a particle set More...
 
void recompute (const ParticleSet &P) override
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch) override
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi) override
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wf_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wf_list) const override
 return a shared resource to a collection More...
 
std::unique_ptr< DiracDeterminantBasemakeCopy (std::unique_ptr< SPOSet > &&spo) const override
 cloning function More...
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios) override
 evaluate the ratios of one virtual move with respect to all the particles More...
 
ValueMatrixgetPsiMinv () override
 return for testing More...
 
- Public Member Functions inherited from DiracDeterminantBase
 DiracDeterminantBase (const std::string &class_name, std::unique_ptr< SPOSet > &&spos, int first, int last)
 constructor More...
 
 ~DiracDeterminantBase () override
 default destructor More...
 
 DiracDeterminantBase (const DiracDeterminantBase &s)=delete
 
DiracDeterminantBaseoperator= (const DiracDeterminantBase &s)=delete
 
SPOSetPtr getPhi () const
 
int getFirstIndex () const
 
int getLastIndex () const
 
bool isFermionic () const final
 true, if this component is fermionic More...
 
bool isOptimizable () const final
 if true, this contains optimizable components More...
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) final
 extract underlying OptimizableObject references More...
 
void checkOutVariables (const opt_variables_type &active) final
 check out variational optimizable variables More...
 
virtual void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, int offset, Matrix< RealType > &dlogpsi, Array< GradType, 3 > &dG, Matrix< RealType > &dL)
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const final
 make clone More...
 
PsiValue ratioGradWithSpin (ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad) 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...
 
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...
 
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 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 LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)=0
 evaluate the value of the WaveFunctionComponent from scratch 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 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 copyFromBuffer (ParticleSet &P, WFBufferType &buf)=0
 For particle-by-particle move. 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 acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 acquire a shared resource from a collection More...
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 return a shared resource to a collection 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 completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
virtual GradType evalGrad (ParticleSet &P, int iat)
 return the current gradient for the iat-th particle 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 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_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...
 
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...
 
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 PsiValue ratio (ParticleSet &P, int iat)=0
 evaluate the ratio of the new to old WaveFunctionComponent value 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 void restore (int iat)=0
 If a move for iat-th particle is rejected, restore to the content. 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 void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi_all)
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP 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 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...
 
- 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 isMultiDet () const
 true, if this component is multi-determinant 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
 
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...
 
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_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 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 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

ValueMatrix psiM_temp
 psiM(j,i) $= \psi_j({\bf r}_i)$ More...
 
ValueMatrix psiM
 inverse transpose of psiM(j,i) $= \psi_j({\bf r}_i)$ More...
 
ValueMatrix psiMinv
 temporary container for testing More...
 
GradMatrix dpsiM
 dpsiM(i,j) $= \nabla_i \psi_j({\bf r}_i)$ More...
 
ValueMatrix d2psiM
 d2psiM(i,j) $= \nabla_i^2 \psi_j({\bf r}_i)$ More...
 
GradMatrix grad_source_psiM
 Used for force computations. More...
 
GradMatrix grad_lapl_source_psiM
 
HessMatrix grad_grad_source_psiM
 
GradMatrix phi_alpha_Minv
 
GradMatrix grad_phi_Minv
 
ValueMatrix lapl_phi_Minv
 
HessMatrix grad_phi_alpha_Minv
 
ValueVector psiV
 value of single-particle orbital for particle-by-particle update More...
 
ValueVector dspin_psiV
 
GradVector dpsiV
 
ValueVector d2psiV
 
DU_TYPE updateEng
 delayed update engine More...
 
ValueVector invRow
 the row of up-to-date inverse matrix More...
 
int invRow_id
 row id correspond to the up-to-date invRow. More...
 
PsiValue curRatio
 
ValueTypeFirstAddressOfdV
 
ValueTypeLastAddressOfdV
 
- 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 Member Functions

void resize (int nel, int morb)
 reset the size: with the number of particles and number of orbtials More...
 

Protected Attributes

const int ndelay_
 
- Protected Attributes inherited from DiracDeterminantBase
NewTimerUpdateTimer
 Timers. More...
 
NewTimerRatioTimer
 
NewTimerInverseTimer
 
NewTimerBufferTimer
 
NewTimerSPOVTimer
 
NewTimerSPOVGLTimer
 
const std::unique_ptr< SPOSetPhi
 a set of single-particle orbitals used to fill in the values of the matrix More...
 
const int FirstIndex
 index of the first particle with respect to the particle set More...
 
const int LastIndex
 index of the last particle with respect to the particle set More...
 
const int NumOrbitals
 number of single-particle orbitals which belong to this Dirac determinant More...
 
const int NumPtcls
 number of particles which belong to this Dirac determinant More...
 
ValueMatrix dummy_vmt
 
- 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 invertPsiM (const ValueMatrix &logdetT, ValueMatrix &invMat)
 invert psiM or its copies More...
 
void resizeScratchObjectsForIonDerivs ()
 Resize all temporary arrays required for force computation. More...
 
PsiValue ratioGrad_compute (int iat, GradType &grad_iat)
 internal function computing ratio and gradients after computing the SPOs, used by ratioGrad. More...
 

Private Attributes

DiracMatrix< QMCTraits::QTFull::ValueTypehost_inverter_
 slow but doesn't consume device memory More...
 
const DetMatInvertor matrix_inverter_kind_
 selected scheme for inversion More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from DiracDeterminantBase
static bool checkG (const GradType &g)
 

Detailed Description

template<typename DU_TYPE = DelayedUpdate<QMCTraits::ValueType, QMCTraits::QTFull::ValueType>>
class qmcplusplus::DiracDeterminant< DU_TYPE >

Definition at line 37 of file DiracDeterminant.h.

Member Typedef Documentation

◆ GradMatrix

Definition at line 49 of file DiracDeterminant.h.

◆ GradVector

Definition at line 48 of file DiracDeterminant.h.

◆ HessMatrix

Definition at line 50 of file DiracDeterminant.h.

◆ HessVector

Definition at line 51 of file DiracDeterminant.h.

◆ mGradType

Definition at line 54 of file DiracDeterminant.h.

◆ mValueType

Definition at line 53 of file DiracDeterminant.h.

◆ ValueMatrix

Definition at line 47 of file DiracDeterminant.h.

◆ ValueVector

Definition at line 46 of file DiracDeterminant.h.

Constructor & Destructor Documentation

◆ DiracDeterminant() [1/2]

DiracDeterminant ( std::unique_ptr< SPOSet > &&  spos,
int  first,
int  last,
int  ndelay = 1,
DetMatInvertor  matrix_inverter_kind = DetMatInvertor::ACCEL 
)

constructor

Parameters
sposthe single-particle orbital set
firstindex of the first particle
lastindex of last particle
ndelaydelayed update rank
sposthe single-particle orbital set
firstindex of the first particle

Definition at line 33 of file DiracDeterminant.cpp.

References RotatedSPOs::buildOptVariables(), DiracDeterminantBase::NumPtcls, DiracDeterminantBase::Phi, and DiracDeterminant< DU_TYPE >::resize().

38  : DiracDeterminantBase(getClassName(), std::move(spos), first, last),
39  ndelay_(ndelay),
40  invRow_id(-1),
41  matrix_inverter_kind_(matrix_inverter_kind)
42 {
44 
45  RotatedSPOs* rot_spo = dynamic_cast<RotatedSPOs*>(Phi.get());
46  if (rot_spo)
47  rot_spo->buildOptVariables(NumPtcls);
48 
49  if (Phi->getOrbitalSetSize() < NumPtcls)
50  {
51  std::ostringstream err_msg;
52  err_msg << "The SPOSet " << Phi->getName() << " only has " << Phi->getOrbitalSetSize() << " orbitals "
53  << "but this determinant needs at least " << NumPtcls << std::endl;
54  throw std::runtime_error(err_msg.str());
55  }
56 }
std::string getClassName() const override
return class name
void resize(int nel, int morb)
reset the size: with the number of particles and number of orbtials
int invRow_id
row id correspond to the up-to-date invRow.
const DetMatInvertor matrix_inverter_kind_
selected scheme for inversion
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
DiracDeterminantBase(const std::string &class_name, std::unique_ptr< SPOSet > &&spos, int first, int last)
constructor
const int NumPtcls
number of particles which belong to this Dirac determinant

◆ DiracDeterminant() [2/2]

DiracDeterminant ( const DiracDeterminant< DU_TYPE > &  s)
delete

Member Function Documentation

◆ acceptMove()

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

move was accepted, update the real container

Implements WaveFunctionComponent.

Definition at line 277 of file DiracDeterminant.cpp.

References qmcplusplus::convertValueToLog(), and qmcplusplus::simd::copy().

278 {
279  if (curRatio == PsiValue(0))
280  {
281  std::ostringstream msg;
282  msg << "DiracDeterminant::acceptMove curRatio is " << curRatio << "! Report a bug." << std::endl;
283  throw std::runtime_error(msg.str());
284  }
285  ScopedTimer local_timer(UpdateTimer);
286  const int WorkingIndex = iat - FirstIndex;
287  assert(WorkingIndex >= 0);
289  updateEng.acceptRow(psiM, WorkingIndex, psiV, curRatio);
290  if (!safe_to_delay)
291  updateEng.updateInvMat(psiM);
292  // invRow becomes invalid after accepting a move
293  invRow_id = -1;
295  {
296  simd::copy(dpsiM[WorkingIndex], dpsiV.data(), NumOrbitals);
297  simd::copy(d2psiM[WorkingIndex], d2psiV.data(), NumOrbitals);
298  }
299  curRatio = 1.0;
300 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueMatrix d2psiM
d2psiM(i,j)
ValueVector psiV
value of single-particle orbital for particle-by-particle update
void copy(T1 *restrict target, const T2 *restrict source, size_t n)
copy function using memcpy
Definition: algorithm.hpp:40
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
const int FirstIndex
index of the first particle with respect to the particle set
int invRow_id
row id correspond to the up-to-date invRow.
GradMatrix dpsiM
dpsiM(i,j)
DU_TYPE updateEng
delayed update engine
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
ValueMatrix psiM
inverse transpose of psiM(j,i)

◆ 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 771 of file DiracDeterminant.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedLeader(), and DiracDeterminantBase::Phi.

773 {
774  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminant<DU_TYPE>>();
775  RefVectorWithLeader<SPOSet> phi_list(*wfc_leader.Phi);
776  for (WaveFunctionComponent& wfc : wfc_list)
777  {
778  auto& det = static_cast<DiracDeterminant<DU_TYPE>&>(wfc);
779  phi_list.push_back(*det.Phi);
780  }
781  wfc_leader.Phi->acquireResource(collection, phi_list);
782 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
WaveFunctionComponent(const std::string &obj_name="")
default constructor

◆ completeUpdates()

void completeUpdates ( )
overridevirtual

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 from WaveFunctionComponent.

Definition at line 311 of file DiracDeterminant.cpp.

Referenced by DiracDeterminant< DU_TYPE >::mw_completeUpdates().

312 {
313  ScopedTimer local_timer(UpdateTimer);
314  // invRow becomes invalid after updating the inverse matrix
315  invRow_id = -1;
316  updateEng.updateInvMat(psiM);
317 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
int invRow_id
row id correspond to the up-to-date invRow.
DU_TYPE updateEng
delayed update engine
ValueMatrix psiM
inverse transpose of psiM(j,i)

◆ 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 397 of file DiracDeterminant.cpp.

References PooledMemory< T_scalar, Alloc >::get(), and PooledMemory< T_scalar, Alloc >::lendReference().

398 {
399  ScopedTimer local_timer(BufferTimer);
400  psiM.attachReference(buf.lendReference<ValueType>(psiM.size()));
401  dpsiM.attachReference(buf.lendReference<GradType>(dpsiM.size()));
402  d2psiM.attachReference(buf.lendReference<ValueType>(d2psiM.size()));
403  buf.get(log_value_);
404  // start with invRow labelled invalid
405  invRow_id = -1;
406  updateEng.initializeInv(psiM);
407 }
QTBase::GradType GradType
Definition: Configuration.h:62
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueMatrix d2psiM
d2psiM(i,j)
int invRow_id
row id correspond to the up-to-date invRow.
GradMatrix dpsiM
dpsiM(i,j)
QTBase::ValueType ValueType
Definition: Configuration.h:60
DU_TYPE updateEng
delayed update engine
ValueMatrix psiM
inverse transpose of psiM(j,i)

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 765 of file DiracDeterminant.cpp.

766 {
767  Phi->createResource(collection);
768 }
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ evalGrad()

DiracDeterminant< DU_TYPE >::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 139 of file DiracDeterminant.cpp.

References qmcplusplus::simd::dot().

140 {
141  ScopedTimer local_timer(RatioTimer);
142  const int WorkingIndex = iat - FirstIndex;
143  assert(WorkingIndex >= 0);
144  invRow_id = WorkingIndex;
145  updateEng.getInvRow(psiM, WorkingIndex, invRow);
146  GradType g = simd::dot(invRow.data(), dpsiM[WorkingIndex], invRow.size());
147  assert(checkG(g));
148  return g;
149 }
QTBase::GradType GradType
Definition: Configuration.h:62
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
static bool checkG(const GradType &g)
int invRow_id
row id correspond to the up-to-date invRow.
GradMatrix dpsiM
dpsiM(i,j)
DU_TYPE updateEng
delayed update engine
ValueMatrix psiM
inverse transpose of psiM(j,i)
ValueVector invRow
the row of up-to-date inverse matrix

◆ evalGradSource() [1/2]

DiracDeterminant< DU_TYPE >::GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat 
)
overridevirtual

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 556 of file DiracDeterminant.cpp.

References qmcplusplus::simd::dot().

559 {
560  GradType g(0.0);
561  if (Phi->hasIonDerivs())
562  {
564  Phi->evaluateGradSource(P, FirstIndex, LastIndex, source, iat, grad_source_psiM);
565  g = simd::dot(psiM.data(), grad_source_psiM.data(), psiM.size());
566  }
567 
568  return g;
569 }
QTBase::GradType GradType
Definition: Configuration.h:62
void resizeScratchObjectsForIonDerivs()
Resize all temporary arrays required for force computation.
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
GradMatrix grad_source_psiM
Used for force computations.
ValueMatrix psiM
inverse transpose of psiM(j,i)

◆ evalGradSource() [2/2]

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

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 598 of file DiracDeterminant.cpp.

References OHMMS_DIM.

604 {
605  GradType gradPsi(0.0);
606  if (Phi->hasIonDerivs())
607  {
609  Phi->evaluateGradSource(P, FirstIndex, LastIndex, source, iat, grad_source_psiM, grad_grad_source_psiM,
611  // HACK HACK HACK
612  // Phi->evaluateVGL(P, FirstIndex, LastIndex, psiM, dpsiM, d2psiM);
613  // psiM_temp = psiM;
614  // LogValue=InvertWithLog(psiM.data(),NumPtcls,NumOrbitals,
615  // WorkSpace.data(),Pivot.data(),PhaseValue);
616  // for (int i=0; i<NumPtcls; i++)
617  // for (int j=0; j<NumPtcls; j++) {
618  // double val = 0.0;
619  // for (int k=0; k<NumPtcls; k++)
620  // val += psiM(i,k) * psiM_temp(k,j);
621  // val -= (i == j) ? 1.0 : 0.0;
622  // if (std::abs(val) > 1.0e-12)
623  // std::cerr << "Error in inverse.\n";
624  // }
625  // for (int i=0; i<NumPtcls; i++) {
626  // P.G[FirstIndex+i] = GradType();
627  // for (int j=0; j<NumOrbitals; j++)
628  // P.G[FirstIndex+i] += psiM(i,j)*dpsiM(i,j);
629  // }
630  // Compute matrices
631  phi_alpha_Minv = 0.0;
632  grad_phi_Minv = 0.0;
633  lapl_phi_Minv = 0.0;
634  grad_phi_alpha_Minv = 0.0;
635  for (int i = 0; i < NumPtcls; i++)
636  for (int j = 0; j < NumOrbitals; j++)
637  {
638  lapl_phi_Minv(i, j) = 0.0;
639  for (int k = 0; k < NumOrbitals; k++)
640  lapl_phi_Minv(i, j) += d2psiM(i, k) * psiM(j, k);
641  }
642  for (int dim = 0; dim < OHMMS_DIM; dim++)
643  {
644  for (int i = 0; i < NumPtcls; i++)
645  for (int j = 0; j < NumOrbitals; j++)
646  {
647  for (int k = 0; k < NumOrbitals; k++)
648  {
649  phi_alpha_Minv(i, j)[dim] += grad_source_psiM(i, k)[dim] * psiM(j, k);
650  grad_phi_Minv(i, j)[dim] += dpsiM(i, k)[dim] * psiM(j, k);
651  for (int dim_el = 0; dim_el < OHMMS_DIM; dim_el++)
652  grad_phi_alpha_Minv(i, j)(dim, dim_el) += grad_grad_source_psiM(i, k)(dim, dim_el) * psiM(j, k);
653  }
654  }
655  }
656  for (int i = 0, iel = FirstIndex; i < NumPtcls; i++, iel++)
657  {
658  HessType dval(0.0);
659  GradType d2val(0.0);
660  for (int dim = 0; dim < OHMMS_DIM; dim++)
661  for (int dim_el = 0; dim_el < OHMMS_DIM; dim_el++)
662  dval(dim, dim_el) = grad_phi_alpha_Minv(i, i)(dim, dim_el);
663  for (int j = 0; j < NumOrbitals; j++)
664  {
665  gradPsi += grad_source_psiM(i, j) * psiM(i, j);
666  for (int dim = 0; dim < OHMMS_DIM; dim++)
667  for (int k = 0; k < OHMMS_DIM; k++)
668  dval(dim, k) -= phi_alpha_Minv(j, i)[dim] * grad_phi_Minv(i, j)[k];
669  }
670  for (int dim = 0; dim < OHMMS_DIM; dim++)
671  {
672  for (int k = 0; k < OHMMS_DIM; k++)
673  grad_grad[dim][iel][k] += dval(dim, k);
674  for (int j = 0; j < NumOrbitals; j++)
675  {
676  // First term, eq 9
677  lapl_grad[dim][iel] += grad_lapl_source_psiM(i, j)[dim] * psiM(i, j);
678  // Second term, eq 9
679  if (j == i)
680  for (int dim_el = 0; dim_el < OHMMS_DIM; dim_el++)
681  lapl_grad[dim][iel] -=
682  (RealType)2.0 * grad_phi_alpha_Minv(j, i)(dim, dim_el) * grad_phi_Minv(i, j)[dim_el];
683  // Third term, eq 9
684  // First term, eq 10
685  lapl_grad[dim][iel] -= phi_alpha_Minv(j, i)[dim] * lapl_phi_Minv(i, j);
686  // Second term, eq 11
687  for (int dim_el = 0; dim_el < OHMMS_DIM; dim_el++)
688  lapl_grad[dim][iel] +=
689  (RealType)2.0 * phi_alpha_Minv(j, i)[dim] * grad_phi_Minv(i, i)[dim_el] * grad_phi_Minv(i, j)[dim_el];
690  }
691  }
692  }
693  }
694  return gradPsi;
695 }
QTBase::GradType GradType
Definition: Configuration.h:62
void resizeScratchObjectsForIonDerivs()
Resize all temporary arrays required for force computation.
ValueMatrix d2psiM
d2psiM(i,j)
OrbitalSetTraits< ValueType >::HessType HessType
const int FirstIndex
index of the first particle with respect to the particle set
#define OHMMS_DIM
Definition: config.h:64
GradMatrix dpsiM
dpsiM(i,j)
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
GradMatrix grad_source_psiM
Used for force computations.
ValueMatrix psiM
inverse transpose of psiM(j,i)
QMCTraits::RealType RealType
const int NumPtcls
number of particles which belong to this Dirac determinant

◆ evalGradWithSpin()

DiracDeterminant< DU_TYPE >::GradType evalGradWithSpin ( ParticleSet P,
int  iat,
ComplexType spingrad 
)
finalvirtual

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 152 of file DiracDeterminant.cpp.

References qmcplusplus::simd::dot().

155 {
156  Phi->evaluate_spin(P, iat, psiV, dspin_psiV);
157  ScopedTimer local_timer(RatioTimer);
158  const int WorkingIndex = iat - FirstIndex;
159  assert(WorkingIndex >= 0);
160  invRow_id = WorkingIndex;
161  updateEng.getInvRow(psiM, WorkingIndex, invRow);
162  GradType g = simd::dot(invRow.data(), dpsiM[WorkingIndex], invRow.size());
163  ComplexType spin_g = simd::dot(invRow.data(), dspin_psiV.data(), invRow.size());
164  spingrad += spin_g;
165 
166  return g;
167 }
QTBase::GradType GradType
Definition: Configuration.h:62
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
ValueVector psiV
value of single-particle orbital for particle-by-particle update
const int FirstIndex
index of the first particle with respect to the particle set
int invRow_id
row id correspond to the up-to-date invRow.
GradMatrix dpsiM
dpsiM(i,j)
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
DU_TYPE updateEng
delayed update engine
ValueMatrix psiM
inverse transpose of psiM(j,i)
ValueVector invRow
the row of up-to-date inverse matrix

◆ evaluateDerivatives()

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

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.

Implements WaveFunctionComponent.

Definition at line 741 of file DiracDeterminant.cpp.

745 {
746  Phi->evaluateDerivatives(P, active, dlogpsi, dhpsioverpsi, FirstIndex, LastIndex);
747 }
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set

◆ evaluateDerivativesWF()

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

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 from DiracDeterminantBase.

Definition at line 750 of file DiracDeterminant.cpp.

753 {
754  Phi->evaluateDerivativesWF(P, active, dlogpsi, FirstIndex, LastIndex);
755 }
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set

◆ evaluateDerivRatios()

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

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 from WaveFunctionComponent.

Definition at line 522 of file DiracDeterminant.cpp.

References qmcplusplus::syclBLAS::copy_n(), and VirtualParticleSet::refPtcl.

526 {
527  const int WorkingIndex = VP.refPtcl - FirstIndex;
528  assert(WorkingIndex >= 0);
529  std::copy_n(psiM[WorkingIndex], invRow.size(), invRow.data());
530  Phi->evaluateDerivRatios(VP, optvars, psiV, invRow, ratios, dratios, FirstIndex, LastIndex);
531 }
ValueVector psiV
value of single-particle orbital for particle-by-particle update
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
ValueMatrix psiM
inverse transpose of psiM(j,i)
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548
ValueVector invRow
the row of up-to-date inverse matrix

◆ evaluateGL()

DiracDeterminant< DU_TYPE >::LogValue evaluateGL ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L,
bool  fromscratch 
)
overridevirtual

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 370 of file DiracDeterminant.cpp.

374 {
375  if (fromscratch)
376  evaluateLog(P, G, L);
377  else
378  updateAfterSweep(P, G, L);
379  return log_value_;
380 }
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate log of a determinant for a particle set
void updateAfterSweep(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)

◆ evaluateHessian()

void evaluateHessian ( ParticleSet P,
HessVector grad_grad_psi 
)
overridevirtual

Reimplemented from WaveFunctionComponent.

Definition at line 572 of file DiracDeterminant.cpp.

References qmcplusplus::simd::dot(), and qmcplusplus::outerProduct().

573 {
574  // Hessian is not often used, so only resize/allocate if used
575  grad_grad_source_psiM.resize(psiM.rows(), psiM.cols());
576  //IM A HACK. Assumes evaluateLog has already been executed.
577  Phi->evaluate_notranspose(P, FirstIndex, LastIndex, psiM_temp, dpsiM, grad_grad_source_psiM);
579 
580  phi_alpha_Minv = 0.0;
581  grad_phi_Minv = 0.0;
582  lapl_phi_Minv = 0.0;
583  grad_phi_alpha_Minv = 0.0;
584  //grad_grad_psi.resize(NumPtcls);
585 
586  for (int i = 0, iat = FirstIndex; i < NumPtcls; i++, iat++)
587  {
588  GradType rv = simd::dot(psiM[i], dpsiM[i], NumOrbitals);
589  // HessType hess_tmp=simd::dot(psiM[i],grad_grad_source_psiM[i],NumOrbitals);
590  HessType hess_tmp;
591  hess_tmp = 0.0;
592  hess_tmp = simd::dot(psiM[i], grad_grad_source_psiM[i], NumOrbitals);
593  grad_grad_psi[iat] = hess_tmp - outerProduct(rv, rv);
594  }
595 }
QTBase::GradType GradType
Definition: Configuration.h:62
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
OrbitalSetTraits< ValueType >::HessType HessType
const int FirstIndex
index of the first particle with respect to the particle set
GradMatrix dpsiM
dpsiM(i,j)
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
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 LastIndex
index of the last particle with respect to the particle set
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
ValueMatrix psiM
inverse transpose of psiM(j,i)
void invertPsiM(const ValueMatrix &logdetT, ValueMatrix &invMat)
invert psiM or its copies
ValueMatrix psiM_temp
psiM(j,i)
const int NumPtcls
number of particles which belong to this Dirac determinant

◆ evaluateLog()

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

evaluate log of a determinant for a particle set

Calculate the log value of the Dirac determinant for particles.

Parameters
Pinput configuration containing N particles
Ga vector containing N gradients
La vector containing N laplacians
Returns
the value of the determinant

$ (first,first+nel). $ Add the gradient and laplacian contribution of the determinant to G(radient) and L(aplacian) for local energy calculations.

Implements WaveFunctionComponent.

Definition at line 709 of file DiracDeterminant.cpp.

References qmcplusplus::simd::dot(), and qmcplusplus::dot().

712 {
713  recompute(P);
714 
715  for (int i = 0, iat = FirstIndex; i < NumPtcls; i++, iat++)
716  {
717  mGradType rv = simd::dot(psiM[i], dpsiM[i], NumOrbitals);
718  mValueType lap = simd::dot(psiM[i], d2psiM[i], NumOrbitals);
719  G[iat] += rv;
720  L[iat] += lap - dot(rv, rv);
721  }
722  return log_value_;
723 }
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ValueMatrix d2psiM
d2psiM(i,j)
const int FirstIndex
index of the first particle with respect to the particle set
TinyVector< mValueType, DIM > mGradType
GradMatrix dpsiM
dpsiM(i,j)
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
ValueMatrix psiM
inverse transpose of psiM(j,i)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
const int NumPtcls
number of particles which belong to this Dirac determinant
QMCTraits::QTFull::ValueType mValueType

◆ evaluateRatios()

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

compute multiple ratios for a particle move

Reimplemented from WaveFunctionComponent.

Definition at line 445 of file DiracDeterminant.cpp.

References qmcplusplus::syclBLAS::copy_n(), and VirtualParticleSet::refPtcl.

446 {
447  {
448  ScopedTimer local_timer(RatioTimer);
449  const int WorkingIndex = VP.refPtcl - FirstIndex;
450  assert(WorkingIndex >= 0);
451  std::copy_n(psiM[WorkingIndex], invRow.size(), invRow.data());
452  }
453  {
454  ScopedTimer local_timer(SPOVTimer);
455  Phi->evaluateDetRatios(VP, psiV, invRow, ratios);
456  }
457 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueVector psiV
value of single-particle orbital for particle-by-particle update
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
ValueMatrix psiM
inverse transpose of psiM(j,i)
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548
ValueVector invRow
the row of up-to-date inverse matrix

◆ evaluateRatiosAlltoOne()

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

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 from WaveFunctionComponent.

Definition at line 534 of file DiracDeterminant.cpp.

References qmcplusplus::MatrixOperators::product().

535 {
536  ScopedTimer local_timer(SPOVTimer);
537  Phi->evaluateValue(P, -1, psiV);
538  Vector<ValueType> ratios_this_det(ratios.data() + FirstIndex, NumPtcls);
539  MatrixOperators::product(psiM, psiV, ratios_this_det);
540 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueVector psiV
value of single-particle orbital for particle-by-particle update
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
void product(const Matrix< T > &A, const Matrix< T > &B, Matrix< T > &C)
static function to perform C=AB for real matrices
ValueMatrix psiM
inverse transpose of psiM(j,i)
const int NumPtcls
number of particles which belong to this Dirac determinant

◆ evaluateSpinorRatios()

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

Used by SOECPComponent for faster SOC evaluation.

Reimplemented from WaveFunctionComponent.

Definition at line 460 of file DiracDeterminant.cpp.

References qmcplusplus::syclBLAS::copy_n(), and VirtualParticleSet::refPtcl.

461 {
462  {
463  ScopedTimer local_timer(RatioTimer);
464  const int WorkingIndex = VP.refPtcl - FirstIndex;
465  assert(WorkingIndex >= 0);
466  std::copy_n(psiM[WorkingIndex], invRow.size(), invRow.data());
467  }
468  {
469  ScopedTimer local_timer(SPOVTimer);
470  Phi->evaluateDetSpinorRatios(VP, psiV, spinor_multiplier, invRow, ratios);
471  }
472 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueVector psiV
value of single-particle orbital for particle-by-particle update
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
ValueMatrix psiM
inverse transpose of psiM(j,i)
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548
ValueVector invRow
the row of up-to-date inverse matrix

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 72 of file DiracDeterminant.h.

72 { return "DiracDeterminant"; }

◆ getPsiMinv()

ValueMatrix& getPsiMinv ( )
inlineoverridevirtual

return for testing

Reimplemented from DiracDeterminantBase.

Definition at line 210 of file DiracDeterminant.h.

References DiracDeterminant< DU_TYPE >::psiM.

210 { return psiM; }
ValueMatrix psiM
inverse transpose of psiM(j,i)

◆ invertPsiM()

void invertPsiM ( const ValueMatrix logdetT,
ValueMatrix invMat 
)
private

invert psiM or its copies

Definition at line 59 of file DiracDeterminant.cpp.

References qmcplusplus::ACCEL, OHMMS::Controller, qmcplusplus::Units::charge::e, omp_get_thread_num(), and Communicate::rank().

60 {
61  ScopedTimer local_timer(InverseTimer);
63  {
64  bool success = false;
65  int failure_counter = 0;
66  do
67  {
68  try
69  {
70  updateEng.invert_transpose(logdetT, invMat, log_value_);
71  if (failure_counter > 0)
72  {
73  std::ostringstream success_msg;
74  success_msg << "Successful rerun matrix inversion on Rank " << OHMMS::Controller->rank() << " Thread "
75  << omp_get_thread_num() << std::endl;
76  std::cerr << success_msg.str();
77  }
78  success = true;
79  }
80  catch (const std::exception& e)
81  {
82  failure_counter++;
83  std::ostringstream err_msg;
84  err_msg << failure_counter << "th matrix inversion on Rank " << OHMMS::Controller->rank() << " Thread "
85  << omp_get_thread_num() << " which failed earlier with an error:\n " << e.what() << std::endl;
86  std::cerr << err_msg.str();
87  if (failure_counter == 1)
88  {
89  //record the bad matrix to a file at the first failure
90  std::ostringstream matfname;
91  matfname << "badmatrix.r" << OHMMS::Controller->rank() << "t" << omp_get_thread_num() << ".txt";
92  std::ofstream matfile(matfname.str().c_str(), std::ios::app);
93  matfile << std::setprecision(14) << std::scientific;
94  for (size_t i = 0; i < logdetT.rows(); i++)
95  {
96  for (size_t j = 0; j < logdetT.cols(); j++)
97  matfile << " " << logdetT[i][j];
98  matfile << std::endl;
99  }
100  }
101  }
102  } while (!success && failure_counter < 5); // try 5 times at maximum
103  if (!success)
104  throw std::runtime_error("Matrix inversion failed after " + std::to_string(failure_counter) + " attempts.\n");
105  }
106  else
107  {
108  host_inverter_.invert_transpose(logdetT, invMat, log_value_);
109  updateEng.initializeInv(psiM);
110  }
111 }
int rank() const
return the rank
Definition: Communicate.h:116
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
const DetMatInvertor matrix_inverter_kind_
selected scheme for inversion
DU_TYPE updateEng
delayed update engine
ValueMatrix psiM
inverse transpose of psiM(j,i)
DiracMatrix< QMCTraits::QTFull::ValueType > host_inverter_
slow but doesn&#39;t consume device memory
std::enable_if_t< std::is_same< T_FP, TMAT >::value > invert_transpose(const Matrix< TMAT, ALLOC1 > &amat, Matrix< TMAT, ALLOC2 > &invMat, std::complex< TREAL > &LogDet)
compute the inverse of the transpose of matrix A and its determinant value in log when T_FP and TMAT ...
Definition: DiracMatrix.h:188

◆ makeCopy()

std::unique_ptr< DiracDeterminantBase > makeCopy ( std::unique_ptr< SPOSet > &&  spo) const
overridevirtual

cloning function

Parameters
tqptarget particleset
spospo set

This interface is exposed only to SlaterDet and its derived classes can overwrite to clone itself correctly.

Implements DiracDeterminantBase.

Definition at line 758 of file DiracDeterminant.cpp.

759 {
760  return std::make_unique<DiracDeterminant<DU_TYPE>>(std::move(spo), FirstIndex, LastIndex, ndelay_,
762 }
const int FirstIndex
index of the first particle with respect to the particle set
const DetMatInvertor matrix_inverter_kind_
selected scheme for inversion
const int LastIndex
index of the last particle with respect to the particle set

◆ 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
inlineoverridevirtual

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 146 of file DiracDeterminant.h.

151  {
152  for (int iw = 0; iw < wfc_list.size(); iw++)
153  if (isAccepted[iw])
154  wfc_list[iw].acceptMove(p_list[iw], iat, safe_to_delay);
155  else
156  wfc_list[iw].restore(iat);
157  }

◆ mw_completeUpdates()

void mw_completeUpdates ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list) const
inlineoverridevirtual

complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region.

Reimplemented from WaveFunctionComponent.

Definition at line 161 of file DiracDeterminant.h.

References DiracDeterminant< DU_TYPE >::completeUpdates().

162  {
163  for (int iw = 0; iw < wfc_list.size(); iw++)
164  wfc_list[iw].completeUpdates();
165  }
void completeUpdates() override
complete all the delayed or asynchronous operations before leaving the p-by-p move region...

◆ mw_evaluateRatios()

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

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 from WaveFunctionComponent.

Definition at line 475 of file DiracDeterminant.cpp.

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

478 {
479  const size_t nw = wfc_list.size();
480 
481  RefVectorWithLeader<SPOSet> phi_list(*Phi);
482  RefVector<ValueVector> psiV_list;
483  std::vector<const ValueType*> invRow_ptr_list;
484  phi_list.reserve(nw);
485  psiV_list.reserve(nw);
486  invRow_ptr_list.reserve(nw);
487 
488  {
489  ScopedTimer local_timer(RatioTimer);
490  for (size_t iw = 0; iw < nw; iw++)
491  {
492  auto& det = wfc_list.getCastedElement<DiracDeterminant<DU_TYPE>>(iw);
493  const VirtualParticleSet& vp(vp_list[iw]);
494  const int WorkingIndex = vp.refPtcl - FirstIndex;
495  assert(WorkingIndex >= 0);
496  // If DiracDeterminant is in a valid state this copy_n is not necessary.
497  // That is at minimum a call to evaluateLog and ...
498  // std::copy_n(det.psiM[WorkingIndex], det.invRow.s.ize(), det.invRow.data());
499  // build lists
500  phi_list.push_back(*det.Phi);
501  psiV_list.push_back(det.psiV);
502  invRow_ptr_list.push_back(det.psiM[WorkingIndex]);
503  }
504  }
505 
506  {
507  ScopedTimer local_timer(SPOVTimer);
508  // Phi->isOMPoffload() requires device invRow pointers for mw_evaluateDetRatios.
509  // evaluateDetRatios only requires host invRow pointers.
510  if (Phi->isOMPoffload())
511  for (int iw = 0; iw < phi_list.size(); iw++)
512  {
513  Vector<ValueType> invRow(const_cast<ValueType*>(invRow_ptr_list[iw]), psiV_list[iw].get().size());
514  phi_list[iw].evaluateDetRatios(vp_list[iw], psiV_list[iw], invRow, ratios[iw]);
515  }
516  else
517  Phi->mw_evaluateDetRatios(phi_list, vp_list, psiV_list, invRow_ptr_list, ratios);
518  }
519 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
ValueVector invRow
the row of up-to-date inverse matrix

◆ 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
overridevirtual

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 from WaveFunctionComponent.

Definition at line 240 of file DiracDeterminant.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), and DiracDeterminant< DU_TYPE >::ratioGrad_compute().

245 {
246  {
247  ScopedTimer local_timer(SPOVGLTimer);
248  RefVectorWithLeader<SPOSet> phi_list(*Phi);
249  phi_list.reserve(wfc_list.size());
250  RefVector<ValueVector> psi_v_list;
251  psi_v_list.reserve(wfc_list.size());
252  RefVector<GradVector> dpsi_v_list;
253  dpsi_v_list.reserve(wfc_list.size());
254  RefVector<ValueVector> d2psi_v_list;
255  d2psi_v_list.reserve(wfc_list.size());
256 
257  for (WaveFunctionComponent& wfc : wfc_list)
258  {
259  auto& det = static_cast<DiracDeterminant<DU_TYPE>&>(wfc);
260  phi_list.push_back(*det.Phi);
261  psi_v_list.push_back(det.psiV);
262  dpsi_v_list.push_back(det.dpsiV);
263  d2psi_v_list.push_back(det.d2psiV);
264  }
265 
266  Phi->mw_evaluateVGL(phi_list, p_list, iat, psi_v_list, dpsi_v_list, d2psi_v_list);
267  }
268 
269  for (int iw = 0; iw < wfc_list.size(); iw++)
270  ratios[iw] = wfc_list.getCastedElement<DiracDeterminant<DU_TYPE>>(iw).ratioGrad_compute(iat, grad_new[iw]);
271 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
WaveFunctionComponent(const std::string &obj_name="")
default constructor

◆ operator=()

DiracDeterminant& operator= ( const DiracDeterminant< DU_TYPE > &  s)
delete

◆ ratio()

DiracDeterminant< DU_TYPE >::PsiValue ratio ( ParticleSet P,
int  iat 
)
overridevirtual

return the ratio only for the iat-th partcle move

Parameters
Pcurrent configuration
iatthe particle thas is being moved

Implements WaveFunctionComponent.

Definition at line 420 of file DiracDeterminant.cpp.

References qmcplusplus::simd::dot().

421 {
423  const int WorkingIndex = iat - FirstIndex;
424  assert(WorkingIndex >= 0);
425  {
426  ScopedTimer local_timer(SPOVTimer);
427  Phi->evaluateValue(P, iat, psiV);
428  }
429  {
430  ScopedTimer local_timer(RatioTimer);
431  // This is an optimization.
432  // check invRow_id against WorkingIndex to see if getInvRow() has been called
433  // This is intended to save redundant compuation in TM1 and TM3
434  if (invRow_id != WorkingIndex)
435  {
436  invRow_id = WorkingIndex;
437  updateEng.getInvRow(psiM, WorkingIndex, invRow);
438  }
439  curRatio = simd::dot(invRow.data(), psiV.data(), invRow.size());
440  }
441  return curRatio;
442 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueVector psiV
value of single-particle orbital for particle-by-particle update
const int FirstIndex
index of the first particle with respect to the particle set
int invRow_id
row id correspond to the up-to-date invRow.
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
DU_TYPE updateEng
delayed update engine
ValueMatrix psiM
inverse transpose of psiM(j,i)
ValueVector invRow
the row of up-to-date inverse matrix

◆ ratioGrad()

DiracDeterminant< DU_TYPE >::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 170 of file DiracDeterminant.cpp.

173 {
174  {
175  ScopedTimer local_timer(SPOVGLTimer);
176  Phi->evaluateVGL(P, iat, psiV, dpsiV, d2psiV);
177  }
178  return ratioGrad_compute(iat, grad_iat);
179 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueVector psiV
value of single-particle orbital for particle-by-particle update
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
PsiValue ratioGrad_compute(int iat, GradType &grad_iat)
internal function computing ratio and gradients after computing the SPOs, used by ratioGrad...

◆ ratioGrad_compute()

DiracDeterminant< DU_TYPE >::PsiValue ratioGrad_compute ( int  iat,
GradType grad_iat 
)
private

internal function computing ratio and gradients after computing the SPOs, used by ratioGrad.

Definition at line 182 of file DiracDeterminant.cpp.

References qmcplusplus::simd::dot().

Referenced by DiracDeterminant< DU_TYPE >::mw_ratioGrad().

183 {
184  ScopedTimer local_timer(RatioTimer);
185 
187  const int WorkingIndex = iat - FirstIndex;
188  assert(WorkingIndex >= 0);
189  // This is an satefy mechanism.
190  // check invRow_id against WorkingIndex to see if getInvRow() has been called already
191  // when evalGrad has not been called already or the particle id is not consistent,
192  // invRow is recomputed.
193  if (invRow_id != WorkingIndex)
194  {
195  invRow_id = WorkingIndex;
196  updateEng.getInvRow(psiM, WorkingIndex, invRow);
197  }
198  curRatio = simd::dot(invRow.data(), psiV.data(), invRow.size());
199  grad_iat += static_cast<ValueType>(static_cast<PsiValue>(1.0) / curRatio) *
200  simd::dot(invRow.data(), dpsiV.data(), invRow.size());
201  return curRatio;
202 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueVector psiV
value of single-particle orbital for particle-by-particle update
const int FirstIndex
index of the first particle with respect to the particle set
int invRow_id
row id correspond to the up-to-date invRow.
QTBase::ValueType ValueType
Definition: Configuration.h:60
DU_TYPE updateEng
delayed update engine
ValueMatrix psiM
inverse transpose of psiM(j,i)
ValueVector invRow
the row of up-to-date inverse matrix

◆ ratioGradWithSpin()

DiracDeterminant< DU_TYPE >::PsiValue ratioGradWithSpin ( ParticleSet P,
int  iat,
GradType grad_iat,
ComplexType spingrad_iat 
)
finalvirtual

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 205 of file DiracDeterminant.cpp.

References qmcplusplus::simd::dot().

209 {
210  {
211  ScopedTimer local_timer(SPOVGLTimer);
212  Phi->evaluateVGL_spin(P, iat, psiV, dpsiV, d2psiV, dspin_psiV);
213  }
214 
215  {
216  ScopedTimer local_timer(RatioTimer);
218  const int WorkingIndex = iat - FirstIndex;
219  assert(WorkingIndex >= 0);
220  // This is an optimization.
221  // check invRow_id against WorkingIndex to see if getInvRow() has been called already
222  // Some code paths call evalGrad before calling ratioGrad.
223  if (invRow_id != WorkingIndex)
224  {
225  invRow_id = WorkingIndex;
226  updateEng.getInvRow(psiM, WorkingIndex, invRow);
227  }
228  curRatio = simd::dot(invRow.data(), psiV.data(), invRow.size());
229  grad_iat += static_cast<ValueType>(static_cast<PsiValue>(1.0) / curRatio) *
230  simd::dot(invRow.data(), dpsiV.data(), invRow.size());
231 
232  spingrad_iat += static_cast<ValueType>(static_cast<PsiValue>(1.0) / curRatio) *
233  simd::dot(invRow.data(), dspin_psiV.data(), invRow.size());
234  }
235 
236  return curRatio;
237 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueVector psiV
value of single-particle orbital for particle-by-particle update
const int FirstIndex
index of the first particle with respect to the particle set
int invRow_id
row id correspond to the up-to-date invRow.
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
QTBase::ValueType ValueType
Definition: Configuration.h:60
DU_TYPE updateEng
delayed update engine
ValueMatrix psiM
inverse transpose of psiM(j,i)
ValueVector invRow
the row of up-to-date inverse matrix

◆ recompute()

void recompute ( const ParticleSet P)
overridevirtual

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 726 of file DiracDeterminant.cpp.

727 {
728  {
729  ScopedTimer local_timer(SPOVGLTimer);
731  Phi->evaluate_notranspose(P, FirstIndex, LastIndex, psiM_temp, dpsiM, d2psiM);
732  }
733 
735 
736  // invRow becomes invalid after updating the inverse matrix
737  invRow_id = -1;
738 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueMatrix d2psiM
d2psiM(i,j)
const int FirstIndex
index of the first particle with respect to the particle set
int invRow_id
row id correspond to the up-to-date invRow.
GradMatrix dpsiM
dpsiM(i,j)
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
ValueMatrix psiM
inverse transpose of psiM(j,i)
void invertPsiM(const ValueMatrix &logdetT, ValueMatrix &invMat)
invert psiM or its copies
ValueMatrix psiM_temp
psiM(j,i)

◆ 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 341 of file DiracDeterminant.cpp.

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

342 {
343  if (Bytes_in_WFBuffer == 0)
344  {
345  //add the data: inverse, gradient and laplacian
346  Bytes_in_WFBuffer = buf.current();
347  buf.add(psiM.first_address(), psiM.last_address());
349  buf.add(d2psiM.first_address(), d2psiM.last_address());
350  Bytes_in_WFBuffer = buf.current() - Bytes_in_WFBuffer;
351  // free local space
352  psiM.free();
353  dpsiM.free();
354  d2psiM.free();
355  }
356  else
357  {
358  buf.forward(Bytes_in_WFBuffer);
359 #ifndef NDEBUG
360  // this causes too much output in the legacy code.
361  // \todo turn this back on after legacy is dropped,
362  // I don't think it should print at all in the new design
363  // std::cerr << ("You really should know whether you have registered this objects data previously!, consider this an error in the unified code");
364 #endif
365  }
366  buf.add(log_value_);
367 }
ValueMatrix d2psiM
d2psiM(i,j)
GradMatrix dpsiM
dpsiM(i,j)
ValueMatrix psiM
inverse transpose of psiM(j,i)
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

◆ registerTWFFastDerivWrapper()

void registerTWFFastDerivWrapper ( const ParticleSet P,
TWFFastDerivWrapper twf 
) const
finalvirtual

Finds the SPOSet associated with this determinant, and registers it with WFN wrapper.

Reimplemented from DiracDeterminantBase.

Definition at line 410 of file DiracDeterminant.cpp.

References ParticleSet::getGroupID(), and qmcplusplus::twf.

411 {
412  twf.addGroup(P, P.getGroupID(FirstIndex), Phi.get());
413 }
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ 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 785 of file DiracDeterminant.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedLeader(), and DiracDeterminantBase::Phi.

787 {
788  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminant<DU_TYPE>>();
789  RefVectorWithLeader<SPOSet> phi_list(*wfc_leader.Phi);
790  for (WaveFunctionComponent& wfc : wfc_list)
791  {
792  auto& det = static_cast<DiracDeterminant<DU_TYPE>&>(wfc);
793  phi_list.push_back(*det.Phi);
794  }
795  wfc_leader.Phi->releaseResource(collection, phi_list);
796 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
WaveFunctionComponent(const std::string &obj_name="")
default constructor

◆ resize()

void resize ( int  nel,
int  morb 
)
protected

reset the size: with the number of particles and number of orbtials

Definition at line 116 of file DiracDeterminant.cpp.

References qmcplusplus::ewaldref::DIM.

Referenced by DiracDeterminant< DU_TYPE >::DiracDeterminant().

117 {
118  if (Bytes_in_WFBuffer > 0)
119  throw std::runtime_error("DiracDeterimnant just went out of sync with buffer");
120  int norb = morb;
121  if (norb <= 0)
122  norb = nel; // for morb == -1 (default)
123  updateEng.resize(norb, ndelay_);
124  psiM.resize(nel, norb);
125  dpsiM.resize(nel, norb);
126  d2psiM.resize(nel, norb);
127  psiV.resize(norb);
128  invRow.resize(norb);
129  psiM_temp.resize(nel, norb);
130 
131  dpsiV.resize(NumOrbitals);
132  dspin_psiV.resize(NumOrbitals);
133  d2psiV.resize(NumOrbitals);
134  FirstAddressOfdV = &(dpsiM(0, 0)[0]); //(*dpsiM.begin())[0]);
136 }
ValueMatrix d2psiM
d2psiM(i,j)
ValueVector psiV
value of single-particle orbital for particle-by-particle update
GradMatrix dpsiM
dpsiM(i,j)
DU_TYPE updateEng
delayed update engine
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
ValueMatrix psiM
inverse transpose of psiM(j,i)
ValueMatrix psiM_temp
psiM(j,i)
const int NumPtcls
number of particles which belong to this Dirac determinant
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.
ValueVector invRow
the row of up-to-date inverse matrix

◆ resizeScratchObjectsForIonDerivs()

void resizeScratchObjectsForIonDerivs ( )
private

Resize all temporary arrays required for force computation.

Definition at line 544 of file DiracDeterminant.cpp.

545 {
553 }
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
GradMatrix grad_source_psiM
Used for force computations.
const int NumPtcls
number of particles which belong to this Dirac determinant

◆ restore()

void restore ( int  iat)
overridevirtual

move was rejected.

copy the real container to the temporary to move on

Implements WaveFunctionComponent.

Definition at line 305 of file DiracDeterminant.cpp.

306 {
307  curRatio = 1.0;
308 }

◆ updateAfterSweep()

void updateAfterSweep ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
)

Definition at line 320 of file DiracDeterminant.cpp.

References qmcplusplus::simd::dot(), and qmcplusplus::dot().

323 {
324  if (UpdateMode == ORB_PBYP_RATIO)
325  { //need to compute dpsiM and d2psiM. Do not touch psiM!
326  ScopedTimer local_timer(SPOVGLTimer);
327  Phi->evaluate_notranspose(P, FirstIndex, LastIndex, psiM_temp, dpsiM, d2psiM);
329  }
330 
331  for (size_t i = 0, iat = FirstIndex; i < NumPtcls; ++i, ++iat)
332  {
333  mValueType dot_temp = simd::dot(psiM[i], d2psiM[i], NumOrbitals);
334  mGradType rv = simd::dot(psiM[i], dpsiM[i], NumOrbitals);
335  G[iat] += rv;
336  L[iat] += dot_temp - dot(rv, rv);
337  }
338 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ValueMatrix d2psiM
d2psiM(i,j)
const int FirstIndex
index of the first particle with respect to the particle set
TinyVector< mValueType, DIM > mGradType
GradMatrix dpsiM
dpsiM(i,j)
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
ValueMatrix psiM
inverse transpose of psiM(j,i)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
ValueMatrix psiM_temp
psiM(j,i)
const int NumPtcls
number of particles which belong to this Dirac determinant
QMCTraits::QTFull::ValueType mValueType

◆ updateBuffer()

DiracDeterminant< DU_TYPE >::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 383 of file DiracDeterminant.cpp.

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

386 {
387  evaluateGL(P, P.G, P.L, fromscratch);
388  {
389  ScopedTimer local_timer(BufferTimer);
390  buf.forward(Bytes_in_WFBuffer);
391  buf.put(log_value_);
392  }
393  return log_value_;
394 }
LogValue evaluateGL(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch) override
compute gradients and laplacian of the TWF with respect to each particle.
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.

Member Data Documentation

◆ curRatio

PsiValue curRatio

Definition at line 257 of file DiracDeterminant.h.

◆ d2psiM

ValueMatrix d2psiM

d2psiM(i,j) $= \nabla_i^2 \psi_j({\bf r}_i)$

Definition at line 228 of file DiracDeterminant.h.

◆ d2psiV

ValueVector d2psiV

Definition at line 242 of file DiracDeterminant.h.

◆ dpsiM

GradMatrix dpsiM

dpsiM(i,j) $= \nabla_i \psi_j({\bf r}_i)$

Definition at line 225 of file DiracDeterminant.h.

◆ dpsiV

GradVector dpsiV

Definition at line 241 of file DiracDeterminant.h.

◆ dspin_psiV

ValueVector dspin_psiV

Definition at line 240 of file DiracDeterminant.h.

◆ FirstAddressOfdV

ValueType* FirstAddressOfdV

Definition at line 258 of file DiracDeterminant.h.

◆ grad_grad_source_psiM

HessMatrix grad_grad_source_psiM

Definition at line 232 of file DiracDeterminant.h.

◆ grad_lapl_source_psiM

GradMatrix grad_lapl_source_psiM

Definition at line 231 of file DiracDeterminant.h.

◆ grad_phi_alpha_Minv

HessMatrix grad_phi_alpha_Minv

Definition at line 236 of file DiracDeterminant.h.

◆ grad_phi_Minv

GradMatrix grad_phi_Minv

Definition at line 234 of file DiracDeterminant.h.

◆ grad_source_psiM

GradMatrix grad_source_psiM

Used for force computations.

Definition at line 231 of file DiracDeterminant.h.

◆ host_inverter_

DiracMatrix<QMCTraits::QTFull::ValueType> host_inverter_
private

slow but doesn't consume device memory

Definition at line 263 of file DiracDeterminant.h.

◆ invRow

ValueVector invRow

the row of up-to-date inverse matrix

Definition at line 248 of file DiracDeterminant.h.

◆ invRow_id

int invRow_id

row id correspond to the up-to-date invRow.

[0 norb), invRow is ready; -1, invRow is not valid. This id is set after calling getInvRow indicating invRow has been prepared for the invRow_id row ratioGrad checks if invRow_id is consistent. If not, invRow needs to be recomputed. acceptMove and completeUpdates mark invRow invalid by setting invRow_id to -1

Definition at line 255 of file DiracDeterminant.h.

◆ lapl_phi_Minv

ValueMatrix lapl_phi_Minv

Definition at line 235 of file DiracDeterminant.h.

◆ LastAddressOfdV

ValueType* LastAddressOfdV

Definition at line 259 of file DiracDeterminant.h.

◆ matrix_inverter_kind_

const DetMatInvertor matrix_inverter_kind_
private

selected scheme for inversion

Definition at line 266 of file DiracDeterminant.h.

◆ ndelay_

const int ndelay_
protected

Definition at line 40 of file DiracDeterminant.h.

◆ phi_alpha_Minv

GradMatrix phi_alpha_Minv

Definition at line 234 of file DiracDeterminant.h.

◆ psiM

inverse transpose of psiM(j,i) $= \psi_j({\bf r}_i)$

Definition at line 219 of file DiracDeterminant.h.

Referenced by DiracDeterminant< DU_TYPE >::getPsiMinv().

◆ psiM_temp

ValueMatrix psiM_temp

psiM(j,i) $= \psi_j({\bf r}_i)$

Definition at line 216 of file DiracDeterminant.h.

◆ psiMinv

ValueMatrix psiMinv

temporary container for testing

Definition at line 222 of file DiracDeterminant.h.

◆ psiV

value of single-particle orbital for particle-by-particle update

Definition at line 239 of file DiracDeterminant.h.

◆ updateEng

DU_TYPE updateEng

delayed update engine

Definition at line 245 of file DiracDeterminant.h.


The documentation for this class was generated from the following files: