QMCPACK
Many-body wave function group

Classes to handle many-body trial wave functions. More...

Classes

class  TrialWaveFunction
 Class to represent a many-body trial wave function. More...
 

Detailed Description

Classes to handle many-body trial wave functions.


Class Documentation

◆ qmcplusplus::TrialWaveFunction

class qmcplusplus::TrialWaveFunction

Class to represent a many-body trial wave function.

A many-body trial wave function is represented by $\Psi({\bf R}) = \prod_i \psi_i({\bf R})$, where each function $\psi_i({\bf R})$ is an WaveFunctionComponent (see WaveFunctionComponent). A Composite Pattern is used to handle $\prod$ operations. Each WaveFunctionComponent should provide proper evaluate functions for the value, gradient and laplacian values.

mw_ prefix is a function name signature indicating it is for handling a batch of TrialWaveFunction objects in a lock-step fashion. These functions are defined statically because they should not have access to a concrete TWF object except through the passed RefVectorWithLeader<TWF>&. It dispatches to mw_ functions of WaveFunctionComponent

Definition at line 60 of file TrialWaveFunction.h.

+ Collaboration diagram for TrialWaveFunction:

Public Types

enum  ComputeType { ALL, FERMIONIC, NONFERMIONIC }
 enum type for computing partial WaveFunctionComponents More...
 
using RealType = WaveFunctionComponent::RealType
 
using ComplexType = WaveFunctionComponent::ComplexType
 
using FullPrecRealType = WaveFunctionComponent::FullPrecRealType
 
using ValueType = WaveFunctionComponent::ValueType
 
using ValueVector = WaveFunctionComponent::ValueVector
 
using GradType = WaveFunctionComponent::GradType
 
using BufferType = WaveFunctionComponent::BufferType
 
using WFBufferType = WaveFunctionComponent::WFBufferType
 
using HessType = WaveFunctionComponent::HessType
 
using HessVector = WaveFunctionComponent::HessVector
 
using LogValue = WaveFunctionComponent::LogValue
 
using PsiValue = WaveFunctionComponent::PsiValue
 
using SPOMap = SPOSet::SPOMap
 

Public Member Functions

 TrialWaveFunction (const RuntimeOptions &runtime_options, const std::string_view aname="psi0", bool tasking=false)
 
 TrialWaveFunction (const TrialWaveFunction &)=delete
 
TrialWaveFunctionoperator= (const TrialWaveFunction &)=delete
 
 ~TrialWaveFunction ()
 Destructor. More...
 
int size () const
 
RealType getPhase () const
 
void setPhase (RealType PhaseValue_new)
 
void getLogs (std::vector< RealType > &lvals)
 
void getPhases (std::vector< RealType > &pvals)
 
RealType getPhaseDiff () const
 
void resetPhaseDiff ()
 
RealType getLogPsi () const
 
void setLogPsi (RealType LogPsi_new)
 
void addComponent (std::unique_ptr< WaveFunctionComponent > &&aterm)
 add a WaveFunctionComponent More...
 
bool put (xmlNodePtr cur)
 read from xmlNode More...
 
UniqueOptObjRefs extractOptimizableObjectRefs ()
 extract underlying OptimizableObject references More...
 
void checkInVariables (opt_variables_type &o)
 Check in an optimizable parameter. More...
 
void checkOutVariables (const opt_variables_type &o)
 Check out optimizable variables Assign index mappings from global list (o) to local values in each component. More...
 
void resetParameters (const opt_variables_type &active)
 Set values of parameters in each component from the global list. More...
 
void reportStatus (std::ostream &os)
 print out state of the trial wavefunction More...
 
void initializeTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Initialize a TWF wrapper for fast derivative evaluation. More...
 
RealType evaluateLog (ParticleSet &P)
 evalaute the log (internally gradients and laplacian) of the trial wavefunction. More...
 
void recompute (const ParticleSet &P)
 recompute the value of the orbitals which require critical accuracy More...
 
RealType evaluateDeltaLog (ParticleSet &P, bool recompute=false)
 evaluate the log value of a many-body wave function More...
 
void evaluateDeltaLogSetup (ParticleSet &P, RealType &logpsi_fixed, RealType &logpsi_opt, ParticleSet::ParticleGradient &fixedG, ParticleSet::ParticleLaplacian &fixedL)
 evaluate the sum of log value of optimizable many-body wavefunctions More...
 
ValueType calcRatio (ParticleSet &P, int iat, ComputeType ct=ComputeType::ALL)
 compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex. More...
 
void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios, ComputeType ct=ComputeType::ALL)
 compulte multiple ratios to handle non-local moves and other virtual moves More...
 
void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios) const
 Used by SOECPComponent to do faster SOC evaluation. More...
 
void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratio)
 compute both ratios and deriatives of ratio with respect to the optimizables More...
 
void printGL (ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, std::string tag="GL")
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat)
 Returns the logarithmic gradient of the trial wave function with respect to the iat^th atom of the source ParticleSet. More...
 
GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad)
 Returns the logarithmic gradient of the w.r.t. More...
 
ValueType calcRatioGrad (ParticleSet &P, int iat, GradType &grad_iat)
 compute psi(R_new) / psi(R_current) ratio and ln(psi(R_new)) gradients It returns a complex value if the wavefunction is complex. More...
 
ValueType calcRatioGradWithSpin (ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad_iat)
 compute psi(R_new) / psi(R_current) ratio and d/ds ln(psi(R_new)) spin gradient It returns a complex value if the wavefunction is complex. More...
 
void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group Particle groups usually correspond to determinants of different spins. More...
 
GradType evalGrad (ParticleSet &P, int iat)
 
GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad)
 compute d/ds ln(psi) spin gradient at current particle position for iat electron More...
 
void rejectMove (int iat)
 restore to the original state More...
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false)
 update the state with the new data More...
 
void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
LogValue evaluateGL (ParticleSet &P, bool fromscratch)
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
void registerData (ParticleSet &P, WFBufferType &buf)
 register all the wavefunction components in buffer. More...
 
RealType updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false)
 update all the wavefunction components in buffer. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf)
 copy all the wavefunction components from buffer. More...
 
void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
RealType KECorrection () const
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
 evaluate derivatives of KE wrt optimizable varibles More...
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi)
 
void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 
void evaluateHessian (ParticleSet &P, HessVector &all_grad_grad_psi)
 evaluate the hessian w.r.t. More...
 
std::unique_ptr< TrialWaveFunctionmakeClone (ParticleSet &tqp) const
 
std::vector< std::unique_ptr< WaveFunctionComponent > > const & getOrbitals ()
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 
void setTwist (const std::vector< RealType > &t)
 
void setTwist (std::vector< RealType > &&t)
 
const std::vector< RealType > & twist () const
 
void setMassTerm (ParticleSet &P)
 
RealType getReciprocalMass ()
 
const std::string & getName () const
 
bool use_tasking () const
 
void storeXMLNode (xmlNodePtr node)
 
xmlNodePtr getNode () const
 
void storeSPOMap (SPOMap &&spomap)
 store an SPOSet map More...
 
const SPOSetgetSPOSet (const std::string &name) const
 look up SPOSet named 'name', if not found, throw exception. More...
 
const SPOMapgetSPOMap () const
 spomap_ reference accessor More...
 
RefVector< MultiSlaterDetTableMethodfindMSD () const
 find MSD WFCs if exist More...
 

Static Public Member Functions

static void mw_evaluateLog (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list)
 batched version of evaluateLog. More...
 
static void mw_recompute (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute)
 batched version of recompute More...
 
static void mw_evaluateDeltaLogSetup (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, std::vector< RealType > &logpsi_fixed_list, std::vector< RealType > &logpsi_opt_list, RefVector< ParticleSet::ParticleGradient > &fixedG_list, RefVector< ParticleSet::ParticleLaplacian > &fixedL_list)
 evaluate the sum of log value of optimizable many-body wavefunctions More...
 
static void mw_evaluateDeltaLog (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, std::vector< RealType > &logpsi_list, RefVector< ParticleSet::ParticleGradient > &dummyG_list, RefVector< ParticleSet::ParticleLaplacian > &dummyL_list, bool recompute=false)
 evaluate the log value for optimizable parts of a many-body wave function More...
 
static void mw_calcRatio (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, ComputeType ct=ComputeType::ALL)
 batched version of calcRatio More...
 
static void mw_evaluateRatios (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< const VirtualParticleSet > &Vp_list, const RefVector< std::vector< ValueType >> &ratios_list, ComputeType ct=ComputeType::ALL)
 batched version of evaluateRatios Note: unlike other mw_ static functions, *this is the batch leader instead of wf_list[0]. More...
 
template<CoordsType CT>
static void mw_calcRatioGrad (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grads)
 batched version of ratioGrad More...
 
static void mw_prepareGroup (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig)
 batched version of prepareGroup More...
 
template<CoordsType CT>
static void mw_evalGrad (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, TWFGrads< CT > &grads)
 batched version of evalGrad More...
 
static void mw_accept_rejectMove (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false)
 
static void mw_completeUpdates (const RefVectorWithLeader< TrialWaveFunction > &wf_list)
 
static void mw_evaluateGL (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, bool fromscratch)
 
static void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< TrialWaveFunction > &wf_list)
 acquire external resource Note: use RAII ResourceCollectionLock whenever possible More...
 
static void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< TrialWaveFunction > &wf_list)
 release external resource Note: use RAII ResourceCollectionLock whenever possible More...
 
static void mw_evaluateParameterDerivatives (const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const opt_variables_type &optvars, RecordArray< ValueType > &dlogpsi, RecordArray< ValueType > &dhpsioverpsi)
 

Public Attributes

ParticleSet::ParticleGradient G
 differential gradients More...
 
ParticleSet::ParticleLaplacian L
 differential laplacians More...
 

Static Private Member Functions

static void debugOnlyCheckBuffer (WFBufferType &buffer)
 
static std::vector< WaveFunctionComponent * > extractWFCPtrList (const UPtrVector< TrialWaveFunction > &wf_list, int id)
 helper function for extracting a list of WaveFunctionComponent from a list of TrialWaveFunction More...
 
static RefVectorWithLeader< WaveFunctionComponentextractWFCRefList (const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
 
static RefVector< ParticleSet::ParticleGradientextractGRefList (const RefVectorWithLeader< TrialWaveFunction > &wf_list)
 }@ More...
 
static RefVector< ParticleSet::ParticleLaplacianextractLRefList (const RefVectorWithLeader< TrialWaveFunction > &wf_list)
 

Private Attributes

const RuntimeOptionsruntime_options_
 top-level runtime options from project data information > WaveFunctionPool More...
 
xmlNodePtr myNode_
 XML input node for a many-body wavefunction. More...
 
const std::shared_ptr< SPOMapspomap_
 Owned SPOSets. Once a TWF is fully built, SPOSet lookup should be done via TWF. More...
 
const std::string myName
 getName is in the way More...
 
size_t BufferCursor
 starting index of the buffer More...
 
size_t BufferCursor_scalar
 starting index of the scalar buffer More...
 
RealType PhaseValue
 sign of the trial wave function More...
 
RealType PhaseDiff
 diff of the phase of the trial wave function during ratio calls More...
 
RealType log_real_
 real part of trial wave function log More...
 
RealType OneOverM
 One over mass of target particleset, needed for Local Energy Derivatives. More...
 
const bool use_tasking_
 if true, using internal tasking implementation More...
 
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
 a list of WaveFunctionComponents constituting many-body wave functions More...
 
TWFFastDerivWrapper twf_prototype
 For now, TrialWaveFunction will own the wrapper. More...
 
TimerList_t TWF_timers_
 timers at TrialWaveFunction function call level More...
 
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
 timers at WaveFunctionComponent function call level More...
 
std::vector< RealTypemyTwist
 

Member Typedef Documentation

◆ BufferType

◆ ComplexType

◆ FullPrecRealType

◆ GradType

Definition at line 73 of file TrialWaveFunction.h.

◆ HessType

Definition at line 76 of file TrialWaveFunction.h.

◆ HessVector

◆ LogValue

Definition at line 78 of file TrialWaveFunction.h.

◆ PsiValue

Definition at line 79 of file TrialWaveFunction.h.

◆ RealType

Definition at line 64 of file TrialWaveFunction.h.

◆ SPOMap

Definition at line 81 of file TrialWaveFunction.h.

◆ ValueType

using ValueType = WaveFunctionComponent::ValueType

Definition at line 71 of file TrialWaveFunction.h.

◆ ValueVector

◆ WFBufferType

Member Enumeration Documentation

◆ ComputeType

enum ComputeType
strong

enum type for computing partial WaveFunctionComponents

Enumerator
ALL 
FERMIONIC 
NONFERMIONIC 

Definition at line 84 of file TrialWaveFunction.h.

85  {
86  ALL,
87  FERMIONIC,
88  NONFERMIONIC
89  };

Constructor & Destructor Documentation

◆ TrialWaveFunction() [1/2]

TrialWaveFunction ( const RuntimeOptions runtime_options,
const std::string_view  aname = "psi0",
bool  tasking = false 
)

Definition at line 56 of file TrialWaveFunction.cpp.

References qmcplusplus::suffixes, and qmcplusplus::TIMER_SKIP.

57  : runtime_options_(runtime_options),
58  myNode_(NULL),
59  spomap_(std::make_shared<SPOMap>()),
60  myName(aname),
61  BufferCursor(0),
63  PhaseValue(0.0),
64  PhaseDiff(0.0),
65  log_real_(0.0),
66  OneOverM(1.0),
67  use_tasking_(tasking),
69 {
70  if (suffixes.size() != TIMER_SKIP)
71  throw std::runtime_error("TrialWaveFunction::TrialWaveFunction mismatched timer enums and suffixes");
72 }
size_t BufferCursor_scalar
starting index of the scalar buffer
RealType PhaseDiff
diff of the phase of the trial wave function during ratio calls
const bool use_tasking_
if true, using internal tasking implementation
RealType PhaseValue
sign of the trial wave function
const std::shared_ptr< SPOMap > spomap_
Owned SPOSets. Once a TWF is fully built, SPOSet lookup should be done via TWF.
RealType log_real_
real part of trial wave function log
xmlNodePtr myNode_
XML input node for a many-body wavefunction.
static const std::vector< std::string > suffixes
static TimerNameList_t< TimerEnum > create_names(std::string_view myName)
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
RealType OneOverM
One over mass of target particleset, needed for Local Energy Derivatives.
const RuntimeOptions & runtime_options_
top-level runtime options from project data information > WaveFunctionPool
TimerManager< NewTimer > & getGlobalTimerManager()
size_t BufferCursor
starting index of the buffer
const std::string myName
getName is in the way

◆ TrialWaveFunction() [2/2]

TrialWaveFunction ( const TrialWaveFunction )
delete

