QMCPACK
CountingJastrow< RegionType > Class Template Reference
+ Inheritance diagram for CountingJastrow< RegionType >:
+ Collaboration diagram for CountingJastrow< RegionType >:

Public Member Functions

 CountingJastrow (ParticleSet &P, std::unique_ptr< RegionType > c, const Matrix< RealType > &f, bool opt_C_flag, bool opt_F_flag)
 
std::string getClassName () const override
 return class name More...
 
bool isOptimizable () const override
 if true, this contains optimizable components More...
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) override
 extract underlying OptimizableObject references More...
 
void checkInVariablesExclusive (opt_variables_type &active) final
 check in variational parameters to the global list of parameters used by the optimizer. More...
 
void checkOutVariables (const opt_variables_type &active) override
 check out variational optimizable variables More...
 
void resetParametersExclusive (const opt_variables_type &active) override
 reset the parameters during optimizations. More...
 
void initialize ()
 
void reportStatus (std::ostream &os) override
 print the state, e.g., optimizables More...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch More...
 
void recompute (const ParticleSet &P) override
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
void evaluateExponents (const ParticleSet &P)
 
void evaluateExponents_print (std::ostream &os, const ParticleSet &P)
 
void evaluateTempExponents (ParticleSet &P, int iat)
 
void evaluateTempExponents_print (std::ostream &os, ParticleSet &P, int iat)
 
GradType evalGrad (ParticleSet &P, int iat) override
 return the current gradient for the iat-th particle More...
 
PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient More...
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 a move for iat-th particle is accepted. More...
 
void restore (int iat) override
 If a move for iat-th particle is rejected, restore to the content. More...
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
 For particle-by-particle move. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const override
 make clone More...
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
void addDebug (bool debug_flag, int seqlen, int period)
 
- Public Member Functions inherited from WaveFunctionComponent
const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
virtual void checkSanity () const
 Validate the internal consistency of the object. More...
 
const std::string & getName () const
 return object name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual bool isFermionic () const
 true, if this component is fermionic More...
 
virtual bool isMultiDet () const
 true, if this component is multi-determinant More...
 
virtual void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
virtual void mw_evaluateLog (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const
 evaluate from scratch the same type WaveFunctionComponent of multiple walkers More...
 
virtual void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 
virtual void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi_all)
 
virtual void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
virtual GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad)
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, TWFGrads< CT > &grads_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat)
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
virtual GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad)
 Adds the gradient w.r.t. More...
 
virtual PsiValue ratioGradWithSpin (ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad_iat)
 evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const
 
virtual void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
virtual void mw_accept_rejectMove (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false) const
 moves of the iat-th particle on some walkers in a batch is accepted. More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
virtual void mw_completeUpdates (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region. More...
 
virtual void mw_calcRatio (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const
 compute the ratio of the new to old WaveFunctionComponent value of multiple walkers More...
 
virtual LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch)
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
virtual void mw_evaluateGL (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list, bool fromscratch) const
 evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers More...
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 acquire a shared resource from a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 return a shared resource to a collection More...
 
virtual RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
virtual void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)=0
 Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimizable parameters. More...
 
virtual void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi)
 Compute the derivatives of the log of the wavefunction with respect to optimizable parameters. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void finalizeOptimization ()
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
virtual void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const
 evaluate ratios to evaluate the non-local PP multiple walkers More...
 
virtual void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void mw_evalGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const
 compute the current gradients and spin gradients for the iat-th particle of multiple walkers More...
 
virtual void mw_ratioGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new, std::vector< ComplexType > &spingrad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of multiple walkers More...
 
- Public Member Functions inherited from OptimizableObject
 OptimizableObject (const std::string &name)
 
const std::string & getName () const
 
bool isOptimized () const
 
void setOptimization (bool state)
 
virtual void writeVariationalParameters (hdf_archive &hout)
 Write the variational parameters for this object to the VP HDF file. More...
 
virtual void readVariationalParameters (hdf_archive &hin)
 Read the variational parameters for this object from the VP HDF file. More...
 

Protected Types

enum  opt_var { OPT_F, NUM_OPT_VAR }
 

Protected Attributes

int num_els
 
int num_regions
 
bool debug = false
 
int debug_seqlen
 
int debug_period
 
Matrix< RealTypeF
 
std::unique_ptr< RegionType > C
 
bool opt_F
 
bool opt_C
 
std::vector< RealTypeFCsum
 
Matrix< PosTypeFCgrad
 
Matrix< RealTypeFClap
 
std::vector< RealTypeFCggsum
 
std::vector< RealTypeFClapsum
 
std::vector< RealTypeFCsum_t
 
std::vector< PosTypeFCgrad_t
 
std::vector< RealTypeFClap_t
 
RealType Jval
 
std::vector< PosTypeJgrad
 
std::vector< RealTypeJlap
 
RealType Jval_t
 
std::vector< PosTypeJgrad_t
 
std::vector< RealTypeJlap_t
 
Matrix< RealTypedCsum
 
Matrix< RealTypedCggsum
 
Matrix< RealTypedClapsum
 
std::vector< RealTypedCsum_t
 
std::vector< RealTypedCFCggsum
 
std::vector< int > dCindex
 
std::array< std::vector< int >, NUM_OPT_VARopt_index
 
std::array< std::vector< std::string >, NUM_OPT_VARopt_id
 
- Protected Attributes inherited from WaveFunctionComponent
const std::string my_name_
 Name of the object It is required to be different for objects of the same derived type like multiple J1. More...
 
LogValue log_value_
 Current $\log\phi $. More...
 

Additional Inherited Members

- Public Types inherited from WaveFunctionComponent
enum  {
  ORB_PBYP_RATIO, ORB_PBYP_ALL, ORB_PBYP_PARTIAL, ORB_WALKER,
  ORB_ALLWALKER
}
 enum for a update mode More...
 
using Walker_t = ParticleSet::Walker_t
 
using WFBufferType = Walker_t::WFBuffer_t
 
using BufferType = Walker_t::Buffer_t
 
using RealMatrix_t = OrbitalSetTraits< RealType >::ValueMatrix
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using LogValue = std::complex< QTFull::RealType >
 
using PsiValue = QTFull::ValueType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 
- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 

Detailed Description

template<class RegionType>
class qmcplusplus::CountingJastrow< RegionType >

Definition at line 23 of file CountingJastrow.h.

Member Enumeration Documentation

◆ opt_var

enum opt_var
protected
Enumerator
OPT_F 
NUM_OPT_VAR 

Definition at line 80 of file CountingJastrow.h.

Constructor & Destructor Documentation

◆ CountingJastrow()

CountingJastrow ( ParticleSet P,
std::unique_ptr< RegionType >  c,
const Matrix< RealType > &  f,
bool  opt_C_flag,
bool  opt_F_flag 
)
inline

Definition at line 94 of file CountingJastrow.h.

