QMCPACK
SpinorSet Class Reference

Class for Melton & Mitas style Spinors. More...

+ Inheritance diagram for SpinorSet:
+ Collaboration diagram for SpinorSet:

Classes

struct  SpinorSetMultiWalkerResource
 

Public Member Functions

 SpinorSet (const std::string &my_name)
 constructor More...
 
 ~SpinorSet () override
 
std::string getClassName () const override
 return class name More...
 
bool isOptimizable () const override
 Query if this SPOSet is optimizable. More...
 
bool isOMPoffload () const override
 Query if this SPOSet uses OpenMP offload. More...
 
bool hasIonDerivs () const override
 Query if this SPOSet has an explicit ion dependence. More...
 
bool isRotationSupported () const override
 return true if this SPOSet can be wrappered by RotatedSPO More...
 
void storeParamsBeforeRotation () override
 store parameters before getting destroyed by rotation. More...
 
void applyRotation (const ValueMatrix &rot_mat, bool use_stored_copy) override
 apply rotation to all the orbitals More...
 
void set_spos (std::unique_ptr< SPOSet > &&up, std::unique_ptr< SPOSet > &&dn)
 
void setOrbitalSetSize (int norbs) override
 set the OrbitalSetSize More...
 
void evaluateValue (const ParticleSet &P, int iat, ValueVector &psi) override
 evaluate the values of this spinor set More...
 
void evaluateDetSpinorRatios (const VirtualParticleSet &VP, ValueVector &psi, const std::pair< ValueVector, ValueVector > &spinor_multipler, const ValueVector &invrow, std::vector< ValueType > &ratios) override
 evaluate determinant ratios for virtual moves, specifically for Spinor SPOSets More...
 
void evaluateVGL (const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi) override
 evaluate the values, gradients and laplacians of this single-particle orbital set More...
 
void evaluateVGL_spin (const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi, ValueVector &dspin) override
 evaluate the values, gradients and laplacians of this single-particle orbital set More...
 
void mw_evaluateVGLWithSpin (const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const RefVector< ValueVector > &psi_v_list, const RefVector< GradVector > &dpsi_v_list, const RefVector< ValueVector > &d2psi_v_list, OffloadMatrix< ComplexType > &mw_dspin) const override
 evaluate the values, gradients and laplacians and spin gradient of this single-particle orbital sets of multiple walkers More...
 
void mw_evaluateVGLandDetRatioGradsWithSpin (const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const std::vector< const ValueType *> &invRow_ptr_list, OffloadMWVGLArray &phi_vgl_v, std::vector< ValueType > &ratios, std::vector< GradType > &grads, std::vector< ValueType > &spingrads) const override
 evaluate the values, gradients and laplacians of this single-particle orbital sets and determinant ratio and grads of multiple walkers. More...
 
void evaluate_notranspose (const ParticleSet &P, int first, int last, ValueMatrix &logdet, GradMatrix &dlogdet, ValueMatrix &d2logdet) override
 evaluate the values, gradients and laplacians of this single-particle orbital for [first,last) particles More...
 
void mw_evaluate_notranspose (const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int first, int last, const RefVector< ValueMatrix > &logdet_list, const RefVector< GradMatrix > &dlogdet_list, const RefVector< ValueMatrix > &d2logdet_list) const override
 
void evaluate_notranspose_spin (const ParticleSet &P, int first, int last, ValueMatrix &logdet, GradMatrix &dlogdet, ValueMatrix &d2logdet, ValueMatrix &dspinlogdet) override
 evaluate the values, gradients and laplacians of this single-particle orbital for [first,last) particles, including the spin gradient More...
 
void evaluate_spin (const ParticleSet &P, int iat, ValueVector &psi, ValueVector &dpsi) override
 Evaluate the values, spin gradients, and spin laplacians of single particle spinors corresponding to electron iat. More...
 
virtual void evaluateGradSource (const ParticleSet &P, int first, int last, const ParticleSet &source, int iat_src, GradMatrix &gradphi) override
 evaluate the gradients of this single-particle orbital for [first,last) target particles with respect to the given source particle More...
 
std::unique_ptr< SPOSetmakeClone () const override
 make a clone of itself every derived class must implement this to have threading working correctly. More...
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< SPOSet > &spo_list) const override
 acquire a shared resource from collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< SPOSet > &spo_list) const override
 return a shared resource to collection More...
 
bool isResourceOwned () const
 check if the multi walker resource is owned. For testing only. More...
 
- Public Member Functions inherited from SPOSet
 SPOSet (const std::string &my_name)
 constructor More...
 
virtual ~SPOSet ()=default
 destructor More...
 
int size () const
 return the size of the orbital set Ye: this needs to be replaced by getOrbitalSetSize(); More...
 
void basic_report (const std::string &pad="") const
 print basic SPOSet information More...
 
virtual void report (const std::string &pad="") const
 print SPOSet information More...
 
int getOrbitalSetSize () const
 return the size of the orbitals More...
 
virtual void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs)
 extract underlying OptimizableObject references More...
 
virtual void checkOutVariables (const opt_variables_type &active)
 check out variational optimizable variables More...
 
virtual void checkObject () const
 check a few key parameters before putting the SPO into a determinant More...
 
virtual void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi, const int &FirstIndex, const int &LastIndex)
 Parameter derivatives of the wavefunction and the Laplacian of the wavefunction. More...
 
virtual void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, int FirstIndex, int LastIndex)
 Parameter derivatives of the wavefunction. More...
 
virtual void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi, const ValueType &psiCurrent, const std::vector< ValueType > &Coeff, const std::vector< size_t > &C2node_up, const std::vector< size_t > &C2node_dn, const ValueVector &detValues_up, const ValueVector &detValues_dn, const GradMatrix &grads_up, const GradMatrix &grads_dn, const ValueMatrix &lapls_up, const ValueMatrix &lapls_dn, const ValueMatrix &M_up, const ValueMatrix &M_dn, const ValueMatrix &Minv_up, const ValueMatrix &Minv_dn, const GradMatrix &B_grad, const ValueMatrix &B_lapl, const std::vector< int > &detData_up, const size_t N1, const size_t N2, const size_t NP1, const size_t NP2, const std::vector< std::vector< int >> &lookup_tbl)
 Evaluate the derivative of the optimized orbitals with respect to the parameters this is used only for MSD, to be refined for better serving both single and multi SD. More...
 
virtual void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, const QTFull::ValueType &psiCurrent, const std::vector< ValueType > &Coeff, const std::vector< size_t > &C2node_up, const std::vector< size_t > &C2node_dn, const ValueVector &detValues_up, const ValueVector &detValues_dn, const ValueMatrix &M_up, const ValueMatrix &M_dn, const ValueMatrix &Minv_up, const ValueMatrix &Minv_dn, const std::vector< int > &detData_up, const std::vector< std::vector< int >> &lookup_tbl)
 Evaluate the derivative of the optimized orbitals with respect to the parameters this is used only for MSD, to be refined for better serving both single and multi SD. More...
 
virtual void evaluateDetRatios (const VirtualParticleSet &VP, ValueVector &psi, const ValueVector &psiinv, std::vector< ValueType > &ratios)
 evaluate determinant ratios for virtual moves, e.g., sphere move for nonlocalPP More...
 
virtual void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, ValueVector &psi, const ValueVector &psiinv, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios, int FirstIndex, int LastIndex)
 Determinant ratios and parameter derivatives of the wavefunction for virtual moves. More...
 
virtual void mw_evaluateDetRatios (const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, const RefVector< ValueVector > &psi_list, const std::vector< const ValueType *> &invRow_ptr_list, std::vector< std::vector< ValueType >> &ratios_list) const
 evaluate determinant ratios for virtual moves, e.g., sphere move for nonlocalPP, of multiple walkers More...
 