◆ ~TrialWaveFunction()

Destructor.

Warning
Have not decided whether Z is cleaned up by TrialWaveFunction or not. It will depend on I/O implementation.

Definition at line 79 of file TrialWaveFunction.cpp.

References TrialWaveFunction::myNode_.

80 {
81  if (myNode_ != NULL)
82  xmlFreeNode(myNode_);
83 }
xmlNodePtr myNode_
XML input node for a many-body wavefunction.

Member Function Documentation

◆ acceptMove()

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

update the state with the new data

Parameters
PParticleSet
iatindex of the particle with a trial move

The proposed move of the iath particle is accepted. All the temporary data should be incorporated so that the next move is valid.

Definition at line 758 of file TrialWaveFunction.cpp.

References qmcplusplus::ACCEPT_TIMER, TrialWaveFunction::log_real_, TrialWaveFunction::PhaseDiff, TrialWaveFunction::PhaseValue, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SODMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPWithRejectionFast::advanceWalker(), SOVMCUpdatePbyP::advanceWalker(), VMCUpdatePbyP::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), RMCUpdatePbyPWithDrift::advanceWalkersRMC(), RMCUpdatePbyPWithDrift::advanceWalkersVMC(), NonLocalECPComponent::evaluateOneWithForces(), SOECPComponent::evaluateValueAndDerivatives(), NonLocalECPComponent::evaluateValueAndDerivatives(), NonLocalECPotential::makeNonLocalMovesPbyP(), WaveFunctionTester::runRatioTest(), qmcplusplus::TEST_CASE(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

759 {
760  ScopedTimer local_timer(TWF_timers_[ACCEPT_TIMER]);
761  PRAGMA_OMP_TASKLOOP("omp taskloop default(shared) if (use_tasking_)")
762  for (int i = 0; i < Z.size(); i++)
763  {
765  Z[i]->acceptMove(P, iat, safe_to_delay);
766  }
768  PhaseDiff = 0.0;
769  log_real_ = 0;
770  for (int i = 0; i < Z.size(); i++)
771  log_real_ += std::real(Z[i]->get_log_value());
772 }
QMCTraits::RealType real
RealType PhaseDiff
diff of the phase of the trial wave function during ratio calls
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
RealType PhaseValue
sign of the trial wave function
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
RealType log_real_
real part of trial wave function log
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list 
)
static

acquire external resource Note: use RAII ResourceCollectionLock whenever possible

Definition at line 1210 of file TrialWaveFunction.cpp.

References TrialWaveFunction::extractWFCRefList(), and RefVectorWithLeader< T >::getLeader().

1212 {
1213  auto& wf_leader = wf_list.getLeader();
1214  auto& wavefunction_components = wf_leader.Z;
1215  const int num_wfc = wf_leader.Z.size();
1216  for (int i = 0; i < num_wfc; ++i)
1217  {
1218  const auto wfc_list(extractWFCRefList(wf_list, i));
1219  wavefunction_components[i]->acquireResource(collection, wfc_list);
1220  }
1221 }
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)

◆ addComponent()

void addComponent ( std::unique_ptr< WaveFunctionComponent > &&  aterm)

add a WaveFunctionComponent

Takes owndership of aterm.

Parameters
aterma WaveFunctionComponent pointer

Definition at line 87 of file TrialWaveFunction.cpp.

References qmcplusplus::app_log(), qmcplusplus::createGlobalTimer(), qmcplusplus::suffixes, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by qmcplusplus::doSOECPotentialTest(), qmcplusplus::TEST_CASE(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

88 {
89  std::string aname = aterm->getClassName();
90  if (!aterm->getName().empty())
91  aname += ":" + aterm->getName();
92 
93  if (aterm->isFermionic())
94  app_log() << " Added a fermionic WaveFunctionComponent " << aname << std::endl;
95 
96  for (auto& suffix : suffixes)
97  WFC_timers_.push_back(createGlobalTimer(aname + "::" + suffix));
98 
99  Z.emplace_back(std::move(aterm));
100 }
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
static const std::vector< std::string > suffixes
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ calcRatio()

TrialWaveFunction::ValueType calcRatio ( ParticleSet P,
int  iat,
ComputeType  ct = ComputeType::ALL 
)

compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex.

Parameters
Pthe active ParticleSet
iatthe index of a particle moved to the new position.
ctselect ComputeType
Returns
ratio value

Definition at line 450 of file TrialWaveFunction.cpp.

References TrialWaveFunction::ALL, NaNguard::checkOneParticleRatio(), TrialWaveFunction::FERMIONIC, TrialWaveFunction::NONFERMIONIC, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, qmcplusplus::V_TIMER, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SOVMCUpdatePbyP::advanceWalker(), VMCUpdatePbyP::advanceWalker(), DensityMatrices1B::evaluate_check(), SOECPComponent::evaluateOne(), NonLocalECPComponent::evaluateOne(), NonLocalECPComponent::evaluateOneWithForces(), SOECPComponent::evaluateValueAndDerivatives(), NonLocalECPComponent::evaluateValueAndDerivatives(), OneBodyDensityMatrices::generateSampleRatios(), DensityMatrices1B::integrate(), SOECPComponent::mw_evaluateOne(), NonLocalECPComponent::mw_evaluateOne(), WaveFunctionTester::runBasicTest(), WaveFunctionTester::runNodePlot(), WaveFunctionTester::runRatioTest2(), qmcplusplus::TEST_CASE(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

451 {
452  ScopedTimer local_timer(TWF_timers_[V_TIMER]);
453  PsiValue r(1.0);
454  for (int i = 0; i < Z.size(); i++)
455  if (ct == ComputeType::ALL || (Z[i]->isFermionic() && ct == ComputeType::FERMIONIC) ||
456  (!Z[i]->isFermionic() && ct == ComputeType::NONFERMIONIC))
457  {
458  ScopedTimer z_timer(WFC_timers_[V_TIMER + TIMER_SKIP * i]);
459  r *= Z[i]->ratio(P, iat);
460  }
461 
462  NaNguard::checkOneParticleRatio(r, "TWF::calcRatio at particle " + std::to_string(iat));
463  return static_cast<ValueType>(r);
464 }
WaveFunctionComponent::PsiValue PsiValue
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
WaveFunctionComponent::ValueType ValueType
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
static void checkOneParticleRatio(const PsiValue &ratio, const std::string_view info)
check if ratio is NaN and throw an error if yes.
Definition: NaNguard.cpp:18
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ calcRatioGrad()

TrialWaveFunction::ValueType calcRatioGrad ( ParticleSet P,
int  iat,
GradType grad_iat 
)

compute psi(R_new) / psi(R_current) ratio and ln(psi(R_new)) gradients It returns a complex value if the wavefunction is complex.

Parameters
Pthe active ParticleSet
iatthe index of a particle moved to the new position.
grad_iatgradients. The consumer must verify if ratio is non-zero.
Returns
ratio value. The caller must reject zero ratio moves.

Definition at line 609 of file TrialWaveFunction.cpp.

References NaNguard::checkOneParticleGradients(), NaNguard::checkOneParticleRatio(), qmcplusplus::convertValueToLog(), qmcplusplus::imag(), TrialWaveFunction::PhaseDiff, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::use_tasking_, qmcplusplus::VGL_TIMER, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by DMCUpdatePbyPWithRejectionFast::advanceWalker(), VMCUpdatePbyP::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), RMCUpdatePbyPWithDrift::advanceWalkersRMC(), RMCUpdatePbyPWithDrift::advanceWalkersVMC(), NonLocalECPComponent::evaluateOneWithForces(), NonLocalECPotential::makeNonLocalMovesPbyP(), and WaveFunctionTester::runRatioTest2().

610 {
611  ScopedTimer local_timer(TWF_timers_[VGL_TIMER]);
612  grad_iat = 0.0;
613  PsiValue r(1.0);
614  if (use_tasking_)
615  {
616  std::vector<GradType> grad_components(Z.size(), GradType(0.0));
617  std::vector<PsiValue> ratio_components(Z.size(), 0.0);
618  PRAGMA_OMP_TASKLOOP("omp taskloop default(shared)")
619  for (int i = 0; i < Z.size(); ++i)
620  {
622  ratio_components[i] = Z[i]->ratioGrad(P, iat, grad_components[i]);
623  }
624 
625  for (int i = 0; i < Z.size(); ++i)
626  {
627  grad_iat += grad_components[i];
628  r *= ratio_components[i];
629  }
630  }
631  else
632  for (int i = 0; i < Z.size(); ++i)
633  {
635  r *= Z[i]->ratioGrad(P, iat, grad_iat);
636  }
637 
638  NaNguard::checkOneParticleRatio(r, "TWF::calcRatioGrad at particle " + std::to_string(iat));
639  if (r != PsiValue(0)) // grad_iat is meaningful only when r is strictly non-zero
640  NaNguard::checkOneParticleGradients(grad_iat, "TWF::calcRatioGrad at particle " + std::to_string(iat));
641  LogValue logratio = convertValueToLog(r);
642  PhaseDiff = std::imag(logratio);
643  return static_cast<ValueType>(r);
644 }
WaveFunctionComponent::PsiValue PsiValue
WaveFunctionComponent::GradType GradType
RealType PhaseDiff
diff of the phase of the trial wave function during ratio calls
WaveFunctionComponent::LogValue LogValue
const bool use_tasking_
if true, using internal tasking implementation
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
WaveFunctionComponent::ValueType ValueType
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
static void checkOneParticleRatio(const PsiValue &ratio, const std::string_view info)
check if ratio is NaN and throw an error if yes.
Definition: NaNguard.cpp:18
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
static void checkOneParticleGradients(const GradType &grads, const std::string_view info)
check if any gradient component (x,y,z) is NaN and throw an error if yes.
Definition: NaNguard.cpp:29
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ calcRatioGradWithSpin()

TrialWaveFunction::ValueType calcRatioGradWithSpin ( ParticleSet P,
int  iat,
GradType grad_iat,
ComplexType spingrad_iat 
)

compute psi(R_new) / psi(R_current) ratio and d/ds ln(psi(R_new)) spin gradient It returns a complex value if the wavefunction is complex.

Parameters
Pthe active ParticleSet
iatthe index of a particle moved to the new position.
grad_iatreal space gradient for iat. The consumer must verify if ratio is non-zero.
spingrad_iatspin gradient for iat. The consumer must verify if ratio is non-zero.
Returns
ratio value. The caller must reject zero ratio moves.

Definition at line 646 of file TrialWaveFunction.cpp.

References NaNguard::checkOneParticleGradients(), NaNguard::checkOneParticleRatio(), qmcplusplus::convertValueToLog(), qmcplusplus::imag(), TrialWaveFunction::PhaseDiff, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, qmcplusplus::VGL_TIMER, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SODMCUpdatePbyPWithRejectionFast::advanceWalker(), and SOVMCUpdatePbyP::advanceWalker().

650 {
651  ScopedTimer local_timer(TWF_timers_[VGL_TIMER]);
652  grad_iat = 0.0;
653  spingrad_iat = 0.0;
654  PsiValue r(1.0);
655  for (int i = 0; i < Z.size(); ++i)
656  {
658  r *= Z[i]->ratioGradWithSpin(P, iat, grad_iat, spingrad_iat);
659  }
660 
661  NaNguard::checkOneParticleRatio(r, "TWF::calcRatioGradWithSpin at particle " + std::to_string(iat));
662  if (r != PsiValue(0)) // grad_iat is meaningful only when r is strictly non-zero
663  NaNguard::checkOneParticleGradients(grad_iat, "TWF::calcRatioGradWithSpin at particle " + std::to_string(iat));
664  LogValue logratio = convertValueToLog(r);
665  PhaseDiff = std::imag(logratio);
666  return static_cast<ValueType>(r);
667 }
WaveFunctionComponent::PsiValue PsiValue
RealType PhaseDiff
diff of the phase of the trial wave function during ratio calls
WaveFunctionComponent::LogValue LogValue
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
WaveFunctionComponent::ValueType ValueType
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
static void checkOneParticleRatio(const PsiValue &ratio, const std::string_view info)
check if ratio is NaN and throw an error if yes.
Definition: NaNguard.cpp:18
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
static void checkOneParticleGradients(const GradType &grads, const std::string_view info)
check if any gradient component (x,y,z) is NaN and throw an error if yes.
Definition: NaNguard.cpp:29
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ checkInVariables()

void checkInVariables ( opt_variables_type o)

Check in an optimizable parameter.

Parameters
oaggregated list of optimizable variables

Gather all the optimizable parameters from wavefunction components into a single list

Definition at line 912 of file TrialWaveFunction.cpp.

References TrialWaveFunction::extractOptimizableObjectRefs().

Referenced by WaveFunctionTester::runDerivCloneTest(), WaveFunctionTester::runDerivNLPPTest(), WaveFunctionTester::runDerivTest(), qmcplusplus::TEST_CASE(), and qmcplusplus::test_hcpBe_rotation().

913 {
914  auto opt_obj_refs = extractOptimizableObjectRefs();
915  for (OptimizableObject& obj : opt_obj_refs)
916  obj.checkInVariablesExclusive(active);
917 }
UniqueOptObjRefs extractOptimizableObjectRefs()
extract underlying OptimizableObject references

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type o)

Check out optimizable variables Assign index mappings from global list (o) to local values in each component.

Definition at line 919 of file TrialWaveFunction.cpp.

References TrialWaveFunction::Z.

Referenced by QMCCostFunctionBase::put(), WaveFunctionTester::runDerivCloneTest(), WaveFunctionTester::runDerivNLPPTest(), WaveFunctionTester::runDerivTest(), qmcplusplus::TEST_CASE(), and qmcplusplus::test_hcpBe_rotation().

920 {
921  for (int i = 0; i < Z.size(); i++)
922  if (Z[i]->isOptimizable())
923  Z[i]->checkOutVariables(active);
924 }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
void checkOutVariables(const opt_variables_type &o)
Check out optimizable variables Assign index mappings from global list (o) to local values in each co...

◆ completeUpdates()

void completeUpdates ( )

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

See WaveFunctionComponent::completeUpdates for more detail

Definition at line 807 of file TrialWaveFunction.cpp.

References qmcplusplus::ACCEPT_TIMER, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SODMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPWithRejectionFast::advanceWalker(), VMCUpdatePbyP::advanceWalker(), SOVMCUpdatePbyP::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), RMCUpdatePbyPWithDrift::advanceWalkersRMC(), RMCUpdatePbyPWithDrift::advanceWalkersVMC(), and NonLocalECPotential::makeNonLocalMovesPbyP().

808 {
809  ScopedTimer local_timer(TWF_timers_[ACCEPT_TIMER]);
810  for (int i = 0; i < Z.size(); i++)
811  {
813  Z[i]->completeUpdates();
814  }
815 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ copyFromBuffer()

void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)

