QMCPACK
MultiDiracDeterminant Class Reference
+ Inheritance diagram for MultiDiracDeterminant:
+ Collaboration diagram for MultiDiracDeterminant:

Classes

struct  MultiDiracDetMultiWalkerResource
 

Public Types

template<typename DT >
using OffloadVector = Vector< DT, OffloadPinnedAllocator< DT > >
 
template<typename DT >
using UnpinnedOffloadVector = Vector< DT, OffloadAllocator< DT > >
 
template<typename DT >
using OffloadMatrix = Matrix< DT, OffloadPinnedAllocator< DT > >
 
template<typename DT >
using UnpinnedOffloadMatrix = Matrix< DT, OffloadAllocator< DT > >
 
using ValueVector = SPOSet::ValueVector
 
using ValueMatrix = SPOSet::ValueMatrix
 
- 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

 MultiDiracDeterminant (std::unique_ptr< SPOSet > &&spos, bool spinor, int first, int nel)
 constructor More...
 
 ~MultiDiracDeterminant () override
 default destructor More...
 
 MultiDiracDeterminant (const MultiDiracDeterminant &s)
 copy constructor More...
 
MultiDiracDeterminantoperator= (const MultiDiracDeterminant &s)=delete
 
std::unique_ptr< SPOSetclonePhi () const
 return a clone of Phi More...
 
SPOSetPtr getPhi ()
 
std::string getClassName () const override
 return class name More...
 
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) override
 check out variational optimizable variables More...
 
void buildOptVariables (std::vector< size_t > &C2node)
 create optimizable orbital rotation parameters More...
 
int build_occ_vec (const OffloadVector< int > &data, const size_t nel, const size_t nmo, std::vector< int > &occ_vec)
 helper function to buildOptVariables More...
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi, const MultiDiracDeterminant &pseudo_dn, const ValueType &psiCurrent, const std::vector< ValueType > &Coeff, const std::vector< size_t > &C2node_up, const std::vector< size_t > &C2node_dn)
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, const MultiDiracDeterminant &pseudo_dn, const PsiValue &psiCurrent, const std::vector< ValueType > &Coeff, const std::vector< size_t > &C2node_up, const std::vector< size_t > &C2node_dn)
 
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 acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 move was accepted, update the real container More...
 
void restore (int iat) override
 move was rejected. More...
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< MultiDiracDeterminant > &wfc_list) const
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< MultiDiracDeterminant > &wfc_list) const
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const override
 make clone More...
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
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...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch More...
 
ValueType evaluate (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)
 
void createDetData (const int ref_det_id, const std::vector< ci_configuration2 > &configlist_unsorted, const std::vector< size_t > &C2nodes_unsorted, std::vector< size_t > &C2nodes_sorted)
 create necessary structures related to unique determinants sort configlist_unsorted by excitation level abd store the results in ciConfigList (class member) ciConfigList shouldn't change during a simulation after it is sorted here More...
 
void evaluateDetsForPtclMove (const ParticleSet &P, int iat, int refPtcl=-1)
 evaluate the value of all the unique determinants with one electron moved. More...
 
void evaluateDetsAndGradsForPtclMove (const ParticleSet &P, int iat)
 evaluate the value and gradients of all the unique determinants with one electron moved. Used by the table method More...
 
void evaluateDetsAndGradsForPtclMoveWithSpin (const ParticleSet &P, int iat)
 evaluate the value and gradients of all the unique determinants with one electron moved. Used by the table method. Includes Spin Gradient data More...
 
void evaluateGrads (ParticleSet &P, int iat)
 evaluate the gradients of all the unique determinants with one electron moved. Used by the table method More...
 
void evaluateGradsWithSpin (ParticleSet &P, int iat)
 evaluate the gradients of all the unique determinants with one electron moved. Used by the table method. Includes Spin Gradient data More...
 
void evaluateForWalkerMove (const ParticleSet &P, bool fromScratch=true)
 
void evaluateForWalkerMoveWithSpin (const ParticleSet &P, bool fromScratch=true)
 
int getNumDets () const
 
int getNumPtcls () const
 
int getFirstIndex () const
 
const OffloadVector< ValueType > & getRatiosToRefDet () const
 
const OffloadVector< ValueType > & getNewRatiosToRefDet () const
 
const Matrix< GradType > & getGrads () const
 
const Matrix< GradType > & getNewGrads () const
 
const Matrix< ValueType > & getLapls () const
 
const Matrix< ValueType > & getNewLapls () const
 
const Matrix< ValueType > & getSpinGrads () const
 
const Matrix< ValueType > & getNewSpinGrads () const
 
PsiValue getRefDetRatio () const
 
LogValue getLogValueRefDet () const
 
- 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 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)
 
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 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 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 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...
 

Static Public Member Functions

static void mw_accept_rejectMove (const RefVectorWithLeader< MultiDiracDeterminant > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted)
 
static void mw_evaluateDetsForPtclMove (const RefVectorWithLeader< MultiDiracDeterminant > &det_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat)
 multi walker version of evaluateDetsForPtclMove More...
 
static void mw_evaluateDetsAndGradsForPtclMove (const RefVectorWithLeader< MultiDiracDeterminant > &det_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, UnpinnedOffloadMatrix< ValueType > &mw_grads)
 multi walker version of mw_evaluateDetsAndGradsForPtclMove More...
 
static void mw_evaluateGrads (const RefVectorWithLeader< MultiDiracDeterminant > &det_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, UnpinnedOffloadMatrix< ValueType > &mw_grads)
 multi walker version of mw_evaluateGrads More...
 

Public Attributes

NewTimerinverse_timer
 
NewTimerbuildTable_timer
 
NewTimertable2ratios_timer
 
NewTimerevalWalker_timer
 
NewTimerevalOrbValue_timer
 
NewTimerevalOrbVGL_timer
 
NewTimerupdateInverse_timer
 
NewTimercalculateRatios_timer
 
NewTimercalculateGradRatios_timer
 
NewTimerupdateRatios_timer
 
NewTimerevaluateDetsForPtclMove_timer
 
NewTimerevaluateDetsAndGradsForPtclMove_timer
 
NewTimerevaluateGrads_timer
 
NewTimeroffload_timer
 
NewTimertransferH2D_timer
 
NewTimertransferD2H_timer
 
opt_variables_type myVars
 
std::vector< std::vector< int > > lookup_tbl
 
- 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

void mw_InverseUpdateByColumn (MultiDiracDetMultiWalkerResource &mw_res, const int working_index, const OffloadVector< ValueType > &curRatio_list, const OffloadVector< ValueType *> &psiV_deviceptr_list, const OffloadVector< ValueType *> &psiMinv_deviceptr_list, const size_t psiMinv_rows) const
 
void mw_updateRatios_generic (const int ext_level, const size_t det_offset, const size_t data_offset, SmallMatrixDetCalculator< ValueType > &det_calculator, const OffloadVector< int > &data, const OffloadVector< RealType > &sign, const RefVector< OffloadMatrix< ValueType >> &table_matrix_list, const RefVector< OffloadVector< ValueType >> &ratios_list) const
 update ratios with respect to the reference deteriminant for a given excitation level More...
 
void mw_updateRatios_det0 (const OffloadVector< ValueType > &det0_list, const OffloadVector< ValueType *> &ratios_deviceptr_list) const
 update ratios of the reference deteriminant More...
 
template<unsigned EXT_LEVEL>
void mw_updateRatios (const size_t det_offset, const size_t data_offset, const OffloadVector< int > &data, const OffloadVector< RealType > &sign, const OffloadVector< ValueType *> &table_matrix_deviceptr_list, const size_t num_table_matrix_cols, const OffloadVector< ValueType *> &ratios_deviceptr_list) const
 update ratios with respect to the reference deteriminant for a given excitation level More...
 
void mw_buildTableMatrix_calculateRatios_impl (MultiDiracDetMultiWalkerResource &mw_res, int ref, const OffloadVector< ValueType > &det0_list, const RefVector< OffloadMatrix< ValueType >> &psiinv_list, const RefVector< OffloadMatrix< ValueType >> &psi_list, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const RefVector< OffloadMatrix< ValueType >> &table_matrix_list, const RefVector< OffloadVector< ValueType >> &ratios_list)
 Function to calculate the ratio of the excited determinant to the reference determinant in CustomizedMatrixDet following the paper by Clark et al. More...
 
void buildTableMatrix_calculateRatios_impl (int ref, ValueType det0, ValueType *restrict ratios, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, OffloadMatrix< ValueType > &table_matrix, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign)
 Function to calculate the ratio of the excited determinant to the reference determinant in CustomizedMatrixDet following the paper by Clark et al. More...
 
void buildTableMatrix_calculateRatios (int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, OffloadVector< ValueType > &ratios)
 compute the ratio of the excited determinants to the reference determinant More...
 
void mw_buildTableMatrix_calculateRatios (MultiDiracDetMultiWalkerResource &mw_res, int ref, const OffloadVector< ValueType > &det0_list, const RefVector< OffloadMatrix< ValueType >> &psiinv_list, const RefVector< OffloadMatrix< ValueType >> &psi_list, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const RefVector< OffloadMatrix< ValueType >> &table_matrix_list, const RefVector< OffloadVector< ValueType >> &ratios_list)
 
void buildTableMatrix_calculateGradRatios (int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const ValueType &det0_grad, OffloadMatrix< ValueType > &table_matrix, int dx, int iat, Matrix< GradType > &grads)
 Function to calculate the ratio of the gradients of the excited determinant to the reference determinant in CustomizedMatrixDet following the paper by Clark et al. More...
 
void mw_buildTableMatrix_calculateGradRatios (MultiDiracDetMultiWalkerResource &mw_res, int ref, int iat, int dx, int getNumDets, const OffloadVector< ValueType > &det0_grad_list, const RefVector< OffloadMatrix< ValueType >> &psiinv_list, const RefVector< OffloadMatrix< ValueType >> &psi_list, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const RefVector< OffloadVector< ValueType >> &WorkSpace_list, const RefVector< OffloadMatrix< ValueType >> &table_matrix_list, UnpinnedOffloadMatrix< ValueType > &mw_grads)
 Function to calculate the ratio of the gradients of the excited determinant to the reference determinant in CustomizedMatrixDet following the paper by Clark et al. More...
 
void buildTableMatrix_calculateRatiosValueMatrixOneParticle (int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, int iat, Matrix< ValueType > &ratios)
 
void resize ()
 reset the size: with the number of particles More...
 

Private Attributes

const std::unique_ptr< SPOSetPhi
 a set of single-particle orbitals used to fill in the values of the matrix More...
 
const int NumOrbitals
 number of single-particle orbitals which belong to this Dirac determinant More...
 
const int FirstIndex
 index of the first particle with respect to the particle set More...
 
const int NumPtcls
 number of particles which belong to this Dirac determinant More...
 
const int LastIndex
 index of the last particle with respect to the particle set More...
 
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
 use shared_ptr More...
 
std::shared_ptr< OffloadVector< size_t > > refdet_occup
 reference determinant occupation More...
 
const bool is_spinor_
 
OffloadMatrix< ValueTypepsiM
 psiM(i,j) $= \psi_j({\bf r}_i)$ TpsiM(i,j) $= psiM(j,i) $ More...
 
OffloadMatrix< ValueTypeTpsiM
 
OffloadMatrix< ValueTypepsiMinv
 inverse Dirac determinant matrix of the reference det More...
 
OffloadMatrix< ValueTypepsiMinv_temp
 
OffloadMatrix< GradTypedpsiM
 dpsiM(i,j) $= \nabla_i \psi_j({\bf r}_i)$ More...
 
OffloadMatrix< ValueTypedpsiMinv
 
OffloadMatrix< ValueTyped2psiM
 d2psiM(i,j) $= \nabla_i^2 \psi_j({\bf r}_i)$ More...
 
ValueMatrix dspin_psiM
 
OffloadVector< ValueTypepsiV
 value of single-particle orbital for particle-by-particle update More...
 
OffloadVector< ValueTypepsiV_temp
 
OffloadVector< GradTypedpsiV
 
OffloadVector< ValueTyped2psiV
 
OffloadVector< ValueTypeworkV1
 
OffloadVector< ValueTypeworkV2
 
ValueVector dspin_psiV
 
OffloadMatrix< ValueTypetable_matrix
 
OffloadVector< ValueTypeWorkSpace
 
Vector< IndexTypePivot
 
ValueTypeFirstAddressOfGrads
 
ValueTypeLastAddressOfGrads
 
ValueTypeFirstAddressOfdpsiM
 
ValueTypeLastAddressOfdpsiM
 
OffloadVector< ValueTyperatios_to_ref_
 determinant ratios with respect to the reference determinant More...
 
OffloadVector< ValueTypenew_ratios_to_ref_
 new determinant ratios with respect to the updated reference determinant upon a proposed move More...
 
ValueType curRatio
 new value of the reference determinant over the old value upon a proposed move More...
 
LogValue log_value_ref_det_
 log value of the reference determinant More...
 
Matrix< GradTypegrads
 store determinant grads (old and new) More...
 
Matrix< GradTypenew_grads
 
Matrix< ValueTypelapls
 store determinant lapls (old and new) More...
 
Matrix< ValueTypenew_lapls
 
Matrix< ValueTypespingrads
 
Matrix< ValueTypenew_spingrads
 
std::shared_ptr< OffloadVector< int > > detData
 
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
 
std::shared_ptr< OffloadVector< RealType > > DetSigns
 
std::shared_ptr< std::vector< int > > ndets_per_excitation_level_
 number of unique determinants at each excitation level (relative to reference) {1, n_singles, n_doubles, n_triples, ...} More...
 
SmallMatrixDetCalculator< ValueTypedet_calculator_
 
ResourceHandle< MultiDiracDetMultiWalkerResourcemw_res_handle_
 

Static Private Attributes

static constexpr int ReferenceDeterminant = 0
 all the unique determinants are sorted, the id of the reference det id is always 0 More...
 
static constexpr size_t MaxSmallDet = 5
 for matrices with leading dimensions <= MaxSmallDet, compute determinant with direct expansion. 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...
 

Detailed Description

Definition at line 33 of file MultiDiracDeterminant.h.

Member Typedef Documentation

◆ OffloadMatrix

Definition at line 50 of file MultiDiracDeterminant.h.

◆ OffloadVector

Definition at line 46 of file MultiDiracDeterminant.h.

◆ UnpinnedOffloadMatrix

Definition at line 52 of file MultiDiracDeterminant.h.

◆ UnpinnedOffloadVector

Definition at line 48 of file MultiDiracDeterminant.h.

◆ ValueMatrix

Definition at line 55 of file MultiDiracDeterminant.h.

◆ ValueVector

Definition at line 54 of file MultiDiracDeterminant.h.

Constructor & Destructor Documentation

◆ MultiDiracDeterminant() [1/2]

MultiDiracDeterminant ( std::unique_ptr< SPOSet > &&  spos,
bool  spinor,
int  first,
int  nel 
)

constructor

Parameters
sposthe single-particle orbital set
firstindex of the first particle
sposthe single-particle orbital set
firstindex of the first particle
spinorflag to determinane if spin arrays need to be resized and used

Definition at line 589 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::ciConfigList, MultiDiracDeterminant::detData, MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::ndets_per_excitation_level_, MultiDiracDeterminant::refdet_occup, and MultiDiracDeterminant::uniquePairs.

590  : inverse_timer(createGlobalTimer(getClassName() + "::invertRefDet")),
591  buildTable_timer(createGlobalTimer(getClassName() + "::buildTable")),
592  table2ratios_timer(createGlobalTimer(getClassName() + "::table2ratios")),
593  evalWalker_timer(createGlobalTimer(getClassName() + "::evalWalker")),
594  evalOrbValue_timer(createGlobalTimer(getClassName() + "::evalOrbValue")),
595  evalOrbVGL_timer(createGlobalTimer(getClassName() + "::evalOrbVGL")),
596  updateInverse_timer(createGlobalTimer(getClassName() + "::updateRefDetInv")),
599  updateRatios_timer(createGlobalTimer(getClassName() + "::updateRatios")),
602  evaluateGrads_timer(createGlobalTimer(getClassName() + "::evaluateGrad")),
603  offload_timer(createGlobalTimer(getClassName() + "::offload")),
604  transferH2D_timer(createGlobalTimer(getClassName() + "::transferH2D")),
605  transferD2H_timer(createGlobalTimer(getClassName() + "::transferD2H")),
606  Phi(std::move(spos)),
607  NumOrbitals(Phi->getOrbitalSetSize()),
608  FirstIndex(first),
609  NumPtcls(nel),
610  LastIndex(first + nel),
611  is_spinor_(spinor)
612 {
613  ciConfigList = std::make_shared<std::vector<ci_configuration2>>();
614  refdet_occup = std::make_shared<OffloadVector<size_t>>();
615  detData = std::make_shared<OffloadVector<int>>();
616  uniquePairs = std::make_shared<VectorSoaContainer<int, 2, OffloadPinnedAllocator<int>>>();
617  DetSigns = std::make_shared<OffloadVector<RealType>>();
618  ndets_per_excitation_level_ = std::make_shared<std::vector<int>>();
619 }
std::shared_ptr< OffloadVector< size_t > > refdet_occup
reference determinant occupation
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
std::shared_ptr< std::vector< int > > ndets_per_excitation_level_
number of unique determinants at each excitation level (relative to reference) {1, n_singles, n_doubles, n_triples, ...}
std::shared_ptr< OffloadVector< RealType > > DetSigns
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set
std::string getClassName() const override
return class name

◆ ~MultiDiracDeterminant()

~MultiDiracDeterminant ( )
overridedefault

default destructor

◆ MultiDiracDeterminant() [2/2]

copy constructor

Parameters
sexisting DiracDeterminant

This constructor makes a shallow copy of Phi. Other data members are allocated properly.

Definition at line 541 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::resize().

543  inverse_timer(s.inverse_timer),
544  buildTable_timer(s.buildTable_timer),
545  table2ratios_timer(s.table2ratios_timer),
546  evalWalker_timer(s.evalWalker_timer),
547  evalOrbValue_timer(s.evalOrbValue_timer),
548  evalOrbVGL_timer(s.evalOrbVGL_timer),
549  updateInverse_timer(s.updateInverse_timer),
550  calculateRatios_timer(s.calculateRatios_timer),
551  calculateGradRatios_timer(s.calculateGradRatios_timer),
552  updateRatios_timer(s.updateRatios_timer),
553  evaluateDetsForPtclMove_timer(s.evaluateDetsForPtclMove_timer),
554  evaluateDetsAndGradsForPtclMove_timer(s.evaluateDetsAndGradsForPtclMove_timer),
555  evaluateGrads_timer(s.evaluateGrads_timer),
556  offload_timer(s.offload_timer),
557  transferH2D_timer(s.transferH2D_timer),
558  transferD2H_timer(s.transferD2H_timer),
559  lookup_tbl(s.lookup_tbl),
560  Phi(s.Phi->makeClone()),
561  NumOrbitals(Phi->getOrbitalSetSize()),
562  FirstIndex(s.FirstIndex),
563  NumPtcls(s.NumPtcls),
564  LastIndex(s.LastIndex),
565  ciConfigList(s.ciConfigList),
566  refdet_occup(s.refdet_occup),
567  is_spinor_(s.is_spinor_),
568  detData(s.detData),
569  uniquePairs(s.uniquePairs),
570  DetSigns(s.DetSigns),
571  ndets_per_excitation_level_(s.ndets_per_excitation_level_)
572 {
573  resize();
574 }
std::shared_ptr< OffloadVector< size_t > > refdet_occup
reference determinant occupation
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
std::shared_ptr< std::vector< int > > ndets_per_excitation_level_
number of unique determinants at each excitation level (relative to reference) {1, n_singles, n_doubles, n_triples, ...}
std::shared_ptr< OffloadVector< RealType > > DetSigns
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
void resize()
reset the size: with the number of particles
const int FirstIndex
index of the first particle with respect to the particle set
WaveFunctionComponent(const std::string &obj_name="")
default constructor
const int LastIndex
index of the last particle with respect to the particle set
std::vector< std::vector< int > > lookup_tbl

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 411 of file MultiDiracDeterminant.cpp.

References Matrix< T, Alloc >::begin(), qmcplusplus::convertValueToLog(), copy(), MultiDiracDeterminant::curRatio, MultiDiracDeterminant::d2psiM, MultiDiracDeterminant::d2psiV, MultiDiracDeterminant::dpsiM, MultiDiracDeterminant::dpsiV, MultiDiracDeterminant::dspin_psiM, MultiDiracDeterminant::dspin_psiV, Matrix< T, Alloc >::end(), MultiDiracDeterminant::FirstIndex, MultiDiracDeterminant::grads, MultiDiracDeterminant::is_spinor_, ParticleSet::isSpinor(), MultiDiracDeterminant::lapls, MultiDiracDeterminant::LastIndex, MultiDiracDeterminant::log_value_ref_det_, MultiDiracDeterminant::new_grads, MultiDiracDeterminant::new_lapls, MultiDiracDeterminant::new_ratios_to_ref_, MultiDiracDeterminant::new_spingrads, MultiDiracDeterminant::NumOrbitals, WaveFunctionComponent::ORB_PBYP_PARTIAL, WaveFunctionComponent::ORB_PBYP_RATIO, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiMinv_temp, MultiDiracDeterminant::psiV, MultiDiracDeterminant::ratios_to_ref_, MultiDiracDeterminant::spingrads, MultiDiracDeterminant::TpsiM, MultiDiracDeterminant::transferH2D_timer, and WaveFunctionComponent::UpdateMode.

