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

Public Types

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

 SlaterDetWithBackflow (ParticleSet &targetPtcl, std::vector< std::unique_ptr< Determinant_t >> dets, std::unique_ptr< BackflowTransformation > BF)
 constructor More...
 
 ~SlaterDetWithBackflow () 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...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch 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...
 
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...
 
GradType evalGrad (ParticleSet &P, int iat) override
 return the current gradient for the iat-th particle 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 acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 a move for iat-th particle is accepted. More...
 
void restore (int iat) override
 If a move for iat-th particle is rejected, restore to the content. More...
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const override
 make clone More...
 
SPOSetPtr getPhi (int i=0) const
 
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 &optvars, 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 testDerivGL (ParticleSet &P)
 
- Public Member Functions inherited from WaveFunctionComponent
const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
virtual void checkSanity () const
 Validate the internal consistency of the object. More...
 
const std::string & getName () const
 return object name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual bool isMultiDet () const
 true, if this component is multi-determinant More...
 
virtual void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
virtual void mw_evaluateLog (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const
 evaluate from scratch the same type WaveFunctionComponent of multiple walkers More...
 
virtual void recompute (const ParticleSet &P)
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
virtual void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 
virtual void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi_all)
 
virtual void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
virtual GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad)
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, TWFGrads< CT > &grads_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual PsiValue ratioGradWithSpin (ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad_iat)
 evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const
 
virtual void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
virtual void mw_accept_rejectMove (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false) const
 moves of the iat-th particle on some walkers in a batch is accepted. More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
virtual void mw_completeUpdates (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region. More...
 
virtual void mw_calcRatio (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const
 compute the ratio of the new to old WaveFunctionComponent value of multiple walkers More...
 
virtual LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch)
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
virtual void mw_evaluateGL (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list, bool fromscratch) const
 evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers More...
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 acquire a shared resource from a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 return a shared resource to a collection More...
 
virtual RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
virtual void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi)
 Compute the derivatives of the log of the wavefunction with respect to optimizable parameters. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void finalizeOptimization ()
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
virtual void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const
 evaluate ratios to evaluate the non-local PP multiple walkers More...
 
virtual void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void mw_evalGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const
 compute the current gradients and spin gradients for the iat-th particle of multiple walkers More...
 
virtual void mw_ratioGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new, std::vector< ComplexType > &spingrad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of multiple walkers More...
 

Private Attributes

const std::vector< std::unique_ptr< Determinant_t > > Dets
 container for the DiracDeterminants More...
 
const std::unique_ptr< BackflowTransformationBFTrans
 backflow transformation More...
 

Additional Inherited Members

- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 
- Protected 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 25 of file SlaterDetWithBackflow.h.

Member Typedef Documentation

◆ Determinant_t

Constructor & Destructor Documentation

◆ SlaterDetWithBackflow()

SlaterDetWithBackflow ( ParticleSet targetPtcl,
std::vector< std::unique_ptr< Determinant_t >>  dets,
std::unique_ptr< BackflowTransformation BF 
)

constructor

Parameters
targetPtcltarget Particleset
rnrelease node

Definition at line 22 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::BFTrans, SlaterDetWithBackflow::Dets, and ParticleSet::groups().

25  : Dets(std::move(dets)), BFTrans(std::move(BF))
26 {
27  assert(BFTrans);
28  assert(Dets.size() == targetPtcl.groups());
29 }
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ ~SlaterDetWithBackflow()

~SlaterDetWithBackflow ( )
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 99 of file SlaterDetWithBackflow.h.

References SlaterDetWithBackflow::BFTrans, and SlaterDetWithBackflow::Dets.

100  {
101  BFTrans->acceptMove(P, iat);
102  for (int i = 0; i < Dets.size(); i++)
103  Dets[i]->acceptMove(P, iat);
104  }
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
a move for iat-th particle is accepted.
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
inlineoverridevirtual

check out variational optimizable variables

Parameters
activea super set of optimizable variables

Reimplemented from WaveFunctionComponent.

Definition at line 46 of file SlaterDetWithBackflow.h.

References SlaterDetWithBackflow::BFTrans, and SlaterDetWithBackflow::Dets.

Referenced by SlaterDetWithBackflow::testDerivGL().