copy all the wavefunction components from buffer.

See WaveFunctionComponent::updateBuffer for more detail

Definition at line 1014 of file TrialWaveFunction.cpp.

References qmcplusplus::BUFFER_TIMER, TrialWaveFunction::BufferCursor, TrialWaveFunction::BufferCursor_scalar, TrialWaveFunction::debugOnlyCheckBuffer(), PooledMemory< T_scalar, Alloc >::get(), TrialWaveFunction::log_real_, TrialWaveFunction::PhaseValue, PooledMemory< T_scalar, Alloc >::rewind(), qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SODMCUpdatePbyPWithRejectionFast::advanceWalker(), SOVMCUpdatePbyP::advanceWalker(), VMCUpdatePbyP::advanceWalker(), DMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), RMCUpdatePbyPWithDrift::advanceWalkersRMC(), RMCUpdatePbyPWithDrift::advanceWalkersVMC(), RMCUpdatePbyPWithDrift::initWalkersForPbyP(), QMCUpdateBase::initWalkersForPbyP(), WaveFunctionTester::runCloneTest(), WaveFunctionTester::runNodePlot(), WaveFunctionTester::runRatioTest(), and WaveFunctionTester::runRatioTest2().

1015 {
1016  ScopedTimer local_timer(TWF_timers_[BUFFER_TIMER]);
1017  buf.rewind(BufferCursor, BufferCursor_scalar);
1018  for (int i = 0; i < Z.size(); ++i)
1019  {
1021  Z[i]->copyFromBuffer(P, buf);
1022  }
1023  //get the gradients and laplacians from the buffer
1024  buf.get(PhaseValue);
1025  buf.get(log_real_);
1026  debugOnlyCheckBuffer(buf);
1027 }
size_t BufferCursor_scalar
starting index of the scalar buffer
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
RealType PhaseValue
sign of the trial wave function
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
RealType log_real_
real part of trial wave function log
static void debugOnlyCheckBuffer(WFBufferType &buffer)
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
size_t BufferCursor
starting index of the buffer
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ createResource()

void createResource ( ResourceCollection collection) const

initialize a shared resource and hand it to a collection

Definition at line 1204 of file TrialWaveFunction.cpp.

References TrialWaveFunction::Z.

Referenced by CostFunctionCrowdData::CostFunctionCrowdData(), qmcplusplus::doSOECPotentialTest(), QMCDriverNew::initializeQMC(), qmcplusplus::TEST_CASE(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

1205 {
1206  for (int i = 0; i < Z.size(); ++i)
1207  Z[i]->createResource(collection);
1208 }
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions

◆ debugOnlyCheckBuffer()

void debugOnlyCheckBuffer ( WFBufferType buffer)
staticprivate

Definition at line 973 of file TrialWaveFunction.cpp.

References PooledMemory< T_scalar, Alloc >::current(), PooledMemory< T_scalar, Alloc >::current_scalar(), and PooledMemory< T_scalar, Alloc >::size().

Referenced by TrialWaveFunction::copyFromBuffer(), and TrialWaveFunction::updateBuffer().

974 {
975 #ifndef NDEBUG
976  if (buffer.size() < buffer.current() + buffer.current_scalar() * sizeof(FullPrecRealType))
977  {
978  std::ostringstream assert_message;
979  assert_message << "On thread:" << Concurrency::getWorkerId<>() << " buf_list[iw].get().size():" << buffer.size()
980  << " < buf_list[iw].get().current():" << buffer.current()
981  << " + buf.current_scalar():" << buffer.current_scalar()
982  << " * sizeof(FullPrecRealType):" << sizeof(FullPrecRealType) << '\n';
983  throw std::runtime_error(assert_message.str());
984  }
985 #endif
986 }
WaveFunctionComponent::FullPrecRealType FullPrecRealType

◆ evalGrad()

TrialWaveFunction::GradType evalGrad ( ParticleSet P,
int  iat 
)

Definition at line 525 of file TrialWaveFunction.cpp.

References NaNguard::checkOneParticleGradients(), qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, qmcplusplus::VGL_TIMER, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by DMCUpdatePbyPWithRejectionFast::advanceWalker(), VMCUpdatePbyP::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), RMCUpdatePbyPWithDrift::advanceWalkersRMC(), RMCUpdatePbyPWithDrift::advanceWalkersVMC(), and WaveFunctionTester::runRatioTest2().

526 {
527  ScopedTimer local_timer(TWF_timers_[VGL_TIMER]);
528  GradType grad_iat;
529  for (int i = 0; i < Z.size(); ++i)
530  {
532  grad_iat += Z[i]->evalGrad(P, iat);
533  }
534  NaNguard::checkOneParticleGradients(grad_iat, "TWF::evalGrad at particle " + std::to_string(iat));
535  return grad_iat;
536 }
WaveFunctionComponent::GradType GradType
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
static void checkOneParticleGradients(const GradType &grads, const std::string_view info)
check if any gradient component (x,y,z) is NaN and throw an error if yes.
Definition: NaNguard.cpp:29
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evalGradSource() [1/2]

TrialWaveFunction::GradType evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat 
)

Returns the logarithmic gradient of the trial wave function with respect to the iat^th atom of the source ParticleSet.

Definition at line 582 of file TrialWaveFunction.cpp.

References TrialWaveFunction::Z.

Referenced by TrialWaveFunction::evalGradSource(), QMCHamiltonian::evaluateIonDerivs(), QMCHamiltonian::evaluateIonDerivsDeterministic(), NonLocalECPComponent::evaluateOneWithForces(), BareKineticEnergy::evaluateWithIonDerivs(), WaveFunctionTester::runGradSourceTest(), WaveFunctionTester::runZeroVarianceTest(), and qmcplusplus::TEST_CASE().

583 {
584  GradType grad_iat = GradType();
585  for (int i = 0; i < Z.size(); ++i)
586  grad_iat += Z[i]->evalGradSource(P, source, iat);
587  return grad_iat;
588 }
WaveFunctionComponent::GradType GradType
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat)
Returns the logarithmic gradient of the trial wave function with respect to the iat^th atom of the so...

◆ evalGradSource() [2/2]

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

Returns the logarithmic gradient of the w.r.t.

the iat^th atom of the source ParticleSet of the sum of laplacians w.r.t. the electrons (target ParticleSet) of the trial wave function.

Definition at line 590 of file TrialWaveFunction.cpp.

References TrialWaveFunction::evalGradSource(), OHMMS_DIM, TinyVector< T, D >::size(), and TrialWaveFunction::Z.

596 {
597  GradType grad_iat = GradType();
598  for (int dim = 0; dim < OHMMS_DIM; dim++)
599  for (int i = 0; i < grad_grad[0].size(); i++)
600  {
601  grad_grad[dim][i] = GradType();
602  lapl_grad[dim][i] = 0.0;
603  }
604  for (int i = 0; i < Z.size(); ++i)
605  grad_iat += Z[i]->evalGradSource(P, source, iat, grad_grad, lapl_grad);
606  return grad_iat;
607 }
WaveFunctionComponent::GradType GradType
#define OHMMS_DIM
Definition: config.h:64
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat)
Returns the logarithmic gradient of the trial wave function with respect to the iat^th atom of the so...

◆ evalGradWithSpin()

TrialWaveFunction::GradType evalGradWithSpin ( ParticleSet P,
int  iat,
ComplexType spingrad 
)

compute d/ds ln(psi) spin gradient at current particle position for iat electron

Parameters
Pactive particle set.
iatindex of the particle moved to the new position.
spingradspingrad value. Zeroed out first, then filled with d/ds ln(psi).
Returns
ln(psi) (complex)

Definition at line 538 of file TrialWaveFunction.cpp.

References NaNguard::checkOneParticleGradients(), qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, qmcplusplus::VGL_TIMER, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SODMCUpdatePbyPWithRejectionFast::advanceWalker(), and SOVMCUpdatePbyP::advanceWalker().

539 {
540  ScopedTimer local_timer(TWF_timers_[VGL_TIMER]);
541  GradType grad_iat;
542  spingrad = 0;
543  for (int i = 0; i < Z.size(); ++i)
544  {
546  grad_iat += Z[i]->evalGradWithSpin(P, iat, spingrad);
547  }
548  NaNguard::checkOneParticleGradients(grad_iat, "TWF::evalGradWithSpin at particle " + std::to_string(iat));
549  return grad_iat;
550 }
WaveFunctionComponent::GradType GradType
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
static void checkOneParticleGradients(const GradType &grads, const std::string_view info)
check if any gradient component (x,y,z) is NaN and throw an error if yes.
Definition: NaNguard.cpp:29
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateDeltaLog()

TrialWaveFunction::RealType evaluateDeltaLog ( ParticleSet P,
bool  recompute = false 
)

evaluate the log value of a many-body wave function

Parameters
Pinput configuration containing N particles
recomputeallrecompute all orbitals from scratch
Returns
the value of $ \log( \Pi_i \Psi_i) $ many-body wave function

default value. call evaluateLog only on optimizable orbitals. OK if nonlocal pp's aren't used.

To save time, logpsi, G, and L are only computed for orbitals that change over the course of the optimization. It is assumed that the fixed components are stored elsewhere. See evaluateDeltaLog(P,logpsi_fixed_r,logpsi_opt,fixedG,fixedL) defined below. Nonlocal pseudopotential evaluation requires temporary information like matrix inverses, so while the logpsi, G, and L don't change, evaluateLog is called anyways to compute these auxiliary quantities from scratch. logpsi, G, and L associated with these non-optimizable orbitals are discarded explicitly and with dummy variables.

Definition at line 232 of file TrialWaveFunction.cpp.

References TrialWaveFunction::evaluateLog(), ParticleSet::G, qmcplusplus::imag(), ParticleSet::L, TrialWaveFunction::log_real_, TrialWaveFunction::PhaseValue, qmcplusplus::RECOMPUTE_TIMER, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by qmcplusplus::TEST_CASE().