412 {
413  const int WorkingIndex = iat - FirstIndex;
414  assert(WorkingIndex >= 0 && WorkingIndex < LastIndex - FirstIndex);
415  assert(P.isSpinor() == is_spinor_);
416  if (curRatio == ValueType(0))
417  {
418  std::ostringstream msg;
419  msg << "MultiDiracDeterminant::acceptMove curRatio is " << curRatio << "! Report a bug." << std::endl;
420  throw std::runtime_error(msg.str());
421  }
423  curRatio = ValueType(1);
424  switch (UpdateMode)
425  {
426  case ORB_PBYP_RATIO:
428  // Ye: During acceptMove and restore, TpsiM is updated on the host, thus need to update the device copy.
429  // Ideally, this should be done directly on the device.
430  // However, acceptMove/restore are shared by both single walker and batched APIs.
431  // So the data motion must be kept consistently in all implementations.
432  // Right now in batched APIs, ratio and ratioGad implementation also doesn't have the same data motion.
433  // Thus also need a fix.
434  for (int i = 0; i < NumOrbitals; i++)
435  TpsiM(i, WorkingIndex) = psiV[i];
436  std::copy(psiV.begin(), psiV.end(), psiM[iat - FirstIndex]);
438  {
439  ScopedTimer local_timer(transferH2D_timer);
440  ratios_to_ref_.updateTo();
441  TpsiM.updateTo();
442  psiMinv.updateTo();
443  psiM.updateTo();
444  dpsiM.updateTo();
445  }
446  break;
447  case ORB_PBYP_PARTIAL:
449  for (int i = 0; i < NumOrbitals; i++)
450  TpsiM(i, WorkingIndex) = psiV[i];
452  std::copy(psiV.begin(), psiV.end(), psiM[WorkingIndex]);
453  std::copy(dpsiV.begin(), dpsiV.end(), dpsiM[WorkingIndex]);
454  std::copy(d2psiV.begin(), d2psiV.end(), d2psiM[WorkingIndex]);
455  {
456  ScopedTimer local_timer(transferH2D_timer);
457  ratios_to_ref_.updateTo();
458  TpsiM.updateTo();
459  psiMinv.updateTo();
460  psiM.updateTo();
461  dpsiM.updateTo();
462  }
463  if (is_spinor_)
464  std::copy(dspin_psiV.begin(), dspin_psiV.end(), dspin_psiM[WorkingIndex]);
465  break;
466  default:
468  for (int i = 0; i < NumOrbitals; i++)
469  TpsiM(i, WorkingIndex) = psiV[i];
470 
474  std::copy(psiV.begin(), psiV.end(), psiM[WorkingIndex]);
475  std::copy(dpsiV.begin(), dpsiV.end(), dpsiM[WorkingIndex]);
476  std::copy(d2psiV.begin(), d2psiV.end(), d2psiM[WorkingIndex]);
477  {
478  ScopedTimer local_timer(transferH2D_timer);
479  ratios_to_ref_.updateTo();
480  TpsiM.updateTo();
481  psiMinv.updateTo();
482  psiM.updateTo();
483  dpsiM.updateTo();
484  }
485  if (is_spinor_)
486  {
488  std::copy(dspin_psiV.begin(), dspin_psiV.end(), dspin_psiM[WorkingIndex]);
489  }
490  break;
491  }
492 }
Container_t::iterator begin()
Definition: OhmmsMatrix.h:89
Matrix< ValueType > lapls
store determinant lapls (old and new)
OffloadMatrix< GradType > dpsiM
dpsiM(i,j)
LogValue log_value_ref_det_
log value of the reference determinant
OffloadMatrix< ValueType > psiMinv_temp
Matrix< GradType > grads
store determinant grads (old and new)
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant
OffloadVector< ValueType > psiV
value of single-particle orbital for particle-by-particle update
QTBase::ValueType ValueType
Definition: Configuration.h:60
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
ValueType curRatio
new value of the reference determinant over the old value upon a proposed move
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
OffloadVector< ValueType > new_ratios_to_ref_
new determinant ratios with respect to the updated reference determinant upon a proposed move ...
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set
Container_t::iterator end()
Definition: OhmmsMatrix.h:90

◆ acquireResource()

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

Definition at line 655 of file MultiDiracDeterminant.cpp.

References qmcplusplus::det(), MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::dpsiM_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::dpsiMinv_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::dpsiV_deviceptr_list, RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), ResourceCollection::lendResource(), MultiDiracDeterminant::mw_res_handle_, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::psiM_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::psiMinv_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::psiMinv_temp_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::psiV_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::psiV_temp_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::resizeConstants(), MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::TpsiM_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::workV1_deviceptr_list, and MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::workV2_deviceptr_list.

657 {
658  auto& wfc_leader = wfc_list.getCastedLeader<MultiDiracDeterminant>();
659  wfc_leader.mw_res_handle_ = collection.lendResource<MultiDiracDetMultiWalkerResource>();
660  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
661 
662  const size_t nw = wfc_list.size();
663  mw_res.resizeConstants(nw);
664 
665  auto& psiV_temp_deviceptr_list = mw_res.psiV_temp_deviceptr_list;
666  auto& psiMinv_temp_deviceptr_list = mw_res.psiMinv_temp_deviceptr_list;
667  auto& dpsiMinv_deviceptr_list = mw_res.dpsiMinv_deviceptr_list;
668  auto& workV1_deviceptr_list = mw_res.workV1_deviceptr_list;
669  auto& workV2_deviceptr_list = mw_res.workV2_deviceptr_list;
670 
671  auto& psiV_deviceptr_list = mw_res.psiV_deviceptr_list;
672  auto& dpsiV_deviceptr_list = mw_res.dpsiV_deviceptr_list;
673  auto& TpsiM_deviceptr_list = mw_res.TpsiM_deviceptr_list;
674  auto& psiM_deviceptr_list = mw_res.psiM_deviceptr_list;
675  auto& psiMinv_deviceptr_list = mw_res.psiMinv_deviceptr_list;
676  auto& dpsiM_deviceptr_list = mw_res.dpsiM_deviceptr_list;
677 
678  psiV_temp_deviceptr_list.resize(nw);
679  psiMinv_temp_deviceptr_list.resize(nw);
680  dpsiMinv_deviceptr_list.resize(nw);
681  workV1_deviceptr_list.resize(nw);
682  workV2_deviceptr_list.resize(nw);
683 
684  psiV_deviceptr_list.resize(nw);
685  dpsiV_deviceptr_list.resize(nw);
686  TpsiM_deviceptr_list.resize(nw);
687  psiM_deviceptr_list.resize(nw);
688  psiMinv_deviceptr_list.resize(nw);
689  dpsiM_deviceptr_list.resize(nw);
690 
691  for (size_t iw = 0; iw < nw; iw++)
692  {
693  auto& det = wfc_list.getCastedElement<MultiDiracDeterminant>(iw);
694  psiV_temp_deviceptr_list[iw] = det.psiV_temp.device_data();
695  psiMinv_temp_deviceptr_list[iw] = det.psiMinv_temp.device_data();
696  dpsiMinv_deviceptr_list[iw] = det.dpsiMinv.device_data();
697  workV1_deviceptr_list[iw] = det.workV1.device_data();
698  workV2_deviceptr_list[iw] = det.workV2.device_data();
699 
700  psiV_deviceptr_list[iw] = det.psiV.device_data();
701  dpsiV_deviceptr_list[iw] = det.dpsiV.device_data();
702  TpsiM_deviceptr_list[iw] = det.TpsiM.device_data();
703  psiM_deviceptr_list[iw] = det.psiM.device_data();
704  psiMinv_deviceptr_list[iw] = det.psiMinv.device_data();
705  dpsiM_deviceptr_list[iw] = det.dpsiM.device_data();
706  }
707 
708  psiV_temp_deviceptr_list.updateTo();
709  psiMinv_temp_deviceptr_list.updateTo();
710  dpsiMinv_deviceptr_list.updateTo();
711  workV1_deviceptr_list.updateTo();
712  workV2_deviceptr_list.updateTo();
713 
714  psiV_deviceptr_list.updateTo();
715  dpsiV_deviceptr_list.updateTo();
716  TpsiM_deviceptr_list.updateTo();
717  psiM_deviceptr_list.updateTo();
718  psiMinv_deviceptr_list.updateTo();
719  dpsiM_deviceptr_list.updateTo();
720 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
MultiDiracDeterminant(std::unique_ptr< SPOSet > &&spos, bool spinor, int first, int nel)
constructor

◆ build_occ_vec()

int build_occ_vec ( const OffloadVector< int > &  data,
const size_t  nel,
const size_t  nmo,
std::vector< int > &  occ_vec 
)

helper function to buildOptVariables

Definition at line 834 of file MultiDiracDeterminant.cpp.

References Vector< T, Alloc >::size().

Referenced by MultiDiracDeterminant::buildOptVariables().

838 {
839  size_t it = 0;
840  int count = 0; //number of determinants
841  while (it < data.size())
842  {
843  int k = data[it]; // number of excitations with respect to the reference matrix
844  if (count == 0)
845  {
846  it += 3 * k + 1;
847  count++;
848  }
849  else
850  {
851  for (int i = 0; i < k; i++)
852  {
853  //for determining active orbitals
854  occ_vec[data[it + 1 + i]]++;
855  occ_vec[data[it + 1 + k + i]]++;
856  }
857  it += 3 * k + 1;
858  count++;
859  }
860  }
861  return count;
862 }

◆ buildOptVariables()

void buildOptVariables ( std::vector< size_t > &  C2node)

create optimizable orbital rotation parameters

Definition at line 771 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::build_occ_vec(), RotatedSPOs::buildOptVariables(), MultiDiracDeterminant::detData, MultiDiracDeterminant::isOptimizable(), MultiDiracDeterminant::lookup_tbl, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, and MultiDiracDeterminant::Phi.

772 {
773  if (!isOptimizable())
774  return;
775 
776  const size_t nel = NumPtcls;
777  const size_t nmo = NumOrbitals;
778  //a vector in which the element's index value correspond to Molecular Orbitals.
779  //The element value at an index indicates how many times an electron is excited from or to that orbital in the Multi-Slater expansion i.e the indices with non-zero elements are active space orbitals
780  std::vector<int> occupancy_vector(nmo, 0);
781 
782  // Function to fill occupancy_vectors and also return number of unique determinants
783  const size_t unique_dets = build_occ_vec(*detData, nel, nmo, occupancy_vector);
784 
785  // When calculating the parameter derivative of the Multi-Slater component of the wavefunction, each unique deterimant can contribute multiple times.
786  // The lookup_tbls are used so that a parameter derivative of a unique determinant is only done once and then scaled according to how many times it appears in the Multi-Slater expansion
787  lookup_tbl.resize(unique_dets);
788  //construct lookup table
789  for (int i(0); i < C2node.size(); i++)
790  {
791  lookup_tbl[C2node[i]].push_back(i);
792  }
793 
794  // create active rotation parameter indices
795  std::vector<std::pair<int, int>> m_act_rot_inds;
796  std::vector<std::pair<int, int>> other_rot_inds;
797 
798  for (int i = 0; i < nmo; i++)
799  for (int j = i + 1; j < nmo; j++)
800  {
801  bool core_i(!occupancy_vector[i] and i <= nel - 1); // true if orbital i is a 'core' orbital
802  bool core_j(!occupancy_vector[j] and j <= nel - 1); // true if orbital j is a 'core' orbital
803  bool virt_i(!occupancy_vector[i] and i > nel - 1); // true if orbital i is a 'virtual' orbital
804  bool virt_j(!occupancy_vector[j] and j > nel - 1); // true if orbital j is a 'virtual' orbital
805  if (!((core_i and core_j) or (virt_i and virt_j)))
806  {
807  m_act_rot_inds.push_back(
808  std::pair<
809  int,
810  int>(i,
811  j)); // orbital rotation parameter accepted as long as rotation isn't core-core or virtual-virtual
812  }
813  else
814  {
815  other_rot_inds.push_back(std::pair<int, int>(i, j));
816  }
817  }
818 
819  std::vector<std::pair<int, int>> full_rot_inds;
820 
821  // Copy the adjustable rotations first
822  full_rot_inds = m_act_rot_inds;
823  // Add the other rotations at the end
824  full_rot_inds.insert(full_rot_inds.end(), other_rot_inds.begin(), other_rot_inds.end());
825 
826 
827 #ifndef QMC_COMPLEX
828  RotatedSPOs* rot_spo = dynamic_cast<RotatedSPOs*>(Phi.get());
829  if (rot_spo)
830  rot_spo->buildOptVariables(m_act_rot_inds, full_rot_inds);
831 #endif
832 }
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
int build_occ_vec(const OffloadVector< int > &data, const size_t nel, const size_t nmo, std::vector< int > &occ_vec)
helper function to buildOptVariables
bool isOptimizable() const final
if true, this contains optimizable components
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
std::vector< std::vector< int > > lookup_tbl

◆ buildTableMatrix_calculateGradRatios()

void buildTableMatrix_calculateGradRatios ( int  ref,
const OffloadMatrix< ValueType > &  psiinv,
const OffloadMatrix< ValueType > &  psi,
const OffloadVector< int > &  data,
const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &  pairs,
const OffloadVector< RealType > &  sign,
const ValueType det0_grad,
OffloadMatrix< ValueType > &  table_matrix,
int  dx,
int  iat,
Matrix< GradType > &  grads 
)
private

Function to calculate the ratio of the gradients of the excited determinant to the reference determinant in CustomizedMatrixDet following the paper by Clark et al.

JCP 135(24), 244105

Parameters
refID of the reference determinant
psiinv
psi
data(Shared by all determinants)
pairsis the number of unique determinants (std::pair[Nb_unique_alpha][Nb_unique_beta]) (Shared by all determinants)
sign(Shared by all determinants)
det0_gradgradient value taking RatioGrad/curRatio
table_matrixstores all the dot products between 2 determinants (I,J)
dxdimension (OHMMS_DIM)
iatatom ID
gradsreturned computed gradients

Definition at line 248 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateRatios_impl(), MultiDiracDeterminant::calculateGradRatios_timer, MultiDiracDeterminant::getNumDets(), MultiDiracDeterminant::grads, sign(), MultiDiracDeterminant::table_matrix, and MultiDiracDeterminant::WorkSpace.

Referenced by MultiDiracDeterminant::evaluateDetsAndGradsForPtclMove(), MultiDiracDeterminant::evaluateDetsAndGradsForPtclMoveWithSpin(), MultiDiracDeterminant::evaluateForWalkerMove(), MultiDiracDeterminant::evaluateForWalkerMoveWithSpin(), MultiDiracDeterminant::evaluateGrads(), and MultiDiracDeterminant::evaluateGradsWithSpin().

260 {
262  buildTableMatrix_calculateRatios_impl(ref, det0_grad, WorkSpace.data(), psiinv, psi, table_matrix, data, pairs, sign);
263  for (size_t count = 0; count < getNumDets(); ++count)
264  grads(count, iat)[dx] = WorkSpace[count];
265 }
Matrix< GradType > grads
store determinant grads (old and new)
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
void buildTableMatrix_calculateRatios_impl(int ref, ValueType det0, ValueType *restrict ratios, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, OffloadMatrix< ValueType > &table_matrix, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign)
Function to calculate the ratio of the excited determinant to the reference determinant in Customized...
OffloadVector< ValueType > WorkSpace
double sign(double x)
Definition: Standard.h:73
OffloadMatrix< ValueType > table_matrix

◆ buildTableMatrix_calculateRatios()

void buildTableMatrix_calculateRatios ( int  ref,
const OffloadMatrix< ValueType > &  psiinv,
const OffloadMatrix< ValueType > &  psi,
const OffloadVector< int > &  data,
const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &  pairs,
const OffloadVector< RealType > &  sign,
OffloadMatrix< ValueType > &  table_matrix,
OffloadVector< ValueType > &  ratios 
)
private

compute the ratio of the excited determinants to the reference determinant

Parameters
ratiosthe output.

Definition at line 211 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateRatios_impl(), MultiDiracDeterminant::calculateRatios_timer, Vector< T, Alloc >::data(), sign(), and MultiDiracDeterminant::table_matrix.

Referenced by MultiDiracDeterminant::evaluateDetsAndGradsForPtclMove(), MultiDiracDeterminant::evaluateDetsAndGradsForPtclMoveWithSpin(), MultiDiracDeterminant::evaluateDetsForPtclMove(), MultiDiracDeterminant::evaluateForWalkerMove(), and MultiDiracDeterminant::evaluateForWalkerMoveWithSpin().

220 {
221  ScopedTimer local_timer(calculateRatios_timer);
222  buildTableMatrix_calculateRatios_impl(ref, ValueType(1), ratios.data(), psiinv, psi, table_matrix, data, pairs, sign);
223 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
void buildTableMatrix_calculateRatios_impl(int ref, ValueType det0, ValueType *restrict ratios, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, OffloadMatrix< ValueType > &table_matrix, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign)
Function to calculate the ratio of the excited determinant to the reference determinant in Customized...
QTBase::ValueType ValueType
Definition: Configuration.h:60
double sign(double x)
Definition: Standard.h:73
OffloadMatrix< ValueType > table_matrix

◆ buildTableMatrix_calculateRatios_impl()

void buildTableMatrix_calculateRatios_impl ( int  ref,
ValueType  det0,
ValueType *restrict  ratios,
const OffloadMatrix< ValueType > &  psiinv,
const OffloadMatrix< ValueType > &  psi,
OffloadMatrix< ValueType > &  table_matrix,
const OffloadVector< int > &  data,
const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &  pairs,
const OffloadVector< RealType > &  sign 
)
private

Function to calculate the ratio of the excited determinant to the reference determinant in CustomizedMatrixDet following the paper by Clark et al.

shared function used by buildTableMatrix_calculateRatios

JCP 135(24), 244105

Parameters
refID of the reference determinant
det0take ValueType(1) for the value or RatioGrad/curRatio for the gradients
ratiosreturned computed ratios
psiinv
psi
table_matrixstores all the dot products between 2 determinants (I,J)
data(Shared by all determinants)
pairsis the number of unique determinants (std::pair[Nb_unique_alpha][Nb_unique_beta]) (Shared by all determinants)
sign(Shared by all determinants)

Definition at line 29 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTable_timer, qmcplusplus::calcSmallDeterminant(), Vector< T, Alloc >::data(), MultiDiracDeterminant::det_calculator_, qmcplusplus::simd::dot(), SmallMatrixDetCalculator< T >::evaluate(), Matrix< T, Alloc >::extent(), I, qmcplusplus::Units::energy::J, MultiDiracDeterminant::MaxSmallDet, qmcplusplus::n, qmcplusplus::Units::second, sign(), MultiDiracDeterminant::table2ratios_timer, and MultiDiracDeterminant::table_matrix.

Referenced by MultiDiracDeterminant::buildTableMatrix_calculateGradRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatios(), and MultiDiracDeterminant::buildTableMatrix_calculateRatiosValueMatrixOneParticle().

39 {
40  {
42  const size_t num = psi.extent(1);
43  const size_t npairs = pairs.size();
44  //MatrixOperators::product_ABt(psiinv,psi,table_matrix);
45  const int* first = pairs.data(0);
46  const int* second = pairs.data(1);
47  for (size_t i = 0; i < npairs; ++i)
48  {
49  const int I = first[i];
50  const int J = second[i];
51  table_matrix(I, J) = simd::dot(psiinv[I], psi[J], num);
52  }
53  }
54 
55  {
57  const int* it2 = data.data();
58  const size_t nitems = sign.size();
59  const size_t nb_cols = table_matrix.cols();
60  // explore Inclusive Scan for OpenMP
61  for (size_t count = 0; count < nitems; ++count)
62  {
63  const size_t n = *it2;
64  if (count != ref)
65  ratios[count] = sign[count] * det0 *
67  : calcSmallDeterminant(n, table_matrix.data(), it2 + 1, nb_cols));
68  it2 += 3 * n + 1;
69  }
70 
71  ratios[ref] = det0;
72  }
73 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
VALUE calcSmallDeterminant(size_t n, const VALUE *table_matrix, const int *it, const size_t nb_cols)
static constexpr size_t MaxSmallDet
for matrices with leading dimensions <= MaxSmallDet, compute determinant with direct expansion...
static T evaluate(T a11, T a12, T a21, T a22)
double sign(double x)
Definition: Standard.h:73
OffloadMatrix< ValueType > table_matrix
std::complex< double > I
SmallMatrixDetCalculator< ValueType > det_calculator_

◆ buildTableMatrix_calculateRatiosValueMatrixOneParticle()

void buildTableMatrix_calculateRatiosValueMatrixOneParticle ( int  ref,
const OffloadMatrix< ValueType > &  psiinv,
const OffloadMatrix< ValueType > &  psi,
const OffloadVector< int > &  data,
const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &  pairs,
const OffloadVector< RealType > &  sign,
OffloadMatrix< ValueType > &  table_matrix,
int  iat,
Matrix< ValueType > &  ratios 
)
private

Definition at line 303 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateRatios_impl(), qmcplusplus::simd::dot(), MultiDiracDeterminant::getNumDets(), qmcplusplus::n, sign(), MultiDiracDeterminant::table_matrix, and MultiDiracDeterminant::WorkSpace.

Referenced by MultiDiracDeterminant::evaluateDetsAndGradsForPtclMoveWithSpin(), MultiDiracDeterminant::evaluateForWalkerMove(), MultiDiracDeterminant::evaluateForWalkerMoveWithSpin(), and MultiDiracDeterminant::evaluateGradsWithSpin().

313 {
314  const ValueType det0 = ratios(ref, iat);
315  buildTableMatrix_calculateRatios_impl(ref, det0, WorkSpace.data(), psiinv, psi, table_matrix, data, pairs, sign);
316  //splatt
317  for (size_t count = 0; count < getNumDets(); ++count)
318  ratios(count, iat) = WorkSpace[count];
319 #if 0
320  ValueType det0 = ratios(ref,iat);
321  int num=psi.extent(1);
322  std::vector<std::pair<int,int> >::iterator it(pairs.begin()), last(pairs.end());
323  while(it != last)
324  {
325  table_matrix((*it).first,(*it).second) = simd::dot(psiinv[(*it).first],psi[(*it).second],num);
326  it++;
327  }
328  std::vector<int>::iterator it2 = data.begin();
329  int count= 0; // number of determinants processed
330  while(it2 != data.end())
331  {
332  int n = *it2; // number of excitations
333  if(count == ref)
334  {
335  it2+=3*n+1; // number of integers used to encode the current excitation
336  count++;
337  continue;
338  }
339  ratios(count,iat) = sign[count]*det0*CustomizedMatrixDet(n,table_matrix,it2+1);
340  count++;
341  it2+=3*n+1;
342  }
343 #endif
344 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
void buildTableMatrix_calculateRatios_impl(int ref, ValueType det0, ValueType *restrict ratios, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, OffloadMatrix< ValueType > &table_matrix, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign)
Function to calculate the ratio of the excited determinant to the reference determinant in Customized...
QTBase::ValueType ValueType
Definition: Configuration.h:60
OffloadVector< ValueType > WorkSpace
double sign(double x)
Definition: Standard.h:73
OffloadMatrix< ValueType > table_matrix

◆ 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 157 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::Phi.

158  {
159  if (Phi->isOptimizable())
160  Phi->checkOutVariables(active);
161  }
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ clonePhi()

std::unique_ptr< SPOSet > clonePhi ( ) const

return a clone of Phi

Definition at line 576 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::Phi.

576 { return Phi->makeClone(); }
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ 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 384 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::d2psiM, MultiDiracDeterminant::dspin_psiM, Matrix< T, Alloc >::first_address(), MultiDiracDeterminant::FirstAddressOfdpsiM, MultiDiracDeterminant::FirstAddressOfGrads, PooledMemory< T_scalar, Alloc >::get(), MultiDiracDeterminant::is_spinor_, ParticleSet::isSpinor(), MultiDiracDeterminant::lapls, Matrix< T, Alloc >::last_address(), MultiDiracDeterminant::LastAddressOfdpsiM, MultiDiracDeterminant::LastAddressOfGrads, MultiDiracDeterminant::log_value_ref_det_, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiMinv_temp, MultiDiracDeterminant::ratios_to_ref_, MultiDiracDeterminant::spingrads, and MultiDiracDeterminant::TpsiM.

385 {
386  assert(P.isSpinor() == is_spinor_);
387  buf.get(psiM.first_address(), psiM.last_address());
389  buf.get(d2psiM.first_address(), d2psiM.last_address());
390  buf.get(psiMinv.first_address(), psiMinv.last_address());
391  buf.get(log_value_ref_det_);
392  buf.get(ratios_to_ref_.first_address(), ratios_to_ref_.last_address());
394  buf.get(lapls.first_address(), lapls.last_address());
395  if (is_spinor_)
396  {
397  buf.get(dspin_psiM.first_address(), dspin_psiM.last_address());
399  }
400  // only used with ORB_PBYP_ALL,
402  int n1 = psiM.extent(0);
403  int n2 = psiM.extent(1);
404  for (int i = 0; i < n1; i++)
405  for (int j = 0; j < n2; j++)
406  TpsiM(j, i) = psiM(i, j);
407 }
Matrix< ValueType > lapls
store determinant lapls (old and new)
pointer last_address()
Definition: OhmmsMatrix.h:209
LogValue log_value_ref_det_
log value of the reference determinant
OffloadMatrix< ValueType > psiMinv_temp
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
pointer first_address()
Definition: OhmmsMatrix.h:204
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)

◆ createDetData()

void createDetData ( const int  ref_det_id,
const std::vector< ci_configuration2 > &  configlist_unsorted,
const std::vector< size_t > &  C2nodes_unsorted,
std::vector< size_t > &  C2nodes_sorted 
)

create necessary structures related to unique determinants sort configlist_unsorted by excitation level abd store the results in ciConfigList (class member) ciConfigList shouldn't change during a simulation after it is sorted here

Parameters
ref_det_idid of the reference determinant before sorting
configlist_unsortedconfig list to be loaded.
C2nodes_unsortedmapping from overall det index to unique det (configlist_unsorted) index
C2nodes_sortedmapping from overall det index to unique det (ciConfigList) index

Definition at line 36 of file MultiDiracDeterminant.cpp.

References qmcplusplus::app_log(), MultiDiracDeterminant::ciConfigList, MultiDiracDeterminant::detData, MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::ndets_per_excitation_level_, MultiDiracDeterminant::NumPtcls, MultiDiracDeterminant::refdet_occup, MultiDiracDeterminant::resize(), qmcplusplus::Units::second, sign(), MultiDiracDeterminant::transferH2D_timer, and MultiDiracDeterminant::uniquePairs.

40 {
41  auto& ref = configlist_unsorted[ref_det_id];
42  auto& configlist_sorted = *ciConfigList;
43  auto& data = *detData;
44  auto& pairs = *uniquePairs;
45  auto& sign = *DetSigns;
46  auto& ndets_per_excitation_level = *ndets_per_excitation_level_;
47 
48  const size_t nci = configlist_unsorted.size();
49  std::vector<std::pair<int, int>> pairs_local;
50 
51  size_t nex_max = 0;
52  std::vector<size_t> pos(NumPtcls);
53  std::vector<size_t> ocp(NumPtcls);
54  std::vector<size_t> uno(NumPtcls);
55  // map key is exc. lvl
56  std::map<int, std::vector<int>> dataMap;
57  std::map<int, std::vector<int>> sortMap;
58  std::vector<RealType> tmp_sign(nci, 0);
59  for (size_t i = 0; i < nci; i++)
60  {
61  size_t nex;
62  tmp_sign[i] = ref.calculateExcitations(configlist_unsorted[i], nex, pos, ocp, uno);
63  nex_max = std::max(nex, nex_max);
64  dataMap[nex].push_back(nex);
65  sortMap[nex].push_back(i);
66  for (int k = 0; k < nex; k++)
67  dataMap[nex].push_back(pos[k]);
68  for (int k = 0; k < nex; k++)
69  dataMap[nex].push_back(uno[k]);
70  for (int k = 0; k < nex; k++)
71  dataMap[nex].push_back(ocp[k]);
72  // determine unique pairs, to avoid redundant calculation of matrix elements
73  // if storing the entire MOxMO matrix is too much, then make an array and a mapping to it.
74  // is there an easier way??
75  for (int k1 = 0; k1 < nex; k1++)
76  for (int k2 = 0; k2 < nex; k2++)
77  {
78  // std::pair<int,int> temp(ocp[k1],uno[k2]);
79  std::pair<int, int> temp(pos[k1], uno[k2]);
80  if (find(pairs_local.begin(), pairs_local.end(), temp) == pairs_local.end()) //pair is new
81  pairs_local.push_back(temp);
82  }
83  }
84  pairs.resize(pairs_local.size());
85  int* first = pairs.data(0);
86  int* second = pairs.data(1);
87 
88  for (size_t i = 0; i < pairs_local.size(); i++)
89  {
90  first[i] = pairs_local[i].first;
91  second[i] = pairs_local[i].second;
92  }
93 
94 
95  app_log() << "Number of terms in pairs array: " << pairs.size() << std::endl;
96  ndets_per_excitation_level.resize(nex_max + 1, 0);
97  //reorder configs and det data
98  std::vector<size_t> det_idx_order; // old indices in new order
99  std::vector<size_t> det_idx_reverse(nci, 0); // new indices in old order
100 
101  // populate data, ordered by exc. lvl.
102  // make mapping from new to old det idx
103  std::vector<int> data_local;
104  data_local.clear();
105  data.clear();
106 
107  for (const auto& [nex, det_idx_old] : sortMap)
108  {
109  data_local.insert(data_local.end(), dataMap[nex].begin(), dataMap[nex].end());
110  det_idx_order.insert(det_idx_order.end(), det_idx_old.begin(), det_idx_old.end());
111  ndets_per_excitation_level[nex] = det_idx_old.size();
112  }
113  data.resize(data_local.size());
114  for (size_t i = 0; i < data_local.size(); i++)
115  data[i] = data_local[i];
116 
117  assert(det_idx_order.size() == nci);
118 
119  // make reverse mapping (old to new) and reorder confgList by exc. lvl.
120  configlist_sorted.resize(nci);
121  sign.resize(nci);
122  for (size_t i = 0; i < nci; i++)
123  {
124  det_idx_reverse[det_idx_order[i]] = i;
125  configlist_sorted[i] = configlist_unsorted[det_idx_order[i]];
126  sign[i] = tmp_sign[det_idx_order[i]];
127  }
128 
129  auto& refdet_occup_ref(*refdet_occup);
130  refdet_occup_ref.resize(NumPtcls);
131  for (size_t i = 0; i < NumPtcls; i++)
132  refdet_occup_ref[i] = configlist_unsorted[ref_det_id].occup[i];
133 
134  {
135  ScopedTimer local_timer(transferH2D_timer);
136  sign.updateTo();
137  pairs.updateTo();
138  data.updateTo();
139  refdet_occup_ref.updateTo();
140  }
141  // update C2nodes for new det ordering
142  C2nodes_sorted.resize(C2nodes_unsorted.size());
143  for (int i = 0; i < C2nodes_unsorted.size(); i++)
144  C2nodes_sorted[i] = det_idx_reverse[C2nodes_unsorted[i]];
145 
146  /*
147  std::cout <<"ref: " <<ref << std::endl;
148  std::cout <<"list: " << std::endl;
149  for(int i=0; i<confgList.size(); i++)
150  std::cout <<confgList[i] << std::endl;
151 
152  std::cout <<"pairs: " << std::endl;
153  for(int i=0; i<pairs.size(); i++)
154  std::cout <<pairs[i].first <<" " <<pairs[i].second << std::endl;
155  */
156 
157  // make sure internal objects depending on the number of unique determinants are resized
158  resize();
159 }
std::shared_ptr< OffloadVector< size_t > > refdet_occup
reference determinant occupation
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
std::ostream & app_log()
Definition: OutputManager.h:65
std::shared_ptr< std::vector< int > > ndets_per_excitation_level_
number of unique determinants at each excitation level (relative to reference) {1, n_singles, n_doubles, n_triples, ...}
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::shared_ptr< OffloadVector< RealType > > DetSigns
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
double sign(double x)
Definition: Standard.h:73
void resize()
reset the size: with the number of particles

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 650 of file MultiDiracDeterminant.cpp.

References ResourceCollection::addResource().

651 {
652  collection.addResource(std::make_unique<MultiDiracDetMultiWalkerResource>());
653 }

◆ 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 231 of file MultiDiracDeterminant.h.

References APP_ABORT.

232  {
233  APP_ABORT(" MultiDiracDeterminant: This should not be called. \n");
234  return GradType();
235  }
QTBase::GradType GradType
Definition: Configuration.h:62
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ evaluate()

ValueType evaluate ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
)
inline

Definition at line 251 of file MultiDiracDeterminant.h.

References APP_ABORT.

252  {
253  APP_ABORT(" MultiDiracDeterminant: This should not be called. \n");
254  return ValueType();
255  }
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

◆ evaluateDerivatives() [1/2]

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

Definition at line 168 of file MultiDiracDeterminant.h.

172  {}

◆ evaluateDerivatives() [2/2]

void evaluateDerivatives ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi,
const MultiDiracDeterminant pseudo_dn,
const ValueType psiCurrent,
const std::vector< ValueType > &  Coeff,
const std::vector< size_t > &  C2node_up,
const std::vector< size_t > &  C2node_dn 
)