virtual void mw_evaluateValue (const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const RefVector< ValueVector > &psi_v_list) const
 evaluate the values this single-particle orbital sets of multiple walkers More...
 
virtual void mw_evaluateVGL (const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const RefVector< ValueVector > &psi_v_list, const RefVector< GradVector > &dpsi_v_list, const RefVector< ValueVector > &d2psi_v_list) const
 evaluate the values, gradients and laplacians of this single-particle orbital sets of multiple walkers More...
 
virtual void mw_evaluateVGLandDetRatioGrads (const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const std::vector< const ValueType *> &invRow_ptr_list, OffloadMWVGLArray &phi_vgl_v, std::vector< ValueType > &ratios, std::vector< GradType > &grads) const
 evaluate the values, gradients and laplacians of this single-particle orbital sets and determinant ratio and grads of multiple walkers. More...
 
virtual void evaluateVGH (const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, HessVector &grad_grad_psi)
 evaluate the values, gradients and hessians of this single-particle orbital set More...
 
virtual void evaluateVGHGH (const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, HessVector &grad_grad_psi, GGGVector &grad_grad_grad_psi)
 evaluate the values, gradients, hessians, and grad hessians of this single-particle orbital set More...
 
virtual void evaluateThirdDeriv (const ParticleSet &P, int first, int last, GGGMatrix &grad_grad_grad_logdet)
 evaluate the third derivatives of this single-particle orbital set More...
 
virtual void evaluate_notranspose (const ParticleSet &P, int first, int last, ValueMatrix &logdet, GradMatrix &dlogdet, HessMatrix &grad_grad_logdet)
 evaluate the values, gradients and hessians of this single-particle orbital for [first,last) particles More...
 
virtual void evaluate_notranspose (const ParticleSet &P, int first, int last, ValueMatrix &logdet, GradMatrix &dlogdet, HessMatrix &grad_grad_logdet, GGGMatrix &grad_grad_grad_logdet)
 evaluate the values, gradients, hessians and third derivatives of this single-particle orbital for [first,last) particles More...
 
virtual void evaluateGradSource (const ParticleSet &P, int first, int last, const ParticleSet &source, int iat_src, GradMatrix &grad_phi, HessMatrix &grad_grad_phi, GradMatrix &grad_lapl_phi)
 evaluate the gradients of values, gradients, laplacians of this single-particle orbital for [first,last) target particles with respect to the given source particle More...
 
virtual void evaluateGradSourceRow (const ParticleSet &P, int iel, const ParticleSet &source, int iat_src, GradVector &gradphi)
 Returns a row of d/dR_iat phi_j(r) evaluated at position r. More...
 
virtual PosType get_k (int orb)
 access the k point related to the given orbital More...
 
virtual bool transformSPOSet ()
 Used only by cusp correction in AOS LCAO. More...
 
virtual void finalizeConstruction ()
 finalize the construction of SPOSet More...
 
const std::string & getName () const
 return object name More...
 

Private Member Functions

std::pair< RefVectorWithLeader< SPOSet >, RefVectorWithLeader< SPOSet > > extractSpinComponentRefList (const RefVectorWithLeader< SPOSet > &spo_list) const
 

Private Attributes

ResourceHandle< SpinorSetMultiWalkerResourcemw_res_handle_
 
std::unique_ptr< SPOSetspo_up
 
std::unique_ptr< SPOSetspo_dn
 
ValueVector psi_work_up
 
ValueVector psi_work_down
 
GradVector dpsi_work_up
 
GradVector dpsi_work_down
 
ValueVector d2psi_work_up
 
ValueVector d2psi_work_down
 
ValueMatrix logpsi_work_up
 
ValueMatrix logpsi_work_down
 
GradMatrix dlogpsi_work_up
 
GradMatrix dlogpsi_work_down
 
ValueMatrix d2logpsi_work_up
 
ValueMatrix d2logpsi_work_down
 

Additional Inherited Members

- Public Types inherited from SPOSet
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradVector = OrbitalSetTraits< ValueType >::GradVector
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using HessMatrix = OrbitalSetTraits< ValueType >::HessMatrix
 
using GGGVector = OrbitalSetTraits< ValueType >::GradHessVector
 
using GGGMatrix = OrbitalSetTraits< ValueType >::GradHessMatrix
 
using SPOMap = std::map< std::string, const std::unique_ptr< const SPOSet > >
 
using OffloadMWVGLArray = Array< ValueType, 3, OffloadPinnedAllocator< ValueType > >
 
using OffloadMWVArray = Array< ValueType, 2, OffloadPinnedAllocator< ValueType > >
 
template<typename DT >
using OffloadMatrix = Matrix< DT, OffloadPinnedAllocator< DT > >
 
- 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 > >
 
- Protected Attributes inherited from SPOSet
const std::string my_name_
 name of the object, unique identifier More...
 
IndexType OrbitalSetSize
 number of Single-particle orbitals More...
 
opt_variables_type myVars
 Optimizable variables. More...
 

Detailed Description

Class for Melton & Mitas style Spinors.

Definition at line 24 of file SpinorSet.h.

Constructor & Destructor Documentation

◆ SpinorSet()

SpinorSet ( const std::string &  my_name)

constructor

Definition at line 31 of file SpinorSet.cpp.

31 : SPOSet(my_name), spo_up(nullptr), spo_dn(nullptr) {}
SPOSet(const std::string &my_name)
constructor
Definition: SPOSet.cpp:29
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201

◆ ~SpinorSet()

~SpinorSet ( )
overridedefault

Member Function Documentation

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< SPOSet > &  spo_list 
) const
overridevirtual

acquire a shared resource from collection

Reimplemented from SPOSet.

Definition at line 585 of file SpinorSet.cpp.

References SpinorSet::acquireResource(), SpinorSet::extractSpinComponentRefList(), RefVectorWithLeader< T >::getCastedLeader(), and ResourceCollection::lendResource().

Referenced by SpinorSet::acquireResource().

586 {
587  auto [up_spo_list, dn_spo_list] = extractSpinComponentRefList(spo_list);
588  auto& spo_leader = spo_list.getCastedLeader<SpinorSet>();
589  auto& up_spo_leader = up_spo_list.getLeader();
590  auto& dn_spo_leader = dn_spo_list.getLeader();
591  up_spo_leader.acquireResource(collection, up_spo_list);
592  dn_spo_leader.acquireResource(collection, dn_spo_list);
593  spo_leader.mw_res_handle_ = collection.lendResource<SpinorSetMultiWalkerResource>();
594 }
std::pair< RefVectorWithLeader< SPOSet >, RefVectorWithLeader< SPOSet > > extractSpinComponentRefList(const RefVectorWithLeader< SPOSet > &spo_list) const
Definition: SpinorSet.cpp:607
SpinorSet(const std::string &my_name)
constructor
Definition: SpinorSet.cpp:31

◆ applyRotation()

void applyRotation ( const ValueMatrix rot_mat,
bool  use_stored_copy 
)
overridevirtual

apply rotation to all the orbitals

Reimplemented from SPOSet.

Definition at line 40 of file SpinorSet.cpp.

References SpinorSet::spo_dn, and SpinorSet::spo_up.

41 {
42  spo_up->applyRotation(rot_mat, use_stored_copy);
43  spo_dn->applyRotation(rot_mat, use_stored_copy);
44 }
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to collection

Reimplemented from SPOSet.

Definition at line 578 of file SpinorSet.cpp.

References ResourceCollection::addResource(), SpinorSet::spo_dn, and SpinorSet::spo_up.