233 {
235  P.G = 0.0;
236  P.L = 0.0;
237  LogValue logpsi(0.0);
238  for (int i = 0; i < Z.size(); ++i)
239  {
241  if (Z[i]->isOptimizable())
242  logpsi += Z[i]->evaluateLog(P, P.G, P.L);
243  }
244  log_real_ = std::real(logpsi);
245  PhaseValue = std::imag(logpsi);
246 
247  //In case we need to recompute orbitals, initialize dummy vectors for G and L.
248  //evaluateLog dumps into these variables, and logPsi contribution is discarded.
249  //Only called for non-optimizable orbitals.
250  if (recomputeall)
251  {
252  ParticleSet::ParticleGradient dummyG(P.G);
253  ParticleSet::ParticleLaplacian dummyL(P.L);
254 
255  for (int i = 0; i < Z.size(); ++i)
256  {
257  //update orbitals if its not flagged optimizable, AND recomputeall is true
258  if (!Z[i]->isOptimizable())
259  Z[i]->evaluateLog(P, dummyG, dummyL);
260  }
261  }
262  return log_real_;
263 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
QMCTraits::RealType real
WaveFunctionComponent::LogValue LogValue
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
RealType PhaseValue
sign of the trial wave function
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
RealType log_real_
real part of trial wave function log
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateDeltaLogSetup()

void evaluateDeltaLogSetup ( ParticleSet P,
RealType logpsi_fixed,
RealType logpsi_opt,
ParticleSet::ParticleGradient fixedG,
ParticleSet::ParticleLaplacian fixedL 
)

evaluate the sum of log value of optimizable many-body wavefunctions

Parameters
Pinput configuration containing N particles
logpsi_fixedlog(std::abs(psi)) of the invariant orbitals
logpsi_optlog(std::abs(psi)) of the variable orbitals
fixedGgradients of log(psi) of the fixed wave functions
fixedLlaplacians of log(psi) of the fixed wave functions

This function is introduced for optimization only. fixedG and fixedL save the terms coming from the wave functions that are invariant during optimizations. It is expected that evaluateDeltaLog(P,false) is called later and the external object adds the varying G and L and the fixed terms.

Definition at line 265 of file TrialWaveFunction.cpp.

References qmcplusplus::convertToReal(), ParticleSet::G, ParticleSet::L, qmcplusplus::RECOMPUTE_TIMER, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by qmcplusplus::TEST_CASE().

270 {
272  P.G = 0.0;
273  P.L = 0.0;
274  fixedL = 0.0;
275  fixedG = 0.0;
276  LogValue logpsi_fixed(0.0);
277  LogValue logpsi_opt(0.0);
278 
279  for (int i = 0; i < Z.size(); ++i)
280  {
282  if (Z[i]->isOptimizable())
283  logpsi_opt += Z[i]->evaluateLog(P, P.G, P.L);
284  else
285  logpsi_fixed += Z[i]->evaluateLog(P, fixedG, fixedL);
286  }
287  P.G += fixedG;
288  P.L += fixedL;
289  convertToReal(logpsi_fixed, logpsi_fixed_r);
290  convertToReal(logpsi_opt, logpsi_opt_r);
291 }
WaveFunctionComponent::LogValue LogValue
void convertToReal(const T1 &in, T2 &out)
generic conversion from type T1 to type T2 using implicit conversion
Definition: ConvertToReal.h:32
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateDerivatives()

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

evaluate derivatives of KE wrt optimizable varibles

Todo:
WaveFunctionComponent objects should take the mass into account.

Definition at line 1128 of file TrialWaveFunction.cpp.

References qmcplusplus::DERIVS_TIMER, TrialWaveFunction::OneOverM, Vector< T, Alloc >::size(), qmcplusplus::TIMER_SKIP, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by BareKineticEnergy::evaluateValueAndDerivatives(), WaveFunctionTester::runDerivCloneTest(), WaveFunctionTester::runDerivNLPPTest(), WaveFunctionTester::runDerivTest(), qmcplusplus::TEST_CASE(), and qmcplusplus::test_hcpBe_rotation().

1132 {
1133  // // First, zero out derivatives
1134  // This should only be done for some variables.
1135  // for (int j=0; j<dlogpsi.size(); j++)
1136  // dlogpsi[j] = dhpsioverpsi[j] = 0.0;
1137  for (int i = 0; i < Z.size(); i++)
1138  {
1140  Z[i]->evaluateDerivatives(P, optvars, dlogpsi, dhpsioverpsi);
1141  }
1142  //orbitals do not know about mass of particle.
1143  for (int i = 0; i < dhpsioverpsi.size(); i++)
1144  dhpsioverpsi[i] *= OneOverM;
1145 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
size_type size() const
return the current size
Definition: OhmmsVector.h:162
RealType OneOverM
One over mass of target particleset, needed for Local Energy Derivatives.
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateDerivativesWF()

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

Definition at line 1164 of file TrialWaveFunction.cpp.

References qmcplusplus::DERIVS_TIMER, qmcplusplus::TIMER_SKIP, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SOECPComponent::evaluateValueAndDerivatives(), and NonLocalECPComponent::evaluateValueAndDerivatives().

1167 {
1168  for (int i = 0; i < Z.size(); i++)
1169  {
1171  Z[i]->evaluateDerivativesWF(P, optvars, dlogpsi);
1172  }
1173 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateDerivRatios()

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

compute both ratios and deriatives of ratio with respect to the optimizables

Definition at line 1094 of file TrialWaveFunction.cpp.

References Matrix< T, Alloc >::begin(), qmcplusplus::DERIVS_TIMER, Matrix< T, Alloc >::end(), qmcplusplus::TIMER_SKIP, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SOECPComponent::evaluateValueAndDerivatives(), and NonLocalECPComponent::evaluateValueAndDerivatives().

1098 {
1099  std::fill(ratios.begin(), ratios.end(), 1.0);
1100  std::fill(dratio.begin(), dratio.end(), 0.0);
1101  std::vector<ValueType> t(ratios.size());
1102  for (int i = 0; i < Z.size(); ++i)
1103  {
1105  Z[i]->evaluateDerivRatios(VP, optvars, t, dratio);
1106  for (int j = 0; j < ratios.size(); ++j)
1107  ratios[j] *= t[j];
1108  }
1109 }
Container_t::iterator begin()
Definition: OhmmsMatrix.h:89
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
Container_t::iterator end()
Definition: OhmmsMatrix.h:90
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateGL()

TrialWaveFunction::LogValue evaluateGL ( ParticleSet P,
bool  fromscratch 
)

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

See WaveFunctionComponent::evaluateGL for more detail

Definition at line 832 of file TrialWaveFunction.cpp.

References qmcplusplus::BUFFER_TIMER, ParticleSet::G, TrialWaveFunction::G, qmcplusplus::imag(), ParticleSet::L, TrialWaveFunction::L, TrialWaveFunction::log_real_, TrialWaveFunction::PhaseValue, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

833 {
834  ScopedTimer local_timer(TWF_timers_[BUFFER_TIMER]);
835  P.G = 0.0;
836  P.L = 0.0;
837  LogValue logpsi(0.0);
838  for (int i = 0; i < Z.size(); ++i)
839  {
841  logpsi += Z[i]->evaluateGL(P, P.G, P.L, fromscratch);
842  }
843 
844  // Ye: temporal workaround to have WF.G/L always defined.
845  // remove when KineticEnergy use WF.G/L instead of P.G/L
846  G = P.G;
847  L = P.L;
848  log_real_ = std::real(logpsi);
849  PhaseValue = std::imag(logpsi);
850  return logpsi;
851 }
QMCTraits::RealType real
WaveFunctionComponent::LogValue LogValue
ParticleSet::ParticleLaplacian L
differential laplacians
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ParticleSet::ParticleGradient G
differential gradients
RealType PhaseValue
sign of the trial wave function
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
RealType log_real_
real part of trial wave function log
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateGradDerivatives()

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

Definition at line 1175 of file TrialWaveFunction.cpp.

References TrialWaveFunction::Z.

1177 {
1178  for (int i = 0; i < Z.size(); i++)
1179  Z[i]->evaluateGradDerivatives(G_in, dgradlogpsi);
1180 }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
void evaluateGradDerivatives(const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)

◆ evaluateHessian()

void evaluateHessian ( ParticleSet P,
HessVector all_grad_grad_psi 
)

evaluate the hessian w.r.t.

electronic coordinates of particle iat evaluate the hessian hessian w.r.t. electronic coordinates of particle iat

Definition at line 434 of file TrialWaveFunction.cpp.

References ParticleSet::getTotalNum(), and TrialWaveFunction::Z.

Referenced by L2Potential::evaluate(), and StressPBC::evaluateKineticSymTensor().

435 {
436  grad_grad_psi.resize(P.getTotalNum());
437 
438  for (int i = 0; i < Z.size(); i++)
439  {
440  HessVector tmp_hess(grad_grad_psi);
441  tmp_hess = 0.0;
442  Z[i]->evaluateHessian(P, tmp_hess);
443  grad_grad_psi += tmp_hess;
444  // app_log()<<"TrialWavefunction::tmp_hess = "<<tmp_hess<< std::endl;
445  // app_log()<< std::endl<< std::endl;
446  }
447  // app_log()<<" TrialWavefunction::Hessian = "<<grad_grad_psi<< std::endl;
448 }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
WaveFunctionComponent::HessVector HessVector

◆ evaluateLog()

evalaute the log (internally gradients and laplacian) of the trial wavefunction.

return log(|psi|)

gold reference

PhaseValue is the phase for the complex wave function

Definition at line 123 of file TrialWaveFunction.cpp.

References ParticleSet::G, TrialWaveFunction::G, qmcplusplus::imag(), ParticleSet::L, TrialWaveFunction::L, TrialWaveFunction::log_real_, TrialWaveFunction::PhaseValue, qmcplusplus::RECOMPUTE_TIMER, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SOVMCUpdateAll::advanceWalker(), DMCUpdateAllWithRejection::advanceWalker(), VMCUpdateAll::advanceWalker(), DMCUpdateAllWithKill::advanceWalker(), RMCUpdateAllWithDrift::advanceWalkersRMC(), RMCUpdateAllWithDrift::advanceWalkersVMC(), WaveFunctionTester::checkGradientAtConfiguration(), WaveFunctionTester::computeNumericalGrad(), TrialWaveFunction::evaluateDeltaLog(), QMCHamiltonian::evaluateElecGrad(), BareKineticEnergy::evaluateWithIonDerivs(), QMCMain::executeCMCSection(), RMCUpdateAllWithDrift::initWalkers(), QMCUpdateBase::initWalkers(), RMCUpdatePbyPWithDrift::initWalkersForPbyP(), QMCUpdateBase::initWalkersForPbyP(), WaveFunctionTester::printEloc(), WaveFunctionTester::runBasicTest(), WaveFunctionTester::runCloneTest(), WaveFunctionTester::runDerivCloneTest(), WaveFunctionTester::runDerivNLPPTest(), WaveFunctionTester::runDerivTest(), WaveFunctionTester::runGradSourceTest(), WaveFunctionTester::runRatioTest(), WaveFunctionTester::runRatioTest2(), WaveFunctionTester::runZeroVarianceTest(), qmcplusplus::TEST_CASE(), qmcplusplus::test_hcpBe_rotation(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

124 {
126  P.G = 0.0;
127  P.L = 0.0;
128  LogValue logpsi(0.0);
129  for (int i = 0; i < Z.size(); ++i)
130  {
132 #ifndef NDEBUG
133  // Best way I've found yet to quickly see if WFC made it over the wire successfully
134  auto subterm = Z[i]->evaluateLog(P, P.G, P.L);
135  // std::cerr << "evaluate log Z element:" << i << " value: " << subterm << '\n';
136  logpsi += subterm;
137 #else
138  logpsi += Z[i]->evaluateLog(P, P.G, P.L);
139 #endif
140  }
141 
142  G = P.G;
143  L = P.L;
144 
145  log_real_ = std::real(logpsi);
146  PhaseValue = std::imag(logpsi);
147  return log_real_;
148 }
QMCTraits::RealType real
WaveFunctionComponent::LogValue LogValue
ParticleSet::ParticleLaplacian L
differential laplacians
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ParticleSet::ParticleGradient G
differential gradients
RealType PhaseValue
sign of the trial wave function
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
RealType log_real_
real part of trial wave function log
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateRatios()

void evaluateRatios ( const VirtualParticleSet VP,
std::vector< ValueType > &  ratios,
ComputeType  ct = ComputeType::ALL 
)

compulte multiple ratios to handle non-local moves and other virtual moves

Definition at line 1029 of file TrialWaveFunction.cpp.

References TrialWaveFunction::ALL, TrialWaveFunction::FERMIONIC, VirtualParticleSet::getTotalNum(), qmcplusplus::NL_TIMER, TrialWaveFunction::NONFERMIONIC, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SOECPComponent::evaluateOne(), NonLocalECPComponent::evaluateOne(), NonLocalECPComponent::evaluateOneWithForces(), MagnetizationDensity::generateSpinIntegrand(), and WaveFunctionTester::runRatioV().

1030 {
1031  ScopedTimer local_timer(TWF_timers_[NL_TIMER]);
1032  assert(VP.getTotalNum() == ratios.size());
1033  std::vector<ValueType> t(ratios.size());
1034  std::fill(ratios.begin(), ratios.end(), 1.0);
1035  for (int i = 0; i < Z.size(); ++i)
1036  if (ct == ComputeType::ALL || (Z[i]->isFermionic() && ct == ComputeType::FERMIONIC) ||
1037  (!Z[i]->isFermionic() && ct == ComputeType::NONFERMIONIC))
1038  {
1039  ScopedTimer z_timer(WFC_timers_[NL_TIMER + TIMER_SKIP * i]);
1040  Z[i]->evaluateRatios(VP, t);
1041  for (int j = 0; j < ratios.size(); ++j)
1042  ratios[j] *= t[j];
1043  }
1044 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateRatiosAlltoOne()

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

Definition at line 1190 of file TrialWaveFunction.cpp.

References qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, qmcplusplus::V_TIMER, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by MomentumDistribution::accumulate(), MomentumEstimator::evaluate(), DensityMatrices1B::generate_sample_ratios(), and OneBodyDensityMatrices::generateSampleRatios().

1191 {
1192  ScopedTimer local_timer(TWF_timers_[V_TIMER]);
1193  std::fill(ratios.begin(), ratios.end(), 1.0);
1194  std::vector<ValueType> t(ratios.size());
1195  for (int i = 0; i < Z.size(); ++i)
1196  {
1197  ScopedTimer local_timer(WFC_timers_[V_TIMER + TIMER_SKIP * i]);
1198  Z[i]->evaluateRatiosAlltoOne(P, t);
1199  for (int j = 0; j < t.size(); ++j)
1200  ratios[j] *= t[j];
1201  }
1202 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ evaluateSpinorRatios()

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

Used by SOECPComponent to do faster SOC evaluation.

Definition at line 1046 of file TrialWaveFunction.cpp.

References VirtualParticleSet::getTotalNum(), qmcplusplus::NL_TIMER, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SOECPComponent::evaluateOneExactSpinIntegration().

1047 {
1048  ScopedTimer local_timer(TWF_timers_[NL_TIMER]);
1049  assert(VP.getTotalNum() == ratios.size());
1050  std::vector<ValueType> t(ratios.size());
1051  std::fill(ratios.begin(), ratios.end(), 1.0);
1052  for (int i = 0; i < Z.size(); ++i)
1053  {
1054  ScopedTimer z_timer(WFC_timers_[NL_TIMER + TIMER_SKIP * i]);
1055  Z[i]->evaluateSpinorRatios(VP, spinor_multiplier, t);
1056  for (int j = 0; j < ratios.size(); ++j)
1057  ratios[j] *= t[j];
1058  }
1059 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ extractGRefList()

RefVector< ParticleSet::ParticleGradient > extractGRefList ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list)
staticprivate

}@

Definition at line 1256 of file TrialWaveFunction.cpp.

Referenced by TrialWaveFunction::mw_evaluateDeltaLog(), TrialWaveFunction::mw_evaluateDeltaLogSetup(), TrialWaveFunction::mw_evaluateGL(), and TrialWaveFunction::mw_evaluateLog().

1258 {
1259  RefVector<ParticleSet::ParticleGradient> g_list;
1260  for (TrialWaveFunction& wf : wf_list)
1261  g_list.push_back(wf.G);
1262  return g_list;
1263 }
TrialWaveFunction(const RuntimeOptions &runtime_options, const std::string_view aname="psi0", bool tasking=false)

◆ extractLRefList()

RefVector< ParticleSet::ParticleLaplacian > extractLRefList ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list)
staticprivate

Definition at line 1265 of file TrialWaveFunction.cpp.

Referenced by TrialWaveFunction::mw_evaluateDeltaLog(), TrialWaveFunction::mw_evaluateDeltaLogSetup(), TrialWaveFunction::mw_evaluateGL(), and TrialWaveFunction::mw_evaluateLog().

1267 {
1268  RefVector<ParticleSet::ParticleLaplacian> l_list;
1269  for (TrialWaveFunction& wf : wf_list)
1270  l_list.push_back(wf.L);
1271  return l_list;
1272 }
TrialWaveFunction(const RuntimeOptions &runtime_options, const std::string_view aname="psi0", bool tasking=false)

◆ extractOptimizableObjectRefs()

UniqueOptObjRefs extractOptimizableObjectRefs ( )

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Definition at line 904 of file TrialWaveFunction.cpp.

References TrialWaveFunction::Z.

Referenced by TrialWaveFunction::checkInVariables(), QMCCostFunctionBase::extractOptimizableObjects(), QMCCostFunctionBase::reportParameters(), TrialWaveFunction::reportStatus(), TrialWaveFunction::resetParameters(), and qmcplusplus::TEST_CASE().

905 {
906  UniqueOptObjRefs opt_obj_refs;
907  for (int i = 0; i < Z.size(); i++)
908  Z[i]->extractOptimizableObjectRefs(opt_obj_refs);
909  return opt_obj_refs;
910 }
UniqueOptObjRefs extractOptimizableObjectRefs()
extract underlying OptimizableObject references
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions

◆ extractWFCPtrList()

std::vector< WaveFunctionComponent * > extractWFCPtrList ( const UPtrVector< TrialWaveFunction > &  wf_list,
int  id 
)
staticprivate

helper function for extracting a list of WaveFunctionComponent from a list of TrialWaveFunction

Definition at line 1247 of file TrialWaveFunction.cpp.

1248 {
1249  std::vector<WaveFunctionComponent*> WFC_list;
1250  WFC_list.reserve(g.size());
1251  for (auto& WF : g)
1252  WFC_list.push_back(WF->Z[id].get());
1253  return WFC_list;
1254 }

◆ extractWFCRefList()

RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
int  id 
)
staticprivate

Definition at line 1236 of file TrialWaveFunction.cpp.

References RefVectorWithLeader< T >::getLeader().

Referenced by TrialWaveFunction::acquireResource(), TrialWaveFunction::mw_accept_rejectMove(), TrialWaveFunction::mw_calcRatio(), TrialWaveFunction::mw_calcRatioGrad(), TrialWaveFunction::mw_completeUpdates(), TrialWaveFunction::mw_evalGrad(), TrialWaveFunction::mw_evaluateDeltaLog(), TrialWaveFunction::mw_evaluateDeltaLogSetup(), TrialWaveFunction::mw_evaluateGL(), TrialWaveFunction::mw_evaluateLog(), TrialWaveFunction::mw_evaluateRatios(), TrialWaveFunction::mw_prepareGroup(), TrialWaveFunction::mw_recompute(), and TrialWaveFunction::releaseResource().

1239 {
1240  RefVectorWithLeader<WaveFunctionComponent> wfc_list(*wf_list.getLeader().Z[id]);
1241  wfc_list.reserve(wf_list.size());
1242  for (TrialWaveFunction& wf : wf_list)
1243  wfc_list.push_back(*wf.Z[id]);
1244  return wfc_list;
1245 }
TrialWaveFunction(const RuntimeOptions &runtime_options, const std::string_view aname="psi0", bool tasking=false)

◆ findMSD()

RefVector< MultiSlaterDetTableMethod > findMSD ( ) const

find MSD WFCs if exist

Definition at line 110 of file TrialWaveFunction.cpp.

References TrialWaveFunction::Z.

Referenced by SelfHealingOverlap::accumulate(), SelfHealingOverlapLegacy::evaluate(), SelfHealingOverlap::SelfHealingOverlap(), SelfHealingOverlapLegacy::SelfHealingOverlapLegacy(), and qmcplusplus::TEST_CASE().

111 {
112  RefVector<MultiSlaterDetTableMethod> refs;
113  for (auto& component : Z)
114  if (auto* comp_ptr = dynamic_cast<MultiSlaterDetTableMethod*>(component.get()); comp_ptr)
115  refs.push_back(*comp_ptr);
116  return refs;
117 }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions

◆ getLogPsi()

◆ getLogs()

void getLogs ( std::vector< RealType > &  lvals)

Definition at line 940 of file TrialWaveFunction.cpp.

References TrialWaveFunction::Z.

Referenced by QMCUpdateBase::getLogs().

941 {
942  lvals.resize(Z.size(), 0);
943  for (int i = 0; i < Z.size(); i++)
944  {
945  lvals[i] = std::real(Z[i]->get_log_value());
946  }
947 }
QMCTraits::RealType real
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions

◆ getName()

const std::string& getName ( ) const
inline

Definition at line 496 of file TrialWaveFunction.h.

References TrialWaveFunction::myName.

Referenced by QMCCostFunctionBase::put().

496 { return myName; }
const std::string myName
getName is in the way

◆ getNode()

xmlNodePtr getNode ( ) const
inline

Definition at line 502 of file TrialWaveFunction.h.

References TrialWaveFunction::myNode_.

502 { return myNode_; }
xmlNodePtr myNode_
XML input node for a many-body wavefunction.

◆ getOrbitals()

std::vector<std::unique_ptr<WaveFunctionComponent> > const& getOrbitals ( )
inline

Definition at line 477 of file TrialWaveFunction.h.

References TrialWaveFunction::Z.

Referenced by SelfHealingOverlap::accumulate(), WaveFunctionTester::checkGradientAtConfiguration(), SelfHealingOverlapLegacy::evaluate(), qmcplusplus::TEST_CASE(), and qmcplusplus::test_hcpBe_rotation().

477 { return Z; }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions

◆ getPhase()

◆ getPhaseDiff()

◆ getPhases()

void getPhases ( std::vector< RealType > &  pvals)

Definition at line 949 of file TrialWaveFunction.cpp.

References qmcplusplus::imag(), and TrialWaveFunction::Z.

950 {
951  pvals.resize(Z.size(), 0);
952  for (int i = 0; i < Z.size(); i++)
953  {
954  pvals[i] = std::imag(Z[i]->get_log_value());
955  }
956 }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...

◆ getReciprocalMass()

RealType getReciprocalMass ( )
inline

Definition at line 494 of file TrialWaveFunction.h.

References TrialWaveFunction::OneOverM.

494 { return OneOverM; }
RealType OneOverM
One over mass of target particleset, needed for Local Energy Derivatives.

◆ getSPOMap()

const SPOMap& getSPOMap ( ) const
inline

spomap_ reference accessor

Definition at line 511 of file TrialWaveFunction.h.

References TrialWaveFunction::spomap_.

Referenced by HamiltonianFactory::build(), and DensityMatrices1B::set_state().

511 { return *spomap_; }
const std::shared_ptr< SPOMap > spomap_
Owned SPOSets. Once a TWF is fully built, SPOSet lookup should be done via TWF.

◆ getSPOSet()

const SPOSet & getSPOSet ( const std::string &  name) const

look up SPOSet named 'name', if not found, throw exception.

Definition at line 102 of file TrialWaveFunction.cpp.

References TrialWaveFunction::spomap_.

103 {
104  auto spoit = spomap_->find(name);
105  if (spoit == spomap_->end())
106  throw std::runtime_error("SPOSet " + name + " cannot be found!");
107  return *spoit->second;
108 }
const std::shared_ptr< SPOMap > spomap_
Owned SPOSets. Once a TWF is fully built, SPOSet lookup should be done via TWF.

◆ initializeTWFFastDerivWrapper()

void initializeTWFFastDerivWrapper ( const ParticleSet P,
TWFFastDerivWrapper twf 
) const

Initialize a TWF wrapper for fast derivative evaluation.

Definition at line 1274 of file TrialWaveFunction.cpp.

References qmcplusplus::twf, and TrialWaveFunction::Z.

Referenced by ACForce::ACForce(), and qmcplusplus::TEST_CASE().

1275 {
1276  for (int i = 0; i < Z.size(); ++i)
1277  {
1278  if (Z[i]->isFermionic())
1279  {
1280  //OK, so this is a hack only for SlaterDeterminant objects.
1281  //Needs a bit of logic and protection before this reaches production.
1282  //SlaterDet* det = dynamic_cast<SlaterDet*>(Z[i].get());
1283  //det->registerTWFFastDerivWrapper(P, twf);
1284  Z[i]->registerTWFFastDerivWrapper(P, twf);
1285  }
1286  else
1287  twf.addJastrow(Z[i].get());
1288  }
1289 }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions

◆ KECorrection()

TrialWaveFunction::RealType KECorrection ( ) const

Definition at line 1182 of file TrialWaveFunction.cpp.

References TrialWaveFunction::Z.

Referenced by ChiesaCorrection::evaluate().

1183 {
1184  RealType sum = 0.0;
1185  for (int i = 0; i < Z.size(); ++i)
1186  sum += Z[i]->KECorrection();
1187  return sum;
1188 }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
QMCTraits::RealType RealType

◆ makeClone()

std::unique_ptr< TrialWaveFunction > makeClone ( ParticleSet tqp) const

Definition at line 1113 of file TrialWaveFunction.cpp.

References TrialWaveFunction::BufferCursor, TrialWaveFunction::BufferCursor_scalar, TrialWaveFunction::myName, TrialWaveFunction::OneOverM, TrialWaveFunction::runtime_options_, TrialWaveFunction::use_tasking_, and TrialWaveFunction::Z.

Referenced by CostFunctionCrowdData::CostFunctionCrowdData(), MCPopulation::createWalkers(), qmcplusplus::doSOECPotentialTest(), CloneManager::makeClones(), WaveFunctionTester::runCloneTest(), WaveFunctionTester::runDerivCloneTest(), MCPopulation::spawnWalker(), qmcplusplus::TEST_CASE(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

1114 {
1115  auto myclone = std::make_unique<TrialWaveFunction>(runtime_options_, myName, use_tasking_);
1116  myclone->BufferCursor = BufferCursor;
1117  myclone->BufferCursor_scalar = BufferCursor_scalar;
1118  for (int i = 0; i < Z.size(); ++i)
1119  myclone->addComponent(Z[i]->makeClone(tqp));
1120  myclone->OneOverM = OneOverM;
1121  return myclone;
1122 }
size_t BufferCursor_scalar
starting index of the scalar buffer
const bool use_tasking_
if true, using internal tasking implementation
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
RealType OneOverM
One over mass of target particleset, needed for Local Energy Derivatives.
const RuntimeOptions & runtime_options_
top-level runtime options from project data information > WaveFunctionPool
size_t BufferCursor
starting index of the buffer
const std::string myName
getName is in the way

◆ mw_accept_rejectMove()

void mw_accept_rejectMove ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
const std::vector< bool > &  isAccepted,
bool  safe_to_delay = false 
)
static

Definition at line 774 of file TrialWaveFunction.cpp.

References qmcplusplus::ACCEPT_TIMER, TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::imag(), and qmcplusplus::TIMER_SKIP.

Referenced by TWFdispatcher::flex_accept_rejectMove(), qmcplusplus::TEST_CASE(), qmcplusplus::test_LiH_msd(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

779 {
780  auto& wf_leader = wf_list.getLeader();
781  ScopedTimer local_timer(wf_leader.TWF_timers_[ACCEPT_TIMER]);
782  const int num_wfc = wf_leader.Z.size();
783  auto& wavefunction_components = wf_leader.Z;
784 
785  for (int iw = 0; iw < wf_list.size(); iw++)
786  if (isAccepted[iw])
787  {
788  wf_list[iw].log_real_ = 0;
789  wf_list[iw].PhaseValue = 0;
790  }
791 
792  PRAGMA_OMP_TASKLOOP("omp taskloop default(shared) if (wf_leader.use_tasking_)")
793  for (int i = 0; i < num_wfc; i++)
794  {
795  ScopedTimer z_timer(wf_leader.WFC_timers_[ACCEPT_TIMER + TIMER_SKIP * i]);
796  const auto wfc_list(extractWFCRefList(wf_list, i));
797  wavefunction_components[i]->mw_accept_rejectMove(wfc_list, p_list, iat, isAccepted, safe_to_delay);
798  for (int iw = 0; iw < wf_list.size(); iw++)
799  if (isAccepted[iw])
800  {
801  wf_list[iw].log_real_ += std::real(wfc_list[iw].get_log_value());
802  wf_list[iw].PhaseValue += std::imag(wfc_list[iw].get_log_value());
803  }
804  }
805 }
QMCTraits::RealType real
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...

◆ mw_calcRatio()

void mw_calcRatio ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios,
ComputeType  ct = ComputeType::ALL 
)
static

batched version of calcRatio

Definition at line 466 of file TrialWaveFunction.cpp.

References TrialWaveFunction::ALL, NaNguard::checkOneParticleRatio(), TrialWaveFunction::extractWFCRefList(), TrialWaveFunction::FERMIONIC, RefVectorWithLeader< T >::getLeader(), TrialWaveFunction::NONFERMIONIC, qmcplusplus::TIMER_SKIP, and qmcplusplus::V_TIMER.

Referenced by TWFdispatcher::flex_calcRatio(), qmcplusplus::TEST_CASE(), qmcplusplus::test_LiH_msd(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

471 {
472  const int num_wf = wf_list.size();
473  ratios.resize(num_wf);
474  std::fill(ratios.begin(), ratios.end(), PsiValue(1));
475 
476  auto& wf_leader = wf_list.getLeader();
477  ScopedTimer local_timer(wf_leader.TWF_timers_[V_TIMER]);
478  const int num_wfc = wf_leader.Z.size();
479  auto& wavefunction_components = wf_leader.Z;
480 
481  std::vector<PsiValue> ratios_z(num_wf);
482  for (int i = 0; i < num_wfc; i++)
483  {
484  if (ct == ComputeType::ALL || (wavefunction_components[i]->isFermionic() && ct == ComputeType::FERMIONIC) ||
485  (!wavefunction_components[i]->isFermionic() && ct == ComputeType::NONFERMIONIC))
486  {
487  ScopedTimer z_timer(wf_leader.WFC_timers_[V_TIMER + TIMER_SKIP * i]);
488  const auto wfc_list(extractWFCRefList(wf_list, i));
489  wavefunction_components[i]->mw_calcRatio(wfc_list, p_list, iat, ratios_z);
490  for (int iw = 0; iw < wf_list.size(); iw++)
491  ratios[iw] *= ratios_z[iw];
492  }
493  }
494 
495  for (int iw = 0; iw < wf_list.size(); iw++)
496  {
497  NaNguard::checkOneParticleRatio(ratios[iw], "TWF::mw_calcRatio at particle " + std::to_string(iat));
498  wf_list[iw].PhaseDiff = std::arg(ratios[iw]);
499  }
500 }
WaveFunctionComponent::PsiValue PsiValue
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
static void checkOneParticleRatio(const PsiValue &ratio, const std::string_view info)
check if ratio is NaN and throw an error if yes.
Definition: NaNguard.cpp:18

◆ mw_calcRatioGrad()

void mw_calcRatioGrad ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios,
TWFGrads< CT > &  grads 
)
static

batched version of ratioGrad

all vector sizes must match implements switch between normal and WithSpin version

Definition at line 670 of file TrialWaveFunction.cpp.

References NaNguard::checkOneParticleGradients(), NaNguard::checkOneParticleRatio(), TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::TIMER_SKIP, and qmcplusplus::VGL_TIMER.

Referenced by TWFdispatcher::flex_calcRatioGrad(), qmcplusplus::TEST_CASE(), qmcplusplus::test_LiH_msd(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

675 {
676  const int num_wf = wf_list.size();
677  ratios.resize(num_wf);
678  std::fill(ratios.begin(), ratios.end(), PsiValue(1));
679  grad_new = TWFGrads<CT>(num_wf);
680 
681  auto& wf_leader = wf_list.getLeader();
682  ScopedTimer local_timer(wf_leader.TWF_timers_[VGL_TIMER]);
683  const int num_wfc = wf_leader.Z.size();
684  auto& wavefunction_components = wf_leader.Z;
685 
686  if (wf_leader.use_tasking_)
687  {
688  std::vector<std::vector<PsiValue>> ratios_components(num_wfc, std::vector<PsiValue>(wf_list.size()));
689  std::vector<TWFGrads<CT>> grads_components(num_wfc, TWFGrads<CT>(num_wf));
690  PRAGMA_OMP_TASKLOOP("omp taskloop default(shared)")
691  for (int i = 0; i < num_wfc; ++i)
692  {
693  ScopedTimer z_timer(wf_leader.WFC_timers_[VGL_TIMER + TIMER_SKIP * i]);
694  const auto wfc_list(extractWFCRefList(wf_list, i));
695  wavefunction_components[i]->mw_ratioGrad(wfc_list, p_list, iat, ratios_components[i], grads_components[i]);
696  }
697 
698  for (int i = 0; i < num_wfc; ++i)
699  {
700  grad_new += grads_components[i];
701  for (int iw = 0; iw < wf_list.size(); iw++)
702  ratios[iw] *= ratios_components[i][iw];
703  }
704  }
705  else
706  {
707  std::vector<PsiValue> ratios_z(wf_list.size());
708  for (int i = 0; i < num_wfc; ++i)
709  {
710  ScopedTimer z_timer(wf_leader.WFC_timers_[VGL_TIMER + TIMER_SKIP * i]);
711  const auto wfc_list(extractWFCRefList(wf_list, i));
712  wavefunction_components[i]->mw_ratioGrad(wfc_list, p_list, iat, ratios_z, grad_new);
713  for (int iw = 0; iw < wf_list.size(); iw++)
714  ratios[iw] *= ratios_z[iw];
715  }
716  }
717  for (int iw = 0; iw < wf_list.size(); iw++)
718  {
719  wf_list[iw].PhaseDiff = std::arg(ratios[iw]);
720  NaNguard::checkOneParticleRatio(ratios[iw], "TWF::mw_calcRatioGrad at particle " + std::to_string(iat));
721  if (ratios[iw] != PsiValue(0))
722  NaNguard::checkOneParticleGradients(grad_new.grads_positions[iw],
723  "TWF::mw_calcRatioGrad at particle " + std::to_string(iat));
724  }
725 }
WaveFunctionComponent::PsiValue PsiValue
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
static void checkOneParticleRatio(const PsiValue &ratio, const std::string_view info)
check if ratio is NaN and throw an error if yes.
Definition: NaNguard.cpp:18
static void checkOneParticleGradients(const GradType &grads, const std::string_view info)
check if any gradient component (x,y,z) is NaN and throw an error if yes.
Definition: NaNguard.cpp:29

◆ mw_completeUpdates()

void mw_completeUpdates ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list)
static

Definition at line 817 of file TrialWaveFunction.cpp.

References qmcplusplus::ACCEPT_TIMER, TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), and qmcplusplus::TIMER_SKIP.

Referenced by TWFdispatcher::flex_completeUpdates(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

818 {
819  auto& wf_leader = wf_list.getLeader();
820  ScopedTimer local_timer(wf_leader.TWF_timers_[ACCEPT_TIMER]);
821  const int num_wfc = wf_leader.Z.size();
822  auto& wavefunction_components = wf_leader.Z;
823 
824  for (int i = 0; i < num_wfc; i++)
825  {
826  ScopedTimer z_timer(wf_leader.WFC_timers_[ACCEPT_TIMER + TIMER_SKIP * i]);
827  const auto wfc_list(extractWFCRefList(wf_list, i));
828  wavefunction_components[i]->mw_completeUpdates(wfc_list);
829  }
830 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)

◆ mw_evalGrad()

void mw_evalGrad ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
TWFGrads< CT > &  grads 
)
static

batched version of evalGrad

This is static because it should have no direct access to any TWF. implements switch between normal and WithSpin version

Definition at line 553 of file TrialWaveFunction.cpp.

References NaNguard::checkOneParticleGradients(), TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::TIMER_SKIP, and qmcplusplus::VGL_TIMER.

Referenced by TWFdispatcher::flex_evalGrad(), qmcplusplus::TEST_CASE(), qmcplusplus::test_LiH_msd(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

557 {
558  const int num_wf = wf_list.size();
559  grads = TWFGrads<CT>(num_wf); //ensure elements are set to zero
560 
561  auto& wf_leader = wf_list.getLeader();
562  ScopedTimer local_timer(wf_leader.TWF_timers_[VGL_TIMER]);
563  // Right now mw_evalGrad can only be called through an concrete instance of a wavefunctioncomponent
564  const int num_wfc = wf_leader.Z.size();
565  auto& wavefunction_components = wf_leader.Z;
566 
567  TWFGrads<CT> grads_z(num_wf);
568  for (int i = 0; i < num_wfc; i++)
569  {
570  ScopedTimer localtimer(wf_leader.WFC_timers_[VGL_TIMER + TIMER_SKIP * i]);
571  const auto wfc_list(extractWFCRefList(wf_list, i));
572  wavefunction_components[i]->mw_evalGrad(wfc_list, p_list, iat, grads_z);
573  grads += grads_z;
574  }
575 
576  for (const GradType& grads : grads.grads_positions)
577  NaNguard::checkOneParticleGradients(grads, "TWF::mw_evalGrad at particle " + std::to_string(iat));
578 }
WaveFunctionComponent::GradType GradType
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
static void checkOneParticleGradients(const GradType &grads, const std::string_view info)
check if any gradient component (x,y,z) is NaN and throw an error if yes.
Definition: NaNguard.cpp:29

◆ mw_evaluateDeltaLog()

void mw_evaluateDeltaLog ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
std::vector< RealType > &  logpsi_list,
RefVector< ParticleSet::ParticleGradient > &  dummyG_list,
RefVector< ParticleSet::ParticleLaplacian > &  dummyL_list,
bool  recompute = false 
)
static

evaluate the log value for optimizable parts of a many-body wave function

Parameters
wf_listvector of wavefunctions
p_listvector of input particle configurations
logpsi_listvector of log(std::abs(psi)) of the variable orbitals
dummyG_listvector of gradients of log(psi) of the fixed wave functions.
dummyL_listvector of laplacians of log(psi) of the fixed wave functions

The dummyG_list and dummyL_list are only referenced if recompute is true. If recompute is false, the storage of these lists are needed, but the values can be discarded.

default value. call evaluateLog only on optimizable orbitals. OK if nonlocal pp's aren't used.

To save time, logpsi, G, and L are only computed for orbitals that change over the course of the optimization. It is assumed that the fixed components are stored elsewhere. See mw_evaluateDeltaLogSetup defined above. Nonlocal pseudopotential evaluation requires temporary information like matrix inverses, so while the logpsi, G, and L don't change, evaluateLog is called anyways to compute these auxiliary quantities from scratch. logpsi, G, and L associated with these non-optimizable orbitals are discarded explicitly and with dummy variables.

Definition at line 352 of file TrialWaveFunction.cpp.

References BLAS::czero, TrialWaveFunction::extractGRefList(), TrialWaveFunction::extractLRefList(), TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::pset, TrialWaveFunction::recompute(), qmcplusplus::RECOMPUTE_TIMER, qmcplusplus::TIMER_SKIP, and qmcplusplus::twf.

Referenced by QMCCostFunctionBatched::correlatedSampling(), and qmcplusplus::TEST_CASE().

358 {
359  auto& p_leader = p_list.getLeader();
360  auto& wf_leader = wf_list.getLeader();
361  ScopedTimer local_timer(wf_leader.TWF_timers_[RECOMPUTE_TIMER]);
362  constexpr RealType czero(0);
363  int num_particles = p_leader.getTotalNum();
364  const auto g_list(TrialWaveFunction::extractGRefList(wf_list));
365  const auto l_list(TrialWaveFunction::extractLRefList(wf_list));
366 
367  // Initialize various members of the wavefunction, grad, and laplacian
368  auto initGandL = [num_particles, czero](TrialWaveFunction& twf, ParticleSet::ParticleGradient& grad,
370  grad.resize(num_particles);
371  lapl.resize(num_particles);
372  grad = czero;
373  lapl = czero;
374  twf.log_real_ = czero;
375  twf.PhaseValue = czero;
376  };
377  for (int iw = 0; iw < wf_list.size(); iw++)
378  initGandL(wf_list[iw], g_list[iw], l_list[iw]);
379 
380  // Get wavefunction components (assumed the same for every WF in the list)
381  auto& wavefunction_components = wf_leader.Z;
382  const int num_wfc = wf_leader.Z.size();
383 
384  // Loop over the wavefunction components
385  for (int i = 0; i < num_wfc; ++i)
386  if (wavefunction_components[i]->isOptimizable())
387  {
388  ScopedTimer z_timer(wf_leader.WFC_timers_[RECOMPUTE_TIMER + TIMER_SKIP * i]);
389  const auto wfc_list(extractWFCRefList(wf_list, i));
390  wavefunction_components[i]->mw_evaluateLog(wfc_list, p_list, g_list, l_list);
391  for (int iw = 0; iw < wf_list.size(); iw++)
392  logpsi_list[iw] += std::real(wfc_list[iw].get_log_value());
393  }
394 
395  // Temporary workaround to have P.G/L always defined.
396  // remove when KineticEnergy use WF.G/L instead of P.G/L
397  auto copyToP = [](ParticleSet& pset, TrialWaveFunction& twf) {
398  pset.G = twf.G;
399  pset.L = twf.L;
400  };
401  for (int iw = 0; iw < wf_list.size(); iw++)
402  copyToP(p_list[iw], wf_list[iw]);
403 
404  // Recompute is usually used to prepare the wavefunction for NLPP derivatives.
405  // (e.g compute the matrix inverse for determinants)
406  // Call mw_evaluateLog for the wavefunction components that were skipped previously.
407  // Ignore logPsi, G and L.
408  if (recompute)
409  for (int i = 0; i < num_wfc; ++i)
410  if (!wavefunction_components[i]->isOptimizable())
411  {
412  ScopedTimer z_timer(wf_leader.WFC_timers_[RECOMPUTE_TIMER + TIMER_SKIP * i]);
413  const auto wfc_list(extractWFCRefList(wf_list, i));
414  wavefunction_components[i]->mw_evaluateLog(wfc_list, p_list, dummyG_list, dummyL_list);
415  }
416 }
QMCTraits::RealType real
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
TrialWaveFunction(const RuntimeOptions &runtime_options, const std::string_view aname="psi0", bool tasking=false)
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
static RefVector< ParticleSet::ParticleGradient > extractGRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list)
}@
void recompute(const ParticleSet &P)
recompute the value of the orbitals which require critical accuracy
QMCTraits::RealType RealType
static RefVector< ParticleSet::ParticleLaplacian > extractLRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list)
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95