Definition at line 865 of file MultiDiracDeterminant.cpp.

References Matrix< T, Alloc >::cols(), MultiDiracDeterminant::d2psiM, Matrix< T, Alloc >::data(), Vector< T, Alloc >::data(), MultiDiracDeterminant::detData, MultiDiracDeterminant::dpsiM, MultiDiracDeterminant::FirstIndex, MultiDiracDeterminant::getRatiosToRefDet(), MultiDiracDeterminant::grads, MultiDiracDeterminant::isOptimizable(), MultiDiracDeterminant::lapls, MultiDiracDeterminant::lookup_tbl, MultiDiracDeterminant::NumPtcls, MultiDiracDeterminant::Phi, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, Matrix< T, Alloc >::rows(), and Vector< T, Alloc >::size().

874 {
875  if (!isOptimizable())
876  return;
877 
878  const OffloadVector<ValueType>& detValues_up = getRatiosToRefDet();
879  const OffloadVector<ValueType>& detValues_dn = pseudo_dn.getRatiosToRefDet();
880  const Matrix<GradType>& grads_up = grads;
881  const Matrix<GradType>& grads_dn = pseudo_dn.grads;
882  const Matrix<ValueType>& lapls_up = lapls;
883  const Matrix<ValueType>& lapls_dn = pseudo_dn.lapls;
884  const OffloadMatrix<ValueType>& M_up = psiM;
885  const OffloadMatrix<ValueType>& M_dn = pseudo_dn.psiM;
886  const OffloadMatrix<ValueType>& Minv_up = psiMinv;
887  const OffloadMatrix<ValueType>& Minv_dn = pseudo_dn.psiMinv;
888  const OffloadMatrix<GradType>& B_grad = dpsiM;
889  const OffloadMatrix<ValueType>& B_lapl = d2psiM;
890  std::vector<int> detData_local(detData->size());
891  for (size_t i = 0; i < detData->size(); i++)
892  detData_local[i] = (*detData)[i];
893 
894 
895  const size_t N1 = FirstIndex;
896  const size_t N2 = pseudo_dn.FirstIndex;
897  const size_t NP1 = NumPtcls;
898  const size_t NP2 = pseudo_dn.NumPtcls;
899  Vector<ValueType> detValues_up_host_view(const_cast<ValueType*>(detValues_up.data()), detValues_up.size());
900  Vector<ValueType> detValues_dn_host_view(const_cast<ValueType*>(detValues_dn.data()), detValues_dn.size());
901  Matrix<ValueType> M_up_host_view(const_cast<ValueType*>(M_up.data()), M_up.rows(), M_up.cols());
902  Matrix<ValueType> M_dn_host_view(const_cast<ValueType*>(M_dn.data()), M_dn.rows(), M_dn.cols());
903  Matrix<ValueType> Minv_up_host_view(const_cast<ValueType*>(Minv_up.data()), Minv_up.rows(), Minv_up.cols());
904  Matrix<ValueType> Minv_dn_host_view(const_cast<ValueType*>(Minv_dn.data()), Minv_dn.rows(), Minv_dn.cols());
905  Matrix<GradType> B_grad_host_view(const_cast<GradType*>(B_grad.data()), B_grad.rows(), B_grad.cols());
906  Matrix<ValueType> B_lapl_host_view(const_cast<ValueType*>(B_lapl.data()), B_lapl.rows(), B_lapl.cols());
907  Phi->evaluateDerivatives(P, optvars, dlogpsi, dhpsioverpsi, psiCurrent, Coeff, C2node_up, C2node_dn,
908  detValues_up_host_view, detValues_dn_host_view, grads_up, grads_dn, lapls_up, lapls_dn,
909  M_up_host_view, M_dn_host_view, Minv_up_host_view, Minv_dn_host_view, B_grad_host_view,
910  B_lapl_host_view, detData_local, N1, N2, NP1, NP2, lookup_tbl);
911 }
Matrix< ValueType > lapls
store determinant lapls (old and new)
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
OffloadMatrix< GradType > dpsiM
dpsiM(i,j)
Matrix< GradType > grads
store determinant grads (old and new)
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
bool isOptimizable() const final
if true, this contains optimizable components
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
const int FirstIndex
index of the first particle with respect to the particle set
std::vector< std::vector< int > > lookup_tbl
const OffloadVector< ValueType > & getRatiosToRefDet() const

◆ evaluateDerivativesWF()

void evaluateDerivativesWF ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi,
const MultiDiracDeterminant pseudo_dn,
const PsiValue psiCurrent,
const std::vector< ValueType > &  Coeff,
const std::vector< size_t > &  C2node_up,
const std::vector< size_t > &  C2node_dn 
)

Definition at line 914 of file MultiDiracDeterminant.cpp.

References Matrix< T, Alloc >::cols(), Matrix< T, Alloc >::data(), Vector< T, Alloc >::data(), MultiDiracDeterminant::detData, MultiDiracDeterminant::getRatiosToRefDet(), MultiDiracDeterminant::isOptimizable(), MultiDiracDeterminant::lookup_tbl, MultiDiracDeterminant::Phi, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, Matrix< T, Alloc >::rows(), and Vector< T, Alloc >::size().

922 {
923  if (!isOptimizable())
924  return;
925 
926  const OffloadVector<ValueType>& detValues_up = getRatiosToRefDet();
927  const OffloadVector<ValueType>& detValues_dn = pseudo_dn.getRatiosToRefDet();
928  const OffloadMatrix<ValueType>& M_up = psiM;
929  const OffloadMatrix<ValueType>& M_dn = pseudo_dn.psiM;
930  const OffloadMatrix<ValueType>& Minv_up = psiMinv;
931  const OffloadMatrix<ValueType>& Minv_dn = pseudo_dn.psiMinv;
932 
933  std::vector<int> detData_local(detData->size());
934  for (size_t i = 0; i < detData->size(); i++)
935  detData_local[i] = (*detData)[i];
936  Vector<ValueType> detValues_up_host_view(const_cast<ValueType*>(detValues_up.data()), detValues_up.size());
937  Vector<ValueType> detValues_dn_host_view(const_cast<ValueType*>(detValues_dn.data()), detValues_dn.size());
938  Matrix<ValueType> M_up_host_view(const_cast<ValueType*>(M_up.data()), M_up.rows(), M_up.cols());
939  Matrix<ValueType> M_dn_host_view(const_cast<ValueType*>(M_dn.data()), M_dn.rows(), M_dn.cols());
940  Matrix<ValueType> Minv_up_host_view(const_cast<ValueType*>(Minv_up.data()), Minv_up.rows(), Minv_up.cols());
941  Matrix<ValueType> Minv_dn_host_view(const_cast<ValueType*>(Minv_dn.data()), Minv_dn.rows(), Minv_dn.cols());
942  Phi->evaluateDerivativesWF(P, optvars, dlogpsi, psiCurrent, Coeff, C2node_up, C2node_dn, detValues_up_host_view,
943  detValues_dn_host_view, M_up_host_view, M_dn_host_view, Minv_up_host_view,
944  Minv_dn_host_view, detData_local, lookup_tbl);
945 }
std::shared_ptr< OffloadVector< int > > detData
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
bool isOptimizable() const final
if true, this contains optimizable components
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
std::vector< std::vector< int > > lookup_tbl
const OffloadVector< ValueType > & getRatiosToRefDet() const

◆ evaluateDetsAndGradsForPtclMove()

void evaluateDetsAndGradsForPtclMove ( const ParticleSet P,
int  iat 
)

evaluate the value and gradients of all the unique determinants with one electron moved. Used by the table method

Definition at line 530 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateGradRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatios(), MultiDiracDeterminant::ciConfigList, MultiDiracDeterminant::curRatio, MultiDiracDeterminant::d2psiV, MultiDiracDeterminant::detData, qmcplusplus::DetRatioByColumn(), MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::dpsiMinv, MultiDiracDeterminant::dpsiV, MultiDiracDeterminant::evalOrbVGL_timer, MultiDiracDeterminant::evaluateDetsAndGradsForPtclMove_timer, MultiDiracDeterminant::FirstIndex, qmcplusplus::inverse(), qmcplusplus::InverseUpdateByColumn(), MultiDiracDeterminant::LastIndex, MultiDiracDeterminant::new_grads, MultiDiracDeterminant::new_ratios_to_ref_, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, OHMMS_DIM, WaveFunctionComponent::ORB_PBYP_PARTIAL, MultiDiracDeterminant::Phi, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiMinv_temp, MultiDiracDeterminant::psiV, MultiDiracDeterminant::psiV_temp, MultiDiracDeterminant::ReferenceDeterminant, MultiDiracDeterminant::table_matrix, MultiDiracDeterminant::TpsiM, MultiDiracDeterminant::uniquePairs, MultiDiracDeterminant::updateInverse_timer, WaveFunctionComponent::UpdateMode, MultiDiracDeterminant::workV1, and MultiDiracDeterminant::workV2.

531 {
534  {
535  ScopedTimer local_timer(evalOrbVGL_timer);
536  // Using Host Views for Phi-evaluateVGL since not ported to GPU
537  Vector<ValueType> psiV_host_view(psiV.data(), psiV.size());
538  Vector<GradType> dpsiV_host_view(dpsiV.data(), dpsiV.size());
539  Vector<ValueType> d2psiV_host_view(d2psiV.data(), d2psiV.size());
540  Phi->evaluateVGL(P, iat, psiV_host_view, dpsiV_host_view, d2psiV_host_view);
541  }
542  const int WorkingIndex = iat - FirstIndex;
543  const auto& confgList = *ciConfigList;
544  assert(WorkingIndex >= 0 && WorkingIndex < LastIndex - FirstIndex);
545 
546  GradType ratioGradRef;
547  {
549  //mmorales: check comment above
551  //std::vector<int>::iterator it(confgList[ReferenceDeterminant].occup.begin());
552  auto it(confgList[ReferenceDeterminant].occup.begin());
553  for (size_t i = 0; i < NumPtcls; i++)
554  {
555  psiV_temp[i] = psiV[*it];
556  ratioGradRef += psiMinv_temp(i, WorkingIndex) * dpsiV[*it];
557  it++;
558  }
561  for (size_t i = 0; i < NumOrbitals; i++)
562  TpsiM(i, WorkingIndex) = psiV[i];
563  }
566  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
567  {
568  {
570  //dpsiMinv = psiMinv_temp;
571  dpsiMinv = psiMinv;
572  auto it(confgList[ReferenceDeterminant].occup.begin());
573  for (size_t i = 0; i < NumPtcls; i++)
574  psiV_temp[i] = dpsiV[*(it++)][idim];
575  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, WorkingIndex, ratioGradRef[idim]);
576  for (size_t i = 0; i < NumOrbitals; i++)
577  TpsiM(i, WorkingIndex) = dpsiV[i][idim];
578  }
580  ratioGradRef[idim] / curRatio, table_matrix, idim, WorkingIndex, new_grads);
581  }
582  // check comment above
583  for (int i = 0; i < NumOrbitals; i++)
584  TpsiM(i, WorkingIndex) = psiM(WorkingIndex, i);
585 }
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
QTBase::GradType GradType
Definition: Configuration.h:62
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
OffloadMatrix< ValueType > psiMinv_temp
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
#define OHMMS_DIM
Definition: config.h:64
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
OffloadVector< ValueType > psiV
value of single-particle orbital for particle-by-particle update
std::shared_ptr< OffloadVector< RealType > > DetSigns
MatA::value_type DetRatioByColumn(const MatA &Minv, const VecB &newv, int colchanged)
determinant ratio with a column substitution
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
ValueType curRatio
new value of the reference determinant over the old value upon a proposed move
OffloadMatrix< ValueType > table_matrix
OffloadVector< ValueType > psiV_temp
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
Tensor< T, D > inverse(const Tensor< T, D > &a)
Definition: TensorOps.h:879
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
OffloadVector< ValueType > new_ratios_to_ref_
new determinant ratios with respect to the updated reference determinant upon a proposed move ...
void buildTableMatrix_calculateRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, OffloadVector< ValueType > &ratios)
compute the ratio of the excited determinants to the reference determinant
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set
void InverseUpdateByColumn(Matrix< T, ALLOC > &Minv, Vector< T, ALLOC > &newcol, Vector< T, ALLOC > &rvec, Vector< T, ALLOC > &rvecinv, int colchanged, T c_ratio)
void buildTableMatrix_calculateGradRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const ValueType &det0_grad, OffloadMatrix< ValueType > &table_matrix, int dx, int iat, Matrix< GradType > &grads)
Function to calculate the ratio of the gradients of the excited determinant to the reference determin...