47  {
48  //if(Optimizable) {
49  if (BFTrans->isOptimizable())
50  {
51  BFTrans->checkOutVariables(active);
52  for (int i = 0; i < Dets.size(); i++)
53  Dets[i]->checkOutVariables(active);
54  }
55  }
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ 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 80 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::BFTrans, and SlaterDetWithBackflow::Dets.

81 {
82  BFTrans->copyFromBuffer(P, buf);
83  for (int i = 0; i < Dets.size(); i++)
84  Dets[i]->copyFromBuffer(P, buf);
85 }
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ 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 75 of file SlaterDetWithBackflow.h.

References SlaterDetWithBackflow::Dets.

76  {
78  for (int i = 0; i < Dets.size(); ++i)
79  g += Dets[i]->evalGrad(P, iat);
80  return g;
81  }
QTBase::GradType GradType
Definition: Configuration.h:62
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ 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 83 of file SlaterDetWithBackflow.h.

References APP_ABORT.

84  {
85  APP_ABORT("Need to implement SlaterDetWithBackflow::evalGradSource() \n");
86  return ValueType();
87  }
QTBase::ValueType ValueType
Definition: Configuration.h:60
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ 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 89 of file SlaterDetWithBackflow.h.

References APP_ABORT.

94  {
95  APP_ABORT("Need to implement SlaterDetWithBackflow::evalGradSource() \n");
96  return GradType();
97  }
QTBase::GradType GradType
Definition: Configuration.h:62
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ evaluateDerivatives()

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

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

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

Implements WaveFunctionComponent.

Definition at line 193 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::BFTrans, and SlaterDetWithBackflow::Dets.

197 {
198  //testDerivGL(P);
199  if (BFTrans->isOptimizable())
200  {
201  // build QP,Amat,Bmat_full,Xmat,Cmat,Ymat
202  BFTrans->evaluateDerivatives(P);
203  for (int i = 0; i < Dets.size(); i++)
204  Dets[i]->evaluateDerivatives(P, optvars, dlogpsi, dhpsioverpsi);
205  }
206 }
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimi...
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ evaluateLog()

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 53 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::BFTrans, SlaterDetWithBackflow::Dets, and WaveFunctionComponent::log_value_.

Referenced by SlaterDetWithBackflow::testDerivGL().

56 {
57  BFTrans->evaluate(P);
58  log_value_ = 0.0;
59  for (int i = 0; i < Dets.size(); ++i)
60  log_value_ += Dets[i]->evaluateLog(P, G, L);
61  return log_value_;
62 }
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ 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 47 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::Dets.

48 {
49  for (int i = 0; i < Dets.size(); ++i)
50  Dets[i]->evaluateRatiosAlltoOne(P, ratios);
51 }
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios) override
evaluate the ratios of one virtual move with respect to all the particles
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ 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 40 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::BFTrans, SlaterDetWithBackflow::Dets, SlaterDetWithBackflow::extractOptimizableObjectRefs(), and UniqueOptObjRefs::push_back().

Referenced by SlaterDetWithBackflow::extractOptimizableObjectRefs(), and SlaterDetWithBackflow::testDerivGL().

41 {
42  opt_obj_refs.push_back(*BFTrans);
43  for (int i = 0; i < Dets.size(); i++)
44  Dets[i]->extractOptimizableObjectRefs(opt_obj_refs);
45 }
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 40 of file SlaterDetWithBackflow.h.

40 { return "SlaterDetWithBackflow"; }

◆ getPhi()

SPOSetPtr getPhi ( int  i = 0) const
inline

Definition at line 126 of file SlaterDetWithBackflow.h.

References SlaterDetWithBackflow::Dets.

126 { return Dets[i]->getPhi(); }
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ isFermionic()

bool isFermionic ( ) const
inlinefinalvirtual

true, if this component is fermionic

Reimplemented from WaveFunctionComponent.

Definition at line 41 of file SlaterDetWithBackflow.h.

41 { return true; }

◆ isOptimizable()

bool isOptimizable ( ) const
overridevirtual

if true, this contains optimizable components

Reimplemented from WaveFunctionComponent.

Definition at line 34 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::BFTrans, qmcplusplus::det(), and SlaterDetWithBackflow::Dets.

Referenced by SlaterDetWithBackflow::makeClone().