◆ mw_evaluateDeltaLogSetup()

void mw_evaluateDeltaLogSetup ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
std::vector< RealType > &  logpsi_fixed_list,
std::vector< RealType > &  logpsi_opt_list,
RefVector< ParticleSet::ParticleGradient > &  fixedG_list,
RefVector< ParticleSet::ParticleLaplacian > &  fixedL_list 
)
static

evaluate the sum of log value of optimizable many-body wavefunctions

Parameters
wf_listvector of wavefunctions
p_listvector of input particle configurations
logpsi_fixed_listvector of log(std::abs(psi)) of the invariant orbitals
logpsi_opt_listvector of log(std::abs(psi)) of the variable orbitals
fixedG_listvector of gradients of log(psi) of the fixed wave functions
fixedL_listvector of laplacians of log(psi) of the fixed wave functions

For wavefunction optimization, it can speed evaluation to split the log value, the gradient, and the laplacian computed from wavefunction components with optimizable parameters from components that do not. This function computes the log value of both parts, and the gradient and laplacian of the fixed components. During correlated sampling steps only the components with optimizable parameters need to have the gradient and laplacian re-evaluated.

Parameters fixedG_list and fixedL_list save the terms coming from the components that do not have optimizable parameters. It is expected that mw_evaluateDeltaLog(P,false) is called later and the external object adds the varying G and L and the fixed terms.

