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

Public Types

using Determinant_t = DiracDeterminantBase
 
- 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

 SlaterDet (ParticleSet &targetPtcl, std::vector< std::unique_ptr< Determinant_t >> dets, const std::string &class_name="SlaterDet")
 constructor More...
 
 ~SlaterDet () override
 destructor More...
 
std::string getClassName () const override
 return class name More...
 
bool isFermionic () const final
 true, if this component is fermionic More...
 
bool isOptimizable () const override
 if true, this contains optimizable components More...
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) override
 extract underlying OptimizableObject references More...
 
void checkOutVariables (const opt_variables_type &active) override
 check out variational optimizable variables More...
 
void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const override
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch More...
 
void mw_evaluateLog (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const override
 evaluate from scratch the same type WaveFunctionComponent of multiple walkers More...
 
LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch) override
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
void mw_evaluateGL (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list, bool fromscratch) const override
 evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers More...
 
void recompute (const ParticleSet &P) override
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const override
 
void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi) override
 
int size () const
 return the total number of Dirac determinants More...
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
 For particle-by-particle move. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 return a shared resource to a collection More...
 
void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
 evaluate ratios to evaluate the non-local PP More...
 
void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios) override
 Used by SOECPComponent for faster SOC evaluation. More...
 
void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
 evaluate ratios to evaluate the non-local PP More...
 
void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const override
 evaluate ratios to evaluate the non-local PP multiple walkers More...
 
PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient More...
 
PsiValue ratioGradWithSpin (ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad_iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_now) const override
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
void mw_ratioGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const override
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of multiple walkers More...
 
GradType evalGrad (ParticleSet &P, int iat) override
 return the current gradient for the iat-th particle More...
 
GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad) override
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const override
 compute the current gradients for the iat-th particle of multiple walkers More...
 
void mw_evalGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const override
 compute the current gradients and spin gradients for the iat-th particle of multiple walkers More...
 
GradType evalGradSource (ParticleSet &P, ParticleSet &src, int iat) override
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
GradType evalGradSource (ParticleSet &P, ParticleSet &src, int iat, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad) override
 Adds the gradient w.r.t. More...
 
void restore (int iat) override
 If a move for iat-th particle is rejected, restore to the content. More...
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 a move for iat-th particle is accepted. More...
 
void mw_accept_rejectMove (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false) const override
 moves of the iat-th particle on some walkers in a batch is accepted. More...
 
void completeUpdates () override
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
void mw_completeUpdates (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region. More...
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
void mw_calcRatio (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const override
 compute the ratio of the new to old WaveFunctionComponent value of multiple walkers More...
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const override
 make clone More...
 
SPOSetPtr getPhi (int i=0)
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios) override
 evaluate the ratios of one virtual move with respect to all the particles More...
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimizable parameters. More...
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
 Compute the derivatives of the log of the wavefunction with respect to optimizable parameters. More...
 
void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi) override
 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...
 
- 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 prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
template<CoordsType CT>
void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, TWFGrads< CT > &grads_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
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 RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
virtual void finalizeOptimization ()
 

Public Attributes

const std::vector< std::unique_ptr< Determinant_t > > Dets
 container for the DiracDeterminants More...
 
- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 

Private Member Functions

int getDetID (const int iat) const
 
