QMCPACK
SelfHealingOverlapLegacy Class Reference

Class that collects MSD coefficient values via the Self-Healing overlap (legacy driver version) More...

+ Inheritance diagram for SelfHealingOverlapLegacy:
+ Collaboration diagram for SelfHealingOverlapLegacy:

Public Types

using LatticeType = PtclOnLatticeTraits::ParticleLayout
 
using RealType = QMCTraits::RealType
 
using ComplexType = QMCTraits::ComplexType
 
using ValueType = QMCTraits::ValueType
 
using PosType = QMCTraits::PosType
 
- Public Types inherited from OperatorBase
enum  EnergyDomains { KINETIC = 0, POTENTIAL, NO_ENERGY_DOMAIN }
 enum to denote energy domain of operators More...
 
enum  QuantumDomains {
  NO_QUANTUM_DOMAIN = 0, CLASSICAL, QUANTUM, CLASSICAL_CLASSICAL,
  QUANTUM_CLASSICAL, QUANTUM_QUANTUM
}
 
enum  {
  PRIMARY = 0, OPTIMIZABLE = 1, RATIOUPDATE = 2, PHYSICAL = 3,
  COLLECTABLE = 4, NONLOCAL = 5
}
 enum for update_mode More...
 
using Return_t = FullPrecRealType
 type of return value of evaluate More...
 
using ValueMatrix = SPOSet::ValueMatrix
 For fast derivative evaluation. More...
 
using GradMatrix = SPOSet::GradMatrix
 
using BufferType = ParticleSet::Buffer_t
 typedef for the serialized buffer More...
 
using Walker_t = ParticleSet::Walker_t
 typedef for the walker More...
 
using ParticleScalar = ParticleSet::Scalar_t
 typedef for the ParticleScalar More...
 
using SPOMap = SPOSet::SPOMap
 typedef for SPOMap More...
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 SelfHealingOverlapLegacy (TrialWaveFunction &wfn)
 
 ~SelfHealingOverlapLegacy () override
 
std::string getClassName () const override
 return class name More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &P, TrialWaveFunction &psi) final
 
bool put (xmlNodePtr cur) override
 Read the input parameter. More...
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
void addObservables (PropertySetType &plist, BufferType &olist) override
 named values to the property list Default implementaton uses addValue(plist_) More...
 
void registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const override
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
void setObservables (PropertySetType &plist) override
 Set the values evaluated by this object to plist Default implementation is to assign Value which is updated by evaluate function using my_index_. More...
 
void setParticlePropertyList (PropertySetType &plist, int offset) override
 
void checkout_scalar_arrays (TraceManager &tm)
 
void collect_scalar_samples ()
 
void delete_scalar_arrays ()
 
bool get (std::ostream &os) const override
 write about the class More...
 
- Public Member Functions inherited from OperatorBase
 OperatorBase ()
 Construct a new Operator Base object Default and unique empty constructor. More...
 
virtual ~OperatorBase ()=default
 
virtual bool dependsOnWaveFunction () const
 return true if this operator depends on a wavefunction More...
 
std::bitset< 8 > & getUpdateMode () noexcept
 get update_mode_ reference More...
 
Return_t getValue () const noexcept
 get a copy of value_ More...
 
std::string getName () const noexcept
 getter a copy of my_name_, rvalue small string optimization More...
 
void setName (const std::string name) noexcept
 Set my_name member, uses small string optimization (pass by value) More...
 
TraceRequestgetRequest () noexcept
 Get request_ member. More...
 
virtual void registerObservables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 add to observable descriptor for hdf5 The default implementation is to register a scalar for this->value_ More...
 
virtual void setHistories (Walker_t &ThisWalker)
 
virtual Return_t evaluateDeterministic (ParticleSet &P)
 Evaluate the local energy contribution of this component, deterministically based on current state. More...
 