Definition at line 294 of file TrialWaveFunction.cpp.

References BLAS::czero, TrialWaveFunction::extractGRefList(), TrialWaveFunction::extractLRefList(), TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::pset, qmcplusplus::RECOMPUTE_TIMER, qmcplusplus::TIMER_SKIP, and qmcplusplus::twf.

Referenced by QMCCostFunctionBatched::checkConfigurations(), and qmcplusplus::TEST_CASE().

300 {
301  auto& wf_leader = wf_list.getLeader();
302  auto& p_leader = p_list.getLeader();
303  ScopedTimer local_timer(wf_leader.TWF_timers_[RECOMPUTE_TIMER]);
304  constexpr RealType czero(0);
305  const int num_particles = p_leader.getTotalNum();
306  const auto g_list(TrialWaveFunction::extractGRefList(wf_list));
307  const auto l_list(TrialWaveFunction::extractLRefList(wf_list));
308 
309  auto initGandL = [num_particles, czero](TrialWaveFunction& twf, ParticleSet::ParticleGradient& grad,
311  grad.resize(num_particles);
312  lapl.resize(num_particles);
313  grad = czero;
314  lapl = czero;
315  twf.log_real_ = czero;
316  twf.PhaseValue = czero;
317  };
318  for (int iw = 0; iw < wf_list.size(); iw++)
319  initGandL(wf_list[iw], g_list[iw], l_list[iw]);
320  auto& wavefunction_components = wf_leader.Z;
321  const int num_wfc = wf_leader.Z.size();
322  for (int i = 0; i < num_wfc; ++i)
323  {
324  ScopedTimer z_timer(wf_leader.WFC_timers_[RECOMPUTE_TIMER + TIMER_SKIP * i]);
325  const auto wfc_list(extractWFCRefList(wf_list, i));
326  if (wavefunction_components[i]->isOptimizable())
327  {
328  wavefunction_components[i]->mw_evaluateLog(wfc_list, p_list, g_list, l_list);
329  for (int iw = 0; iw < wf_list.size(); iw++)
330  logpsi_opt_list[iw] += std::real(wfc_list[iw].get_log_value());
331  }
332  else
333  {
334  wavefunction_components[i]->mw_evaluateLog(wfc_list, p_list, fixedG_list, fixedL_list);
335  for (int iw = 0; iw < wf_list.size(); iw++)
336  logpsi_fixed_list[iw] += std::real(wfc_list[iw].get_log_value());
337  }
338  }
339 
340  // Temporary workaround to have P.G/L always defined.
341  // remove when KineticEnergy use WF.G/L instead of P.G/L
342  auto addAndCopyToP = [](ParticleSet& pset, TrialWaveFunction& twf, ParticleSet::ParticleGradient& grad,
344  pset.G = twf.G + grad;
345  pset.L = twf.L + lapl;
346  };
347  for (int iw = 0; iw < wf_list.size(); iw++)
348  addAndCopyToP(p_list[iw], wf_list[iw], fixedG_list[iw], fixedL_list[iw]);
349 }
QMCTraits::RealType real
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
TrialWaveFunction(const RuntimeOptions &runtime_options, const std::string_view aname="psi0", bool tasking=false)
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
static RefVector< ParticleSet::ParticleGradient > extractGRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list)
}@
QMCTraits::RealType RealType
static RefVector< ParticleSet::ParticleLaplacian > extractLRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list)
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95

◆ mw_evaluateGL()

void mw_evaluateGL ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
bool  fromscratch 
)
static

Definition at line 853 of file TrialWaveFunction.cpp.

References qmcplusplus::BUFFER_TIMER, BLAS::czero, TrialWaveFunction::extractGRefList(), TrialWaveFunction::extractLRefList(), TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::imag(), qmcplusplus::pset, qmcplusplus::TIMER_SKIP, and qmcplusplus::twf.