◆ evaluateDetsAndGradsForPtclMoveWithSpin()

void evaluateDetsAndGradsForPtclMoveWithSpin ( const ParticleSet P,
int  iat 
)

evaluate the value and gradients of all the unique determinants with one electron moved. Used by the table method. Includes Spin Gradient data

Definition at line 587 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateGradRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatiosValueMatrixOneParticle(), MultiDiracDeterminant::ciConfigList, MultiDiracDeterminant::curRatio, MultiDiracDeterminant::d2psiV, MultiDiracDeterminant::detData, qmcplusplus::DetRatioByColumn(), MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::dpsiMinv, MultiDiracDeterminant::dpsiV, MultiDiracDeterminant::dspin_psiV, MultiDiracDeterminant::evalOrbVGL_timer, MultiDiracDeterminant::evaluateDetsAndGradsForPtclMove_timer, MultiDiracDeterminant::FirstIndex, qmcplusplus::inverse(), qmcplusplus::InverseUpdateByColumn(), MultiDiracDeterminant::is_spinor_, ParticleSet::isSpinor(), MultiDiracDeterminant::LastIndex, MultiDiracDeterminant::new_grads, MultiDiracDeterminant::new_ratios_to_ref_, MultiDiracDeterminant::new_spingrads, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, OHMMS_DIM, WaveFunctionComponent::ORB_PBYP_PARTIAL, MultiDiracDeterminant::Phi, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiMinv_temp, MultiDiracDeterminant::psiV, MultiDiracDeterminant::psiV_temp, MultiDiracDeterminant::ReferenceDeterminant, MultiDiracDeterminant::table_matrix, MultiDiracDeterminant::TpsiM, MultiDiracDeterminant::uniquePairs, MultiDiracDeterminant::updateInverse_timer, WaveFunctionComponent::UpdateMode, MultiDiracDeterminant::workV1, and MultiDiracDeterminant::workV2.

588 {
589  assert(P.isSpinor() == is_spinor_);
592  {
593  ScopedTimer orb_timer(evalOrbVGL_timer);
594  // Creating Host view to call Phi->evaluateVGL
595  Vector<ValueType> psiV_host_view(psiV.data(), psiV.size());
596  Vector<GradType> dpsiV_host_view(dpsiV.data(), dpsiV.size());
597  Vector<ValueType> d2psiV_host_view(d2psiV.data(), d2psiV.size());
598  Phi->evaluateVGL_spin(P, iat, psiV_host_view, dpsiV_host_view, d2psiV_host_view, dspin_psiV);
599  }
600  const int WorkingIndex = iat - FirstIndex;
601  assert(WorkingIndex >= 0 && WorkingIndex < LastIndex - FirstIndex);
602  const auto& confgList = *ciConfigList;
603  GradType ratioGradRef;
604  ValueType ratioSpinGradRef = 0.0;
605  {
607  //mmorales: check comment above
609  //std::vector<int>::iterator it(confgList[ReferenceDeterminant].occup.begin());
610  auto it(confgList[ReferenceDeterminant].occup.begin());
611  for (size_t i = 0; i < NumPtcls; i++)
612  {
613  psiV_temp[i] = psiV[*it];
614  ratioGradRef += psiMinv_temp(i, WorkingIndex) * dpsiV[*it];
615  ratioSpinGradRef += psiMinv_temp(i, WorkingIndex) * dspin_psiV[*it];
616  it++;
617  }
619  new_spingrads(ReferenceDeterminant, WorkingIndex) = ratioSpinGradRef / curRatio;
621  for (size_t i = 0; i < NumOrbitals; i++)
622  TpsiM(i, WorkingIndex) = psiV[i];
623  }
626  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
627  {
628  {
630  //dpsiMinv = psiMinv_temp;
631  dpsiMinv = psiMinv;
632  auto it(confgList[ReferenceDeterminant].occup.begin());
633  for (size_t i = 0; i < NumPtcls; i++)
634  psiV_temp[i] = dpsiV[*(it++)][idim];
635  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, WorkingIndex, ratioGradRef[idim]);
636  for (size_t i = 0; i < NumOrbitals; i++)
637  TpsiM(i, WorkingIndex) = dpsiV[i][idim];
638  }
640  ratioGradRef[idim] / curRatio, table_matrix, idim, WorkingIndex, new_grads);
641  }
642 
643  //Now compute the spin gradient, same procedure as normal gradient components above
644  {
646  dpsiMinv = psiMinv;
647  auto it(confgList[ReferenceDeterminant].occup.begin());
648  for (size_t i = 0; i < NumPtcls; i++)
649  psiV_temp[i] = dspin_psiV[*(it++)];
650  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, WorkingIndex, ratioSpinGradRef);
651  for (size_t i = 0; i < NumOrbitals; i++)
652  TpsiM(i, WorkingIndex) = dspin_psiV[i];
653  }
655  *DetSigns, table_matrix, WorkingIndex, new_spingrads);
656 
657  // check comment above
658  for (int i = 0; i < NumOrbitals; i++)
659  TpsiM(i, WorkingIndex) = psiM(WorkingIndex, i);
660 }
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
QTBase::GradType GradType
Definition: Configuration.h:62
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
OffloadMatrix< ValueType > psiMinv_temp
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
#define OHMMS_DIM
Definition: config.h:64
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
void buildTableMatrix_calculateRatiosValueMatrixOneParticle(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, int iat, Matrix< ValueType > &ratios)
OffloadVector< ValueType > psiV
value of single-particle orbital for particle-by-particle update
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::shared_ptr< OffloadVector< RealType > > DetSigns
MatA::value_type DetRatioByColumn(const MatA &Minv, const VecB &newv, int colchanged)
determinant ratio with a column substitution
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
ValueType curRatio
new value of the reference determinant over the old value upon a proposed move
OffloadMatrix< ValueType > table_matrix
OffloadVector< ValueType > psiV_temp
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
Tensor< T, D > inverse(const Tensor< T, D > &a)
Definition: TensorOps.h:879
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
OffloadVector< ValueType > new_ratios_to_ref_
new determinant ratios with respect to the updated reference determinant upon a proposed move ...
void buildTableMatrix_calculateRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, OffloadVector< ValueType > &ratios)
compute the ratio of the excited determinants to the reference determinant
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set
void InverseUpdateByColumn(Matrix< T, ALLOC > &Minv, Vector< T, ALLOC > &newcol, Vector< T, ALLOC > &rvec, Vector< T, ALLOC > &rvecinv, int colchanged, T c_ratio)
void buildTableMatrix_calculateGradRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const ValueType &det0_grad, OffloadMatrix< ValueType > &table_matrix, int dx, int iat, Matrix< GradType > &grads)
Function to calculate the ratio of the gradients of the excited determinant to the reference determin...

◆ evaluateDetsForPtclMove()

void evaluateDetsForPtclMove ( const ParticleSet P,
int  iat,
int  refPtcl = -1 
)

evaluate the value of all the unique determinants with one electron moved.

Used by the table method

Parameters
Pparticle set which provides the positions
iatthe index of the moved electron
refPtclif given, the id of the reference particle in virtual moves

Definition at line 492 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateRatios(), MultiDiracDeterminant::ciConfigList, MultiDiracDeterminant::curRatio, MultiDiracDeterminant::detData, qmcplusplus::DetRatioByColumn(), MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::evalOrbValue_timer, MultiDiracDeterminant::evaluateDetsForPtclMove_timer, MultiDiracDeterminant::FirstIndex, qmcplusplus::inverse(), qmcplusplus::InverseUpdateByColumn(), MultiDiracDeterminant::LastIndex, MultiDiracDeterminant::new_ratios_to_ref_, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, WaveFunctionComponent::ORB_PBYP_RATIO, MultiDiracDeterminant::Phi, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiMinv_temp, MultiDiracDeterminant::psiV, MultiDiracDeterminant::psiV_temp, MultiDiracDeterminant::ReferenceDeterminant, MultiDiracDeterminant::table_matrix, MultiDiracDeterminant::TpsiM, MultiDiracDeterminant::uniquePairs, MultiDiracDeterminant::updateInverse_timer, WaveFunctionComponent::UpdateMode, MultiDiracDeterminant::workV1, and MultiDiracDeterminant::workV2.

493 {
495 
497  {
498  ScopedTimer orb_timer(evalOrbValue_timer);
499  Vector<ValueType> psiV_host_view(psiV.data(), psiV.size());
500  Phi->evaluateValue(P, iat, psiV_host_view);
501  }
502  const int WorkingIndex = (refPtcl < 0 ? iat : refPtcl) - FirstIndex;
503  assert(WorkingIndex >= 0 && WorkingIndex < LastIndex - FirstIndex);
504  const auto& confgList = *ciConfigList;
505  //std::vector<int>::iterator it(confgList[ReferenceDeterminant].occup.begin());
506  auto it(confgList[ReferenceDeterminant].occup.begin());
507  // mmorales: the only reason this is here is because
508  // NonlocalECP do not necessarily call rejectMove after
509  // calling ratio(), and even if the move is rejected
510  // this matrix needs to be restored
511  // If we always restore after ratio, then this is not needed
512  // For efficiency reasons, I don't do this for ratioGrad or ratio(P,dG,dL)
513  {
516  for (size_t i = 0; i < NumPtcls; i++)
517  psiV_temp[i] = psiV[*(it++)];
520  for (size_t i = 0; i < NumOrbitals; i++)
521  TpsiM(i, WorkingIndex) = psiV[i];
522  }
525  // check comment above
526  for (size_t i = 0; i < NumOrbitals; i++)
527  TpsiM(i, WorkingIndex) = psiM(WorkingIndex, i);
528 }
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
OffloadMatrix< ValueType > psiMinv_temp
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
OffloadVector< ValueType > psiV
value of single-particle orbital for particle-by-particle update
std::shared_ptr< OffloadVector< RealType > > DetSigns
MatA::value_type DetRatioByColumn(const MatA &Minv, const VecB &newv, int colchanged)
determinant ratio with a column substitution
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
ValueType curRatio
new value of the reference determinant over the old value upon a proposed move
OffloadMatrix< ValueType > table_matrix
OffloadVector< ValueType > psiV_temp
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
Tensor< T, D > inverse(const Tensor< T, D > &a)
Definition: TensorOps.h:879
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
OffloadVector< ValueType > new_ratios_to_ref_
new determinant ratios with respect to the updated reference determinant upon a proposed move ...
void buildTableMatrix_calculateRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, OffloadVector< ValueType > &ratios)
compute the ratio of the excited determinants to the reference determinant
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set
void InverseUpdateByColumn(Matrix< T, ALLOC > &Minv, Vector< T, ALLOC > &newcol, Vector< T, ALLOC > &rvec, Vector< T, ALLOC > &rvecinv, int colchanged, T c_ratio)

◆ evaluateForWalkerMove()

void evaluateForWalkerMove ( const ParticleSet P,
bool  fromScratch = true 
)

Force host view as no implementation of evaluate_notranspose

Pinning ratios_to_ref_ to the device.

Definition at line 161 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateGradRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatiosValueMatrixOneParticle(), MultiDiracDeterminant::ciConfigList, MultiDiracDeterminant::d2psiM, Vector< T, Alloc >::data(), MultiDiracDeterminant::detData, MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::dpsiM, MultiDiracDeterminant::dpsiMinv, MultiDiracDeterminant::evalWalker_timer, MultiDiracDeterminant::FirstIndex, MultiDiracDeterminant::grads, MultiDiracDeterminant::inverse_timer, qmcplusplus::InverseUpdateByColumn(), qmcplusplus::InvertWithLog(), MultiDiracDeterminant::lapls, MultiDiracDeterminant::LastIndex, MultiDiracDeterminant::log_value_ref_det_, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, OHMMS_DIM, MultiDiracDeterminant::Phi, MultiDiracDeterminant::Pivot, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiMinv_temp, MultiDiracDeterminant::psiV_temp, MultiDiracDeterminant::ratios_to_ref_, MultiDiracDeterminant::ReferenceDeterminant, MultiDiracDeterminant::table_matrix, MultiDiracDeterminant::TpsiM, MultiDiracDeterminant::transferH2D_timer, MultiDiracDeterminant::uniquePairs, MultiDiracDeterminant::WorkSpace, MultiDiracDeterminant::workV1, and MultiDiracDeterminant::workV2.

Referenced by MultiDiracDeterminant::updateBuffer().

162 {
163  ScopedTimer local_timer(evalWalker_timer);
164  if (fromScratch)
165  {
166  ///Force host view as no implementation of evaluate_notranspose
167  Matrix<ValueType> psiM_host_view(psiM.data(), psiM.rows(), psiM.cols());
168  Matrix<GradType> dpsiM_host_view(dpsiM.data(), dpsiM.rows(), dpsiM.cols());
169  Matrix<ValueType> d2psiM_host_view(d2psiM.data(), d2psiM.rows(), d2psiM.cols());
170  Phi->evaluate_notranspose(P, FirstIndex, LastIndex, psiM_host_view, dpsiM_host_view, d2psiM_host_view);
171  {
172  ScopedTimer local_timer(transferH2D_timer);
173  psiM.updateTo();
174  dpsiM.updateTo();
175  //d2psiM.updateTo();
176  }
177  }
178 
179 
180  const auto& confgList = *ciConfigList;
181 
182  {
183  ScopedTimer local_timer(inverse_timer);
184  auto it(confgList[ReferenceDeterminant].occup.begin());
185  for (size_t i = 0; i < NumPtcls; i++)
186  {
187  for (size_t j = 0; j < NumPtcls; j++)
188  psiMinv(j, i) = psiM(j, *it);
189  it++;
190  }
191 
192  for (size_t i = 0; i < NumPtcls; i++)
193  for (size_t j = 0; j < NumOrbitals; j++)
194  TpsiM(j, i) = psiM(i, j);
195 
196  std::complex<RealType> logValueRef;
197  InvertWithLog(psiMinv.data(), NumPtcls, NumPtcls, WorkSpace.data(), Pivot.data(), logValueRef);
198  log_value_ref_det_ = logValueRef;
199  }
200 
201  const RealType detsign = (*DetSigns)[ReferenceDeterminant];
204  ///Pinning ratios_to_ref_ to the device.
205 
206 
207  for (size_t iat = 0; iat < NumPtcls; iat++)
208  {
209  auto it(confgList[ReferenceDeterminant].occup.begin());
210  GradType gradRatio;
211  ValueType ratioLapl = 0.0;
212  for (size_t i = 0; i < NumPtcls; i++)
213  {
214  gradRatio += psiMinv(i, iat) * dpsiM(iat, *it);
215  ratioLapl += psiMinv(i, iat) * d2psiM(iat, *it);
216  it++;
217  }
218  lapls(ReferenceDeterminant, iat) = ratioLapl;
219  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
220  {
221  dpsiMinv = psiMinv;
222  it = confgList[ReferenceDeterminant].occup.begin();
223  for (size_t i = 0; i < NumPtcls; i++)
224  psiV_temp[i] = dpsiM(iat, *(it++))[idim];
225  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, iat, gradRatio[idim]);
226  for (size_t i = 0; i < NumOrbitals; i++)
227  TpsiM(i, iat) = dpsiM(iat, i)[idim];
229  gradRatio[idim], table_matrix, idim, iat, grads);
230  }
231  dpsiMinv = psiMinv;
232  it = confgList[ReferenceDeterminant].occup.begin();
233  for (size_t i = 0; i < NumPtcls; i++)
234  psiV_temp[i] = d2psiM(iat, *(it++));
236  for (size_t i = 0; i < NumOrbitals; i++)
237  TpsiM(i, iat) = d2psiM(iat, i);
240  // restore matrix
241  for (size_t i = 0; i < NumOrbitals; i++)
242  TpsiM(i, iat) = psiM(iat, i);
243  }
244 
245  {
246  ScopedTimer local_timer(transferH2D_timer);
247  ratios_to_ref_.updateTo();
248  psiMinv.updateTo();
249  TpsiM.updateTo();
250  }
251 
253 }
Matrix< ValueType > lapls
store determinant lapls (old and new)
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
QTBase::GradType GradType
Definition: Configuration.h:62
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
OffloadMatrix< GradType > dpsiM
dpsiM(i,j)
LogValue log_value_ref_det_
log value of the reference determinant
OffloadMatrix< ValueType > psiMinv_temp
Matrix< GradType > grads
store determinant grads (old and new)
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
#define OHMMS_DIM
Definition: config.h:64
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
void buildTableMatrix_calculateRatiosValueMatrixOneParticle(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, int iat, Matrix< ValueType > &ratios)
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::shared_ptr< OffloadVector< RealType > > DetSigns
void InvertWithLog(T *restrict x, int n, int m, T *restrict work, int *restrict pivot, std::complex< T1 > &logdet)
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
OffloadVector< ValueType > WorkSpace
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
OffloadMatrix< ValueType > table_matrix
OffloadVector< ValueType > psiV_temp
QMCTraits::RealType RealType
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
void buildTableMatrix_calculateRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, OffloadVector< ValueType > &ratios)
compute the ratio of the excited determinants to the reference determinant
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set
void InverseUpdateByColumn(Matrix< T, ALLOC > &Minv, Vector< T, ALLOC > &newcol, Vector< T, ALLOC > &rvec, Vector< T, ALLOC > &rvecinv, int colchanged, T c_ratio)
void buildTableMatrix_calculateGradRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const ValueType &det0_grad, OffloadMatrix< ValueType > &table_matrix, int dx, int iat, Matrix< GradType > &grads)
Function to calculate the ratio of the gradients of the excited determinant to the reference determin...

◆ evaluateForWalkerMoveWithSpin()

void evaluateForWalkerMoveWithSpin ( const ParticleSet P,
bool  fromScratch = true 
)

Force host view as no implementation of evaluate_notranspose

Stop inverse_timerScop

Definition at line 255 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateGradRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatiosValueMatrixOneParticle(), MultiDiracDeterminant::ciConfigList, MultiDiracDeterminant::d2psiM, Vector< T, Alloc >::data(), MultiDiracDeterminant::detData, MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::dpsiM, MultiDiracDeterminant::dpsiMinv, MultiDiracDeterminant::dspin_psiM, MultiDiracDeterminant::evalWalker_timer, MultiDiracDeterminant::FirstIndex, MultiDiracDeterminant::grads, MultiDiracDeterminant::inverse_timer, qmcplusplus::InverseUpdateByColumn(), qmcplusplus::InvertWithLog(), MultiDiracDeterminant::lapls, MultiDiracDeterminant::LastIndex, MultiDiracDeterminant::log_value_ref_det_, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, OHMMS_DIM, MultiDiracDeterminant::Phi, MultiDiracDeterminant::Pivot, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiMinv_temp, MultiDiracDeterminant::psiV_temp, MultiDiracDeterminant::ratios_to_ref_, MultiDiracDeterminant::ReferenceDeterminant, MultiDiracDeterminant::spingrads, MultiDiracDeterminant::table_matrix, MultiDiracDeterminant::TpsiM, MultiDiracDeterminant::transferH2D_timer, MultiDiracDeterminant::uniquePairs, MultiDiracDeterminant::WorkSpace, MultiDiracDeterminant::workV1, and MultiDiracDeterminant::workV2.

Referenced by MultiDiracDeterminant::updateBuffer().