579 {
580  spo_up->createResource(collection);
581  spo_dn->createResource(collection);
582  auto index = collection.addResource(std::make_unique<SpinorSetMultiWalkerResource>());
583 }
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201

◆ evaluate_notranspose()

void evaluate_notranspose ( const ParticleSet P,
int  first,
int  last,
ValueMatrix logdet,
GradMatrix dlogdet,
ValueMatrix d2logdet 
)
overridevirtual

evaluate the values, gradients and laplacians of this single-particle orbital for [first,last) particles

Parameters
Pcurrent ParticleSet
firststarting index of the particles
lastending index of the particles
logdetdeterminant matrix to be inverted
dlogdetgradients
d2logdetlaplacians

Implements SPOSet.

Definition at line 337 of file SpinorSet.cpp.

References ParticleSet::activeSpin(), qmcplusplus::cos(), SpinorSet::d2logpsi_work_down, SpinorSet::d2logpsi_work_up, SpinorSet::dlogpsi_work_down, SpinorSet::dlogpsi_work_up, ParticleSet::getTotalNum(), SpinorSet::logpsi_work_down, SpinorSet::logpsi_work_up, qmcplusplus::Units::time::s, qmcplusplus::sin(), SpinorSet::spo_dn, and SpinorSet::spo_up.

343 {
344  IndexType nelec = P.getTotalNum();
345 
346  const size_t norb_requested = logdet.cols();
347 
348  logpsi_work_up.resize(nelec, norb_requested);
349  logpsi_work_down.resize(nelec, norb_requested);
350 
351  dlogpsi_work_up.resize(nelec, norb_requested);
352  dlogpsi_work_down.resize(nelec, norb_requested);
353 
354  d2logpsi_work_up.resize(nelec, norb_requested);
355  d2logpsi_work_down.resize(nelec, norb_requested);
356 
357  spo_up->evaluate_notranspose(P, first, last, logpsi_work_up, dlogpsi_work_up, d2logpsi_work_up);
358  spo_dn->evaluate_notranspose(P, first, last, logpsi_work_down, dlogpsi_work_down, d2logpsi_work_down);
359 
360 
361  for (int iat = first; iat < last; iat++)
362  {
363  ParticleSet::Scalar_t s = P.activeSpin(iat);
364 
365  RealType coss(0.0), sins(0.0);
366 
367  coss = std::cos(s);
368  sins = std::sin(s);
369 
370  ValueType eis(coss, sins);
371  ValueType emis(coss, -sins);
372 
373  for (int no = 0; no < norb_requested; no++)
374  {
375  logdet(iat, no) = eis * logpsi_work_up(iat, no) + emis * logpsi_work_down(iat, no);
376  dlogdet(iat, no) = eis * dlogpsi_work_up(iat, no) + emis * dlogpsi_work_down(iat, no);
377  d2logdet(iat, no) = eis * d2logpsi_work_up(iat, no) + emis * d2logpsi_work_down(iat, no);
378  }
379  }
380 }
ValueMatrix logpsi_work_up
Definition: SpinorSet.h:216
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
ValueMatrix d2logpsi_work_up
Definition: SpinorSet.h:222
GradMatrix dlogpsi_work_down
Definition: SpinorSet.h:220
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201
ValueMatrix logpsi_work_down
Definition: SpinorSet.h:217
GradMatrix dlogpsi_work_up
Definition: SpinorSet.h:219
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
QMCTraits::RealType RealType
ValueMatrix d2logpsi_work_down
Definition: SpinorSet.h:223

◆ evaluate_notranspose_spin()

void evaluate_notranspose_spin ( const ParticleSet P,
int  first,
int  last,
ValueMatrix logdet,
GradMatrix dlogdet,
ValueMatrix d2logdet,
ValueMatrix dspinlogdet 
)
overridevirtual

evaluate the values, gradients and laplacians of this single-particle orbital for [first,last) particles, including the spin gradient

Parameters
Pcurrent ParticleSet
firststarting index of the particles
lastending index of the particles
logdetdeterminant matrix to be inverted
dlogdetgradients
d2logdetlaplacians
dspinlogdet,spingradients

default implementation will abort for all SPOSets except SpinorSet

Reimplemented from SPOSet.

Definition at line 468 of file SpinorSet.cpp.

References ParticleSet::activeSpin(), qmcplusplus::cos(), SpinorSet::d2logpsi_work_down, SpinorSet::d2logpsi_work_up, SpinorSet::dlogpsi_work_down, SpinorSet::dlogpsi_work_up, ParticleSet::getTotalNum(), SpinorSet::logpsi_work_down, SpinorSet::logpsi_work_up, qmcplusplus::Units::time::s, qmcplusplus::sin(), SpinorSet::spo_dn, and SpinorSet::spo_up.

475 {
476  IndexType nelec = P.getTotalNum();
477 
478  const size_t norb_requested = logdet.cols();
479  logpsi_work_up.resize(nelec, norb_requested);
480  logpsi_work_down.resize(nelec, norb_requested);
481 
482  dlogpsi_work_up.resize(nelec, norb_requested);
483  dlogpsi_work_down.resize(nelec, norb_requested);
484 
485  d2logpsi_work_up.resize(nelec, norb_requested);
486  d2logpsi_work_down.resize(nelec, norb_requested);
487 
488  spo_up->evaluate_notranspose(P, first, last, logpsi_work_up, dlogpsi_work_up, d2logpsi_work_up);
489  spo_dn->evaluate_notranspose(P, first, last, logpsi_work_down, dlogpsi_work_down, d2logpsi_work_down);
490 
491 
492  for (int iat = 0; iat < nelec; iat++)
493  {
494  ParticleSet::Scalar_t s = P.activeSpin(iat);
495 
496  RealType coss(0.0), sins(0.0);
497 
498  coss = std::cos(s);
499  sins = std::sin(s);
500 
501  ValueType eis(coss, sins);
502  ValueType emis(coss, -sins);
503  ValueType eye(0, 1.0);
504 
505  for (int no = 0; no < norb_requested; no++)
506  {
507  logdet(iat, no) = eis * logpsi_work_up(iat, no) + emis * logpsi_work_down(iat, no);
508  dlogdet(iat, no) = eis * dlogpsi_work_up(iat, no) + emis * dlogpsi_work_down(iat, no);
509  d2logdet(iat, no) = eis * d2logpsi_work_up(iat, no) + emis * d2logpsi_work_down(iat, no);
510  dspinlogdet(iat, no) = eye * (eis * logpsi_work_up(iat, no) - emis * logpsi_work_down(iat, no));
511  }
512  }
513 }
ValueMatrix logpsi_work_up
Definition: SpinorSet.h:216
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
ValueMatrix d2logpsi_work_up
Definition: SpinorSet.h:222
GradMatrix dlogpsi_work_down
Definition: SpinorSet.h:220
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201
ValueMatrix logpsi_work_down
Definition: SpinorSet.h:217
GradMatrix dlogpsi_work_up
Definition: SpinorSet.h:219
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
QMCTraits::RealType RealType
ValueMatrix d2logpsi_work_down
Definition: SpinorSet.h:223

◆ evaluate_spin()

void evaluate_spin ( const ParticleSet P,
int  iat,
ValueVector psi,
ValueVector dpsi 
)
overridevirtual

Evaluate the values, spin gradients, and spin laplacians of single particle spinors corresponding to electron iat.

Parameters
Pcurrent particle set.
iatelectron index.
spinorvalues.
spingradient values. d/ds phi(r,s).

Reimplemented from SPOSet.

Definition at line 516 of file SpinorSet.cpp.