Referenced by TWFdispatcher::flex_evaluateGL(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

856 {
857  auto& p_leader = p_list.getLeader();
858  auto& wf_leader = wf_list.getLeader();
859  ScopedTimer local_timer(wf_leader.TWF_timers_[BUFFER_TIMER]);
860 
861  constexpr RealType czero(0);
862  const auto g_list(TrialWaveFunction::extractGRefList(wf_list));
863  const auto l_list(TrialWaveFunction::extractLRefList(wf_list));
864 
865  const int num_particles = p_leader.getTotalNum();
866  for (TrialWaveFunction& wfs : wf_list)
867  {
868  wfs.G.resize(num_particles);
869  wfs.L.resize(num_particles);
870  wfs.G = czero;
871  wfs.L = czero;
872  wfs.log_real_ = czero;
873  wfs.PhaseValue = czero;
874  }
875 
876  auto& wavefunction_components = wf_leader.Z;
877  const int num_wfc = wf_leader.Z.size();
878 
879  for (int i = 0; i < num_wfc; ++i)
880  {
881  ScopedTimer z_timer(wf_leader.WFC_timers_[BUFFER_TIMER + TIMER_SKIP * i]);
882  const auto wfc_list(extractWFCRefList(wf_list, i));
883  wavefunction_components[i]->mw_evaluateGL(wfc_list, p_list, g_list, l_list, fromscratch);
884  }
885 
886  for (int iw = 0; iw < wf_list.size(); iw++)
887  {
888  ParticleSet& pset = p_list[iw];
889  TrialWaveFunction& twf = wf_list[iw];
890 
891  for (int i = 0; i < num_wfc; ++i)
892  {
893  twf.log_real_ += std::real(twf.Z[i]->get_log_value());
894  twf.PhaseValue += std::imag(twf.Z[i]->get_log_value());
895  }
896 
897  // Ye: temporal workaround to have P.G/L always defined.
898  // remove when KineticEnergy use WF.G/L instead of P.G/L
899  pset.G = twf.G;
900  pset.L = twf.L;
901  }
902 }
QMCTraits::RealType real
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
TrialWaveFunction(const RuntimeOptions &runtime_options, const std::string_view aname="psi0", bool tasking=false)
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
static RefVector< ParticleSet::ParticleGradient > extractGRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list)
}@
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
QMCTraits::RealType RealType
static RefVector< ParticleSet::ParticleLaplacian > extractLRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list)

◆ mw_evaluateLog()

void mw_evaluateLog ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list 
)
static

batched version of evaluateLog.

gold reference

Definition at line 150 of file TrialWaveFunction.cpp.

References BLAS::czero, TrialWaveFunction::extractGRefList(), TrialWaveFunction::extractLRefList(), TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::imag(), qmcplusplus::pset, qmcplusplus::RECOMPUTE_TIMER, qmcplusplus::TIMER_SKIP, and qmcplusplus::twf.

Referenced by qmcplusplus::doSOECPotentialTest(), TWFdispatcher::flex_evaluateLog(), qmcplusplus::TEST_CASE(), qmcplusplus::test_LiH_msd(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

152 {
153  auto& wf_leader = wf_list.getLeader();
154  auto& p_leader = p_list.getLeader();
155  ScopedTimer local_timer(wf_leader.TWF_timers_[RECOMPUTE_TIMER]);
156 
157  constexpr RealType czero(0);
158  const auto g_list(TrialWaveFunction::extractGRefList(wf_list));
159  const auto l_list(TrialWaveFunction::extractLRefList(wf_list));
160 
161  // due to historic design issue, ParticleSet holds G and L instead of TrialWaveFunction.
162  // TrialWaveFunction now also holds G and L to move forward but they need to be copied to P.G and P.L
163  // to be compatible with legacy use pattern.
164  const int num_particles = p_leader.getTotalNum();
165  auto initGandL = [num_particles, czero](TrialWaveFunction& twf, ParticleSet::ParticleGradient& grad,
167  grad.resize(num_particles);
168  lapl.resize(num_particles);
169  grad = czero;
170  lapl = czero;
171  twf.log_real_ = czero;
172  twf.PhaseValue = czero;
173  };
174  for (int iw = 0; iw < wf_list.size(); iw++)
175  initGandL(wf_list[iw], g_list[iw], l_list[iw]);
176 
177  auto& wavefunction_components = wf_leader.Z;
178  const int num_wfc = wf_leader.Z.size();
179  for (int i = 0; i < num_wfc; ++i)
180  {
181  ScopedTimer z_timer(wf_leader.WFC_timers_[RECOMPUTE_TIMER + TIMER_SKIP * i]);
182  const auto wfc_list(extractWFCRefList(wf_list, i));
183  wavefunction_components[i]->mw_evaluateLog(wfc_list, p_list, g_list, l_list);
184  }
185 
186  for (int iw = 0; iw < wf_list.size(); iw++)
187  {
188  ParticleSet& pset = p_list[iw];
189  TrialWaveFunction& twf = wf_list[iw];
190 
191  for (int i = 0; i < num_wfc; ++i)
192  {
193  twf.log_real_ += std::real(twf.Z[i]->get_log_value());
194  twf.PhaseValue += std::imag(twf.Z[i]->get_log_value());
195  }
196 
197  // Ye: temporal workaround to have P.G/L always defined.
198  // remove when KineticEnergy use WF.G/L instead of P.G/L
199  pset.G = twf.G;
200  pset.L = twf.L;
201  }
202 }
QMCTraits::RealType real
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
TrialWaveFunction(const RuntimeOptions &runtime_options, const std::string_view aname="psi0", bool tasking=false)
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
static RefVector< ParticleSet::ParticleGradient > extractGRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list)
}@
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
QMCTraits::RealType RealType
static RefVector< ParticleSet::ParticleLaplacian > extractLRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list)
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95

◆ mw_evaluateParameterDerivatives()

void mw_evaluateParameterDerivatives ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const opt_variables_type optvars,
RecordArray< ValueType > &  dlogpsi,
RecordArray< ValueType > &  dhpsioverpsi 
)
static

Definition at line 1147 of file TrialWaveFunction.cpp.

References RecordArray< T >::getNumOfParams().

Referenced by BareKineticEnergy::mw_evaluateWithParameterDerivatives(), qmcplusplus::TEST_CASE(), and qmcplusplus::test_hcpBe_rotation().

1152 {
1153  const int nparam = dlogpsi.getNumOfParams();
1154  for (int iw = 0; iw < wf_list.size(); iw++)
1155  {
1156  Vector<ValueType> dlogpsi_record_view(dlogpsi[iw], nparam);
1157  Vector<ValueType> dhpsioverpsi_record_view(dhpsioverpsi[iw], nparam);
1158 
1159  wf_list[iw].evaluateDerivatives(p_list[iw], optvars, dlogpsi_record_view, dhpsioverpsi_record_view);
1160  }
1161 }

◆ mw_evaluateRatios()

void mw_evaluateRatios ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< const VirtualParticleSet > &  Vp_list,
const RefVector< std::vector< ValueType >> &  ratios_list,
ComputeType  ct = ComputeType::ALL 
)
static

batched version of evaluateRatios Note: unlike other mw_ static functions, *this is the batch leader instead of wf_list[0].

Definition at line 1061 of file TrialWaveFunction.cpp.

References TrialWaveFunction::ALL, TrialWaveFunction::extractWFCRefList(), TrialWaveFunction::FERMIONIC, RefVectorWithLeader< T >::getLeader(), qmcplusplus::NL_TIMER, TrialWaveFunction::NONFERMIONIC, and qmcplusplus::TIMER_SKIP.

Referenced by TWFdispatcher::flex_evaluateRatios(), SOECPComponent::mw_evaluateOne(), NonLocalECPComponent::mw_evaluateOne(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

1065 {
1066  auto& wf_leader = wf_list.getLeader();
1067  ScopedTimer local_timer(wf_leader.TWF_timers_[NL_TIMER]);
1068  auto& wavefunction_components = wf_leader.Z;
1069  std::vector<std::vector<ValueType>> t(ratios_list.size());
1070  for (int iw = 0; iw < wf_list.size(); iw++)
1071  {
1072  std::vector<ValueType>& ratios = ratios_list[iw];
1073  assert(vp_list[iw].getTotalNum() == ratios.size());
1074  std::fill(ratios.begin(), ratios.end(), 1.0);
1075  t[iw].resize(ratios.size());
1076  }
1077 
1078  for (int i = 0; i < wavefunction_components.size(); i++)
1079  if (ct == ComputeType::ALL || (wavefunction_components[i]->isFermionic() && ct == ComputeType::FERMIONIC) ||
1080  (!wavefunction_components[i]->isFermionic() && ct == ComputeType::NONFERMIONIC))
1081  {
1082  ScopedTimer z_timer(wf_leader.WFC_timers_[NL_TIMER + TIMER_SKIP * i]);
1083  const auto wfc_list(extractWFCRefList(wf_list, i));
1084  wavefunction_components[i]->mw_evaluateRatios(wfc_list, vp_list, t);
1085  for (int iw = 0; iw < wf_list.size(); iw++)
1086  {
1087  std::vector<ValueType>& ratios = ratios_list[iw];
1088  for (int j = 0; j < ratios.size(); ++j)
1089  ratios[j] *= t[iw][j];
1090  }
1091  }
1092 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)

◆ mw_prepareGroup()

void mw_prepareGroup ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  ig 
)
static

batched version of prepareGroup

all vector sizes must match

Definition at line 508 of file TrialWaveFunction.cpp.

References TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), qmcplusplus::PREPAREGROUP_TIMER, and qmcplusplus::TIMER_SKIP.

Referenced by TWFdispatcher::flex_prepareGroup(), SOECPotential::mw_evaluateImpl(), NonLocalECPotential::mw_evaluateImpl(), and qmcplusplus::test_LiH_msd().

511 {
512  auto& wf_leader = wf_list.getLeader();
513  ScopedTimer local_timer(wf_leader.TWF_timers_[PREPAREGROUP_TIMER]);
514  const int num_wfc = wf_leader.Z.size();
515  auto& wavefunction_components = wf_leader.Z;
516 
517  for (int i = 0; i < num_wfc; i++)
518  {
519  ScopedTimer z_timer(wf_leader.WFC_timers_[PREPAREGROUP_TIMER + TIMER_SKIP * i]);
520  const auto wfc_list(extractWFCRefList(wf_list, i));
521  wavefunction_components[i]->mw_prepareGroup(wfc_list, p_list, ig);
522  }
523 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)

◆ mw_recompute()

void mw_recompute ( const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const std::vector< bool > &  recompute 
)
static

batched version of recompute

Definition at line 214 of file TrialWaveFunction.cpp.

References TrialWaveFunction::extractWFCRefList(), RefVectorWithLeader< T >::getLeader(), TrialWaveFunction::recompute(), qmcplusplus::RECOMPUTE_TIMER, and qmcplusplus::TIMER_SKIP.

Referenced by TWFdispatcher::flex_recompute().

217 {
218  auto& wf_leader = wf_list.getLeader();
219  auto& p_leader = p_list.getLeader();
220  ScopedTimer local_timer(wf_leader.TWF_timers_[RECOMPUTE_TIMER]);
221 
222  auto& wavefunction_components = wf_leader.Z;
223  const int num_wfc = wf_leader.Z.size();
224  for (int i = 0; i < num_wfc; ++i)
225  {
226  ScopedTimer z_timer(wf_leader.WFC_timers_[RECOMPUTE_TIMER + TIMER_SKIP * i]);
227  const auto wfc_list(extractWFCRefList(wf_list, i));
228  wavefunction_components[i]->mw_recompute(wfc_list, p_list, recompute);
229  }
230 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)
void recompute(const ParticleSet &P)
recompute the value of the orbitals which require critical accuracy

◆ operator=()

TrialWaveFunction& operator= ( const TrialWaveFunction )
delete

◆ prepareGroup()

void prepareGroup ( ParticleSet P,
int  ig 
)

Prepare internal data for updating WFC correspond to a particle group Particle groups usually correspond to determinants of different spins.

This call can be used to handle precomputation for PbyP moves.

Parameters
Pquantum particle set
igparticle group index

Definition at line 502 of file TrialWaveFunction.cpp.

References TrialWaveFunction::Z.

Referenced by SODMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPWithRejectionFast::advanceWalker(), VMCUpdatePbyP::advanceWalker(), SOVMCUpdatePbyP::advanceWalker(), NonLocalECPotential::evalIonDerivsImpl(), NonLocalECPotential::evaluateImpl(), and NonLocalECPotential::makeNonLocalMovesPbyP().

503 {
504  for (int i = 0; i < Z.size(); ++i)
505  Z[i]->prepareGroup(P, ig);
506 }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
void prepareGroup(ParticleSet &P, int ig)
Prepare internal data for updating WFC correspond to a particle group Particle groups usually corresp...

◆ printGL()

void printGL ( ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L,
std::string  tag = "GL" 
)

Definition at line 727 of file TrialWaveFunction.cpp.

References TrialWaveFunction::G, and TrialWaveFunction::L.

728 {
729  std::ostringstream o;
730  o << "--- reporting " << tag << std::endl << " ---" << std::endl;
731  for (int iat = 0; iat < L.size(); iat++)
732  o << "index: " << std::fixed << iat << std::scientific << " G: " << G[iat][0] << " " << G[iat][1] << " "
733  << G[iat][2] << " L: " << L[iat] << std::endl;
734  o << "--- end ---" << std::endl;
735  std::cout << o.str();
736 }
ParticleSet::ParticleLaplacian L
differential laplacians
ParticleSet::ParticleGradient G
differential gradients

◆ put()

bool put ( xmlNodePtr  cur)

read from xmlNode

Definition at line 1111 of file TrialWaveFunction.cpp.

Referenced by HamiltonianFactory::addForceHam().

1111 { return true; }

◆ recompute()

void recompute ( const ParticleSet P)

recompute the value of the orbitals which require critical accuracy

Definition at line 204 of file TrialWaveFunction.cpp.

References qmcplusplus::RECOMPUTE_TIMER, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by TrialWaveFunction::mw_evaluateDeltaLog(), and TrialWaveFunction::mw_recompute().