References ParticleSet::getTotalNum(), and CountingJastrow< RegionType >::num_els.

99  : OptimizableObject("countingjas"), F(f), C(std::move(c)), opt_F(opt_F_flag), opt_C(opt_C_flag)
100  {
101  num_els = P.getTotalNum();
102  }
std::unique_ptr< RegionType > C
OptimizableObject(const std::string &name)

Member Function Documentation

◆ acceptMove()

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

a move for iat-th particle is accepted.

Update the current content.

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

Implements WaveFunctionComponent.

Definition at line 395 of file CountingJastrow.h.

References CountingJastrow< RegionType >::C, CountingJastrow< RegionType >::FCgrad, CountingJastrow< RegionType >::FCgrad_t, CountingJastrow< RegionType >::FClap, CountingJastrow< RegionType >::FClap_t, CountingJastrow< RegionType >::FCsum, CountingJastrow< RegionType >::FCsum_t, I, CountingJastrow< RegionType >::Jgrad, CountingJastrow< RegionType >::Jgrad_t, CountingJastrow< RegionType >::Jlap, CountingJastrow< RegionType >::Jlap_t, CountingJastrow< RegionType >::Jval, CountingJastrow< RegionType >::Jval_t, WaveFunctionComponent::log_value_, CountingJastrow< RegionType >::num_els, and CountingJastrow< RegionType >::num_regions.

Referenced by qmcplusplus::TEST_CASE().

396  {
397  C->acceptMove(P, iat);
398  // update values for C, FC to those at proposed position
399  // copy over temporary values
400  for (int I = 0; I < num_regions; ++I)
401  {
402  FCsum[I] = FCsum_t[I];
403  FCgrad(I, iat) = FCgrad_t[I];
404  FClap(I, iat) = FClap_t[I];
405  }
406  // update exponent values to that at proposed position
407  Jval = Jval_t;
408  log_value_ = Jval;
409  for (int i = 0; i < num_els; ++i)
410  {
411  Jgrad[i] = Jgrad_t[i];
412  Jlap[i] = Jlap_t[i];
413  }
414  }
std::unique_ptr< RegionType > C
std::vector< RealType > Jlap_t
std::vector< RealType > FClap_t
std::vector< PosType > Jgrad_t
std::complex< double > I
std::vector< RealType > FCsum_t
std::vector< RealType > FCsum
std::vector< RealType > Jlap
std::vector< PosType > FCgrad_t
std::vector< PosType > Jgrad

◆ addDebug()

void addDebug ( bool  debug_flag,
int  seqlen,
int  period 
)
inline

◆ checkInVariablesExclusive()

void checkInVariablesExclusive ( opt_variables_type active)
inlinefinalvirtual

check in variational parameters to the global list of parameters used by the optimizer.

Parameters
activea super set of optimizable variables

The existing checkInVariables implementation in WFC/SPO/.. are inclusive and it calls checkInVariables of its members class A: public SPOSet {} class B: public WFC { A objA; checkInVariables() { objA.checkInVariables(); } };