References ParticleSet::activeSpin(), qmcplusplus::cos(), SpinorSet::psi_work_down, SpinorSet::psi_work_up, qmcplusplus::Units::time::s, qmcplusplus::sin(), SpinorSet::spo_dn, and SpinorSet::spo_up.

517 {
518  const size_t norb_requested = psi.size();
519  psi_work_up.resize(norb_requested);
520  psi_work_down.resize(norb_requested);
521  psi_work_up = 0.0;
522  psi_work_down = 0.0;
523 
524  spo_up->evaluateValue(P, iat, psi_work_up);
525  spo_dn->evaluateValue(P, iat, psi_work_down);
526 
527  ParticleSet::Scalar_t s = P.activeSpin(iat);
528 
529  RealType coss(0.0), sins(0.0);
530 
531  coss = std::cos(s);
532  sins = std::sin(s);
533 
534  ValueType eis(coss, sins);
535  ValueType emis(coss, -sins);
536  ValueType eye(0, 1.0);
537 
538  psi = eis * psi_work_up + emis * psi_work_down;
539  dpsi = eye * (eis * psi_work_up - emis * psi_work_down);
540 }
ValueVector psi_work_up
Definition: SpinorSet.h:204
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201
QMCTraits::RealType RealType
ValueVector psi_work_down
Definition: SpinorSet.h:205

◆ evaluateDetSpinorRatios()

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

evaluate determinant ratios for virtual moves, specifically for Spinor SPOSets

Parameters
VPvirtual particle set
psivalues of the SPO, used as a scratch space if needed
spinor_multiplierfactor to apply to the up and down components independently
invrowthe row of inverse slater matrix corresponding to the particle moved virtually
ratiosreturn determinant ratios

Reimplemented from SPOSet.

Definition at line 89 of file SpinorSet.cpp.

References ParticleSet::activeSpin(), qmcplusplus::cos(), qmcplusplus::simd::dot(), VirtualParticleSet::getTotalNum(), SpinorSet::psi_work_down, SpinorSet::psi_work_up, qmcplusplus::Units::time::s, qmcplusplus::sin(), SpinorSet::spo_dn, and SpinorSet::spo_up.

94 {
95  assert(psi.size() == psiinv.size());
96  const size_t norb_requested = psi.size();
97  psi_work_up.resize(norb_requested);
98  psi_work_down.resize(norb_requested);
99 
100  for (size_t iat = 0.0; iat < VP.getTotalNum(); iat++)
101  {
102  psi_work_up = 0.0;
103  psi_work_down = 0.0;
104  spo_up->evaluateValue(VP, iat, psi_work_up);
105  spo_dn->evaluateValue(VP, iat, psi_work_down);
106 
107  ParticleSet::Scalar_t s = VP.activeSpin(iat);
108  RealType coss = std::cos(s);
109  RealType sins = std::sin(s);
110 
111  ValueType eis(coss, sins);
112  ValueType emis(coss, -sins);
113 
114  psi = spinor_multiplier.first[iat] * eis * psi_work_up + spinor_multiplier.second[iat] * emis * psi_work_down;
115  ratios[iat] = simd::dot(psi.data(), psiinv.data(), psi.size());
116  }
117 }
ValueVector psi_work_up
Definition: SpinorSet.h:204
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201
QMCTraits::RealType RealType
ValueVector psi_work_down
Definition: SpinorSet.h:205

◆ evaluateGradSource()

void evaluateGradSource ( const ParticleSet P,
int  first,
int  last,
const ParticleSet source,
int  iat_src,
GradMatrix gradphi 
)
overridevirtual

evaluate the gradients of this single-particle orbital for [first,last) target particles with respect to the given source particle

Parameters
Pcurrent ParticleSet
firststarting index of the particles
lastending index of the particles
iat_srcsource particle index
gradphigradients

Reimplemented from SPOSet.

Definition at line 542 of file SpinorSet.cpp.

References ParticleSet::activeSpin(), qmcplusplus::cos(), ParticleSet::getTotalNum(), qmcplusplus::Units::time::s, qmcplusplus::sin(), SpinorSet::spo_dn, and SpinorSet::spo_up.

548 {
549  IndexType nelec = P.getTotalNum();
550 
551  const size_t norb_requested = gradphi.size();
552  GradMatrix gradphi_up(nelec, norb_requested);
553  GradMatrix gradphi_dn(nelec, norb_requested);
554  spo_up->evaluateGradSource(P, first, last, source, iat_src, gradphi_up);
555  spo_dn->evaluateGradSource(P, first, last, source, iat_src, gradphi_dn);
556 
557  for (int iat = first; iat < last; iat++)
558  {
559  ParticleSet::Scalar_t s = P.activeSpin(iat);
560  RealType coss = std::cos(s);
561  RealType sins = std::sin(s);
562  ValueType eis(coss, sins);
563  ValueType emis(coss, -sins);
564  for (int imo = 0; imo < norb_requested; imo++)
565  gradphi(iat, imo) = gradphi_up(iat, imo) * eis + gradphi_dn(iat, imo) * emis;
566  }
567 }
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
Definition: SPOSet.h:52
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
QMCTraits::RealType RealType

◆ evaluateValue()

void evaluateValue ( const ParticleSet P,
int  iat,
ValueVector psi 
)
overridevirtual

evaluate the values of this spinor set

Parameters
Pcurrent ParticleSet
iatactive particle
psivalues of the SPO

Implements SPOSet.

Definition at line 64 of file SpinorSet.cpp.

References ParticleSet::activeSpin(), qmcplusplus::cos(), SpinorSet::psi_work_down, SpinorSet::psi_work_up, qmcplusplus::Units::time::s, qmcplusplus::sin(), SpinorSet::spo_dn, and SpinorSet::spo_up.

65 {
66  const size_t norb_requested = psi.size();
67  psi_work_up.resize(norb_requested);
68  psi_work_down.resize(norb_requested);
69  psi_work_up = 0.0;
70  psi_work_down = 0.0;
71 
72  spo_up->evaluateValue(P, iat, psi_work_up);
73  spo_dn->evaluateValue(P, iat, psi_work_down);
74 
75  ParticleSet::Scalar_t s = P.activeSpin(iat);
76 
77  RealType coss(0.0), sins(0.0);
78 
79  coss = std::cos(s);
80  sins = std::sin(s);
81 
82  //This is only supported in the complex build, so ValueType is some complex number depending on the precision.
83  ValueType eis(coss, sins);
84  ValueType emis(coss, -sins);
85 
86  psi = eis * psi_work_up + emis * psi_work_down;
87 }
ValueVector psi_work_up
Definition: SpinorSet.h:204
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201
QMCTraits::RealType RealType
ValueVector psi_work_down
Definition: SpinorSet.h:205

◆ evaluateVGL()

void evaluateVGL ( const ParticleSet P,
int  iat,
ValueVector psi,
GradVector dpsi,
ValueVector d2psi 
)
overridevirtual

evaluate the values, gradients and laplacians of this single-particle orbital set

Parameters
Pcurrent ParticleSet
iatactive particle
psivalues of the SPO
dpsigradients of the SPO
d2psilaplacians of the SPO

Implements SPOSet.

Definition at line 119 of file SpinorSet.cpp.

References ParticleSet::activeSpin(), qmcplusplus::cos(), SpinorSet::d2psi_work_down, SpinorSet::d2psi_work_up, SpinorSet::dpsi_work_down, SpinorSet::dpsi_work_up, SpinorSet::psi_work_down, SpinorSet::psi_work_up, qmcplusplus::Units::time::s, qmcplusplus::sin(), SpinorSet::spo_dn, and SpinorSet::spo_up.

