16 #ifndef QMCPLUSPLUS_DIRACDETERMINANT_BASE_H 17 #define QMCPLUSPLUS_DIRACDETERMINANT_BASE_H 78 Phi->extractOptimizableObjectRefs(opt_obj_refs);
83 if (
Phi->isOptimizable())
84 Phi->checkOutVariables(active);
89 throw std::runtime_error(
"DiracDeterminantBase::registerTWFFastDerivWrapper must be overridden\n");
142 APP_ABORT(
" Illegal action. Cannot use DiracDeterminantBase::evaluateDerivatives");
148 APP_ABORT(
" Illegal action. Cannot use DiracDeterminantBase::makeClone");
149 return std::unique_ptr<DiracDeterminantBase>();
154 APP_ABORT(
" DiracDeterminantBase::ratioGradWithSpin(): Implementation required\n");
159 APP_ABORT(
" DiracDeterminantBase::evalGradWithSpin(): Implementation required\n");
169 virtual std::unique_ptr<DiracDeterminantBase>
makeCopy(std::unique_ptr<SPOSet>&& spo)
const = 0;
175 const std::unique_ptr<SPOSet>
Phi;
197 throw std::runtime_error(
"gradient of NaN");
199 throw std::runtime_error(
"gradient of inf");
200 if (g_mag <
std::abs(std::numeric_limits<RealType>::epsilon()))
202 std::cerr <<
"evalGrad gradient is " << g[0] <<
' ' << g[1] <<
' ' << g[2] <<
'\n';
203 throw std::runtime_error(
"gradient of zero");
base class for Single-particle orbital sets
virtual void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
return a shared resource to a collection
virtual LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)=0
evaluate the value of the WaveFunctionComponent from scratch
virtual LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false)=0
For particle-by-particle move.
helper functions for EinsplineSetBuilder
QTBase::GradType GradType
virtual void recompute(const ParticleSet &P)
recompute the value of the WaveFunctionComponents which require critical accuracy.
virtual void evaluateHessian(ParticleSet &P, HessVector &grad_grad_psi_all)
virtual void registerTWFFastDerivWrapper(const ParticleSet &P, TWFFastDerivWrapper &twf) const override
Register the component with the TWFFastDerivWrapper wrapper.
virtual GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat)
return the logarithmic gradient for the iat-th particle of the source particleset ...
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
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.
DetMatInvertor
determinant matrix inverter select
virtual std::unique_ptr< DiracDeterminantBase > makeCopy(std::unique_ptr< SPOSet > &&spo) const =0
cloning function
virtual ValueMatrix & getPsiMinv()
QTBase::ComplexType ComplexType
Timer accumulates time and call counts.
bool isFermionic() const final
true, if this component is fermionic
TWFFastDerivWrapper is a wrapper class for TrialWavefunction that provides separate and low level acc...
virtual void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
acquire a shared resource from a collection
const int FirstIndex
index of the first particle with respect to the particle set
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
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 ...
static bool checkG(const GradType &g)
An abstract class for a component of a many-body trial wave function.
virtual void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)=0
Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimi...
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
Specialized paritlce class for atomistic simulations.
GradType evalGradWithSpin(ParticleSet &P, int iat, ComplexType &spingrad) override
return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunc...
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const final
make clone
virtual void registerData(ParticleSet &P, WFBufferType &buf)=0
For particle-by-particle move.
PsiValue ratioGradWithSpin(ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default im...
void checkOutVariables(const opt_variables_type &active) final
check out variational optimizable variables
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...
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
class to handle a set of variables that can be modified during optimizations
const int LastIndex
index of the last particle with respect to the particle set
virtual void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
virtual GradType evalGrad(ParticleSet &P, int iat)
return the current gradient for the iat-th particle
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
virtual void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, int offset, Matrix< RealType > &dlogpsi, Array< GradType, 3 > &dG, Matrix< RealType > &dL)
QTFull::ValueType PsiValue
virtual void evaluateSpinorRatios(const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
Used by SOECPComponent for faster SOC evaluation.
virtual PsiValue ratio(ParticleSet &P, int iat)=0
evaluate the ratio of the new to old WaveFunctionComponent value
virtual void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
evaluate ratios to evaluate the non-local PP
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) final
extract underlying OptimizableObject references
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.
DiracDeterminantBase(const std::string &class_name, std::unique_ptr< SPOSet > &&spos, int first, int last)
constructor
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
~DiracDeterminantBase() override
default destructor
void mw_ratioGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const
NewTimer & UpdateTimer
Timers.
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
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
virtual void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi) override
Compute the derivatives of the log of the wavefunction with respect to optimizable parameters...
virtual PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat)
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
virtual void copyFromBuffer(ParticleSet &P, WFBufferType &buf)=0
For particle-by-particle move.
virtual void completeUpdates()
complete all the delayed or asynchronous operations before leaving the p-by-p move region...
Declaration of WaveFunctionComponent.
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 ...
const int NumPtcls
number of particles which belong to this Dirac determinant
virtual void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios)
evaluate the ratios of one virtual move with respect to all the particles
virtual void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false)=0
a move for iat-th particle is accepted.
A D-dimensional Array class based on PETE.
int getFirstIndex() const
virtual void restore(int iat)=0
If a move for iat-th particle is rejected, restore to the content.
bool isOptimizable() const final
if true, this contains optimizable components
bool isinf(float a)
return true if the value is Inf.
DiracDeterminantBase & operator=(const DiracDeterminantBase &s)=delete
bool isnan(float a)
return true if the value is NaN.