205 {
207  for (int i = 0; i < Z.size(); ++i)
208  {
210  Z[i]->recompute(P);
211  }
212 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ registerData()

void registerData ( ParticleSet P,
WFBufferType buf 
)

register all the wavefunction components in buffer.

See WaveFunctionComponent::registerData for more detail

Definition at line 958 of file TrialWaveFunction.cpp.

References PooledMemory< T_scalar, Alloc >::add(), qmcplusplus::BUFFER_TIMER, TrialWaveFunction::BufferCursor, TrialWaveFunction::BufferCursor_scalar, PooledMemory< T_scalar, Alloc >::current(), PooledMemory< T_scalar, Alloc >::current_scalar(), TrialWaveFunction::log_real_, TrialWaveFunction::PhaseValue, qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by RMCUpdatePbyPWithDrift::initWalkersForPbyP(), QMCUpdateBase::initWalkersForPbyP(), WaveFunctionTester::runCloneTest(), WaveFunctionTester::runRatioTest(), WaveFunctionTester::runRatioTest2(), WaveFunctionTester::runRatioV(), and qmcplusplus::TEST_CASE().

959 {
960  ScopedTimer local_timer(TWF_timers_[BUFFER_TIMER]);
961  //save the current position
962  BufferCursor = buf.current();
963  BufferCursor_scalar = buf.current_scalar();
964  for (int i = 0; i < Z.size(); ++i)
965  {
967  Z[i]->registerData(P, buf);
968  }
969  buf.add(PhaseValue);
970  buf.add(log_real_);
971 }
size_t BufferCursor_scalar
starting index of the scalar buffer
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
RealType PhaseValue
sign of the trial wave function
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
RealType log_real_
real part of trial wave function log
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
size_t BufferCursor
starting index of the buffer
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ rejectMove()

void rejectMove ( int  iat)

restore to the original state

Parameters
iatindex of the particle with a trial move

The proposed move of the iath particle is rejected. All the temporary data should be restored to the state prior to the move.

Definition at line 744 of file TrialWaveFunction.cpp.

References TrialWaveFunction::PhaseDiff, and TrialWaveFunction::Z.

Referenced by SODMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPWithRejectionFast::advanceWalker(), SOVMCUpdatePbyP::advanceWalker(), VMCUpdatePbyP::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), RMCUpdatePbyPWithDrift::advanceWalkersRMC(), RMCUpdatePbyPWithDrift::advanceWalkersVMC(), WaveFunctionTester::runBasicTest(), WaveFunctionTester::runNodePlot(), WaveFunctionTester::runRatioTest(), and WaveFunctionTester::runRatioTest2().

745 {
746  for (int i = 0; i < Z.size(); i++)
747  Z[i]->restore(iat);
748  PhaseDiff = 0;
749 }
RealType PhaseDiff
diff of the phase of the trial wave function during ratio calls
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list 
)
static

release external resource Note: use RAII ResourceCollectionLock whenever possible

Definition at line 1223 of file TrialWaveFunction.cpp.

References TrialWaveFunction::extractWFCRefList(), and RefVectorWithLeader< T >::getLeader().

1225 {
1226  auto& wf_leader = wf_list.getLeader();
1227  auto& wavefunction_components = wf_leader.Z;
1228  const int num_wfc = wf_leader.Z.size();
1229  for (int i = 0; i < num_wfc; ++i)
1230  {
1231  const auto wfc_list(extractWFCRefList(wf_list, i));
1232  wavefunction_components[i]->releaseResource(collection, wfc_list);
1233  }
1234 }
static RefVectorWithLeader< WaveFunctionComponent > extractWFCRefList(const RefVectorWithLeader< TrialWaveFunction > &wf_list, int id)

◆ reportStatus()

void reportStatus ( std::ostream &  os)

print out state of the trial wavefunction

Definition at line 933 of file TrialWaveFunction.cpp.

References TrialWaveFunction::extractOptimizableObjectRefs().

934 {
935  auto opt_obj_refs = extractOptimizableObjectRefs();
936  for (OptimizableObject& obj : opt_obj_refs)
937  obj.reportStatus(os);
938 }
UniqueOptObjRefs extractOptimizableObjectRefs()
extract underlying OptimizableObject references

◆ resetParameters()

void resetParameters ( const opt_variables_type active)

Set values of parameters in each component from the global list.

Definition at line 926 of file TrialWaveFunction.cpp.

References TrialWaveFunction::extractOptimizableObjectRefs().

Referenced by WaveFunctionTester::runDerivCloneTest(), WaveFunctionTester::runDerivNLPPTest(), WaveFunctionTester::runDerivTest(), qmcplusplus::TEST_CASE(), and qmcplusplus::test_hcpBe_rotation().

927 {
928  auto opt_obj_refs = extractOptimizableObjectRefs();
929  for (OptimizableObject& obj : opt_obj_refs)
930  obj.resetParametersExclusive(active);
931 }
UniqueOptObjRefs extractOptimizableObjectRefs()
extract underlying OptimizableObject references

◆ resetPhaseDiff()

◆ setLogPsi()

void setLogPsi ( RealType  LogPsi_new)
inline

Definition at line 115 of file TrialWaveFunction.h.

References TrialWaveFunction::log_real_.

Referenced by qmcplusplus::TEST_CASE().

115 { log_real_ = LogPsi_new; }
RealType log_real_
real part of trial wave function log

◆ setMassTerm()

void setMassTerm ( ParticleSet P)
inline

Definition at line 485 of file TrialWaveFunction.h.

References ParticleSet::Mass, and TrialWaveFunction::OneOverM.

486  {
487  OneOverM = 1.0 / P.Mass[0];
488  //SpeciesSet tspecies(P.getSpeciesSet());
489  //int massind=tspecies.addAttribute("mass");
490  //RealType mass = tspecies(massind,0);
491  //OneOverM = 1.0/mass;
492  }
RealType OneOverM
One over mass of target particleset, needed for Local Energy Derivatives.

◆ setPhase()

void setPhase ( RealType  PhaseValue_new)
inline

Definition at line 108 of file TrialWaveFunction.h.

References TrialWaveFunction::PhaseValue.

108 { PhaseValue = PhaseValue_new; }
RealType PhaseValue
sign of the trial wave function

◆ setTwist() [1/2]

void setTwist ( const std::vector< RealType > &  t)
inline

Definition at line 481 of file TrialWaveFunction.h.

References TrialWaveFunction::myTwist.

481 { myTwist = t; }
std::vector< RealType > myTwist

◆ setTwist() [2/2]

void setTwist ( std::vector< RealType > &&  t)
inline

Definition at line 482 of file TrialWaveFunction.h.

References TrialWaveFunction::myTwist.

482 { myTwist = std::move(t); }
std::vector< RealType > myTwist

◆ size()

int size ( void  ) const
inline

Definition at line 105 of file TrialWaveFunction.h.

References TrialWaveFunction::Z.

105 { return Z.size(); }
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions

◆ storeSPOMap()

void storeSPOMap ( SPOMap &&  spomap)
inline

store an SPOSet map

Definition at line 505 of file TrialWaveFunction.h.

References qmcplusplus::spomap, and TrialWaveFunction::spomap_.

505 { *spomap_ = std::move(spomap); }
const std::shared_ptr< SPOMap > spomap_
Owned SPOSets. Once a TWF is fully built, SPOSet lookup should be done via TWF.

◆ storeXMLNode()

void storeXMLNode ( xmlNodePtr  node)
inline

Definition at line 500 of file TrialWaveFunction.h.

References TrialWaveFunction::myNode_, and qmcplusplus::node.

500 { myNode_ = xmlCopyNode(node, 1); }
if(!okay) throw std xmlNodePtr node
xmlNodePtr myNode_
XML input node for a many-body wavefunction.

◆ twist()

const std::vector<RealType>& twist ( ) const
inline

Definition at line 483 of file TrialWaveFunction.h.

References TrialWaveFunction::myTwist.

483 { return myTwist; }
std::vector< RealType > myTwist

◆ updateBuffer()

TrialWaveFunction::RealType updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)

update all the wavefunction components in buffer.

See WaveFunctionComponent::updateBuffer for more detail

Definition at line 988 of file TrialWaveFunction.cpp.

References qmcplusplus::BUFFER_TIMER, TrialWaveFunction::BufferCursor, TrialWaveFunction::BufferCursor_scalar, TrialWaveFunction::debugOnlyCheckBuffer(), ParticleSet::G, TrialWaveFunction::G, qmcplusplus::imag(), ParticleSet::L, TrialWaveFunction::L, TrialWaveFunction::log_real_, TrialWaveFunction::PhaseValue, PooledMemory< T_scalar, Alloc >::put(), PooledMemory< T_scalar, Alloc >::rewind(), qmcplusplus::TIMER_SKIP, TrialWaveFunction::TWF_timers_, TrialWaveFunction::WFC_timers_, and TrialWaveFunction::Z.

Referenced by SODMCUpdatePbyPWithRejectionFast::advanceWalker(), SOVMCUpdatePbyP::advanceWalker(), VMCUpdatePbyP::advanceWalker(), DMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), RMCUpdatePbyPWithDrift::advanceWalkersRMC(), RMCUpdatePbyPWithDrift::advanceWalkersVMC(), RMCUpdatePbyPWithDrift::initWalkersForPbyP(), QMCUpdateBase::initWalkersForPbyP(), WaveFunctionTester::runCloneTest(), WaveFunctionTester::runRatioTest(), and WaveFunctionTester::runRatioTest2().

989 {
990  ScopedTimer local_timer(TWF_timers_[BUFFER_TIMER]);
991  P.G = 0.0;
992  P.L = 0.0;
993  buf.rewind(BufferCursor, BufferCursor_scalar);
994  LogValue logpsi(0.0);
995  for (int i = 0; i < Z.size(); ++i)
996  {
998  logpsi += Z[i]->updateBuffer(P, buf, fromscratch);
999  }
1000 
1001  G = P.G;
1002  L = P.L;
1003 
1004  log_real_ = std::real(logpsi);
1005  PhaseValue = std::imag(logpsi);
1006  //printGL(P.G,P.L);
1007  buf.put(PhaseValue);
1008  buf.put(log_real_);
1009  // Ye: temperal added check, to be removed
1010  debugOnlyCheckBuffer(buf);
1011  return log_real_;
1012 }
size_t BufferCursor_scalar
starting index of the scalar buffer
QMCTraits::RealType real
WaveFunctionComponent::LogValue LogValue
ParticleSet::ParticleLaplacian L
differential laplacians
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
ParticleSet::ParticleGradient G
differential gradients
RealType PhaseValue
sign of the trial wave function
std::vector< std::unique_ptr< WaveFunctionComponent > > Z
a list of WaveFunctionComponents constituting many-body wave functions
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
RealType log_real_
real part of trial wave function log
static void debugOnlyCheckBuffer(WFBufferType &buffer)
TimerList_t TWF_timers_
timers at TrialWaveFunction function call level
size_t BufferCursor
starting index of the buffer
std::vector< std::reference_wrapper< NewTimer > > WFC_timers_
timers at WaveFunctionComponent function call level

◆ use_tasking()

bool use_tasking ( ) const
inline

Definition at line 498 of file TrialWaveFunction.h.

References TrialWaveFunction::use_tasking_.

498 { return use_tasking_; }
const bool use_tasking_
if true, using internal tasking implementation

Member Data Documentation

◆ BufferCursor

size_t BufferCursor
private

◆ BufferCursor_scalar

size_t BufferCursor_scalar
private

◆ G

◆ L

◆ log_real_

◆ myName

const std::string myName
private

getName is in the way

Definition at line 532 of file TrialWaveFunction.h.

Referenced by TrialWaveFunction::getName(), and TrialWaveFunction::makeClone().

◆ myNode_

xmlNodePtr myNode_
private

XML input node for a many-body wavefunction.

Copied from the original one. WFOpt driver needs to look it up and make its own copies. YL: updating parameters in an XML file is extremely messy. Better to make WFOpt using h5 only.

Definition at line 526 of file TrialWaveFunction.h.

Referenced by TrialWaveFunction::getNode(), TrialWaveFunction::storeXMLNode(), and TrialWaveFunction::~TrialWaveFunction().

◆ myTwist

std::vector<RealType> myTwist
private

Definition at line 564 of file TrialWaveFunction.h.

Referenced by TrialWaveFunction::setTwist(), and TrialWaveFunction::twist().

◆ OneOverM

RealType OneOverM
private

One over mass of target particleset, needed for Local Energy Derivatives.

Definition at line 550 of file TrialWaveFunction.h.

Referenced by TrialWaveFunction::evaluateDerivatives(), TrialWaveFunction::getReciprocalMass(), TrialWaveFunction::makeClone(), and TrialWaveFunction::setMassTerm().

◆ PhaseDiff

◆ PhaseValue

◆ runtime_options_

const RuntimeOptions& runtime_options_
private

top-level runtime options from project data information > WaveFunctionPool

Definition at line 520 of file TrialWaveFunction.h.

Referenced by TrialWaveFunction::makeClone().

◆ spomap_

const std::shared_ptr<SPOMap> spomap_
private

Owned SPOSets. Once a TWF is fully built, SPOSet lookup should be done via TWF.

Definition at line 529 of file TrialWaveFunction.h.

Referenced by TrialWaveFunction::getSPOMap(), TrialWaveFunction::getSPOSet(), and TrialWaveFunction::storeSPOMap().

◆ twf_prototype

TWFFastDerivWrapper twf_prototype
private

For now, TrialWaveFunction will own the wrapper.

Definition at line 559 of file TrialWaveFunction.h.

◆ TWF_timers_

◆ use_tasking_

const bool use_tasking_
private

if true, using internal tasking implementation

Definition at line 553 of file TrialWaveFunction.h.

Referenced by TrialWaveFunction::calcRatioGrad(), TrialWaveFunction::makeClone(), and TrialWaveFunction::use_tasking().

◆ WFC_timers_

◆ Z

std::vector<std::unique_ptr<WaveFunctionComponent> > Z
private

a list of WaveFunctionComponents constituting many-body wave functions

Definition at line 556 of file TrialWaveFunction.h.

Referenced by TrialWaveFunction::acceptMove(), TrialWaveFunction::addComponent(), TrialWaveFunction::calcRatio(), TrialWaveFunction::calcRatioGrad(), TrialWaveFunction::calcRatioGradWithSpin(), TrialWaveFunction::checkOutVariables(), TrialWaveFunction::completeUpdates(), TrialWaveFunction::copyFromBuffer(), TrialWaveFunction::createResource(), TrialWaveFunction::evalGrad(), TrialWaveFunction::evalGradSource(), TrialWaveFunction::evalGradWithSpin(), TrialWaveFunction::evaluateDeltaLog(), TrialWaveFunction::evaluateDeltaLogSetup(), TrialWaveFunction::evaluateDerivatives(), TrialWaveFunction::evaluateDerivativesWF(), TrialWaveFunction::evaluateDerivRatios(), TrialWaveFunction::evaluateGL(), TrialWaveFunction::evaluateGradDerivatives(), TrialWaveFunction::evaluateHessian(), TrialWaveFunction::evaluateLog(), TrialWaveFunction::evaluateRatios(), TrialWaveFunction::evaluateRatiosAlltoOne(), TrialWaveFunction::evaluateSpinorRatios(), TrialWaveFunction::extractOptimizableObjectRefs(), TrialWaveFunction::findMSD(), TrialWaveFunction::getLogs(), TrialWaveFunction::getOrbitals(), TrialWaveFunction::getPhases(), TrialWaveFunction::initializeTWFFastDerivWrapper(), TrialWaveFunction::KECorrection(), TrialWaveFunction::makeClone(), TrialWaveFunction::prepareGroup(), TrialWaveFunction::recompute(), TrialWaveFunction::registerData(), TrialWaveFunction::rejectMove(), TrialWaveFunction::size(), and TrialWaveFunction::updateBuffer().