256 {
257  ScopedTimer local_timer(evalWalker_timer);
258  if (fromScratch)
259  {
260  ///Force host view as no implementation of evaluate_notranspose
261  Matrix<ValueType> psiM_host_view(psiM.data(), psiM.rows(), psiM.cols());
262  Matrix<GradType> dpsiM_host_view(dpsiM.data(), dpsiM.rows(), dpsiM.cols());
263  Matrix<ValueType> d2psiM_host_view(d2psiM.data(), d2psiM.rows(), d2psiM.cols());
264  Phi->evaluate_notranspose_spin(P, FirstIndex, LastIndex, psiM_host_view, dpsiM_host_view, d2psiM_host_view,
265  dspin_psiM);
266  {
267  ScopedTimer local_timer(transferH2D_timer);
268  psiM.updateTo();
269  dpsiM.updateTo();
270  }
271  }
272 
273 
274  const auto& confgList = *ciConfigList;
275  std::complex<RealType> logValueRef;
276 
277  {
278  ScopedTimer local_timer(inverse_timer);
279  auto it(confgList[ReferenceDeterminant].occup.begin());
280  for (size_t i = 0; i < NumPtcls; i++)
281  {
282  for (size_t j = 0; j < NumPtcls; j++)
283  psiMinv(j, i) = psiM(j, *it);
284  it++;
285  }
286  for (size_t i = 0; i < NumPtcls; i++)
287  {
288  for (size_t j = 0; j < NumOrbitals; j++)
289  TpsiM(j, i) = psiM(i, j);
290  }
291  InvertWithLog(psiMinv.data(), NumPtcls, NumPtcls, WorkSpace.data(), Pivot.data(), logValueRef);
292  log_value_ref_det_ = logValueRef;
293  } ///Stop inverse_timerScop
294  const RealType detsign = (*DetSigns)[ReferenceDeterminant];
297 
298  for (size_t iat = 0; iat < NumPtcls; iat++)
299  {
300  auto it(confgList[ReferenceDeterminant].occup.begin());
301  GradType gradRatio;
302  ValueType ratioLapl = 0.0;
303  ValueType spingradRatio = 0.0;
304  for (size_t i = 0; i < NumPtcls; i++)
305  {
306  gradRatio += psiMinv(i, iat) * dpsiM(iat, *it);
307  ratioLapl += psiMinv(i, iat) * d2psiM(iat, *it);
308  spingradRatio += psiMinv(i, iat) * dspin_psiM(iat, *it);
309  it++;
310  }
311  lapls(ReferenceDeterminant, iat) = ratioLapl;
312  spingrads(ReferenceDeterminant, iat) = spingradRatio;
313  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
314  {
315  dpsiMinv = psiMinv;
316  it = confgList[ReferenceDeterminant].occup.begin();
317  for (size_t i = 0; i < NumPtcls; i++)
318  psiV_temp[i] = dpsiM(iat, *(it++))[idim];
319  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, iat, gradRatio[idim]);
320  for (size_t i = 0; i < NumOrbitals; i++)
321  TpsiM(i, iat) = dpsiM(iat, i)[idim];
323  gradRatio[idim], table_matrix, idim, iat, grads);
324  }
325  dpsiMinv = psiMinv;
326  it = confgList[ReferenceDeterminant].occup.begin();
327  for (size_t i = 0; i < NumPtcls; i++)
328  psiV_temp[i] = d2psiM(iat, *(it++));
330  for (size_t i = 0; i < NumOrbitals; i++)
331  TpsiM(i, iat) = d2psiM(iat, i);
334 
335  //Adding the spin gradient
336  dpsiMinv = psiMinv;
337  it = confgList[ReferenceDeterminant].occup.begin();
338  for (size_t i = 0; i < NumPtcls; i++)
339  psiV_temp[i] = dspin_psiM(iat, *(it++));
340  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, iat, spingradRatio);
341  for (size_t i = 0; i < NumOrbitals; i++)
342  TpsiM(i, iat) = dspin_psiM(iat, i);
345 
346  // restore matrix
347  for (size_t i = 0; i < NumOrbitals; i++)
348  TpsiM(i, iat) = psiM(iat, i);
349  }
350 
351  {
352  ScopedTimer local_timer(transferH2D_timer);
353  ratios_to_ref_.updateTo();
354  psiMinv.updateTo();
355  TpsiM.updateTo();
356  }
358 }
Matrix< ValueType > lapls
store determinant lapls (old and new)
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
QTBase::GradType GradType
Definition: Configuration.h:62
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
OffloadMatrix< GradType > dpsiM
dpsiM(i,j)
LogValue log_value_ref_det_
log value of the reference determinant
OffloadMatrix< ValueType > psiMinv_temp
Matrix< GradType > grads
store determinant grads (old and new)
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
#define OHMMS_DIM
Definition: config.h:64
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
void buildTableMatrix_calculateRatiosValueMatrixOneParticle(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, int iat, Matrix< ValueType > &ratios)
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::shared_ptr< OffloadVector< RealType > > DetSigns
void InvertWithLog(T *restrict x, int n, int m, T *restrict work, int *restrict pivot, std::complex< T1 > &logdet)
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
OffloadVector< ValueType > WorkSpace
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
OffloadMatrix< ValueType > table_matrix
OffloadVector< ValueType > psiV_temp
QMCTraits::RealType RealType
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
void buildTableMatrix_calculateRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, OffloadVector< ValueType > &ratios)
compute the ratio of the excited determinants to the reference determinant
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set
void InverseUpdateByColumn(Matrix< T, ALLOC > &Minv, Vector< T, ALLOC > &newcol, Vector< T, ALLOC > &rvec, Vector< T, ALLOC > &rvecinv, int colchanged, T c_ratio)
void buildTableMatrix_calculateGradRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const ValueType &det0_grad, OffloadMatrix< ValueType > &table_matrix, int dx, int iat, Matrix< GradType > &grads)
Function to calculate the ratio of the gradients of the excited determinant to the reference determin...

◆ evaluateGrads()

void evaluateGrads ( ParticleSet P,
int  iat 
)

evaluate the gradients of all the unique determinants with one electron moved. Used by the table method

Definition at line 894 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateGradRatios(), MultiDiracDeterminant::ciConfigList, MultiDiracDeterminant::detData, MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::dpsiM, MultiDiracDeterminant::dpsiMinv, MultiDiracDeterminant::FirstIndex, MultiDiracDeterminant::grads, qmcplusplus::InverseUpdateByColumn(), MultiDiracDeterminant::LastIndex, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, OHMMS_DIM, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiV_temp, MultiDiracDeterminant::ReferenceDeterminant, MultiDiracDeterminant::table_matrix, MultiDiracDeterminant::TpsiM, MultiDiracDeterminant::uniquePairs, MultiDiracDeterminant::workV1, and MultiDiracDeterminant::workV2.

895 {
896  const int WorkingIndex = iat - FirstIndex;
897  assert(WorkingIndex >= 0 && WorkingIndex < LastIndex - FirstIndex);
898 
899  const auto& confgList = *ciConfigList;
900  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
901  {
902  //dpsiMinv = psiMinv_temp;
903  dpsiMinv = psiMinv;
904  auto it = confgList[ReferenceDeterminant].occup.begin();
905  ValueType ratioG = 0.0;
906  for (size_t i = 0; i < NumPtcls; i++)
907  {
908  psiV_temp[i] = dpsiM(WorkingIndex, *it)[idim];
909  ratioG += psiMinv(i, WorkingIndex) * dpsiM(WorkingIndex, *it)[idim];
910  it++;
911  }
912  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, WorkingIndex, ratioG);
913  for (size_t i = 0; i < NumOrbitals; i++)
914  TpsiM(i, WorkingIndex) = dpsiM(WorkingIndex, i)[idim];
916  ratioG, table_matrix, idim, WorkingIndex, grads);
917  }
918  // check comment above
919  for (size_t i = 0; i < NumOrbitals; i++)
920  TpsiM(i, WorkingIndex) = psiM(WorkingIndex, i);
921 }
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
OffloadMatrix< GradType > dpsiM
dpsiM(i,j)
Matrix< GradType > grads
store determinant grads (old and new)
#define OHMMS_DIM
Definition: config.h:64
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::shared_ptr< OffloadVector< RealType > > DetSigns
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
OffloadMatrix< ValueType > table_matrix
OffloadVector< ValueType > psiV_temp
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set
void InverseUpdateByColumn(Matrix< T, ALLOC > &Minv, Vector< T, ALLOC > &newcol, Vector< T, ALLOC > &rvec, Vector< T, ALLOC > &rvecinv, int colchanged, T c_ratio)
void buildTableMatrix_calculateGradRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const ValueType &det0_grad, OffloadMatrix< ValueType > &table_matrix, int dx, int iat, Matrix< GradType > &grads)
Function to calculate the ratio of the gradients of the excited determinant to the reference determin...

◆ evaluateGradsWithSpin()

void evaluateGradsWithSpin ( ParticleSet P,
int  iat 
)

evaluate the gradients of all the unique determinants with one electron moved. Used by the table method. Includes Spin Gradient data

Definition at line 923 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTableMatrix_calculateGradRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatiosValueMatrixOneParticle(), MultiDiracDeterminant::ciConfigList, MultiDiracDeterminant::detData, MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::dpsiM, MultiDiracDeterminant::dpsiMinv, MultiDiracDeterminant::dspin_psiM, MultiDiracDeterminant::FirstIndex, MultiDiracDeterminant::grads, qmcplusplus::InverseUpdateByColumn(), MultiDiracDeterminant::is_spinor_, ParticleSet::isSpinor(), MultiDiracDeterminant::LastIndex, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, OHMMS_DIM, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiV_temp, MultiDiracDeterminant::ReferenceDeterminant, MultiDiracDeterminant::spingrads, MultiDiracDeterminant::table_matrix, MultiDiracDeterminant::TpsiM, MultiDiracDeterminant::uniquePairs, MultiDiracDeterminant::workV1, and MultiDiracDeterminant::workV2.

924 {
925  assert(P.isSpinor() == is_spinor_);
926  const int WorkingIndex = iat - FirstIndex;
927  assert(WorkingIndex >= 0 && WorkingIndex < LastIndex - FirstIndex);
928 
929  const auto& confgList = *ciConfigList;
930  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
931  {
932  //dpsiMinv = psiMinv_temp;
933  dpsiMinv = psiMinv;
934  auto it = confgList[ReferenceDeterminant].occup.begin();
935  ValueType ratioG = 0.0;
936  for (size_t i = 0; i < NumPtcls; i++)
937  {
938  psiV_temp[i] = dpsiM(WorkingIndex, *it)[idim];
939  ratioG += psiMinv(i, WorkingIndex) * dpsiM(WorkingIndex, *it)[idim];
940  it++;
941  }
942  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, WorkingIndex, ratioG);
943  for (size_t i = 0; i < NumOrbitals; i++)
944  TpsiM(i, WorkingIndex) = dpsiM(WorkingIndex, i)[idim];
946  ratioG, table_matrix, idim, WorkingIndex, grads);
947  }
948 
949  //Now compute the spin gradient, same procedure as normal gradient components above
950  dpsiMinv = psiMinv;
951  auto it = confgList[ReferenceDeterminant].occup.begin();
952  ValueType ratioSG = 0.0;
953  for (size_t i = 0; i < NumPtcls; i++)
954  {
955  psiV_temp[i] = dspin_psiM(WorkingIndex, *it);
956  ratioSG += psiMinv(i, WorkingIndex) * dspin_psiM(WorkingIndex, *it);
957  it++;
958  }
959  spingrads(ReferenceDeterminant, WorkingIndex) = ratioSG;
960  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, WorkingIndex, ratioSG);
961  for (size_t i = 0; i < NumOrbitals; i++)
962  TpsiM(i, WorkingIndex) = dspin_psiM(WorkingIndex, i);
964  *DetSigns, table_matrix, WorkingIndex, spingrads);
965 
966  // check comment above
967  for (size_t i = 0; i < NumOrbitals; i++)
968  TpsiM(i, WorkingIndex) = psiM(WorkingIndex, i);
969 }
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
std::shared_ptr< OffloadVector< int > > detData
const int NumPtcls
number of particles which belong to this Dirac determinant
OffloadMatrix< GradType > dpsiM
dpsiM(i,j)
Matrix< GradType > grads
store determinant grads (old and new)
#define OHMMS_DIM
Definition: config.h:64
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
void buildTableMatrix_calculateRatiosValueMatrixOneParticle(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, int iat, Matrix< ValueType > &ratios)
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::shared_ptr< OffloadVector< RealType > > DetSigns
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
OffloadMatrix< ValueType > table_matrix
OffloadVector< ValueType > psiV_temp
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set
void InverseUpdateByColumn(Matrix< T, ALLOC > &Minv, Vector< T, ALLOC > &newcol, Vector< T, ALLOC > &rvec, Vector< T, ALLOC > &rvecinv, int colchanged, T c_ratio)
void buildTableMatrix_calculateGradRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const ValueType &det0_grad, OffloadMatrix< ValueType > &table_matrix, int dx, int iat, Matrix< GradType > &grads)
Function to calculate the ratio of the gradients of the excited determinant to the reference determin...

◆ 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 243 of file MultiDiracDeterminant.h.

References APP_ABORT.

246  {
247  APP_ABORT(" MultiDiracDeterminant: This should not be called. \n");
248  return 0.0;
249  }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
inlinefinalvirtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented from WaveFunctionComponent.

Definition at line 152 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::Phi.

153  {
154  Phi->extractOptimizableObjectRefs(opt_obj_refs);
155  }
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 147 of file MultiDiracDeterminant.h.

147 { return "MultiDiracDeterminant"; }

◆ getFirstIndex()

int getFirstIndex ( ) const
inline

Definition at line 316 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::FirstIndex.

316 { return FirstIndex; }
const int FirstIndex
index of the first particle with respect to the particle set

◆ getGrads()

const Matrix<GradType>& getGrads ( ) const
inline

Definition at line 320 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::grads.

320 { return grads; }
Matrix< GradType > grads
store determinant grads (old and new)

◆ getLapls()

const Matrix<ValueType>& getLapls ( ) const
inline

Definition at line 322 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::lapls.

322 { return lapls; }
Matrix< ValueType > lapls
store determinant lapls (old and new)

◆ getLogValueRefDet()

LogValue getLogValueRefDet ( ) const
inline

Definition at line 328 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::log_value_ref_det_.

328 { return log_value_ref_det_; }
LogValue log_value_ref_det_
log value of the reference determinant

◆ getNewGrads()

const Matrix<GradType>& getNewGrads ( ) const
inline

Definition at line 321 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::new_grads.

321 { return new_grads; }

◆ getNewLapls()

const Matrix<ValueType>& getNewLapls ( ) const
inline

Definition at line 323 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::new_lapls.

323 { return new_lapls; }

◆ getNewRatiosToRefDet()

const OffloadVector<ValueType>& getNewRatiosToRefDet ( ) const
inline

Definition at line 319 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::new_ratios_to_ref_.

319 { return new_ratios_to_ref_; }
OffloadVector< ValueType > new_ratios_to_ref_
new determinant ratios with respect to the updated reference determinant upon a proposed move ...

◆ getNewSpinGrads()

const Matrix<ValueType>& getNewSpinGrads ( ) const
inline

Definition at line 325 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::new_spingrads.

325 { return new_spingrads; }

◆ getNumDets()

◆ getNumPtcls()

int getNumPtcls ( ) const
inline

Definition at line 315 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::NumPtcls.

315 { return NumPtcls; }
const int NumPtcls
number of particles which belong to this Dirac determinant

◆ getPhi()

SPOSetPtr getPhi ( )
inline

Definition at line 145 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::Phi.

Referenced by MultiDiracDeterminant::mw_evaluateDetsAndGradsForPtclMove(), and MultiDiracDeterminant::mw_evaluateDetsForPtclMove().

145 { return Phi.get(); };
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ getRatiosToRefDet()

const OffloadVector<ValueType>& getRatiosToRefDet ( ) const
inline

Definition at line 318 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::ratios_to_ref_.

Referenced by MultiDiracDeterminant::evaluateDerivatives(), and MultiDiracDeterminant::evaluateDerivativesWF().

318 { return ratios_to_ref_; }
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant

◆ getRefDetRatio()

PsiValue getRefDetRatio ( ) const
inline

Definition at line 327 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::curRatio.

327 { return static_cast<PsiValue>(curRatio); }
ValueType curRatio
new value of the reference determinant over the old value upon a proposed move

◆ getSpinGrads()

const Matrix<ValueType>& getSpinGrads ( ) const
inline

Definition at line 324 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::spingrads.

324 { return spingrads; }

◆ isFermionic()

bool isFermionic ( ) const
inlinefinalvirtual

true, if this component is fermionic

Reimplemented from WaveFunctionComponent.

Definition at line 149 of file MultiDiracDeterminant.h.

149 { return true; }

◆ isOptimizable()

bool isOptimizable ( ) const
inlinefinalvirtual

if true, this contains optimizable components

Reimplemented from WaveFunctionComponent.

Definition at line 150 of file MultiDiracDeterminant.h.

References MultiDiracDeterminant::Phi.

Referenced by MultiDiracDeterminant::buildOptVariables(), MultiDiracDeterminant::evaluateDerivatives(), and MultiDiracDeterminant::evaluateDerivativesWF().

150 { return Phi->isOptimizable(); }
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ 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 578 of file MultiDiracDeterminant.cpp.

References APP_ABORT.

579 {
580  APP_ABORT(" Illegal action. Cannot use MultiDiracDeterminant::makeClone");
581  return std::unique_ptr<MultiDiracDeterminant>();
582 }
#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< MultiDiracDeterminant > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
const std::vector< bool > &  isAccepted 
)
static

Definition at line 527 of file MultiDiracDeterminant.cpp.

531 {
532  // TODO to be expanded to serve offload needs without relying on calling acceptMove and restore
533  for (int iw = 0; iw < wfc_list.size(); iw++)
534  if (isAccepted[iw])
535  wfc_list[iw].acceptMove(p_list[iw], iat, false);
536  else
537  wfc_list[iw].restore(iat);
538 }

◆ mw_buildTableMatrix_calculateGradRatios()

void mw_buildTableMatrix_calculateGradRatios ( MultiDiracDetMultiWalkerResource mw_res,
int  ref,
int  iat,
int  dx,
int  getNumDets,
const OffloadVector< ValueType > &  det0_grad_list,
const RefVector< OffloadMatrix< ValueType >> &  psiinv_list,
const RefVector< OffloadMatrix< ValueType >> &  psi_list,
const OffloadVector< int > &  data,
const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &  pairs,
const OffloadVector< RealType > &  sign,
const RefVector< OffloadVector< ValueType >> &  WorkSpace_list,
const RefVector< OffloadMatrix< ValueType >> &  table_matrix_list,
UnpinnedOffloadMatrix< ValueType > &  mw_grads 
)
private

Function to calculate the ratio of the gradients of the excited determinant to the reference determinant in CustomizedMatrixDet following the paper by Clark et al.

JCP 135(24), 244105

Parameters
nwNumber of walkers in the batch
refID of the reference determinant
iatatom ID
dxdimension (OHMMS_DIM)
getNumDetsNumber of determinants
psiinv_list
psi_list
data(Shared by all determinants)
pairsis the number of unique determinants (std::pair[Nb_unique_alpha][Nb_unique_beta]) (Shared by all determinants)
sign(Shared by all determinants)
WorkSpace_listlist refering to det.WorkSpace
table_matrix_liststores all the dot products between 2 determinants (I,J)
ratios_listreturned computed list of gradients

Definition at line 267 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::calculateGradRatios_timer, Matrix< T, Alloc >::cols(), Matrix< T, Alloc >::data(), Vector< T, Alloc >::data(), Vector< T, Alloc >::device_data(), MultiDiracDeterminant::getNumDets(), MultiDiracDeterminant::mw_buildTableMatrix_calculateRatios_impl(), and sign().

Referenced by MultiDiracDeterminant::mw_evaluateDetsAndGradsForPtclMove(), and MultiDiracDeterminant::mw_evaluateGrads().