120 {
121  const size_t norb_requested = psi.size();
122  psi_work_up.resize(norb_requested);
123  psi_work_down.resize(norb_requested);
124  dpsi_work_up.resize(norb_requested);
125  dpsi_work_down.resize(norb_requested);
126  d2psi_work_up.resize(norb_requested);
127  d2psi_work_down.resize(norb_requested);
128  psi_work_up = 0.0;
129  psi_work_down = 0.0;
130  dpsi_work_up = 0.0;
131  dpsi_work_down = 0.0;
132  d2psi_work_up = 0.0;
133  d2psi_work_down = 0.0;
134 
135  spo_up->evaluateVGL(P, iat, psi_work_up, dpsi_work_up, d2psi_work_up);
136  spo_dn->evaluateVGL(P, iat, psi_work_down, dpsi_work_down, d2psi_work_down);
137 
138  ParticleSet::Scalar_t s = P.activeSpin(iat);
139 
140  RealType coss(0.0), sins(0.0);
141 
142  coss = std::cos(s);
143  sins = std::sin(s);
144 
145  ValueType eis(coss, sins);
146  ValueType emis(coss, -sins);
147 
148  psi = eis * psi_work_up + emis * psi_work_down;
149  dpsi = eis * dpsi_work_up + emis * dpsi_work_down;
150  d2psi = eis * d2psi_work_up + emis * d2psi_work_down;
151 }
ValueVector psi_work_up
Definition: SpinorSet.h:204
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
ValueVector d2psi_work_down
Definition: SpinorSet.h:213
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
GradVector dpsi_work_up
Definition: SpinorSet.h:208
ValueVector d2psi_work_up
Definition: SpinorSet.h:212
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201
QMCTraits::RealType RealType
GradVector dpsi_work_down
Definition: SpinorSet.h:209
ValueVector psi_work_down
Definition: SpinorSet.h:205

◆ evaluateVGL_spin()

void evaluateVGL_spin ( const ParticleSet P,
int  iat,
ValueVector psi,
GradVector dpsi,
ValueVector d2psi,
ValueVector dspin 
)
overridevirtual

evaluate the values, gradients and laplacians of this single-particle orbital set

Parameters
Pcurrent ParticleSet
iatactive particle
psivalues of the SPO
dpsigradients of the SPO
d2psilaplacians of the SPO
dspinspin gradient of the SPO

Reimplemented from SPOSet.

Definition at line 153 of file SpinorSet.cpp.

References ParticleSet::activeSpin(), qmcplusplus::cos(), SpinorSet::d2psi_work_down, SpinorSet::d2psi_work_up, SpinorSet::dpsi_work_down, SpinorSet::dpsi_work_up, SpinorSet::psi_work_down, SpinorSet::psi_work_up, qmcplusplus::Units::time::s, qmcplusplus::sin(), SpinorSet::spo_dn, and SpinorSet::spo_up.

159 {
160  const size_t norb_requested = psi.size();
161  psi_work_up.resize(norb_requested);
162  psi_work_down.resize(norb_requested);
163  dpsi_work_up.resize(norb_requested);
164  dpsi_work_down.resize(norb_requested);
165  d2psi_work_up.resize(norb_requested);
166  d2psi_work_down.resize(norb_requested);
167  psi_work_up = 0.0;
168  psi_work_down = 0.0;
169  dpsi_work_up = 0.0;
170  dpsi_work_down = 0.0;
171  d2psi_work_up = 0.0;
172  d2psi_work_down = 0.0;
173 
174  spo_up->evaluateVGL(P, iat, psi_work_up, dpsi_work_up, d2psi_work_up);
175  spo_dn->evaluateVGL(P, iat, psi_work_down, dpsi_work_down, d2psi_work_down);
176 
177  ParticleSet::Scalar_t s = P.activeSpin(iat);
178 
179  RealType coss(0.0), sins(0.0);
180 
181  coss = std::cos(s);
182  sins = std::sin(s);
183 
184  ValueType eis(coss, sins);
185  ValueType emis(coss, -sins);
186  ValueType eye(0, 1.0);
187 
188  psi = eis * psi_work_up + emis * psi_work_down;
189  dpsi = eis * dpsi_work_up + emis * dpsi_work_down;
190  d2psi = eis * d2psi_work_up + emis * d2psi_work_down;
191  dspin = eye * (eis * psi_work_up - emis * psi_work_down);
192 }
ValueVector psi_work_up
Definition: SpinorSet.h:204
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
ValueVector d2psi_work_down
Definition: SpinorSet.h:213
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
GradVector dpsi_work_up
Definition: SpinorSet.h:208
ValueVector d2psi_work_up
Definition: SpinorSet.h:212
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201
QMCTraits::RealType RealType
GradVector dpsi_work_down
Definition: SpinorSet.h:209
ValueVector psi_work_down
Definition: SpinorSet.h:205

◆ extractSpinComponentRefList()

std::pair< RefVectorWithLeader< SPOSet >, RefVectorWithLeader< SPOSet > > extractSpinComponentRefList ( const RefVectorWithLeader< SPOSet > &  spo_list) const
private

Definition at line 607 of file SpinorSet.cpp.

References RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), SpinorSet::spo_dn, and SpinorSet::spo_up.

Referenced by SpinorSet::acquireResource(), SpinorSet::mw_evaluate_notranspose(), SpinorSet::mw_evaluateVGLandDetRatioGradsWithSpin(), SpinorSet::mw_evaluateVGLWithSpin(), and SpinorSet::releaseResource().

609 {
610  auto& spo_leader = spo_list.getCastedLeader<SpinorSet>();
611  IndexType nw = spo_list.size();
612  SPOSet& up_spo_leader = *(spo_leader.spo_up);
613  SPOSet& dn_spo_leader = *(spo_leader.spo_dn);
614  RefVectorWithLeader<SPOSet> up_spo_list(up_spo_leader);
615  RefVectorWithLeader<SPOSet> dn_spo_list(dn_spo_leader);
616  up_spo_list.reserve(nw);
617  dn_spo_list.reserve(nw);
618  for (int iw = 0; iw < nw; iw++)
619  {
620  SpinorSet& spinor = spo_list.getCastedElement<SpinorSet>(iw);
621  up_spo_list.emplace_back(*(spinor.spo_up));
622  dn_spo_list.emplace_back(*(spinor.spo_dn));
623  }
624  return std::make_pair(up_spo_list, dn_spo_list);
625 }
SPOSet(const std::string &my_name)
constructor
Definition: SPOSet.cpp:29
SpinorSet(const std::string &my_name)
constructor
Definition: SpinorSet.cpp:31
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements SPOSet.

Definition at line 31 of file SpinorSet.h.

31 { return "SpinorSet"; }

◆ hasIonDerivs()

bool hasIonDerivs ( ) const
inlineoverridevirtual

Query if this SPOSet has an explicit ion dependence.

returns true if it does.

Reimplemented from SPOSet.

Definition at line 34 of file SpinorSet.h.

References SpinorSet::spo_dn, and SpinorSet::spo_up.

34 { return spo_up->hasIonDerivs() || spo_dn->hasIonDerivs(); }
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201

◆ isOMPoffload()

bool isOMPoffload ( ) const
inlineoverridevirtual

Query if this SPOSet uses OpenMP offload.

Reimplemented from SPOSet.

Definition at line 33 of file SpinorSet.h.

References SpinorSet::spo_dn, and SpinorSet::spo_up.

33 { return spo_up->isOMPoffload() || spo_dn->isOMPoffload(); }
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201

◆ isOptimizable()

bool isOptimizable ( ) const
inlineoverridevirtual

Query if this SPOSet is optimizable.

