20 #ifndef QMCPLUSPLUS_MULTIDIRACDETERMINANT_H 21 #define QMCPLUSPLUS_MULTIDIRACDETERMINANT_H 62 std::unique_ptr<Resource>
makeClone()
const override 64 return std::make_unique<MultiDiracDetMultiWalkerResource>(*this);
143 std::unique_ptr<SPOSet>
clonePhi()
const;
147 std::string
getClassName()
const override {
return "MultiDiracDeterminant"; }
154 Phi->extractOptimizableObjectRefs(opt_obj_refs);
159 if (
Phi->isOptimizable())
160 Phi->checkOutVariables(active);
180 const std::vector<ValueType>& Coeff,
181 const std::vector<size_t>& C2node_up,
182 const std::vector<size_t>& C2node_dn);
189 const std::vector<ValueType>& Coeff,
190 const std::vector<size_t>& C2node_up,
191 const std::vector<size_t>& C2node_dn);
206 void restore(
int iat)
override;
211 const std::vector<bool>& isAccepted);
227 APP_ABORT(
" MultiDiracDeterminant: This should not be called. \n");
233 APP_ABORT(
" MultiDiracDeterminant: This should not be called. \n");
239 APP_ABORT(
" MultiDiracDeterminant: This should not be called. \n");
247 APP_ABORT(
" MultiDiracDeterminant: This should not be called. \n");
253 APP_ABORT(
" MultiDiracDeterminant: This should not be called. \n");
272 const std::vector<ci_configuration2>& configlist_unsorted,
273 const std::vector<size_t>& C2nodes_unsorted,
274 std::vector<size_t>& C2nodes_sorted);
293 UnpinnedOffloadMatrix<ValueType>& mw_grads);
304 UnpinnedOffloadMatrix<ValueType>& mw_grads);
332 const int working_index,
336 const size_t psiMinv_rows)
const;
348 const size_t det_offset,
349 const size_t data_offset,
353 const RefVector<OffloadMatrix<ValueType>>& table_matrix_list,
370 template<
unsigned EXT_LEVEL>
372 const size_t data_offset,
376 const size_t num_table_matrix_cols,
394 const RefVector<OffloadMatrix<ValueType>>& psiinv_list,
395 const RefVector<OffloadMatrix<ValueType>>& psi_list,
399 const RefVector<OffloadMatrix<ValueType>>& table_matrix_list,
416 const OffloadMatrix<ValueType>& psiinv,
417 const OffloadMatrix<ValueType>& psi,
427 const OffloadMatrix<ValueType>& psiinv,
428 const OffloadMatrix<ValueType>& psi,
438 const RefVector<OffloadMatrix<ValueType>>& psiinv_list,
439 const RefVector<OffloadMatrix<ValueType>>& psi_list,
443 const RefVector<OffloadMatrix<ValueType>>& table_matrix_list,
460 const OffloadMatrix<ValueType>& psiinv,
461 const OffloadMatrix<ValueType>& psi,
492 const RefVector<OffloadMatrix<ValueType>>& psiinv_list,
493 const RefVector<OffloadMatrix<ValueType>>& psi_list,
498 const RefVector<OffloadMatrix<ValueType>>& table_matrix_list,
499 UnpinnedOffloadMatrix<ValueType>& mw_grads);
503 const OffloadMatrix<ValueType>& psiinv,
504 const OffloadMatrix<ValueType>& psi,
516 const std::unique_ptr<SPOSet>
Phi;
594 std::shared_ptr<VectorSoaContainer<int, 2, OffloadPinnedAllocator<int>>>
uniquePairs;
base class for Single-particle orbital sets
Vector< IndexType > Pivot
OffloadVector< ValueType > curRatio_list
~MultiDiracDeterminant() override
default destructor
NewTimer & evaluateGrads_timer
OffloadVector< ValueType * > TpsiM_deviceptr_list
ValueType * LastAddressOfGrads
std::shared_ptr< OffloadVector< size_t > > refdet_occup
reference determinant occupation
Matrix< ValueType > lapls
store determinant lapls (old and new)
OffloadMatrix< ValueType > dpsiMinv
NewTimer & updateInverse_timer
WaveFunctionComponent::PsiValue PsiValue
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
Matrix< GradType > new_grads
helper functions for EinsplineSetBuilder
QTBase::GradType GradType
std::shared_ptr< OffloadVector< int > > detData
MultiDiracDeterminant & operator=(const MultiDiracDeterminant &s)=delete
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
OffloadVector< GradType * > dpsiM_deviceptr_list
const int NumPtcls
number of particles which belong to this Dirac determinant
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
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
void fill_n(T *x, size_t count, const T &value)
int getFirstIndex() const
ResourceHandle manages the temporary resource referenced from a collection.
NewTimer & calculateRatios_timer
Walker_t::WFBuffer_t WFBufferType
OffloadVector< ValueType > czero_vec
OffloadMatrix< ValueType > psiMinv_temp
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
Matrix< GradType > grads
store determinant grads (old and new)
LatticeGaussianProduct::GradType GradType
opt_variables_type myVars
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, ...}
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
SoA adaptor class for Vector<TinyVector<T,D> >
Timer accumulates time and call counts.
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...
std::unique_ptr< Resource > makeClone() const override
void evaluateGradsWithSpin(ParticleSet &P, int iat)
evaluate the gradients of all the unique determinants with one electron moved. Used by the table meth...
Attaches a unit to a Vector for IO.
OffloadVector< ValueType * > table_matrix_deviceptr_list
NewTimer & buildTable_timer
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
static constexpr size_t MaxSmallDet
for matrices with leading dimensions <= MaxSmallDet, compute determinant with direct expansion...
void evaluateForWalkerMoveWithSpin(const ParticleSet &P, bool fromScratch=true)
OffloadVector< ValueType * > psiMinv_temp_deviceptr_list
const OffloadVector< ValueType > & getNewRatiosToRefDet() const
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 lev...
static void mw_accept_rejectMove(const RefVectorWithLeader< MultiDiracDeterminant > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted)
OffloadVector< ValueType * > workV2_deviceptr_list
NewTimer & table2ratios_timer
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
OffloadVector< ValueType * > psiMinv_deviceptr_list
OffloadMatrix< ValueType > TpsiM
ValueType * LastAddressOfdpsiM
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) final
extract underlying OptimizableObject references
ValueType evaluate(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)
std::complex< QTFull::RealType > LogValue
PsiValue getRefDetRatio() const
const Matrix< ValueType > & getNewSpinGrads() const
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
void buildOptVariables(std::vector< size_t > &C2node)
create optimizable orbital rotation parameters
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 ...
An abstract class for a component of a many-body trial wave function.
OffloadVector< ValueType * > psi_deviceptr_list
void evaluateDetsAndGradsForPtclMoveWithSpin(const ParticleSet &P, int iat)
evaluate the value and gradients of all the unique determinants with one electron moved...
Specialized paritlce class for atomistic simulations.
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
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 acquireResource(ResourceCollection &collection, const RefVectorWithLeader< MultiDiracDeterminant > &wfc_list) const
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< MultiDiracDeterminant > &wfc_list) const
OffloadVector< ValueType > psiV
value of single-particle orbital for particle-by-particle update
SPOSet::ValueMatrix ValueMatrix
NewTimer & evalOrbValue_timer
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
void mw_updateRatios_det0(const OffloadVector< ValueType > &det0_list, const OffloadVector< ValueType *> &ratios_deviceptr_list) const
update ratios of the reference deteriminant
std::shared_ptr< OffloadVector< RealType > > DetSigns
OffloadVector< ValueType > workV1
void resizeConstants(size_t nw)
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
static void mw_evaluateDetsForPtclMove(const RefVectorWithLeader< MultiDiracDeterminant > &det_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat)
multi walker version of evaluateDetsForPtclMove
NewTimer & evalOrbVGL_timer
OrbitalSetTraits< ValueType >::ValueVector ValueVector
const Matrix< GradType > & getGrads() const
Matrix< ValueType > spingrads
class to handle a set of variables that can be modified during optimizations
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
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
Matrix< ValueType > new_spingrads
OffloadVector< ValueType * > psiV_deviceptr_list
ValueType curRatio
new value of the reference determinant over the old value upon a proposed move
OffloadVector< ValueType > WorkSpace
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
QTFull::ValueType PsiValue
MultiDiracDetMultiWalkerResource()
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
OffloadVector< ValueType * > psiV_temp_deviceptr_list
bool isFermionic() const final
true, if this component is fermionic
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
move was accepted, update the real container
const Matrix< ValueType > & getNewLapls() const
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...
OMPallocator is an allocator with fused device and dualspace allocator functionality.
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
OffloadVector< ValueType * > dpsiMinv_deviceptr_list
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
bool isOptimizable() const final
if true, this contains optimizable components
OffloadMatrix< ValueType > table_matrix
SmallMatrixDetCalculator< ValueType > det_calculator_
OffloadVector< ValueType > psiV_temp
std::unique_ptr< SPOSet > clonePhi() const
return a clone of Phi
Define determinant operators.
OffloadVector< ValueType * > ratios_deviceptr_list
std::vector< std::reference_wrapper< T > > RefVector
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)
NewTimer & updateRatios_timer
const Matrix< ValueType > & getSpinGrads() const
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
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)
MultiDiracDeterminant(std::unique_ptr< SPOSet > &&spos, bool spinor, int first, int nel)
constructor
OffloadVector< ValueType > cminus_one_vec
void evaluateDetsForPtclMove(const ParticleSet &P, int iat, int refPtcl=-1)
evaluate the value of all the unique determinants with one electron moved.
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 ...
ResourceHandle< MultiDiracDetMultiWalkerResource > mw_res_handle_
void restore(int iat) override
move was rejected.
void evaluateDetsAndGradsForPtclMove(const ParticleSet &P, int iat)
evaluate the value and gradients of all the unique determinants with one electron moved...
ValueType * FirstAddressOfdpsiM
const Matrix< ValueType > & getLapls() const
LogValue getLogValueRefDet() const
void evaluateForWalkerMove(const ParticleSet &P, bool fromScratch=true)
NewTimer & evaluateDetsForPtclMove_timer
OffloadVector< GradType > ratioGradRef_list
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
OffloadVector< GradType > dpsiV
LatticeGaussianProduct::ValueType ValueType
void resize()
reset the size: with the number of particles
OffloadVector< ValueType * > workV1_deviceptr_list
NewTimer & calculateGradRatios_timer
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
OffloadVector< ValueType * > psiM_deviceptr_list
Declaration of WaveFunctionComponent.
std::complex< double > LogValue
Matrix< ValueType > new_lapls
const int LastIndex
index of the last particle with respect to the particle set
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
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
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
OffloadVector< GradType * > dpsiV_deviceptr_list
std::vector< std::vector< int > > lookup_tbl
const Matrix< GradType > & getNewGrads() const
std::string getClassName() const override
return class name
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const override
make clone
OffloadVector< ValueType > det0_grad_list
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 ...
const OffloadVector< ValueType > & getRatiosToRefDet() const
void evaluateGrads(ParticleSet &P, int iat)
evaluate the gradients of all the unique determinants with one electron moved. Used by the table meth...
MultiDiracDetMultiWalkerResource(const MultiDiracDetMultiWalkerResource &)
NewTimer & evaluateDetsAndGradsForPtclMove_timer
NewTimer & transferH2D_timer
OffloadVector< ValueType * > psiinv_deviceptr_list
OffloadVector< ValueType > d2psiV
NewTimer & transferD2H_timer
OffloadVector< ValueType > workV2
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
ValueType * FirstAddressOfGrads
OffloadVector< ValueType > cone_vec
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...
SPOSet::ValueVector ValueVector
OffloadVector< ValueType > inv_curRatio_list
NewTimer & evalWalker_timer