35 {
36  return BFTrans->isOptimizable() ||
37  std::any_of(Dets.begin(), Dets.end(), [](const auto& det) { return det->isOptimizable(); });
38 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ 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 87 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::BFTrans, qmcplusplus::det(), SlaterDetWithBackflow::Dets, and SlaterDetWithBackflow::isOptimizable().

88 {
89  auto bf = BFTrans->makeClone(tqp);
90  std::vector<std::unique_ptr<Determinant_t>> dets;
91  for (const auto& det : Dets)
92  dets.push_back(det->makeCopyWithBF(det->getPhi()->makeClone(), *bf));
93  auto myclone = std::make_unique<SlaterDetWithBackflow>(tqp, std::move(dets), std::move(bf));
94  assert(myclone->isOptimizable() == isOptimizable());
95  return myclone;
96 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
bool isOptimizable() const override
if true, this contains optimizable components
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ 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 114 of file SlaterDetWithBackflow.h.

References SlaterDetWithBackflow::BFTrans, and SlaterDetWithBackflow::Dets.

115  {
116  BFTrans->evaluatePbyP(P, iat);
117  //BFTrans->evaluate(P);
118  PsiValue ratio = 1.0;
119  for (int i = 0; i < Dets.size(); ++i)
120  ratio *= Dets[i]->ratio(P, iat);
121  return ratio;
122  }
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ ratioGrad()

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 65 of file SlaterDetWithBackflow.h.

References SlaterDetWithBackflow::BFTrans, and SlaterDetWithBackflow::Dets.

66  {
67  BFTrans->evaluatePbyPWithGrad(P, iat);
68  //BFTrans->evaluate(P);
69  PsiValue psi = 1.0;
70  for (int i = 0; i < Dets.size(); ++i)
71  psi *= Dets[i]->ratioGrad(P, iat, grad_iat);
72  return psi;
73  }
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...

◆ 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 64 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::BFTrans, and SlaterDetWithBackflow::Dets.

65 {
66  BFTrans->registerData(P, buf);
67  for (int i = 0; i < Dets.size(); ++i)
68  Dets[i]->registerData(P, buf);
69 }
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ 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 106 of file SlaterDetWithBackflow.h.

References SlaterDetWithBackflow::BFTrans, and SlaterDetWithBackflow::Dets.

107  {
108  BFTrans->restore(iat);
109  for (int i = 0; i < Dets.size(); i++)
110  Dets[i]->restore(iat);
111  }
void restore(int iat) override
If a move for iat-th particle is rejected, restore to the content.
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ testDerivGL()

void testDerivGL ( ParticleSet P)

Definition at line 98 of file SlaterDetWithBackflow.cpp.

References APP_ABORT, qmcplusplus::app_log(), SlaterDetWithBackflow::BFTrans, SlaterDetWithBackflow::checkOutVariables(), SlaterDetWithBackflow::Dets, DiracDeterminantWithBackflow::evaluateDerivatives(), SlaterDetWithBackflow::evaluateLog(), SlaterDetWithBackflow::extractOptimizableObjectRefs(), ParticleSet::getTotalNum(), VariableSet::print(), Vector< T, Alloc >::resize(), VariableSet::size(), DiracDeterminantWithBackflow::testDerivFjj(), DiracDeterminantWithBackflow::testDerivLi(), and DiracDeterminantWithBackflow::testGGG().

99 {
100  // testing derivatives of G and L
101  app_log() << "testing derivatives of G and L \n";
102  opt_variables_type wfVars, wfvar_prime;
103  UniqueOptObjRefs opt_obj_refs;
104  extractOptimizableObjectRefs(opt_obj_refs);
105  for (OptimizableObject& obj : opt_obj_refs)
106  obj.checkInVariablesExclusive(wfVars);
107  checkOutVariables(wfVars);
108  int Nvars = wfVars.size();
109  wfvar_prime = wfVars;
110  wfVars.print(std::cout);
111  std::vector<RealType> dlogpsi;
112  std::vector<RealType> dhpsi;
113  dlogpsi.resize(Nvars);
114  dhpsi.resize(Nvars);
117  G0.resize(P.getTotalNum());
118  G1.resize(P.getTotalNum());
119  G2.resize(P.getTotalNum());
120  L0.resize(P.getTotalNum());
121  L1.resize(P.getTotalNum());
122  L2.resize(P.getTotalNum());
123  LogValue psi1 = 1.0;
124  LogValue psi2 = 1.0;
125  RealType dh = 0.00001;
126  for (int k = 0; k < Dets.size(); k++)
127  {
128  DiracDeterminantWithBackflow* Dets_ = dynamic_cast<DiracDeterminantWithBackflow*>(Dets[k].get());
129  Dets_->testGGG(P);
130  for (int i = 0; i < Nvars; i++)
131  {
132  Dets_->testDerivFjj(P, i);
133  Dets_->testDerivLi(P, i);
134  }
135  }
136  app_log() << "Nvars: " << Nvars << std::endl;
137  for (int i = 0; i < Nvars; i++)
138  {
139  for (int j = 0; j < Nvars; j++)
140  wfvar_prime[j] = wfVars[j];
141  for (OptimizableObject& obj : opt_obj_refs)
142  obj.checkInVariablesExclusive(wfvar_prime);
143  BFTrans->evaluateDerivatives(P);
144  G0 = 0.0;
145  G1 = 0.0;
146  G2 = 0.0;
147  L0 = 0.0;
148  L1 = 0.0;
149  L2 = 0.0;
150  for (int k = 0; k < Dets.size(); k++)
151  {
152  DiracDeterminantWithBackflow* Dets_ = dynamic_cast<DiracDeterminantWithBackflow*>(Dets[k].get());
153  Dets_->evaluateDerivatives(P, wfVars, dlogpsi, dhpsi, &G0, &L0, i);
154  }
155 
156  for (int j = 0; j < Nvars; j++)
157  wfvar_prime[j] = wfVars[j];
158  wfvar_prime[i] = wfVars[i] + dh;
159  for (OptimizableObject& obj : opt_obj_refs)
160  obj.checkInVariablesExclusive(wfvar_prime);
161  BFTrans->evaluate(P);
162  for (int k = 0; k < Dets.size(); k++)
163  psi1 += Dets[k]->evaluateLog(P, G1, L1);
164 
165  for (int j = 0; j < Nvars; j++)
166  wfvar_prime[j] = wfVars[j];
167  wfvar_prime[i] = wfVars[i] - dh;
168  for (OptimizableObject& obj : opt_obj_refs)
169  obj.checkInVariablesExclusive(wfvar_prime);
170  BFTrans->evaluate(P);
171  for (int k = 0; k < Dets.size(); k++)
172  psi2 += Dets[k]->evaluateLog(P, G2, L2);
173 
175  for (int q = 0; q < P.getTotalNum(); q++)
176  tmp += (L1[q] - L2[q]) / (2.0 * dh);
177  app_log() << i << "\n"
178  << "Ldiff : " << L0[0] << " " << tmp << " " << L0[0] - tmp << std::endl;
179  for (int k = 0; k < P.getTotalNum(); k++)
180  {
181  app_log() << G0[k] << std::endl
182  << (G1[k] - G2[k]) / (2.0 * dh) << std::endl
183  << "Gdiff: " << G0[k] - (G1[k] - G2[k]) / (2.0 * dh) << std::endl
184  << std::endl;
185  }
186  }
187  for (OptimizableObject& obj : opt_obj_refs)
188  obj.checkInVariablesExclusive(wfVars);
189  APP_ABORT("Testing bF derivs \n");
190 }
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
std::ostream & app_log()
Definition: OutputManager.h:65
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
QTFull::ValueType SingleParticleValue
Definition: Configuration.h:97
std::complex< QTFull::RealType > LogValue
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
optimize::VariableSet opt_variables_type
QMCTraits::RealType RealType
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

◆ updateBuffer()

SlaterDetWithBackflow::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 71 of file SlaterDetWithBackflow.cpp.

References SlaterDetWithBackflow::BFTrans, SlaterDetWithBackflow::Dets, and WaveFunctionComponent::log_value_.

72 {
73  BFTrans->updateBuffer(P, buf, fromscratch);
74  log_value_ = 0.0;
75  for (int i = 0; i < Dets.size(); ++i)
76  log_value_ += Dets[i]->updateBuffer(P, buf, fromscratch);
77  return log_value_;
78 }
const std::unique_ptr< BackflowTransformation > BFTrans
backflow transformation
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
const std::vector< std::unique_ptr< Determinant_t > > Dets
container for the DiracDeterminants

Member Data Documentation

◆ BFTrans

◆ Dets


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