Reimplemented from SPOSet.

Definition at line 32 of file SpinorSet.h.

References SpinorSet::spo_dn, and SpinorSet::spo_up.

32 { return spo_up->isOptimizable() || spo_dn->isOptimizable(); }
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201

◆ isResourceOwned()

bool isResourceOwned ( ) const
inline

check if the multi walker resource is owned. For testing only.

Definition at line 190 of file SpinorSet.h.

References SpinorSet::mw_res_handle_.

Referenced by qmcplusplus::test_lcao_spinor().

190 { return bool(mw_res_handle_); }
ResourceHandle< SpinorSetMultiWalkerResource > mw_res_handle_
Definition: SpinorSet.h:193

◆ isRotationSupported()

bool isRotationSupported ( ) const
inlineoverridevirtual

return true if this SPOSet can be wrappered by RotatedSPO

Reimplemented from SPOSet.

Definition at line 35 of file SpinorSet.h.

References SpinorSet::spo_dn, and SpinorSet::spo_up.

35 { return spo_up->isRotationSupported() && spo_dn->isRotationSupported(); }
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201

◆ makeClone()

std::unique_ptr< SPOSet > makeClone ( ) const
overridevirtual

make a clone of itself every derived class must implement this to have threading working correctly.

Reimplemented from SPOSet.

Definition at line 569 of file SpinorSet.cpp.

References SPOSet::my_name_, SpinorSet::spo_dn, and SpinorSet::spo_up.

570 {
571  auto myclone = std::make_unique<SpinorSet>(my_name_);
572  std::unique_ptr<SPOSet> cloneup(spo_up->makeClone());
573  std::unique_ptr<SPOSet> clonedn(spo_dn->makeClone());
574  myclone->set_spos(std::move(cloneup), std::move(clonedn));
575  return myclone;
576 }
const std::string my_name_
name of the object, unique identifier
Definition: SPOSet.h:564
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201

◆ mw_evaluate_notranspose()

void mw_evaluate_notranspose ( const RefVectorWithLeader< SPOSet > &  spo_list,
const RefVectorWithLeader< ParticleSet > &  P_list,
int  first,
int  last,
const RefVector< ValueMatrix > &  logdet_list,
const RefVector< GradMatrix > &  dlogdet_list,
const RefVector< ValueMatrix > &  d2logdet_list 
) const
overridevirtual

Reimplemented from SPOSet.

Definition at line 382 of file SpinorSet.cpp.