With OptimizableObject, class A: public OptimizableObject {} class B: public OptimizableObject { A objA; checkInVariablesExclusive() { // should not call objA.checkInVariablesExclusive() if objA has been extracted; } }; A vector of OptimizableObject, will be created by calling extractOptimizableObjects(). All the checkInVariablesExclusive() will be called through this vector and thus checkInVariablesExclusive implementation should only handle non-OptimizableObject members.

Implements OptimizableObject.

Definition at line 110 of file CountingJastrow.h.

References CountingJastrow< RegionType >::C, and WaveFunctionComponent::myVars.

Referenced by qmcplusplus::TEST_CASE().

111  {
112  active.insertFrom(myVars);
113  C->checkInVariables(active);
114  }
std::unique_ptr< RegionType > C
opt_variables_type myVars
list of variables this WaveFunctionComponent handles

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
inlineoverridevirtual

check out variational optimizable variables

Parameters
activea super set of optimizable variables

Reimplemented from WaveFunctionComponent.

Definition at line 116 of file CountingJastrow.h.

References CountingJastrow< RegionType >::C, VariableSet::getIndex(), and WaveFunctionComponent::myVars.

Referenced by qmcplusplus::TEST_CASE().

117  {
118  myVars.getIndex(active);
119  C->checkOutVariables(active);
120  }
std::unique_ptr< RegionType > C
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter

◆ copyFromBuffer()

void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)
inlineoverridevirtual

For particle-by-particle move.

Copy data or attach memory from a walker buffer to the objects of this class. The log value, P.G and P.L contribution from the objects of this class are also added.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 453 of file CountingJastrow.h.

References PooledMemory< T_scalar, Alloc >::current(), DEBUG_PSIBUFFER, PooledMemory< T_scalar, Alloc >::get(), CountingJastrow< RegionType >::Jgrad, CountingJastrow< RegionType >::Jlap, and CountingJastrow< RegionType >::Jval.

454  {
455  RealType* Jlap_begin = &Jlap[0];
456  RealType* Jlap_end = Jlap_begin + Jlap.size();
457  RealType* Jgrad_begin = &Jgrad[0][0];
458  RealType* Jgrad_end = Jgrad_begin + Jgrad.size() * 3;
459  DEBUG_PSIBUFFER(" CountingJastrow::copyFromBuffer ", buf.current());
460  buf.get(&Jval, &Jval);
461  buf.get(Jlap_begin, Jlap_end);
462  buf.get(Jgrad_begin, Jgrad_end);
463  DEBUG_PSIBUFFER(" CountingJastrow::copyFromBuffer ", buf.current());
464  return;
465  }
#define DEBUG_PSIBUFFER(who, msg)
Definition: Configuration.h:40
QMCTraits::RealType RealType
std::vector< RealType > Jlap
std::vector< PosType > Jgrad

◆ evalGrad()

GradType evalGrad ( ParticleSet P,
int  iat 
)
inlineoverridevirtual

return the current gradient for the iat-th particle

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

Reimplemented from WaveFunctionComponent.

Definition at line 381 of file CountingJastrow.h.

References CountingJastrow< RegionType >::evaluateExponents(), CountingJastrow< RegionType >::Jgrad, CountingJastrow< RegionType >::Jval, and WaveFunctionComponent::log_value_.

Referenced by qmcplusplus::TEST_CASE().

382  {
384  log_value_ = Jval;
385  return Jgrad[iat];
386  }
void evaluateExponents(const ParticleSet &P)
std::vector< PosType > Jgrad

◆ evaluateDerivatives()

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

Definition at line 475 of file CountingJastrow.h.

References APP_ABORT, qmcplusplus::app_log(), Matrix< T, Alloc >::begin(), CountingJastrow< RegionType >::C, copy(), CountingJastrow< RegionType >::dCFCggsum, CountingJastrow< RegionType >::dCggsum, CountingJastrow< RegionType >::dClapsum, CountingJastrow< RegionType >::dCsum, CountingJastrow< RegionType >::debug, CountingJastrow< RegionType >::debug_period, CountingJastrow< RegionType >::debug_seqlen, qmcplusplus::dot(), Matrix< T, Alloc >::end(), CountingJastrow< RegionType >::evaluateExponents(), CountingJastrow< RegionType >::evaluateExponents_print(), CountingJastrow< RegionType >::FCggsum, CountingJastrow< RegionType >::FCgrad, CountingJastrow< RegionType >::FClap, CountingJastrow< RegionType >::FClapsum, CountingJastrow< RegionType >::FCsum, ParticleSet::G, VariableSet::getIndex(), I, VariableSet::Index, qmcplusplus::Units::energy::J, WaveFunctionComponent::myVars, VariableSet::name(), VariableSet::NameAndValue, CountingJastrow< RegionType >::num_els, CountingJastrow< RegionType >::num_regions, CountingJastrow< RegionType >::opt_C, CountingJastrow< RegionType >::opt_F, CountingJastrow< RegionType >::OPT_F, CountingJastrow< RegionType >::opt_id, CountingJastrow< RegionType >::opt_index, and VariableSet::size().

Referenced by qmcplusplus::TEST_CASE().

479  {
480 #ifdef QMC_COMPLEX
481  APP_ABORT("CountingJastrow::evaluateDerivatives is not available on complex builds.");
482 #else
484  // evaluate derivatives of F
485  static int deriv_print_index = 0;
486  if (opt_F)
487  {
488  for (int oi = 0; oi < opt_index[OPT_F].size(); ++oi)
489  {
490  std::string id = opt_id[OPT_F][oi];
491  int ia = myVars.getIndex(id);
492  if (ia == -1)
493  continue; // ignore inactive parameters
494  int IJ = opt_index[OPT_F][oi];
495  int I = IJ / num_regions;
496  int J = IJ % num_regions;
497  // coefficient due to symmetry of F: \sum\limits_{I} F_{II} C_I^2 + \sum\limits_{J > I} 2 F_{IJ}*C_I*C_J
498  RealType x = (I == J) ? 1 : 2;
499  RealType dJF_val = C->sum[I] * C->sum[J] * x;
500  RealType dJF_gg = 0, dJF_lap = 0;
501  for (int i = 0; i < num_els; ++i)
502  {
503  PosType grad_i(P.G[i]);
504  dJF_gg += x * (dot(C->grad(I, i), grad_i) * C->sum[J] + C->sum[I] * dot(C->grad(J, i), grad_i));
505  dJF_lap += x * (C->lap(I, i) * C->sum[J] + 2 * dot(C->grad(I, i), C->grad(J, i)) + C->lap(J, i) * C->sum[I]);
506  }
507  dlogpsi[ia] += dJF_val;
508  dhpsioverpsi[ia] += -0.5 * dJF_lap - dJF_gg;
509  if (debug && deriv_print_index < debug_seqlen)
510  {
511  app_log() << " dJ/dF[" << I << "][" << J << "]; ia: " << ia << ", dlogpsi: " << dlogpsi[ia]
512  << ", dhpsioverpsi: " << dhpsioverpsi[ia] << std::endl;
513  }
514  }
515  }
516 
517  // // evaluate partial derivatives of C
518  if (opt_C)
519  {
520  // containers for CountingRegions' evaluateDerivatives calculations
521  // blocks of dimension n_p x n_C
522  // ex: dNsum = \sum\limits_k [ [dC1 / dp1] [dC2 / dp1] .. ]
523  // Where each [dCi / dpj] block is n_p x 1 vector of derivatives of parameters
524  // for counting region j as summed over electron coordinate k
525 
526  // exception: dNFN ggsum is an n_p x 1 vector since it is an evaluation of a quadratic form:
527  // \sum\limits_{kI} [\nabla_k dC_I/dpj] dot [ (F \nabla_k C)_I ]
528  // since we have the premultiplied (F\nabla_k C) vector on hand.
529  // make a lambda function FCgrad(I,i) which gives the appropriate element of FCgrad[iI]
530 
531  // clear some vectors
532  std::fill(FCggsum.begin(), FCggsum.end(), 0);
533  std::fill(FClapsum.begin(), FClapsum.end(), 0);
534 
535  // evaluate FCggsum
536  for (int I = 0; I < num_regions; ++I)
537  {
538  for (int i = 0; i < num_els; ++i)
539  {
540  PosType grad_i(P.G[i]);
541  FCggsum[I] += dot(FCgrad(I, i), grad_i);
542  FClapsum[I] += FClap(I, i);
543  }
544  }
545  // pointer to C->C[I]->myVars.Index
546  // for pI in { 0 .. C->num_derivs(I) }
547  // dCindex->[pI] is the index that corresponds to this parameter in active.
548  // i.e., active[dCindex->[pI]] <=> C->C[I]->myVars.Index[pI]
549 
550  // external print block
551  if (debug && deriv_print_index < debug_seqlen)
552  {
553  app_log() << std::endl << "=== evaluateDerivatives ===" << std::endl;
554  app_log() << "== print current exponent values ==" << std::endl;
556  app_log() << "== additional counting function terms ==" << std::endl;
557  app_log() << "P.G: ";
558  std::copy(P.G.begin(), P.G.end(), std::ostream_iterator<PosType>(app_log(), ", "));
559  app_log() << std::endl << "FCgrad: ";
560  std::copy(FCgrad.begin(), FCgrad.end(), std::ostream_iterator<PosType>(app_log(), ", "));
561  app_log() << std::endl << "FClap: ";
562  std::copy(FClap.begin(), FClap.end(), std::ostream_iterator<RealType>(app_log(), ", "));
563  app_log() << std::endl << "FCggsum: ";
564  std::copy(FCggsum.begin(), FCggsum.end(), std::ostream_iterator<RealType>(app_log(), ", "));
565  app_log() << std::endl << "FClapsum: ";
566  std::copy(FClapsum.begin(), FClapsum.end(), std::ostream_iterator<RealType>(app_log(), ", "));
567  app_log() << std::endl;
568  }
569 
570  for (int I = 0; I < num_regions; ++I)
571  {
572  // get the number of active parameters for the Ith counting region
573  opt_variables_type I_vars = C->getVars(I);
574  int I_num_derivs = I_vars.size();
575  // clear arrays before each evaluate
576  std::fill(dCsum.begin(), dCsum.end(), 0);
577  std::fill(dCggsum.begin(), dCggsum.end(), 0);
578  std::fill(dClapsum.begin(), dClapsum.end(), 0);
579  std::fill(dCFCggsum.begin(), dCFCggsum.end(), 0);
580  // evaluate all derivatives for the Ith counting function
581  C->evaluateDerivatives(P, I, FCgrad, dCsum, dCggsum, dClapsum, dCFCggsum);
582  if (debug && deriv_print_index < debug_seqlen)
583  {
584  // print out current index information
585  app_log() << std::endl;
586  app_log() << " == evaluateDerivatives for counting region " << I << ", num_derivs: " << I_num_derivs
587  << " ==" << std::endl;
588  app_log() << " Indices: ";
589  std::copy(I_vars.Index.begin(), I_vars.Index.end(), std::ostream_iterator<int>(app_log(), ", "));
590  app_log() << std::endl << " Names: ";
591  for (auto it = I_vars.NameAndValue.begin(); it != I_vars.NameAndValue.end(); ++it)
592  app_log() << (*it).first << ", ";
593  app_log() << std::endl << " Values: ";
594  for (auto it = I_vars.NameAndValue.begin(); it != I_vars.NameAndValue.end(); ++it)
595  app_log() << (*it).second << ", ";
596  // print out values from evaluate derivatives
597  app_log() << std::endl << " dCsum: ";
598  std::copy(dCsum.begin(), dCsum.end(), std::ostream_iterator<RealType>(app_log(), ", "));
599  app_log() << std::endl << " dCggsum: ";
600  std::copy(dCggsum.begin(), dCggsum.end(), std::ostream_iterator<RealType>(app_log(), ", "));
601  app_log() << std::endl << " dClapsum: ";
602  std::copy(dClapsum.begin(), dClapsum.end(), std::ostream_iterator<RealType>(app_log(), ", "));
603  app_log() << std::endl << " dCFCggsum: ";
604  std::copy(dCFCggsum.begin(), dCFCggsum.end(), std::ostream_iterator<RealType>(app_log(), ", "));
605  app_log() << std::endl;
606  }
607  // loop over parameters for the Ith counting function
608  for (int pI = 0; pI < I_num_derivs; ++pI)
609  {
610  // index for active optimizable variables
611  int ia = I_vars.Index[pI];
612  if (ia == -1)
613  continue; // ignore inactive
614  // middle laplacian term:
615  dhpsioverpsi[ia] += -0.5 * (4.0 * dCFCggsum[pI]);
616  if (debug && deriv_print_index < debug_seqlen)
617  {
618  app_log() << " == evaluateDerivatives calculations ==" << std::endl;
619  app_log() << " pI: " << pI << ", name: " << I_vars.name(pI) << ", ia: " << ia << std::endl;
620  app_log() << " dCFCggsum: " << dCFCggsum[pI] << std::endl;
621  }
622  for (int J = 0; J < num_regions; ++J)
623  {
624  dlogpsi[ia] += dCsum(J, pI) * (2 * FCsum[J]);
625  // grad dot grad terms
626  dhpsioverpsi[ia] += -1.0 * (dCggsum(J, pI) * (2.0 * FCsum[J]) + dCsum(J, pI) * 2.0 * FCggsum[J]);
627  // outer laplacian terms
628  dhpsioverpsi[ia] += -0.5 * (2.0 * dCsum(J, pI) * FClapsum[J] + dClapsum(J, pI) * (2.0 * FCsum[J]));
629  if (debug && deriv_print_index < debug_seqlen)
630  {
631  app_log() << " J: " << J << std::endl;
632  app_log() << " dlogpsi term : " << dCsum(J, pI) * (2 * FCsum[J]) << std::endl;
633  app_log() << " dhpsi/psi, graddotgrad: "
634  << -1.0 * (dCggsum(J, pI) * (2.0 * FCsum[J]) + dCsum(J, pI) * 2.0 * FCggsum[J]) << std::endl;
635  app_log() << " dhpsi/psi, laplacian : "
636  << -0.5 * (2.0 * dCsum(J, pI) * FClapsum[J] + dClapsum(J, pI) * (2.0 * FCsum[J])) << std::endl;
637  }
638  }
639  }
640  }
641 
642  } // end opt_C
643  // increment and modulo deriv_print_index
644  if (debug)
645  {
646  app_log() << "Final derivatives: " << std::endl;
647  app_log() << " F derivatives: " << std::endl;
648  for (int oi = 0; oi < opt_index[OPT_F].size(); ++oi)
649  {
650  std::string id = opt_id[OPT_F][oi];
651  int ia = myVars.getIndex(id);
652  if (ia == -1)
653  continue; // ignore inactive parameters
654  app_log() << " ia: " << ia << ", dlogpsi: " << dlogpsi[ia] << ", dhpsioverpsi: " << dhpsioverpsi[ia]
655  << std::endl;
656  }
657  app_log() << " C derivatives: " << std::endl;
658  for (int I = 0; I < num_regions; ++I)
659  {
660  app_log() << " C[" << I << "] derivs: " << std::endl;
661  // get the number of active parameters for the Ith counting region
662  opt_variables_type I_vars = C->getVars(I);
663  int I_num_derivs = I_vars.size();
664  for (int pI = 0; pI < I_num_derivs; ++pI)
665  {
666  // index for active optimizable variables
667  int ia = I_vars.Index[pI];
668  if (ia == -1)
669  continue; // ignore inactive
670  app_log() << " ia: " << ia << ", dlogpsi: " << dlogpsi[ia] << ", dhpsioverpsi: " << dhpsioverpsi[ia]
671  << std::endl;
672  }
673  }
674  deriv_print_index = deriv_print_index % debug_period;
675  deriv_print_index++;
676  }
677 #endif
678  }
Container_t::iterator begin()
Definition: OhmmsMatrix.h:89
std::unique_ptr< RegionType > C
std::ostream & app_log()
Definition: OutputManager.h:65
void evaluateExponents_print(std::ostream &os, const ParticleSet &P)
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
QMCTraits::PosType PosType
Matrix< RealType > dCggsum
void evaluateExponents(const ParticleSet &P)
std::array< std::vector< std::string >, NUM_OPT_VAR > opt_id
std::vector< RealType > FCggsum
std::vector< RealType > dCFCggsum
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
optimize::VariableSet opt_variables_type
std::array< std::vector< int >, NUM_OPT_VAR > opt_index
std::vector< RealType > FClapsum
std::complex< double > I
QMCTraits::RealType RealType
Matrix< RealType > dClapsum
std::vector< RealType > FCsum
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
Container_t::iterator end()
Definition: OhmmsMatrix.h:90
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter

◆ evaluateExponents()

void evaluateExponents ( const ParticleSet P)
inline

Definition at line 242 of file CountingJastrow.h.

References qmcplusplus::app_log(), Matrix< T, Alloc >::begin(), CountingJastrow< RegionType >::C, CountingJastrow< RegionType >::debug, CountingJastrow< RegionType >::debug_period, CountingJastrow< RegionType >::debug_seqlen, qmcplusplus::dot(), Matrix< T, Alloc >::end(), CountingJastrow< RegionType >::evaluateExponents_print(), CountingJastrow< RegionType >::F, CountingJastrow< RegionType >::FCgrad, CountingJastrow< RegionType >::FClap, CountingJastrow< RegionType >::FCsum, I, qmcplusplus::Units::energy::J, CountingJastrow< RegionType >::Jgrad, CountingJastrow< RegionType >::Jlap, CountingJastrow< RegionType >::Jval, CountingJastrow< RegionType >::num_els, and CountingJastrow< RegionType >::num_regions.

Referenced by CountingJastrow< RegionType >::evalGrad(), CountingJastrow< RegionType >::evaluateDerivatives(), CountingJastrow< RegionType >::evaluateLog(), and CountingJastrow< RegionType >::recompute().

243  {
244  // evaluate counting regions
245  C->evaluate(P);
246  std::fill(FCsum.begin(), FCsum.end(), 0);
247  std::fill(FCgrad.begin(), FCgrad.end(), 0);
248  std::fill(FClap.begin(), FClap.end(), 0);
249  Jval = 0;
250  std::fill(Jgrad.begin(), Jgrad.end(), 0);
251  std::fill(Jlap.begin(), Jlap.end(), 0);
252 
253  // evaluate FC products
254  for (int I = 0; I < num_regions; ++I)
255  {
256  for (int J = 0; J < num_regions; ++J)
257  {
258  FCsum[I] += F(I, J) * C->sum[J]; // MV
259  for (int i = 0; i < num_els; ++i)
260  {
261  FCgrad(I, i) += F(I, J) * C->grad(J, i); // 3*nels*MV
262  FClap(I, i) += F(I, J) * C->lap(J, i); // nels*MV
263  }
264  }
265  }
266  // evaluate components of J
267  for (int I = 0; I < num_regions; ++I)
268  {
269  Jval += FCsum[I] * C->sum[I]; // VV
270  for (int i = 0; i < num_els; ++i)
271  {
272  Jgrad[i] += 2 * FCsum[I] * C->grad(I, i); // 3*nels*VV
273  Jlap[i] += 2 * FCsum[I] * C->lap(I, i) + 2 * dot(FCgrad(I, i), C->grad(I, i)); // nels*VV
274  }
275  }
276  // print out results every so often
277  if (debug)
278  {
279  static int exp_print_index = 0;
280  if (exp_print_index < debug_seqlen)
282  ++exp_print_index;
283  exp_print_index = exp_print_index % debug_period;
284  }
285  }
Container_t::iterator begin()
Definition: OhmmsMatrix.h:89
std::unique_ptr< RegionType > C
std::ostream & app_log()
Definition: OutputManager.h:65
void evaluateExponents_print(std::ostream &os, const ParticleSet &P)
std::complex< double > I
std::vector< RealType > FCsum
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< RealType > Jlap
Container_t::iterator end()
Definition: OhmmsMatrix.h:90
std::vector< PosType > Jgrad

◆ evaluateExponents_print()

void evaluateExponents_print ( std::ostream &  os,
const ParticleSet P 
)
inline

Definition at line 288 of file CountingJastrow.h.

References qmcplusplus::app_log(), Matrix< T, Alloc >::begin(), CountingJastrow< RegionType >::C, copy(), Matrix< T, Alloc >::end(), CountingJastrow< RegionType >::FCgrad, CountingJastrow< RegionType >::FClap, CountingJastrow< RegionType >::FCsum, CountingJastrow< RegionType >::Jgrad, CountingJastrow< RegionType >::Jlap, and CountingJastrow< RegionType >::Jval.

Referenced by CountingJastrow< RegionType >::evaluateDerivatives(), and CountingJastrow< RegionType >::evaluateExponents().

289  {
290  // print counting regions
291  C->evaluate_print(app_log(), P);
292  // FCsum, FCgrad, FClap
293  os << "CountingJastrow::evaluateExponents_print: ";
294  os << std::endl << "FCsum: ";
295  std::copy(FCsum.begin(), FCsum.end(), std::ostream_iterator<RealType>(os, ", "));
296  os << std::endl << "FCgrad: ";
297  std::copy(FCgrad.begin(), FCgrad.end(), std::ostream_iterator<PosType>(os, ", "));
298  os << std::endl << "FClap: ";
299  std::copy(FClap.begin(), FClap.end(), std::ostream_iterator<RealType>(os, ", "));
300  // Jval, Jgrad, Jlap
301  os << std::endl << "Jval: " << Jval;
302  os << std::endl << "Jgrad: ";
303  std::copy(Jgrad.begin(), Jgrad.end(), std::ostream_iterator<PosType>(os, ", "));
304  os << std::endl << "Jlap: ";
305  std::copy(Jlap.begin(), Jlap.end(), std::ostream_iterator<RealType>(os, ", "));
306  os << std::endl << std::endl;
307  }
Container_t::iterator begin()
Definition: OhmmsMatrix.h:89
std::unique_ptr< RegionType > C
std::ostream & app_log()
Definition: OutputManager.h:65
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
std::vector< RealType > FCsum
std::vector< RealType > Jlap
Container_t::iterator end()
Definition: OhmmsMatrix.h:90
std::vector< PosType > Jgrad

◆ evaluateLog()

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

evaluate the value of the WaveFunctionComponent from scratch

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

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

Implements WaveFunctionComponent.

Definition at line 221 of file CountingJastrow.h.

References CountingJastrow< RegionType >::evaluateExponents(), CountingJastrow< RegionType >::Jgrad, CountingJastrow< RegionType >::Jlap, CountingJastrow< RegionType >::Jval, WaveFunctionComponent::log_value_, and CountingJastrow< RegionType >::num_els.

Referenced by CountingJastrow< RegionType >::registerData(), qmcplusplus::TEST_CASE(), and CountingJastrow< RegionType >::updateBuffer().

224  {
226  for (int i = 0; i < num_els; ++i)
227  {
228  G[i] += Jgrad[i];
229  L[i] += Jlap[i];
230  }
231  log_value_ = Jval;
232  return log_value_;
233  }
void evaluateExponents(const ParticleSet &P)
std::vector< RealType > Jlap
std::vector< PosType > Jgrad

◆ evaluateTempExponents()

void evaluateTempExponents ( ParticleSet P,
int  iat 
)
inline

Definition at line 310 of file CountingJastrow.h.

References qmcplusplus::app_log(), CountingJastrow< RegionType >::C, CountingJastrow< RegionType >::debug, CountingJastrow< RegionType >::debug_period, CountingJastrow< RegionType >::debug_seqlen, qmcplusplus::dot(), CountingJastrow< RegionType >::evaluateTempExponents_print(), CountingJastrow< RegionType >::F, CountingJastrow< RegionType >::FCgrad, CountingJastrow< RegionType >::FCgrad_t, CountingJastrow< RegionType >::FClap_t, CountingJastrow< RegionType >::FCsum_t, I, qmcplusplus::Units::energy::J, CountingJastrow< RegionType >::Jgrad_t, CountingJastrow< RegionType >::Jlap_t, CountingJastrow< RegionType >::Jval_t, CountingJastrow< RegionType >::num_els, and CountingJastrow< RegionType >::num_regions.

Referenced by CountingJastrow< RegionType >::ratio(), and CountingJastrow< RegionType >::ratioGrad().

311  {
312  // evaluate temporary counting regions
313  C->evaluateTemp(P, iat);
314  Jval_t = 0;
315  std::fill(Jgrad_t.begin(), Jgrad_t.end(), 0);
316  std::fill(Jlap_t.begin(), Jlap_t.end(), 0);
317  std::fill(FCsum_t.begin(), FCsum_t.end(), 0);
318  std::fill(FCgrad_t.begin(), FCgrad_t.end(), 0);
319  std::fill(FClap_t.begin(), FClap_t.end(), 0);
320 
321  // evaluate temp FC arrays
322  for (int I = 0; I < num_regions; ++I)
323  {
324  for (int J = 0; J < num_regions; ++J)
325  {
326  FCsum_t[I] += F(I, J) * C->sum_t[J];
327  FCgrad_t[I] += F(I, J) * C->grad_t[J];
328  FClap_t[I] += F(I, J) * C->lap_t[J];
329  }
330  }
331  // evaluate components of the exponent
332  for (int I = 0; I < num_regions; ++I)
333  {
334  Jval_t += C->sum_t[I] * FCsum_t[I];
335  for (int i = 0; i < num_els; ++i)
336  {
337  if (i == iat)
338  {
339  Jgrad_t[i] += C->grad_t[I] * 2 * FCsum_t[I];
340  Jlap_t[i] += C->lap_t[I] * 2 * FCsum_t[I] + 2 * dot(C->grad_t[I], FCgrad_t[I]);
341  }
342  else
343  {
344  Jgrad_t[i] += C->grad(I, i) * 2 * FCsum_t[I];
345  Jlap_t[i] += C->lap(I, i) * 2 * FCsum_t[I] + 2 * dot(C->grad(I, i), FCgrad(I, i));
346  }
347  }
348  }
349  // print out results every so often
350  if (debug)
351  {
352  static int expt_print_index = 0;
353  if (expt_print_index < debug_seqlen)
355  ++expt_print_index;
356  expt_print_index = expt_print_index % debug_period;
357  }
358  }
std::unique_ptr< RegionType > C
std::vector< RealType > Jlap_t
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< RealType > FClap_t
std::vector< PosType > Jgrad_t
std::complex< double > I
std::vector< RealType > FCsum_t
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< PosType > FCgrad_t
void evaluateTempExponents_print(std::ostream &os, ParticleSet &P, int iat)

◆ evaluateTempExponents_print()

void evaluateTempExponents_print ( std::ostream &  os,
ParticleSet P,
int  iat 
)
inline

Definition at line 360 of file CountingJastrow.h.

References qmcplusplus::app_log(), CountingJastrow< RegionType >::C, copy(), CountingJastrow< RegionType >::FCgrad_t, CountingJastrow< RegionType >::FClap_t, CountingJastrow< RegionType >::FCsum_t, CountingJastrow< RegionType >::Jgrad_t, CountingJastrow< RegionType >::Jlap_t, and CountingJastrow< RegionType >::Jval_t.

Referenced by CountingJastrow< RegionType >::evaluateTempExponents().

361  {
362  // print counting regions
363  C->evaluateTemp_print(app_log(), P);
364  // FCsum, FCgrad, FClap
365  os << "CountingJastrow::evaluateTempExponents_print: iat: " << iat;
366  os << std::endl << "FCsum_t: ";
367  std::copy(FCsum_t.begin(), FCsum_t.end(), std::ostream_iterator<RealType>(os, ", "));
368  os << std::endl << "FCgrad_t: ";
369  std::copy(FCgrad_t.begin(), FCgrad_t.end(), std::ostream_iterator<PosType>(os, ", "));
370  os << std::endl << "FClap_t: ";
371  std::copy(FClap_t.begin(), FClap_t.end(), std::ostream_iterator<RealType>(os, ", "));
372  // Jval, Jgrad, Jlap
373  os << std::endl << "Jval_t: " << Jval_t;
374  os << std::endl << "Jgrad_t: ";
375  std::copy(Jgrad_t.begin(), Jgrad_t.end(), std::ostream_iterator<PosType>(os, ", "));
376  os << std::endl << "Jlap_t: ";
377  std::copy(Jlap_t.begin(), Jlap_t.end(), std::ostream_iterator<RealType>(os, ", "));
378  os << std::endl << std::endl;
379  }
std::unique_ptr< RegionType > C
std::vector< RealType > Jlap_t
std::ostream & app_log()
Definition: OutputManager.h:65
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
std::vector< RealType > FClap_t
std::vector< PosType > Jgrad_t
std::vector< RealType > FCsum_t
std::vector< PosType > FCgrad_t

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
inlineoverridevirtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented from WaveFunctionComponent.

Definition at line 108 of file CountingJastrow.h.

References UniqueOptObjRefs::push_back().

108 { opt_obj_refs.push_back(*this); }

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 104 of file CountingJastrow.h.

104 { return "CountingJastrow"; }

◆ initialize()

void initialize ( )
inline

Definition at line 150 of file CountingJastrow.h.

References APP_ABORT, CountingJastrow< RegionType >::C, CountingJastrow< RegionType >::dCFCggsum, CountingJastrow< RegionType >::dCggsum, CountingJastrow< RegionType >::dClapsum, CountingJastrow< RegionType >::dCsum, CountingJastrow< RegionType >::F, CountingJastrow< RegionType >::FCggsum, CountingJastrow< RegionType >::FCgrad, CountingJastrow< RegionType >::FCgrad_t, CountingJastrow< RegionType >::FClap, CountingJastrow< RegionType >::FClap_t, CountingJastrow< RegionType >::FClapsum, CountingJastrow< RegionType >::FCsum, CountingJastrow< RegionType >::FCsum_t, I, VariableSet::insert(), qmcplusplus::Units::energy::J, CountingJastrow< RegionType >::Jgrad, CountingJastrow< RegionType >::Jgrad_t, CountingJastrow< RegionType >::Jlap, CountingJastrow< RegionType >::Jlap_t, WaveFunctionComponent::myVars, CountingJastrow< RegionType >::num_els, CountingJastrow< RegionType >::num_regions, CountingJastrow< RegionType >::opt_F, CountingJastrow< RegionType >::OPT_F, CountingJastrow< RegionType >::opt_id, CountingJastrow< RegionType >::opt_index, VariableSet::resetIndex(), Matrix< T, Alloc >::resize(), and Matrix< T, Alloc >::size().

151  {
152  // allocate memory and assign variables
153  num_regions = C->size();
154 
155  FCsum.resize(num_regions);
156  FCgrad.resize(num_regions, num_els);
158 
159  FCggsum.resize(num_regions);
160  FClapsum.resize(num_regions);
161 
162  FCsum_t.resize(num_regions);
163  FCgrad_t.resize(num_regions);
164  FClap_t.resize(num_regions);
165 
166  Jgrad.resize(num_els);
167  Jlap.resize(num_els);
168 
169  Jgrad_t.resize(num_els);
170  Jlap_t.resize(num_els);
171 
172  // check that F, C dimensions match
173  if (F.size() != num_regions * num_regions)
174  {
175  std::ostringstream err;
176  err << "CountingJastrow::initialize: F, C dimension mismatch: F: " << F.size() << ", C: " << num_regions
177  << std::endl;
178  APP_ABORT(err.str());
179  }
180 
181  // for CountingRegion optimization: don't allocate every evalDeriv call
182  int max_num_derivs = C->max_num_derivs();
183  dCsum.resize(max_num_derivs, num_regions);
184  dCggsum.resize(max_num_derivs, num_regions);
185  dClapsum.resize(max_num_derivs, num_regions);
186  dCFCggsum.resize(max_num_derivs);
187  // register optimizable parameters
188  std::ostringstream os;
189  std::string id_F;
190  for (int I = 0; I < num_regions; ++I)
191  for (int J = I, IJ = I * num_regions + I; J < num_regions; ++J, ++IJ)
192  {
193  os.str("");
194  os << "F_" << I << "_" << J;
195  id_F = os.str();
196  myVars.insert(id_F, F(IJ), (opt_F && I < (num_regions - 1)));
197  opt_index[OPT_F].push_back(IJ);
198  opt_id[OPT_F].push_back(id_F);
199  }
200  myVars.resetIndex();
201  }
std::unique_ptr< RegionType > C
std::vector< RealType > Jlap_t
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
void resetIndex()
reset Index
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
Matrix< RealType > dCggsum
size_type size() const
Definition: OhmmsMatrix.h:76
void insert(const std::string &vname, real_type v, bool enable=true, int type=OTHER_P)
Definition: VariableSet.h:133
std::array< std::vector< std::string >, NUM_OPT_VAR > opt_id
std::vector< RealType > FCggsum
std::vector< RealType > dCFCggsum
std::vector< RealType > FClap_t
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::array< std::vector< int >, NUM_OPT_VAR > opt_index
std::vector< PosType > Jgrad_t
std::vector< RealType > FClapsum
std::complex< double > I
std::vector< RealType > FCsum_t
Matrix< RealType > dClapsum
std::vector< RealType > FCsum
std::vector< RealType > Jlap
std::vector< PosType > FCgrad_t
std::vector< PosType > Jgrad

◆ isOptimizable()

bool isOptimizable ( ) const
inlineoverridevirtual

if true, this contains optimizable components

Reimplemented from WaveFunctionComponent.

Definition at line 106 of file CountingJastrow.h.

References CountingJastrow< RegionType >::opt_C, and CountingJastrow< RegionType >::opt_F.

◆ makeClone()

std::unique_ptr<WaveFunctionComponent> makeClone ( ParticleSet tqp) const
inlineoverridevirtual

make clone

Parameters
tqptarget Quantum ParticleSet
deepcopyif true, make a decopy

If not true, return a proxy class

Reimplemented from WaveFunctionComponent.

Definition at line 467 of file CountingJastrow.h.

References CountingJastrow< RegionType >::C, CountingJastrow< RegionType >::debug, CountingJastrow< RegionType >::debug_period, CountingJastrow< RegionType >::debug_seqlen, CountingJastrow< RegionType >::F, CountingJastrow< RegionType >::opt_C, and CountingJastrow< RegionType >::opt_F.

Referenced by qmcplusplus::TEST_CASE().

468  {
469  auto cjc = std::make_unique<CountingJastrow>(tqp, C->makeClone(), F, opt_C, opt_F);
470  cjc->addDebug(debug, debug_seqlen, debug_period);
471  cjc->initialize();
472  return cjc;
473  }
std::unique_ptr< RegionType > C

◆ ratio()

PsiValue ratio ( ParticleSet P,
int  iat 
)
inlineoverridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value

Parameters
Pthe active ParticleSet
iatthe index of a particle
Returns
$ \psi( \{ {\bf R}^{'} \} )/ \psi( \{ {\bf R}\})$

Specialized for particle-by-particle move

Implements WaveFunctionComponent.

Definition at line 418 of file CountingJastrow.h.

References CountingJastrow< RegionType >::evaluateTempExponents(), qmcplusplus::exp(), CountingJastrow< RegionType >::Jval, and CountingJastrow< RegionType >::Jval_t.

Referenced by qmcplusplus::TEST_CASE().

419  {
420  evaluateTempExponents(P, iat);
421  return std::exp(static_cast<PsiValue>(Jval_t - Jval));
422  }
void evaluateTempExponents(ParticleSet &P, int iat)
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)

◆ ratioGrad()

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

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

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

Reimplemented from WaveFunctionComponent.

Definition at line 388 of file CountingJastrow.h.

References CountingJastrow< RegionType >::evaluateTempExponents(), qmcplusplus::exp(), CountingJastrow< RegionType >::Jgrad_t, CountingJastrow< RegionType >::Jval, and CountingJastrow< RegionType >::Jval_t.

Referenced by qmcplusplus::TEST_CASE().

389  {
390  evaluateTempExponents(P, iat);
391  grad_iat += Jgrad_t[iat];
392  return std::exp(static_cast<PsiValue>(Jval_t - Jval));
393  }
void evaluateTempExponents(ParticleSet &P, int iat)
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
std::vector< PosType > Jgrad_t

◆ recompute()

void recompute ( const ParticleSet P)
inlineoverridevirtual

recompute the value of the WaveFunctionComponents which require critical accuracy.

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

Reimplemented from WaveFunctionComponent.

Definition at line 236 of file CountingJastrow.h.

References CountingJastrow< RegionType >::evaluateExponents(), CountingJastrow< RegionType >::Jval, and WaveFunctionComponent::log_value_.

Referenced by qmcplusplus::TEST_CASE().

237  {
239  log_value_ = Jval;
240  }
void evaluateExponents(const ParticleSet &P)

◆ registerData()

void registerData ( ParticleSet P,
WFBufferType buf 
)
inlineoverridevirtual

For particle-by-particle move.

Requests space in the buffer based on the data type sizes of the objects in this class.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 424 of file CountingJastrow.h.

References PooledMemory< T_scalar, Alloc >::add(), PooledMemory< T_scalar, Alloc >::current(), DEBUG_PSIBUFFER, QMCTraits::DIM, CountingJastrow< RegionType >::evaluateLog(), ParticleSet::G, CountingJastrow< RegionType >::Jgrad, CountingJastrow< RegionType >::Jlap, CountingJastrow< RegionType >::Jval, and ParticleSet::L.

425  {
426  LogValue logValue = evaluateLog(P, P.G, P.L);
427  RealType* Jlap_begin = &Jlap[0];
428  RealType* Jlap_end = Jlap_begin + Jlap.size();
429  RealType* Jgrad_begin = &Jgrad[0][0];
430  RealType* Jgrad_end = Jgrad_begin + Jgrad.size() * DIM;
431  DEBUG_PSIBUFFER(" CountingJastrow::registerData", buf.current());
432  buf.add(&Jval, &Jval);
433  buf.add(Jlap_begin, Jlap_end);
434  buf.add(Jgrad_begin, Jgrad_end);
435  DEBUG_PSIBUFFER(" CountingJastrow::registerData", buf.current());
436  }
std::complex< QTFull::RealType > LogValue
#define DEBUG_PSIBUFFER(who, msg)
Definition: Configuration.h:40
QMCTraits::RealType RealType
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
std::vector< RealType > Jlap
std::vector< PosType > Jgrad

◆ reportStatus()

void reportStatus ( std::ostream &  os)
inlineoverridevirtual

print the state, e.g., optimizables

Reimplemented from OptimizableObject.

Definition at line 204 of file CountingJastrow.h.

References CountingJastrow< RegionType >::C, CountingJastrow< RegionType >::debug, CountingJastrow< RegionType >::debug_period, CountingJastrow< RegionType >::debug_seqlen, WaveFunctionComponent::myVars, CountingJastrow< RegionType >::num_regions, VariableSet::print(), and VariableSet::size_of_active().

205  {
206  os << " Number of counting regions: " << num_regions << std::endl;
207  os << " Total optimizable parameters: " << C->total_num_derivs() + myVars.size_of_active() << std::endl;
208  os << " F matrix optimizable parameters: " << myVars.size_of_active() << std::endl;
209  if (debug)
210  {
211  os << " Debug sample sequence length: " << debug_seqlen << std::endl;
212  os << " Debug sample periodicity: " << debug_period << std::endl;
213  }
214  os << std::endl;
215  myVars.print(os, 6, true);
216  os << std::endl;
217  C->reportStatus(os);
218  }
std::unique_ptr< RegionType > C
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
int size_of_active() const
return the number of active variables
Definition: VariableSet.h:78
void print(std::ostream &os, int leftPadSpaces=0, bool printHeader=false) const

◆ resetParametersExclusive()

void resetParametersExclusive ( const opt_variables_type active)
inlineoverridevirtual

reset the parameters during optimizations.

Exclusive, see checkInVariablesExclusive

Implements OptimizableObject.

Definition at line 123 of file CountingJastrow.h.

References CountingJastrow< RegionType >::C, CountingJastrow< RegionType >::F, VariableSet::getIndex(), VariableSet::getLoc(), WaveFunctionComponent::myVars, CountingJastrow< RegionType >::num_regions, CountingJastrow< RegionType >::OPT_F, CountingJastrow< RegionType >::opt_id, CountingJastrow< RegionType >::opt_index, VariableSet::size(), and VariableSet::where().

Referenced by qmcplusplus::TEST_CASE().

124  {
125  int ia, IJ, JI;
126  std::string id;
127  myVars.getIndex(active);
128  for (int i = 0; i < myVars.size(); ++i)
129  {
130  ia = myVars.where(i);
131  if (ia != -1)
132  myVars[i] = active[ia];
133  }
134  // set F parameters from myVars
135  for (int oi = 0; oi < opt_index[OPT_F].size(); ++oi)
136  {
137  IJ = opt_index[OPT_F][oi];
138  JI = num_regions * (IJ % num_regions) + IJ / num_regions;
139  id = opt_id[OPT_F][oi];
140  ia = active.getLoc(id);
141  myVars[id] = active[ia];
142  F(IJ) = std::real(myVars[id]);
143  F(JI) = std::real(myVars[id]);
144  }
145  // reset parameters for counting regions
146  C->resetParameters(active);
147  }
QMCTraits::RealType real
std::unique_ptr< RegionType > C
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::array< std::vector< std::string >, NUM_OPT_VAR > opt_id
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
std::array< std::vector< int >, NUM_OPT_VAR > opt_index
size_type size() const
return the size
Definition: VariableSet.h:88
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter

◆ restore()

void restore ( int  iat)
inlineoverridevirtual

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

Parameters
iatindex of the particle whose new position was proposed

Ye: hopefully we can gradually move away from restore

Implements WaveFunctionComponent.

Definition at line 416 of file CountingJastrow.h.

References CountingJastrow< RegionType >::C.

416 { C->restore(iat); }
std::unique_ptr< RegionType > C

◆ updateBuffer()

LogValue updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)
inlineoverridevirtual

For particle-by-particle move.

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

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

Implements WaveFunctionComponent.

Definition at line 438 of file CountingJastrow.h.

References PooledMemory< T_scalar, Alloc >::current(), DEBUG_PSIBUFFER, QMCTraits::DIM, CountingJastrow< RegionType >::evaluateLog(), ParticleSet::G, CountingJastrow< RegionType >::Jgrad, CountingJastrow< RegionType >::Jlap, CountingJastrow< RegionType >::Jval, ParticleSet::L, and PooledMemory< T_scalar, Alloc >::put().

439  {
440  LogValue logValue = evaluateLog(P, P.G, P.L);
441  RealType* Jlap_begin = &Jlap[0];
442  RealType* Jlap_end = Jlap_begin + Jlap.size();
443  RealType* Jgrad_begin = &Jgrad[0][0];
444  RealType* Jgrad_end = Jgrad_begin + Jgrad.size() * DIM;
445  DEBUG_PSIBUFFER(" CountingJastrow::updateBuffer ", buf.current());
446  buf.put(&Jval, &Jval);
447  buf.put(Jlap_begin, Jlap_end);
448  buf.put(Jgrad_begin, Jgrad_end);
449  DEBUG_PSIBUFFER(" CountingJastrow::updateBuffer ", buf.current());
450  return Jval;
451  }
std::complex< QTFull::RealType > LogValue
#define DEBUG_PSIBUFFER(who, msg)
Definition: Configuration.h:40
QMCTraits::RealType RealType
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
std::vector< RealType > Jlap
std::vector< PosType > Jgrad

Member Data Documentation

◆ C

◆ dCFCggsum

std::vector<RealType> dCFCggsum
protected

◆ dCggsum

◆ dCindex

std::vector<int> dCindex
protected

Definition at line 77 of file CountingJastrow.h.

◆ dClapsum

◆ dCsum

◆ dCsum_t

std::vector<RealType> dCsum_t
protected

Definition at line 75 of file CountingJastrow.h.

◆ debug

◆ debug_period

◆ debug_seqlen

◆ F

◆ FCggsum

std::vector<RealType> FCggsum
protected

◆ FCgrad

◆ FCgrad_t

◆ FClap

◆ FClap_t

◆ FClapsum

std::vector<RealType> FClapsum
protected

◆ FCsum

◆ FCsum_t

◆ Jgrad

◆ Jgrad_t

◆ Jlap

◆ Jlap_t

◆ Jval

◆ Jval_t

◆ num_els

◆ num_regions

◆ opt_C

◆ opt_F

◆ opt_id

◆ opt_index


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