282 {
284  mw_buildTableMatrix_calculateRatios_impl(mw_res, ref, det0_grad_list, psiinv_list, psi_list, data, pairs, sign,
285  table_matrix_list, WorkSpace_list);
286 
287  const size_t nw = WorkSpace_list.size();
288  OffloadVector<ValueType*> WorkSpace_deviceptr_list(nw);
289  for (size_t iw = 0; iw < nw; iw++)
290  WorkSpace_deviceptr_list[iw] = WorkSpace_list[iw].get().device_data();
291 
292  auto* WorkSpace_list_ptr = WorkSpace_deviceptr_list.data();
293  auto* mw_grads_ptr = mw_grads.data();
294  const size_t Grads_cols = mw_grads.cols();
295 
296  PRAGMA_OFFLOAD("omp target teams distribute parallel for collapse(2) map(from:mw_grads_ptr[:mw_grads.size()]) \
297  map(always, to:WorkSpace_list_ptr[:nw])")
298  for (uint32_t iw = 0; iw < nw; iw++)
299  for (uint32_t count = 0; count < getNumDets; ++count)
300  mw_grads_ptr[(3 * iw + dx) * Grads_cols + count] = WorkSpace_list_ptr[iw][count];
301 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
void mw_buildTableMatrix_calculateRatios_impl(MultiDiracDetMultiWalkerResource &mw_res, int ref, const OffloadVector< ValueType > &det0_list, const RefVector< OffloadMatrix< ValueType >> &psiinv_list, const RefVector< OffloadMatrix< ValueType >> &psi_list, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const RefVector< OffloadMatrix< ValueType >> &table_matrix_list, const RefVector< OffloadVector< ValueType >> &ratios_list)
Function to calculate the ratio of the excited determinant to the reference determinant in Customized...
double sign(double x)
Definition: Standard.h:73

◆ mw_buildTableMatrix_calculateRatios()

void mw_buildTableMatrix_calculateRatios ( MultiDiracDetMultiWalkerResource mw_res,
int  ref,
const OffloadVector< ValueType > &  det0_list,
const RefVector< OffloadMatrix< ValueType >> &  psiinv_list,
const RefVector< OffloadMatrix< ValueType >> &  psi_list,
const OffloadVector< int > &  data,
const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &  pairs,
const OffloadVector< RealType > &  sign,
const RefVector< OffloadMatrix< ValueType >> &  table_matrix_list,
const RefVector< OffloadVector< ValueType >> &  ratios_list 
)
private

Definition at line 225 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::calculateRatios_timer, MultiDiracDeterminant::mw_buildTableMatrix_calculateRatios_impl(), sign(), and MultiDiracDeterminant::transferD2H_timer.

Referenced by MultiDiracDeterminant::mw_evaluateDetsAndGradsForPtclMove(), and MultiDiracDeterminant::mw_evaluateDetsForPtclMove().

236 {
237  ScopedTimer local_timer(calculateRatios_timer);
238  mw_buildTableMatrix_calculateRatios_impl(mw_res, ref, det0_list, psiinv_list, psi_list, data, pairs, sign,
239  table_matrix_list, ratios_list);
240 
241  {
242  ScopedTimer local_timer(transferD2H_timer);
243  for (size_t iw = 0; iw < ratios_list.size(); iw++)
244  ratios_list[iw].get().updateFrom();
245  }
246 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
void mw_buildTableMatrix_calculateRatios_impl(MultiDiracDetMultiWalkerResource &mw_res, int ref, const OffloadVector< ValueType > &det0_list, const RefVector< OffloadMatrix< ValueType >> &psiinv_list, const RefVector< OffloadMatrix< ValueType >> &psi_list, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const RefVector< OffloadMatrix< ValueType >> &table_matrix_list, const RefVector< OffloadVector< ValueType >> &ratios_list)
Function to calculate the ratio of the excited determinant to the reference determinant in Customized...
double sign(double x)
Definition: Standard.h:73

◆ mw_buildTableMatrix_calculateRatios_impl()

void mw_buildTableMatrix_calculateRatios_impl ( MultiDiracDetMultiWalkerResource mw_res,
int  ref,
const OffloadVector< ValueType > &  det0_list,
const RefVector< OffloadMatrix< ValueType >> &  psiinv_list,
const RefVector< OffloadMatrix< ValueType >> &  psi_list,
const OffloadVector< int > &  data,
const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &  pairs,
const OffloadVector< RealType > &  sign,
const RefVector< OffloadMatrix< ValueType >> &  table_matrix_list,
const RefVector< OffloadVector< ValueType >> &  ratios_list 
)
private

Function to calculate the ratio of the excited determinant to the reference determinant in CustomizedMatrixDet following the paper by Clark et al.

JCP 135(24), 244105

Parameters
nwNumber of walkers in the batch
refID of the reference determinant
det0_listtakes lists of ValueType(1) for the value or RatioGrad/curRatio for the gradients
psiinv_list
psi_list
data(Shared by all determinants)
pairsis the number of unique determinants (std::pair[Nb_unique_alpha][Nb_unique_beta]) (Shared by all determinants)
sign(Shared by all determinants)
table_matrix_liststores all the dot products between 2 determinants (I,J)
ratio_listreturned computed ratios

Definition at line 75 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::buildTable_timer, MultiDiracDeterminant::det_calculator_, I, qmcplusplus::Units::energy::J, MultiDiracDeterminant::mw_updateRatios_det0(), MultiDiracDeterminant::mw_updateRatios_generic(), MultiDiracDeterminant::ndets_per_excitation_level_, MultiDiracDeterminant::offload_timer, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::psi_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::psiinv_deviceptr_list, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::ratios_deviceptr_list, qmcplusplus::Units::second, sign(), MultiDiracDeterminant::table2ratios_timer, and MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::table_matrix_deviceptr_list.

Referenced by MultiDiracDeterminant::mw_buildTableMatrix_calculateGradRatios(), and MultiDiracDeterminant::mw_buildTableMatrix_calculateRatios().

86 {
87  const size_t nw = ratios_list.size();
88  auto& psiinv_deviceptr_list = mw_res.psiinv_deviceptr_list;
89  auto& psi_deviceptr_list = mw_res.psi_deviceptr_list;
90  auto& table_matrix_deviceptr_list = mw_res.table_matrix_deviceptr_list;
91  auto& ratios_deviceptr_list = mw_res.ratios_deviceptr_list;
92  const size_t nb_cols_table_matrix(table_matrix_list[0].get().cols());
93 
94  {
96  const size_t npairs = pairs.size();
97  const size_t num = psi_list[0].get().extent(1);
98  const size_t nitems = sign.size();
99 
100  const int* first = pairs.data(0);
101  const int* second = pairs.data(1);
102 
103  psiinv_deviceptr_list.resize(nw);
104  psi_deviceptr_list.resize(nw);
105  table_matrix_deviceptr_list.resize(nw);
106  ratios_deviceptr_list.resize(nw);
107 
108  for (size_t iw = 0; iw < nw; iw++)
109  {
110  psiinv_deviceptr_list[iw] = psiinv_list[iw].get().device_data();
111  psi_deviceptr_list[iw] = psi_list[iw].get().device_data();
112  table_matrix_deviceptr_list[iw] = table_matrix_list[iw].get().device_data();
113  ratios_deviceptr_list[iw] = ratios_list[iw].get().device_data();
114  }
115 
116  const size_t nb_cols_psi(psi_list[0].get().cols());
117  const size_t nb_cols_psiinv(psiinv_list[0].get().cols());
118 
119  auto* ratios_list_ptr = ratios_deviceptr_list.data();
120  auto* table_matrix_list_ptr = table_matrix_deviceptr_list.data();
121  const auto* psiinv_list_ptr = psiinv_deviceptr_list.data();
122  const auto* psi_list_ptr = psi_deviceptr_list.data();
123 
124  {
125  ScopedTimer local_timer(offload_timer);
126  PRAGMA_OFFLOAD("omp target teams distribute parallel for collapse(2) \
127  map(always, to: psiinv_list_ptr[:nw], psi_list_ptr[:nw]) \
128  map(always, to: ratios_list_ptr[:nw], table_matrix_list_ptr[:nw]) \
129  map(to:first[:npairs], second[:npairs])")
130  for (uint32_t iw = 0; iw < nw; iw++)
131  for (uint32_t i = 0; i < npairs; ++i)
132  {
133  const int I = first[i];
134  const int J = second[i];
135 
136  ValueType table_matrix_local = 0.0;
137  for (uint32_t ind = 0; ind < num; ind++)
138  table_matrix_local +=
139  psiinv_list_ptr[iw][I * nb_cols_psiinv + ind] * psi_list_ptr[iw][J * nb_cols_psi + ind];
140  table_matrix_list_ptr[iw][I * nb_cols_table_matrix + J] = table_matrix_local;
141  }
142  }
143  }
144  {
146  const int max_ext_level = ndets_per_excitation_level_->size() - 1;
147 
148  // Compute workload changes drastically as the excitation level increases.
149  // this may need different parallelization strategy.
150  size_t det_offset = 1;
151  size_t data_offset = 1;
152 
153  auto update_offsets = [&](size_t ext_level) {
154  det_offset += (*ndets_per_excitation_level_)[ext_level];
155  data_offset += (*ndets_per_excitation_level_)[ext_level] * (3 * ext_level + 1);
156  };
157 
158  mw_updateRatios_det0(det0_list, ratios_deviceptr_list);
159 
160  if (max_ext_level >= 1)
161  {
162  mw_updateRatios<1>(det_offset, data_offset, data, sign, table_matrix_deviceptr_list, nb_cols_table_matrix,
163  ratios_deviceptr_list);
164  update_offsets(1);
165  }
166 
167  if (max_ext_level >= 2)
168  {
169  mw_updateRatios<2>(det_offset, data_offset, data, sign, table_matrix_deviceptr_list, nb_cols_table_matrix,
170  ratios_deviceptr_list);
171  update_offsets(2);
172  }
173 
174  if (max_ext_level >= 3)
175  {
176  mw_updateRatios<3>(det_offset, data_offset, data, sign, table_matrix_deviceptr_list, nb_cols_table_matrix,
177  ratios_deviceptr_list);
178  update_offsets(3);
179  }
180 
181  if (max_ext_level >= 4)
182  {
183  mw_updateRatios<4>(det_offset, data_offset, data, sign, table_matrix_deviceptr_list, nb_cols_table_matrix,
184  ratios_deviceptr_list);
185  update_offsets(4);
186  }
187 
188  if (max_ext_level >= 5)
189  {
190  mw_updateRatios<5>(det_offset, data_offset, data, sign, table_matrix_deviceptr_list, nb_cols_table_matrix,
191  ratios_deviceptr_list);
192  update_offsets(5);
193  }
194 
195  if (max_ext_level >= 6)
196  {
197  for (size_t iw = 0; iw < nw; iw++)
198  table_matrix_list[iw].get().updateFrom();
199  for (size_t ext_level = 6; ext_level <= max_ext_level; ext_level++)
200  {
201  mw_updateRatios_generic(ext_level, det_offset, data_offset, det_calculator_, data, sign, table_matrix_list,
202  ratios_list);
203  update_offsets(ext_level);
204  }
205  // FIXME need to transfer the part of det ratios ext_level >= 6 to the device.
206  }
207  }
208 }
std::shared_ptr< std::vector< int > > ndets_per_excitation_level_
number of unique determinants at each excitation level (relative to reference) {1, n_singles, n_doubles, n_triples, ...}
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
void mw_updateRatios_generic(const int ext_level, const size_t det_offset, const size_t data_offset, SmallMatrixDetCalculator< ValueType > &det_calculator, const OffloadVector< int > &data, const OffloadVector< RealType > &sign, const RefVector< OffloadMatrix< ValueType >> &table_matrix_list, const RefVector< OffloadVector< ValueType >> &ratios_list) const
update ratios with respect to the reference deteriminant for a given excitation level ...
QTBase::ValueType ValueType
Definition: Configuration.h:60
void mw_updateRatios_det0(const OffloadVector< ValueType > &det0_list, const OffloadVector< ValueType *> &ratios_deviceptr_list) const
update ratios of the reference deteriminant
double sign(double x)
Definition: Standard.h:73
std::complex< double > I
SmallMatrixDetCalculator< ValueType > det_calculator_

◆ mw_evaluateDetsAndGradsForPtclMove()

void mw_evaluateDetsAndGradsForPtclMove ( const RefVectorWithLeader< MultiDiracDeterminant > &  det_list,
const RefVectorWithLeader< ParticleSet > &  P_list,
int  iat,
UnpinnedOffloadMatrix< ValueType > &  mw_grads 
)
static

multi walker version of mw_evaluateDetsAndGradsForPtclMove

This is needed by Host in acceptMove. Eventually acceptMove will need to become mw_acceptMove.

Definition at line 662 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::ciConfigList, qmcplusplus::ompBLAS::copy_batched(), qmcplusplus::ompBLAS::copy_batched_offset(), qmcplusplus::det(), MultiDiracDeterminant::detData, MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::evalOrbVGL_timer, MultiDiracDeterminant::evaluateDetsAndGradsForPtclMove_timer, MultiDiracDeterminant::FirstIndex, RefVectorWithLeader< T >::getLeader(), MultiDiracDeterminant::getNumDets(), MultiDiracDeterminant::getPhi(), qmcplusplus::Units::energy::J, MultiDiracDeterminant::mw_buildTableMatrix_calculateGradRatios(), MultiDiracDeterminant::mw_buildTableMatrix_calculateRatios(), MultiDiracDeterminant::mw_InverseUpdateByColumn(), MultiDiracDeterminant::mw_res_handle_, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, OHMMS_DIM, WaveFunctionComponent::ORB_PBYP_PARTIAL, MultiDiracDeterminant::refdet_occup, MultiDiracDeterminant::ReferenceDeterminant, MultiDiracDeterminant::transferD2H_timer, MultiDiracDeterminant::transferH2D_timer, MultiDiracDeterminant::uniquePairs, and WaveFunctionComponent::UpdateMode.

667 {
668  const int nw = det_list.size();
669  MultiDiracDeterminant& det_leader = det_list.getLeader();
670  RefVectorWithLeader<SPOSet> phi_list(*det_leader.getPhi());
671 
672  ScopedTimer local_timer(det_leader.evaluateDetsAndGradsForPtclMove_timer);
673  int success = 0;
674  int dummy_handle = 0;
675  const size_t NumOrbitals(det_leader.NumOrbitals);
676  const size_t NumPtcls(det_leader.NumPtcls);
677 
678  RefVector<OffloadVector<ValueType>> psiV_list, psiV_temp_list, new_ratios_to_ref_list, WorkSpace_list;
679  RefVector<OffloadVector<ValueType>> d2psiV_list;
680 
681  RefVector<OffloadMatrix<ValueType>> psiMinv_temp_list, psiMinv_list, dpsiMinv_list;
682  RefVector<OffloadMatrix<ValueType>> table_matrix_list, psiM_list, TpsiM_list;
683 
684  RefVector<OffloadVector<GradType>> dpsiV_list;
685 
686  phi_list.reserve(nw);
687  psiV_list.reserve(nw);
688  dpsiV_list.reserve(nw);
689  d2psiV_list.reserve(nw);
690  psiV_temp_list.reserve(nw);
691  psiMinv_temp_list.reserve(nw);
692  psiMinv_list.reserve(nw);
693  psiM_list.reserve(nw);
694 
695  TpsiM_list.reserve(nw);
696  new_ratios_to_ref_list.reserve(nw);
697  table_matrix_list.reserve(nw);
698  dpsiMinv_list.reserve(nw);
699  WorkSpace_list.reserve(nw);
700 
701  auto& mw_res = det_leader.mw_res_handle_.getResource();
702  auto& ratioGradRef_list = mw_res.ratioGradRef_list;
703  auto& det0_grad_list = mw_res.det0_grad_list;
704  ratioGradRef_list.resize(nw);
705  det0_grad_list.resize(nw);
706 
707  det_leader.UpdateMode = ORB_PBYP_PARTIAL;
708  const int WorkingIndex = iat - det_leader.FirstIndex;
709 
710  for (size_t iw = 0; iw < nw; iw++)
711  {
712  MultiDiracDeterminant& det = (det_list[iw]);
713  det.UpdateMode = ORB_PBYP_PARTIAL;
714  phi_list.push_back(*det.Phi);
715  psiV_list.push_back(det.psiV);
716  dpsiV_list.push_back(det.dpsiV);
717  d2psiV_list.push_back(det.d2psiV);
718  psiV_temp_list.push_back(det.psiV_temp);
719  psiMinv_list.push_back(det.psiMinv);
720  psiM_list.push_back(det.psiM);
721  psiMinv_temp_list.push_back(det.psiMinv_temp);
722  new_ratios_to_ref_list.push_back(det.new_ratios_to_ref_);
723  TpsiM_list.push_back(det.TpsiM);
724  table_matrix_list.push_back(det.table_matrix);
725  dpsiMinv_list.push_back(det.dpsiMinv);
726  WorkSpace_list.push_back(det.WorkSpace);
727  }
728 
729  {
730  ScopedTimer local_timer(det_leader.evalOrbVGL_timer);
731  for (size_t iw = 0; iw < nw; iw++)
732  {
733  MultiDiracDeterminant& det = (det_list[iw]);
734  Vector<ValueType> psiV_list_host_view(psiV_list[iw].get().data(), psiV_list[iw].get().size());
735  Vector<GradType> dpsiV_list_host_view(dpsiV_list[iw].get().data(), dpsiV_list[iw].get().size());
736  Vector<ValueType> d2psiV_list_host_view(d2psiV_list[iw].get().data(), d2psiV_list[iw].get().size());
737  det.Phi->evaluateVGL(P_list[iw], iat, psiV_list_host_view, dpsiV_list_host_view, d2psiV_list_host_view);
738 
739  {
740  ScopedTimer local_timer(det_leader.transferH2D_timer);
741  psiV_list[iw].get().updateTo();
742  dpsiV_list[iw].get().updateTo();
743  }
744  }
745  }
746 
747  const auto psiMinv_rows = psiMinv_list[0].get().rows();
748  const auto psiMinv_cols = psiMinv_list[0].get().cols();
749  const auto TpsiM_num_cols = TpsiM_list[0].get().cols();
750  const auto psiM_num_cols = psiM_list[0].get().cols();
751  const auto& confgList = *det_leader.ciConfigList;
752 
753  auto* psiV_list_devptr = mw_res.psiV_deviceptr_list.device_data();
754  auto* psiV_temp_list_ptr = mw_res.psiV_temp_deviceptr_list.data();
755  auto* TpsiM_list_devptr = mw_res.TpsiM_deviceptr_list.device_data();
756  auto* psiM_list_ptr = mw_res.psiM_deviceptr_list.data();
757  auto* psiMinv_list_devptr = mw_res.psiMinv_deviceptr_list.device_data();
758  auto* dpsiMinv_list_devptr = mw_res.dpsiMinv_deviceptr_list.device_data();
759  auto* psiMinv_temp_list_devptr = mw_res.psiMinv_temp_deviceptr_list.device_data();
760 
761  auto& curRatio_list = mw_res.curRatio_list;
762  curRatio_list.resize(nw);
763  auto* curRatio_list_ptr = curRatio_list.data();
764 
765  auto& inv_curRatio_list = mw_res.inv_curRatio_list;
766  inv_curRatio_list.resize(nw);
767  auto* inv_curRatio_list_ptr = inv_curRatio_list.data();
768 
769  auto* det0_grad_list_ptr = det0_grad_list.data();
770  auto* confgListOccup_ptr = det_leader.refdet_occup->data();
771 
772  auto* dpsiV_list_ptr = mw_res.dpsiV_deviceptr_list.data();
773  auto* ratioGradRef_list_ptr = ratioGradRef_list.data();
774 
775  {
776  success = ompBLAS::copy_batched(dummy_handle, psiMinv_rows * psiMinv_cols, psiMinv_list_devptr, 1,
777  psiMinv_temp_list_devptr, 1, nw);
778  if (success != 0)
779  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::copy_batched_offset failed.");
780 
781 
782  // Index of loop over nw must be 32 bit sized to avoid assignment-after-reduction offload bug
783  // See https://github.com/QMCPACK/qmcpack/issues/4767
784  PRAGMA_OFFLOAD("omp target teams distribute is_device_ptr(psiV_list_devptr, psiMinv_temp_list_devptr) \
785  map(always, from:curRatio_list_ptr[:nw])")
786  for (uint32_t iw = 0; iw < nw; iw++)
787  {
788  GradType ratioGradRef_local(0);
789  PRAGMA_OFFLOAD("omp parallel for reduction(+ : ratioGradRef_local)")
790  for (uint32_t i = 0; i < NumPtcls; i++)
791  {
792  const size_t J = confgListOccup_ptr[i];
793  psiV_temp_list_ptr[iw][i] = psiV_list_devptr[iw][J];
794  ratioGradRef_local += psiMinv_temp_list_devptr[iw][i * psiMinv_cols + WorkingIndex] * dpsiV_list_ptr[iw][J];
795  }
796  // Workaround for assignment-after-reduction issue.
797  // In full precision, changing the loop variable iw to 32 bits in size works.
798  // In mixed precision, changing the loop variable iw to 16 bits would work, but is not acceptable.
799  // For that case we use the other workaround of assigning each value in the array separately.
800  // See https://github.com/QMCPACK/qmcpack/issues/4767
801  ratioGradRef_list_ptr[iw][0] = ratioGradRef_local[0];
802  ratioGradRef_list_ptr[iw][1] = ratioGradRef_local[1];
803  ratioGradRef_list_ptr[iw][2] = ratioGradRef_local[2];
804 
805  ValueType c_ratio = 0.0;
806  PRAGMA_OFFLOAD("omp parallel for reduction(+ : c_ratio)")
807  for (uint32_t jc = 0; jc < psiMinv_cols; jc += 1)
808  {
809  const size_t ic = jc * psiMinv_cols;
810  c_ratio += (psiMinv_temp_list_devptr[iw] + WorkingIndex)[ic] * psiV_temp_list_ptr[iw][jc];
811  }
812  curRatio_list_ptr[iw] = c_ratio;
813  inv_curRatio_list_ptr[iw] = ValueType(1) / c_ratio;
814  }
815 
816  success = ompBLAS::copy_batched_offset(dummy_handle, det_leader.NumOrbitals, psiV_list_devptr, 0, 1,
817  TpsiM_list_devptr, WorkingIndex, TpsiM_num_cols, nw);
818  if (success != 0)
819  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::copy_batched_offset failed.");
820 
821 
822  det_leader.mw_InverseUpdateByColumn(det_leader.mw_res_handle_, WorkingIndex, inv_curRatio_list,
823  mw_res.psiV_temp_deviceptr_list, mw_res.psiMinv_temp_deviceptr_list,
824  psiMinv_rows);
825 
826  ///This is needed by Host in acceptMove. Eventually acceptMove will need to become mw_acceptMove.
827  {
828  ScopedTimer local_timer(det_leader.transferD2H_timer);
829  for (size_t iw = 0; iw < nw; iw++)
830  psiMinv_temp_list[iw].get().updateFrom();
831  }
832 
833  auto& det0_list = mw_res.cone_vec;
834  det_leader.mw_buildTableMatrix_calculateRatios(det_leader.mw_res_handle_, det_leader.ReferenceDeterminant,
835  det0_list, psiMinv_temp_list, TpsiM_list, *det_leader.detData,
836  *det_leader.uniquePairs, *det_leader.DetSigns, table_matrix_list,
837  new_ratios_to_ref_list);
838 
839  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
840  {
841  success = ompBLAS::copy_batched(dummy_handle, psiMinv_rows * psiMinv_cols, psiMinv_list_devptr, 1,
842  dpsiMinv_list_devptr, 1, nw);
843  if (success != 0)
844  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::copy_batched_offset failed.");
845 
846  PRAGMA_OFFLOAD("omp target teams distribute map(to: ratioGradRef_list_ptr[:nw])")
847  for (uint32_t iw = 0; iw < nw; iw++)
848  {
849  inv_curRatio_list_ptr[iw] = ValueType(1) / ratioGradRef_list_ptr[iw][idim];
850 
851  for (uint32_t i = 0; i < NumPtcls; i++)
852  {
853  const size_t J = confgListOccup_ptr[i];
854  psiV_temp_list_ptr[iw][i] = dpsiV_list_ptr[iw][J][idim];
855  }
856  }
857 
858  det_leader.mw_InverseUpdateByColumn(det_leader.mw_res_handle_, WorkingIndex, inv_curRatio_list,
859  mw_res.psiV_temp_deviceptr_list, mw_res.dpsiMinv_deviceptr_list,
860  psiMinv_rows);
861 
862  PRAGMA_OFFLOAD("omp target teams distribute map(to:dpsiV_list_ptr[:nw], curRatio_list_ptr[:nw]) \
863  map(always,from:det0_grad_list_ptr[:nw]) \
864  is_device_ptr(TpsiM_list_devptr)")
865  for (uint32_t iw = 0; iw < nw; iw++)
866  {
867  det0_grad_list_ptr[iw] = ratioGradRef_list_ptr[iw][idim] / curRatio_list_ptr[iw];
868  for (uint32_t i = 0; i < NumOrbitals; i++)
869  TpsiM_list_devptr[iw][i * TpsiM_num_cols + WorkingIndex] = dpsiV_list_ptr[iw][i][idim];
870  }
871 
872  det_leader.mw_buildTableMatrix_calculateGradRatios(det_leader.mw_res_handle_, det_leader.ReferenceDeterminant,
873  WorkingIndex, idim, det_leader.getNumDets(), det0_grad_list,
874  dpsiMinv_list, TpsiM_list, *det_leader.detData,
875  *det_leader.uniquePairs, *det_leader.DetSigns, WorkSpace_list,
876  table_matrix_list, mw_grads);
877  }
878 
879  // restore the modified column of TpsiM.
880  PRAGMA_OFFLOAD("omp target teams distribute parallel for collapse(2) is_device_ptr(TpsiM_list_devptr) \
881  map(always, to:psiM_list_ptr[:nw])")
882  for (uint32_t iw = 0; iw < nw; iw++)
883  for (uint32_t i = 0; i < NumOrbitals; i++)
884  TpsiM_list_devptr[iw][i * TpsiM_num_cols + WorkingIndex] = psiM_list_ptr[iw][i + psiM_num_cols * WorkingIndex];
885  }
886 
887  for (size_t iw = 0; iw < nw; iw++)
888  {
889  MultiDiracDeterminant& det = (det_list[iw]);
890  det.curRatio = curRatio_list[iw];
891  }
892 }
QTBase::GradType GradType
Definition: Configuration.h:62
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
const int NumPtcls
number of particles which belong to this Dirac determinant
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
#define OHMMS_DIM
Definition: config.h:64
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
QTBase::ValueType ValueType
Definition: Configuration.h:60
ompBLAS_status copy_batched_offset(ompBLAS_handle &handle, const int n, const T *const x[], const int x_offset, const int incx, T *const y[], const int y_offset, const int incy, const int batch_count)
copy device data from x to y with additional offset applied to array of device pointers ...
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
MultiDiracDeterminant(std::unique_ptr< SPOSet > &&spos, bool spinor, int first, int nel)
constructor
ompBLAS_status copy_batched(ompBLAS_handle &handle, const int n, const T *const x[], const int incx, T *const y[], const int incy, const int batch_count)
copy device data from x to y

◆ mw_evaluateDetsForPtclMove()

void mw_evaluateDetsForPtclMove ( const RefVectorWithLeader< MultiDiracDeterminant > &  det_list,
const RefVectorWithLeader< ParticleSet > &  P_list,
int  iat 
)
static

multi walker version of evaluateDetsForPtclMove

Transfer of data from host to Device

This is needed by acceptMove. Eventually acceptMove will need to become mw_acceptMove.

Definition at line 346 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::ciConfigList, qmcplusplus::ompBLAS::copy_batched(), qmcplusplus::ompBLAS::copy_batched_offset(), qmcplusplus::det(), MultiDiracDeterminant::detData, MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::evalOrbValue_timer, MultiDiracDeterminant::evaluateDetsForPtclMove_timer, MultiDiracDeterminant::FirstIndex, RefVectorWithLeader< T >::getLeader(), MultiDiracDeterminant::getPhi(), qmcplusplus::Units::energy::J, MultiDiracDeterminant::mw_buildTableMatrix_calculateRatios(), MultiDiracDeterminant::mw_InverseUpdateByColumn(), MultiDiracDeterminant::mw_res_handle_, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, WaveFunctionComponent::ORB_PBYP_PARTIAL, WaveFunctionComponent::ORB_PBYP_RATIO, MultiDiracDeterminant::refdet_occup, MultiDiracDeterminant::ReferenceDeterminant, MultiDiracDeterminant::transferD2H_timer, MultiDiracDeterminant::uniquePairs, and WaveFunctionComponent::UpdateMode.

349 {
350  const int nw = det_list.size();
351  MultiDiracDeterminant& det_leader = det_list.getLeader();
352  RefVectorWithLeader<SPOSet> phi_list(*det_leader.getPhi());
353 
354  ScopedTimer local_timer(det_leader.evaluateDetsForPtclMove_timer);
355 
356  RefVector<OffloadVector<ValueType>> psiV_list, new_ratios_to_ref_list;
357  RefVector<OffloadMatrix<ValueType>> TpsiM_list, psiM_list, table_matrix_list;
358  RefVector<OffloadMatrix<ValueType>> psiMinv_temp_list, psiMinv_list;
359 
360  phi_list.reserve(nw);
361  psiV_list.reserve(nw);
362  psiMinv_list.reserve(nw);
363  psiMinv_temp_list.reserve(nw);
364  table_matrix_list.reserve(nw);
365  TpsiM_list.reserve(nw);
366  psiM_list.reserve(nw);
367  new_ratios_to_ref_list.reserve(nw);
368 
369  for (size_t iw = 0; iw < nw; iw++)
370  {
371  MultiDiracDeterminant& det = (det_list[iw]);
372  det.UpdateMode = ORB_PBYP_PARTIAL;
373  phi_list.push_back(*det.Phi);
374  psiV_list.push_back(det.psiV);
375  psiMinv_list.push_back(det.psiMinv);
376  psiM_list.push_back(det.psiM);
377  psiMinv_temp_list.push_back(det.psiMinv_temp);
378  new_ratios_to_ref_list.push_back(det.new_ratios_to_ref_);
379  table_matrix_list.push_back(det.table_matrix);
380  TpsiM_list.push_back(det.TpsiM);
381  }
382 
383 
384  det_leader.UpdateMode = ORB_PBYP_RATIO;
385  const int WorkingIndex = iat - det_leader.FirstIndex;
386 
387  {
388  ScopedTimer local_timer(det_leader.evalOrbValue_timer);
389  for (size_t iw = 0; iw < nw; iw++)
390  {
391  MultiDiracDeterminant& det = (det_list[iw]);
392  Vector<ValueType> psiV_list_host_view(psiV_list[iw].get().data(), psiV_list[iw].get().size());
393  det.getPhi()->evaluateValue(P_list[iw], iat, psiV_list_host_view);
394  ///Transfer of data from host to Device
395  {
396  ScopedTimer local_timer(det.transferH2D_timer);
397  psiV_list[iw].get().updateTo();
398  }
399  }
400  }
401 
402  size_t success = 0;
403  int dummy_handle = 0;
404  const auto psiMinv_rows = psiMinv_list[0].get().rows();
405  const auto psiMinv_cols = psiMinv_list[0].get().cols();
406  const auto TpsiM_cols = TpsiM_list[0].get().cols();
407  const auto psiM_cols = psiM_list[0].get().cols();
408  const auto TpsiM_rows = TpsiM_list[0].get().rows();
409  const auto NumPtcls = det_leader.NumPtcls;
410  const auto NumOrbitals = det_leader.NumOrbitals;
411  const auto& confgList = *det_leader.ciConfigList;
412 
413  auto& mw_res = det_leader.mw_res_handle_.getResource();
414  auto* psiV_list_devptr = mw_res.psiV_deviceptr_list.device_data();
415  auto* psiV_temp_list_ptr = mw_res.psiV_temp_deviceptr_list.data();
416 
417  auto* psiMinv_list_devptr = mw_res.psiMinv_deviceptr_list.device_data();
418  auto* psiMinv_temp_list_devptr = mw_res.psiMinv_temp_deviceptr_list.device_data();
419 
420  auto* TpsiM_list_devptr = mw_res.TpsiM_deviceptr_list.device_data();
421  auto* psiM_list_ptr = mw_res.psiM_deviceptr_list.data();
422 
423  auto& curRatio_list = mw_res.curRatio_list;
424  curRatio_list.resize(nw);
425  auto* curRatio_list_ptr = curRatio_list.data();
426 
427  auto& inv_curRatio_list = mw_res.inv_curRatio_list;
428  inv_curRatio_list.resize(nw);
429  auto* inv_curRatio_list_ptr = inv_curRatio_list.data();
430 
431  auto* confgListOccup_ptr = det_leader.refdet_occup->data();
432 
433  {
434  success = ompBLAS::copy_batched(dummy_handle, psiMinv_rows * psiMinv_cols, psiMinv_list_devptr, 1,
435  psiMinv_temp_list_devptr, 1, nw);
436  if (success != 0)
437  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::copy_batched_offset failed.");
438 
439  success = ompBLAS::copy_batched_offset(dummy_handle, det_leader.NumOrbitals, psiV_list_devptr, 0, 1,
440  TpsiM_list_devptr, WorkingIndex, TpsiM_cols, nw);
441  if (success != 0)
442  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::copy_batched_offset failed.");
443 
444  PRAGMA_OFFLOAD("omp target teams distribute map(always, from:curRatio_list_ptr[:nw]) \
445  is_device_ptr(psiV_list_devptr, psiMinv_temp_list_devptr)")
446  for (uint32_t iw = 0; iw < nw; iw++)
447  {
448  ValueType c_ratio = 0.0;
449  PRAGMA_OFFLOAD("omp parallel for reduction(+ : c_ratio)")
450  for (uint32_t jc = 0; jc < NumPtcls; jc++)
451  {
452  const size_t J = confgListOccup_ptr[jc];
453  psiV_temp_list_ptr[iw][jc] = psiV_list_devptr[iw][J];
454  size_t ic = jc * psiMinv_cols;
455  c_ratio += (psiMinv_temp_list_devptr[iw] + WorkingIndex)[ic] * psiV_temp_list_ptr[iw][jc];
456  }
457  curRatio_list_ptr[iw] = c_ratio;
458  inv_curRatio_list_ptr[iw] = ValueType(1) / c_ratio;
459  }
460 
461  det_leader.mw_InverseUpdateByColumn(det_leader.mw_res_handle_, WorkingIndex, inv_curRatio_list,
462  mw_res.psiV_temp_deviceptr_list, mw_res.psiMinv_temp_deviceptr_list,
463  psiMinv_rows);
464  ///This is needed by acceptMove. Eventually acceptMove will need to become mw_acceptMove.
465  {
466  ScopedTimer local_timer(det_leader.transferD2H_timer);
467  for (size_t iw = 0; iw < nw; iw++)
468  psiMinv_temp_list[iw].get().updateFrom();
469  }
470 
471  auto& det0_list = mw_res.cone_vec;
472  det_leader.mw_buildTableMatrix_calculateRatios(det_leader.mw_res_handle_, det_leader.ReferenceDeterminant,
473  det0_list, psiMinv_temp_list, TpsiM_list, *det_leader.detData,
474  *det_leader.uniquePairs, *det_leader.DetSigns, table_matrix_list,
475  new_ratios_to_ref_list);
476 
477  // restore the modified column of TpsiM.
478  PRAGMA_OFFLOAD("omp target teams distribute parallel for collapse(2) is_device_ptr(TpsiM_list_devptr) \
479  map(always, to:psiM_list_ptr[:nw])")
480  for (uint32_t iw = 0; iw < nw; iw++)
481  for (uint32_t i = 0; i < NumOrbitals; i++)
482  TpsiM_list_devptr[iw][i * TpsiM_cols + WorkingIndex] = psiM_list_ptr[iw][i + psiM_cols * WorkingIndex];
483  }
484 
485  for (size_t iw = 0; iw < nw; iw++)
486  {
487  MultiDiracDeterminant& det = (det_list[iw]);
488  det.curRatio = curRatio_list_ptr[iw];
489  }
490 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
const int NumPtcls
number of particles which belong to this Dirac determinant
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
ompBLAS_status copy_batched_offset(ompBLAS_handle &handle, const int n, const T *const x[], const int x_offset, const int incx, T *const y[], const int y_offset, const int incy, const int batch_count)
copy device data from x to y with additional offset applied to array of device pointers ...
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
MultiDiracDeterminant(std::unique_ptr< SPOSet > &&spos, bool spinor, int first, int nel)
constructor
ompBLAS_status copy_batched(ompBLAS_handle &handle, const int n, const T *const x[], const int incx, T *const y[], const int incy, const int batch_count)
copy device data from x to y

◆ mw_evaluateGrads()

void mw_evaluateGrads ( const RefVectorWithLeader< MultiDiracDeterminant > &  det_list,
const RefVectorWithLeader< ParticleSet > &  P_list,
int  iat,
UnpinnedOffloadMatrix< ValueType > &  mw_grads 
)
static

multi walker version of mw_evaluateGrads

Definition at line 971 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::ciConfigList, qmcplusplus::ompBLAS::copy_batched(), qmcplusplus::det(), MultiDiracDeterminant::detData, MultiDiracDeterminant::DetSigns, MultiDiracDeterminant::evaluateGrads_timer, MultiDiracDeterminant::FirstIndex, RefVectorWithLeader< T >::getLeader(), MultiDiracDeterminant::getNumDets(), qmcplusplus::Units::energy::J, MultiDiracDeterminant::mw_buildTableMatrix_calculateGradRatios(), MultiDiracDeterminant::mw_InverseUpdateByColumn(), MultiDiracDeterminant::mw_res_handle_, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, OHMMS_DIM, MultiDiracDeterminant::refdet_occup, MultiDiracDeterminant::ReferenceDeterminant, and MultiDiracDeterminant::uniquePairs.

975 {
976  const int nw = det_list.size();
977  MultiDiracDeterminant& det_leader = det_list.getLeader();
978  const int WorkingIndex = iat - det_leader.FirstIndex;
979  int success = 0;
980  int dummy_handle = 0;
981  const size_t NumOrbitals(det_leader.NumOrbitals);
982  const size_t NumPtcls(det_leader.NumPtcls);
983 
984  ScopedTimer local_timer(det_leader.evaluateGrads_timer);
985 
986  RefVector<OffloadMatrix<ValueType>> dpsiMinv_list, psiMinv_list;
987  RefVector<OffloadMatrix<GradType>> dpsiM_list;
988  RefVector<OffloadVector<ValueType>> psiV_temp_list, WorkSpace_list;
989  RefVector<OffloadMatrix<ValueType>> table_matrix_list, TpsiM_list, psiM_list;
990  //RefVector<OffloadMatrix<GradType>> grads_list;
991 
992  psiMinv_list.reserve(nw);
993  dpsiMinv_list.reserve(nw);
994  dpsiM_list.reserve(nw);
995  psiV_temp_list.reserve(nw);
996  //grads_list.reserve(nw);
997  table_matrix_list.reserve(nw);
998  TpsiM_list.reserve(nw);
999  psiM_list.reserve(nw);
1000  WorkSpace_list.reserve(nw);
1001 
1002  for (size_t iw = 0; iw < nw; iw++)
1003  {
1004  MultiDiracDeterminant& det = (det_list[iw]);
1005  psiMinv_list.push_back(det.psiMinv);
1006  dpsiMinv_list.push_back(det.dpsiMinv);
1007  psiV_temp_list.push_back(det.psiV_temp);
1008  dpsiM_list.push_back(det.dpsiM);
1009  //grads_list.push_back(det.grads);
1010  TpsiM_list.push_back(det.TpsiM);
1011  psiM_list.push_back(det.psiM);
1012  table_matrix_list.push_back(det.table_matrix);
1013  WorkSpace_list.push_back(det.WorkSpace);
1014  }
1015 
1016  const auto psiMinv_rows = psiMinv_list[0].get().rows();
1017  const auto psiMinv_cols = psiMinv_list[0].get().cols();
1018  const auto TpsiM_cols = TpsiM_list[0].get().cols();
1019  const auto psiM_cols = psiM_list[0].get().cols();
1020  const auto dpsiM_cols = dpsiM_list[0].get().cols();
1021  const auto dpsiM_rows = dpsiM_list[0].get().rows();
1022  const auto& confgList = *det_leader.ciConfigList;
1023 
1024  auto& mw_res = det_leader.mw_res_handle_.getResource();
1025  auto& ratioG_list = mw_res.curRatio_list;
1026  ratioG_list.resize(nw);
1027  auto* ratioG_list_ptr = ratioG_list.data();
1028 
1029  auto& inv_ratioG_list = mw_res.inv_curRatio_list;
1030  inv_ratioG_list.resize(nw);
1031  auto* inv_ratioG_list_ptr = inv_ratioG_list.data();
1032 
1033  auto* psiMinv_list_devptr = mw_res.psiMinv_deviceptr_list.device_data();
1034  auto* dpsiMinv_list_devptr = mw_res.dpsiMinv_deviceptr_list.device_data();
1035  auto* TpsiM_list_devptr = mw_res.TpsiM_deviceptr_list.data();
1036  auto* psiM_list_ptr = mw_res.psiM_deviceptr_list.data();
1037  auto* psiV_temp_list_ptr = mw_res.psiV_temp_deviceptr_list.data();
1038  auto* dpsiM_list_ptr = mw_res.dpsiM_deviceptr_list.data();
1039  auto* confgListOccup_ptr = det_leader.refdet_occup->data();
1040 
1041  {
1042  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
1043  {
1044  success = ompBLAS::copy_batched(dummy_handle, psiMinv_rows * psiMinv_cols, psiMinv_list_devptr, 1,
1045  dpsiMinv_list_devptr, 1, nw);
1046  if (success != 0)
1047  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::copy_batched_offset failed.");
1048 
1049  PRAGMA_OFFLOAD("omp target teams distribute map(always, to: psiV_temp_list_ptr[:nw]) \
1050  map(always, to: dpsiM_list_ptr[:nw])")
1051  for (uint32_t iw = 0; iw < nw; iw++)
1052  for (uint32_t i = 0; i < NumPtcls; i++)
1053  {
1054  size_t J = confgListOccup_ptr[i];
1055  psiV_temp_list_ptr[iw][i] = dpsiM_list_ptr[iw][WorkingIndex * dpsiM_cols + J][idim];
1056  }
1057 
1058  PRAGMA_OFFLOAD("omp target teams distribute is_device_ptr(psiMinv_list_devptr) \
1059  map(always, from: ratioG_list_ptr[:nw])")
1060  for (uint32_t iw = 0; iw < nw; iw++)
1061  {
1062  ValueType ratioG_local(0);
1063  PRAGMA_OFFLOAD("omp parallel for reduction(+ : ratioG_local)")
1064  for (uint32_t i = 0; i < NumPtcls; i++)
1065  {
1066  size_t J = confgListOccup_ptr[i];
1067  ratioG_local += psiMinv_list_devptr[iw][i * psiMinv_cols + WorkingIndex] *
1068  dpsiM_list_ptr[iw][WorkingIndex * dpsiM_cols + J][idim];
1069  }
1070  ratioG_list_ptr[iw] = ratioG_local;
1071  inv_ratioG_list_ptr[iw] = ValueType(1) / ratioG_local;
1072  }
1073 
1074  det_leader.mw_InverseUpdateByColumn(det_leader.mw_res_handle_, WorkingIndex, inv_ratioG_list,
1075  mw_res.psiV_temp_deviceptr_list, mw_res.dpsiMinv_deviceptr_list,
1076  psiMinv_rows);
1077 
1078  PRAGMA_OFFLOAD("omp target teams distribute parallel for collapse(2) map(to:dpsiM_list_ptr[:nw]) \
1079  map(always, to: TpsiM_list_devptr[:nw])")
1080  for (uint32_t iw = 0; iw < nw; iw++)
1081  for (uint32_t i = 0; i < NumOrbitals; i++)
1082  TpsiM_list_devptr[iw][i * TpsiM_cols + WorkingIndex] =
1083  dpsiM_list_ptr[iw][dpsiM_cols * WorkingIndex + i][idim];
1084 
1085 
1087  WorkingIndex, idim, det_leader.getNumDets(), ratioG_list,
1088  dpsiMinv_list, TpsiM_list, *det_leader.detData,
1089  *det_leader.uniquePairs, *det_leader.DetSigns, WorkSpace_list,
1090  table_matrix_list, mw_grads);
1091  }
1092 
1093  // restore the modified column of TpsiM.
1094  PRAGMA_OFFLOAD("omp target teams distribute parallel for map(from:TpsiM_list_devptr[:nw]) \
1095  map(always,to:psiM_list_ptr[:nw])")
1096  for (uint32_t iw = 0; iw < nw; iw++)
1097  for (uint32_t i = 0; i < NumOrbitals; i++)
1098  TpsiM_list_devptr[iw][i * TpsiM_cols + WorkingIndex] = psiM_list_ptr[iw][i + psiM_cols * WorkingIndex];
1099  }
1100 }
std::shared_ptr< OffloadVector< int > > detData
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
const int NumPtcls
number of particles which belong to this Dirac determinant
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
void mw_buildTableMatrix_calculateGradRatios(MultiDiracDetMultiWalkerResource &mw_res, int ref, int iat, int dx, int getNumDets, const OffloadVector< ValueType > &det0_grad_list, const RefVector< OffloadMatrix< ValueType >> &psiinv_list, const RefVector< OffloadMatrix< ValueType >> &psi_list, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const RefVector< OffloadVector< ValueType >> &WorkSpace_list, const RefVector< OffloadMatrix< ValueType >> &table_matrix_list, UnpinnedOffloadMatrix< ValueType > &mw_grads)
Function to calculate the ratio of the gradients of the excited determinant to the reference determin...
#define OHMMS_DIM
Definition: config.h:64
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::shared_ptr< OffloadVector< RealType > > DetSigns
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
MultiDiracDeterminant(std::unique_ptr< SPOSet > &&spos, bool spinor, int first, int nel)
constructor
ResourceHandle< MultiDiracDetMultiWalkerResource > mw_res_handle_
ompBLAS_status copy_batched(ompBLAS_handle &handle, const int n, const T *const x[], const int incx, T *const y[], const int incy, const int batch_count)
copy device data from x to y

◆ mw_InverseUpdateByColumn()

void mw_InverseUpdateByColumn ( MultiDiracDetMultiWalkerResource mw_res,
const int  working_index,
const OffloadVector< ValueType > &  curRatio_list,
const OffloadVector< ValueType *> &  psiV_deviceptr_list,
const OffloadVector< ValueType *> &  psiMinv_deviceptr_list,
const size_t  psiMinv_rows 
) const
private

Definition at line 1168 of file MultiDiracDeterminant.2.cpp.

References MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::cminus_one_vec, BLAS::cone, qmcplusplus::ompBLAS::copy_batched_offset(), MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::czero_vec, Vector< T, Alloc >::device_data(), qmcplusplus::ompBLAS::gemv_batched(), qmcplusplus::ompBLAS::ger_batched(), Vector< T, Alloc >::size(), MultiDiracDeterminant::updateInverse_timer, MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::workV1_deviceptr_list, and MultiDiracDeterminant::MultiDiracDetMultiWalkerResource::workV2_deviceptr_list.

Referenced by MultiDiracDeterminant::mw_evaluateDetsAndGradsForPtclMove(), MultiDiracDeterminant::mw_evaluateDetsForPtclMove(), and MultiDiracDeterminant::mw_evaluateGrads().

1174 {
1175  ScopedTimer local_timer(updateInverse_timer);
1176 
1177  constexpr ValueType cone(1);
1178 
1179  const size_t nw = inv_curRatio_list.size();
1180 
1181  ValueType* czero_ptr = mw_res.czero_vec.device_data();
1182  ValueType* cminus_one_ptr = mw_res.cminus_one_vec.device_data();
1183 
1184  int success = 0;
1185  int dummy_handle = 0;
1186 
1187  auto* psiV_list_devptr = psiV_deviceptr_list.device_data();
1188  auto* psiMinv_list_devptr = psiMinv_deviceptr_list.device_data();
1189  auto* workV1_list_ptr = mw_res.workV1_deviceptr_list.device_data();
1190  auto* workV2_list_ptr = mw_res.workV2_deviceptr_list.device_data();
1191  auto* inv_curRatio_list_devptr = inv_curRatio_list.device_data();
1192 
1193  success =
1194  ompBLAS::gemv_batched(dummy_handle, 'N', psiMinv_rows, psiMinv_rows, inv_curRatio_list_devptr,
1195  psiMinv_list_devptr, psiMinv_rows, psiV_list_devptr, 1, czero_ptr, workV1_list_ptr, 1, nw);
1196  if (success != 0)
1197  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::gemv_batched failed.");
1198 
1199  PRAGMA_OFFLOAD("omp target teams distribute parallel for is_device_ptr(workV1_list_ptr, inv_curRatio_list_devptr)")
1200  for (uint32_t iw = 0; iw < nw; iw++)
1201  workV1_list_ptr[iw][working_index] = cone - inv_curRatio_list_devptr[iw];
1202  if (success != 0)
1203  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::copy_batched_offset failed.");
1204 
1205  success = ompBLAS::copy_batched_offset(dummy_handle, psiMinv_rows, psiMinv_list_devptr, working_index, psiMinv_rows,
1206  workV2_list_ptr, 0, 1, nw);
1207  if (success != 0)
1208  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::copy_batched_offset failed.");
1209 
1210  success = ompBLAS::ger_batched(dummy_handle, psiMinv_rows, psiMinv_rows, cminus_one_ptr, workV1_list_ptr, 1,
1211  workV2_list_ptr, 1, psiMinv_list_devptr, psiMinv_rows, nw);
1212  if (success != 0)
1213  throw std::runtime_error("In MultiDiracDeterminant ompBLAS::ger_batched failed.");
1214 }
if(c->rank()==0)
constexpr std::complex< float > cone
Definition: BLAS.hpp:50
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
ompBLAS_status gemv_batched(ompBLAS_handle &handle, const char trans, const int m, const int n, const T *alpha, const T *const A[], const int lda, const T *const x[], const int incx, const T *beta, T *const y[], const int incy, const int batch_count)
QTBase::ValueType ValueType
Definition: Configuration.h:60
ompBLAS_status copy_batched_offset(ompBLAS_handle &handle, const int n, const T *const x[], const int x_offset, const int incx, T *const y[], const int y_offset, const int incy, const int batch_count)
copy device data from x to y with additional offset applied to array of device pointers ...
MultiDiracDeterminant(std::unique_ptr< SPOSet > &&spos, bool spinor, int first, int nel)
constructor
void ger_batched(BLASHandle< PlatformKind::CUDA > &handle, const int m, const int n, const T *alpha, const T *const x[], const int incx, const T *const y[], const int incy, T *const A[], const int lda, const int batch_count)

◆ mw_updateRatios()

void mw_updateRatios ( const size_t  det_offset,
const size_t  data_offset,
const OffloadVector< int > &  data,
const OffloadVector< RealType > &  sign,
const OffloadVector< ValueType *> &  table_matrix_deviceptr_list,
const size_t  num_table_matrix_cols,
const OffloadVector< ValueType *> &  ratios_deviceptr_list 
) const
private

update ratios with respect to the reference deteriminant for a given excitation level

Parameters
det_offsetoffset of the determinant id
data_offsetoffset of the "data" structure
signof determinants
table_matrix_listlist of table_matrix

this is intended to be customized based on EXT_LEVEL

Definition at line 1137 of file MultiDiracDeterminant.2.cpp.

References Vector< T, Alloc >::data(), qmcplusplus::evaluate(), sign(), Vector< T, Alloc >::size(), and MultiDiracDeterminant::updateRatios_timer.

1144 {
1145  const size_t nw = ratios_deviceptr_list.size();
1146  const size_t size_sign = sign.size();
1147  const size_t ndet_ext = (*ndets_per_excitation_level_)[EXT_LEVEL];
1148 
1149  ScopedTimer local_timer(updateRatios_timer);
1150 
1151  auto* ratios_list_ptr = ratios_deviceptr_list.data();
1152  const auto* sign_ptr = sign.data();
1153  const int* data_ptr = data.data();
1154  const auto* table_matrix_list_ptr = table_matrix_deviceptr_list.data();
1155 
1156  PRAGMA_OFFLOAD("omp target teams distribute parallel for collapse(2)")
1157  for (uint32_t iw = 0; iw < nw; iw++)
1158  for (uint32_t count = 0; count < ndet_ext; ++count)
1159  {
1160  size_t det_id = det_offset + count;
1161  ratios_list_ptr[iw][det_id] = sign_ptr[det_id] * ratios_list_ptr[iw][0] *
1162  CustomizedMatrixDet<EXT_LEVEL>::evaluate(table_matrix_list_ptr[iw],
1163  (data_ptr + data_offset) + 1 + count * (3 * EXT_LEVEL + 1),
1164  num_table_matrix_cols);
1165  }
1166 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
double sign(double x)
Definition: Standard.h:73
void evaluate(Matrix< T, Alloc > &lhs, const Op &op, const Expression< RHS > &rhs)
Definition: OhmmsMatrix.h:514

◆ mw_updateRatios_det0()

void mw_updateRatios_det0 ( const OffloadVector< ValueType > &  det0_list,
const OffloadVector< ValueType *> &  ratios_deviceptr_list 
) const
private

update ratios of the reference deteriminant

Parameters
det0_listlist of reference det value

Definition at line 1122 of file MultiDiracDeterminant.2.cpp.

References Vector< T, Alloc >::data(), Vector< T, Alloc >::size(), and MultiDiracDeterminant::updateRatios_timer.

Referenced by MultiDiracDeterminant::mw_buildTableMatrix_calculateRatios_impl().

1124 {
1125  ScopedTimer local_timer(updateRatios_timer);
1126 
1127  const size_t nw = ratios_deviceptr_list.size();
1128  auto* ratios_list_ptr = ratios_deviceptr_list.data();
1129  const auto* det0_list_ptr = det0_list.data();
1130 
1131  PRAGMA_OFFLOAD("omp target teams distribute parallel for map(always, to: det0_list_ptr[:nw])")
1132  for (uint32_t iw = 0; iw < nw; iw++)
1133  ratios_list_ptr[iw][0] = det0_list_ptr[iw];
1134 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])

◆ mw_updateRatios_generic()

void mw_updateRatios_generic ( const int  ext_level,
const size_t  det_offset,
const size_t  data_offset,
SmallMatrixDetCalculator< ValueType > &  det_calculator,
const OffloadVector< int > &  data,
const OffloadVector< RealType > &  sign,
const RefVector< OffloadMatrix< ValueType >> &  table_matrix_list,
const RefVector< OffloadVector< ValueType >> &  ratios_list 
) const
private

update ratios with respect to the reference deteriminant for a given excitation level

Parameters
ext_levelexcitation level
det_offsetoffset of the determinant id
data_offsetoffset of the "data" structure
signof determinants
table_matrix_listlist of table_matrix

this is a general implementation. Support abitrary excitation level

Definition at line 1102 of file MultiDiracDeterminant.2.cpp.

References Vector< T, Alloc >::data(), SmallMatrixDetCalculator< T >::evaluate(), and sign().

Referenced by MultiDiracDeterminant::mw_buildTableMatrix_calculateRatios_impl().

1110 {
1111  const size_t nw = ratios_list.size();
1112  const int* it2 = data.data() + data_offset;
1113  for (size_t iw = 0; iw < nw; iw++)
1114  for (size_t count = 0; count < (*ndets_per_excitation_level_)[ext_level]; ++count)
1115  {
1116  size_t det_id = det_offset + count;
1117  ratios_list[iw].get()[det_id] = sign[det_id] * ratios_list[iw].get()[0] *
1118  det_calculator.evaluate(table_matrix_list[iw].get(), it2 + 1 + count * (3 * ext_level + 1), ext_level);
1119  }
1120 }
static T evaluate(T a11, T a12, T a21, T a22)
double sign(double x)
Definition: Standard.h:73

◆ operator=()

MultiDiracDeterminant& operator= ( const MultiDiracDeterminant s)
delete

◆ 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 225 of file MultiDiracDeterminant.h.

References APP_ABORT.

226  {
227  APP_ABORT(" MultiDiracDeterminant: This should not be called. \n");
228  return PsiValue();
229  }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ 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 237 of file MultiDiracDeterminant.h.

References APP_ABORT.

238  {
239  APP_ABORT(" MultiDiracDeterminant: This should not be called. \n");
240  return PsiValue();
241  }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ 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 624 of file MultiDiracDeterminant.cpp.

References PooledMemory< T_scalar, Alloc >::add(), MultiDiracDeterminant::d2psiM, QMCTraits::DIM, MultiDiracDeterminant::dpsiM, MultiDiracDeterminant::dspin_psiM, Matrix< T, Alloc >::first_address(), MultiDiracDeterminant::FirstAddressOfdpsiM, MultiDiracDeterminant::FirstAddressOfGrads, MultiDiracDeterminant::getNumDets(), MultiDiracDeterminant::grads, MultiDiracDeterminant::is_spinor_, ParticleSet::isSpinor(), MultiDiracDeterminant::lapls, Matrix< T, Alloc >::last_address(), MultiDiracDeterminant::LastAddressOfdpsiM, MultiDiracDeterminant::LastAddressOfGrads, MultiDiracDeterminant::log_value_ref_det_, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::ratios_to_ref_, and MultiDiracDeterminant::spingrads.

625 {
626  assert(P.isSpinor() == is_spinor_);
627 
628  //extra pointers
629  FirstAddressOfGrads = &(grads(0, 0)[0]);
631  FirstAddressOfdpsiM = &(dpsiM(0, 0)[0]);
633 
634  //add the data:
635  buf.add(psiM.first_address(), psiM.last_address());
637  buf.add(d2psiM.first_address(), d2psiM.last_address());
638  buf.add(psiMinv.first_address(), psiMinv.last_address());
639  buf.add(log_value_ref_det_);
640  buf.add(ratios_to_ref_.first_address(), ratios_to_ref_.last_address());
642  buf.add(lapls.first_address(), lapls.last_address());
643  if (is_spinor_)
644  {
645  buf.add(dspin_psiM.first_address(), dspin_psiM.last_address());
647  }
648 }
Matrix< ValueType > lapls
store determinant lapls (old and new)
pointer last_address()
Definition: OhmmsMatrix.h:209
const int NumPtcls
number of particles which belong to this Dirac determinant
OffloadMatrix< GradType > dpsiM
dpsiM(i,j)
LogValue log_value_ref_det_
log value of the reference determinant
Matrix< GradType > grads
store determinant grads (old and new)
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
pointer first_address()
Definition: OhmmsMatrix.h:204
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)

◆ releaseResource()

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

Definition at line 722 of file MultiDiracDeterminant.cpp.

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

724 {
725  auto& wfc_leader = wfc_list.getCastedLeader<MultiDiracDeterminant>();
726  collection.takebackResource(wfc_leader.mw_res_handle_);
727 }
MultiDiracDeterminant(std::unique_ptr< SPOSet > &&spos, bool spinor, int first, int nel)
constructor

◆ resize()

void resize ( )
private

reset the size: with the number of particles

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

Definition at line 730 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::d2psiM, MultiDiracDeterminant::d2psiV, MultiDiracDeterminant::det_calculator_, MultiDiracDeterminant::dpsiM, MultiDiracDeterminant::dpsiMinv, MultiDiracDeterminant::dpsiV, MultiDiracDeterminant::dspin_psiM, MultiDiracDeterminant::dspin_psiV, MultiDiracDeterminant::getNumDets(), MultiDiracDeterminant::grads, MultiDiracDeterminant::is_spinor_, MultiDiracDeterminant::lapls, MultiDiracDeterminant::new_grads, MultiDiracDeterminant::new_lapls, MultiDiracDeterminant::new_ratios_to_ref_, MultiDiracDeterminant::new_spingrads, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::NumPtcls, MultiDiracDeterminant::Pivot, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiMinv_temp, MultiDiracDeterminant::psiV, MultiDiracDeterminant::psiV_temp, MultiDiracDeterminant::ratios_to_ref_, SmallMatrixDetCalculator< T >::resize(), Matrix< T, Alloc >::resize(), Vector< T, Alloc >::resize(), MultiDiracDeterminant::spingrads, MultiDiracDeterminant::table_matrix, MultiDiracDeterminant::TpsiM, MultiDiracDeterminant::WorkSpace, MultiDiracDeterminant::workV1, and MultiDiracDeterminant::workV2.

Referenced by MultiDiracDeterminant::createDetData(), and MultiDiracDeterminant::MultiDiracDeterminant().

731 {
732  const int nel = NumPtcls;
733  assert(NumPtcls > 0);
734  const int NumDets = getNumDets();
735  assert(NumDets > 0);
736 
737  psiV_temp.resize(nel);
738  psiV.resize(NumOrbitals);
739  dpsiV.resize(NumOrbitals);
740  d2psiV.resize(NumOrbitals);
741  psiM.resize(nel, NumOrbitals);
742  dpsiM.resize(nel, NumOrbitals);
743  d2psiM.resize(nel, NumOrbitals);
744  TpsiM.resize(NumOrbitals, nel);
745  psiMinv.resize(nel, nel);
746  dpsiMinv.resize(nel, nel);
747  psiMinv_temp.resize(nel, nel);
748  //scratch spaces: stateless
749  WorkSpace.resize(std::max(nel, NumDets));
750  Pivot.resize(nel);
751  workV1.resize(nel);
752  workV2.resize(nel);
753  ratios_to_ref_.resize(NumDets);
754  new_ratios_to_ref_.resize(NumDets);
755  grads.resize(NumDets, nel);
756  new_grads.resize(NumDets, nel);
757  lapls.resize(NumDets, nel);
758  new_lapls.resize(NumDets, nel);
760  det_calculator_.resize(nel);
761 
762  if (is_spinor_)
763  {
764  dspin_psiV.resize(NumOrbitals);
765  dspin_psiM.resize(nel, NumOrbitals);
766  spingrads.resize(NumDets, nel);
767  new_spingrads.resize(NumDets, nel);
768  }
769 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
Matrix< ValueType > lapls
store determinant lapls (old and new)
const int NumPtcls
number of particles which belong to this Dirac determinant
OffloadMatrix< GradType > dpsiM
dpsiM(i,j)
OffloadMatrix< ValueType > psiMinv_temp
Matrix< GradType > grads
store determinant grads (old and new)
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant
OffloadVector< ValueType > psiV
value of single-particle orbital for particle-by-particle update
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
OffloadVector< ValueType > WorkSpace
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
OffloadMatrix< ValueType > table_matrix
SmallMatrixDetCalculator< ValueType > det_calculator_
OffloadVector< ValueType > psiV_temp
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
OffloadVector< ValueType > new_ratios_to_ref_
new determinant ratios with respect to the updated reference determinant upon a proposed move ...

◆ restore()

void restore ( int  iat)
overridevirtual

move was rejected.

copy the real container to the temporary to move on

Implements WaveFunctionComponent.

Definition at line 496 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::curRatio, MultiDiracDeterminant::FirstIndex, MultiDiracDeterminant::LastIndex, MultiDiracDeterminant::NumOrbitals, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, MultiDiracDeterminant::psiMinv_temp, MultiDiracDeterminant::TpsiM, and MultiDiracDeterminant::transferH2D_timer.

497 {
498  const int WorkingIndex = iat - FirstIndex;
499  assert(WorkingIndex >= 0 && WorkingIndex < LastIndex - FirstIndex);
501  for (int i = 0; i < NumOrbitals; i++)
502  TpsiM(i, WorkingIndex) = psiM(WorkingIndex, i);
503  {
504  ScopedTimer local_timer(transferH2D_timer);
505  TpsiM.updateTo();
506  }
507  curRatio = ValueType(1);
508  /*
509  switch(UpdateMode)
510  {
511  case ORB_PBYP_RATIO:
512  psiMinv_temp = psiMinv;
513  for(int i=0; i<NumOrbitals; i++)
514  TpsiM(i,WorkingIndex) = psiM(WorkingIndex,i);
515  break;
516  case ORB_PBYP_PARTIAL:
517  psiMinv_temp = psiMinv;
518  for(int i=0; i<NumOrbitals; i++)
519  TpsiM(i,WorkingIndex) = psiM(WorkingIndex,i);
520  break;
521  default:
522  break;
523  }
524  */
525 }
OffloadMatrix< ValueType > psiMinv_temp
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
QTBase::ValueType ValueType
Definition: Configuration.h:60
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
ValueType curRatio
new value of the reference determinant over the old value upon a proposed move
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set

◆ updateBuffer()

MultiDiracDeterminant::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 361 of file MultiDiracDeterminant.cpp.

References MultiDiracDeterminant::d2psiM, MultiDiracDeterminant::dspin_psiM, MultiDiracDeterminant::evaluateForWalkerMove(), MultiDiracDeterminant::evaluateForWalkerMoveWithSpin(), Matrix< T, Alloc >::first_address(), MultiDiracDeterminant::FirstAddressOfdpsiM, MultiDiracDeterminant::FirstAddressOfGrads, MultiDiracDeterminant::is_spinor_, ParticleSet::isSpinor(), MultiDiracDeterminant::lapls, Matrix< T, Alloc >::last_address(), MultiDiracDeterminant::LastAddressOfdpsiM, MultiDiracDeterminant::LastAddressOfGrads, MultiDiracDeterminant::log_value_ref_det_, WaveFunctionComponent::ORB_PBYP_RATIO, MultiDiracDeterminant::psiM, MultiDiracDeterminant::psiMinv, PooledMemory< T_scalar, Alloc >::put(), MultiDiracDeterminant::ratios_to_ref_, MultiDiracDeterminant::spingrads, and WaveFunctionComponent::UpdateMode.

362 {
363  assert(P.isSpinor() == is_spinor_);
364  if (is_spinor_)
366  else
367  evaluateForWalkerMove(P, (fromscratch || UpdateMode == ORB_PBYP_RATIO));
368  buf.put(psiM.first_address(), psiM.last_address());
370  buf.put(d2psiM.first_address(), d2psiM.last_address());
371  buf.put(psiMinv.first_address(), psiMinv.last_address());
372  buf.put(log_value_ref_det_);
373  buf.put(ratios_to_ref_.first_address(), ratios_to_ref_.last_address());
375  buf.put(lapls.first_address(), lapls.last_address());
376  if (is_spinor_)
377  {
378  buf.put(dspin_psiM.first_address(), dspin_psiM.last_address());
380  }
381  return 1.0;
382 }
Matrix< ValueType > lapls
store determinant lapls (old and new)
pointer last_address()
Definition: OhmmsMatrix.h:209
LogValue log_value_ref_det_
log value of the reference determinant
void evaluateForWalkerMoveWithSpin(const ParticleSet &P, bool fromScratch=true)
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
pointer first_address()
Definition: OhmmsMatrix.h:204
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
void evaluateForWalkerMove(const ParticleSet &P, bool fromScratch=true)

Member Data Documentation

◆ buildTable_timer

◆ calculateGradRatios_timer

◆ calculateRatios_timer

◆ ciConfigList

◆ curRatio

◆ d2psiM

◆ d2psiV

◆ det_calculator_

◆ detData

◆ DetSigns

◆ dpsiM

◆ dpsiMinv

◆ dpsiV

◆ dspin_psiM

◆ dspin_psiV

◆ evalOrbValue_timer

◆ evalOrbVGL_timer

◆ evaluateDetsAndGradsForPtclMove_timer

◆ evaluateDetsForPtclMove_timer

◆ evaluateGrads_timer

NewTimer & evaluateGrads_timer

Definition at line 39 of file MultiDiracDeterminant.h.

Referenced by MultiDiracDeterminant::mw_evaluateGrads().

◆ evalWalker_timer

◆ FirstAddressOfdpsiM

◆ FirstAddressOfGrads

◆ FirstIndex

◆ grads

◆ inverse_timer

◆ is_spinor_

◆ lapls

◆ LastAddressOfdpsiM

◆ LastAddressOfGrads

◆ LastIndex

◆ log_value_ref_det_

◆ lookup_tbl

◆ MaxSmallDet

constexpr size_t MaxSmallDet = 5
staticprivate

for matrices with leading dimensions <= MaxSmallDet, compute determinant with direct expansion.

Definition at line 603 of file MultiDiracDeterminant.h.

Referenced by MultiDiracDeterminant::buildTableMatrix_calculateRatios_impl().

◆ mw_res_handle_

◆ myVars

Definition at line 43 of file MultiDiracDeterminant.h.

◆ ndets_per_excitation_level_

std::shared_ptr<std::vector<int> > ndets_per_excitation_level_
private

number of unique determinants at each excitation level (relative to reference) {1, n_singles, n_doubles, n_triples, ...}

Definition at line 599 of file MultiDiracDeterminant.h.

Referenced by MultiDiracDeterminant::createDetData(), MultiDiracDeterminant::MultiDiracDeterminant(), and MultiDiracDeterminant::mw_buildTableMatrix_calculateRatios_impl().

◆ new_grads

◆ new_lapls

◆ new_ratios_to_ref_

◆ new_spingrads

◆ NumOrbitals

◆ NumPtcls

◆ offload_timer

◆ Phi

◆ Pivot

◆ psiM

◆ psiMinv

◆ psiMinv_temp

◆ psiV

◆ psiV_temp

◆ ratios_to_ref_

◆ refdet_occup

◆ ReferenceDeterminant

◆ spingrads

◆ table2ratios_timer

◆ table_matrix

◆ TpsiM

◆ transferD2H_timer

◆ transferH2D_timer

◆ uniquePairs

◆ updateInverse_timer

◆ updateRatios_timer

◆ WorkSpace

◆ workV1

◆ workV2


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