virtual void mw_evaluate (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 Evaluate the contribution of this component of multiple walkers. More...
 
virtual void mw_evaluatePerParticle (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &listeners_ions) const
 Evaluate the contribution of this component of multiple walkers per particle and report to registerd listeners from objects in Estimators. More...
 
virtual void mw_evaluateWithParameterDerivatives (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< ParticleSet > &p_list, const opt_variables_type &optvars, const RecordArray< ValueType > &dlogpsi, RecordArray< ValueType > &dhpsioverpsi) const
 TODO: add docs. More...
 
virtual Return_t rejectedMove (ParticleSet &P)
 TODO: add docs. More...
 
virtual Return_t evaluateWithToperator (ParticleSet &P)
 Evaluate the local energy contribution of this component with Toperators updated if requested. More...
 
virtual void mw_evaluateWithToperator (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 Evaluate the contribution of this component of multiple walkers. More...
 
virtual void mw_evaluatePerParticleWithToperator (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &listeners_ions) const
 Evaluate the contribution of this component of multiple walkers per particle and report to registerd listeners from objects in Estimators. More...
 
virtual Return_t evaluateValueAndDerivatives (ParticleSet &P, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
 Evaluate value and derivatives wrt the optimizables. More...
 
virtual Return_t evaluateWithIonDerivs (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_term, ParticleSet::ParticlePos &pulay_term)
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
virtual Return_t evaluateWithIonDerivsDeterministic (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_term, ParticleSet::ParticlePos &pulay_term)
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
virtual void evaluateOneBodyOpMatrix (ParticleSet &P, const TWFFastDerivWrapper &psi, std::vector< ValueMatrix > &B)
 Evaluate "B" matrix for observable. More...
 
virtual void evaluateOneBodyOpMatrixForceDeriv (ParticleSet &P, ParticleSet &source, const TWFFastDerivWrapper &psi, const int iat, std::vector< std::vector< ValueMatrix >> &Bforce)
 Evaluate "dB/dR" matrices for observable. More...
 
virtual void updateSource (ParticleSet &s)
 Update data associated with a particleset. More...
 
virtual Return_t getEnsembleAverage ()
 Return an average value by collective operation. 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< OperatorBase > &o_list) const
 Acquire a shared resource from a collection. More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const
 Return a shared resource to a collection. More...
 
virtual void setRandomGenerator (RandomBase< FullPrecRealType > *rng)
 Set the Random Generator object TODO: add docs. More...
 
virtual void add2Hamiltonian (ParticleSet &qp, TrialWaveFunction &psi, QMCHamiltonian &targetH)
 TODO: add docs. More...
 
virtual void getRequiredTraces (TraceManager &tm)
 TODO: add docs. More...
 
virtual void informOfPerParticleListener ()
 
bool isClassical () const noexcept
 
bool isQuantum () const noexcept
 
bool isClassicalClassical () const noexcept
 
bool isQuantumClassical () const noexcept
 
bool isQuantumQuantum () const noexcept
 
bool getMode (const int i) const noexcept
 Return the mode i. More...
 
bool isNonLocal () const noexcept
 TODO: add docs. More...
 
bool hasListener () const noexcept
 
void contributeTraceQuantities ()
 Make trace quantities available. More...
 
void checkoutTraceQuantities (TraceManager &tm)
 Checkout trace arrays Derived classes must guard individual checkouts using request info. More...
 
void collectScalarTraces ()
 Collect scalar trace data. More...
 
void deleteTraceQuantities ()
 delete trace arrays More...
 

Public Attributes

size_t ncoef
 
TrialWaveFunctionpsi_ref
 
Vector< ValueTypedet_ratios
 

Additional Inherited Members

- Protected Member Functions inherited from OperatorBase
virtual void contributeScalarQuantities ()
 
virtual void checkoutScalarQuantities (TraceManager &tm)
 
virtual void collectScalarQuantities ()
 
virtual void deleteScalarQuantities ()
 
virtual void contributeParticleQuantities ()
 
virtual void checkoutParticleQuantities (TraceManager &tm)
 
virtual void deleteParticleQuantities ()
 
virtual void setComputeForces (bool compute)
 
void setEnergyDomain (EnergyDomains edomain)
 Set the Energy Domain. More...
 
void setQuantumDomain (QuantumDomains qdomain)
 set quantum domain More...
 
void oneBodyQuantumDomain (const ParticleSet &P)
 set quantum domain for one-body operator More...
 
void twoBodyQuantumDomain (const ParticleSet &P)
 set quantum domain for two-body operator More...
 
void twoBodyQuantumDomain (const ParticleSet &P1, const ParticleSet &P2)
 set quantum domain for two-body operator More...
 
void addValue (PropertySetType &plist)
 named values to the property list More...
 
- Protected Attributes inherited from OperatorBase
std::bitset< 8 > update_mode_
 set the current update mode More...
 
Return_t value_
 current value More...
 
std::string name_
 name of this object More...
 
TraceRequest request_
 whether traces are being collected More...
 
int my_index_
 starting index of this object More...
 
Return_t new_value_
 a new value for a proposed move More...
 
Walker_tt_walker_
 reference to the current walker More...
 
bool streaming_particles_
 
bool have_required_traces_
 

Detailed Description

Class that collects MSD coefficient values via the Self-Healing overlap (legacy driver version)

Definition at line 23 of file SelfHealingOverlapLegacy.h.

Member Typedef Documentation

◆ ComplexType

Definition at line 28 of file SelfHealingOverlapLegacy.h.

◆ LatticeType

◆ PosType

Definition at line 30 of file SelfHealingOverlapLegacy.h.

◆ RealType

Definition at line 27 of file SelfHealingOverlapLegacy.h.

◆ ValueType

Definition at line 29 of file SelfHealingOverlapLegacy.h.

Constructor & Destructor Documentation

◆ SelfHealingOverlapLegacy()

Definition at line 20 of file SelfHealingOverlapLegacy.cpp.

References OperatorBase::COLLECTABLE, TrialWaveFunction::findMSD(), MultiSlaterDetTableMethod::getLinearExpansionCoefs(), OperatorBase::name_, SelfHealingOverlapLegacy::ncoef, and OperatorBase::update_mode_.

21  : psi_ref(wfn)
22 {
23  name_ = "SelfHealingOverlap";
24  update_mode_.set(COLLECTABLE, 1);
25 
26  auto msd_refvec = wfn.findMSD();
27  if (msd_refvec.size() != 1)
28  throw std::runtime_error(
29  "SelfHealingOverlap requires one and only one multi slater determinant component in the trial wavefunction.");
30 
31  const MultiSlaterDetTableMethod& msd = msd_refvec[0];
32 
33  ncoef = msd.getLinearExpansionCoefs().size();
34 }
std::string name_
name of this object
Definition: OperatorBase.h:527
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521

◆ ~SelfHealingOverlapLegacy()

~SelfHealingOverlapLegacy ( )
inlineoverride

Definition at line 39 of file SelfHealingOverlapLegacy.h.

39 {}

Member Function Documentation

◆ addObservables()

void addObservables ( PropertySetType plist,
BufferType collectables 
)
overridevirtual

named values to the property list Default implementaton uses addValue(plist_)

Parameters
plistRecordNameProperty
collectablesObservables that are accumulated by evaluate

Reimplemented from OperatorBase.

Definition at line 53 of file SelfHealingOverlapLegacy.cpp.

References PooledData< T >::add(), PooledData< T >::current(), OperatorBase::my_index_, and SelfHealingOverlapLegacy::ncoef.

54 {
55  my_index_ = collectables.current();
56  std::vector<RealType> tmp(ncoef);
57  collectables.add(tmp.begin(), tmp.end());
58 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535

◆ checkout_scalar_arrays()

void checkout_scalar_arrays ( TraceManager tm)
inline

Definition at line 56 of file SelfHealingOverlapLegacy.h.

56 {}

◆ collect_scalar_samples()

void collect_scalar_samples ( )
inline

Definition at line 57 of file SelfHealingOverlapLegacy.h.

57 {}

◆ delete_scalar_arrays()

void delete_scalar_arrays ( )
inline

Definition at line 58 of file SelfHealingOverlapLegacy.h.

58 {}

◆ evaluate()

SelfHealingOverlapLegacy::Return_t evaluate ( ParticleSet P)
overridevirtual

Evaluate the local energy contribution of this component.

Parameters
Pinput configuration containing N particles
Returns
the value of the Hamiltonian component

Implements OperatorBase.

Definition at line 71 of file SelfHealingOverlapLegacy.cpp.

References MultiSlaterDetTableMethod::calcIndividualDetRatios(), ParticleSet::Collectables, SelfHealingOverlapLegacy::det_ratios, qmcplusplus::exp(), TrialWaveFunction::findMSD(), TrialWaveFunction::getOrbitals(), OperatorBase::my_index_, SelfHealingOverlapLegacy::ncoef, SelfHealingOverlapLegacy::psi_ref, qmcplusplus::real(), Vector< T, Alloc >::size(), OperatorBase::t_walker_, and Walker< t_traits, p_traits >::Weight.

72 {
73  RealType weight = t_walker_->Weight;
74  int offset = my_index_;
75  auto& wcs = psi_ref.getOrbitals();
76 
77  // separate jastrow and fermi wavefunction components
78  std::vector<WaveFunctionComponent*> wcs_jastrow;
79  std::vector<WaveFunctionComponent*> wcs_fermi;
80  for (auto& wc : wcs)
81  if (wc->isFermionic())
82  wcs_fermi.push_back(wc.get());
83  else
84  wcs_jastrow.push_back(wc.get());
85  auto msd_refvec = psi_ref.findMSD();
86  MultiSlaterDetTableMethod& msd = msd_refvec[0];
87 
88  // fermionic must have only one component, and must be multideterminant
89  assert(wcs_fermi.size() == 1);
90  WaveFunctionComponent& wf = *wcs_fermi[0];
91  if (!wf.isMultiDet())
92  throw std::runtime_error("SelfHealingOverlap estimator requires use of multideterminant wavefunction");
93 
94  // collect parameter derivatives: (dpsi/dc_i)/psi
95  msd.calcIndividualDetRatios(det_ratios);
96 
97  // collect jastrow prefactor
99  for (auto& wc : wcs_jastrow)
100  Jval += wc->get_log_value();
101  auto Jprefactor = std::real(std::exp(-2. * Jval));
102 
103  // accumulate data
104  assert(det_ratios.size() == ncoef);
105  for (int ic = 0; ic < det_ratios.size(); ++ic)
106  P.Collectables[offset+ic] += weight * Jprefactor * real(det_ratios[ic]); // only real supported for now
107 
108  return 0.0;
109 }
QMCTraits::RealType real
int my_index_
starting index of this object
Definition: OperatorBase.h:535
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
RefVector< MultiSlaterDetTableMethod > findMSD() const
find MSD WFCs if exist
std::complex< QTFull::RealType > LogValue
size_type size() const
return the current size
Definition: OhmmsVector.h:162
std::vector< std::unique_ptr< WaveFunctionComponent > > const & getOrbitals()
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
Walker_t * t_walker_
reference to the current walker
Definition: OperatorBase.h:541
QMCTraits::RealType RealType
FullPrecRealType Weight
Weight of the walker.
Definition: Walker.h:102

◆ get()

bool get ( std::ostream &  os) const
inlineoverridevirtual

write about the class

Implements OperatorBase.

Definition at line 62 of file SelfHealingOverlapLegacy.h.

62 { return false; }

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 42 of file SelfHealingOverlapLegacy.h.

42 { return "SelfHealingOverlapLegacy"; }

◆ makeClone()

std::unique_ptr< OperatorBase > makeClone ( ParticleSet P,
TrialWaveFunction psi 
)
finalvirtual

Implements OperatorBase.

Definition at line 37 of file SelfHealingOverlapLegacy.cpp.

38 {
39  return std::make_unique<SelfHealingOverlapLegacy>(psi);
40 }

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

Read the input parameter.

Parameters
curxml node for a OperatorBase object

Implements OperatorBase.

Definition at line 43 of file SelfHealingOverlapLegacy.cpp.

References OhmmsAttributeSet::add(), OperatorBase::name_, and OhmmsAttributeSet::put().

44 {
45  OhmmsAttributeSet attrib;
46  attrib.add(name_, "name");
47  attrib.put(cur);
48  return true;
49 }
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::string name_
name of this object
Definition: OperatorBase.h:527
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42

◆ registerCollectables()

void registerCollectables ( std::vector< ObservableHelper > &  h5desc,
hdf_archive file 
) const
overridevirtual

Reimplemented from OperatorBase.

Definition at line 61 of file SelfHealingOverlapLegacy.cpp.

References OperatorBase::my_index_, and SelfHealingOverlapLegacy::ncoef.

62 {
63  std::vector<int> ng(1);
64  ng[0] = ncoef;
65  h5desc.push_back({{"sh_coeff"}});
66  auto& h5o = h5desc.back();
67  h5o.set_dimensions(ng, my_index_);
68 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
inlineoverridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 52 of file SelfHealingOverlapLegacy.h.

52 {}

◆ setObservables()

void setObservables ( PropertySetType plist)
inlineoverridevirtual

Set the values evaluated by this object to plist Default implementation is to assign Value which is updated by evaluate function using my_index_.

Parameters
plistRecordNameProperty

Reimplemented from OperatorBase.

Definition at line 53 of file SelfHealingOverlapLegacy.h.

53 {}

◆ setParticlePropertyList()

void setParticlePropertyList ( PropertySetType plist,
int  offset 
)
inlineoverridevirtual

Reimplemented from OperatorBase.

Definition at line 54 of file SelfHealingOverlapLegacy.h.

54 {}

Member Data Documentation

◆ det_ratios

Vector<ValueType> det_ratios

Definition at line 35 of file SelfHealingOverlapLegacy.h.

Referenced by SelfHealingOverlapLegacy::evaluate().

◆ ncoef

◆ psi_ref

Definition at line 34 of file SelfHealingOverlapLegacy.h.

Referenced by SelfHealingOverlapLegacy::evaluate().


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