References qmcplusplus::cos(), SpinorSet::extractSpinComponentRefList(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::Units::time::s, and qmcplusplus::sin().

389 {
390  auto& spo_leader = spo_list.getCastedLeader<SpinorSet>();
391  auto& P_leader = P_list.getLeader();
392  assert(this == &spo_leader);
393 
394  IndexType nw = spo_list.size();
395  IndexType nelec = P_leader.getTotalNum();
396 
397  auto [up_spo_list, dn_spo_list] = extractSpinComponentRefList(spo_list);
398  auto& up_spo_leader = up_spo_list.getLeader();
399  auto& dn_spo_leader = dn_spo_list.getLeader();
400 
401  std::vector<ValueMatrix> mw_up_logdet, mw_dn_logdet;
402  std::vector<GradMatrix> mw_up_dlogdet, mw_dn_dlogdet;
403  std::vector<ValueMatrix> mw_up_d2logdet, mw_dn_d2logdet;
404  mw_up_logdet.reserve(nw);
405  mw_dn_logdet.reserve(nw);
406  mw_up_dlogdet.reserve(nw);
407  mw_dn_dlogdet.reserve(nw);
408  mw_up_d2logdet.reserve(nw);
409  mw_dn_d2logdet.reserve(nw);
410 
411  RefVector<ValueMatrix> up_logdet_list, dn_logdet_list;
412  RefVector<GradMatrix> up_dlogdet_list, dn_dlogdet_list;
413  RefVector<ValueMatrix> up_d2logdet_list, dn_d2logdet_list;
414  up_logdet_list.reserve(nw);
415  dn_logdet_list.reserve(nw);
416  up_dlogdet_list.reserve(nw);
417  dn_dlogdet_list.reserve(nw);
418  up_d2logdet_list.reserve(nw);
419  dn_d2logdet_list.reserve(nw);
420 
421  const size_t norb_requested = logdet_list.front().get().cols();
422  ValueMatrix tmp_val_mat(nelec, norb_requested);
423  GradMatrix tmp_grad_mat(nelec, norb_requested);
424  for (int iw = 0; iw < nw; iw++)
425  {
426  mw_up_logdet.emplace_back(tmp_val_mat);
427  up_logdet_list.emplace_back(mw_up_logdet.back());
428  mw_dn_logdet.emplace_back(tmp_val_mat);
429  dn_logdet_list.emplace_back(mw_dn_logdet.back());
430 
431  mw_up_dlogdet.emplace_back(tmp_grad_mat);
432  up_dlogdet_list.emplace_back(mw_up_dlogdet.back());
433  mw_dn_dlogdet.emplace_back(tmp_grad_mat);
434  dn_dlogdet_list.emplace_back(mw_dn_dlogdet.back());
435 
436  mw_up_d2logdet.emplace_back(tmp_val_mat);
437  up_d2logdet_list.emplace_back(mw_up_d2logdet.back());
438  mw_dn_d2logdet.emplace_back(tmp_val_mat);
439  dn_d2logdet_list.emplace_back(mw_dn_d2logdet.back());
440  }
441 
442  up_spo_leader.mw_evaluate_notranspose(up_spo_list, P_list, first, last, up_logdet_list, up_dlogdet_list,
443  up_d2logdet_list);
444  dn_spo_leader.mw_evaluate_notranspose(dn_spo_list, P_list, first, last, dn_logdet_list, dn_dlogdet_list,
445  dn_d2logdet_list);
446 
447  for (int iw = 0; iw < nw; iw++)
448  for (int iat = first; iat < last; iat++)
449  {
450  ParticleSet::Scalar_t s = P_list[iw].activeSpin(iat);
451  RealType coss = std::cos(s);
452  RealType sins = std::sin(s);
453  ValueType eis(coss, sins);
454  ValueType emis(coss, -sins);
455 
456  for (int no = 0; no < norb_requested; no++)
457  {
458  logdet_list[iw].get()(iat, no) =
459  eis * up_logdet_list[iw].get()(iat, no) + emis * dn_logdet_list[iw].get()(iat, no);
460  dlogdet_list[iw].get()(iat, no) =
461  eis * up_dlogdet_list[iw].get()(iat, no) + emis * dn_dlogdet_list[iw].get()(iat, no);
462  d2logdet_list[iw].get()(iat, no) =
463  eis * up_d2logdet_list[iw].get()(iat, no) + emis * dn_d2logdet_list[iw].get()(iat, no);
464  }
465  }
466 }
std::pair< RefVectorWithLeader< SPOSet >, RefVectorWithLeader< SPOSet > > extractSpinComponentRefList(const RefVectorWithLeader< SPOSet > &spo_list) const
Definition: SpinorSet.cpp:607
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
Definition: SPOSet.h:50
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
Definition: SPOSet.h:52
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
SpinorSet(const std::string &my_name)
constructor
Definition: SpinorSet.cpp:31
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
QMCTraits::RealType RealType

◆ mw_evaluateVGLandDetRatioGradsWithSpin()

void mw_evaluateVGLandDetRatioGradsWithSpin ( const RefVectorWithLeader< SPOSet > &  spo_list,
const RefVectorWithLeader< ParticleSet > &  P_list,
int  iat,
const std::vector< const ValueType *> &  invRow_ptr_list,
OffloadMWVGLArray phi_vgl_v,
std::vector< ValueType > &  ratios,
std::vector< GradType > &  grads,
std::vector< ValueType > &  spingrads 
) const
overridevirtual

evaluate the values, gradients and laplacians of this single-particle orbital sets and determinant ratio and grads of multiple walkers.

Device data of phi_vgl_v must be up-to-date upon return. Includes spin gradients

Parameters
spo_listthe list of SPOSet pointers in a walker batch
P_listthe list of ParticleSet pointers in a walker batch
iatactive particle
phi_vgl_vorbital values, gradients and laplacians of all the walkers
ratios,ratiosof all walkers
grads,spatialgradients of all walkers
spingrads,spingradients of all walkers

Reimplemented from SPOSet.

Definition at line 258 of file SpinorSet.cpp.

References qmcplusplus::cos(), Array< T, D, ALLOC >::data(), QMCTraits::DIM_VGL, SpinorSet::extractSpinComponentRefList(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::Units::time::s, qmcplusplus::sin(), qmcplusplus::sincos(), and Array< T, D, ALLOC >::size().

266 {
267  auto& spo_leader = spo_list.getCastedLeader<SpinorSet>();
268  auto& P_leader = P_list.getLeader();
269  assert(this == &spo_leader);
270  assert(phi_vgl_v.size(0) == DIM_VGL);
271  assert(phi_vgl_v.size(1) == spo_list.size());
272  const size_t nw = spo_list.size();
273  const size_t norb_requested = phi_vgl_v.size(2);
274 
275  auto& mw_res = spo_leader.mw_res_handle_.getResource();
276  auto& up_phi_vgl_v = mw_res.up_phi_vgl_v;
277  auto& dn_phi_vgl_v = mw_res.dn_phi_vgl_v;
278  auto& up_ratios = mw_res.up_ratios;
279  auto& dn_ratios = mw_res.dn_ratios;
280  auto& up_grads = mw_res.up_grads;
281  auto& dn_grads = mw_res.dn_grads;
282  auto& spins = mw_res.spins;
283 
284  up_phi_vgl_v.resize(DIM_VGL, nw, norb_requested);
285  dn_phi_vgl_v.resize(DIM_VGL, nw, norb_requested);
286  up_ratios.resize(nw);
287  dn_ratios.resize(nw);
288  up_grads.resize(nw);
289  dn_grads.resize(nw);
290  spins.resize(nw);
291 
292  auto [up_spo_list, dn_spo_list] = extractSpinComponentRefList(spo_list);
293  auto& up_spo_leader = up_spo_list.getLeader();
294  auto& dn_spo_leader = dn_spo_list.getLeader();
295 
296  up_spo_leader.mw_evaluateVGLandDetRatioGrads(up_spo_list, P_list, iat, invRow_ptr_list, up_phi_vgl_v, up_ratios,
297  up_grads);
298  dn_spo_leader.mw_evaluateVGLandDetRatioGrads(dn_spo_list, P_list, iat, invRow_ptr_list, dn_phi_vgl_v, dn_ratios,
299  dn_grads);
300  for (int iw = 0; iw < nw; iw++)
301  {
302  ParticleSet::Scalar_t s = P_list[iw].activeSpin(iat);
303  spins[iw] = s;
304  RealType coss = std::cos(s);
305  RealType sins = std::sin(s);
306 
307  ValueType eis(coss, sins);
308  ValueType emis(coss, -sins);
309  ValueType eye(0, 1.0);
310 
311  ratios[iw] = eis * up_ratios[iw] + emis * dn_ratios[iw];
312  grads[iw] = (eis * up_grads[iw] * up_ratios[iw] + emis * dn_grads[iw] * dn_ratios[iw]) / ratios[iw];
313  spingrads[iw] = eye * (eis * up_ratios[iw] - emis * dn_ratios[iw]) / ratios[iw];
314  }
315 
316  auto* spins_ptr = spins.data();
317  //This data lives on the device
318  auto* phi_vgl_ptr = phi_vgl_v.data();
319  auto* up_phi_vgl_ptr = up_phi_vgl_v.data();
320  auto* dn_phi_vgl_ptr = dn_phi_vgl_v.data();
321  PRAGMA_OFFLOAD("omp target teams distribute map(to:spins_ptr[0:nw])")
322  for (int iw = 0; iw < nw; iw++)
323  {
324  RealType c, s;
325  omptarget::sincos(spins_ptr[iw], &s, &c);
326  ValueType eis(c, s), emis(c, -s);
327  PRAGMA_OFFLOAD("omp parallel for collapse(2)")
328  for (int idim = 0; idim < DIM_VGL; idim++)
329  for (int iorb = 0; iorb < norb_requested; iorb++)
330  {
331  auto offset = idim * nw * norb_requested + iw * norb_requested + iorb;
332  phi_vgl_ptr[offset] = eis * up_phi_vgl_ptr[offset] + emis * dn_phi_vgl_ptr[offset];
333  }
334  }
335 }
std::pair< RefVectorWithLeader< SPOSet >, RefVectorWithLeader< SPOSet > > extractSpinComponentRefList(const RefVectorWithLeader< SPOSet > &spo_list) const
Definition: SpinorSet.cpp:607
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
SpinorSet(const std::string &my_name)
constructor
Definition: SpinorSet.cpp:31
QMCTraits::RealType RealType
void sincos(T a, T *restrict s, T *restrict c)
sincos function wrapper
Definition: math.hpp:62

◆ mw_evaluateVGLWithSpin()

void mw_evaluateVGLWithSpin ( const RefVectorWithLeader< SPOSet > &  spo_list,
const RefVectorWithLeader< ParticleSet > &  P_list,
int  iat,
const RefVector< ValueVector > &  psi_v_list,
const RefVector< GradVector > &  dpsi_v_list,
const RefVector< ValueVector > &  d2psi_v_list,
OffloadMatrix< ComplexType > &  mw_dspin 
) const
overridevirtual

evaluate the values, gradients and laplacians and spin gradient of this single-particle orbital sets of multiple walkers

Parameters
spo_listthe list of SPOSet pointers in a walker batch
P_listthe list of ParticleSet pointers in a walker batch
iatactive particle
psi_v_listthe list of value vector pointers in a walker batch
dpsi_v_listthe list of gradient vector pointers in a walker batch
d2psi_v_listthe list of laplacian vector pointers in a walker batch
mw_dspindual matrix of spin gradients. nw x num_orbitals

Reimplemented from SPOSet.

Definition at line 194 of file SpinorSet.cpp.

References Matrix< T, Alloc >::cols(), qmcplusplus::cos(), SpinorSet::extractSpinComponentRefList(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::Units::time::s, qmcplusplus::sin(), SPOSet::size(), and Matrix< T, Alloc >::updateTo().

201 {
202  auto& spo_leader = spo_list.getCastedLeader<SpinorSet>();
203  auto& P_leader = P_list.getLeader();
204  assert(this == &spo_leader);
205 
206  IndexType nw = spo_list.size();
207  auto [up_spo_list, dn_spo_list] = extractSpinComponentRefList(spo_list);
208  auto& up_spo_leader = up_spo_list.getLeader();
209  auto& dn_spo_leader = dn_spo_list.getLeader();
210 
211  RefVector<ValueVector> up_psi_v_list, dn_psi_v_list;
212  RefVector<GradVector> up_dpsi_v_list, dn_dpsi_v_list;
213  RefVector<ValueVector> up_d2psi_v_list, dn_d2psi_v_list;
214  for (int iw = 0; iw < nw; iw++)
215  {
216  auto& spo = spo_list.getCastedElement<SpinorSet>(iw);
217  auto& psi = psi_v_list[iw].get();
218  const size_t norb_requested = psi.size();
219 
220  spo.psi_work_up.resize(norb_requested);
221  spo.psi_work_down.resize(norb_requested);
222  spo.dpsi_work_up.resize(norb_requested);
223  spo.dpsi_work_down.resize(norb_requested);
224  spo.d2psi_work_up.resize(norb_requested);
225  spo.d2psi_work_down.resize(norb_requested);
226 
227  up_psi_v_list.push_back(spo.psi_work_up);
228  dn_psi_v_list.push_back(spo.psi_work_down);
229  up_dpsi_v_list.push_back(spo.dpsi_work_up);
230  dn_dpsi_v_list.push_back(spo.dpsi_work_down);
231  up_d2psi_v_list.push_back(spo.d2psi_work_up);
232  dn_d2psi_v_list.push_back(spo.d2psi_work_down);
233  }
234 
235  up_spo_leader.mw_evaluateVGL(up_spo_list, P_list, iat, up_psi_v_list, up_dpsi_v_list, up_d2psi_v_list);
236  dn_spo_leader.mw_evaluateVGL(dn_spo_list, P_list, iat, dn_psi_v_list, dn_dpsi_v_list, dn_d2psi_v_list);
237 
238  for (int iw = 0; iw < nw; iw++)
239  {
240  ParticleSet::Scalar_t s = P_list[iw].activeSpin(iat);
241  RealType coss = std::cos(s);
242  RealType sins = std::sin(s);
243 
244  ValueType eis(coss, sins);
245  ValueType emis(coss, -sins);
246  ValueType eye(0, 1.0);
247 
248  psi_v_list[iw].get() = eis * up_psi_v_list[iw].get() + emis * dn_psi_v_list[iw].get();
249  dpsi_v_list[iw].get() = eis * up_dpsi_v_list[iw].get() + emis * dn_dpsi_v_list[iw].get();
250  d2psi_v_list[iw].get() = eis * up_d2psi_v_list[iw].get() + emis * dn_d2psi_v_list[iw].get();
251  for (int iorb = 0; iorb < mw_dspin.cols(); iorb++)
252  mw_dspin(iw, iorb) = eye * (eis * (up_psi_v_list[iw].get())[iorb] - emis * (dn_psi_v_list[iw].get())[iorb]);
253  }
254  //Data above is all on host, but since mw_dspin is DualMatrix we need to sync the host and device
255  mw_dspin.updateTo();
256 }
std::pair< RefVectorWithLeader< SPOSet >, RefVectorWithLeader< SPOSet > > extractSpinComponentRefList(const RefVectorWithLeader< SPOSet > &spo_list) const
Definition: SpinorSet.cpp:607
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
SpinorSet(const std::string &my_name)
constructor
Definition: SpinorSet.cpp:31
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
QMCTraits::RealType RealType

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< SPOSet > &  spo_list 
) const
overridevirtual

return a shared resource to collection

Reimplemented from SPOSet.

Definition at line 596 of file SpinorSet.cpp.

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

Referenced by SpinorSet::releaseResource().

597 {
598  auto [up_spo_list, dn_spo_list] = extractSpinComponentRefList(spo_list);
599  auto& spo_leader = spo_list.getCastedLeader<SpinorSet>();
600  auto& up_spo_leader = up_spo_list.getLeader();
601  auto& dn_spo_leader = dn_spo_list.getLeader();
602  up_spo_leader.releaseResource(collection, up_spo_list);
603  dn_spo_leader.releaseResource(collection, dn_spo_list);
604  collection.takebackResource(spo_leader.mw_res_handle_);
605 }
std::pair< RefVectorWithLeader< SPOSet >, RefVectorWithLeader< SPOSet > > extractSpinComponentRefList(const RefVectorWithLeader< SPOSet > &spo_list) const
Definition: SpinorSet.cpp:607
SpinorSet(const std::string &my_name)
constructor
Definition: SpinorSet.cpp:31

◆ set_spos()

void set_spos ( std::unique_ptr< SPOSet > &&  up,
std::unique_ptr< SPOSet > &&  dn 
)

Definition at line 46 of file SpinorSet.cpp.

References SpinorSet::setOrbitalSetSize(), SpinorSet::spo_dn, and SpinorSet::spo_up.

47 {
48  //Sanity check for input SPO's. They need to be the same size or
49  IndexType spo_size_up = up->getOrbitalSetSize();
50  IndexType spo_size_down = dn->getOrbitalSetSize();
51 
52  if (spo_size_up != spo_size_down)
53  throw std::runtime_error("SpinorSet::set_spos(...): up and down SPO components have different sizes.");
54 
55  setOrbitalSetSize(spo_size_up);
56 
57  spo_up = std::move(up);
58  spo_dn = std::move(dn);
59 }
void setOrbitalSetSize(int norbs) override
set the OrbitalSetSize
Definition: SpinorSet.cpp:61
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65

◆ setOrbitalSetSize()

void setOrbitalSetSize ( int  norbs)
overridevirtual

set the OrbitalSetSize

Parameters
norbsnumber of single-particle orbitals

Implements SPOSet.

Definition at line 61 of file SpinorSet.cpp.

References SPOSet::OrbitalSetSize.

Referenced by SpinorSet::set_spos().

61 { OrbitalSetSize = norbs; };
IndexType OrbitalSetSize
number of Single-particle orbitals
Definition: SPOSet.h:566

◆ storeParamsBeforeRotation()

void storeParamsBeforeRotation ( )
overridevirtual

store parameters before getting destroyed by rotation.

Reimplemented from SPOSet.

Definition at line 34 of file SpinorSet.cpp.

References SpinorSet::spo_dn, and SpinorSet::spo_up.

35 {
36  spo_up->storeParamsBeforeRotation();
37  spo_dn->storeParamsBeforeRotation();
38 }
std::unique_ptr< SPOSet > spo_up
Definition: SpinorSet.h:200
std::unique_ptr< SPOSet > spo_dn
Definition: SpinorSet.h:201

Member Data Documentation

◆ d2logpsi_work_down

ValueMatrix d2logpsi_work_down
private

◆ d2logpsi_work_up

ValueMatrix d2logpsi_work_up
private

◆ d2psi_work_down

ValueVector d2psi_work_down
private

Definition at line 213 of file SpinorSet.h.

Referenced by SpinorSet::evaluateVGL(), and SpinorSet::evaluateVGL_spin().

◆ d2psi_work_up

ValueVector d2psi_work_up
private

Definition at line 212 of file SpinorSet.h.

Referenced by SpinorSet::evaluateVGL(), and SpinorSet::evaluateVGL_spin().

◆ dlogpsi_work_down

GradMatrix dlogpsi_work_down
private

◆ dlogpsi_work_up

GradMatrix dlogpsi_work_up
private

◆ dpsi_work_down

GradVector dpsi_work_down
private

Definition at line 209 of file SpinorSet.h.

Referenced by SpinorSet::evaluateVGL(), and SpinorSet::evaluateVGL_spin().

◆ dpsi_work_up

GradVector dpsi_work_up
private

Definition at line 208 of file SpinorSet.h.

Referenced by SpinorSet::evaluateVGL(), and SpinorSet::evaluateVGL_spin().

◆ logpsi_work_down

ValueMatrix logpsi_work_down
private

◆ logpsi_work_up

ValueMatrix logpsi_work_up
private

◆ mw_res_handle_

Definition at line 193 of file SpinorSet.h.

Referenced by SpinorSet::isResourceOwned().

◆ psi_work_down

◆ psi_work_up

◆ spo_dn

◆ spo_up


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