RefVectorWithLeader< WaveFunctionComponentextract_DetRef_list (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
 

Private Attributes

std::vector< int > Last
 the last particle of each group 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 28 of file SlaterDet.h.

Member Typedef Documentation

◆ Determinant_t

Definition at line 31 of file SlaterDet.h.

Constructor & Destructor Documentation

◆ SlaterDet()

SlaterDet ( ParticleSet targetPtcl,
std::vector< std::unique_ptr< Determinant_t >>  dets,
const std::string &  class_name = "SlaterDet" 
)

constructor

Parameters
targetPtcltarget Particleset

Definition at line 27 of file SlaterDet.cpp.

References SlaterDet::Dets, ParticleSet::groups(), SlaterDet::Last, and ParticleSet::last().

30  : Dets(std::move(dets))
31 {
32  assert(Dets.size() == targetPtcl.groups());
33 
34  Last.resize(targetPtcl.groups());
35  for (int i = 0; i < Last.size(); ++i)
36  Last[i] = targetPtcl.last(i) - 1;
37 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
std::vector< int > Last
the last particle of each group
Definition: SlaterDet.h:319

◆ ~SlaterDet()

~SlaterDet ( )
overridedefault

destructor

Member Function Documentation

◆ acceptMove()

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

a move for iat-th particle is accepted.

Update the current content.

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

Implements WaveFunctionComponent.

Definition at line 189 of file SlaterDet.h.

References SlaterDet::Dets, WaveFunctionComponent::get_log_value(), SlaterDet::getDetID(), and WaveFunctionComponent::log_value_.

190  {
191  Dets[getDetID(iat)]->acceptMove(P, iat, safe_to_delay);
192 
193  log_value_ = 0.0;
194  for (int i = 0; i < Dets.size(); ++i)
195  log_value_ += Dets[i]->get_log_value();
196  }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ acquireResource()

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

acquire a shared resource from a collection

Reimplemented from WaveFunctionComponent.

Definition at line 221 of file SlaterDet.cpp.

References SlaterDet::Dets, and SlaterDet::extract_DetRef_list().

223 {
224  for (int i = 0; i < Dets.size(); ++i)
225  {
226  const auto det_list(extract_DetRef_list(wfc_list, i));
227  Dets[i]->acquireResource(collection, det_list);
228  }
229 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
overridevirtual

check out variational optimizable variables

Parameters
activea super set of optimizable variables

Reimplemented from WaveFunctionComponent.

Definition at line 53 of file SlaterDet.cpp.

References VariableSet::clear(), SlaterDet::Dets, VariableSet::getIndex(), VariableSet::insertFrom(), SlaterDet::isOptimizable(), and WaveFunctionComponent::myVars.

54 {
55  myVars.clear();
56  if (isOptimizable())
57  for (int i = 0; i < Dets.size(); i++)
58  {
59  Dets[i]->checkOutVariables(active);
61  }
62  myVars.getIndex(active);
63 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
bool isOptimizable() const override
if true, this contains optimizable components
Definition: SlaterDet.cpp:42
void clear()
clear the variable set
Definition: VariableSet.cpp:28
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
Definition: VariableSet.cpp:37
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter

◆ completeUpdates()

void completeUpdates ( )
inlineoverridevirtual

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 226 of file SlaterDet.h.

References SlaterDet::Dets.

227  {
228  for (int i = 0; i < Dets.size(); i++)
229  Dets[i]->completeUpdates();
230  }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
void completeUpdates() override
complete all the delayed or asynchronous operations before leaving the p-by-p move region...
Definition: SlaterDet.h:226

◆ 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 259 of file SlaterDet.cpp.

References PooledMemory< T_scalar, Alloc >::current(), DEBUG_PSIBUFFER, and SlaterDet::Dets.

260 {
261  DEBUG_PSIBUFFER(" SlaterDet::copyFromBuffer ", buf.current());
262  for (int i = 0; i < Dets.size(); i++)
263  Dets[i]->copyFromBuffer(P, buf);
264  DEBUG_PSIBUFFER(" SlaterDet::copyFromBuffer ", buf.current());
265 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
#define DEBUG_PSIBUFFER(who, msg)
Definition: Configuration.h:40
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
Definition: SlaterDet.cpp:259

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 215 of file SlaterDet.cpp.

References SlaterDet::Dets.

Referenced by qmcplusplus::TEST_CASE().

216 {
217  for (int i = 0; i < Dets.size(); ++i)
218  Dets[i]->createResource(collection);
219 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
Definition: SlaterDet.cpp:215

◆ 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 145 of file SlaterDet.h.

References SlaterDet::Dets, and SlaterDet::getDetID().

145 { return Dets[getDetID(iat)]->evalGrad(P, iat); }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ evalGradSource() [1/2]

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 167 of file SlaterDet.h.

References SlaterDet::Dets, and SlaterDet::size().

Referenced by SlaterDet::evalGradSource().

168  {
169  GradType G = GradType();
170  for (int iz = 0; iz < size(); iz++)
171  G += Dets[iz]->evalGradSource(P, src, iat);
172  return G;
173  }
QTBase::GradType GradType
Definition: Configuration.h:62
int size() const
return the total number of Dirac determinants
Definition: SlaterDet.h:85
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
GradType evalGradSource(ParticleSet &P, ParticleSet &src, int iat) override
return the logarithmic gradient for the iat-th particle of the source particleset ...
Definition: SlaterDet.h:167

◆ evalGradSource() [2/2]

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

Adds the gradient w.r.t.

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 175 of file SlaterDet.h.

References SlaterDet::Dets, SlaterDet::evalGradSource(), and SlaterDet::size().

180  {
181  GradType G = GradType();
182  for (int iz = 0; iz < size(); iz++)
183  G += Dets[iz]->evalGradSource(P, src, iat, grad_grad, lapl_grad);
184  return G;
185  }
QTBase::GradType GradType
Definition: Configuration.h:62
int size() const
return the total number of Dirac determinants
Definition: SlaterDet.h:85
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
GradType evalGradSource(ParticleSet &P, ParticleSet &src, int iat) override
return the logarithmic gradient for the iat-th particle of the source particleset ...
Definition: SlaterDet.h:167

◆ evalGradWithSpin()

GradType evalGradWithSpin ( ParticleSet P,
int  iat,
ComplexType spingrad 
)
inlineoverridevirtual

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 147 of file SlaterDet.h.

References SlaterDet::Dets, and SlaterDet::getDetID().

148  {
149  return Dets[getDetID(iat)]->evalGradWithSpin(P, iat, spingrad);
150  }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ evaluateDerivatives()

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

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

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

Implements WaveFunctionComponent.

Definition at line 255 of file SlaterDet.h.

References SlaterDet::Dets, WaveFunctionComponent::myVars, VariableSet::size(), and VariableSet::where().

259  {
260  // First zero out values, since each determinant only adds on
261  // its contribution (i.e. +=) , rather than setting the value
262  // (i.e. =)
263  for (int k = 0; k < myVars.size(); ++k)
264  {
265  int kk = myVars.where(k);
266  if (kk >= 0)
267  dlogpsi[kk] = dhpsioverpsi[kk] = 0.0;
268  }
269  // Now add on contribution from each determinant to the derivatives
270  for (int i = 0; i < Dets.size(); i++)
271  Dets[i]->evaluateDerivatives(P, active, dlogpsi, dhpsioverpsi);
272  }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_type size() const
return the size
Definition: VariableSet.h:88
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimi...
Definition: SlaterDet.h:255

◆ evaluateDerivativesWF()

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

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

parameters

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

Reimplemented from WaveFunctionComponent.

Definition at line 274 of file SlaterDet.h.

References SlaterDet::Dets, WaveFunctionComponent::myVars, VariableSet::size(), and VariableSet::where().

275  {
276  // First zero out values, since each determinant only adds on
277  // its contribution (i.e. +=) , rather than setting the value
278  // (i.e. =)
279  for (int k = 0; k < myVars.size(); ++k)
280  {
281  int kk = myVars.where(k);
282  if (kk >= 0)
283  dlogpsi[kk] = 0.0;
284  }
285  // Now add on contribution from each determinant to the derivatives
286  for (int i = 0; i < Dets.size(); i++)
287  Dets[i]->evaluateDerivativesWF(P, active, dlogpsi);
288  }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
Compute the derivatives of the log of the wavefunction with respect to optimizable parameters...
Definition: SlaterDet.h:274
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
size_type size() const
return the size
Definition: VariableSet.h:88

◆ evaluateDerivRatios()

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

evaluate ratios to evaluate the non-local PP

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

Reimplemented from WaveFunctionComponent.

Definition at line 114 of file SlaterDet.cpp.

References SlaterDet::Dets, SlaterDet::getDetID(), and VirtualParticleSet::refPtcl.

118 {
119  return Dets[getDetID(VP.refPtcl)]->evaluateDerivRatios(VP, optvars, ratios, dratios);
120 }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ evaluateGL()

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 151 of file SlaterDet.cpp.

References SlaterDet::Dets, and WaveFunctionComponent::log_value_.

155 {
156  log_value_ = 0.0;
157  for (int i = 0; i < Dets.size(); ++i)
158  log_value_ += Dets[i]->evaluateGL(P, G, L, from_scratch);
159  return log_value_;
160 }
LogValue evaluateGL(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch) override
compute gradients and laplacian of the TWF with respect to each particle.
Definition: SlaterDet.cpp:151
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ evaluateGradDerivatives()

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

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

This object is then returned as dgradlogpsi.

Reimplemented from WaveFunctionComponent.

Definition at line 290 of file SlaterDet.h.

References SlaterDet::Dets.

291  {
292  for (int i = 0; i < Dets.size(); i++)
293  Dets[i]->evaluateGradDerivatives(G_in, dgradlogpsi);
294  }
void evaluateGradDerivatives(const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi) override
Calculates the derivatives of with respect to the optimizable parameters, and the dot product of thi...
Definition: SlaterDet.h:290
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ evaluateHessian()

void evaluateHessian ( ParticleSet P,
HessVector grad_grad_psi 
)
overridevirtual

Reimplemented from WaveFunctionComponent.

Definition at line 199 of file SlaterDet.cpp.

References SlaterDet::Dets, and ParticleSet::getTotalNum().

200 {
201  grad_grad_psi.resize(P.getTotalNum());
202  HessVector tmp;
203  tmp.resize(P.getTotalNum());
204  for (int i = 0; i < Dets.size(); ++i)
205  {
206  tmp = 0;
207  Dets[i]->evaluateHessian(P, tmp);
208  // app_log()<<"squee ----- "<<i<< std::endl;
209  // app_log()<<"grad_grad_psi = "<<grad_grad_psi<< std::endl;
210  // app_log()<<"tmp = "<<tmp<< std::endl<< std::endl;
211  grad_grad_psi += tmp;
212  }
213 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
OrbitalSetTraits< ValueType >::HessVector HessVector

◆ evaluateLog()

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

evaluate the value of the WaveFunctionComponent from scratch

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

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

Implements WaveFunctionComponent.

Definition at line 122 of file SlaterDet.cpp.

References SlaterDet::Dets, and WaveFunctionComponent::log_value_.

125 {
126  log_value_ = 0.0;
127  for (int i = 0; i < Dets.size(); ++i)
128  log_value_ += Dets[i]->evaluateLog(P, G, L);
129  return log_value_;
130 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
Definition: SlaterDet.cpp:122

◆ evaluateRatios()

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

evaluate ratios to evaluate the non-local PP

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

Reimplemented from WaveFunctionComponent.

Definition at line 101 of file SlaterDet.h.

References SlaterDet::Dets, SlaterDet::getDetID(), and VirtualParticleSet::refPtcl.

102  {
103  return Dets[getDetID(VP.refPtcl)]->evaluateRatios(VP, ratios);
104  }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ evaluateRatiosAlltoOne()

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 108 of file SlaterDet.cpp.

References SlaterDet::Dets.

109 {
110  for (int i = 0; i < Dets.size(); ++i)
111  Dets[i]->evaluateRatiosAlltoOne(P, ratios);
112 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios) override
evaluate the ratios of one virtual move with respect to all the particles
Definition: SlaterDet.cpp:108

◆ evaluateSpinorRatios()

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

Used by SOECPComponent for faster SOC evaluation.

Reimplemented from WaveFunctionComponent.

Definition at line 106 of file SlaterDet.h.

References SlaterDet::Dets, SlaterDet::getDetID(), and VirtualParticleSet::refPtcl.

107  {
108  return Dets[getDetID(VP.refPtcl)]->evaluateSpinorRatios(VP, spinor_multiplier, ratios);
109  }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ extract_DetRef_list()

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

Definition at line 307 of file SlaterDet.h.

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

Referenced by SlaterDet::acquireResource(), SlaterDet::mw_accept_rejectMove(), SlaterDet::mw_calcRatio(), SlaterDet::mw_completeUpdates(), SlaterDet::mw_evalGrad(), SlaterDet::mw_evalGradWithSpin(), SlaterDet::mw_evaluateGL(), SlaterDet::mw_evaluateLog(), SlaterDet::mw_evaluateRatios(), SlaterDet::mw_ratioGrad(), SlaterDet::mw_ratioGradWithSpin(), SlaterDet::mw_recompute(), and SlaterDet::releaseResource().

310  {
311  RefVectorWithLeader<WaveFunctionComponent> Det_list(*wfc_list.getCastedLeader<SlaterDet>().Dets[det_id]);
312  Det_list.reserve(wfc_list.size());
313  for (WaveFunctionComponent& wfc : wfc_list)
314  Det_list.push_back(*static_cast<SlaterDet&>(wfc).Dets[det_id]);
315  return Det_list;
316  }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
WaveFunctionComponent(const std::string &obj_name="")
default constructor
SlaterDet(ParticleSet &targetPtcl, std::vector< std::unique_ptr< Determinant_t >> dets, const std::string &class_name="SlaterDet")
constructor
Definition: SlaterDet.cpp:27

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
overridevirtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented from WaveFunctionComponent.

Definition at line 47 of file SlaterDet.cpp.

References SlaterDet::Dets, and SlaterDet::extractOptimizableObjectRefs().

Referenced by SlaterDet::extractOptimizableObjectRefs().

48 {
49  for (int i = 0; i < Dets.size(); i++)
50  Dets[i]->extractOptimizableObjectRefs(opt_obj_refs);
51 }
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
Definition: SlaterDet.cpp:47
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 45 of file SlaterDet.h.

45 { return "SlaterDet"; }

◆ getDetID()

◆ getPhi()

SPOSetPtr getPhi ( int  i = 0)
inline

Definition at line 251 of file SlaterDet.h.

References SlaterDet::Dets.

Referenced by qmcplusplus::TEST_CASE().

251 { return Dets[i]->getPhi(); }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ isFermionic()

bool isFermionic ( ) const
inlinefinalvirtual

true, if this component is fermionic

Reimplemented from WaveFunctionComponent.

Definition at line 47 of file SlaterDet.h.

47 { return true; }

◆ isOptimizable()

bool isOptimizable ( ) const
overridevirtual

if true, this contains optimizable components

Reimplemented from WaveFunctionComponent.

Definition at line 42 of file SlaterDet.cpp.

References qmcplusplus::det(), and SlaterDet::Dets.

Referenced by SlaterDet::checkOutVariables(), and SlaterDet::makeClone().

43 {
44  return std::any_of(Dets.begin(), Dets.end(), [](const auto& det) { return det->isOptimizable(); });
45 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ 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 267 of file SlaterDet.cpp.

References qmcplusplus::det(), SlaterDet::Dets, and SlaterDet::isOptimizable().

268 {
269  std::vector<std::unique_ptr<Determinant_t>> dets;
270  for (const auto& det : Dets)
271  dets.emplace_back(det->makeCopy(det->getPhi()->makeClone()));
272  auto myclone = std::make_unique<SlaterDet>(tqp, std::move(dets));
273  assert(myclone->isOptimizable() == isOptimizable());
274  return myclone;
275 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
bool isOptimizable() const override
if true, this contains optimizable components
Definition: SlaterDet.cpp:42

◆ mw_accept_rejectMove()

void mw_accept_rejectMove ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
const std::vector< bool > &  isAccepted,
bool  safe_to_delay = false 
) const
inlineoverridevirtual

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 198 of file SlaterDet.h.

References BLAS::czero, SlaterDet::Dets, SlaterDet::extract_DetRef_list(), WaveFunctionComponent::get_log_value(), RefVectorWithLeader< T >::getCastedElement(), SlaterDet::getDetID(), and WaveFunctionComponent::log_value_.

203  {
204  constexpr LogValue czero(0);
205 
206  // This log_value_ is in the slater determinant, it's still around but not consistent anymore with the
207  // sum of the log_values in its determinants. Caching the state seems like a bad call, but the wfc base class
208  // having log_value_ as a data member asks for this sort of consistency issue when wfc can contain wfc.
209  for (int iw = 0; iw < wfc_list.size(); iw++)
210  if (isAccepted[iw])
211  wfc_list.getCastedElement<SlaterDet>(iw).log_value_ = czero;
212 
213  for (int i = 0; i < Dets.size(); ++i)
214  {
215  const auto Det_list(extract_DetRef_list(wfc_list, i));
216 
217  if (i == getDetID(iat))
218  Dets[i]->mw_accept_rejectMove(Det_list, p_list, iat, isAccepted, safe_to_delay);
219 
220  for (int iw = 0; iw < wfc_list.size(); iw++)
221  if (isAccepted[iw])
222  wfc_list.getCastedElement<SlaterDet>(iw).log_value_ += Det_list[iw].get_log_value();
223  }
224  }
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
std::complex< QTFull::RealType > LogValue
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307
SlaterDet(ParticleSet &targetPtcl, std::vector< std::unique_ptr< Determinant_t >> dets, const std::string &class_name="SlaterDet")
constructor
Definition: SlaterDet.cpp:27

◆ mw_calcRatio()

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

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

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
ratiosthe list of WF ratios of a walker batch, $ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})$

Reimplemented from WaveFunctionComponent.

Definition at line 240 of file SlaterDet.h.

References SlaterDet::Dets, SlaterDet::extract_DetRef_list(), and SlaterDet::getDetID().

244  {
245  const int det_id = getDetID(iat);
246  Dets[det_id]->mw_calcRatio(extract_DetRef_list(wfc_list, det_id), p_list, iat, ratios);
247  }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307

◆ mw_completeUpdates()

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 232 of file SlaterDet.h.

References SlaterDet::Dets, and SlaterDet::extract_DetRef_list().

233  {
234  for (int i = 0; i < Dets.size(); i++)
235  Dets[i]->mw_completeUpdates(extract_DetRef_list(wfc_list, i));
236  }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307
void mw_completeUpdates(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the...
Definition: SlaterDet.h:232

◆ mw_evalGrad()

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 152 of file SlaterDet.h.

References SlaterDet::Dets, SlaterDet::extract_DetRef_list(), and SlaterDet::getDetID().

Referenced by qmcplusplus::TEST_CASE().

156  {
157  const int det_id = getDetID(iat);
158  Dets[det_id]->mw_evalGrad(extract_DetRef_list(wfc_list, det_id), p_list, iat, grad_now);
159  }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307

◆ mw_evalGradWithSpin()

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 98 of file SlaterDet.cpp.

References SlaterDet::Dets, SlaterDet::extract_DetRef_list(), and SlaterDet::getDetID().

Referenced by qmcplusplus::TEST_CASE().

103 {
104  const int det_id = getDetID(iat);
105  Dets[det_id]->mw_evalGradWithSpin(extract_DetRef_list(wfc_list, det_id), p_list, iat, grad_now, spingrad_now);
106 }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307

◆ mw_evaluateGL()

void mw_evaluateGL ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const RefVector< ParticleSet::ParticleGradient > &  G_list,
const RefVector< ParticleSet::ParticleLaplacian > &  L_list,
bool  fromscratch 
) const
overridevirtual

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 162 of file SlaterDet.cpp.

References BLAS::czero, SlaterDet::Dets, SlaterDet::extract_DetRef_list(), RefVectorWithLeader< T >::getCastedElement(), and WaveFunctionComponent::log_value_.

167 {
168  constexpr LogValue czero(0);
169 
170  for (int iw = 0; iw < wfc_list.size(); iw++)
171  wfc_list.getCastedElement<SlaterDet>(iw).log_value_ = czero;
172 
173  for (int i = 0; i < Dets.size(); ++i)
174  {
175  const auto Det_list(extract_DetRef_list(wfc_list, i));
176  Dets[i]->mw_evaluateGL(Det_list, p_list, G_list, L_list, fromscratch);
177  for (int iw = 0; iw < wfc_list.size(); iw++)
178  wfc_list.getCastedElement<SlaterDet>(iw).log_value_ += Det_list[iw].get_log_value();
179  }
180 }
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
std::complex< QTFull::RealType > LogValue
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307
SlaterDet(ParticleSet &targetPtcl, std::vector< std::unique_ptr< Determinant_t >> dets, const std::string &class_name="SlaterDet")
constructor
Definition: SlaterDet.cpp:27

◆ mw_evaluateLog()

void mw_evaluateLog ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const RefVector< ParticleSet::ParticleGradient > &  G_list,
const RefVector< ParticleSet::ParticleLaplacian > &  L_list 
) const
overridevirtual

evaluate from scratch the same type WaveFunctionComponent of multiple walkers

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

Reimplemented from WaveFunctionComponent.

Definition at line 132 of file SlaterDet.cpp.

References BLAS::czero, SlaterDet::Dets, SlaterDet::extract_DetRef_list(), RefVectorWithLeader< T >::getCastedElement(), and WaveFunctionComponent::log_value_.

136 {
137  constexpr LogValue czero(0);
138 
139  for (int iw = 0; iw < wfc_list.size(); iw++)
140  wfc_list.getCastedElement<SlaterDet>(iw).log_value_ = czero;
141 
142  for (int i = 0; i < Dets.size(); ++i)
143  {
144  const auto Det_list(extract_DetRef_list(wfc_list, i));
145  Dets[i]->mw_evaluateLog(Det_list, p_list, G_list, L_list);
146  for (int iw = 0; iw < wfc_list.size(); iw++)
147  wfc_list.getCastedElement<SlaterDet>(iw).log_value_ += Det_list[iw].get_log_value();
148  }
149 }
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
std::complex< QTFull::RealType > LogValue
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307
SlaterDet(ParticleSet &targetPtcl, std::vector< std::unique_ptr< Determinant_t >> dets, const std::string &class_name="SlaterDet")
constructor
Definition: SlaterDet.cpp:27

◆ mw_evaluateRatios()

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

evaluate ratios to evaluate the non-local PP multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent references of the same component in a walker batch
vp_listthe list of VirtualParticleSet references in a walker batch
ratiosof all the virtual moves of all the walkers

Reimplemented from WaveFunctionComponent.

Definition at line 116 of file SlaterDet.h.

References SlaterDet::Dets, SlaterDet::extract_DetRef_list(), and SlaterDet::getDetID().

119  {
120  if (wfc_list.size())
121  {
122  // assuming all the VP.refPtcl are identical
123  const int det_id = getDetID(vp_list[0].refPtcl);
124  Dets[det_id]->mw_evaluateRatios(extract_DetRef_list(wfc_list, det_id), vp_list, ratios);
125  }
126  }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307

◆ mw_ratioGrad()

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

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

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
ratiosthe list of WF ratios of a walker batch, $ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})$
grad_nowthe list of new gradients in a walker batch, $\nabla\ln\Psi$

Reimplemented from WaveFunctionComponent.

Definition at line 75 of file SlaterDet.cpp.

References SlaterDet::Dets, SlaterDet::extract_DetRef_list(), and SlaterDet::getDetID().

Referenced by qmcplusplus::TEST_CASE().

80 {
81  const int det_id = getDetID(iat);
82  Dets[det_id]->mw_ratioGrad(extract_DetRef_list(wfc_list, det_id), p_list, iat, ratios, grad_now);
83 }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307

◆ mw_ratioGradWithSpin()

void mw_ratioGradWithSpin ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios,
std::vector< GradType > &  grad_new,
std::vector< ComplexType > &  spingrad_new 
) const
overridevirtual

compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
ratiosthe list of WF ratios of a walker batch, $ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})$
grad_nowthe list of new gradients in a walker batch, $\nabla\ln\Psi$

Reimplemented from WaveFunctionComponent.

Definition at line 85 of file SlaterDet.cpp.

References SlaterDet::Dets, SlaterDet::extract_DetRef_list(), and SlaterDet::getDetID().

Referenced by qmcplusplus::TEST_CASE().

91 {
92  const int det_id = getDetID(iat);
93  Dets[det_id]->mw_ratioGradWithSpin(extract_DetRef_list(wfc_list, det_id), p_list, iat, ratios, grad_now,
94  spingrad_now);
95 }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307

◆ mw_recompute()

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

Reimplemented from WaveFunctionComponent.

Definition at line 188 of file SlaterDet.cpp.

References SlaterDet::Dets, SlaterDet::extract_DetRef_list(), and SlaterDet::recompute().

191 {
192  for (int i = 0; i < Dets.size(); ++i)
193  {
194  const auto Det_list(extract_DetRef_list(wfc_list, i));
195  Dets[i]->mw_recompute(Det_list, p_list, recompute);
196  }
197 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
Definition: SlaterDet.cpp:182

◆ 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 238 of file SlaterDet.h.

References SlaterDet::Dets, and SlaterDet::getDetID().

238 { return Dets[getDetID(iat)]->ratio(P, iat); }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ ratioGrad()

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 65 of file SlaterDet.cpp.

References SlaterDet::Dets, and SlaterDet::getDetID().

66 {
67  return Dets[getDetID(iat)]->ratioGrad(P, iat, grad_iat);
68 }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ ratioGradWithSpin()

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 70 of file SlaterDet.cpp.

References SlaterDet::Dets, and SlaterDet::getDetID().

71 {
72  return Dets[getDetID(iat)]->ratioGradWithSpin(P, iat, grad_iat, spingrad_iat);
73 }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ recompute()

void recompute ( const ParticleSet P)
overridevirtual

recompute the value of the WaveFunctionComponents which require critical accuracy.

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

Reimplemented from WaveFunctionComponent.

Definition at line 182 of file SlaterDet.cpp.

References SlaterDet::Dets.

Referenced by SlaterDet::mw_recompute().

183 {
184  for (int i = 0; i < Dets.size(); ++i)
185  Dets[i]->recompute(P);
186 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
Definition: SlaterDet.cpp:182

◆ 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 241 of file SlaterDet.cpp.

References PooledMemory< T_scalar, Alloc >::current(), DEBUG_PSIBUFFER, and SlaterDet::Dets.

242 {
243  DEBUG_PSIBUFFER(" SlaterDet::registerData ", buf.current());
244  for (int i = 0; i < Dets.size(); ++i)
245  Dets[i]->registerData(P, buf);
246  DEBUG_PSIBUFFER(" SlaterDet::registerData ", buf.current());
247 }
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
Definition: SlaterDet.cpp:241
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
#define DEBUG_PSIBUFFER(who, msg)
Definition: Configuration.h:40

◆ registerTWFFastDerivWrapper()

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

Register the component with the TWFFastDerivWrapper wrapper.

Reimplemented from WaveFunctionComponent.

Definition at line 277 of file SlaterDet.cpp.

References SlaterDet::Dets, and qmcplusplus::twf.

278 {
279  for (int i = 0; i < Dets.size(); ++i)
280  {
281  Dets[i]->registerTWFFastDerivWrapper(P, twf);
282  }
283 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ releaseResource()

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

return a shared resource to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 231 of file SlaterDet.cpp.

References SlaterDet::Dets, and SlaterDet::extract_DetRef_list().

233 {
234  for (int i = 0; i < Dets.size(); ++i)
235  {
236  const auto det_list(extract_DetRef_list(wfc_list, i));
237  Dets[i]->releaseResource(collection, det_list);
238  }
239 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
RefVectorWithLeader< WaveFunctionComponent > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
Definition: SlaterDet.h:307

◆ restore()

void restore ( int  iat)
inlineoverridevirtual

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

Parameters
iatindex of the particle whose new position was proposed

Ye: hopefully we can gradually move away from restore

Implements WaveFunctionComponent.

Definition at line 187 of file SlaterDet.h.

References SlaterDet::Dets, and SlaterDet::getDetID().

187 { return Dets[getDetID(iat)]->restore(iat); }
int getDetID(const int iat) const
Definition: SlaterDet.h:298
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ size()

int size ( void  ) const
inline

return the total number of Dirac determinants

Definition at line 85 of file SlaterDet.h.

References SlaterDet::Dets.

Referenced by SlaterDet::evalGradSource().

85 { return Dets.size(); }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33

◆ updateBuffer()

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

For particle-by-particle move.

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

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

Implements WaveFunctionComponent.

Definition at line 249 of file SlaterDet.cpp.

References PooledMemory< T_scalar, Alloc >::current(), DEBUG_PSIBUFFER, SlaterDet::Dets, and WaveFunctionComponent::log_value_.

250 {
251  DEBUG_PSIBUFFER(" SlaterDet::updateBuffer ", buf.current());
252  log_value_ = 0.0;
253  for (int i = 0; i < Dets.size(); ++i)
254  log_value_ += Dets[i]->updateBuffer(P, buf, fromscratch);
255  DEBUG_PSIBUFFER(" SlaterDet::updateBuffer ", buf.current());
256  return log_value_;
257 }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
Definition: SlaterDet.h:33
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
Definition: SlaterDet.cpp:249
#define DEBUG_PSIBUFFER(who, msg)
Definition: Configuration.h:40

Member Data Documentation

◆ Dets

const std::vector<std::unique_ptr<Determinant_t> > Dets

container for the DiracDeterminants

Definition at line 33 of file SlaterDet.h.

Referenced by SlaterDet::acceptMove(), SlaterDet::acquireResource(), WaveFunctionTester::checkGradientAtConfiguration(), SlaterDet::checkOutVariables(), SlaterDet::completeUpdates(), SlaterDet::copyFromBuffer(), SlaterDet::createResource(), SlaterDet::evalGrad(), SlaterDet::evalGradSource(), SlaterDet::evalGradWithSpin(), SlaterDet::evaluateDerivatives(), SlaterDet::evaluateDerivativesWF(), SlaterDet::evaluateDerivRatios(), SlaterDet::evaluateGL(), SlaterDet::evaluateGradDerivatives(), SlaterDet::evaluateHessian(), SlaterDet::evaluateLog(), SlaterDet::evaluateRatios(), SlaterDet::evaluateRatiosAlltoOne(), SlaterDet::evaluateSpinorRatios(), SlaterDet::extract_DetRef_list(), SlaterDet::extractOptimizableObjectRefs(), SlaterDet::getPhi(), SlaterDet::isOptimizable(), SlaterDet::makeClone(), SlaterDet::mw_accept_rejectMove(), SlaterDet::mw_calcRatio(), SlaterDet::mw_completeUpdates(), SlaterDet::mw_evalGrad(), SlaterDet::mw_evalGradWithSpin(), SlaterDet::mw_evaluateGL(), SlaterDet::mw_evaluateLog(), SlaterDet::mw_evaluateRatios(), SlaterDet::mw_ratioGrad(), SlaterDet::mw_ratioGradWithSpin(), SlaterDet::mw_recompute(), SlaterDet::ratio(), SlaterDet::ratioGrad(), SlaterDet::ratioGradWithSpin(), SlaterDet::recompute(), SlaterDet::registerData(), SlaterDet::registerTWFFastDerivWrapper(), SlaterDet::releaseResource(), SlaterDet::restore(), SlaterDet::size(), SlaterDet::SlaterDet(), and SlaterDet::updateBuffer().

◆ Last

std::vector<int> Last
private

the last particle of each group

Definition at line 319 of file SlaterDet.h.

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


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