QMCPACK
Hamiltonian group

QMCHamiltonian and its component, OperatorBase. More...

Classes

class  BareKineticEnergy
 Evaluate the kinetic energy with a single mass. More...
 
struct  CoulombPBCAA
 Calculates the AA Coulomb potential using PBCs. More...
 
class  CoulombPBCAB
 Calculates the AA Coulomb potential using PBCs. More...
 
struct  L2Potential
 Evaluate the L2 potentials around each ion. More...
 
struct  LocalECPotential
 Evaluate the local potentials (either pseudo or full core) around each ion. More...
 
class  MPC
 Calculates the Model Periodic Coulomb potential using PBCs. More...
 
class  NonLocalECPotential
 Evaluate the semi local potentials. More...
 
class  OperatorBase
 An abstract class for Local Energy operators. More...
 
struct  Pressure
 Evaluate the Bare Pressure. More...
 
class  SpaceWarpTransformation
 This implements the differential space warp transformation for ZVZB estimators given by Sorella & Capriotti J. More...
 

Detailed Description

QMCHamiltonian and its component, OperatorBase.


Class Documentation

◆ qmcplusplus::BareKineticEnergy

class qmcplusplus::BareKineticEnergy

Evaluate the kinetic energy with a single mass.

The unit of the mass is AU, i.e., the electron mass $ m_e = 1 $. To evaluate the Bare Kinetic part of the local energy $E_L({\bf R}) = \Psi^{-1}({\bf R})\hat{H}\Psi({\bf R}),$ it is useful to use the following trick

\begin{eqnarray*} \nabla^2\Psi({\bf R}) &=& \nabla^2(\exp(\ln \Psi({\bf R})))\\ &=&\nabla\cdot(\nabla\exp(\ln \Psi({\bf R}))) \\ &=&\nabla\cdot(\nabla\ln \Psi({\bf R}))\exp(\ln \Psi({\bf R}))\\ -\frac{1}{2}\frac{\nabla^2\Psi({\bf R})}{\Psi({\bf R})} &=& -\frac{1}{2}\nabla^2\ln \Psi({\bf R}) -\frac{1}{2}(\nabla\ln \Psi({\bf R}))^2 \end{eqnarray*}

Definition at line 43 of file BareKineticEnergy.h.

+ Inheritance diagram for BareKineticEnergy:
+ Collaboration diagram for BareKineticEnergy:

Public Member Functions

 BareKineticEnergy (ParticleSet &p, TrialWaveFunction &psi)
 constructor with particleset More...
 
 ~BareKineticEnergy () override
 destructor More...
 
bool dependsOnWaveFunction () const override
 return true if this operator depends on a wavefunction More...
 
std::string getClassName () const override
 return class name More...
 
void resetTargetParticleSet (ParticleSet &p) override
 Reset the data with the target ParticleSet. More...
 
void contributeParticleQuantities () override
 
void checkoutParticleQuantities (TraceManager &tm) override
 
void deleteParticleQuantities () override
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
Return_t evaluateValueAndDerivatives (ParticleSet &P, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
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 override
 
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 >> &ion_listeners) const override
 Evaluate the contribution of this component for multiple walkers reporting to registered listeners from Estimators. More...
 
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 >> &ion_listeners) const override
 For BareKineticEnergy since it does override any Toperator evals this needs to decay to mw_evaluatePerParticle. More...
 
Return_t evaluateWithIonDerivs (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms) override
 Function to compute the value, direct ionic gradient terms, and pulay terms for the local kinetic energy. More...
 
void evaluateOneBodyOpMatrix (ParticleSet &P, const TWFFastDerivWrapper &psi, std::vector< ValueMatrix > &B) override
 Evaluate "B" matrix for observable. More...
 
void evaluateOneBodyOpMatrixForceDeriv (ParticleSet &P, ParticleSet &source, const TWFFastDerivWrapper &psi, const int iat, std::vector< std::vector< ValueMatrix >> &Bforce) override
 Evaluate "dB/dR" matrices for observable. More...
 
Return_t evaluate_sp (ParticleSet &P)
 
Return_t evaluate_orig (ParticleSet &P)
 
bool put (xmlNodePtr) override
 implements the virtual function. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) final
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
 return a shared resource to a collection More...
 
- Public Member Functions inherited from OperatorBase
 OperatorBase ()
 Construct a new Operator Base object Default and unique empty constructor. More...
 
virtual ~OperatorBase ()=default
 
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 addObservables (PropertySetType &plist, BufferType &collectables)
 named values to the property list Default implementaton uses addValue(plist_) 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 registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 
virtual void setObservables (PropertySetType &plist)
 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...
 
virtual void setParticlePropertyList (PropertySetType &plist, int offset)
 
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 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 updateSource (ParticleSet &s)
 Update data associated with a particleset. More...
 
virtual Return_t getEnsembleAverage ()
 Return an average value by collective operation. 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...
 

Private Attributes

bool same_mass_
 true, if all the species have the same mass More...
 
FullPrecRealType particle_mass_
 mass of the particle More...
 
FullPrecRealType one_over_2m_
 $ 1/(2 m^*) $ More...
 
std::vector< FullPrecRealTypeminus_over_2m_
 minus_over_2m_[i] = $ -1/2m[i]$ for the ith species More...
 
Array< TraceReal, 1 > * t_sample_
 
Array< TraceComp, 1 > * t_sample_comp_
 
Array< TraceComp, 2 > * p_sample_
 
ParticleSetps_
 
ResourceHandle< MultiWalkerResourcemw_res_
 
TrialWaveFunctionpsi_
 

Additional Inherited Members

- 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 > >
 
- Protected Member Functions inherited from OperatorBase
virtual void contributeScalarQuantities ()
 
virtual void checkoutScalarQuantities (TraceManager &tm)
 
virtual void collectScalarQuantities ()
 
virtual void deleteScalarQuantities ()
 
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_
 

Constructor & Destructor Documentation

◆ BareKineticEnergy()

constructor with particleset

Parameters
targetparticleset

Store mass per species and use SameMass to choose the methods. if SameMass, probably faster and easy to vectorize but no impact on the performance.

Definition at line 47 of file BareKineticEnergy.cpp.

References qmcplusplus::abs(), qmcplusplus::Units::charge::e, ParticleSet::getSpeciesSet(), OperatorBase::KINETIC, BareKineticEnergy::minus_over_2m_, BareKineticEnergy::one_over_2m_, OperatorBase::oneBodyQuantumDomain(), OperatorBase::OPTIMIZABLE, BareKineticEnergy::particle_mass_, BareKineticEnergy::same_mass_, OperatorBase::setEnergyDomain(), and OperatorBase::update_mode_.

47  : ps_(p), psi_(psi)
48 {
51  update_mode_.set(OPTIMIZABLE, 1);
52  SpeciesSet& tspecies(p.getSpeciesSet());
53  minus_over_2m_.resize(tspecies.size());
54  int massind = tspecies.addAttribute("mass");
55  same_mass_ = true;
56  particle_mass_ = tspecies(massind, 0);
58  for (int i = 0; i < tspecies.size(); ++i)
59  {
60  same_mass_ &= (std::abs(tspecies(massind, i) - particle_mass_) < 1e-6);
61  minus_over_2m_[i] = -1.0 / (2.0 * tspecies(massind, i));
62  }
63 }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
FullPrecRealType particle_mass_
mass of the particle
bool same_mass_
true, if all the species have the same mass
void oneBodyQuantumDomain(const ParticleSet &P)
set quantum domain for one-body operator
void setEnergyDomain(EnergyDomains edomain)
Set the Energy Domain.
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521

◆ ~BareKineticEnergy()

~BareKineticEnergy ( )
overridedefault

destructor

Member Function Documentation

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
overridevirtual

acquire a shared resource from a collection

Reimplemented from OperatorBase.

Definition at line 446 of file BareKineticEnergy.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), ResourceCollection::lendResource(), and BareKineticEnergy::mw_res_.

448 {
449  auto& O_leader = o_list.getCastedLeader<BareKineticEnergy>();
450  O_leader.mw_res_ = collection.lendResource<MultiWalkerResource>();
451 }
BareKineticEnergy(ParticleSet &p, TrialWaveFunction &psi)
constructor with particleset

◆ checkoutParticleQuantities()

void checkoutParticleQuantities ( TraceManager tm)
overridevirtual

Reimplemented from OperatorBase.

Definition at line 82 of file BareKineticEnergy.cpp.

References TraceManager::checkout_complex(), TraceManager::checkout_real(), QMCTraits::DIM, OperatorBase::name_, BareKineticEnergy::p_sample_, BareKineticEnergy::ps_, OperatorBase::request_, TraceRequest::streaming_array(), OperatorBase::streaming_particles_, BareKineticEnergy::t_sample_, and BareKineticEnergy::t_sample_comp_.

83 {
85  request_.streaming_array("momentum");
87  {
88  t_sample_ = tm.checkout_real<1>(name_, ps_);
89  t_sample_comp_ = tm.checkout_complex<1>(name_ + "_complex", ps_);
90  p_sample_ = tm.checkout_complex<2>("momentum", ps_, DIM);
91  }
92 }
bool streaming_array(const std::string &name)
Definition: TraceManager.h:249
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
std::string name_
name of this object
Definition: OperatorBase.h:527
Array< TraceComp, 1 > * t_sample_comp_
Array< TraceComp, 2 > * p_sample_
Array< TraceReal, 1 > * t_sample_

◆ contributeParticleQuantities()

void contributeParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 75 of file BareKineticEnergy.cpp.

References TraceRequest::contribute_array(), OperatorBase::name_, and OperatorBase::request_.

76 {
78  request_.contribute_array(name_ + "_complex");
79  request_.contribute_array("momentum");
80 }
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
std::string name_
name of this object
Definition: OperatorBase.h:527
void contribute_array(const std::string &name, bool default_quantity=false)
Definition: TraceManager.h:198

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from OperatorBase.

Definition at line 440 of file BareKineticEnergy.cpp.

References ResourceCollection::addResource().

Referenced by qmcplusplus::testElecCase().

441 {
442  auto new_res = std::make_unique<MultiWalkerResource>();
443  auto resource_index = collection.addResource(std::move(new_res));
444 }

◆ deleteParticleQuantities()

void deleteParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 94 of file BareKineticEnergy.cpp.

References BareKineticEnergy::p_sample_, OperatorBase::streaming_particles_, BareKineticEnergy::t_sample_, and BareKineticEnergy::t_sample_comp_.

95 {
97  {
98  delete t_sample_;
99  delete t_sample_comp_;
100  delete p_sample_;
101  }
102 }
Array< TraceComp, 1 > * t_sample_comp_
Array< TraceComp, 2 > * p_sample_
Array< TraceReal, 1 > * t_sample_

◆ dependsOnWaveFunction()

bool dependsOnWaveFunction ( ) const
overridevirtual

return true if this operator depends on a wavefunction

Reimplemented from OperatorBase.

Definition at line 68 of file BareKineticEnergy.cpp.

68 { return true; }

◆ evaluate()

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 106 of file BareKineticEnergy.cpp.

References qmcplusplus::CplxDot(), qmcplusplus::CplxSum(), qmcplusplus::Dot(), BareKineticEnergy::evaluate_sp(), ParticleSet::first(), ParticleSet::G, ParticleSet::L, qmcplusplus::laplacian(), ParticleSet::last(), BareKineticEnergy::minus_over_2m_, BareKineticEnergy::one_over_2m_, BareKineticEnergy::same_mass_, OperatorBase::streaming_particles_, qmcplusplus::Sum(), and OperatorBase::value_.

Referenced by BareKineticEnergy::evaluateValueAndDerivatives(), and qmcplusplus::TEST_CASE().

107 {
108 #if !defined(REMOVE_TRACEMANAGER)
110  {
111  value_ = evaluate_sp(P);
112  }
113  else
114 #endif
115  if (same_mass_)
116  {
117 #ifdef QMC_COMPLEX
118  value_ = std::real(CplxDot(P.G, P.G) + CplxSum(P.L));
119  value_ *= -one_over_2m_;
120 #else
121  value_ = Dot(P.G, P.G) + Sum(P.L);
122  value_ *= -one_over_2m_;
123 #endif
124  }
125  else
126  {
127  value_ = 0.0;
128  for (int i = 0; i < minus_over_2m_.size(); ++i)
129  {
130  Return_t x = 0.0;
131  for (int j = P.first(i); j < P.last(i); ++j)
132  x += laplacian(P.G[j], P.L[j]);
133  value_ += x * minus_over_2m_[i];
134  }
135  }
136  return value_;
137 }
T Sum(const ParticleAttrib< T > &pa)
std::complex< T > CplxDot(const ParticleAttrib< TinyVector< std::complex< T >, D >> &pa, const ParticleAttrib< TinyVector< std::complex< T >, D >> &pb)
QMCTraits::RealType real
std::complex< T > CplxSum(const ParticleAttrib< std::complex< T >> &pa)
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
bool same_mass_
true, if all the species have the same mass
T laplacian(const TinyVector< T, D > &g, T l)
compute real(laplacian)
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Return_t value_
current value
Definition: OperatorBase.h:524
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species
Return_t evaluate_sp(ParticleSet &P)

◆ evaluate_orig()

Return_t evaluate_orig ( ParticleSet P)

Definition at line 599 of file BareKineticEnergy.cpp.

References qmcplusplus::Dot(), ParticleSet::first(), ParticleSet::G, ParticleSet::L, qmcplusplus::laplacian(), ParticleSet::last(), BareKineticEnergy::minus_over_2m_, BareKineticEnergy::one_over_2m_, BareKineticEnergy::same_mass_, qmcplusplus::Sum(), and OperatorBase::value_.

Referenced by BareKineticEnergy::evaluate_sp().

600 {
601  if (same_mass_)
602  {
603  value_ = Dot(P.G, P.G) + Sum(P.L);
604  value_ *= -one_over_2m_;
605  }
606  else
607  {
608  value_ = 0.0;
609  for (int i = 0; i < minus_over_2m_.size(); ++i)
610  {
611  Return_t x = 0.0;
612  for (int j = P.first(i); j < P.last(i); ++j)
613  x += laplacian(P.G[j], P.L[j]);
614  value_ += x * minus_over_2m_[i];
615  }
616  }
617  return value_;
618 }
T Sum(const ParticleAttrib< T > &pa)
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
bool same_mass_
true, if all the species have the same mass
T laplacian(const TinyVector< T, D > &g, T l)
compute real(laplacian)
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Return_t value_
current value
Definition: OperatorBase.h:524
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species

◆ evaluate_sp()

Return_t evaluate_sp ( ParticleSet P)

Definition at line 537 of file BareKineticEnergy.cpp.

References qmcplusplus::abs(), APP_ABORT, qmcplusplus::app_log(), QMCTraits::DIM, qmcplusplus::dot(), BareKineticEnergy::evaluate_orig(), ParticleSet::first(), ParticleSet::G, ParticleSet::getTotalNum(), ParticleSet::L, ParticleSet::last(), BareKineticEnergy::minus_over_2m_, BareKineticEnergy::one_over_2m_, BareKineticEnergy::p_sample_, qmcplusplus::real(), qmcplusplus::Units::time::s, BareKineticEnergy::same_mass_, Array< T, D, ALLOC >::sum(), BareKineticEnergy::t_sample_, BareKineticEnergy::t_sample_comp_, TraceManager::trace_tol, and OperatorBase::value_.

Referenced by BareKineticEnergy::evaluate().

538 {
539  Array<RealType, 1>& T_samp = *t_sample_;
540  Array<std::complex<RealType>, 1>& T_samp_comp = *t_sample_comp_;
542  std::complex<RealType> t1 = 0.0;
543  const RealType clambda(-one_over_2m_);
544  value_ = 0.0;
545  if (same_mass_)
546  {
547  for (int i = 0; i < P.getTotalNum(); i++)
548  {
549  t1 = P.L[i] + dot(P.G[i], P.G[i]);
550  t1 = clambda * t1;
551  T_samp(i) = real(t1);
552  T_samp_comp(i) = t1;
553  for (int d = 0; d < DIM; ++d)
554  p_samp(i, d) = P.G[i][d];
555  value_ += real(t1);
556  }
557  }
558  else
559  {
560  for (int s = 0; s < minus_over_2m_.size(); ++s)
561  {
562  FullPrecRealType mlambda = minus_over_2m_[s];
563  for (int i = P.first(s); i < P.last(s); ++i)
564  {
565  t1 = P.L[i] + dot(P.G[i], P.G[i]);
566  t1 *= mlambda;
567  T_samp(i) = real(t1);
568  T_samp_comp(i) = t1;
569  for (int d = 0; d < DIM; ++d)
570  p_samp(i, d) = P.G[i][d];
571  value_ += real(t1);
572  }
573  }
574  }
575 #if defined(TRACE_CHECK)
576  RealType Vnow = value_;
577  RealType Vsum = T_samp.sum();
578  RealType Vold = evaluate_orig(P);
579  if (std::abs(Vsum - Vnow) > TraceManager::trace_tol)
580  {
581  app_log() << "accumtest: BareKineticEnergy::evaluate()" << std::endl;
582  app_log() << "accumtest: tot:" << Vnow << std::endl;
583  app_log() << "accumtest: sum:" << Vsum << std::endl;
584  APP_ABORT("Trace check failed");
585  }
586  if (std::abs(Vold - Vnow) > TraceManager::trace_tol)
587  {
588  app_log() << "versiontest: BareKineticEnergy::evaluate()" << std::endl;
589  app_log() << "versiontest: orig:" << Vold << std::endl;
590  app_log() << "versiontest: mod:" << Vnow << std::endl;
591  APP_ABORT("Trace check failed");
592  }
593 #endif
594  return value_;
595 }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
Return_t evaluate_orig(ParticleSet &P)
std::ostream & app_log()
Definition: OutputManager.h:65
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
bool same_mass_
true, if all the species have the same mass
Array< TraceComp, 1 > * t_sample_comp_
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
Type_t sum() const
Definition: OhmmsArray.h:214
Array< TraceComp, 2 > * p_sample_
QMCTraits::RealType RealType
Return_t value_
current value
Definition: OperatorBase.h:524
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
Array< TraceReal, 1 > * t_sample_

◆ evaluateOneBodyOpMatrix()

void evaluateOneBodyOpMatrix ( ParticleSet P,
const TWFFastDerivWrapper psi,
std::vector< ValueMatrix > &  B 
)
overridevirtual

Evaluate "B" matrix for observable.

Filippi scheme for computing fast derivatives.

Parameters
[in]Ptarget particle set (electrons)
[in]psi,TrialWavefunction wrapper for fast derivatives.
[in,out]B.List of B matrices for each species.
Returns
Void

Reimplemented from OperatorBase.

Definition at line 285 of file BareKineticEnergy.cpp.

References B(), qmcplusplus::dot(), TWFFastDerivWrapper::evaluateJastrowVGL(), ParticleSet::first(), TWFFastDerivWrapper::getEGradELaplM(), ParticleSet::getTotalNum(), TWFFastDerivWrapper::getTWFGroupIndex(), ParticleSet::groups(), ParticleSet::last(), BareKineticEnergy::minus_over_2m_, TWFFastDerivWrapper::numOrbitals(), and Vector< T, Alloc >::resize().

288 {
291 
292  const IndexType nelec = P.getTotalNum();
293  G.resize(nelec);
294  L.resize(nelec);
295 
296  const IndexType ngroups = P.groups();
297  assert(B.size() == ngroups);
298  std::vector<ValueMatrix> M;
299  std::vector<GradMatrix> grad_M;
300  std::vector<ValueMatrix> lapl_M;
301  std::vector<ValueMatrix> gradJdotgradPhi;
302  for (int ig = 0; ig < ngroups; ig++)
303  {
304  const IndexType sid = psi.getTWFGroupIndex(ig);
305  const IndexType norbs = psi.numOrbitals(sid);
306  const IndexType first = P.first(ig);
307  const IndexType last = P.last(ig);
308  const IndexType nptcls = last - first;
309  ValueMatrix zeromat;
310  GradMatrix zerogradmat;
311 
312  zeromat.resize(nptcls, norbs);
313  zerogradmat.resize(nptcls, norbs);
314 
315  M.push_back(zeromat);
316  grad_M.push_back(zerogradmat);
317  lapl_M.push_back(zeromat);
318  gradJdotgradPhi.push_back(zeromat);
319  }
320 
321  psi.getEGradELaplM(P, M, grad_M, lapl_M);
322  psi.evaluateJastrowVGL(P, G, L);
323 
324  for (int ig = 0; ig < ngroups; ig++)
325  {
326  const IndexType sid = psi.getTWFGroupIndex(ig);
327  const IndexType norbs = psi.numOrbitals(sid);
328  const IndexType first = P.first(ig);
329  const IndexType last = P.last(ig);
330  const IndexType nptcls = last - first;
331  for (int iel = first; iel < last; iel++)
332  {
333  for (int iorb = 0; iorb < norbs; iorb++)
334  {
335  gradJdotgradPhi[sid][iel - first][iorb] = RealType(2.0) * dot(GradType(G[iel]), grad_M[sid][iel - first][iorb]);
336  B[sid][iel - first][iorb] += RealType(minus_over_2m_[ig]) *
337  (lapl_M[sid][iel - first][iorb] + gradJdotgradPhi[sid][iel - first][iorb] +
338  ValueType(L[iel] + dot(G[iel], G[iel])) * M[sid][iel - first][iorb]);
339  }
340  }
341  }
342 }
QTBase::GradType GradType
Definition: Configuration.h:62
QTBase::RealType RealType
Definition: Configuration.h:58
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
SPOSet::GradMatrix GradMatrix
Definition: OperatorBase.h:69
QTBase::ValueType ValueType
Definition: Configuration.h:60
SPOSet::ValueMatrix ValueMatrix
For fast derivative evaluation.
Definition: OperatorBase.h:68
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
double B(double x, int k, int i, const std::vector< double > &t)

◆ evaluateOneBodyOpMatrixForceDeriv()

void evaluateOneBodyOpMatrixForceDeriv ( ParticleSet P,
ParticleSet source,
const TWFFastDerivWrapper psi,
const int  iat,
std::vector< std::vector< ValueMatrix >> &  Bforce 
)
overridevirtual

Evaluate "dB/dR" matrices for observable.

Filippi scheme for computing fast derivatives.

Parameters
[in]P,targetparticle set (electrons)
[in]source,ionparticle set
[in]psi,TrialWavefunction wrapper for fast derivatives.
[in]iat

Reimplemented from OperatorBase.

Definition at line 344 of file BareKineticEnergy.cpp.

References qmcplusplus::dot(), TWFFastDerivWrapper::evaluateJastrowGradSource(), TWFFastDerivWrapper::evaluateJastrowVGL(), ParticleSet::first(), TWFFastDerivWrapper::getEGradELaplM(), TWFFastDerivWrapper::getIonGradIonGradELaplM(), ParticleSet::getTotalNum(), TWFFastDerivWrapper::getTWFGroupIndex(), ParticleSet::groups(), ParticleSet::last(), BareKineticEnergy::minus_over_2m_, TWFFastDerivWrapper::numOrbitals(), OHMMS_DIM, and Vector< T, Alloc >::resize().

349 {
350  const IndexType ngroups = P.groups();
351  const IndexType nelec = P.getTotalNum();
352 
355  Gtmp.resize(nelec);
356  G.resize(nelec);
357  Ltmp.resize(nelec);
358  L.resize(nelec);
359 
360  std::vector<ValueMatrix> M;
361  std::vector<GradMatrix> grad_M;
362  std::vector<ValueMatrix> lapl_M;
363 
366 
367  for (int dim = 0; dim < OHMMS_DIM; dim++)
368  {
369  dG[dim] = Gtmp;
370  dL[dim] = Ltmp;
371  }
372 
373  assert(Bforce.size() == OHMMS_DIM);
374  assert(Bforce[0].size() == ngroups);
375  std::vector<ValueMatrix> mtmp;
376  for (int ig = 0; ig < ngroups; ig++)
377  {
378  const IndexType sid = psi.getTWFGroupIndex(ig);
379  const IndexType norbs = psi.numOrbitals(sid);
380  const IndexType first = P.first(ig);
381  const IndexType last = P.last(ig);
382  const IndexType nptcls = last - first;
383 
384  ValueMatrix zeromat;
385  GradMatrix zerogradmat;
386 
387  zeromat.resize(nptcls, norbs);
388  zerogradmat.resize(nptcls, norbs);
389 
390  mtmp.push_back(zeromat);
391  M.push_back(zeromat);
392  grad_M.push_back(zerogradmat);
393  lapl_M.push_back(zeromat);
394  }
395 
396 
397  std::vector<std::vector<ValueMatrix>> dm, dlapl;
398  std::vector<std::vector<GradMatrix>> dgmat;
399  dm.push_back(mtmp);
400  dm.push_back(mtmp);
401  dm.push_back(mtmp);
402 
403  dlapl.push_back(mtmp);
404  dlapl.push_back(mtmp);
405  dlapl.push_back(mtmp);
406 
407  dgmat.push_back(grad_M);
408  dgmat.push_back(grad_M);
409  dgmat.push_back(grad_M);
410 
411  psi.getEGradELaplM(P, M, grad_M, lapl_M);
412  psi.getIonGradIonGradELaplM(P, source, iat, dm, dgmat, dlapl);
413  psi.evaluateJastrowVGL(P, G, L);
414  psi.evaluateJastrowGradSource(P, source, iat, dG, dL);
415  for (int idim = 0; idim < OHMMS_DIM; idim++)
416  for (int ig = 0; ig < ngroups; ig++)
417  {
418  const IndexType sid = psi.getTWFGroupIndex(ig);
419  const IndexType norbs = psi.numOrbitals(sid);
420  const IndexType first = P.first(ig);
421  const IndexType last = P.last(ig);
422  const IndexType nptcls = last - first;
423 
424  for (int iel = first; iel < last; iel++)
425  {
426  for (int iorb = 0; iorb < norbs; iorb++)
427  {
428  Bforce[idim][sid][iel - first][iorb] = RealType(minus_over_2m_[ig]) *
429  (dlapl[idim][sid][iel - first][iorb] +
430  RealType(2.0) *
431  (dot(GradType(G[iel]), dgmat[idim][sid][iel - first][iorb]) +
432  dot(GradType(dG[idim][iel]), grad_M[sid][iel - first][iorb])) +
433  M[sid][iel - first][iorb] * ValueType(dL[idim][iel] + 2.0 * dot(dG[idim][iel], G[iel])) +
434  ValueType(L[iel] + dot(G[iel], G[iel])) * dm[idim][sid][iel - first][iorb]);
435  }
436  }
437  }
438 }
QTBase::GradType GradType
Definition: Configuration.h:62
QTBase::RealType RealType
Definition: Configuration.h:58
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
SPOSet::GradMatrix GradMatrix
Definition: OperatorBase.h:69
#define OHMMS_DIM
Definition: config.h:64
QTBase::ValueType ValueType
Definition: Configuration.h:60
SPOSet::ValueMatrix ValueMatrix
For fast derivative evaluation.
Definition: OperatorBase.h:68
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95

◆ evaluateValueAndDerivatives()

Return_t evaluateValueAndDerivatives ( ParticleSet P,
const opt_variables_type optvars,
const Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
override

Definition at line 139 of file BareKineticEnergy.cpp.

References BareKineticEnergy::evaluate(), TrialWaveFunction::evaluateDerivatives(), and BareKineticEnergy::psi_.

143 {
144  // const_cast is needed because TWF::evaluateDerivatives calculates dlogpsi.
145  // KineticEnergy must be the first element in the hamiltonian array.
146  psi_.evaluateDerivatives(P, optvars, const_cast<Vector<ValueType>&>(dlogpsi), dhpsioverpsi);
147  return evaluate(P);
148 }
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
evaluate derivatives of KE wrt optimizable varibles
Return_t evaluate(ParticleSet &P) override
Evaluate the local energy contribution of this component.

◆ evaluateWithIonDerivs()

Return_t evaluateWithIonDerivs ( ParticleSet P,
ParticleSet ions,
TrialWaveFunction psi,
ParticleSet::ParticlePos hf_terms,
ParticleSet::ParticlePos pulay_terms 
)
overridevirtual

Function to compute the value, direct ionic gradient terms, and pulay terms for the local kinetic energy.

This general function represents the OperatorBase interface for computing. For an operator {O}, this function will return {{O}}{}, {({O})}{}, and {{O}}{} - {{O}}{}{ }{}. These are referred to as Value, HF term, and pulay term respectively.

Parameters
Pelectron particle set.
ionsion particle set
psiTrial wave function object.
hf_terms3Nion dimensional object. All direct force terms, or ionic gradient of operator itself. Contribution of this operator is ADDED onto hf_terms.
pulay_termsThe terms coming from ionic gradients of trial wavefunction. Contribution of this operator is ADDED onto pulay_terms.
Returns
Value of kinetic energy operator at electron/ion positions given by P and ions. The force contributions from this operator are added into hf_terms and pulay_terms.

Reimplemented from OperatorBase.

Definition at line 183 of file BareKineticEnergy.cpp.

References qmcplusplus::convertToReal(), qmcplusplus::dlaplacian(), qmcplusplus::Dot(), TrialWaveFunction::evalGradSource(), TrialWaveFunction::evaluateLog(), ParticleSet::first(), ParticleSet::G, ParticleSet::getTotalNum(), ParticleSet::L, qmcplusplus::laplacian(), ParticleSet::last(), BareKineticEnergy::minus_over_2m_, OHMMS_DIM, BareKineticEnergy::one_over_2m_, BareKineticEnergy::same_mass_, qmcplusplus::Sum(), and OperatorBase::value_.

Referenced by qmcplusplus::TEST_CASE().

188 {
189  using ParticlePos = ParticleSet::ParticlePos;
190  using ParticleGradient = ParticleSet::ParticleGradient;
191  using ParticleLaplacian = ParticleSet::ParticleLaplacian;
192 
193  int Nions = ions.getTotalNum();
194  int Nelec = P.getTotalNum();
195 
196  //These are intermediate arrays for potentially complex math.
197  ParticleLaplacian term2_(Nelec);
198  ParticleGradient term4_(Nelec);
199 
200  //Potentially complex temporary array for \partial \psi/\psi and \nabla^2 \partial \psi / \psi
201  ParticleGradient iongradpsi_(Nions), pulaytmp_(Nions);
202  //temporary arrays that will be explicitly real.
203  ParticlePos pulaytmpreal_(Nions), iongradpsireal_(Nions);
204 
205 
208 
209  for (int iondim = 0; iondim < OHMMS_DIM; iondim++)
210  {
211  iongrad_grad_[iondim].resize(Nelec);
212  iongrad_lapl_[iondim].resize(Nelec);
213  }
214 
215  iongradpsi_ = 0;
216  iongradpsireal_ = 0;
217  pulaytmpreal_ = 0;
218  pulaytmp_ = 0;
219 
220  RealType logpsi_ = psi.evaluateLog(P);
221  for (int iat = 0; iat < Nions; iat++)
222  {
223  //reset the iongrad_X containers.
224  for (int iondim = 0; iondim < OHMMS_DIM; iondim++)
225  {
226  iongrad_grad_[iondim] = 0;
227  iongrad_lapl_[iondim] = 0;
228  }
229  iongradpsi_[iat] = psi.evalGradSource(P, ions, iat, iongrad_grad_, iongrad_lapl_);
230  //conversion from potentially complex to definitely real.
231  convertToReal(iongradpsi_[iat], iongradpsireal_[iat]);
232  if (same_mass_)
233  {
234  for (int iondim = 0; iondim < OHMMS_DIM; iondim++)
235  {
236  //These term[24]_ variables exist because I want to do complex math first, and then take the real part at the
237  //end. Sum() and Dot() perform the needed functions and spit out the real part at the end.
238  term2_ = P.L * iongradpsi_[iat][iondim];
239  term4_ = P.G * iongradpsi_[iat][iondim];
240  pulaytmp_[iat][iondim] = -one_over_2m_ *
241  (Sum(iongrad_lapl_[iondim]) + Sum(term2_) + 2.0 * Dot(iongrad_grad_[iondim], P.G) + Dot(P.G, term4_));
242  }
243  }
244  else
245  {
246  for (int iondim = 0; iondim < OHMMS_DIM; iondim++)
247  {
248  for (int g = 0; g < minus_over_2m_.size(); g++)
249  {
250  for (int iel = P.first(g); iel < P.last(g); iel++)
251  {
252  pulaytmp_[iat][iondim] += minus_over_2m_[g] *
253  (dlaplacian(P.G[iel], P.L[iel], iongrad_grad_[iondim][iel], iongrad_lapl_[iondim][iel],
254  iongradpsi_[iat][iondim]));
255  }
256  }
257  }
258  }
259  convertToReal(pulaytmp_[iat], pulaytmpreal_[iat]);
260  }
261 
262  if (same_mass_)
263  {
264  value_ = Dot(P.G, P.G) + Sum(P.L);
265  value_ *= -one_over_2m_;
266  }
267  else
268  {
269  value_ = 0.0;
270  for (int i = 0; i < minus_over_2m_.size(); ++i)
271  {
272  Return_t x = 0.0;
273  for (int j = P.first(i); j < P.last(i); ++j)
274  x += laplacian(P.G[j], P.L[j]);
275  value_ += x * minus_over_2m_[i];
276  }
277  }
278  pulaytmpreal_ -= value_ * iongradpsireal_;
279 
280 
281  pulay_terms += pulaytmpreal_;
282  return value_;
283 }
T Sum(const ParticleAttrib< T > &pa)
T dlaplacian(const TinyVector< T, D > &g, const T l, const TinyVector< T, D > &gg, const T gl, const T ideriv)
Convenience function to compute .
void convertToReal(const T1 &in, T2 &out)
generic conversion from type T1 to type T2 using implicit conversion
Definition: ConvertToReal.h:32
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
#define OHMMS_DIM
Definition: config.h:64
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
bool same_mass_
true, if all the species have the same mass
T laplacian(const TinyVector< T, D > &g, T l)
compute real(laplacian)
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
QMCTraits::RealType RealType
Return_t value_
current value
Definition: OperatorBase.h:524
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 626 of file BareKineticEnergy.cpp.

627 {
628  os << "Kinetic energy";
629  return true;
630 }

◆ getClassName()

std::string getClassName ( ) const
overridevirtual

return class name

Implements OperatorBase.

Definition at line 70 of file BareKineticEnergy.cpp.

70 { return "BareKineticEnergy"; }

◆ makeClone()

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

Implements OperatorBase.

Definition at line 632 of file BareKineticEnergy.cpp.

633 {
634  return std::make_unique<BareKineticEnergy>(qp, psi);
635 }

◆ mw_evaluatePerParticle()

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 >> &  ion_listeners 
) const
override

Evaluate the contribution of this component for multiple walkers reporting to registered listeners from Estimators.

Definition at line 460 of file BareKineticEnergy.cpp.

References qmcplusplus::dot(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), OperatorBase::name_, BareKineticEnergy::one_over_2m_, qmcplusplus::pset, qmcplusplus::real(), Vector< T, Alloc >::resize(), qmcplusplus::Units::time::s, and OperatorBase::value_.

Referenced by BareKineticEnergy::mw_evaluatePerParticleWithToperator().

465 {
466  auto& o_leader = o_list.getCastedLeader<BareKineticEnergy>();
467  auto& p_leader = p_list.getLeader();
468  assert(this == &o_list.getLeader());
469 
470  auto num_particles = p_leader.getTotalNum();
471  auto& name = o_leader.name_;
472  Vector<RealType>& t_samp = o_leader.mw_res_.getResource().t_samples;
473  Vector<std::complex<RealType>>& tcmp_samp = o_leader.mw_res_.getResource().tcmp_samples;
474 
475  auto num_species = p_leader.getSpeciesSet().getTotalNum();
476  t_samp.resize(num_particles);
477  tcmp_samp.resize(num_particles);
478  const RealType clambda(-one_over_2m_);
479  auto evaluate_walker_per_particle = [num_particles, name, &t_samp, &tcmp_samp,
480  clambda](const int walker_index, const BareKineticEnergy& bke,
481  const ParticleSet& pset,
482  const std::vector<ListenerVector<RealType>>& listeners) {
483  RealType value = 0;
484  std::fill(t_samp.begin(), t_samp.end(), 0.0);
485  std::fill(tcmp_samp.begin(), tcmp_samp.end(), 0.0);
486 
487  std::complex<RealType> t1 = 0.0;
488  if (bke.same_mass_)
489  for (int i = 0; i < num_particles; i++)
490  {
491  t1 = pset.L[i] + dot(pset.G[i], pset.G[i]);
492  t1 = clambda * t1;
493  t_samp[i] = real(t1);
494  tcmp_samp[i] = t1;
495  value += real(t1);
496  }
497  else
498  {
499  for (int s = 0; s < bke.minus_over_2m_.size(); ++s)
500  {
501  FullPrecRealType mlambda = bke.minus_over_2m_[s];
502  for (int i = pset.first(s); i < pset.last(s); ++i)
503  {
504  t1 = pset.L[i] + dot(pset.G[i], pset.G[i]);
505  t1 *= mlambda;
506  t_samp[i] = real(t1);
507  tcmp_samp[i] = t1;
508  value += real(t1);
509  }
510  }
511  }
512  for (auto& listener : listeners)
513  {
514  listener.report(walker_index, name, t_samp);
515  }
516  return value;
517  };
518 
519  for (int iw = 0; iw < o_list.size(); iw++)
520  {
521  auto& bare_kinetic_energy = o_list.getCastedElement<BareKineticEnergy>(iw);
522  bare_kinetic_energy.value_ = evaluate_walker_per_particle(iw, bare_kinetic_energy, p_list[iw], listeners);
523  }
524 }
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
QMCTraits::RealType RealType
BareKineticEnergy(ParticleSet &p, TrialWaveFunction &psi)
constructor with particleset
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66

◆ mw_evaluatePerParticleWithToperator()

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 >> &  ion_listeners 
) const
override

For BareKineticEnergy since it does override any Toperator evals this needs to decay to mw_evaluatePerParticle.

This method must be overrideen since the default behavior is to decay to mw_evaluateWithToperator and its default behavior is to call mw_evaluate.

Definition at line 526 of file BareKineticEnergy.cpp.

References BareKineticEnergy::mw_evaluatePerParticle().

532 {
533  mw_evaluatePerParticle(o_list, wf_list, p_list, listeners, ion_listeners);
534 }
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 >> &ion_listeners) const override
Evaluate the contribution of this component for multiple walkers reporting to registered listeners fr...

◆ mw_evaluateWithParameterDerivatives()

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
override

Definition at line 150 of file BareKineticEnergy.cpp.

References RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), OperatorBase::mw_evaluate(), TrialWaveFunction::mw_evaluateParameterDerivatives(), and BareKineticEnergy::psi_.

155 {
156  RefVectorWithLeader<TrialWaveFunction> wf_list(o_list.getCastedLeader<BareKineticEnergy>().psi_);
157  for (int i = 0; i < o_list.size(); i++)
158  wf_list.push_back(o_list.getCastedElement<BareKineticEnergy>(i).psi_);
159  mw_evaluate(o_list, wf_list, p_list);
160  // const_cast is needed because TWF::evaluateDerivatives calculates dlogpsi.
161  // KineticEnergy must be the first element in the hamiltonian array.
163  const_cast<RecordArray<ValueType>&>(dlogpsi), dhpsioverpsi);
164 }
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.
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)
BareKineticEnergy(ParticleSet &p, TrialWaveFunction &psi)
constructor with particleset

◆ put()

bool put ( xmlNodePtr  )
overridevirtual

implements the virtual function.

Nothing is done but should check the mass

Implements OperatorBase.

Definition at line 624 of file BareKineticEnergy.cpp.

Referenced by qmcplusplus::TEST_CASE().

624 { return true; }

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
overridevirtual

return a shared resource to a collection

Reimplemented from OperatorBase.

Definition at line 453 of file BareKineticEnergy.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), and ResourceCollection::takebackResource().

455 {
456  auto& O_leader = o_list.getCastedLeader<BareKineticEnergy>();
457  collection.takebackResource(O_leader.mw_res_);
458 }
BareKineticEnergy(ParticleSet &p, TrialWaveFunction &psi)
constructor with particleset

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
overridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 72 of file BareKineticEnergy.cpp.

72 {}

Member Data Documentation

◆ minus_over_2m_

◆ mw_res_

Definition at line 179 of file BareKineticEnergy.h.

Referenced by BareKineticEnergy::acquireResource().

◆ one_over_2m_

◆ p_sample_

◆ particle_mass_

FullPrecRealType particle_mass_
private

mass of the particle

Definition at line 164 of file BareKineticEnergy.h.

Referenced by BareKineticEnergy::BareKineticEnergy().

◆ ps_

ParticleSet& ps_
private

Definition at line 177 of file BareKineticEnergy.h.

Referenced by BareKineticEnergy::checkoutParticleQuantities().

◆ psi_

◆ same_mass_

◆ t_sample_

◆ t_sample_comp_

◆ qmcplusplus::CoulombPBCAA

struct qmcplusplus::CoulombPBCAA

Calculates the AA Coulomb potential using PBCs.

Functionally identical to CoulombPBCAA but uses a templated version of LRHandler.

Definition at line 38 of file CoulombPBCAA.h.

+ Inheritance diagram for CoulombPBCAA:
+ Collaboration diagram for CoulombPBCAA:

Public Types

using LRHandlerType = LRCoulombSingleton::LRHandlerType
 
using GridType = LRCoulombSingleton::GridType
 
using RadFunctorType = LRCoulombSingleton::RadFunctorType
 
using mRealType = LRHandlerType::mRealType
 
using OffloadSpline = OneDimCubicSplineLinearGrid< LRCoulombSingleton::pRealType >
 
- 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 Types inherited from ForceBase
using Real = QMCTraits::RealType
 cheat, need to use virtual inheriance to clean up More...
 

Public Member Functions

 CoulombPBCAA (ParticleSet &ref, bool active, bool computeForces, bool use_offload)
 constructor More...
 
 ~CoulombPBCAA () override
 
std::string getClassName () const override
 return class name More...
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
void mw_evaluate (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const override
 Evaluate the contribution of this component of multiple walkers. More...
 
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 >> &ion_listeners) const override
 Evaluate the contribution of this component of multiple walkers per particle reporting to registered listeners from Estimators. More...
 
Return_t evaluateWithIonDerivs (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms) override
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
void updateSource (ParticleSet &s) override
 Update data associated with a particleset. More...
 
bool put (xmlNodePtr cur) override
 Do nothing. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) override
 
void informOfPerParticleListener () override
 Inform objects associated with this operator of per particle listeners. More...
 
void contributeParticleQuantities () override
 
void checkoutParticleQuantities (TraceManager &tm) override
 
Return_t evaluate_sp (ParticleSet &P)
 
void deleteParticleQuantities () override
 
Return_t evalSR (ParticleSet &P)
 
Return_t evalLR (ParticleSet &P)
 
Return_t evalSRwithForces (ParticleSet &P)
 
Return_t evalLRwithForces (ParticleSet &P)
 
Return_t evalConsts (bool report=true)
 
void addObservables (PropertySetType &plist, BufferType &collectables) override
 named values to the property list Default implementaton uses addValue(plist_) 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 createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
 return a shared resource to a collection More...
 
RealType get_madelung_constant () const
 
- 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 registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 
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_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 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 Return_t getEnsembleAverage ()
 Return an average value by collective operation. 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...
 
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 Member Functions inherited from ForceBase
Real g (Real r)
 
void initVarReduction (Real rcut, int m, int numFuncs)
 
 ForceBase (ParticleSet &ions, ParticleSet &elns)
 
virtual ~ForceBase ()
 
void registerObservablesF (std::vector< ObservableHelper > &h5list, hdf_archive &file) const
 
void addObservablesF (QMCTraits::PropertySetType &plist)
 
void addObservablesStress (QMCTraits::PropertySetType &plist)
 
void setObservablesF (QMCTraits::PropertySetType &plist)
 
void setObservablesStress (QMCTraits::PropertySetType &plist)
 
void setParticleSetF (QMCTraits::PropertySetType &plist, int offset)
 
void setParticleSetStress (QMCTraits::PropertySetType &plist, int offset)
 
bool getAddIonIon () const noexcept
 
void setAddIonIon (bool val) noexcept
 
const ParticleSet::ParticlePosgetForces () const noexcept
 
void setForces (const ParticleSet::ParticlePos &forces)
 
void setForces (Real val)
 
const ParticleSet::ParticlePosgetForcesIonIon () const noexcept
 
void setForcesIonIon (const ParticleSet::ParticlePos &forces_ion_ion)
 
const SymTensor< Real, OHMMS_DIM > & getStressIonIon () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStressEE () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStressEI () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStressKin () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStress () const noexcept
 

Static Public Member Functions

static std::vector< Return_tmw_evalSR_offload (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< ParticleSet > &p_list)
 

Public Attributes

std::shared_ptr< LRHandlerTypeAA
 energy-optimized long range handle. Should be const LRHandlerType eventually More...
 
std::shared_ptr< const RadFunctorTyperVs
 energy-optimized short range pair potential More...
 
std::shared_ptr< const OffloadSplinerVs_offload
 the same as rVs but can be used inside OpenMP offload regions More...
 
std::shared_ptr< const LRHandlerTypedAA
 force-optimized long range handle More...
 
std::shared_ptr< const RadFunctorTyperVsforce
 force-optimized short range pair potential More...
 
bool is_active
 
bool FirstTime
 
int SourceID
 
int NumSpecies
 
int ChargeAttribIndx
 
int MemberAttribIndx
 
int NumCenters
 
Return_t myConst
 
RealType myRcut
 cutoff radius of the short-range part More...
 
std::string PtclRefName
 
std::vector< RealTypeZat
 
std::vector< RealTypeZspec
 
std::shared_ptr< Vector< RealType, OffloadPinnedAllocator< RealType > > > Zat_offload
 
std::vector< int > NofSpecies
 
std::vector< int > SpeciesID
 
Matrix< RealTypeSR2
 
Vector< RealTypedSR
 
Vector< ComplexTypedel_eikr
 
bool ComputeForces
 Flag for whether to compute forces or not. More...
 
const bool quasi2d
 Flag for whether to use quasi-2D Ewald. More...
 
Array< TraceReal, 1 > * V_sample
 
Array< TraceReal, 1 > V_const
 
ParticleSetPs
 

Private Member Functions

void initBreakup (ParticleSet &P)
 constructor code factored out More...
 
void evalPerParticleConsts (Vector< RealType > &pp_consts) const
 Compute the const part of the per particle coulomb self interaction potential. More...
 

Private Attributes

RealType madelung_constant_
 
const bool use_offload_
 if true use offload More...
 
const int d_aa_ID
 AA table ID. More...
 
NewTimerevalLR_timer_
 Timer for long range. More...
 
NewTimerevalSR_timer_
 Timer for long range. More...
 
NewTimeroffload_timer_
 Timer for offload part. More...
 
ResourceHandle< CoulombPBCAAMultiWalkerResourcemw_res_handle_
 

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 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_
 
- Protected Attributes inherited from ForceBase
int first_force_index_
 
int n_nuc_
 
int n_el_
 
int tries_
 
bool first_time_
 
bool add_ion_ion_
 Determines if ion-ion force will be added to electron-ion force in derived force estimators. If false, forces_ion_ion_=0.0. More...
 
ParticleSetions_
 
ParticleSet::ParticlePos forces_
 
ParticleSet::ParticlePos forces_ion_ion_
 
SymTensor< Real, OHMMS_DIMstress_ion_ion_
 
SymTensor< Real, OHMMS_DIMstress_ee_
 
SymTensor< Real, OHMMS_DIMstress_ei_
 
SymTensor< Real, OHMMS_DIMstress_kin_
 
SymTensor< Real, OHMMS_DIMstress_
 
std::string prefix_
 
std::string pair_name_
 
Real rcut_
 
int m_
 
std::vector< Realck_
 

Member Typedef Documentation

◆ GridType

Definition at line 41 of file CoulombPBCAA.h.

◆ LRHandlerType

◆ mRealType

using mRealType = LRHandlerType::mRealType

Definition at line 43 of file CoulombPBCAA.h.

◆ OffloadSpline

using OffloadSpline = OneDimCubicSplineLinearGrid<LRCoulombSingleton::pRealType>

Definition at line 44 of file CoulombPBCAA.h.

◆ RadFunctorType

Constructor & Destructor Documentation

◆ CoulombPBCAA()

CoulombPBCAA ( ParticleSet ref,
bool  active,
bool  computeForces,
bool  use_offload 
)

constructor

Definition at line 47 of file CoulombPBCAA.cpp.

References qmcplusplus::Units::distance::A, CoulombPBCAA::AA, qmcplusplus::abs(), qmcplusplus::ALL_OFF, qmcplusplus::app_log(), CoulombPBCAA::ComputeForces, CoulombPBCAA::d_aa_ID, qmcplusplus::DC_POS_OFFLOAD, qmcplusplus::ewaldref::ewaldEnergy(), ParticleSet::getCoordinates(), ParticleSet::getDistTable(), DynamicCoordinates::getKind(), ParticleSet::getLattice(), OhmmsElementBase::getName(), CoulombPBCAA::initBreakup(), CoulombPBCAA::is_active, CoulombPBCAA::madelung_constant_, qmcplusplus::NEED_FULL_TABLE_ON_HOST_AFTER_DONEPBYP, CoulombPBCAA::NumCenters, OperatorBase::POTENTIAL, ForceBase::prefix_, CoulombPBCAA::Ps, CoulombPBCAA::PtclRefName, CoulombPBCAA::quasi2d, ParticleSet::R, OperatorBase::setEnergyDomain(), ParticleSet::turnOnPerParticleSK(), OperatorBase::twoBodyQuantumDomain(), ParticleSet::update(), CoulombPBCAA::updateSource(), CoulombPBCAA::use_offload_, OperatorBase::value_, and CoulombPBCAA::Zat.

48  : ForceBase(ref, ref),
49  is_active(active),
50  FirstTime(true),
51  myConst(0.0),
52  ComputeForces(computeForces),
54  Ps(ref),
55  use_offload_(active && !computeForces && use_offload),
57  evalLR_timer_(createGlobalTimer("CoulombPBCAA::LongRange", timer_level_fine)),
58  evalSR_timer_(createGlobalTimer("CoulombPBCAA::ShortRange", timer_level_fine)),
59  offload_timer_(createGlobalTimer("CoulombPBCAA::offload", timer_level_fine))
60 {
61  if (use_offload_)
62  assert(ref.getCoordinates().getKind() == DynamicCoordinateKind::DC_POS_OFFLOAD);
63 
64  ReportEngine PRE("CoulombPBCAA", "CoulombPBCAA");
67  PtclRefName = ref.getDistTable(d_aa_ID).getName();
68  if (ComputeForces || quasi2d)
69  {
70  ref.turnOnPerParticleSK();
71  }
72  initBreakup(ref);
73  if (ComputeForces)
74  {
75  updateSource(ref);
76  }
77 
78  if (!is_active)
79  {
80  ref.update();
81  updateSource(ref);
82 
86 
87  A = Ps.getLattice().R;
88 
89  R.resize(NumCenters);
90  Q.resize(NumCenters);
91  for (int i = 0; i < NumCenters; ++i)
92  {
93  R[i] = Ps.R[i];
94  Q[i] = Zat[i];
95  }
96 
97  RealType Vii_ref = ewaldref::ewaldEnergy(A, R, Q);
98  RealType Vdiff_per_atom = std::abs(value_ - Vii_ref) / NumCenters;
99  app_log() << "Checking ion-ion Ewald energy against reference..." << std::endl;
100  if (Vdiff_per_atom > Ps.getLattice().LR_tol)
101  {
102  std::ostringstream msg;
103  msg << std::setprecision(14);
104  msg << "in ion-ion Ewald energy exceeds " << Ps.getLattice().LR_tol << " Ha/atom tolerance." << std::endl;
105  msg << std::endl;
106  msg << " Reference ion-ion energy: " << Vii_ref << std::endl;
107  msg << " QMCPACK ion-ion energy: " << value_ << std::endl;
108  msg << " ion-ion diff : " << value_ - Vii_ref << std::endl;
109  msg << " diff/atom : " << (value_ - Vii_ref) / NumCenters << std::endl;
110  msg << " tolerance : " << Ps.getLattice().LR_tol << std::endl;
111  msg << std::endl;
112  msg << "Please try increasing the LR_dim_cutoff parameter in the <simulationcell/>" << std::endl;
113  msg << "input. Alternatively, the tolerance can be increased by setting the" << std::endl;
114  msg << "LR_tol parameter in <simulationcell/> to a value greater than " << Ps.getLattice().LR_tol << ". "
115  << std::endl;
116  msg << "If you increase the tolerance, please perform careful checks of energy" << std::endl;
117  msg << "differences to ensure this error is controlled for your application." << std::endl;
118  msg << std::endl;
119 
120  throw UniformCommunicateError(msg.str());
121  }
122  else
123  {
124  app_log() << " Check passed." << std::endl;
125  }
126  }
127  prefix_ = "F_AA";
128  app_log() << " Maximum K shell " << AA->MaxKshell << std::endl;
129  app_log() << " Number of k vectors " << AA->Fk.size() << std::endl;
130  app_log() << " Fixed Coulomb potential for " << ref.getName();
131  app_log() << "\n e-e Madelung Const. =" << std::setprecision(8) << madelung_constant_
132  << "\n Vtot =" << value_ << std::endl;
133 }
void twoBodyQuantumDomain(const ParticleSet &P)
set quantum domain for two-body operator
const bool use_offload_
if true use offload
Definition: CoulombPBCAA.h:191
const int d_aa_ID
AA table ID.
Definition: CoulombPBCAA.h:193
NewTimer & evalLR_timer_
Timer for long range.
Definition: CoulombPBCAA.h:195
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::ostream & app_log()
Definition: OutputManager.h:65
NewTimer & evalSR_timer_
Timer for long range.
Definition: CoulombPBCAA.h:197
std::vector< real_t > ChargeArray
Type for lists of particle charges.
Definition: EwaldRef.h:54
Tensor< real_t, DIM > RealMat
Type for floating point matrices of shape DIM,DIM.
Definition: EwaldRef.h:50
void updateSource(ParticleSet &s) override
Update data associated with a particleset.
real_t ewaldEnergy(const RealMat &a, const PosArray &R, const ChargeArray &Q, real_t tol)
Compute the total Ewald potential energy for a collection of charges.
Definition: EwaldRef.cpp:337
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAA.h:79
ForceBase(ParticleSet &ions, ParticleSet &elns)
Definition: ForceBase.cpp:28
std::string prefix_
Definition: ForceBase.h:96
std::vector< RealVec > PosArray
Type for lists of particle positions.
Definition: EwaldRef.h:52
NewTimer & offload_timer_
Timer for offload part.
Definition: CoulombPBCAA.h:199
void initBreakup(ParticleSet &P)
constructor code factored out
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
ParticlePos R
Position.
Definition: ParticleSet.h:79
void setEnergyDomain(EnergyDomains edomain)
Set the Energy Domain.
const bool quasi2d
Flag for whether to use quasi-2D Ewald.
Definition: CoulombPBCAA.h:81
QMCTraits::RealType RealType
std::shared_ptr< LRHandlerType > AA
energy-optimized long range handle. Should be const LRHandlerType eventually
Definition: CoulombPBCAA.h:47
Return_t value_
current value
Definition: OperatorBase.h:524
std::vector< RealType > Zat
Definition: CoulombPBCAA.h:69
const auto & getLattice() const
Definition: ParticleSet.h:251
whether full table needs to be ready at anytime or not after donePbyP Optimization can be implemented...

◆ ~CoulombPBCAA()

~CoulombPBCAA ( )
overridedefault

Member Function Documentation

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
overridevirtual

acquire a shared resource from a collection

Reimplemented from OperatorBase.

◆ 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 137 of file CoulombPBCAA.cpp.

References ForceBase::addObservablesF(), OperatorBase::addValue(), and CoulombPBCAA::ComputeForces.

138 {
139  addValue(plist);
140  if (ComputeForces)
141  addObservablesF(plist);
142 }
void addObservablesF(QMCTraits::PropertySetType &plist)
Definition: ForceBase.cpp:47
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAA.h:79
void addValue(PropertySetType &plist)
named values to the property list

◆ checkoutParticleQuantities()

void checkoutParticleQuantities ( TraceManager tm)
overridevirtual

Reimplemented from OperatorBase.

Definition at line 174 of file CoulombPBCAA.cpp.

References TraceManager::checkout_real(), CoulombPBCAA::evaluate_sp(), CoulombPBCAA::is_active, OperatorBase::name_, CoulombPBCAA::Ps, OperatorBase::request_, TraceRequest::streaming_array(), OperatorBase::streaming_particles_, ParticleSet::turnOnPerParticleSK(), and CoulombPBCAA::V_sample.

175 {
178  {
180  V_sample = tm.checkout_real<1>(name_, Ps);
181  if (!is_active)
182  evaluate_sp(Ps);
183  }
184 }
bool streaming_array(const std::string &name)
Definition: TraceManager.h:249
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
void turnOnPerParticleSK()
Turn on per particle storage in Structure Factor.
std::string name_
name of this object
Definition: OperatorBase.h:527
Array< TraceReal, 1 > * V_sample
Definition: CoulombPBCAA.h:85
Return_t evaluate_sp(ParticleSet &P)

◆ contributeParticleQuantities()

void contributeParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 172 of file CoulombPBCAA.cpp.

References TraceRequest::contribute_array(), OperatorBase::name_, and OperatorBase::request_.

TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
std::string name_
name of this object
Definition: OperatorBase.h:527
void contribute_array(const std::string &name, bool default_quantity=false)
Definition: TraceManager.h:198

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from OperatorBase.

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

◆ deleteParticleQuantities()

void deleteParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 186 of file CoulombPBCAA.cpp.

References OperatorBase::streaming_particles_, and CoulombPBCAA::V_sample.

187 {
189  delete V_sample;
190 }
Array< TraceReal, 1 > * V_sample
Definition: CoulombPBCAA.h:85

◆ evalConsts()

Return_t evalConsts ( bool  report = true)

◆ evalLR()

◆ evalLRwithForces()

CoulombPBCAA::Return_t evalLRwithForces ( ParticleSet P)

Definition at line 483 of file CoulombPBCAA.cpp.

References CoulombPBCAA::dAA, CoulombPBCAA::evalLR(), ForceBase::forces_, ParticleSet::getTotalNum(), CoulombPBCAA::NumSpecies, CoulombPBCAA::Zat, and CoulombPBCAA::Zspec.

Referenced by CoulombPBCAA::updateSource().

484 {
485  // const StructFact& PtclRhoK(P.getSK());
486  std::vector<TinyVector<RealType, DIM>> grad(P.getTotalNum());
487  for (int spec2 = 0; spec2 < NumSpecies; spec2++)
488  {
489  RealType Z2 = Zspec[spec2];
490  for (int iat = 0; iat < grad.size(); iat++)
491  grad[iat] = TinyVector<RealType, DIM>(0.0);
492  //AA->evaluateGrad(P, P, spec2, Zat, grad);
493  dAA->evaluateGrad(P, P, spec2, Zat, grad);
494  for (int iat = 0; iat < grad.size(); iat++)
495  forces_[iat] += Z2 * grad[iat];
496  } //spec2
497  return evalLR(P);
498 }
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
Return_t evalLR(ParticleSet &P)
std::shared_ptr< const LRHandlerType > dAA
force-optimized long range handle
Definition: CoulombPBCAA.h:53
QMCTraits::RealType RealType
std::vector< RealType > Zspec
Definition: CoulombPBCAA.h:69
std::vector< RealType > Zat
Definition: CoulombPBCAA.h:69

◆ evalPerParticleConsts()

void evalPerParticleConsts ( Vector< RealType > &  pp_consts) const
private

Compute the const part of the per particle coulomb self interaction potential.

Parameters
[out]pp_constsconstant values for the particles self interaction

◆ evalSR()

◆ evalSRwithForces()

CoulombPBCAA::Return_t evalSRwithForces ( ParticleSet P)

Definition at line 501 of file CoulombPBCAA.cpp.

References CoulombPBCAA::d_aa_ID, ForceBase::forces_, ParticleSet::getDistTableAA(), CoulombPBCAA::NumCenters, CoulombPBCAA::rVs, CoulombPBCAA::rVsforce, and CoulombPBCAA::Zat.

Referenced by CoulombPBCAA::updateSource().

502 {
503  const auto& d_aa(P.getDistTableAA(d_aa_ID));
504  mRealType SR = 0.0;
505  for (size_t ipart = 1; ipart < (NumCenters / 2 + 1); ipart++)
506  {
507  mRealType esum = 0.0;
508  const auto& dist = d_aa.getDistRow(ipart);
509  const auto& dr = d_aa.getDisplRow(ipart);
510  for (size_t j = 0; j < ipart; ++j)
511  {
512  RealType V, rV, d_rV_dr, d2_rV_dr2;
513  RealType rinv = 1.0 / dist[j];
514  rV = rVsforce->splint(dist[j], d_rV_dr, d2_rV_dr2);
515  V = rV * rinv;
516  esum += Zat[j] * rVs->splint(dist[j]) * rinv;
517 
518  PosType grad = Zat[j] * Zat[ipart] * (d_rV_dr - V) * rinv * rinv * dr[j];
519  forces_[ipart] += grad;
520  forces_[j] -= grad;
521  }
522  SR += Zat[ipart] * esum;
523 
524  const size_t ipart_reverse = NumCenters - ipart;
525  if (ipart == ipart_reverse)
526  continue;
527 
528  esum = 0.0;
529  const auto& dist2 = d_aa.getDistRow(ipart_reverse);
530  const auto& dr2 = d_aa.getDisplRow(ipart_reverse);
531  for (size_t j = 0; j < ipart_reverse; ++j)
532  {
533  RealType V, rV, d_rV_dr, d2_rV_dr2;
534  RealType rinv = 1.0 / dist2[j];
535  rV = rVsforce->splint(dist2[j], d_rV_dr, d2_rV_dr2);
536  V = rV * rinv;
537  esum += Zat[j] * rVs->splint(dist2[j]) * rinv;
538 
539  PosType grad = Zat[j] * Zat[ipart_reverse] * (d_rV_dr - V) * rinv * rinv * dr2[j];
540  forces_[ipart_reverse] += grad;
541  forces_[j] -= grad;
542  }
543  SR += Zat[ipart_reverse] * esum;
544  }
545  return SR;
546 }
const int d_aa_ID
AA table ID.
Definition: CoulombPBCAA.h:193
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
std::shared_ptr< const RadFunctorType > rVs
energy-optimized short range pair potential
Definition: CoulombPBCAA.h:49
LRHandlerType::mRealType mRealType
Definition: CoulombPBCAA.h:43
std::shared_ptr< const RadFunctorType > rVsforce
force-optimized short range pair potential
Definition: CoulombPBCAA.h:55
QMCTraits::PosType PosType
QMCTraits::RealType RealType
std::vector< RealType > Zat
Definition: CoulombPBCAA.h:69

◆ evaluate()

CoulombPBCAA::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 201 of file CoulombPBCAA.cpp.

References CoulombPBCAA::evalLR(), CoulombPBCAA::evalSR(), CoulombPBCAA::evaluate_sp(), CoulombPBCAA::is_active, CoulombPBCAA::myConst, OperatorBase::streaming_particles_, and OperatorBase::value_.

Referenced by qmcplusplus::TEST_CASE().

202 {
203  if (is_active)
204  {
205 #if !defined(REMOVE_TRACEMANAGER)
207  value_ = evaluate_sp(P);
208  else
209 #endif
210  value_ = evalLR(P) + evalSR(P) + myConst;
211  }
212  return value_;
213 }
Return_t evalSR(ParticleSet &P)
Return_t evalLR(ParticleSet &P)
Return_t value_
current value
Definition: OperatorBase.h:524
Return_t evaluate_sp(ParticleSet &P)

◆ evaluate_sp()

CoulombPBCAA::Return_t evaluate_sp ( ParticleSet P)

Definition at line 343 of file CoulombPBCAA.cpp.

References CoulombPBCAA::AA, qmcplusplus::abs(), APP_ABORT, qmcplusplus::app_log(), CoulombPBCAA::d_aa_ID, CoulombPBCAA::evalLR(), CoulombPBCAA::evalSR(), ParticleSet::getDistTableAA(), ParticleSet::getSimulationCell(), ParticleSet::getSK(), CoulombPBCAA::myConst, CoulombPBCAA::NumCenters, CoulombPBCAA::NumSpecies, CoulombPBCAA::rVs, qmcplusplus::Units::time::s, Array< T, D, ALLOC >::size(), Array< T, D, ALLOC >::sum(), qmcplusplus::SUPERCELL_SLAB, TraceManager::trace_tol, CoulombPBCAA::V_const, CoulombPBCAA::V_sample, OperatorBase::value_, CoulombPBCAA::Zat, and CoulombPBCAA::Zspec.

Referenced by CoulombPBCAA::checkoutParticleQuantities(), and CoulombPBCAA::evaluate().

344 {
345  mRealType Vsr = 0.0;
346  mRealType Vlr = 0.0;
347  mRealType& Vc = myConst;
348  Array<RealType, 1>& V_samp = *V_sample;
349  V_samp = 0.0;
350  {
351  //SR
352  const auto& d_aa(P.getDistTableAA(d_aa_ID));
353  RealType z;
354  for (int ipart = 1; ipart < NumCenters; ipart++)
355  {
356  z = .5 * Zat[ipart];
357  const auto& dist = d_aa.getDistRow(ipart);
358  for (int jpart = 0; jpart < ipart; ++jpart)
359  {
360  RealType pairpot = z * Zat[jpart] * rVs->splint(dist[jpart]) / dist[jpart];
361  V_samp(ipart) += pairpot;
362  V_samp(jpart) += pairpot;
363  Vsr += pairpot;
364  }
365  }
366  Vsr *= 2.0;
367  }
368  {
369  //LR
370  const StructFact& PtclRhoK(P.getSK());
371  if (PtclRhoK.SuperCellEnum == SUPERCELL_SLAB)
372  {
373  APP_ABORT("CoulombPBCAA::evaluate_sp single particle traces have not been implemented for slab geometry");
374  }
375  else
376  {
377  assert(PtclRhoK.isStorePerParticle()); // ensure this so we know eikr_r has been allocated
378  //jtk mark: needs optimizations
379  RealType v1; //single particle energy
380  RealType z;
381  for (int i = 0; i < NumCenters; i++)
382  {
383  z = .5 * Zat[i];
384  v1 = 0.0;
385  for (int s = 0; s < NumSpecies; ++s)
386  v1 += z * Zspec[s] *
387  AA->evaluate(P.getSimulationCell().getKLists().kshell, PtclRhoK.rhok_r[s], PtclRhoK.rhok_i[s],
388  PtclRhoK.eikr_r[i], PtclRhoK.eikr_i[i]);
389  V_samp(i) += v1;
390  Vlr += v1;
391  }
392  }
393  }
394  for (int i = 0; i < V_samp.size(); ++i)
395  V_samp(i) += V_const(i);
396  value_ = Vsr + Vlr + Vc;
397 #if defined(TRACE_CHECK)
398  RealType Vlrnow = evalLR(P);
399  RealType Vsrnow = evalSR(P);
400  RealType Vcnow = myConst;
401  RealType Vnow = Vlrnow + Vsrnow + Vcnow;
402  RealType Vsum = V_samp.sum();
403  RealType Vcsum = V_const.sum();
404  if (std::abs(Vsum - Vnow) > TraceManager::trace_tol)
405  {
406  app_log() << "accumtest: CoulombPBCAA::evaluate()" << std::endl;
407  app_log() << "accumtest: tot:" << Vnow << std::endl;
408  app_log() << "accumtest: sum:" << Vsum << std::endl;
409  APP_ABORT("Trace check failed");
410  }
411  if (std::abs(Vcsum - Vcnow) > TraceManager::trace_tol)
412  {
413  app_log() << "accumtest: CoulombPBCAA::evalConsts()" << std::endl;
414  app_log() << "accumtest: tot:" << Vcnow << std::endl;
415  app_log() << "accumtest: sum:" << Vcsum << std::endl;
416  APP_ABORT("Trace check failed");
417  }
418 #endif
419  return value_;
420 }
const int d_aa_ID
AA table ID.
Definition: CoulombPBCAA.h:193
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
Array< TraceReal, 1 > V_const
Definition: CoulombPBCAA.h:86
std::ostream & app_log()
Definition: OutputManager.h:65
std::shared_ptr< const RadFunctorType > rVs
energy-optimized short range pair potential
Definition: CoulombPBCAA.h:49
Return_t evalSR(ParticleSet &P)
LRHandlerType::mRealType mRealType
Definition: CoulombPBCAA.h:43
Return_t evalLR(ParticleSet &P)
size_t size() const
Definition: OhmmsArray.h:57
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
Type_t sum() const
Definition: OhmmsArray.h:214
QMCTraits::RealType RealType
std::shared_ptr< LRHandlerType > AA
energy-optimized long range handle. Should be const LRHandlerType eventually
Definition: CoulombPBCAA.h:47
Return_t value_
current value
Definition: OperatorBase.h:524
std::vector< RealType > Zspec
Definition: CoulombPBCAA.h:69
std::vector< RealType > Zat
Definition: CoulombPBCAA.h:69
Array< TraceReal, 1 > * V_sample
Definition: CoulombPBCAA.h:85

◆ evaluateWithIonDerivs()

CoulombPBCAA::Return_t evaluateWithIonDerivs ( ParticleSet P,
ParticleSet ions,
TrialWaveFunction psi,
ParticleSet::ParticlePos hf_term,
ParticleSet::ParticlePos pulay_term 
)
overridevirtual

Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase.

Parameters
Ptarget particle set (electrons)
ionssource particle set (ions)
psiTrial wave function
hf_termsAdds OperatorBase's contribution to Re [(dH)Psi]/Psi
pulay_termsAdds OperatorBase's contribution to Re [(H-E_L)dPsi]/Psi
Returns
Contribution of OperatorBase to Local Energy.

Reimplemented from OperatorBase.

Definition at line 330 of file CoulombPBCAA.cpp.

References CoulombPBCAA::ComputeForces, ForceBase::forces_, CoulombPBCAA::is_active, and OperatorBase::value_.

Referenced by qmcplusplus::TEST_CASE().

335 {
336  if (ComputeForces and !is_active)
337  hf_terms -= forces_;
338  //No pulay term.
339  return value_;
340 }
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAA.h:79
Return_t value_
current value
Definition: OperatorBase.h:524

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 127 of file CoulombPBCAA.h.

References CoulombPBCAA::PtclRefName.

128  {
129  os << "CoulombPBCAA potential: " << PtclRefName;
130  return true;
131  }

◆ get_madelung_constant()

RealType get_madelung_constant ( ) const
inline

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 96 of file CoulombPBCAA.h.

96 { return "CoulombPBCAA"; }

◆ informOfPerParticleListener()

void informOfPerParticleListener ( )
overridevirtual

Inform objects associated with this operator of per particle listeners.

i.e. turnOnPerParticleSK of particleset qp.

Reimplemented from OperatorBase.

Definition at line 193 of file CoulombPBCAA.cpp.

References OperatorBase::informOfPerParticleListener(), CoulombPBCAA::Ps, and ParticleSet::turnOnPerParticleSK().

Referenced by qmcplusplus::TEST_CASE().

194 {
195  // turnOnParticleSK is written so it can be called again and again.
198 }
void turnOnPerParticleSK()
Turn on per particle storage in Structure Factor.
virtual void informOfPerParticleListener()
Definition: OperatorBase.h:471

◆ initBreakup()

void initBreakup ( ParticleSet P)
private

constructor code factored out

Definition at line 423 of file CoulombPBCAA.cpp.

References CoulombPBCAA::AA, qmcplusplus::app_log(), CoulombPBCAA::ChargeAttribIndx, CoulombPBCAA::ComputeForces, LRCoulombSingleton::createSpline4RbyVs(), CoulombPBCAA::dAA, CoulombPBCAA::evalConsts(), LRCoulombSingleton::getDerivHandler(), LRCoulombSingleton::getHandler(), ParticleSet::getLattice(), ParticleSet::getSpeciesSet(), ParticleSet::getTotalNum(), ParticleSet::GroupID, ParticleSet::groupsize(), CoulombPBCAA::myConst, CoulombPBCAA::myRcut, CoulombPBCAA::NofSpecies, CoulombPBCAA::NumCenters, CoulombPBCAA::NumSpecies, Array< T, D, ALLOC >::resize(), CoulombPBCAA::rVs, CoulombPBCAA::rVs_offload, CoulombPBCAA::rVsforce, LinearGrid< T, CT >::set(), CoulombPBCAA::SpeciesID, CoulombPBCAA::V_const, CoulombPBCAA::Zat, CoulombPBCAA::Zat_offload, and CoulombPBCAA::Zspec.

Referenced by CoulombPBCAA::CoulombPBCAA().

424 {
425  //SpeciesSet& tspecies(PtclRef->getSpeciesSet());
426  SpeciesSet& tspecies(P.getSpeciesSet());
427  //Things that don't change with lattice are done here instead of InitBreakup()
428  ChargeAttribIndx = tspecies.addAttribute("charge");
429  NumCenters = P.getTotalNum();
430  NumSpecies = tspecies.TotalNum;
431 
432 #if !defined(REMOVE_TRACEMANAGER)
434 #endif
435 
436  Zspec.resize(NumSpecies);
437  NofSpecies.resize(NumSpecies);
438  for (int spec = 0; spec < NumSpecies; spec++)
439  {
440  Zspec[spec] = tspecies(ChargeAttribIndx, spec);
441  NofSpecies[spec] = P.groupsize(spec);
442  }
443 
444  SpeciesID.resize(NumCenters);
445  Zat.resize(NumCenters);
446  Zat_offload = std::make_shared<Vector<RealType, OffloadPinnedAllocator<RealType>>>(NumCenters);
447  auto& Zat_ref(*Zat_offload);
448  for (int iat = 0; iat < NumCenters; iat++)
449  {
450  SpeciesID[iat] = P.GroupID[iat];
451  Zat[iat] = Zspec[P.GroupID[iat]];
452  Zat_ref[iat] = Zat[iat];
453  }
454  Zat_ref.updateTo();
455 
457  //AA->initBreakup(*PtclRef);
458  myConst = evalConsts();
459  myRcut = AA->get_rc(); //Basis.get_rc();
460 
461  auto myGrid = LinearGrid<RealType>();
462  int ng = P.getLattice().num_ewald_grid_points;
463  app_log() << " CoulombPBCAA::initBreakup\n Setting a linear grid=[0,"
464  << myRcut << ") number of grid points =" << ng << std::endl;
465  myGrid.set(0, myRcut, ng);
466 
467  if (rVs == nullptr)
469 
470  rVs_offload = std::make_shared<const OffloadSpline>(*rVs);
471 
472  if (ComputeForces)
473  {
475  if (rVsforce == nullptr)
476  {
478  }
479  }
480 }
static std::unique_ptr< LRHandlerType > getDerivHandler(ParticleSet &ref)
This returns a force/stress optimized LR handler. If non existent, it creates one.
std::shared_ptr< Vector< RealType, OffloadPinnedAllocator< RealType > > > Zat_offload
Definition: CoulombPBCAA.h:70
static std::unique_ptr< RadFunctorType > createSpline4RbyVs(const LRHandlerType *aLR, mRealType rcut, const GridType &agrid)
create a linear spline function
Array< TraceReal, 1 > V_const
Definition: CoulombPBCAA.h:86
std::ostream & app_log()
Definition: OutputManager.h:65
std::shared_ptr< const RadFunctorType > rVs
energy-optimized short range pair potential
Definition: CoulombPBCAA.h:49
std::vector< int > SpeciesID
Definition: CoulombPBCAA.h:73
std::shared_ptr< const LRHandlerType > dAA
force-optimized long range handle
Definition: CoulombPBCAA.h:53
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAA.h:79
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
std::shared_ptr< const RadFunctorType > rVsforce
force-optimized short range pair potential
Definition: CoulombPBCAA.h:55
RealType myRcut
cutoff radius of the short-range part
Definition: CoulombPBCAA.h:66
std::shared_ptr< const OffloadSpline > rVs_offload
the same as rVs but can be used inside OpenMP offload regions
Definition: CoulombPBCAA.h:51
Return_t evalConsts(bool report=true)
Linear Grid inherets from Grid.
Definition: Grid.h:73
std::shared_ptr< LRHandlerType > AA
energy-optimized long range handle. Should be const LRHandlerType eventually
Definition: CoulombPBCAA.h:47
std::vector< RealType > Zspec
Definition: CoulombPBCAA.h:69
std::vector< RealType > Zat
Definition: CoulombPBCAA.h:69
static std::unique_ptr< LRHandlerType > getHandler(ParticleSet &ref)
This returns an energy optimized LR handler. If non existent, it creates one.
std::vector< int > NofSpecies
Definition: CoulombPBCAA.h:72

◆ makeClone()

std::unique_ptr<OperatorBase> makeClone ( ParticleSet qp,
TrialWaveFunction psi 
)
overridevirtual

Implements OperatorBase.

◆ mw_evalSR_offload()

static std::vector<Return_t> mw_evalSR_offload ( const RefVectorWithLeader< OperatorBase > &  o_list,
const RefVectorWithLeader< ParticleSet > &  p_list 
)
static

◆ mw_evaluate()

void mw_evaluate ( const RefVectorWithLeader< OperatorBase > &  o_list,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list 
) const
overridevirtual

Evaluate the contribution of this component of multiple walkers.

Take o_list and p_list update evaluation result variables in o_list? really should reduce vector of local_energies. matching the ordering and size of o list the this can be call for 1 or more QMCHamiltonians

Parameters
o_list
wf_list
p_list

Temporary raw omp pragma for simple thread parallelism ignoring the driver level concurrency

TODO: replace this with a proper abstraction. It should adequately describe the behavior and strictly limit the activation of this level concurrency to when it is intended. It is unlikely to belong in this function.

This implicitly depends on openmp work division logic. Essentially adhoc runtime crowds over which we have given up control of thread/global scope. How many walkers per thread? How to handle their data movement if any of these hamiltonians should be accelerated? We can neither reason about or describe it in C++

As I understand it it should only be required for as long as the AMD openmp offload compliler is incapable of running multiple threads. They should/must fix their compiler before delivery of frontier and it should be removed at that point at latest

If you want 16 threads of 1 walker that should be 16 crowds of 1 not one crowd of 16 with openmp thrown in at hamiltonian level. If this must be different from the other crowd batching. Make this a reasoned about and controlled level of concurency blocking at the driver level.

This is only thread safe only if each walker has a complete set of anything involved in an Operator.evaluate.

Reimplemented from OperatorBase.

Definition at line 215 of file CoulombPBCAA.cpp.

References RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), CoulombPBCAA::mw_evalSR_offload(), OperatorBase::mw_evaluate(), CoulombPBCAA::myConst, CoulombPBCAA::use_offload_, and OperatorBase::value_.

Referenced by qmcplusplus::test_CoulombPBCAA_3p().

218 {
219  auto& o_leader = o_list.getCastedLeader<CoulombPBCAA>();
220  auto& p_leader = p_list.getLeader();
221  assert(this == &o_list.getLeader());
222 
223  if (!o_leader.is_active)
224  return;
225 
226  if (use_offload_)
227  {
228  if (o_leader.streaming_particles_)
229  throw std::runtime_error("Streaming particles is not supported when offloading in CoulombPBCAA");
230 
231  auto short_range_results = mw_evalSR_offload(o_list, p_list);
232 
233  for (int iw = 0; iw < o_list.size(); iw++)
234  {
235  auto& coulomb_aa = o_list.getCastedElement<CoulombPBCAA>(iw);
236  coulomb_aa.value_ = coulomb_aa.evalLR(p_list[iw]) + short_range_results[iw] + myConst;
237  }
238  }
239  else
240  OperatorBase::mw_evaluate(o_list, wf_list, p_list);
241 }
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.
const bool use_offload_
if true use offload
Definition: CoulombPBCAA.h:191
static std::vector< Return_t > mw_evalSR_offload(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< ParticleSet > &p_list)
CoulombPBCAA(ParticleSet &ref, bool active, bool computeForces, bool use_offload)
constructor

◆ mw_evaluatePerParticle()

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 >> &  ion_listeners 
) const
overridevirtual

Evaluate the contribution of this component of multiple walkers per particle reporting to registered listeners from Estimators.

Reimplemented from OperatorBase.

Definition at line 243 of file CoulombPBCAA.cpp.

References APP_ABORT, RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), CoulombPBCAA::myConst, qmcplusplus::pset, qmcplusplus::Units::time::s, qmcplusplus::SUPERCELL_SLAB, and OperatorBase::value_.

Referenced by qmcplusplus::TEST_CASE().

248 {
249  auto& o_leader = o_list.getCastedLeader<CoulombPBCAA>();
250  auto& p_leader = p_list.getLeader();
251  assert(this == &o_list.getLeader());
252 
253  if (!o_leader.is_active)
254  return;
255 
256  auto num_centers = p_leader.getTotalNum();
257  auto name(o_leader.getName());
258  Vector<RealType>& v_sample = o_leader.mw_res_handle_.getResource().v_sample;
259  const auto& pp_consts = o_leader.mw_res_handle_.getResource().pp_consts;
260  auto num_species = p_leader.getSpeciesSet().getTotalNum();
261  v_sample.resize(num_centers);
262  // This lambda is mostly about getting a handle on what is being touched by the per particle evaluation.
263  auto evaluate_walker = [num_species, num_centers, name, &v_sample,
264  &pp_consts](const int walker_index, const CoulombPBCAA& cpbcaa, const ParticleSet& pset,
265  const std::vector<ListenerVector<RealType>>& listeners) -> RealType {
266  mRealType Vsr = 0.0;
267  mRealType Vlr = 0.0;
268  mRealType Vc = cpbcaa.myConst;
269  std::fill(v_sample.begin(), v_sample.end(), 0.0);
270  {
271  //SR
272  const auto& d_aa(pset.getDistTableAA(cpbcaa.d_aa_ID));
273  RealType z;
274  for (int ipart = 1; ipart < num_centers; ipart++)
275  {
276  z = .5 * cpbcaa.Zat[ipart];
277  const auto& dist = d_aa.getDistRow(ipart);
278  for (int jpart = 0; jpart < ipart; ++jpart)
279  {
280  RealType pairpot = z * cpbcaa.Zat[jpart] * cpbcaa.rVs->splint(dist[jpart]) / dist[jpart];
281  v_sample[ipart] += pairpot;
282  v_sample[jpart] += pairpot;
283  Vsr += pairpot;
284  }
285  }
286  Vsr *= 2.0;
287  }
288  {
289  //LR
290  const StructFact& PtclRhoK(pset.getSK());
291  if (PtclRhoK.SuperCellEnum == SUPERCELL_SLAB)
292  {
293  APP_ABORT("CoulombPBCAA::evaluate_sp single particle traces have not been implemented for slab geometry");
294  }
295  else
296  {
297  assert(PtclRhoK.isStorePerParticle()); // ensure this so we know eikr_r has been allocated
298  //jtk mark: needs optimizations
299  RealType v1; //single particle energy
300  RealType z;
301  for (int i = 0; i < num_centers; i++)
302  {
303  z = .5 * cpbcaa.Zat[i];
304  v1 = 0.0;
305  for (int s = 0; s < num_species; ++s)
306  v1 += z * cpbcaa.Zspec[s] *
307  cpbcaa.AA->evaluate(pset.getSimulationCell().getKLists().kshell, PtclRhoK.rhok_r[s], PtclRhoK.rhok_i[s],
308  PtclRhoK.eikr_r[i], PtclRhoK.eikr_i[i]);
309  v_sample[i] += v1;
310  Vlr += v1;
311  }
312  }
313  }
314  for (int i = 0; i < v_sample.size(); ++i)
315  v_sample[i] += pp_consts[i];
316  RealType value = Vsr + Vlr + Vc;
317 
318  for (const ListenerVector<RealType>& listener : listeners)
319  listener.report(walker_index, name, v_sample);
320  return value;
321  };
322 
323  for (int iw = 0; iw < o_list.size(); iw++)
324  {
325  auto& coulomb_aa = o_list.getCastedElement<CoulombPBCAA>(iw);
326  coulomb_aa.value_ = evaluate_walker(iw, coulomb_aa, p_list[iw], listeners);
327  }
328 }
LRHandlerType::mRealType mRealType
Definition: CoulombPBCAA.h:43
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
QMCTraits::RealType RealType
CoulombPBCAA(ParticleSet &ref, bool active, bool computeForces, bool use_offload)
constructor

◆ put()

bool put ( xmlNodePtr  cur)
inlineoverridevirtual

Do nothing.

Implements OperatorBase.

Definition at line 125 of file CoulombPBCAA.h.

125 { return true; }

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
overridevirtual

return a shared resource to a collection

Reimplemented from OperatorBase.

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
overridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 161 of file CoulombPBCAA.cpp.

References CoulombPBCAA::AA, CoulombPBCAA::d_aa_ID, ParticleSet::getDistTable(), CoulombPBCAA::is_active, and CoulombPBCAA::PtclRefName.

162 {
163  if (is_active)
164  {
165  PtclRefName = P.getDistTable(d_aa_ID).getName();
166  AA->resetTargetParticleSet(P);
167  }
168 }
const int d_aa_ID
AA table ID.
Definition: CoulombPBCAA.h:193
std::shared_ptr< LRHandlerType > AA
energy-optimized long range handle. Should be const LRHandlerType eventually
Definition: CoulombPBCAA.h:47

◆ 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 159 of file CoulombPBCAA.h.

References CoulombPBCAA::ComputeForces, OperatorBase::setObservables(), and ForceBase::setObservablesF().

160  {
162  if (ComputeForces)
163  setObservablesF(plist);
164  }
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAA.h:79
void setObservablesF(QMCTraits::PropertySetType &plist)
Definition: ForceBase.cpp:86
virtual void setObservables(PropertySetType &plist)
Set the values evaluated by this object to plist Default implementation is to assign Value which is u...

◆ setParticlePropertyList()

void setParticlePropertyList ( PropertySetType plist,
int  offset 
)
inlineoverridevirtual

Reimplemented from OperatorBase.

Definition at line 166 of file CoulombPBCAA.h.

References CoulombPBCAA::ComputeForces, OperatorBase::setParticlePropertyList(), and ForceBase::setParticleSetF().

167  {
169  if (ComputeForces)
170  setParticleSetF(plist, offset);
171  }
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAA.h:79
void setParticleSetF(QMCTraits::PropertySetType &plist, int offset)
Definition: ForceBase.cpp:113
virtual void setParticlePropertyList(PropertySetType &plist, int offset)

◆ updateSource()

void updateSource ( ParticleSet s)
overridevirtual

Update data associated with a particleset.

Default implementation does nothing. Only A-A interactions for s needs to implement its own method.

Parameters
ssource particle set

Reimplemented from OperatorBase.

Definition at line 144 of file CoulombPBCAA.cpp.

References CoulombPBCAA::ComputeForces, CoulombPBCAA::evalLR(), CoulombPBCAA::evalLRwithForces(), CoulombPBCAA::evalSR(), CoulombPBCAA::evalSRwithForces(), ForceBase::forces_, CoulombPBCAA::myConst, OperatorBase::new_value_, qmcplusplus::Units::time::s, and OperatorBase::value_.

Referenced by CoulombPBCAA::CoulombPBCAA().

145 {
146  mRealType eL(0.0), eS(0.0);
147  if (ComputeForces)
148  {
149  forces_ = 0.0;
150  eS = evalSRwithForces(s);
151  eL = evalLRwithForces(s);
152  }
153  else
154  {
155  eL = evalLR(s);
156  eS = evalSR(s);
157  }
158  new_value_ = value_ = eL + eS + myConst;
159 }
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
Return_t evalSR(ParticleSet &P)
LRHandlerType::mRealType mRealType
Definition: CoulombPBCAA.h:43
Return_t evalLR(ParticleSet &P)
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAA.h:79
Return_t evalSRwithForces(ParticleSet &P)
Return_t new_value_
a new value for a proposed move
Definition: OperatorBase.h:538
Return_t value_
current value
Definition: OperatorBase.h:524
Return_t evalLRwithForces(ParticleSet &P)

Member Data Documentation

◆ AA

std::shared_ptr<LRHandlerType> AA

energy-optimized long range handle. Should be const LRHandlerType eventually

Definition at line 47 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::CoulombPBCAA(), CoulombPBCAA::evaluate_sp(), CoulombPBCAA::initBreakup(), and CoulombPBCAA::resetTargetParticleSet().

◆ ChargeAttribIndx

int ChargeAttribIndx

Definition at line 61 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::initBreakup().

◆ ComputeForces

◆ d_aa_ID

const int d_aa_ID
private

◆ dAA

std::shared_ptr<const LRHandlerType> dAA

force-optimized long range handle

Definition at line 53 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::evalLRwithForces(), and CoulombPBCAA::initBreakup().

◆ del_eikr

Vector<ComplexType> del_eikr

Definition at line 77 of file CoulombPBCAA.h.

◆ dSR

Definition at line 76 of file CoulombPBCAA.h.

◆ evalLR_timer_

NewTimer& evalLR_timer_
private

Timer for long range.

Definition at line 195 of file CoulombPBCAA.h.

◆ evalSR_timer_

NewTimer& evalSR_timer_
private

Timer for long range.

Definition at line 197 of file CoulombPBCAA.h.

◆ FirstTime

bool FirstTime

Definition at line 58 of file CoulombPBCAA.h.

◆ is_active

◆ madelung_constant_

RealType madelung_constant_
private

◆ MemberAttribIndx

int MemberAttribIndx

Definition at line 62 of file CoulombPBCAA.h.

◆ mw_res_handle_

Definition at line 202 of file CoulombPBCAA.h.

◆ myConst

◆ myRcut

RealType myRcut

cutoff radius of the short-range part

Definition at line 66 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::initBreakup().

◆ NofSpecies

std::vector<int> NofSpecies

Definition at line 72 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::initBreakup().

◆ NumCenters

◆ NumSpecies

int NumSpecies

◆ offload_timer_

NewTimer& offload_timer_
private

Timer for offload part.

Definition at line 199 of file CoulombPBCAA.h.

◆ Ps

◆ PtclRefName

std::string PtclRefName

◆ quasi2d

const bool quasi2d

Flag for whether to use quasi-2D Ewald.

Definition at line 81 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::CoulombPBCAA().

◆ rVs

std::shared_ptr<const RadFunctorType> rVs

energy-optimized short range pair potential

Definition at line 49 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::evalSRwithForces(), CoulombPBCAA::evaluate_sp(), and CoulombPBCAA::initBreakup().

◆ rVs_offload

std::shared_ptr<const OffloadSpline> rVs_offload

the same as rVs but can be used inside OpenMP offload regions

Definition at line 51 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::initBreakup().

◆ rVsforce

std::shared_ptr<const RadFunctorType> rVsforce

force-optimized short range pair potential

Definition at line 55 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::evalSRwithForces(), and CoulombPBCAA::initBreakup().

◆ SourceID

int SourceID

Definition at line 59 of file CoulombPBCAA.h.

◆ SpeciesID

std::vector<int> SpeciesID

Definition at line 73 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::initBreakup().

◆ SR2

Definition at line 75 of file CoulombPBCAA.h.

◆ use_offload_

const bool use_offload_
private

if true use offload

Definition at line 191 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::CoulombPBCAA(), and CoulombPBCAA::mw_evaluate().

◆ V_const

Array<TraceReal, 1> V_const

Definition at line 86 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::evaluate_sp(), and CoulombPBCAA::initBreakup().

◆ V_sample

◆ Zat

◆ Zat_offload

std::shared_ptr<Vector<RealType, OffloadPinnedAllocator<RealType> > > Zat_offload

Definition at line 70 of file CoulombPBCAA.h.

Referenced by CoulombPBCAA::initBreakup().

◆ Zspec

std::vector<RealType> Zspec

◆ qmcplusplus::CoulombPBCAB

class qmcplusplus::CoulombPBCAB

Calculates the AA Coulomb potential using PBCs.

Functionally identical to CoulombPBCAB but uses a templated version of LRHandler.

Definition at line 38 of file CoulombPBCAB.h.

+ Inheritance diagram for CoulombPBCAB:
+ Collaboration diagram for CoulombPBCAB:

Public Types

using LRHandlerType = LRCoulombSingleton::LRHandlerType
 
using GridType = LRCoulombSingleton::GridType
 
using RadFunctorType = LRCoulombSingleton::RadFunctorType
 
using mRealType = LRHandlerType::mRealType
 
- 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 Types inherited from ForceBase
using Real = QMCTraits::RealType
 cheat, need to use virtual inheriance to clean up More...
 

Public Member Functions

 CoulombPBCAB (ParticleSet &ions, ParticleSet &elns, bool computeForces=false)
 
 ~CoulombPBCAB () override
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
std::string getClassName () const override
 return class name More...
 
void contributeParticleQuantities () override
 
void checkoutParticleQuantities (TraceManager &tm) override
 
Return_t evaluate_sp (ParticleSet &P)
 
void deleteParticleQuantities () override
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
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 >> &ion_listeners) const override
 Evaluate the contribution of this component of multiple walkers per particle reporting to registered listeners from Estimators. More...
 
Return_t evaluateWithIonDerivs (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms) override
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
bool put (xmlNodePtr cur) override
 Do nothing. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) override
 
Return_t evalSR (ParticleSet &P)
 Computes the short-range contribution to the coulomb energy. More...
 
Return_t evalLR (ParticleSet &P)
 Computes the long-range contribution to the coulomb energy. More...
 
Return_t evalSRwithForces (ParticleSet &P)
 Computes the short-range contribution to the coulomb energy and forces. More...
 
Return_t evalLRwithForces (ParticleSet &P)
 Computes the long-range contribution to the coulomb energy and forces. More...
 
Return_t evalConsts (const ParticleSet &P, bool report=true)
 Evaluates madelung and background contributions to total energy. More...
 
void add (int groupID, std::unique_ptr< RadFunctorType > &&ppot)
 Adds a local pseudopotential channel "ppot" to all source species of type "groupID". More...
 
void addObservables (PropertySetType &plist, BufferType &collectables) override
 named values to the property list Default implementaton uses addValue(plist_) 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
 
const ParticleSetgetSourcePSet () const
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
 return a shared resource to a collection More...
 
void informOfPerParticleListener () override
 Call to inform objects associated with this operator of per particle listeners. 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 registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 
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_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 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 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...
 
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 Member Functions inherited from ForceBase
Real g (Real r)
 
void initVarReduction (Real rcut, int m, int numFuncs)
 
 ForceBase (ParticleSet &ions, ParticleSet &elns)
 
virtual ~ForceBase ()
 
void registerObservablesF (std::vector< ObservableHelper > &h5list, hdf_archive &file) const
 
void addObservablesF (QMCTraits::PropertySetType &plist)
 
void addObservablesStress (QMCTraits::PropertySetType &plist)
 
void setObservablesF (QMCTraits::PropertySetType &plist)
 
void setObservablesStress (QMCTraits::PropertySetType &plist)
 
void setParticleSetF (QMCTraits::PropertySetType &plist, int offset)
 
void setParticleSetStress (QMCTraits::PropertySetType &plist, int offset)
 
bool getAddIonIon () const noexcept
 
void setAddIonIon (bool val) noexcept
 
const ParticleSet::ParticlePosgetForces () const noexcept
 
void setForces (const ParticleSet::ParticlePos &forces)
 
void setForces (Real val)
 
const ParticleSet::ParticlePosgetForcesIonIon () const noexcept
 
void setForcesIonIon (const ParticleSet::ParticlePos &forces_ion_ion)
 
const SymTensor< Real, OHMMS_DIM > & getStressIonIon () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStressEE () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStressEI () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStressKin () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStress () const noexcept
 

Public Attributes

std::shared_ptr< LRHandlerTypeAB
 long-range Handler. Should be const LRHandlerType eventually More...
 
std::shared_ptr< const LRHandlerTypedAB
 long-range derivative handler More...
 
const int myTableIndex
 locator of the distance table More...
 
int NumSpeciesA
 number of species of A particle set More...
 
int NumSpeciesB
 number of species of B particle set More...
 
int NptclA
 number of particles of A More...
 
int NptclB
 number of particles of B More...
 
Return_t myConst
 const energy after breakup More...
 
RealType myRcut
 cutoff radius of the short-range part More...
 
std::shared_ptr< const RadFunctorTypeV0
 Always mave a radial functor for the bare coulomb. More...
 
std::shared_ptr< const RadFunctorTypefV0
 Radial functor for bare coulomb, optimized for forces. More...
 
std::shared_ptr< const RadFunctorTypedfV0
 Radial functor for derivative of bare coulomb, optimized for forces. More...
 
bool ComputeForces
 Flag for whether to compute forces or not. More...
 
std::vector< int > NofSpeciesA
 number of particles per species of A More...
 
std::vector< int > NofSpeciesB
 number of particles per species of B More...
 
std::vector< RealTypeZat
 Zat[iat] charge for the iat-th particle of A. More...
 
std::vector< RealTypeQat
 Qat[iat] charge for the iat-th particle of B. More...
 
std::vector< RealTypeZspec
 Zspec[spec] charge for the spec-th species of A. More...
 
std::vector< RealTypeQspec
 Qspec[spec] charge for the spec-th species of B. More...
 
std::vector< const RadFunctorType * > Vat
 Short-range potential for each ion. More...
 
std::vector< std::shared_ptr< RadFunctorType > > Vspec
 Short-range potential for each species. More...
 
std::vector< const RadFunctorType * > fVat
 Short-range potential (r*V) and potential derivative d/dr(rV) derivative for each ion Required for force evaluations. More...
 
std::vector< const RadFunctorType * > fdVat
 
std::vector< std::shared_ptr< const RadFunctorType > > fVspec
 
std::vector< std::shared_ptr< const RadFunctorType > > fdVspec
 
bool kcdifferent
 
RealType minkc
 
Array< TraceReal, 1 > * Ve_sample
 
Array< TraceReal, 1 > * Vi_sample
 
Array< TraceReal, 1 > Ve_const
 
Array< TraceReal, 1 > Vi_const
 
ParticleSetPeln
 
RealType SRtmp
 short-range part for the moved particle More...
 
RealType LRtmp
 long-range part for the moved particle More...
 
Vector< RealTypeSRpart
 short-range per particle More...
 
Vector< RealTypeLRpart
 long-range per particle More...
 

Protected Member Functions

void initBreakup (ParticleSet &P)
 Creates the long-range handlers, then splines and stores it by particle and species for quick evaluation. More...
 
- Protected Member Functions inherited from OperatorBase
virtual void contributeScalarQuantities ()
 
virtual void checkoutScalarQuantities (TraceManager &tm)
 
virtual void collectScalarQuantities ()
 
virtual void deleteScalarQuantities ()
 
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...
 

Private Member Functions

void evalPerParticleConsts (Vector< RealType > &pp_consts_src, Vector< RealType > &pp_consts_trg) const
 Compute the const part of the per particle coulomb AB potential. More...
 

Private Attributes

ParticleSetpset_ions_
 source particle set More...
 
ResourceHandle< CoulombPBCABMultiWalkerResourcemw_res_handle_
 

Additional Inherited Members

- 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_
 
- Protected Attributes inherited from ForceBase
int first_force_index_
 
int n_nuc_
 
int n_el_
 
int tries_
 
bool first_time_
 
bool add_ion_ion_
 Determines if ion-ion force will be added to electron-ion force in derived force estimators. If false, forces_ion_ion_=0.0. More...
 
ParticleSetions_
 
ParticleSet::ParticlePos forces_
 
ParticleSet::ParticlePos forces_ion_ion_
 
SymTensor< Real, OHMMS_DIMstress_ion_ion_
 
SymTensor< Real, OHMMS_DIMstress_ee_
 
SymTensor< Real, OHMMS_DIMstress_ei_
 
SymTensor< Real, OHMMS_DIMstress_kin_
 
SymTensor< Real, OHMMS_DIMstress_
 
std::string prefix_
 
std::string pair_name_
 
Real rcut_
 
int m_
 
std::vector< Realck_
 

Member Typedef Documentation

◆ GridType

Definition at line 42 of file CoulombPBCAB.h.

◆ LRHandlerType

◆ mRealType

using mRealType = LRHandlerType::mRealType

Definition at line 44 of file CoulombPBCAB.h.

◆ RadFunctorType

Constructor & Destructor Documentation

◆ CoulombPBCAB()

CoulombPBCAB ( ParticleSet ions,
ParticleSet elns,
bool  computeForces = false 
)

Definition at line 43 of file CoulombPBCAB.cpp.

References CoulombPBCAB::AB, qmcplusplus::app_log(), CoulombPBCAB::ComputeForces, CoulombPBCAB::initBreakup(), CoulombPBCAB::myRcut, OperatorBase::POTENTIAL, ForceBase::prefix_, CoulombPBCAB::pset_ions_, OperatorBase::setEnergyDomain(), ParticleSet::turnOnPerParticleSK(), and OperatorBase::twoBodyQuantumDomain().

44  : ForceBase(ions, elns),
45  myTableIndex(elns.addTable(ions)),
46  myConst(0.0),
47  ComputeForces(computeForces),
48  Peln(elns),
49  pset_ions_(ions)
50 {
51  ReportEngine PRE("CoulombPBCAB", "CoulombPBCAB");
53  twoBodyQuantumDomain(ions, elns);
54  if (ComputeForces)
56  initBreakup(elns);
57  prefix_ = "Flocal";
58  app_log() << " Rcut " << myRcut << std::endl;
59  app_log() << " Maximum K shell " << AB->MaxKshell << std::endl;
60  app_log() << " Number of k vectors " << AB->Fk.size() << std::endl;
61 }
void twoBodyQuantumDomain(const ParticleSet &P)
set quantum domain for two-body operator
Return_t myConst
const energy after breakup
Definition: CoulombPBCAB.h:61
std::shared_ptr< LRHandlerType > AB
long-range Handler. Should be const LRHandlerType eventually
Definition: CoulombPBCAB.h:47
std::ostream & app_log()
Definition: OutputManager.h:65
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAB.h:71
ForceBase(ParticleSet &ions, ParticleSet &elns)
Definition: ForceBase.cpp:28
std::string prefix_
Definition: ForceBase.h:96
const int myTableIndex
locator of the distance table
Definition: CoulombPBCAB.h:51
void turnOnPerParticleSK()
Turn on per particle storage in Structure Factor.
RealType myRcut
cutoff radius of the short-range part
Definition: CoulombPBCAB.h:63
void initBreakup(ParticleSet &P)
Creates the long-range handlers, then splines and stores it by particle and species for quick evaluat...
void setEnergyDomain(EnergyDomains edomain)
Set the Energy Domain.
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230

◆ ~CoulombPBCAB()

~CoulombPBCAB ( )
overridedefault

Member Function Documentation

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
overridevirtual

acquire a shared resource from a collection

Reimplemented from OperatorBase.

Definition at line 749 of file CoulombPBCAB.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), ResourceCollection::lendResource(), and CoulombPBCAB::mw_res_handle_.

751 {
752  auto& o_leader = o_list.getCastedLeader<CoulombPBCAB>();
753  o_leader.mw_res_handle_ = collection.lendResource<CoulombPBCABMultiWalkerResource>();
754 }
CoulombPBCAB(ParticleSet &ions, ParticleSet &elns, bool computeForces=false)

◆ add()

void add ( int  groupID,
std::unique_ptr< RadFunctorType > &&  ppot 
)

Adds a local pseudopotential channel "ppot" to all source species of type "groupID".

add a local pseudo potential

Parameters
groupIDspecies index
ppotradial functor for $rV_{loc}$ on a grid

Definition at line 561 of file CoulombPBCAB.cpp.

References CoulombPBCAB::AB, qmcplusplus::app_log(), CoulombPBCAB::ComputeForces, OHMMS::Controller, CoulombPBCAB::dAB, qmcplusplus::Units::charge::e, CoulombPBCAB::fdVat, CoulombPBCAB::fdVspec, CoulombPBCAB::fVat, CoulombPBCAB::fVspec, ParticleSet::GroupID, omptarget::min(), CoulombPBCAB::myRcut, CoulombPBCAB::NptclA, CoulombPBCAB::pset_ions_, qmcplusplus::rank, LinearGrid< T, CT >::set(), CoulombPBCAB::V0, CoulombPBCAB::Vat, and CoulombPBCAB::Vspec.

562 {
563  //FIXME still using magic numbers in the local potential grid.
564  const int MaxGridPoints = 10000;
565  const size_t ng = std::min(MaxGridPoints, static_cast<int>(myRcut / 1e-3) + 1);
566  app_log() << " CoulombPBCAB::add \n Setting a linear grid=[0," << myRcut << ") number of grid =" << ng
567  << std::endl;
568  auto agrid_local = LinearGrid<RealType>();
569  agrid_local.set(0.0, myRcut, ng);
570  RealType dr = agrid_local[1] - agrid_local[0];
571  if (Vspec[groupID] == nullptr)
572  {
573  V0.reset();
574 
575  app_log() << " Creating the short-range pseudopotential for species " << groupID << std::endl;
576  std::vector<RealType> v(ng);
577  for (int ig = 1; ig < ng - 2; ig++)
578  {
579  RealType r = agrid_local[ig];
580  //need to multiply r for the LR
581  v[ig] = -r * AB->evaluateLR(r) + ppot->splint(r);
582  }
583  v[0] = 2.0 * v[1] - v[2];
584  //by construction, v has to go to zero at the boundary
585  v[ng - 2] = 0.0;
586  v[ng - 1] = 0.0;
587  RealType deriv = (v[1] - v[0]) / dr;
588  auto rfunc = std::make_unique<RadFunctorType>(agrid_local.makeClone(), v);
589  rfunc->spline(0, deriv, ng - 1, 0.0);
590  for (int iat = 0; iat < NptclA; iat++)
591  {
592  if (pset_ions_.GroupID[iat] == groupID)
593  Vat[iat] = rfunc.get();
594  }
595  Vspec[groupID] = std::move(rfunc);
596  }
597 
598  if (ComputeForces && fVspec[groupID] == nullptr)
599  {
600  app_log() << " Creating the short-range pseudopotential derivatives for species " << groupID << std::endl;
601  //This is the value coming from optimized breakup for FORCES, not for energy.
602  //Also. Goal of this section is to create and store d/dr(rV), not d/dr(V)!!!
603  std::vector<RealType> v(ng);
604  std::vector<RealType> dv(ng);
605 
606  RealType ppot_val(0), ppot_deriv(0), ppot_2deriv(0);
607  RealType lr_val(0), lr_deriv(0);
608  for (int ig = 1; ig < ng - 2; ig++)
609  {
610  RealType r = agrid_local[ig];
611  ppot_val = ppot->splint(r, ppot_deriv, ppot_2deriv);
612  lr_val = dAB->evaluateLR(r);
613  lr_deriv = dAB->lrDf(r);
614 
615  v[ig] = ppot_val - r * lr_val;
616  dv[ig] = ppot_deriv - (lr_val + lr_deriv * r);
617  }
618  //This is a linear interpolation from v[2] and v[1] to v[0], assuming linear behavior.
619  v[0] = 2.0 * v[1] - v[2];
620  v[ng - 2] = 0.0;
621  v[ng - 1] = 0.0;
622 
623  dv[0] = 2.0 * dv[1] - dv[2];
624  dv[ng - 2] = 0;
625  dv[ng - 1] = 0;
626 
627  auto ffunc = std::make_unique<RadFunctorType>(agrid_local.makeClone(), v);
628  auto fdfunc = std::make_unique<RadFunctorType>(agrid_local.makeClone(), dv);
629 
630  RealType fderiv = (dv[1] - dv[0]) / dr;
631 
632  ffunc->spline(0, dv[0], ng - 1, 0.0);
633  fdfunc->spline(0, fderiv, ng - 1, 0.0);
634 
635  for (int iat = 0; iat < NptclA; iat++)
636  {
637  if (pset_ions_.GroupID[iat] == groupID)
638  {
639  fVat[iat] = ffunc.get();
640  fdVat[iat] = fdfunc.get();
641  }
642  }
643  fVspec[groupID] = std::move(ffunc);
644  fdVspec[groupID] = std::move(fdfunc);
645  //Done
646  }
647 
648  if (ComputeForces)
649  {
650  if (OHMMS::Controller->rank() == 0)
651  {
652  FILE* fout = fopen("Vlocal.dat", "w");
653  for (RealType r = 1.0e-8; r < myRcut; r += 1.0e-2)
654  {
655  RealType d_rV_dr, d2_rV_dr2;
656  RealType Vr = Vat[0]->splint(r, d_rV_dr, d2_rV_dr2);
657  Vr = Vat[0]->splint(r);
658  fprintf(fout, "%1.8e %1.12e %1.12e %1.12e\n", r, Vr, d_rV_dr, d2_rV_dr2);
659  }
660  fclose(fout);
661  }
662  }
663 }
std::vector< const RadFunctorType * > fdVat
Definition: CoulombPBCAB.h:92
std::vector< const RadFunctorType * > Vat
Short-range potential for each ion.
Definition: CoulombPBCAB.h:86
std::shared_ptr< LRHandlerType > AB
long-range Handler. Should be const LRHandlerType eventually
Definition: CoulombPBCAB.h:47
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< std::shared_ptr< RadFunctorType > > Vspec
Short-range potential for each species.
Definition: CoulombPBCAB.h:88
std::vector< std::shared_ptr< const RadFunctorType > > fVspec
Definition: CoulombPBCAB.h:94
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAB.h:71
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
T min(T a, T b)
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
std::shared_ptr< const RadFunctorType > V0
Always mave a radial functor for the bare coulomb.
Definition: CoulombPBCAB.h:65
std::vector< std::shared_ptr< const RadFunctorType > > fdVspec
Definition: CoulombPBCAB.h:95
RealType myRcut
cutoff radius of the short-range part
Definition: CoulombPBCAB.h:63
int NptclA
number of particles of A
Definition: CoulombPBCAB.h:57
Linear Grid inherets from Grid.
Definition: Grid.h:73
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230
std::vector< const RadFunctorType * > fVat
Short-range potential (r*V) and potential derivative d/dr(rV) derivative for each ion Required for fo...
Definition: CoulombPBCAB.h:91
QMCTraits::RealType RealType
std::shared_ptr< const LRHandlerType > dAB
long-range derivative handler
Definition: CoulombPBCAB.h:49

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

References RecordNamedProperty< T >::add(), ForceBase::addObservablesF(), CoulombPBCAB::ComputeForces, OperatorBase::my_index_, and OperatorBase::name_.

81 {
82  my_index_ = plist.add(name_.c_str());
83  if (ComputeForces)
84  addObservablesF(plist);
85 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
void addObservablesF(QMCTraits::PropertySetType &plist)
Definition: ForceBase.cpp:47
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAB.h:71
std::string name_
name of this object
Definition: OperatorBase.h:527

◆ checkoutParticleQuantities()

void checkoutParticleQuantities ( TraceManager tm)
overridevirtual

Reimplemented from OperatorBase.

Definition at line 91 of file CoulombPBCAB.cpp.

References TraceManager::checkout_real(), OperatorBase::name_, CoulombPBCAB::Peln, CoulombPBCAB::pset_ions_, OperatorBase::request_, TraceRequest::streaming_array(), OperatorBase::streaming_particles_, ParticleSet::turnOnPerParticleSK(), CoulombPBCAB::Ve_sample, and CoulombPBCAB::Vi_sample.

92 {
95  {
98  Ve_sample = tm.checkout_real<1>(name_, Peln);
99  Vi_sample = tm.checkout_real<1>(name_, pset_ions_);
100  }
101 }
Array< TraceReal, 1 > * Vi_sample
Definition: CoulombPBCAB.h:116
bool streaming_array(const std::string &name)
Definition: TraceManager.h:249
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
void turnOnPerParticleSK()
Turn on per particle storage in Structure Factor.
Array< TraceReal, 1 > * Ve_sample
Definition: CoulombPBCAB.h:115
std::string name_
name of this object
Definition: OperatorBase.h:527
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230

◆ contributeParticleQuantities()

void contributeParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 89 of file CoulombPBCAB.cpp.

References TraceRequest::contribute_array(), OperatorBase::name_, and OperatorBase::request_.

TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
std::string name_
name of this object
Definition: OperatorBase.h:527
void contribute_array(const std::string &name, bool default_quantity=false)
Definition: TraceManager.h:198

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from OperatorBase.

Definition at line 742 of file CoulombPBCAB.cpp.

References ResourceCollection::addResource(), and CoulombPBCAB::evalPerParticleConsts().

Referenced by qmcplusplus::TEST_CASE().

743 {
744  auto new_res = std::make_unique<CoulombPBCABMultiWalkerResource>();
745  evalPerParticleConsts(new_res->pp_consts_src, new_res->pp_consts_trg);
746  auto resource_index = collection.addResource(std::move(new_res));
747 }
void evalPerParticleConsts(Vector< RealType > &pp_consts_src, Vector< RealType > &pp_consts_trg) const
Compute the const part of the per particle coulomb AB potential.

◆ deleteParticleQuantities()

void deleteParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 111 of file CoulombPBCAB.cpp.

References OperatorBase::streaming_particles_, CoulombPBCAB::Ve_sample, and CoulombPBCAB::Vi_sample.

112 {
114  {
115  delete Ve_sample;
116  delete Vi_sample;
117  }
118 }
Array< TraceReal, 1 > * Vi_sample
Definition: CoulombPBCAB.h:116
Array< TraceReal, 1 > * Ve_sample
Definition: CoulombPBCAB.h:115

◆ evalConsts()

CoulombPBCAB::Return_t evalConsts ( const ParticleSet Peln,
bool  report = true 
)

Evaluates madelung and background contributions to total energy.

Evaluate the background term.

Other constants are handled by AA potentials.

$V_{bg}^{AB}=-\sum_{\alpha}\sum_{\beta} N^{\alpha} N^{\beta} q^{\alpha} q^{\beta} v_s(k=0) $

Todo:
Here is where the charge system has to be handled.

Definition at line 390 of file CoulombPBCAB.cpp.

References CoulombPBCAB::AB, qmcplusplus::app_log(), ParticleSet::getTotalNum(), CoulombPBCAB::NofSpeciesA, CoulombPBCAB::NofSpeciesB, CoulombPBCAB::NumSpeciesA, CoulombPBCAB::NumSpeciesB, CoulombPBCAB::Peln, CoulombPBCAB::pset_ions_, CoulombPBCAB::Qat, CoulombPBCAB::Qspec, Array< T, D, ALLOC >::resize(), qmcplusplus::Units::time::s, CoulombPBCAB::Ve_const, CoulombPBCAB::Vi_const, CoulombPBCAB::Zat, and CoulombPBCAB::Zspec.

Referenced by CoulombPBCAB::initBreakup(), and qmcplusplus::TEST_CASE().

391 {
392  int nelns = Peln.getTotalNum();
393  int nions = pset_ions_.getTotalNum();
394 #if !defined(REMOVE_TRACEMANAGER)
395  Ve_const.resize(nelns);
396  Vi_const.resize(nions);
397  Ve_const = 0.0;
398  Vi_const = 0.0;
399 #endif
400  mRealType Consts = 0.0;
401  mRealType vs_k0 = AB->evaluateSR_k0();
402  mRealType v1; //single particle energy
403  for (int i = 0; i < nelns; ++i)
404  {
405  v1 = 0.0;
406  for (int s = 0; s < NumSpeciesA; s++)
407  v1 += NofSpeciesA[s] * Zspec[s];
408  v1 *= -.5 * Qat[i] * vs_k0;
409 #if !defined(REMOVE_TRACEMANAGER)
410  Ve_const(i) = v1;
411 #endif
412  Consts += v1;
413  }
414  for (int i = 0; i < nions; ++i)
415  {
416  v1 = 0.0;
417  for (int s = 0; s < NumSpeciesB; s++)
418  v1 += NofSpeciesB[s] * Qspec[s];
419  v1 *= -.5 * Zat[i] * vs_k0;
420 #if !defined(REMOVE_TRACEMANAGER)
421  Vi_const(i) = v1;
422 #endif
423  Consts += v1;
424  }
425  if (report)
426  app_log() << " Constant of PBCAB " << Consts << std::endl;
427  return Consts;
428 }
int NumSpeciesB
number of species of B particle set
Definition: CoulombPBCAB.h:55
Array< TraceReal, 1 > Vi_const
Definition: CoulombPBCAB.h:118
std::shared_ptr< LRHandlerType > AB
long-range Handler. Should be const LRHandlerType eventually
Definition: CoulombPBCAB.h:47
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
LRHandlerType::mRealType mRealType
Definition: CoulombPBCAB.h:44
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
Array< TraceReal, 1 > Ve_const
Definition: CoulombPBCAB.h:117
int NumSpeciesA
number of species of A particle set
Definition: CoulombPBCAB.h:53
std::vector< RealType > Qspec
Qspec[spec] charge for the spec-th species of B.
Definition: CoulombPBCAB.h:84
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230
std::vector< int > NofSpeciesA
number of particles per species of A
Definition: CoulombPBCAB.h:74
std::vector< RealType > Qat
Qat[iat] charge for the iat-th particle of B.
Definition: CoulombPBCAB.h:80
std::vector< RealType > Zspec
Zspec[spec] charge for the spec-th species of A.
Definition: CoulombPBCAB.h:82
std::vector< RealType > Zat
Zat[iat] charge for the iat-th particle of A.
Definition: CoulombPBCAB.h:78
std::vector< int > NofSpeciesB
number of particles per species of B
Definition: CoulombPBCAB.h:76

◆ evalLR()

Computes the long-range contribution to the coulomb energy.

Definition at line 449 of file CoulombPBCAB.cpp.

References CoulombPBCAB::AB, ParticleSet::getSimulationCell(), ParticleSet::getSK(), CoulombPBCAB::NumSpeciesA, CoulombPBCAB::NumSpeciesB, CoulombPBCAB::pset_ions_, CoulombPBCAB::Qspec, qmcplusplus::SUPERCELL_SLAB, and CoulombPBCAB::Zspec.

Referenced by CoulombPBCAB::evalLRwithForces(), CoulombPBCAB::evaluate(), CoulombPBCAB::evaluate_sp(), and CoulombPBCAB::evaluateWithIonDerivs().

450 {
451  mRealType res = 0.0;
452  const StructFact& RhoKA(pset_ions_.getSK());
453  const StructFact& RhoKB(P.getSK());
454  if (RhoKA.SuperCellEnum == SUPERCELL_SLAB)
455  throw std::runtime_error(
456  "CoulombPBCAB::evalLR RhoKA.SuperCellEnum == SUPERCELL_SLAB case not implemented. There was an implementation "
457  "with complex-valued storage that may be resurrected using real-valued storage.");
458  else
459  {
460  for (int i = 0; i < NumSpeciesA; i++)
461  {
462  mRealType esum = 0.0;
463  for (int j = 0; j < NumSpeciesB; j++)
464  esum += Qspec[j] *
465  AB->evaluate(pset_ions_.getSimulationCell().getKLists().kshell, RhoKA.rhok_r[i], RhoKA.rhok_i[i],
466  RhoKB.rhok_r[j], RhoKB.rhok_i[j]);
467  res += Zspec[i] * esum;
468  }
469  } //specion
470  return res;
471 }
int NumSpeciesB
number of species of B particle set
Definition: CoulombPBCAB.h:55
std::shared_ptr< LRHandlerType > AB
long-range Handler. Should be const LRHandlerType eventually
Definition: CoulombPBCAB.h:47
LRHandlerType::mRealType mRealType
Definition: CoulombPBCAB.h:44
const auto & getSimulationCell() const
Definition: ParticleSet.h:250
const StructFact & getSK() const
return Structure Factor
Definition: ParticleSet.h:216
int NumSpeciesA
number of species of A particle set
Definition: CoulombPBCAB.h:53
std::vector< RealType > Qspec
Qspec[spec] charge for the spec-th species of B.
Definition: CoulombPBCAB.h:84
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230
std::vector< RealType > Zspec
Zspec[spec] charge for the spec-th species of A.
Definition: CoulombPBCAB.h:82

◆ evalLRwithForces()

CoulombPBCAB::Return_t evalLRwithForces ( ParticleSet P)

Computes the long-range contribution to the coulomb energy and forces.

Definition at line 665 of file CoulombPBCAB.cpp.

References CoulombPBCAB::dAB, CoulombPBCAB::evalLR(), ForceBase::forces_, ParticleSet::getTotalNum(), CoulombPBCAB::NumSpeciesB, CoulombPBCAB::pset_ions_, CoulombPBCAB::Qspec, and CoulombPBCAB::Zat.

Referenced by CoulombPBCAB::evaluate(), and CoulombPBCAB::evaluateWithIonDerivs().

666 {
667  // const StructFact& RhoKA(pset_ions_.getSK());
668  // const StructFact& RhoKB(P.getSK());
669  std::vector<TinyVector<RealType, DIM>> grad(pset_ions_.getTotalNum());
670  for (int j = 0; j < NumSpeciesB; j++)
671  {
672  for (int iat = 0; iat < grad.size(); iat++)
673  grad[iat] = TinyVector<RealType, DIM>(0.0, 0.0, 0.0);
674  dAB->evaluateGrad(pset_ions_, P, j, Zat, grad);
675  for (int iat = 0; iat < grad.size(); iat++)
676  forces_[iat] += Qspec[j] * grad[iat];
677  } // electron species
678  return evalLR(P);
679 }
int NumSpeciesB
number of species of B particle set
Definition: CoulombPBCAB.h:55
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::vector< RealType > Qspec
Qspec[spec] charge for the spec-th species of B.
Definition: CoulombPBCAB.h:84
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230
std::vector< RealType > Zat
Zat[iat] charge for the iat-th particle of A.
Definition: CoulombPBCAB.h:78
std::shared_ptr< const LRHandlerType > dAB
long-range derivative handler
Definition: CoulombPBCAB.h:49
Return_t evalLR(ParticleSet &P)
Computes the long-range contribution to the coulomb energy.

◆ evalPerParticleConsts()

void evalPerParticleConsts ( Vector< RealType > &  pp_consts_src,
Vector< RealType > &  pp_consts_trg 
) const
private

Compute the const part of the per particle coulomb AB potential.

Parameters
[out]pp_consts_srcconstant values for the source particles aka ions aka A
[out]pp_consts_trgconstant values for the target particles aka electrons aka B

Definition at line 715 of file CoulombPBCAB.cpp.

References CoulombPBCAB::AB, ParticleSet::getTotalNum(), CoulombPBCAB::NofSpeciesA, CoulombPBCAB::NofSpeciesB, CoulombPBCAB::NumSpeciesA, CoulombPBCAB::NumSpeciesB, CoulombPBCAB::Peln, CoulombPBCAB::pset_ions_, CoulombPBCAB::Qat, CoulombPBCAB::Qspec, Vector< T, Alloc >::resize(), qmcplusplus::Units::time::s, CoulombPBCAB::Zat, and CoulombPBCAB::Zspec.

Referenced by CoulombPBCAB::createResource().

716 {
717  int nelns = Peln.getTotalNum();
718  int nions = pset_ions_.getTotalNum();
719  pp_consts_trg.resize(nelns, 0.0);
720  pp_consts_src.resize(nions, 0.0);
721 
722  RealType vs_k0 = AB->evaluateSR_k0();
723  RealType v1; //single particle energy
724  for (int i = 0; i < nelns; ++i)
725  {
726  v1 = 0.0;
727  for (int s = 0; s < NumSpeciesA; s++)
728  v1 += NofSpeciesA[s] * Zspec[s];
729  v1 *= -.5 * Qat[i] * vs_k0;
730  pp_consts_trg[i] = v1;
731  }
732  for (int i = 0; i < nions; ++i)
733  {
734  v1 = 0.0;
735  for (int s = 0; s < NumSpeciesB; s++)
736  v1 += NofSpeciesB[s] * Qspec[s];
737  v1 *= -.5 * Zat[i] * vs_k0;
738  pp_consts_src[i] = v1;
739  }
740 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
int NumSpeciesB
number of species of B particle set
Definition: CoulombPBCAB.h:55
std::shared_ptr< LRHandlerType > AB
long-range Handler. Should be const LRHandlerType eventually
Definition: CoulombPBCAB.h:47
size_t getTotalNum() const
Definition: ParticleSet.h:493
int NumSpeciesA
number of species of A particle set
Definition: CoulombPBCAB.h:53
std::vector< RealType > Qspec
Qspec[spec] charge for the spec-th species of B.
Definition: CoulombPBCAB.h:84
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230
std::vector< int > NofSpeciesA
number of particles per species of A
Definition: CoulombPBCAB.h:74
QMCTraits::RealType RealType
std::vector< RealType > Qat
Qat[iat] charge for the iat-th particle of B.
Definition: CoulombPBCAB.h:80
std::vector< RealType > Zspec
Zspec[spec] charge for the spec-th species of A.
Definition: CoulombPBCAB.h:82
std::vector< RealType > Zat
Zat[iat] charge for the iat-th particle of A.
Definition: CoulombPBCAB.h:78
std::vector< int > NofSpeciesB
number of particles per species of B
Definition: CoulombPBCAB.h:76

◆ evalSR()

Computes the short-range contribution to the coulomb energy.

Definition at line 431 of file CoulombPBCAB.cpp.

References BLAS::czero, ParticleSet::getDistTableAB(), CoulombPBCAB::myTableIndex, CoulombPBCAB::NptclA, CoulombPBCAB::NptclB, CoulombPBCAB::Qat, CoulombPBCAB::Vat, and CoulombPBCAB::Zat.

Referenced by CoulombPBCAB::evaluate(), CoulombPBCAB::evaluate_sp(), and CoulombPBCAB::evaluateWithIonDerivs().

432 {
433  constexpr mRealType czero(0);
434  const auto& d_ab(P.getDistTableAB(myTableIndex));
435  mRealType res = czero;
436  //can be optimized but not important enough
437  for (size_t b = 0; b < NptclB; ++b)
438  {
439  const auto& dist = d_ab.getDistRow(b);
440  mRealType esum = czero;
441  for (size_t a = 0; a < NptclA; ++a)
442  esum += Zat[a] * Vat[a]->splint(dist[a]) / dist[a];
443  res += esum * Qat[b];
444  }
445  return res;
446 }
std::vector< const RadFunctorType * > Vat
Short-range potential for each ion.
Definition: CoulombPBCAB.h:86
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
LRHandlerType::mRealType mRealType
Definition: CoulombPBCAB.h:44
const int myTableIndex
locator of the distance table
Definition: CoulombPBCAB.h:51
int NptclB
number of particles of B
Definition: CoulombPBCAB.h:59
int NptclA
number of particles of A
Definition: CoulombPBCAB.h:57
std::vector< RealType > Qat
Qat[iat] charge for the iat-th particle of B.
Definition: CoulombPBCAB.h:80
std::vector< RealType > Zat
Zat[iat] charge for the iat-th particle of A.
Definition: CoulombPBCAB.h:78

◆ evalSRwithForces()

CoulombPBCAB::Return_t evalSRwithForces ( ParticleSet P)

Computes the short-range contribution to the coulomb energy and forces.

Definition at line 681 of file CoulombPBCAB.cpp.

References BLAS::czero, CoulombPBCAB::fdVat, ForceBase::forces_, CoulombPBCAB::fVat, ParticleSet::getDistTableAB(), CoulombPBCAB::myTableIndex, CoulombPBCAB::NptclA, CoulombPBCAB::NptclB, CoulombPBCAB::Qat, CoulombPBCAB::Vat, and CoulombPBCAB::Zat.

Referenced by CoulombPBCAB::evaluate(), and CoulombPBCAB::evaluateWithIonDerivs().

682 {
683  constexpr mRealType czero(0);
684  const auto& d_ab(P.getDistTableAB(myTableIndex));
685  mRealType res = czero;
686  //Temporary variables for computing energy and forces.
687  mRealType rV(0);
688  mRealType frV(0), fdrV(0);
689  mRealType rinv(1.0);
690  //Magnitude of force.
691  mRealType dvdr(0.0);
692  for (size_t b = 0; b < NptclB; ++b)
693  {
694  const auto& dist = d_ab.getDistRow(b);
695  const auto& dr = d_ab.getDisplRow(b);
696  mRealType esum = czero;
697  for (size_t a = 0; a < NptclA; ++a)
698  {
699  //Low hanging SIMD fruit here. See J1/J2 grad computation.
700  rinv = 1.0 / dist[a];
701  rV = Vat[a]->splint(dist[a]);
702  frV = fVat[a]->splint(dist[a]);
703  fdrV = fdVat[a]->splint(dist[a]);
704  dvdr = Qat[b] * Zat[a] * (fdrV - frV * rinv) * rinv;
705  forces_[a][0] -= dvdr * dr[a][0] * rinv;
706  forces_[a][1] -= dvdr * dr[a][1] * rinv;
707  forces_[a][2] -= dvdr * dr[a][2] * rinv;
708  esum += Zat[a] * rV * rinv; //Total energy accumulation
709  }
710  res += esum * Qat[b];
711  }
712  return res;
713 }
std::vector< const RadFunctorType * > fdVat
Definition: CoulombPBCAB.h:92
std::vector< const RadFunctorType * > Vat
Short-range potential for each ion.
Definition: CoulombPBCAB.h:86
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
constexpr std::complex< float > czero
Definition: BLAS.hpp:51
LRHandlerType::mRealType mRealType
Definition: CoulombPBCAB.h:44
const int myTableIndex
locator of the distance table
Definition: CoulombPBCAB.h:51
int NptclB
number of particles of B
Definition: CoulombPBCAB.h:59
int NptclA
number of particles of A
Definition: CoulombPBCAB.h:57
std::vector< const RadFunctorType * > fVat
Short-range potential (r*V) and potential derivative d/dr(rV) derivative for each ion Required for fo...
Definition: CoulombPBCAB.h:91
std::vector< RealType > Qat
Qat[iat] charge for the iat-th particle of B.
Definition: CoulombPBCAB.h:80
std::vector< RealType > Zat
Zat[iat] charge for the iat-th particle of A.
Definition: CoulombPBCAB.h:78

◆ evaluate()

CoulombPBCAB::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 122 of file CoulombPBCAB.cpp.

References CoulombPBCAB::ComputeForces, CoulombPBCAB::evalLR(), CoulombPBCAB::evalLRwithForces(), CoulombPBCAB::evalSR(), CoulombPBCAB::evalSRwithForces(), CoulombPBCAB::evaluate_sp(), ForceBase::forces_, CoulombPBCAB::myConst, OperatorBase::streaming_particles_, and OperatorBase::value_.

Referenced by qmcplusplus::TEST_CASE().

123 {
124  if (ComputeForces)
125  {
126  forces_ = 0.0;
128  }
129  else
130 #if !defined(REMOVE_TRACEMANAGER)
132  value_ = evaluate_sp(P);
133  else
134 #endif
135  value_ = evalLR(P) + evalSR(P) + myConst;
136  return value_;
137 }
Return_t myConst
const energy after breakup
Definition: CoulombPBCAB.h:61
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAB.h:71
Return_t evaluate_sp(ParticleSet &P)
Return_t evalLRwithForces(ParticleSet &P)
Computes the long-range contribution to the coulomb energy and forces.
Return_t value_
current value
Definition: OperatorBase.h:524
Return_t evalLR(ParticleSet &P)
Computes the long-range contribution to the coulomb energy.
Return_t evalSR(ParticleSet &P)
Computes the short-range contribution to the coulomb energy.
Return_t evalSRwithForces(ParticleSet &P)
Computes the short-range contribution to the coulomb energy and forces.

◆ evaluate_sp()

CoulombPBCAB::Return_t evaluate_sp ( ParticleSet P)

Definition at line 158 of file CoulombPBCAB.cpp.

References CoulombPBCAB::AB, qmcplusplus::abs(), APP_ABORT, qmcplusplus::app_log(), CoulombPBCAB::evalLR(), CoulombPBCAB::evalSR(), ParticleSet::getDistTableAB(), ParticleSet::getSimulationCell(), ParticleSet::getSK(), ParticleSet::getTotalNum(), CoulombPBCAB::myConst, CoulombPBCAB::myTableIndex, CoulombPBCAB::NptclA, CoulombPBCAB::NptclB, CoulombPBCAB::NumSpeciesA, CoulombPBCAB::NumSpeciesB, CoulombPBCAB::pset_ions_, CoulombPBCAB::Qat, CoulombPBCAB::Qspec, qmcplusplus::Units::time::s, Array< T, D, ALLOC >::size(), Array< T, D, ALLOC >::sum(), qmcplusplus::SUPERCELL_SLAB, TraceManager::trace_tol, OperatorBase::value_, CoulombPBCAB::Vat, CoulombPBCAB::Ve_const, CoulombPBCAB::Ve_sample, CoulombPBCAB::Vi_const, CoulombPBCAB::Vi_sample, CoulombPBCAB::Zat, and CoulombPBCAB::Zspec.

Referenced by CoulombPBCAB::evaluate().

159 {
160  RealType Vsr = 0.0;
161  RealType Vlr = 0.0;
162  mRealType& Vc = myConst;
163  Array<RealType, 1>& Ve_samp = *Ve_sample;
164  Array<RealType, 1>& Vi_samp = *Vi_sample;
165  Ve_samp = 0.0;
166  Vi_samp = 0.0;
167  {
168  //SR
169  const auto& d_ab(P.getDistTableAB(myTableIndex));
170  RealType z;
171  //Loop over distinct eln-ion pairs
172  for (size_t b = 0; b < NptclB; ++b)
173  {
174  z = 0.5 * Qat[b];
175  const auto& dist = d_ab.getDistRow(b);
176  for (size_t a = 0; a < NptclA; ++a)
177  {
178  Return_t pairpot = z * Zat[a] * Vat[a]->splint(dist[a]) / dist[a];
179  Vi_samp(a) += pairpot;
180  Ve_samp(b) += pairpot;
181  Vsr += pairpot;
182  }
183  }
184  Vsr *= 2.0;
185  }
186  {
187  //LR
188  const StructFact& RhoKA(pset_ions_.getSK());
189  const StructFact& RhoKB(P.getSK());
190  if (RhoKA.SuperCellEnum == SUPERCELL_SLAB)
191  {
192  APP_ABORT("CoulombPBCAB::evaluate_sp single particle traces have not been implemented for slab geometry");
193  }
194  else
195  {
196  assert(RhoKA.isStorePerParticle()); // ensure this so we know eikr_r has been allocated
197  assert(RhoKB.isStorePerParticle());
198  //jtk mark: needs optimizations. will likely require new function definitions
199  RealType v1; //single particle energy
200  RealType q;
201  for (int i = 0; i < P.getTotalNum(); ++i)
202  {
203  q = .5 * Qat[i];
204  v1 = 0.0;
205  for (int s = 0; s < NumSpeciesA; s++)
206  v1 += Zspec[s] * q *
207  AB->evaluate(pset_ions_.getSimulationCell().getKLists().kshell, RhoKA.rhok_r[s], RhoKA.rhok_i[s],
208  RhoKB.eikr_r[i], RhoKB.eikr_i[i]);
209  Ve_samp(i) += v1;
210  Vlr += v1;
211  }
212  for (int i = 0; i < pset_ions_.getTotalNum(); ++i)
213  {
214  q = .5 * Zat[i];
215  v1 = 0.0;
216  for (int s = 0; s < NumSpeciesB; s++)
217  v1 += Qspec[s] * q *
218  AB->evaluate(P.getSimulationCell().getKLists().kshell, RhoKB.rhok_r[s], RhoKB.rhok_i[s], RhoKA.eikr_r[i],
219  RhoKA.eikr_i[i]);
220  Vi_samp(i) += v1;
221  Vlr += v1;
222  }
223  }
224  }
225  for (int i = 0; i < Ve_samp.size(); ++i)
226  Ve_samp(i) += Ve_const(i);
227  for (int i = 0; i < Vi_samp.size(); ++i)
228  Vi_samp(i) += Vi_const(i);
229  value_ = Vsr + Vlr + Vc;
230 #if defined(TRACE_CHECK)
231  RealType Vlrnow = evalLR(P);
232  RealType Vsrnow = evalSR(P);
233  RealType Vcnow = myConst;
234  RealType Vnow = Vlrnow + Vsrnow + Vcnow;
235  RealType Vesum = Ve_samp.sum();
236  RealType Vecsum = Ve_const.sum();
237  RealType Visum = Vi_samp.sum();
238  RealType Vicsum = Vi_const.sum();
239  RealType Vsum = Vesum + Visum;
240  RealType Vcsum = Vecsum + Vicsum;
241  if (std::abs(Vsum - Vnow) > TraceManager::trace_tol)
242  {
243  app_log() << "accumtest: CoulombPBCAA::evaluate()" << std::endl;
244  app_log() << "accumtest: tot:" << Vnow << std::endl;
245  app_log() << "accumtest: sum:" << Vsum << std::endl;
246  APP_ABORT("Trace check failed");
247  }
248  if (std::abs(Vcsum - Vcnow) > TraceManager::trace_tol)
249  {
250  app_log() << "accumtest: CoulombPBCAA::evalConsts()" << std::endl;
251  app_log() << "accumtest: tot:" << Vcnow << std::endl;
252  app_log() << "accumtest: sum:" << Vcsum << std::endl;
253  APP_ABORT("Trace check failed");
254  }
255  if (std::abs(Vesum - Visum) > TraceManager::trace_tol)
256  {
257  app_log() << "sharetest: CoulombPBCAB::evaluate()" << std::endl;
258  app_log() << "sharetest: e share:" << Vesum << std::endl;
259  app_log() << "sharetest: i share:" << Visum << std::endl;
260  }
261  if (std::abs(Vecsum - Vicsum) > TraceManager::trace_tol)
262  {
263  app_log() << "sharetest: CoulombPBCAB::evalConsts()" << std::endl;
264  app_log() << "sharetest: e share:" << Vecsum << std::endl;
265  app_log() << "sharetest: i share:" << Vicsum << std::endl;
266  }
267 
268 #endif
269  return value_;
270 }
Array< TraceReal, 1 > * Vi_sample
Definition: CoulombPBCAB.h:116
int NumSpeciesB
number of species of B particle set
Definition: CoulombPBCAB.h:55
Return_t myConst
const energy after breakup
Definition: CoulombPBCAB.h:61
std::vector< const RadFunctorType * > Vat
Short-range potential for each ion.
Definition: CoulombPBCAB.h:86
Array< TraceReal, 1 > Vi_const
Definition: CoulombPBCAB.h:118
std::shared_ptr< LRHandlerType > AB
long-range Handler. Should be const LRHandlerType eventually
Definition: CoulombPBCAB.h:47
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
LRHandlerType::mRealType mRealType
Definition: CoulombPBCAB.h:44
const int myTableIndex
locator of the distance table
Definition: CoulombPBCAB.h:51
const auto & getSimulationCell() const
Definition: ParticleSet.h:250
Array< TraceReal, 1 > * Ve_sample
Definition: CoulombPBCAB.h:115
int NptclB
number of particles of B
Definition: CoulombPBCAB.h:59
int NptclA
number of particles of A
Definition: CoulombPBCAB.h:57
size_t size() const
Definition: OhmmsArray.h:57
Array< TraceReal, 1 > Ve_const
Definition: CoulombPBCAB.h:117
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
const StructFact & getSK() const
return Structure Factor
Definition: ParticleSet.h:216
int NumSpeciesA
number of species of A particle set
Definition: CoulombPBCAB.h:53
std::vector< RealType > Qspec
Qspec[spec] charge for the spec-th species of B.
Definition: CoulombPBCAB.h:84
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Type_t sum() const
Definition: OhmmsArray.h:214
QMCTraits::RealType RealType
Return_t value_
current value
Definition: OperatorBase.h:524
std::vector< RealType > Qat
Qat[iat] charge for the iat-th particle of B.
Definition: CoulombPBCAB.h:80
std::vector< RealType > Zspec
Zspec[spec] charge for the spec-th species of A.
Definition: CoulombPBCAB.h:82
std::vector< RealType > Zat
Zat[iat] charge for the iat-th particle of A.
Definition: CoulombPBCAB.h:78
Return_t evalLR(ParticleSet &P)
Computes the long-range contribution to the coulomb energy.
Return_t evalSR(ParticleSet &P)
Computes the short-range contribution to the coulomb energy.

◆ evaluateWithIonDerivs()

CoulombPBCAB::Return_t evaluateWithIonDerivs ( ParticleSet P,
ParticleSet ions,
TrialWaveFunction psi,
ParticleSet::ParticlePos hf_term,
ParticleSet::ParticlePos pulay_term 
)
overridevirtual

Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase.

Parameters
Ptarget particle set (electrons)
ionssource particle set (ions)
psiTrial wave function
hf_termsAdds OperatorBase's contribution to Re [(dH)Psi]/Psi
pulay_termsAdds OperatorBase's contribution to Re [(H-E_L)dPsi]/Psi
Returns
Contribution of OperatorBase to Local Energy.

Reimplemented from OperatorBase.

Definition at line 139 of file CoulombPBCAB.cpp.

References CoulombPBCAB::ComputeForces, CoulombPBCAB::evalLR(), CoulombPBCAB::evalLRwithForces(), CoulombPBCAB::evalSR(), CoulombPBCAB::evalSRwithForces(), ForceBase::forces_, CoulombPBCAB::myConst, and OperatorBase::value_.

144 {
145  if (ComputeForces)
146  {
147  forces_ = 0.0;
149  hf_terms -= forces_;
150  //And no Pulay contribution.
151  }
152  else
153  value_ = evalLR(P) + evalSR(P) + myConst;
154  return value_;
155 }
Return_t myConst
const energy after breakup
Definition: CoulombPBCAB.h:61
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAB.h:71
Return_t evalLRwithForces(ParticleSet &P)
Computes the long-range contribution to the coulomb energy and forces.
Return_t value_
current value
Definition: OperatorBase.h:524
Return_t evalLR(ParticleSet &P)
Computes the long-range contribution to the coulomb energy.
Return_t evalSR(ParticleSet &P)
Computes the short-range contribution to the coulomb energy.
Return_t evalSRwithForces(ParticleSet &P)
Computes the short-range contribution to the coulomb energy and forces.

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 165 of file CoulombPBCAB.h.

References OhmmsElementBase::getName(), and CoulombPBCAB::pset_ions_.

166  {
167  os << "CoulombPBCAB potential source: " << pset_ions_.getName();
168  return true;
169  }
const std::string & getName() const
return the name
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 134 of file CoulombPBCAB.h.

134 { return "CoulombPBCAB"; }

◆ getSourcePSet()

const ParticleSet& getSourcePSet ( ) const
inline

Definition at line 202 of file CoulombPBCAB.h.

References CoulombPBCAB::pset_ions_.

202 { return pset_ions_; }
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230

◆ informOfPerParticleListener()

void informOfPerParticleListener ( )
overridevirtual

Call to inform objects associated with this operator of per particle listeners.

should be called before createResources

Reimplemented from OperatorBase.

Definition at line 103 of file CoulombPBCAB.cpp.

References OperatorBase::informOfPerParticleListener(), CoulombPBCAB::Peln, CoulombPBCAB::pset_ions_, and ParticleSet::turnOnPerParticleSK().

104 {
105  // This is written so it can be called again and again.
109 }
void turnOnPerParticleSK()
Turn on per particle storage in Structure Factor.
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230
virtual void informOfPerParticleListener()
Definition: OperatorBase.h:471

◆ initBreakup()

void initBreakup ( ParticleSet P)
protected

Creates the long-range handlers, then splines and stores it by particle and species for quick evaluation.

this is just constructor code factored out. It is called by the derived class CoulombPBCAB_CUDA

Definition at line 474 of file CoulombPBCAB.cpp.

References CoulombPBCAB::AB, qmcplusplus::abs(), SpeciesSet::addAttribute(), APP_ABORT, qmcplusplus::app_log(), CoulombPBCAB::ComputeForces, LRCoulombSingleton::createSpline4RbyVs(), LRCoulombSingleton::createSpline4RbyVsDeriv(), CoulombPBCAB::dAB, CoulombPBCAB::dfV0, CoulombPBCAB::evalConsts(), CoulombPBCAB::fdVat, CoulombPBCAB::fdVspec, qmcplusplus::for(), CoulombPBCAB::fV0, CoulombPBCAB::fVat, CoulombPBCAB::fVspec, LRCoulombSingleton::getDerivHandler(), LRCoulombSingleton::getHandler(), ParticleSet::getLattice(), ParticleSet::getSpeciesSet(), ParticleSet::getTotalNum(), ParticleSet::GroupID, ParticleSet::groupsize(), CoulombPBCAB::kcdifferent, omptarget::min(), CoulombPBCAB::minkc, CoulombPBCAB::myConst, CoulombPBCAB::myRcut, CoulombPBCAB::NofSpeciesA, CoulombPBCAB::NofSpeciesB, CoulombPBCAB::NptclA, CoulombPBCAB::NptclB, CoulombPBCAB::NumSpeciesA, CoulombPBCAB::NumSpeciesB, CoulombPBCAB::pset_ions_, CoulombPBCAB::Qat, CoulombPBCAB::Qspec, LinearGrid< T, CT >::set(), CoulombPBCAB::V0, CoulombPBCAB::Vat, CoulombPBCAB::Vspec, CoulombPBCAB::Zat, and CoulombPBCAB::Zspec.

Referenced by CoulombPBCAB::CoulombPBCAB().

475 {
476  // This is ridiculous so many uneeded convenience variables that also make the object invalid at construction.
477  // Illustraction of the terrible API and convoluted use of species attributes.
478  SpeciesSet& tspeciesA(pset_ions_.getSpeciesSet());
479  SpeciesSet& tspeciesB(P.getSpeciesSet());
480  // Actually finding the index, code further on makes no sense if there wasn't already a charge attribute.
481  int ChargeAttribIndxA = tspeciesA.addAttribute("charge");
482  int ChargeAttribIndxB = tspeciesB.addAttribute("charge");
484  NptclB = P.getTotalNum();
485  NumSpeciesA = tspeciesA.TotalNum;
486  NumSpeciesB = tspeciesB.TotalNum;
487  //Store information about charges and number of each species
488  Zat.resize(NptclA);
489  Zspec.resize(NumSpeciesA);
490  Qat.resize(NptclB);
491  Qspec.resize(NumSpeciesB);
492  NofSpeciesA.resize(NumSpeciesA);
493  NofSpeciesB.resize(NumSpeciesB);
494  for (int spec = 0; spec < NumSpeciesA; spec++)
495  {
496  Zspec[spec] = tspeciesA(ChargeAttribIndxA, spec);
497  NofSpeciesA[spec] = pset_ions_.groupsize(spec);
498  }
499  for (int spec = 0; spec < NumSpeciesB; spec++)
500  {
501  Qspec[spec] = tspeciesB(ChargeAttribIndxB, spec);
502  NofSpeciesB[spec] = P.groupsize(spec);
503  }
504  for (int iat = 0; iat < NptclA; iat++)
505  Zat[iat] = Zspec[pset_ions_.GroupID[iat]];
506  for (int iat = 0; iat < NptclB; iat++)
507  Qat[iat] = Qspec[P.GroupID[iat]];
508  // if(totQ>std::numeric_limits<RealType>::epsilon())
509  // {
510  // LOGMSG("PBCs not yet finished for non-neutral cells");
511  // OHMMS::Controller->abort();
512  // }
513  ////Test if the box sizes are same (=> kcut same for fixed dimcut)
514  kcdifferent =
515  (std::abs(pset_ions_.getLattice().LR_kc - P.getLattice().LR_kc) > std::numeric_limits<RealType>::epsilon());
516  minkc = std::min(pset_ions_.getLattice().LR_kc, P.getLattice().LR_kc);
517  //initBreakup is called only once
519  myConst = evalConsts(P);
520  myRcut = AB->get_rc(); //Basis.get_rc();
521  // create the spline function for the short-range part assuming pure potential
522  auto myGrid = LinearGrid<RealType>();
523  const int ng = P.getLattice().num_ewald_grid_points;
524  app_log() << " CoulombPBCAB::initBreakup\n Setting a linear grid=[0," << myRcut
525  << ") number of grid points =" << ng << std::endl;
526  myGrid.set(0, myRcut, ng);
527  if (V0 == nullptr)
528  {
530  if (Vat.size())
531  {
532  APP_ABORT("CoulombPBCAB::initBreakup. Vat is not empty\n");
533  }
534  Vat.resize(NptclA, V0.get());
535  Vspec.resize(NumSpeciesA); //prepare for PP to overwrite it
536  }
537 
538  //If ComputeForces is true, then we allocate space for the radial derivative functors.
539  if (ComputeForces)
540  {
542  if (fV0 == nullptr)
544  if (dfV0 == nullptr)
546  if (fVat.size())
547  {
548  APP_ABORT("CoulombPBCAB::initBreakup. Vat is not empty\n");
549  }
550  fVat.resize(NptclA, fV0.get());
551  fdVat.resize(NptclA, dfV0.get());
552  fVspec.resize(NumSpeciesA);
553  fdVspec.resize(NumSpeciesA);
554  }
555 }
std::vector< const RadFunctorType * > fdVat
Definition: CoulombPBCAB.h:92
static std::unique_ptr< LRHandlerType > getDerivHandler(ParticleSet &ref)
This returns a force/stress optimized LR handler. If non existent, it creates one.
int NumSpeciesB
number of species of B particle set
Definition: CoulombPBCAB.h:55
std::shared_ptr< const RadFunctorType > fV0
Radial functor for bare coulomb, optimized for forces.
Definition: CoulombPBCAB.h:67
Return_t myConst
const energy after breakup
Definition: CoulombPBCAB.h:61
std::vector< const RadFunctorType * > Vat
Short-range potential for each ion.
Definition: CoulombPBCAB.h:86
std::shared_ptr< LRHandlerType > AB
long-range Handler. Should be const LRHandlerType eventually
Definition: CoulombPBCAB.h:47
static std::unique_ptr< RadFunctorType > createSpline4RbyVs(const LRHandlerType *aLR, mRealType rcut, const GridType &agrid)
create a linear spline function
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< std::shared_ptr< RadFunctorType > > Vspec
Short-range potential for each species.
Definition: CoulombPBCAB.h:88
std::vector< std::shared_ptr< const RadFunctorType > > fVspec
Definition: CoulombPBCAB.h:94
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAB.h:71
T min(T a, T b)
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
std::shared_ptr< const RadFunctorType > V0
Always mave a radial functor for the bare coulomb.
Definition: CoulombPBCAB.h:65
std::shared_ptr< const RadFunctorType > dfV0
Radial functor for derivative of bare coulomb, optimized for forces.
Definition: CoulombPBCAB.h:69
std::vector< std::shared_ptr< const RadFunctorType > > fdVspec
Definition: CoulombPBCAB.h:95
int NptclB
number of particles of B
Definition: CoulombPBCAB.h:59
RealType myRcut
cutoff radius of the short-range part
Definition: CoulombPBCAB.h:63
static std::unique_ptr< RadFunctorType > createSpline4RbyVsDeriv(const LRHandlerType *aLR, mRealType rcut, const GridType &agrid)
create a linear spline of the derivative of short-range potential
int groupsize(int igroup) const
return the size of a group
Definition: ParticleSet.h:527
int NptclA
number of particles of A
Definition: CoulombPBCAB.h:57
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
Linear Grid inherets from Grid.
Definition: Grid.h:73
int NumSpeciesA
number of species of A particle set
Definition: CoulombPBCAB.h:53
std::vector< RealType > Qspec
Qspec[spec] charge for the spec-th species of B.
Definition: CoulombPBCAB.h:84
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
std::vector< int > NofSpeciesA
number of particles per species of A
Definition: CoulombPBCAB.h:74
std::vector< const RadFunctorType * > fVat
Short-range potential (r*V) and potential derivative d/dr(rV) derivative for each ion Required for fo...
Definition: CoulombPBCAB.h:91
std::vector< RealType > Qat
Qat[iat] charge for the iat-th particle of B.
Definition: CoulombPBCAB.h:80
std::vector< RealType > Zspec
Zspec[spec] charge for the spec-th species of A.
Definition: CoulombPBCAB.h:82
std::vector< RealType > Zat
Zat[iat] charge for the iat-th particle of A.
Definition: CoulombPBCAB.h:78
static std::unique_ptr< LRHandlerType > getHandler(ParticleSet &ref)
This returns an energy optimized LR handler. If non existent, it creates one.
std::shared_ptr< const LRHandlerType > dAB
long-range derivative handler
Definition: CoulombPBCAB.h:49
const auto & getLattice() const
Definition: ParticleSet.h:251
std::vector< int > NofSpeciesB
number of particles per species of B
Definition: CoulombPBCAB.h:76
Return_t evalConsts(const ParticleSet &P, bool report=true)
Evaluates madelung and background contributions to total energy.

◆ makeClone()

std::unique_ptr< OperatorBase > makeClone ( ParticleSet qp,
TrialWaveFunction psi 
)
overridevirtual

Implements OperatorBase.

Definition at line 63 of file CoulombPBCAB.cpp.

64 {
65  return std::make_unique<CoulombPBCAB>(*this);
66 }

◆ mw_evaluatePerParticle()

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 >> &  ion_listeners 
) const
overridevirtual

Evaluate the contribution of this component of multiple walkers per particle reporting to registered listeners from Estimators.

Reimplemented from OperatorBase.

Definition at line 273 of file CoulombPBCAB.cpp.

References APP_ABORT, RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), OperatorBase::name_, CoulombPBCAB::NptclA, CoulombPBCAB::NptclB, qmcplusplus::pset, Vector< T, Alloc >::resize(), qmcplusplus::Units::time::s, qmcplusplus::SUPERCELL_SLAB, and OperatorBase::value_.

Referenced by qmcplusplus::TEST_CASE().

278 {
279  auto& o_leader = o_list.getCastedLeader<CoulombPBCAB>();
280  auto& p_leader = p_list.getLeader();
281  assert(this == &o_list.getLeader());
282 
283  auto num_centers = p_leader.getTotalNum();
284  auto& name = o_leader.name_;
285  auto& mw_res = o_leader.mw_res_handle_.getResource();
286  Vector<RealType>& ve_sample = mw_res.pp_samples_trg;
287  Vector<RealType>& vi_sample = mw_res.pp_samples_src;
288  const auto& ve_consts = mw_res.pp_consts_trg;
289  const auto& vi_consts = mw_res.pp_consts_src;
290  auto num_species = p_leader.getSpeciesSet().getTotalNum();
291  ve_sample.resize(NptclB);
292  vi_sample.resize(NptclA);
293 
294  // This lambda is mostly about getting a handle on what is being touched by the per particle evaluation.
295  auto evaluate_walker = [name, &ve_sample, &vi_sample, &ve_consts,
296  &vi_consts](const int walker_index, const CoulombPBCAB& cpbcab, const ParticleSet& pset,
297  const std::vector<ListenerVector<RealType>>& listeners,
298  const std::vector<ListenerVector<RealType>>& ion_listeners) -> RealType {
299  RealType Vsr = 0.0;
300  RealType Vlr = 0.0;
301  RealType Vc = cpbcab.myConst;
302  std::fill(ve_sample.begin(), ve_sample.end(), 0.0);
303  std::fill(vi_sample.begin(), vi_sample.end(), 0.0);
304  auto& pset_source = cpbcab.getSourcePSet();
305  {
306  //SR
307  const auto& d_ab(pset.getDistTableAB(cpbcab.myTableIndex));
308  RealType z;
309  //Loop over distinct eln-ion pairs
310  for (size_t b = 0; b < pset.getTotalNum(); ++b)
311  {
312  z = 0.5 * cpbcab.Qat[b];
313  const auto& dist = d_ab.getDistRow(b);
314  for (size_t a = 0; a < pset_source.getTotalNum(); ++a)
315  {
316  Return_t pairpot = z * cpbcab.Zat[a] * cpbcab.Vat[a]->splint(dist[a]) / dist[a];
317  vi_sample[a] += pairpot;
318  ve_sample[b] += pairpot;
319  Vsr += pairpot;
320  }
321  }
322  Vsr *= 2.0;
323  }
324  {
325  //LR
326  // pset_ions_ is a smelly reference to the ion particle set.
327  const StructFact& RhoKA(pset_source.getSK());
328  const StructFact& RhoKB(pset.getSK());
329  if (RhoKA.SuperCellEnum == SUPERCELL_SLAB)
330  {
331  APP_ABORT("CoulombPBCAB::evaluate_sp single particle traces have not been implemented for slab geometry");
332  }
333  else
334  {
335  assert(RhoKA.isStorePerParticle()); // ensure this so we know eikr_r has been allocated
336  assert(RhoKB.isStorePerParticle());
337  //jtk mark: needs optimizations. will likely require new function definitions
338  RealType v1; //single particle energy
339  RealType q;
340  int num_species_source = pset_source.getSpeciesSet().size();
341  for (int i = 0; i < pset.getTotalNum(); ++i)
342  {
343  q = .5 * cpbcab.Qat[i];
344  v1 = 0.0;
345  for (int s = 0; s < num_species_source; s++)
346  v1 += cpbcab.Zspec[s] * q *
347  cpbcab.AB->evaluate(pset_source.getSimulationCell().getKLists().kshell, RhoKA.rhok_r[s],
348  RhoKA.rhok_i[s], RhoKB.eikr_r[i], RhoKB.eikr_i[i]);
349  ve_sample[i] += v1;
350  Vlr += v1;
351  }
352  int num_species_target = pset.getSpeciesSet().size();
353  for (int i = 0; i < pset_source.getTotalNum(); ++i)
354  {
355  q = .5 * cpbcab.Zat[i];
356  v1 = 0.0;
357  for (int s = 0; s < num_species_target; s++)
358  v1 += cpbcab.Qspec[s] * q *
359  cpbcab.AB->evaluate(pset.getSimulationCell().getKLists().kshell, RhoKB.rhok_r[s], RhoKB.rhok_i[s],
360  RhoKA.eikr_r[i], RhoKA.eikr_i[i]);
361  vi_sample[i] += v1;
362  Vlr += v1;
363  }
364  }
365  }
366  for (int i = 0; i < ve_sample.size(); ++i)
367  ve_sample[i] += ve_consts[i];
368  for (int i = 0; i < vi_sample.size(); ++i)
369  vi_sample[i] += vi_consts[i];
370  RealType value = Vsr + Vlr + Vc;
371  for (const ListenerVector<RealType>& listener : listeners)
372  listener.report(walker_index, name, ve_sample);
373  for (const ListenerVector<RealType>& ion_listener : ion_listeners)
374  ion_listener.report(walker_index, name, vi_sample);
375  return value;
376  };
377 
378  for (int iw = 0; iw < o_list.size(); iw++)
379  {
380  auto& coulomb_ab = o_list.getCastedElement<CoulombPBCAB>(iw);
381  coulomb_ab.value_ = evaluate_walker(iw, coulomb_ab, p_list[iw], listeners, ion_listeners);
382  }
383 }
int NptclB
number of particles of B
Definition: CoulombPBCAB.h:59
int NptclA
number of particles of A
Definition: CoulombPBCAB.h:57
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
CoulombPBCAB(ParticleSet &ions, ParticleSet &elns, bool computeForces=false)
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
QMCTraits::RealType RealType

◆ put()

bool put ( xmlNodePtr  cur)
inlineoverridevirtual

Do nothing.

Implements OperatorBase.

Definition at line 163 of file CoulombPBCAB.h.

163 { return true; }

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
overridevirtual

return a shared resource to a collection

Reimplemented from OperatorBase.

Definition at line 756 of file CoulombPBCAB.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), and ResourceCollection::takebackResource().

758 {
759  auto& o_leader = o_list.getCastedLeader<CoulombPBCAB>();
760  collection.takebackResource(o_leader.mw_res_handle_);
761 }
CoulombPBCAB(ParticleSet &ions, ParticleSet &elns, bool computeForces=false)

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
overridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 70 of file CoulombPBCAB.cpp.

References CoulombPBCAB::AB, ParticleSet::addTable(), APP_ABORT, CoulombPBCAB::myTableIndex, and CoulombPBCAB::pset_ions_.

71 {
72  int tid = P.addTable(pset_ions_);
73  if (tid != myTableIndex)
74  {
75  APP_ABORT("CoulombPBCAB::resetTargetParticleSet found inconsistent table index");
76  }
77  AB->resetTargetParticleSet(P);
78 }
std::shared_ptr< LRHandlerType > AB
long-range Handler. Should be const LRHandlerType eventually
Definition: CoulombPBCAB.h:47
const int myTableIndex
locator of the distance table
Definition: CoulombPBCAB.h:51
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
ParticleSet & pset_ions_
source particle set
Definition: CoulombPBCAB.h:230

◆ 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 188 of file CoulombPBCAB.h.

References CoulombPBCAB::ComputeForces, OperatorBase::setObservables(), and ForceBase::setObservablesF().

189  {
191  if (ComputeForces)
192  setObservablesF(plist);
193  }
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAB.h:71
void setObservablesF(QMCTraits::PropertySetType &plist)
Definition: ForceBase.cpp:86
virtual void setObservables(PropertySetType &plist)
Set the values evaluated by this object to plist Default implementation is to assign Value which is u...

◆ setParticlePropertyList()

void setParticlePropertyList ( PropertySetType plist,
int  offset 
)
inlineoverridevirtual

Reimplemented from OperatorBase.

Definition at line 195 of file CoulombPBCAB.h.

References CoulombPBCAB::ComputeForces, OperatorBase::setParticlePropertyList(), and ForceBase::setParticleSetF().

196  {
198  if (ComputeForces)
199  setParticleSetF(plist, offset);
200  }
bool ComputeForces
Flag for whether to compute forces or not.
Definition: CoulombPBCAB.h:71
void setParticleSetF(QMCTraits::PropertySetType &plist, int offset)
Definition: ForceBase.cpp:113
virtual void setParticlePropertyList(PropertySetType &plist, int offset)

Member Data Documentation

◆ AB

◆ ComputeForces

◆ dAB

std::shared_ptr<const LRHandlerType> dAB

long-range derivative handler

Definition at line 49 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::add(), CoulombPBCAB::evalLRwithForces(), and CoulombPBCAB::initBreakup().

◆ dfV0

std::shared_ptr<const RadFunctorType> dfV0

Radial functor for derivative of bare coulomb, optimized for forces.

Definition at line 69 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::initBreakup().

◆ fdVat

std::vector<const RadFunctorType*> fdVat

◆ fdVspec

std::vector<std::shared_ptr<const RadFunctorType> > fdVspec

Definition at line 95 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::add(), and CoulombPBCAB::initBreakup().

◆ fV0

std::shared_ptr<const RadFunctorType> fV0

Radial functor for bare coulomb, optimized for forces.

Definition at line 67 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::initBreakup().

◆ fVat

std::vector<const RadFunctorType*> fVat

Short-range potential (r*V) and potential derivative d/dr(rV) derivative for each ion Required for force evaluations.

Definition at line 91 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::add(), CoulombPBCAB::evalSRwithForces(), and CoulombPBCAB::initBreakup().

◆ fVspec

std::vector<std::shared_ptr<const RadFunctorType> > fVspec

Definition at line 94 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::add(), and CoulombPBCAB::initBreakup().

◆ kcdifferent

bool kcdifferent

Definition at line 110 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::initBreakup().

◆ LRpart

Vector<RealType> LRpart

long-range per particle

Definition at line 106 of file CoulombPBCAB.h.

◆ LRtmp

RealType LRtmp

long-range part for the moved particle

Definition at line 102 of file CoulombPBCAB.h.

◆ minkc

RealType minkc

Definition at line 111 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::initBreakup().

◆ mw_res_handle_

Definition at line 232 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::acquireResource().

◆ myConst

◆ myRcut

RealType myRcut

cutoff radius of the short-range part

Definition at line 63 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::add(), CoulombPBCAB::CoulombPBCAB(), and CoulombPBCAB::initBreakup().

◆ myTableIndex

const int myTableIndex

◆ NofSpeciesA

std::vector<int> NofSpeciesA

number of particles per species of A

Definition at line 74 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::evalConsts(), CoulombPBCAB::evalPerParticleConsts(), and CoulombPBCAB::initBreakup().

◆ NofSpeciesB

std::vector<int> NofSpeciesB

number of particles per species of B

Definition at line 76 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::evalConsts(), CoulombPBCAB::evalPerParticleConsts(), and CoulombPBCAB::initBreakup().

◆ NptclA

◆ NptclB

◆ NumSpeciesA

int NumSpeciesA

◆ NumSpeciesB

◆ Peln

◆ pset_ions_

◆ Qat

◆ Qspec

std::vector<RealType> Qspec

◆ SRpart

Vector<RealType> SRpart

short-range per particle

Definition at line 104 of file CoulombPBCAB.h.

◆ SRtmp

RealType SRtmp

short-range part for the moved particle

Definition at line 100 of file CoulombPBCAB.h.

◆ V0

std::shared_ptr<const RadFunctorType> V0

Always mave a radial functor for the bare coulomb.

Definition at line 65 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::add(), and CoulombPBCAB::initBreakup().

◆ Vat

std::vector<const RadFunctorType*> Vat

◆ Ve_const

Array<TraceReal, 1> Ve_const

Definition at line 117 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::evalConsts(), and CoulombPBCAB::evaluate_sp().

◆ Ve_sample

◆ Vi_const

Array<TraceReal, 1> Vi_const

Definition at line 118 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::evalConsts(), and CoulombPBCAB::evaluate_sp().

◆ Vi_sample

◆ Vspec

std::vector<std::shared_ptr<RadFunctorType> > Vspec

Short-range potential for each species.

Definition at line 88 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::add(), and CoulombPBCAB::initBreakup().

◆ Zat

◆ Zspec

std::vector<RealType> Zspec

Zspec[spec] charge for the spec-th species of A.

Definition at line 82 of file CoulombPBCAB.h.

Referenced by CoulombPBCAB::evalConsts(), CoulombPBCAB::evalLR(), CoulombPBCAB::evalPerParticleConsts(), CoulombPBCAB::evaluate_sp(), and CoulombPBCAB::initBreakup().

◆ qmcplusplus::L2Potential

struct qmcplusplus::L2Potential

Evaluate the L2 potentials around each ion.

Definition at line 57 of file L2Potential.h.

+ Inheritance diagram for L2Potential:
+ Collaboration diagram for L2Potential:

Public Member Functions

 L2Potential (const ParticleSet &ions, ParticleSet &els, TrialWaveFunction &psi)
 
bool dependsOnWaveFunction () const override
 return true if this operator depends on a wavefunction More...
 
std::string getClassName () const override
 return class name More...
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
void evaluateDK (ParticleSet &P, int iel, TensorType &D, PosType &K)
 
void evaluateD (ParticleSet &P, int iel, TensorType &D)
 
bool put (xmlNodePtr cur) override
 Read the input parameter. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) final
 
void add (int groupID, std::unique_ptr< L2RadialPotential > &&ppot)
 Add a RadialPotentialType of a species. More...
 
- Public Member Functions inherited from OperatorBase
 OperatorBase ()
 Construct a new Operator Base object Default and unique empty constructor. More...
 
virtual ~OperatorBase ()=default
 
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 addObservables (PropertySetType &plist, BufferType &collectables)
 named values to the property list Default implementaton uses addValue(plist_) 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 registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 
virtual void setObservables (PropertySetType &plist)
 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...
 
virtual void setParticlePropertyList (PropertySetType &plist, int offset)
 
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

const ParticleSetIonConfig
 reference to the ionic configuration More...
 
int NumIons
 the number of ions More...
 
int myTableIndex
 distance table index More...
 
std::vector< std::unique_ptr< L2RadialPotential > > PPset
 unique set of L2 PP to cleanup More...
 
std::vector< L2RadialPotential * > PP
 PP[iat] is the L2 potential for the iat-th particle. More...
 
TrialWaveFunctionpsi_ref
 Associated trial wavefunction. More...
 

Additional Inherited Members

- 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 > >
 
- 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_
 

Constructor & Destructor Documentation

◆ L2Potential()

L2Potential ( const ParticleSet ions,
ParticleSet els,
TrialWaveFunction psi 
)

Definition at line 20 of file L2Potential.cpp.

References ParticleSet::addTable(), ParticleSet::getSpeciesSet(), SpeciesSet::getTotalNum(), ParticleSet::getTotalNum(), L2Potential::myTableIndex, qmcplusplus::Units::time::ns, L2Potential::NumIons, OperatorBase::POTENTIAL, L2Potential::PP, L2Potential::PPset, L2Potential::psi_ref, OperatorBase::setEnergyDomain(), and OperatorBase::twoBodyQuantumDomain().

20  : IonConfig(ions)
21 {
23  twoBodyQuantumDomain(ions, els);
24  NumIons = ions.getTotalNum();
25  myTableIndex = els.addTable(ions);
26  size_t ns = ions.getSpeciesSet().getTotalNum();
27  PPset.resize(ns);
28  PP.resize(NumIons, nullptr);
29  psi_ref = &psi;
30 }
void twoBodyQuantumDomain(const ParticleSet &P)
set quantum domain for two-body operator
TrialWaveFunction * psi_ref
Associated trial wavefunction.
Definition: L2Potential.h:70
const ParticleSet & IonConfig
reference to the ionic configuration
Definition: L2Potential.h:60
int myTableIndex
distance table index
Definition: L2Potential.h:64
std::vector< std::unique_ptr< L2RadialPotential > > PPset
unique set of L2 PP to cleanup
Definition: L2Potential.h:66
void setEnergyDomain(EnergyDomains edomain)
Set the Energy Domain.
int NumIons
the number of ions
Definition: L2Potential.h:62
std::vector< L2RadialPotential * > PP
PP[iat] is the L2 potential for the iat-th particle.
Definition: L2Potential.h:68

Member Function Documentation

◆ add()

void add ( int  groupID,
std::unique_ptr< L2RadialPotential > &&  ppot 
)

Add a RadialPotentialType of a species.

Parameters
groupIDindex of the ion species
ppotL2 pseudopotential

Definition at line 42 of file L2Potential.cpp.

References ParticleSet::GroupID, L2Potential::IonConfig, L2Potential::PP, and L2Potential::PPset.

43 {
44  for (int iat = 0; iat < PP.size(); iat++)
45  if (IonConfig.GroupID[iat] == groupID)
46  PP[iat] = ppot.get();
47  PPset[groupID] = std::move(ppot);
48 }
const ParticleSet & IonConfig
reference to the ionic configuration
Definition: L2Potential.h:60
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
std::vector< std::unique_ptr< L2RadialPotential > > PPset
unique set of L2 PP to cleanup
Definition: L2Potential.h:66
std::vector< L2RadialPotential * > PP
PP[iat] is the L2 potential for the iat-th particle.
Definition: L2Potential.h:68

◆ dependsOnWaveFunction()

bool dependsOnWaveFunction ( ) const
inlineoverridevirtual

return true if this operator depends on a wavefunction

Reimplemented from OperatorBase.

Definition at line 74 of file L2Potential.h.

74 { return true; }

◆ evaluate()

L2Potential::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 51 of file L2Potential.cpp.

References QMCTraits::DIM, TrialWaveFunction::evaluateHessian(), ParticleSet::G, ParticleSet::getDistTableAB(), ParticleSet::getTotalNum(), ParticleSet::L, L2Potential::myTableIndex, qmcplusplus::Units::force::N, qmcplusplus::n, L2Potential::NumIons, L2Potential::PP, L2Potential::psi_ref, and OperatorBase::value_.

52 {
53  // compute the Hessian
55  // evaluateHessian gives the Hessian(log(Psi))
56  psi_ref->evaluateHessian(P, D2);
57  // add gradient terms to get (Hessian(Psi))/Psi instead
58  const size_t N = P.getTotalNum();
59  for (size_t n = 0; n < N; n++)
60  for (size_t i = 0; i < DIM; i++)
61  for (size_t j = 0; j < DIM; j++)
62  D2[n](i, j) += P.G[n][i] * P.G[n][j];
63 
64  // compute v_L2(r)*L^2 for all electron-ion pairs
65  const auto& d_table(P.getDistTableAB(myTableIndex));
66  value_ = 0.0;
67  const size_t Nelec = P.getTotalNum();
68  for (size_t iel = 0; iel < Nelec; ++iel)
69  {
70  const auto Le = P.L[iel];
71  const auto& ge = P.G[iel];
72  const auto& D2e = D2[iel];
73  const auto& dist = d_table.getDistRow(iel);
74  const auto& disp = d_table.getDisplRow(iel);
75  Return_t esum = 0.0;
76  for (size_t iat = 0; iat < NumIons; ++iat)
77  {
78  RealType r = dist[iat];
79  if (PP[iat] != nullptr && r < PP[iat]->rcut)
80  {
81  PosType rv = disp[iat]; //SoA rv is r_I-r_e
82  RealType v = -r * r * std::real(Le);
83  for (int i = 0; i < DIM; ++i)
84  v += -r * r * std::real(ge[i] * ge[i]) - 2 * rv[i] * std::real(ge[i]);
85  for (int i = 0; i < DIM; ++i)
86  for (int j = 0; j < DIM; ++j)
87  v += rv[i] * std::real(D2e(i, j)) * rv[j];
88  esum += v * PP[iat]->evaluate(dist[iat]);
89  }
90  }
91  value_ += esum;
92  }
93  return value_;
94 }
QMCTraits::RealType real
void evaluateHessian(ParticleSet &P, HessVector &all_grad_grad_psi)
evaluate the hessian w.r.t.
TrialWaveFunction * psi_ref
Associated trial wavefunction.
Definition: L2Potential.h:70
int myTableIndex
distance table index
Definition: L2Potential.h:64
QMCTraits::PosType PosType
WaveFunctionComponent::HessVector HessVector
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
QMCTraits::RealType RealType
Return_t value_
current value
Definition: OperatorBase.h:524
int NumIons
the number of ions
Definition: L2Potential.h:62
std::vector< L2RadialPotential * > PP
PP[iat] is the L2 potential for the iat-th particle.
Definition: L2Potential.h:68

◆ evaluateD()

void evaluateD ( ParticleSet P,
int  iel,
TensorType D 
)

Definition at line 126 of file L2Potential.cpp.

References Tensor< T, D >::diagonal(), QMCTraits::DIM, L2RadialPotential::evaluate(), ParticleSet::getDistTableAB(), L2Potential::myTableIndex, L2Potential::NumIons, and L2Potential::PP.

Referenced by QMCHamiltonian::computeL2D().

127 {
128  D = 0.0;
129  D.diagonal(1.0);
130 
131  const auto& d_table(P.getDistTableAB(myTableIndex));
132 
133  for (int iat = 0; iat < NumIons; iat++)
134  {
135  L2RadialPotential* ppot = PP[iat];
136  if (ppot == nullptr)
137  continue;
138  RealType r = d_table.getTempDists()[iat];
139  if (r < ppot->rcut)
140  {
141  PosType rv = d_table.getTempDispls()[iat];
142  RealType vL2 = ppot->evaluate(r);
143  for (int i = 0; i < DIM; ++i)
144  D(i, i) += 2 * vL2 * r * r;
145  for (int i = 0; i < DIM; ++i)
146  for (int j = 0; j < DIM; ++j)
147  D(i, j) -= 2 * vL2 * rv[i] * rv[j];
148  }
149  }
150 }
int myTableIndex
distance table index
Definition: L2Potential.h:64
QMCTraits::PosType PosType
QMCTraits::RealType RealType
int NumIons
the number of ions
Definition: L2Potential.h:62
std::vector< L2RadialPotential * > PP
PP[iat] is the L2 potential for the iat-th particle.
Definition: L2Potential.h:68

◆ evaluateDK()

void evaluateDK ( ParticleSet P,
int  iel,
TensorType D,
PosType K 
)

Definition at line 97 of file L2Potential.cpp.

References Tensor< T, D >::diagonal(), QMCTraits::DIM, L2RadialPotential::evaluate(), ParticleSet::getDistTableAB(), qmcplusplus::Units::energy::K, L2Potential::myTableIndex, L2Potential::NumIons, and L2Potential::PP.

Referenced by QMCHamiltonian::computeL2DK().

98 {
99  K = 0.0;
100  D = 0.0;
101  D.diagonal(1.0);
102 
103  const auto& d_table(P.getDistTableAB(myTableIndex));
104 
105  for (int iat = 0; iat < NumIons; iat++)
106  {
107  L2RadialPotential* ppot = PP[iat];
108  if (ppot == nullptr)
109  continue;
110  RealType r = d_table.getTempDists()[iat];
111  if (r < ppot->rcut)
112  {
113  PosType rv = -1 * d_table.getTempDispls()[iat];
114  RealType vL2 = ppot->evaluate(r);
115  K += 2 * rv * vL2;
116  for (int i = 0; i < DIM; ++i)
117  D(i, i) += 2 * vL2 * r * r;
118  for (int i = 0; i < DIM; ++i)
119  for (int j = 0; j < DIM; ++j)
120  D(i, j) -= 2 * vL2 * rv[i] * rv[j];
121  }
122  }
123 }
int myTableIndex
distance table index
Definition: L2Potential.h:64
QMCTraits::PosType PosType
QMCTraits::RealType RealType
int NumIons
the number of ions
Definition: L2Potential.h:62
std::vector< L2RadialPotential * > PP
PP[iat] is the L2 potential for the iat-th particle.
Definition: L2Potential.h:68

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 86 of file L2Potential.h.

References OhmmsElementBase::getName(), and L2Potential::IonConfig.

87  {
88  os << "L2Potential: " << IonConfig.getName();
89  return true;
90  }
const std::string & getName() const
return the name
const ParticleSet & IonConfig
reference to the ionic configuration
Definition: L2Potential.h:60

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 75 of file L2Potential.h.

75 { return "L2Potential"; }

◆ makeClone()

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

Implements OperatorBase.

Definition at line 153 of file L2Potential.cpp.

References L2Potential::IonConfig, and L2Potential::PPset.

154 {
155  std::unique_ptr<L2Potential> myclone = std::make_unique<L2Potential>(IonConfig, qp, psi);
156  for (int ig = 0; ig < PPset.size(); ++ig)
157  {
158  if (PPset[ig])
159  {
160  myclone->add(ig, std::unique_ptr<L2RadialPotential>(PPset[ig]->makeClone()));
161  }
162  }
163  return myclone;
164 }
std::unique_ptr< OperatorBase > makeClone(ParticleSet &qp, TrialWaveFunction &psi) final
const ParticleSet & IonConfig
reference to the ionic configuration
Definition: L2Potential.h:60
std::vector< std::unique_ptr< L2RadialPotential > > PPset
unique set of L2 PP to cleanup
Definition: L2Potential.h:66

◆ put()

bool put ( xmlNodePtr  cur)
inlineoverridevirtual

Read the input parameter.

Parameters
curxml node for a OperatorBase object

Implements OperatorBase.

Definition at line 84 of file L2Potential.h.

84 { return true; }

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
overridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 32 of file L2Potential.cpp.

References ParticleSet::addTable(), APP_ABORT, L2Potential::IonConfig, and L2Potential::myTableIndex.

33 {
34  int tid = P.addTable(IonConfig);
35  if (tid != myTableIndex)
36  {
37  APP_ABORT(" L2Potential::resetTargetParticleSet found a different distance table index.");
38  }
39 }
const ParticleSet & IonConfig
reference to the ionic configuration
Definition: L2Potential.h:60
int myTableIndex
distance table index
Definition: L2Potential.h:64
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

Member Data Documentation

◆ IonConfig

const ParticleSet& IonConfig

reference to the ionic configuration

Definition at line 60 of file L2Potential.h.

Referenced by L2Potential::add(), L2Potential::get(), L2Potential::makeClone(), and L2Potential::resetTargetParticleSet().

◆ myTableIndex

◆ NumIons

int NumIons

the number of ions

Definition at line 62 of file L2Potential.h.

Referenced by L2Potential::evaluate(), L2Potential::evaluateD(), L2Potential::evaluateDK(), and L2Potential::L2Potential().

◆ PP

std::vector<L2RadialPotential*> PP

PP[iat] is the L2 potential for the iat-th particle.

Definition at line 68 of file L2Potential.h.

Referenced by L2Potential::add(), L2Potential::evaluate(), L2Potential::evaluateD(), L2Potential::evaluateDK(), and L2Potential::L2Potential().

◆ PPset

std::vector<std::unique_ptr<L2RadialPotential> > PPset

unique set of L2 PP to cleanup

Definition at line 66 of file L2Potential.h.

Referenced by L2Potential::add(), L2Potential::L2Potential(), and L2Potential::makeClone().

◆ psi_ref

Associated trial wavefunction.

Definition at line 70 of file L2Potential.h.

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

◆ qmcplusplus::LocalECPotential

struct qmcplusplus::LocalECPotential

Evaluate the local potentials (either pseudo or full core) around each ion.

Definition at line 33 of file LocalECPotential.h.

+ Inheritance diagram for LocalECPotential:
+ Collaboration diagram for LocalECPotential:

Public Types

using GridType = OneDimGridBase< RealType >
 
using RadialPotentialType = OneDimCubicSpline< RealType >
 
- 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

 LocalECPotential (const ParticleSet &ions, ParticleSet &els)
 
std::string getClassName () const override
 return class name More...
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
void contributeParticleQuantities () override
 
void checkoutParticleQuantities (TraceManager &tm) override
 
Return_t evaluate_sp (ParticleSet &P)
 
void deleteParticleQuantities () override
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
Return_t evaluateWithIonDerivs (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms) override
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
Return_t evaluate_orig (ParticleSet &P)
 
bool put (xmlNodePtr cur) override
 Read the input parameter. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) override
 
void add (int groupID, std::unique_ptr< RadialPotentialType > &&ppot, RealType z)
 Add a RadialPotentialType of a species. 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 addObservables (PropertySetType &plist, BufferType &collectables)
 named values to the property list Default implementaton uses addValue(plist_) 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 registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 
virtual void setObservables (PropertySetType &plist)
 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...
 
virtual void setParticlePropertyList (PropertySetType &plist, int offset)
 
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 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

const ParticleSetIonConfig
 reference to the ionic configuration More...
 
int NumIons
 the number of ioncs More...
 
int myTableIndex
 distance table index More...
 
RealType PPtmp
 temporary energy per particle for pbyp move More...
 
std::vector< std::unique_ptr< RadialPotentialType > > PPset
 unique set of local ECP to cleanup More...
 
std::vector< RadialPotentialType * > PP
 PP[iat] is the local potential for the iat-th particle. More...
 
std::vector< RealTypeZeff
 effective charge per ion More...
 
std::vector< RealTypegZeff
 effective charge per species More...
 
Vector< RealTypePPart
 energy per particle More...
 
Array< TraceReal, 1 > * Ve_sample
 single particle trace samples More...
 
Array< TraceReal, 1 > * Vi_sample
 
const ParticleSetPeln
 
const ParticleSetPion
 

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 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_
 

Member Typedef Documentation

◆ GridType

Definition at line 35 of file LocalECPotential.h.

◆ RadialPotentialType

Definition at line 36 of file LocalECPotential.h.

Constructor & Destructor Documentation

◆ LocalECPotential()

LocalECPotential ( const ParticleSet ions,
ParticleSet els 
)

Definition at line 24 of file LocalECPotential.cpp.

References ParticleSet::addTable(), ParticleSet::getSpeciesSet(), SpeciesSet::getTotalNum(), ParticleSet::getTotalNum(), LocalECPotential::gZeff, LocalECPotential::myTableIndex, LocalECPotential::NumIons, OperatorBase::POTENTIAL, LocalECPotential::PP, LocalECPotential::PPset, OperatorBase::setEnergyDomain(), OperatorBase::twoBodyQuantumDomain(), and LocalECPotential::Zeff.

24  : IonConfig(ions), Peln(els), Pion(ions)
25 {
27  twoBodyQuantumDomain(ions, els);
28  NumIons = ions.getTotalNum();
29  myTableIndex = els.addTable(ions);
30  //allocate null
31  PPset.resize(ions.getSpeciesSet().getTotalNum());
32  PP.resize(NumIons, nullptr);
33  Zeff.resize(NumIons, 0.0);
34  gZeff.resize(ions.getSpeciesSet().getTotalNum(), 0);
35 }
void twoBodyQuantumDomain(const ParticleSet &P)
set quantum domain for two-body operator
std::vector< RealType > Zeff
effective charge per ion
const ParticleSet & IonConfig
reference to the ionic configuration
int myTableIndex
distance table index
std::vector< std::unique_ptr< RadialPotentialType > > PPset
unique set of local ECP to cleanup
std::vector< RadialPotentialType * > PP
PP[iat] is the local potential for the iat-th particle.
void setEnergyDomain(EnergyDomains edomain)
Set the Energy Domain.
std::vector< RealType > gZeff
effective charge per species
int NumIons
the number of ioncs

Member Function Documentation

◆ add()

void add ( int  groupID,
std::unique_ptr< RadialPotentialType > &&  ppot,
RealType  z 
)

Add a RadialPotentialType of a species.

Parameters
groupIDindex of the ion species
ppotlocal pseudopotential
zeffective charge of groupID particle

Definition at line 46 of file LocalECPotential.cpp.

References ParticleSet::GroupID, LocalECPotential::gZeff, LocalECPotential::IonConfig, LocalECPotential::PP, LocalECPotential::PPset, and LocalECPotential::Zeff.

47 {
48  for (int iat = 0; iat < PP.size(); iat++)
49  {
50  if (IonConfig.GroupID[iat] == groupID)
51  {
52  PP[iat] = ppot.get();
53  Zeff[iat] = z;
54  }
55  }
56  PPset[groupID] = std::move(ppot);
57  gZeff[groupID] = z;
58 }
std::vector< RealType > Zeff
effective charge per ion
const ParticleSet & IonConfig
reference to the ionic configuration
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
std::vector< std::unique_ptr< RadialPotentialType > > PPset
unique set of local ECP to cleanup
std::vector< RadialPotentialType * > PP
PP[iat] is the local potential for the iat-th particle.
std::vector< RealType > gZeff
effective charge per species

◆ checkoutParticleQuantities()

void checkoutParticleQuantities ( TraceManager tm)
overridevirtual

Reimplemented from OperatorBase.

Definition at line 63 of file LocalECPotential.cpp.

References TraceManager::checkout_real(), OperatorBase::name_, LocalECPotential::Peln, LocalECPotential::Pion, OperatorBase::request_, TraceRequest::streaming_array(), OperatorBase::streaming_particles_, LocalECPotential::Ve_sample, and LocalECPotential::Vi_sample.

64 {
67  {
68  Ve_sample = tm.checkout_real<1>(name_, Peln);
69  Vi_sample = tm.checkout_real<1>(name_, Pion);
70  }
71 }
Array< TraceReal, 1 > * Vi_sample
bool streaming_array(const std::string &name)
Definition: TraceManager.h:249
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
Array< TraceReal, 1 > * Ve_sample
single particle trace samples
std::string name_
name of this object
Definition: OperatorBase.h:527

◆ contributeParticleQuantities()

void contributeParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 61 of file LocalECPotential.cpp.

References TraceRequest::contribute_array(), OperatorBase::name_, and OperatorBase::request_.

TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
std::string name_
name of this object
Definition: OperatorBase.h:527
void contribute_array(const std::string &name, bool default_quantity=false)
Definition: TraceManager.h:198

◆ deleteParticleQuantities()

void deleteParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 73 of file LocalECPotential.cpp.

References OperatorBase::streaming_particles_, LocalECPotential::Ve_sample, and LocalECPotential::Vi_sample.

74 {
76  {
77  delete Ve_sample;
78  delete Vi_sample;
79  }
80 }
Array< TraceReal, 1 > * Vi_sample
Array< TraceReal, 1 > * Ve_sample
single particle trace samples

◆ evaluate()

LocalECPotential::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 84 of file LocalECPotential.cpp.

References LocalECPotential::evaluate_sp(), ParticleSet::getDistTableAB(), ParticleSet::getTotalNum(), LocalECPotential::myTableIndex, LocalECPotential::NumIons, LocalECPotential::PP, OperatorBase::streaming_particles_, OperatorBase::value_, and LocalECPotential::Zeff.

85 {
86 #if !defined(REMOVE_TRACEMANAGER)
88  value_ = evaluate_sp(P);
89  else
90 #endif
91  {
92  const auto& d_table(P.getDistTableAB(myTableIndex));
93  value_ = 0.0;
94  const size_t Nelec = P.getTotalNum();
95  for (size_t iel = 0; iel < Nelec; ++iel)
96  {
97  const auto& dist = d_table.getDistRow(iel);
98  Return_t esum(0);
99  for (size_t iat = 0; iat < NumIons; ++iat)
100  if (PP[iat] != nullptr)
101  esum += PP[iat]->splint(dist[iat]) * Zeff[iat] / dist[iat];
102  value_ -= esum;
103  }
104  }
105  return value_;
106 }
std::vector< RealType > Zeff
effective charge per ion
int myTableIndex
distance table index
Return_t evaluate_sp(ParticleSet &P)
std::vector< RadialPotentialType * > PP
PP[iat] is the local potential for the iat-th particle.
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Return_t value_
current value
Definition: OperatorBase.h:524
int NumIons
the number of ioncs

◆ evaluate_orig()

LocalECPotential::Return_t evaluate_orig ( ParticleSet P)

Definition at line 203 of file LocalECPotential.cpp.

References ParticleSet::getDistTableAB(), ParticleSet::getTotalNum(), LocalECPotential::myTableIndex, LocalECPotential::NumIons, LocalECPotential::PP, OperatorBase::value_, and LocalECPotential::Zeff.

Referenced by LocalECPotential::evaluate_sp().

204 {
205  const auto& d_table(P.getDistTableAB(myTableIndex));
206  value_ = 0.0;
207  const size_t Nelec = P.getTotalNum();
208  for (size_t iel = 0; iel < Nelec; ++iel)
209  {
210  const auto& dist = d_table.getDistRow(iel);
211  Return_t esum(0);
212  for (size_t iat = 0; iat < NumIons; ++iat)
213  if (PP[iat] != nullptr)
214  esum += PP[iat]->splint(dist[iat]) * Zeff[iat] / dist[iat];
215  value_ -= esum;
216  }
217  return value_;
218 }
std::vector< RealType > Zeff
effective charge per ion
int myTableIndex
distance table index
std::vector< RadialPotentialType * > PP
PP[iat] is the local potential for the iat-th particle.
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Return_t value_
current value
Definition: OperatorBase.h:524
int NumIons
the number of ioncs

◆ evaluate_sp()

Definition at line 144 of file LocalECPotential.cpp.

References qmcplusplus::abs(), APP_ABORT, qmcplusplus::app_log(), LocalECPotential::evaluate_orig(), ParticleSet::getDistTableAB(), ParticleSet::getTotalNum(), LocalECPotential::myTableIndex, LocalECPotential::NumIons, LocalECPotential::PP, Array< T, D, ALLOC >::sum(), TraceManager::trace_tol, OperatorBase::value_, LocalECPotential::Ve_sample, LocalECPotential::Vi_sample, and LocalECPotential::Zeff.

Referenced by LocalECPotential::evaluate().

145 {
146  const auto& d_table(P.getDistTableAB(myTableIndex));
147  value_ = 0.0;
148  Array<RealType, 1>& Ve_samp = *Ve_sample;
149  Array<RealType, 1>& Vi_samp = *Vi_sample;
150  Ve_samp = 0.0;
151  Vi_samp = 0.0;
152 
153  const size_t Nelec = P.getTotalNum();
154  for (size_t iel = 0; iel < Nelec; ++iel)
155  {
156  const auto& dist = d_table.getDistRow(iel);
157  Return_t esum(0), pairpot;
158  for (size_t iat = 0; iat < NumIons; ++iat)
159  if (PP[iat] != nullptr)
160  {
161  pairpot = -0.5 * PP[iat]->splint(dist[iat]) * Zeff[iat] / dist[iat];
162  Vi_samp(iat) += pairpot;
163  Ve_samp(iel) += pairpot;
164  esum += pairpot;
165  }
166  value_ += esum;
167  }
168  value_ *= 2.0;
169 
170 #if defined(TRACE_CHECK)
171  RealType Vnow = Value;
172  RealType Visum = Vi_samp.sum();
173  RealType Vesum = Ve_samp.sum();
174  RealType Vsum = Vesum + Visum;
175  RealType Vorig = evaluate_orig(P);
176  if (std::abs(Vsum - Vnow) > TraceManager::trace_tol)
177  {
178  app_log() << "accumtest: LocalECPotential::evaluate()" << std::endl;
179  app_log() << "accumtest: tot:" << Vnow << std::endl;
180  app_log() << "accumtest: sum:" << Vsum << std::endl;
181  APP_ABORT("Trace check failed");
182  }
183  if (std::abs(Vesum - Visum) > TraceManager::trace_tol)
184  {
185  app_log() << "sharetest: LocalECPotential::evaluate()" << std::endl;
186  app_log() << "sharetest: e share:" << Vesum << std::endl;
187  app_log() << "sharetest: i share:" << Visum << std::endl;
188  APP_ABORT("Trace check failed");
189  }
190  if (std::abs(Vorig - Vnow) > TraceManager::trace_tol)
191  {
192  app_log() << "versiontest: LocalECPotential::evaluate()" << std::endl;
193  app_log() << "versiontest: orig:" << Vorig << std::endl;
194  app_log() << "versiontest: mod:" << Vnow << std::endl;
195  APP_ABORT("Trace check failed");
196  }
197 #endif
198  return value_;
199 }
Array< TraceReal, 1 > * Vi_sample
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< RealType > Zeff
effective charge per ion
int myTableIndex
distance table index
Array< TraceReal, 1 > * Ve_sample
single particle trace samples
std::vector< RadialPotentialType * > PP
PP[iat] is the local potential for the iat-th particle.
Return_t evaluate_orig(ParticleSet &P)
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Type_t sum() const
Definition: OhmmsArray.h:214
QMCTraits::RealType RealType
Return_t value_
current value
Definition: OperatorBase.h:524
int NumIons
the number of ioncs

◆ evaluateWithIonDerivs()

LocalECPotential::Return_t evaluateWithIonDerivs ( ParticleSet P,
ParticleSet ions,
TrialWaveFunction psi,
ParticleSet::ParticlePos hf_term,
ParticleSet::ParticlePos pulay_term 
)
overridevirtual

Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase.

Parameters
Ptarget particle set (electrons)
ionssource particle set (ions)
psiTrial wave function
hf_termsAdds OperatorBase's contribution to Re [(dH)Psi]/Psi
pulay_termsAdds OperatorBase's contribution to Re [(H-E_L)dPsi]/Psi
Returns
Contribution of OperatorBase to Local Energy.

Reimplemented from OperatorBase.

Definition at line 108 of file LocalECPotential.cpp.

References ParticleSet::getDistTableAB(), ParticleSet::getTotalNum(), LocalECPotential::myTableIndex, LocalECPotential::NumIons, LocalECPotential::PP, OperatorBase::value_, and LocalECPotential::Zeff.

113 {
114  const auto& d_table(P.getDistTableAB(myTableIndex));
115  value_ = 0.0;
116  const size_t Nelec = P.getTotalNum();
117  for (size_t iel = 0; iel < Nelec; ++iel)
118  {
119  const auto& dist = d_table.getDistRow(iel);
120  const auto& dr = d_table.getDisplRow(iel);
121  Return_t esum(0);
122  //value, radial derivative, and 2nd derivative of spline r*V.
123  RealType v(0.0), dv(0.0), d2v(0.0);
124  //radial derivative dV/dr
125  RealType dvdr(0.0);
126  RealType rinv(1.0);
127  for (size_t iat = 0; iat < NumIons; ++iat)
128  {
129  if (PP[iat] != nullptr)
130  {
131  rinv = 1.0 / dist[iat];
132  v = PP[iat]->splint(dist[iat], dv, d2v);
133  dvdr = -Zeff[iat] * (dv - v * rinv) * rinv; //the minus is because of charge of electron.
134  hf_terms[iat] += dvdr * dr[iat] * rinv;
135  esum += -Zeff[iat] * v * rinv;
136  }
137  }
138  value_ += esum;
139  }
140  return value_;
141 }
std::vector< RealType > Zeff
effective charge per ion
int myTableIndex
distance table index
std::vector< RadialPotentialType * > PP
PP[iat] is the local potential for the iat-th particle.
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
QMCTraits::RealType RealType
Return_t value_
current value
Definition: OperatorBase.h:524
int NumIons
the number of ioncs

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 89 of file LocalECPotential.h.

References OhmmsElementBase::getName(), and LocalECPotential::IonConfig.

90  {
91  os << "LocalECPotential: " << IonConfig.getName();
92  return true;
93  }
const std::string & getName() const
return the name
const ParticleSet & IonConfig
reference to the ionic configuration

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 66 of file LocalECPotential.h.

66 { return "LocalECPotential"; }

◆ makeClone()

std::unique_ptr< OperatorBase > makeClone ( ParticleSet qp,
TrialWaveFunction psi 
)
overridevirtual

Implements OperatorBase.

Definition at line 220 of file LocalECPotential.cpp.

References LocalECPotential::gZeff, LocalECPotential::IonConfig, and LocalECPotential::PPset.

221 {
222  std::unique_ptr<LocalECPotential> myclone = std::make_unique<LocalECPotential>(IonConfig, qp);
223 
224  for (int ig = 0; ig < PPset.size(); ++ig)
225  {
226  if (PPset[ig])
227  {
228  myclone->add(ig, std::unique_ptr<RadialPotentialType>(PPset[ig]->makeClone()), gZeff[ig]);
229  }
230  }
231  return myclone;
232 }
const ParticleSet & IonConfig
reference to the ionic configuration
std::vector< std::unique_ptr< RadialPotentialType > > PPset
unique set of local ECP to cleanup
std::vector< RealType > gZeff
effective charge per species
std::unique_ptr< OperatorBase > makeClone(ParticleSet &qp, TrialWaveFunction &psi) override

◆ put()

bool put ( xmlNodePtr  cur)
inlineoverridevirtual

Read the input parameter.

Parameters
curxml node for a OperatorBase object

Implements OperatorBase.

Definition at line 87 of file LocalECPotential.h.

87 { return true; }

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
overridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 37 of file LocalECPotential.cpp.

References ParticleSet::addTable(), APP_ABORT, LocalECPotential::IonConfig, and LocalECPotential::myTableIndex.

38 {
39  int tid = P.addTable(IonConfig);
40  if (tid != myTableIndex)
41  {
42  APP_ABORT(" LocalECPotential::resetTargetParticleSet found a different distance table index.");
43  }
44 }
const ParticleSet & IonConfig
reference to the ionic configuration
int myTableIndex
distance table index
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

Member Data Documentation

◆ gZeff

std::vector<RealType> gZeff

effective charge per species

Definition at line 53 of file LocalECPotential.h.

Referenced by LocalECPotential::add(), LocalECPotential::LocalECPotential(), and LocalECPotential::makeClone().

◆ IonConfig

const ParticleSet& IonConfig

reference to the ionic configuration

Definition at line 39 of file LocalECPotential.h.

Referenced by LocalECPotential::add(), LocalECPotential::get(), LocalECPotential::makeClone(), and LocalECPotential::resetTargetParticleSet().

◆ myTableIndex

◆ NumIons

◆ Peln

const ParticleSet& Peln

Definition at line 61 of file LocalECPotential.h.

Referenced by LocalECPotential::checkoutParticleQuantities().

◆ Pion

const ParticleSet& Pion

Definition at line 62 of file LocalECPotential.h.

Referenced by LocalECPotential::checkoutParticleQuantities().

◆ PP

◆ PPart

Vector<RealType> PPart

energy per particle

Definition at line 55 of file LocalECPotential.h.

◆ PPset

std::vector<std::unique_ptr<RadialPotentialType> > PPset

unique set of local ECP to cleanup

Definition at line 47 of file LocalECPotential.h.

Referenced by LocalECPotential::add(), LocalECPotential::LocalECPotential(), and LocalECPotential::makeClone().

◆ PPtmp

RealType PPtmp

temporary energy per particle for pbyp move

Definition at line 45 of file LocalECPotential.h.

◆ Ve_sample

◆ Vi_sample

◆ Zeff

◆ qmcplusplus::MPC

class qmcplusplus::MPC

Calculates the Model Periodic Coulomb potential using PBCs.

Definition at line 33 of file MPC.h.

+ Inheritance diagram for MPC:
+ Collaboration diagram for MPC:

Public Member Functions

 MPC (ParticleSet &ref, double cutoff)
 
 ~MPC () override
 copy constructor More...
 
std::string getClassName () const override
 return class name More...
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
bool put (xmlNodePtr cur) override
 Do nothing. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) override
 
- 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 addObservables (PropertySetType &plist, BufferType &collectables)
 named values to the property list Default implementaton uses addValue(plist_) 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 registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 
virtual void setObservables (PropertySetType &plist)
 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...
 
virtual void setParticlePropertyList (PropertySetType &plist, int offset)
 
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

std::vector< ComplexTypeRhoAvg_G
 
std::vector< RealTypef_G
 
double f_0
 
bool FirstTime
 
int NumSpecies
 
int ChargeAttribIndx
 
int MemberAttribIndx
 
int NParticles
 
RealType myConst
 
RealType myRcut
 
std::vector< RealTypeZat
 
std::vector< RealTypeZspec
 
std::vector< int > NofSpecies
 

Protected Member Functions

void initBreakup (const ParticleSet &ptcl)
 
void compute_g_G (const ParticleSet &ptcl, double &g_0_N, std::vector< double > &g_G_N, int N)
 
void init_gvecs (const ParticleSet &ptcl)
 
void init_f_G (const ParticleSet &ptcl)
 
void init_spline (const ParticleSet &ptcl)
 
Return_t evalSR (ParticleSet &P) const
 
Return_t evalLR (ParticleSet &P) const
 
- 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

std::shared_ptr< UBspline_3d_d > VlongSpline
 
double Vconst
 
double Ecut
 
std::vector< TinyVector< int, OHMMS_DIM > > Gints
 
std::vector< PosTypeGvecs
 
std::vector< ComplexTypeRho_G
 
std::array< size_t, OHMMS_DIMSplineDim
 
int MaxDim
 
const int d_aa_ID
 
- 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_
 

Additional Inherited Members

- 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 > >
 

Constructor & Destructor Documentation

◆ MPC()

MPC ( ParticleSet ref,
double  cutoff 
)

Definition at line 35 of file MPC.cpp.

References MPC::initBreakup(), and qmcplusplus::NEED_FULL_TABLE_ON_HOST_AFTER_DONEPBYP.

36  : Ecut(cutoff), d_aa_ID(ptcl.addTable(ptcl, DTModes::NEED_FULL_TABLE_ON_HOST_AFTER_DONEPBYP)), FirstTime(true)
37 {
38  initBreakup(ptcl);
39 }
double Ecut
Definition: MPC.h:39
const int d_aa_ID
Definition: MPC.h:46
bool FirstTime
Definition: MPC.h:63
void initBreakup(const ParticleSet &ptcl)
Definition: MPC.cpp:291
whether full table needs to be ready at anytime or not after donePbyP Optimization can be implemented...

◆ ~MPC()

~MPC ( )
overridedefault

copy constructor

Member Function Documentation

◆ compute_g_G()

void compute_g_G ( const ParticleSet ptcl,
double &  g_0_N,
std::vector< double > &  g_G_N,
int  N 
)
protected

Definition at line 78 of file MPC.cpp.

References Array< T, D, ALLOC >::data(), ParticleSet::getLattice(), MPC::Gints, qmcplusplus::Units::force::N, norm(), OHMMS_DIM, qmcplusplus::real(), and qmcplusplus::sqrt().

Referenced by MPC::init_f_G().

79 {
80  double L = ptcl.getLattice().WignerSeitzRadius;
81  double Linv = 1.0 / L;
82  double Linv3 = Linv * Linv * Linv;
83  // create an FFTW plan
84  Array<std::complex<double>, 3> rBox(N, N, N);
85  Array<std::complex<double>, 3> GBox(N, N, N);
86  // app_log() << "Doing " << N << " x " << N << " x " << N << " FFT.\n";
87  //create BC handler
88  DTD_BConds<RealType, 3, SUPERCELL_BULK> mybc(ptcl.getLattice());
89  // Fill the real-space array with f(r)
90  double Ninv = 1.0 / (double)N;
92  for (int ix = 0; ix < N; ix++)
93  {
94  u[0] = Ninv * ix;
95  for (int iy = 0; iy < N; iy++)
96  {
97  u[1] = Ninv * iy;
98  for (int iz = 0; iz < N; iz++)
99  {
100  u[2] = Ninv * iz;
101  r = ptcl.getLattice().toCart(u);
102  //DTD_BConds<double,3,SUPERCELL_BULK>::apply (ptcl.getLattice(), r);
103  //double rmag = std::sqrt(dot(r,r));
104  double rmag = std::sqrt(mybc.apply_bc(r));
105  if (rmag < L)
106  rBox(ix, iy, iz) = -0.5 * rmag * rmag * Linv3 + 1.5 * Linv;
107  else
108  rBox(ix, iy, iz) = 1.0 / rmag;
109  }
110  }
111  }
112  fftw_plan fft = fftw_plan_dft_3d(N, N, N, (fftw_complex*)rBox.data(), (fftw_complex*)GBox.data(), 1, FFTW_ESTIMATE);
113  fftw_execute(fft);
114  fftw_destroy_plan(fft);
115  // Now, copy data into output, and add on analytic part
116  double norm = Ninv * Ninv * Ninv;
117  int numG = Gints.size();
118  for (int iG = 0; iG < numG; iG++)
119  {
121  for (int j = 0; j < OHMMS_DIM; j++)
122  gint[j] = (gint[j] + N) % N;
123  g_G[iG] = norm * real(GBox(gint[0], gint[1], gint[2]));
124  }
125  g_0 = norm * real(GBox(0, 0, 0));
126 }
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
#define OHMMS_DIM
Definition: config.h:64
double norm(const zVec &c)
Definition: VectorOps.h:118
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
A D-dimensional Array class based on PETE.
Definition: OhmmsArray.h:25
std::vector< TinyVector< int, OHMMS_DIM > > Gints
Definition: MPC.h:40

◆ evalLR()

MPC::Return_t evalLR ( ParticleSet P) const
protected

Definition at line 338 of file MPC.cpp.

References qmcplusplus::floor(), ParticleSet::getLattice(), MPC::NParticles, OHMMS_DIM, ParticleSet::R, and MPC::VlongSpline.

Referenced by MPC::evaluate().

339 {
340  RealType LR = 0.0;
341  double val;
342  for (int i = 0; i < NParticles; i++)
343  {
344  //PosType r = P.R[i];
345  //PosType u = P.getLattice().toUnit(r);
346  PosType u = P.getLattice().toUnit(P.R[i]);
347  for (int j = 0; j < OHMMS_DIM; j++)
348  u[j] -= std::floor(u[j]);
349  eval_UBspline_3d_d(VlongSpline.get(), u[0], u[1], u[2], &val);
350  LR += val;
351  }
352  return LR;
353 }
std::shared_ptr< UBspline_3d_d > VlongSpline
Definition: MPC.h:36
#define OHMMS_DIM
Definition: config.h:64
QMCTraits::PosType PosType
int NParticles
Definition: MPC.h:67
QMCTraits::RealType RealType
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)

◆ evalSR()

MPC::Return_t evalSR ( ParticleSet P) const
protected

Definition at line 322 of file MPC.cpp.

References BLAS::cone, MPC::d_aa_ID, ParticleSet::getDistTableAA(), and MPC::NParticles.

Referenced by MPC::evaluate().

323 {
324  const auto& d_aa = P.getDistTableAA(d_aa_ID);
325  RealType SR = 0.0;
326  const RealType cone(1);
327  for (size_t ipart = 0; ipart < NParticles; ipart++)
328  {
329  RealType esum(0);
330  const auto& dist = d_aa.getDistRow(ipart);
331  for (size_t j = 0; j < ipart; ++j)
332  esum += cone / dist[j];
333  SR += esum;
334  }
335  return SR;
336 }
const int d_aa_ID
Definition: MPC.h:46
constexpr std::complex< float > cone
Definition: BLAS.hpp:50
int NParticles
Definition: MPC.h:67
QMCTraits::RealType RealType

◆ evaluate()

MPC::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 355 of file MPC.cpp.

References MPC::evalLR(), MPC::evalSR(), OperatorBase::value_, and MPC::Vconst.

356 {
357  value_ = evalSR(P) + evalLR(P) + Vconst;
358  return value_;
359 }
Return_t evalLR(ParticleSet &P) const
Definition: MPC.cpp:338
Return_t evalSR(ParticleSet &P) const
Definition: MPC.cpp:322
Return_t value_
current value
Definition: OperatorBase.h:524
double Vconst
Definition: MPC.h:38

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 88 of file MPC.h.

89  {
90  //os << "MPC potential: " << PtclRef->getName();
91  return true;
92  }

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 80 of file MPC.h.

80 { return "MPC"; }

◆ init_f_G()

void init_f_G ( const ParticleSet ptcl)
protected

Definition at line 165 of file MPC.cpp.

References qmcplusplus::abs(), qmcplusplus::app_log(), MPC::compute_g_G(), qmcplusplus::cos(), qmcplusplus::dot(), qmcplusplus::extrap(), MPC::f_0, MPC::f_G, ParticleSet::getLattice(), MPC::Gints, MPC::Gvecs, MPC::MaxDim, qmcplusplus::Units::force::N, qmcplusplus::sin(), and qmcplusplus::sqrt().

Referenced by MPC::initBreakup().

166 {
167  int numG = Gints.size();
168  f_G.resize(numG);
169  int N = std::max(64, 2 * MaxDim + 1);
170  std::vector<double> g_G_N(numG), g_G_2N(numG), g_G_4N(numG);
171  double g_0_N, g_0_2N, g_0_4N;
172  compute_g_G(ptcl, g_0_N, g_G_N, 1 * N);
173  compute_g_G(ptcl, g_0_2N, g_G_2N, 2 * N);
174  compute_g_G(ptcl, g_0_4N, g_G_4N, 4 * N);
175  // fprintf (stderr, "g_G_1N[0] = %18.14e\n", g_G_N[0]);
176  // fprintf (stderr, "g_G_2N[0] = %18.14e\n", g_G_2N[0]);
177  // fprintf (stderr, "g_G_4N[0] = %18.14e\n", g_G_4N[0]);
178  double volInv = 1.0 / ptcl.getLattice().Volume;
179  double L = ptcl.getLattice().WignerSeitzRadius;
180  TinyVector<double, 2> g0_12(g_0_2N, g_0_4N);
181  TinyVector<double, 3> g0_124(g_0_N, g_0_2N, g_0_4N);
182  f_0 = extrap(N, g0_124);
183  app_log().precision(12);
184  app_log() << " Linear extrap = " << std::scientific << extrap(2 * N, g0_12) << std::endl;
185  app_log() << " Quadratic extrap = " << std::scientific << f_0 << std::endl;
186  f_0 += 0.4 * M_PI * L * L * volInv;
187  // std::cerr << "f_0 = " << f_0/volInv << std::endl;
188  double worst = 0.0, worstLin = 0.0, worstQuad = 0.0;
189  for (int iG = 0; iG < numG; iG++)
190  {
191  TinyVector<double, 2> g_12(g_G_2N[iG], g_G_4N[iG]);
192  TinyVector<double, 3> g_124(g_G_N[iG], g_G_2N[iG], g_G_4N[iG]);
193  double linearExtrap = extrap(2 * N, g_12);
194  double quadExtrap = extrap(N, g_124);
195  double diff = std::abs(linearExtrap - quadExtrap);
196  if (diff > worst)
197  {
198  worst = diff;
199  worstLin = linearExtrap;
200  worstQuad = quadExtrap;
201  }
202  f_G[iG] = quadExtrap;
203  double G2 = dot(Gvecs[iG], Gvecs[iG]);
204  double G = std::sqrt(G2);
205  f_G[iG] += volInv * M_PI * (4.0 / G2 + 12.0 / (L * L * G2 * G2) * (std::cos(G * L) - std::sin(G * L) / (G * L)));
206  // std::cerr << "f_G = " << f_G[iG]/volInv << std::endl;
207  // std::cerr << "f_G - 4*pi/G2= " << f_G[iG]/volInv - 4.0*M_PI/G2 << std::endl;
208  }
209  std::array<char, 1000> buff;
210  int length = std::snprintf(buff.data(), buff.size(),
211  " Worst MPC discrepancy:\n"
212  " Linear Extrap : %18.14e\n"
213  " Quadratic Extrap: %18.14e\n",
214  worstLin, worstQuad);
215  if (length < 0)
216  throw std::runtime_error("Error generating buffer string");
217  app_log() << std::string_view(buff.data(), length);
218 }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
double extrap(int N, TinyVector< double, 3 > g_124)
Definition: MPC.cpp:129
std::ostream & app_log()
Definition: OutputManager.h:65
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
double f_0
Definition: MPC.h:61
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
int MaxDim
Definition: MPC.h:44
std::vector< RealType > f_G
Definition: MPC.h:59
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< PosType > Gvecs
Definition: MPC.h:41
void compute_g_G(const ParticleSet &ptcl, double &g_0_N, std::vector< double > &g_G_N, int N)
Definition: MPC.cpp:78
std::vector< TinyVector< int, OHMMS_DIM > > Gints
Definition: MPC.h:40

◆ init_gvecs()

void init_gvecs ( const ParticleSet ptcl)
protected

Definition at line 43 of file MPC.cpp.

References qmcplusplus::abs(), qmcplusplus::app_log(), ParticleSet::Density_G, ParticleSet::DensityReducedGvecs, qmcplusplus::dot(), MPC::Ecut, ParticleSet::getLattice(), MPC::Gints, MPC::Gvecs, MPC::MaxDim, OHMMS_DIM, MPC::Rho_G, and MPC::SplineDim.

Referenced by MPC::initBreakup().

44 {
45  TinyVector<int, OHMMS_DIM> maxIndex(0);
46  PosType b[OHMMS_DIM];
47  for (int j = 0; j < OHMMS_DIM; j++)
48  b[j] = static_cast<RealType>(2.0 * M_PI) * ptcl.getLattice().b(j);
49  int numG1 = ptcl.Density_G.size();
50  int numG2 = ptcl.DensityReducedGvecs.size();
51  assert(ptcl.Density_G.size() == ptcl.DensityReducedGvecs.size());
52  // Loop through all the G-vectors, and find the largest
53  // indices in each direction with energy less than the cutoff
54  for (int iG = 0; iG < ptcl.DensityReducedGvecs.size(); iG++)
55  {
56  TinyVector<int, OHMMS_DIM> gint = ptcl.DensityReducedGvecs[iG];
57  PosType G = (double)gint[0] * b[0];
58  for (int j = 1; j < OHMMS_DIM; j++)
59  G += (double)gint[j] * b[j];
60  if (0.5 * dot(G, G) < Ecut)
61  {
62  for (int j = 0; j < OHMMS_DIM; j++)
63  maxIndex[j] = std::max(maxIndex[j], std::abs(gint[j]));
64  Gvecs.push_back(G);
65  Gints.push_back(gint);
66  Rho_G.push_back(ptcl.Density_G[iG]);
67  }
68  }
69  for (int idim = 0; idim < OHMMS_DIM; idim++)
70  SplineDim[idim] = 4 * maxIndex[idim];
71  MaxDim = std::max(maxIndex[0], std::max(maxIndex[1], maxIndex[2]));
72  app_log() << " Using " << Gvecs.size() << " G-vectors for MPC interaction.\n";
73  app_log() << " Using real-space box of size [" << SplineDim[0] << "," << SplineDim[1] << "," << SplineDim[2]
74  << "] for MPC spline.\n";
75 }
double Ecut
Definition: MPC.h:39
std::array< size_t, OHMMS_DIM > SplineDim
Definition: MPC.h:43
std::vector< ComplexType > Rho_G
Definition: MPC.h:42
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::ostream & app_log()
Definition: OutputManager.h:65
#define OHMMS_DIM
Definition: config.h:64
QMCTraits::PosType PosType
int MaxDim
Definition: MPC.h:44
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< PosType > Gvecs
Definition: MPC.h:41
std::vector< TinyVector< int, OHMMS_DIM > > Gints
Definition: MPC.h:40

◆ init_spline()

void init_spline ( const ParticleSet ptcl)
protected

Definition at line 221 of file MPC.cpp.

References qmcplusplus::app_log(), Array< T, D, ALLOC >::data(), qmcplusplus::dot(), MPC::f_0, MPC::f_G, ParticleSet::getLattice(), MPC::Gints, MPC::Gvecs, norm(), OHMMS_DIM, qmcplusplus::real(), MPC::Rho_G, MPC::SplineDim, MPC::Vconst, and MPC::VlongSpline.

Referenced by MPC::initBreakup().

222 {
224  Array<double, 3> splineData(SplineDim);
225  GBox = std::complex<double>();
226  Vconst = 0.0;
227  // Now fill in elements of GBox
228  const RealType vol = ptcl.getLattice().Volume;
229  const RealType volInv = 1.0 / ptcl.getLattice().Volume;
230  const RealType halfvol = vol / 2.0;
231  for (int iG = 0; iG < Gvecs.size(); iG++)
232  {
234  PosType G = Gvecs[iG];
235  double G2 = dot(G, G);
237  for (int j = 0; j < OHMMS_DIM; j++)
238  index[j] = (gint[j] + SplineDim[j]) % SplineDim[j];
239 
240  const RealType xxx(vol * (4.0 * M_PI * volInv / G2 - f_G[iG]));
241  if (!(index[0] == 0 && index[1] == 0 && index[2] == 0))
242  {
243  GBox(index[0], index[1], index[2]) = xxx * Rho_G[iG];
244  Vconst -= halfvol * xxx * norm(Rho_G[iG]);
245  //GBox(index[0], index[1], index[2]) = vol *
246  // Rho_G[iG] * (4.0*M_PI*volInv/G2 - f_G[iG]);
247  //Vconst -= 0.5 * vol * vol * norm(Rho_G[iG])
248  // * (4.0*M_PI*volInv/G2 - f_G[iG]);
249  }
250  }
251  // G=0 component calculated separately
252  //GBox(0,0,0) = -vol * f_0 * Rho_G[0];
253  //Vconst += 0.5 * vol * vol * f_0 * norm(Rho_G[0]);
254  const RealType volf = vol * f_0;
255  GBox(0, 0, 0) = -volf * Rho_G[0];
256  Vconst += halfvol * volf * norm(Rho_G[0]);
257 
258  app_log() << " Constant potential = " << Vconst << std::endl;
259  fftw_plan fft = fftw_plan_dft_3d(SplineDim[0], SplineDim[1], SplineDim[2], (fftw_complex*)GBox.data(),
260  (fftw_complex*)rBox.data(), -1, FFTW_ESTIMATE);
261  fftw_execute(fft);
262  fftw_destroy_plan(fft);
263  for (int i0 = 0; i0 < SplineDim[0]; i0++)
264  for (int i1 = 0; i1 < SplineDim[1]; i1++)
265  for (int i2 = 0; i2 < SplineDim[2]; i2++)
266  splineData(i0, i1, i2) = real(rBox(i0, i1, i2));
267  BCtype_d bc0, bc1, bc2;
268  Ugrid grid0, grid1, grid2;
269  grid0.start = 0.0;
270  grid0.end = 1.0;
271  grid0.num = SplineDim[0];
272  grid1.start = 0.0;
273  grid1.end = 1.0;
274  grid1.num = SplineDim[1];
275  grid2.start = 0.0;
276  grid2.end = 1.0;
277  grid2.num = SplineDim[2];
278  bc0.lCode = bc0.rCode = PERIODIC;
279  bc1.lCode = bc1.rCode = PERIODIC;
280  bc2.lCode = bc2.rCode = PERIODIC;
281  VlongSpline =
282  std::shared_ptr<UBspline_3d_d>(create_UBspline_3d_d(grid0, grid1, grid2, bc0, bc1, bc2, splineData.data()),
283  destroy_Bspline);
284  // grid0.num = ptcl.Density_r.size(0);
285  // grid1.num = ptcl.Density_r.size(1);
286  // grid2.num = ptcl.Density_r.size(2);
287  // DensitySpline = create_UBspline_3d_d (grid0, grid1, grid2, bc0, bc1, bc2,
288  // ptcl.Density_r.data());
289 }
std::shared_ptr< UBspline_3d_d > VlongSpline
Definition: MPC.h:36
std::array< size_t, OHMMS_DIM > SplineDim
Definition: MPC.h:43
std::vector< ComplexType > Rho_G
Definition: MPC.h:42
std::ostream & app_log()
Definition: OutputManager.h:65
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
double f_0
Definition: MPC.h:61
#define OHMMS_DIM
Definition: config.h:64
QMCTraits::PosType PosType
double norm(const zVec &c)
Definition: VectorOps.h:118
std::vector< RealType > f_G
Definition: MPC.h:59
QMCTraits::RealType RealType
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< PosType > Gvecs
Definition: MPC.h:41
double Vconst
Definition: MPC.h:38
A D-dimensional Array class based on PETE.
Definition: OhmmsArray.h:25
std::vector< TinyVector< int, OHMMS_DIM > > Gints
Definition: MPC.h:40

◆ initBreakup()

void initBreakup ( const ParticleSet ptcl)
protected

Definition at line 291 of file MPC.cpp.

References qmcplusplus::app_log(), ParticleSet::getTotalNum(), MPC::init_f_G(), MPC::init_gvecs(), MPC::init_spline(), and MPC::NParticles.

Referenced by MPC::MPC().

292 {
293  NParticles = ptcl.getTotalNum();
294  app_log() << "\n === Initializing MPC interaction === " << std::endl;
295  init_gvecs(ptcl);
296  init_f_G(ptcl);
297  init_spline(ptcl);
298  // FILE *fout = fopen ("MPC.dat", "w");
299  // double vol = ptcl.getLattice().Volume;
300  // PosType r0 (0.0, 0.0, 0.0);
301  // PosType r1 (10.26499236, 10.26499236, 10.26499236);
302  // int nPoints=1001;
303  // for (int i=0; i<nPoints; i++) {
304  // double s = (double)i/(double)(nPoints-1);
305  // PosType r = (1.0-s)*r0 + s*r1;
306  // PosType u = ptcl.getLattice().toUnit(r);
307  // double V, rho(0.0);
308  // eval_UBspline_3d_d (VlongSpline, u[0], u[1], u[2], &V);
309  // // eval_UBspline_3d_d (DensitySpline, u[0], u[1], u[2], &rho);
310  // fprintf (fout, "%6.4f %14.10e %14.10e\n", s, V, rho);
311  // }
312  // fclose(fout);
313  app_log() << " === MPC interaction initialized === \n\n";
314 }
std::ostream & app_log()
Definition: OutputManager.h:65
void init_f_G(const ParticleSet &ptcl)
Definition: MPC.cpp:165
void init_gvecs(const ParticleSet &ptcl)
Definition: MPC.cpp:43
void init_spline(const ParticleSet &ptcl)
Definition: MPC.cpp:221
int NParticles
Definition: MPC.h:67

◆ makeClone()

std::unique_ptr< OperatorBase > makeClone ( ParticleSet qp,
TrialWaveFunction psi 
)
overridevirtual

Implements OperatorBase.

Definition at line 316 of file MPC.cpp.

317 {
318  auto newMPC = std::make_unique<MPC>(*this);
319  return newMPC;
320 }

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

Do nothing.

Implements OperatorBase.

Definition at line 361 of file MPC.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_log(), MPC::Ecut, and OhmmsAttributeSet::put().

362 {
363  Ecut = -1.0;
364  OhmmsAttributeSet attribs;
365  attribs.add(Ecut, "cutoff");
366  attribs.put(cur);
367  if (Ecut < 0.0)
368  {
369  Ecut = 30.0;
370  app_log() << " MPC cutoff not found. Set using \"cutoff\" attribute.\n"
371  << " Setting to default value of " << Ecut << std::endl;
372  }
373  return true;
374 }
double Ecut
Definition: MPC.h:39
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
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

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
overridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 33 of file MPC.cpp.

33 {}

Member Data Documentation

◆ ChargeAttribIndx

int ChargeAttribIndx

Definition at line 65 of file MPC.h.

◆ d_aa_ID

const int d_aa_ID
protected

Definition at line 46 of file MPC.h.

Referenced by MPC::evalSR().

◆ Ecut

double Ecut
protected

Definition at line 39 of file MPC.h.

Referenced by MPC::init_gvecs(), and MPC::put().

◆ f_0

double f_0

Definition at line 61 of file MPC.h.

Referenced by MPC::init_f_G(), and MPC::init_spline().

◆ f_G

std::vector<RealType> f_G

Definition at line 59 of file MPC.h.

Referenced by MPC::init_f_G(), and MPC::init_spline().

◆ FirstTime

bool FirstTime

Definition at line 63 of file MPC.h.

◆ Gints

std::vector<TinyVector<int, OHMMS_DIM> > Gints
protected

Definition at line 40 of file MPC.h.

Referenced by MPC::compute_g_G(), MPC::init_f_G(), MPC::init_gvecs(), and MPC::init_spline().

◆ Gvecs

std::vector<PosType> Gvecs
protected

Definition at line 41 of file MPC.h.

Referenced by MPC::init_f_G(), MPC::init_gvecs(), and MPC::init_spline().

◆ MaxDim

int MaxDim
protected

Definition at line 44 of file MPC.h.

Referenced by MPC::init_f_G(), and MPC::init_gvecs().

◆ MemberAttribIndx

int MemberAttribIndx

Definition at line 66 of file MPC.h.

◆ myConst

RealType myConst

Definition at line 68 of file MPC.h.

◆ myRcut

RealType myRcut

Definition at line 69 of file MPC.h.

◆ NofSpecies

std::vector<int> NofSpecies

Definition at line 71 of file MPC.h.

◆ NParticles

int NParticles

Definition at line 67 of file MPC.h.

Referenced by MPC::evalLR(), MPC::evalSR(), and MPC::initBreakup().

◆ NumSpecies

int NumSpecies

Definition at line 64 of file MPC.h.

◆ Rho_G

std::vector<ComplexType> Rho_G
protected

Definition at line 42 of file MPC.h.

Referenced by MPC::init_gvecs(), and MPC::init_spline().

◆ RhoAvg_G

std::vector<ComplexType> RhoAvg_G

Definition at line 58 of file MPC.h.

◆ SplineDim

std::array<size_t, OHMMS_DIM> SplineDim
protected

Definition at line 43 of file MPC.h.

Referenced by MPC::init_gvecs(), and MPC::init_spline().

◆ Vconst

double Vconst
protected

Definition at line 38 of file MPC.h.

Referenced by MPC::evaluate(), and MPC::init_spline().

◆ VlongSpline

std::shared_ptr<UBspline_3d_d> VlongSpline
protected

Definition at line 36 of file MPC.h.

Referenced by MPC::evalLR(), and MPC::init_spline().

◆ Zat

std::vector<RealType> Zat

Definition at line 70 of file MPC.h.

◆ Zspec

std::vector<RealType> Zspec

Definition at line 70 of file MPC.h.

◆ qmcplusplus::NonLocalECPotential

class qmcplusplus::NonLocalECPotential

Evaluate the semi local potentials.

Definition at line 39 of file NonLocalECPotential.h.

+ Inheritance diagram for NonLocalECPotential:
+ Collaboration diagram for NonLocalECPotential:

Public Member Functions

 NonLocalECPotential (ParticleSet &ions, ParticleSet &els, TrialWaveFunction &psi, bool computeForces, bool enable_DLA)
 constructor More...
 
 ~NonLocalECPotential () override
 
bool dependsOnWaveFunction () const override
 return true if this operator depends on a wavefunction More...
 
std::string getClassName () const override
 return class name More...
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
void contributeParticleQuantities () override
 
void checkoutParticleQuantities (TraceManager &tm) override
 
void deleteParticleQuantities () override
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
Return_t evaluateDeterministic (ParticleSet &P) override
 Evaluate the local energy contribution of this component, deterministically based on current state. More...
 
void mw_evaluate (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const override
 Evaluate the contribution of this component of multiple walkers. More...
 
Return_t evaluateWithToperator (ParticleSet &P) override
 Evaluate the local energy contribution of this component with Toperators updated if requested. More...
 
void mw_evaluateWithToperator (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const override
 Evaluate the contribution of this component of multiple walkers. More...
 
void mw_evaluatePerParticle (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< Real >> &listeners, const std::vector< ListenerVector< Real >> &listeners_ions) const override
 
void mw_evaluatePerParticleWithToperator (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< Real >> &listeners, const std::vector< ListenerVector< Real >> &listeners_ions) const override
 
Return_t evaluateWithIonDerivs (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms) override
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
Return_t evaluateWithIonDerivsDeterministic (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms) override
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
void evaluateOneBodyOpMatrix (ParticleSet &P, const TWFFastDerivWrapper &psi, std::vector< ValueMatrix > &B) override
 Evaluate "B" matrix for observable. More...
 
void evaluateOneBodyOpMatrixForceDeriv (ParticleSet &P, ParticleSet &source, const TWFFastDerivWrapper &psi, const int iat, std::vector< std::vector< ValueMatrix >> &Bforce) override
 Evaluate "dB/dR" matrices for observable. More...
 
void setNonLocalMoves (xmlNodePtr cur)
 set non local moves options More...
 
void setNonLocalMoves (const std::string &non_local_move_option, const double tau, const double alpha, const double gamma)
 
int makeNonLocalMovesPbyP (ParticleSet &P)
 make non local moves with particle-by-particle moves More...
 
Return_t evaluateValueAndDerivatives (ParticleSet &P, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
bool put (xmlNodePtr cur) override
 Do nothing. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
 return a shared resource to a collection More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) override
 
void addComponent (int groupID, std::unique_ptr< NonLocalECPComponent > &&pp)
 
void setRandomGenerator (RandomBase< FullPrecRealType > *rng) override
 set the internal RNG pointer as the given pointer More...
 
void addObservables (PropertySetType &plist, BufferType &collectables) override
 named values to the property list Default implementaton uses addValue(plist_) 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 registerObservables (std::vector< ObservableHelper > &h5list, hdf_archive &file) const override
 add to observable descriptor for hdf5 The default implementation is to register a scalar for this->value_ More...
 
void setComputeForces (bool val) override
 Set the flag whether to compute forces or not. More...
 
- Public Member Functions inherited from OperatorBase
 OperatorBase ()
 Construct a new Operator Base object Default and unique empty constructor. More...
 
virtual ~OperatorBase ()=default
 
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 registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 
virtual void setHistories (Walker_t &ThisWalker)
 
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 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 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 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 Member Functions inherited from ForceBase
Real g (Real r)
 
void initVarReduction (Real rcut, int m, int numFuncs)
 
 ForceBase (ParticleSet &ions, ParticleSet &elns)
 
virtual ~ForceBase ()
 
void registerObservablesF (std::vector< ObservableHelper > &h5list, hdf_archive &file) const
 
void addObservablesF (QMCTraits::PropertySetType &plist)
 
void addObservablesStress (QMCTraits::PropertySetType &plist)
 
void setObservablesF (QMCTraits::PropertySetType &plist)
 
void setObservablesStress (QMCTraits::PropertySetType &plist)
 
void setParticleSetF (QMCTraits::PropertySetType &plist, int offset)
 
void setParticleSetStress (QMCTraits::PropertySetType &plist, int offset)
 
bool getAddIonIon () const noexcept
 
void setAddIonIon (bool val) noexcept
 
const ParticleSet::ParticlePosgetForces () const noexcept
 
void setForces (const ParticleSet::ParticlePos &forces)
 
void setForces (Real val)
 
const ParticleSet::ParticlePosgetForcesIonIon () const noexcept
 
void setForcesIonIon (const ParticleSet::ParticlePos &forces_ion_ion)
 
const SymTensor< Real, OHMMS_DIM > & getStressIonIon () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStressEE () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStressEI () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStressKin () const noexcept
 
const SymTensor< Real, OHMMS_DIM > & getStress () const noexcept
 

Static Protected Member Functions

static void mw_evaluateImpl (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, bool Tmove, std::optional< ListenerOption< Real >> listeners, bool keepGrid=false)
 the actual implementation for batched walkers, used by mw_evaluate, mw_evaluateWithToperator mw_evaluatePerPaticleWithToperator More...
 

Protected Attributes

RandomBase< FullPrecRealType > * myRNG
 random number generator More...
 
std::vector< NonLocalECPComponent * > PP
 the set of local-potentials (one for each ion) More...
 
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
 unique NonLocalECPComponent to remove More...
 
ParticleSetIonConfig
 reference to the center ion More...
 
TrialWaveFunctionPsi
 target TrialWaveFunction More...
 
bool ComputeForces
 true if we should compute forces More...
 
bool use_DLA
 true, determinant localization approximation(DLA) is enabled 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_
 
- Protected Attributes inherited from ForceBase
int first_force_index_
 
int n_nuc_
 
int n_el_
 
int tries_
 
bool first_time_
 
bool add_ion_ion_
 Determines if ion-ion force will be added to electron-ion force in derived force estimators. If false, forces_ion_ion_=0.0. More...
 
ParticleSetions_
 
ParticleSet::ParticlePos forces_
 
ParticleSet::ParticlePos forces_ion_ion_
 
SymTensor< Real, OHMMS_DIMstress_ion_ion_
 
SymTensor< Real, OHMMS_DIMstress_ee_
 
SymTensor< Real, OHMMS_DIMstress_ei_
 
SymTensor< Real, OHMMS_DIMstress_kin_
 
SymTensor< Real, OHMMS_DIMstress_
 
std::string prefix_
 
std::string pair_name_
 
Real rcut_
 
int m_
 
std::vector< Realck_
 

Private Types

using Real = QMCTraits::RealType
 

Private Member Functions

void evaluateImpl (ParticleSet &P, bool Tmove, bool keepGrid=false)
 the actual implementation, used by evaluate and evaluateWithToperator More...
 
void evalIonDerivsImpl (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms, bool keepGrid=false)
 
void computeOneElectronTxy (ParticleSet &P, const int ref_elec)
 compute the T move transition probability for a given electron member variable nonLocalOps.Txy is updated More...
 
void markAffectedElecs (const DistanceTableAB &myTable, int iel)
 mark all the electrons affected by Tmoves and update ElecNeighborIons and IonNeighborElecs More...
 

Private Attributes

int NumIons
 number of ions More...
 
int myTableIndex
 index of distance table for the ion-el pair More...
 
ParticleSetPeln
 reference to the electrons More...
 
NeighborLists ElecNeighborIons
 neighborlist of electrons More...
 
NeighborLists IonNeighborElecs
 neighborlist of ions More...
 
int UseTMove
 use T-moves More...
 
std::vector< bool > elecTMAffected
 ture if an electron is affected by other electrons moved by T-moves More...
 
NonLocalTOperator nonLocalOps
 non local operator More...
 
ParticleSet::ParticlePos PulayTerm
 Pulay force vector. More...
 
std::vector< NonLocalDatatmove_xy_
 
Array< TraceReal, 1 > * Ve_sample
 single particle trace samples More...
 
Array< TraceReal, 1 > * Vi_sample
 
std::vector< std::vector< NLPPJob< Real > > > nlpp_jobs
 NLPP job list of ion-electron pairs by spin group. More...
 
ResourceHandle< NonLocalECPotentialMultiWalkerResourcemw_res_handle_
 mult walker shared resource More...
 

Friends

class testing::TestNonLocalECPotential
 

Additional Inherited Members

- 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 Types inherited from ForceBase
using Real = QMCTraits::RealType
 cheat, need to use virtual inheriance to clean up More...
 
- Protected Member Functions inherited from OperatorBase
virtual void contributeScalarQuantities ()
 
virtual void checkoutScalarQuantities (TraceManager &tm)
 
virtual void collectScalarQuantities ()
 
virtual void deleteScalarQuantities ()
 
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...
 

Member Typedef Documentation

◆ Real

using Real = QMCTraits::RealType
private

Definition at line 41 of file NonLocalECPotential.h.

Constructor & Destructor Documentation

◆ NonLocalECPotential()

NonLocalECPotential ( ParticleSet ions,
ParticleSet els,
TrialWaveFunction psi,
bool  computeForces,
bool  enable_DLA 
)

constructor

Parameters
ionsthe positions of the ions
elsthe positions of the electrons
psitrial wavefunction

Definition at line 54 of file NonLocalECPotential.cpp.

References ParticleSet::addTable(), ParticleSet::getSpeciesSet(), SpeciesSet::getTotalNum(), ParticleSet::getTotalNum(), ParticleSet::groups(), ParticleSet::groupsize(), NonLocalECPotential::IonConfig, NonLocalECPotential::myTableIndex, NonLocalECPotential::nlpp_jobs, OperatorBase::NONLOCAL, NonLocalECPotential::NumIons, OperatorBase::POTENTIAL, NonLocalECPotential::PP, NonLocalECPotential::PPset, ForceBase::prefix_, NonLocalECPotential::PulayTerm, Vector< T, Alloc >::resize(), OperatorBase::setEnergyDomain(), OperatorBase::twoBodyQuantumDomain(), and OperatorBase::update_mode_.

59  : ForceBase(ions, els),
60  myRNG(nullptr),
61  IonConfig(ions),
62  Psi(psi),
63  ComputeForces(computeForces),
64  use_DLA(enable_DLA),
65  Peln(els),
66  ElecNeighborIons(els),
67  IonNeighborElecs(ions),
69 {
71  twoBodyQuantumDomain(ions, els);
72  myTableIndex = els.addTable(ions);
73  NumIons = ions.getTotalNum();
74  //els.resizeSphere(NumIons);
75  PP.resize(NumIons, nullptr);
76  prefix_ = "FNL";
79  update_mode_.set(NONLOCAL, 1);
80  nlpp_jobs.resize(els.groups());
81  for (size_t ig = 0; ig < els.groups(); ig++)
82  {
83  // this should be enough in most calculations assuming that every electron cannot be in more than two pseudo regions.
84  nlpp_jobs[ig].reserve(2 * els.groupsize(ig));
85  }
86 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
void twoBodyQuantumDomain(const ParticleSet &P)
set quantum domain for two-body operator
ParticleSet & IonConfig
reference to the center ion
std::vector< NonLocalECPComponent * > PP
the set of local-potentials (one for each ion)
int myTableIndex
index of distance table for the ion-el pair
bool ComputeForces
true if we should compute forces
ForceBase(ParticleSet &ions, ParticleSet &elns)
Definition: ForceBase.cpp:28
std::string prefix_
Definition: ForceBase.h:96
int getTotalNum() const
return the number of species
Definition: SpeciesSet.h:55
ParticleSet & Peln
reference to the electrons
RandomBase< FullPrecRealType > * myRNG
random number generator
void setEnergyDomain(EnergyDomains edomain)
Set the Energy Domain.
NeighborLists IonNeighborElecs
neighborlist of ions
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
bool use_DLA
true, determinant localization approximation(DLA) is enabled
NeighborLists ElecNeighborIons
neighborlist of electrons
std::vector< std::vector< NLPPJob< Real > > > nlpp_jobs
NLPP job list of ion-electron pairs by spin group.
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
unique NonLocalECPComponent to remove
ParticleSet::ParticlePos PulayTerm
Pulay force vector.
TrialWaveFunction & Psi
target TrialWaveFunction
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521

◆ ~NonLocalECPotential()

~NonLocalECPotential ( )
overridedefault

Member Function Documentation

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
overridevirtual

acquire a shared resource from a collection

Reimplemented from OperatorBase.

Definition at line 780 of file NonLocalECPotential.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), ResourceCollection::lendResource(), and NonLocalECPotential::mw_res_handle_.

782 {
783  auto& O_leader = o_list.getCastedLeader<NonLocalECPotential>();
784  O_leader.mw_res_handle_ = collection.lendResource<NonLocalECPotentialMultiWalkerResource>();
785 }
NonLocalECPotential(ParticleSet &ions, ParticleSet &els, TrialWaveFunction &psi, bool computeForces, bool enable_DLA)
constructor

◆ addComponent()

void addComponent ( int  groupID,
std::unique_ptr< NonLocalECPComponent > &&  pp 
)

Definition at line 759 of file NonLocalECPotential.cpp.

References ParticleSet::GroupID, NonLocalECPotential::IonConfig, NonLocalECPotential::PP, and NonLocalECPotential::PPset.

Referenced by qmcplusplus::TEST_CASE().

760 {
761  for (int iat = 0; iat < PP.size(); iat++)
762  if (IonConfig.GroupID[iat] == groupID)
763  PP[iat] = ppot.get();
764  PPset[groupID] = std::move(ppot);
765 }
ParticleSet & IonConfig
reference to the center ion
std::vector< NonLocalECPComponent * > PP
the set of local-potentials (one for each ion)
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
unique NonLocalECPComponent to remove

◆ 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 805 of file NonLocalECPotential.cpp.

References RecordNamedProperty< T >::add(), OperatorBase::addValue(), NonLocalECPotential::ComputeForces, ForceBase::first_force_index_, ForceBase::n_nuc_, OHMMS_DIM, and RecordNamedProperty< T >::size().

806 {
807  OperatorBase::addValue(plist);
808  if (ComputeForces)
809  {
810  if (first_force_index_ < 0)
811  first_force_index_ = plist.size();
812  for (int iat = 0; iat < n_nuc_; iat++)
813  {
814  for (int x = 0; x < OHMMS_DIM; x++)
815  {
816  std::ostringstream obsName1, obsName2;
817  obsName1 << "FNL"
818  << "_" << iat << "_" << x;
819  plist.add(obsName1.str());
820  // obsName2 << "FNL_Pulay" << "_" << iat << "_" << x;
821  // plist.add(obsName2.str());
822  }
823  }
824  }
825 }
bool ComputeForces
true if we should compute forces
#define OHMMS_DIM
Definition: config.h:64
void addValue(PropertySetType &plist)
named values to the property list

◆ checkoutParticleQuantities()

void checkoutParticleQuantities ( TraceManager tm)
overridevirtual

Reimplemented from OperatorBase.

Definition at line 93 of file NonLocalECPotential.cpp.

References TraceManager::checkout_real(), NonLocalECPotential::IonConfig, OperatorBase::name_, NonLocalECPotential::Peln, OperatorBase::request_, TraceRequest::streaming_array(), OperatorBase::streaming_particles_, NonLocalECPotential::Ve_sample, and NonLocalECPotential::Vi_sample.

94 {
97  {
98  Ve_sample = tm.checkout_real<1>(name_, Peln);
99  Vi_sample = tm.checkout_real<1>(name_, IonConfig);
100  }
101 }
bool streaming_array(const std::string &name)
Definition: TraceManager.h:249
ParticleSet & IonConfig
reference to the center ion
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
Array< TraceReal, 1 > * Ve_sample
single particle trace samples
std::string name_
name of this object
Definition: OperatorBase.h:527
ParticleSet & Peln
reference to the electrons

◆ computeOneElectronTxy()

void computeOneElectronTxy ( ParticleSet P,
const int  ref_elec 
)
private

compute the T move transition probability for a given electron member variable nonLocalOps.Txy is updated

Parameters
Pparticle set
ref_elecreference electron id

Definition at line 537 of file NonLocalECPotential.cpp.

References NonLocalECPotential::ElecNeighborIons, ParticleSet::getDistTableAB(), NeighborLists::getNeighborList(), NonLocalECPotential::myTableIndex, NonLocalECPotential::PP, NonLocalECPotential::Psi, NonLocalECPotential::tmove_xy_, and NonLocalECPotential::use_DLA.

Referenced by NonLocalECPotential::makeNonLocalMovesPbyP().

538 {
539  tmove_xy_.clear();
540  const auto& myTable = P.getDistTableAB(myTableIndex);
541  const std::vector<int>& NeighborIons = ElecNeighborIons.getNeighborList(ref_elec);
542 
543  const auto& dist = myTable.getDistRow(ref_elec);
544  const auto& displ = myTable.getDisplRow(ref_elec);
545  for (int atom_index = 0; atom_index < NeighborIons.size(); atom_index++)
546  {
547  const int iat = NeighborIons[atom_index];
548  PP[iat]->evaluateOne(P, iat, Psi, ref_elec, dist[iat], -displ[iat], use_DLA);
549  PP[iat]->contributeTxy(ref_elec, tmove_xy_);
550  }
551 }
std::vector< NonLocalData > tmove_xy_
std::vector< NonLocalECPComponent * > PP
the set of local-potentials (one for each ion)
int myTableIndex
index of distance table for the ion-el pair
bool use_DLA
true, determinant localization approximation(DLA) is enabled
NeighborLists ElecNeighborIons
neighborlist of electrons
std::vector< int > & getNeighborList(int source)
get the neighbor list of the source particle
Definition: NeighborLists.h:32
TrialWaveFunction & Psi
target TrialWaveFunction

◆ contributeParticleQuantities()

void contributeParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 91 of file NonLocalECPotential.cpp.

References TraceRequest::contribute_array(), OperatorBase::name_, and OperatorBase::request_.

TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
std::string name_
name of this object
Definition: OperatorBase.h:527
void contribute_array(const std::string &name, bool default_quantity=false)
Definition: TraceManager.h:198

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from OperatorBase.

Definition at line 767 of file NonLocalECPotential.cpp.

References ResourceCollection::addResource(), and NonLocalECPotential::PPset.

Referenced by qmcplusplus::TEST_CASE().

768 {
769  auto new_res = std::make_unique<NonLocalECPotentialMultiWalkerResource>();
770  for (int ig = 0; ig < PPset.size(); ++ig)
771  if (PPset[ig] && PPset[ig]->getVP()) // H pp doesn't contain non-local channels and PPset[ig] can be nullptr
772  {
773  PPset[ig]->getVP()->createResource(new_res->collection);
774  // the VP of the first NonLocalECPComponent is responsible for creating the shared resource.
775  break;
776  }
777  auto resource_index = collection.addResource(std::move(new_res));
778 }
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
unique NonLocalECPComponent to remove

◆ deleteParticleQuantities()

void deleteParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 103 of file NonLocalECPotential.cpp.

References OperatorBase::streaming_particles_, NonLocalECPotential::Ve_sample, and NonLocalECPotential::Vi_sample.

104 {
106  {
107  delete Ve_sample;
108  delete Vi_sample;
109  }
110 }
Array< TraceReal, 1 > * Ve_sample
single particle trace samples

◆ dependsOnWaveFunction()

bool dependsOnWaveFunction ( ) const
inlineoverridevirtual

return true if this operator depends on a wavefunction

Reimplemented from OperatorBase.

Definition at line 49 of file NonLocalECPotential.h.

49 { return true; }

◆ evalIonDerivsImpl()

void evalIonDerivsImpl ( ParticleSet P,
ParticleSet ions,
TrialWaveFunction psi,
ParticleSet::ParticlePos hf_terms,
ParticleSet::ParticlePos pulay_terms,
bool  keepGrid = false 
)
private

Definition at line 461 of file NonLocalECPotential.cpp.

References NonLocalECPotential::ElecNeighborIons, ParticleSet::first(), ForceBase::forces_, qmcplusplus::generateRandomRotationMatrix(), ParticleSet::getDistTableAB(), NeighborLists::getNeighborList(), ParticleSet::getTotalNum(), ParticleSet::groups(), NonLocalECPotential::IonNeighborElecs, ParticleSet::last(), NonLocalECPotential::myRNG, NonLocalECPotential::myTableIndex, NonLocalECPotential::NumIons, NonLocalECPotential::PP, NonLocalECPotential::PPset, TrialWaveFunction::prepareGroup(), NonLocalECPotential::Psi, NonLocalECPotential::PulayTerm, NonLocalECPotential::tmove_xy_, and OperatorBase::value_.

Referenced by NonLocalECPotential::evaluateWithIonDerivs(), and NonLocalECPotential::evaluateWithIonDerivsDeterministic().

467 {
468  //We're going to ignore psi and use the internal Psi.
469  //
470  //Dummy vector for now. Tmoves not implemented
471  bool Tmove = false;
472 
473  forces_ = 0;
474  PulayTerm = 0;
475 
476  value_ = 0.0;
477  if (!keepGrid)
478  {
479  for (int ipp = 0; ipp < PPset.size(); ipp++)
480  if (PPset[ipp])
481  PPset[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*myRNG));
482  }
483  //loop over all the ions
484  const auto& myTable = P.getDistTableAB(myTableIndex);
485  // clear all the electron and ion neighbor lists
486  for (int iat = 0; iat < NumIons; iat++)
487  IonNeighborElecs.getNeighborList(iat).clear();
488  for (int jel = 0; jel < P.getTotalNum(); jel++)
489  ElecNeighborIons.getNeighborList(jel).clear();
490 
491  for (int ig = 0; ig < P.groups(); ++ig) //loop over species
492  {
493  Psi.prepareGroup(P, ig);
494  for (int jel = P.first(ig); jel < P.last(ig); ++jel)
495  {
496  const auto& dist = myTable.getDistRow(jel);
497  const auto& displ = myTable.getDisplRow(jel);
498  std::vector<int>& NeighborIons = ElecNeighborIons.getNeighborList(jel);
499  for (int iat = 0; iat < NumIons; iat++)
500  if (PP[iat] != nullptr && dist[iat] < PP[iat]->getRmax())
501  {
502  value_ +=
503  PP[iat]->evaluateOneWithForces(P, ions, iat, Psi, jel, dist[iat], -displ[iat], forces_[iat], PulayTerm);
504  if (Tmove)
505  PP[iat]->contributeTxy(jel, tmove_xy_);
506  NeighborIons.push_back(iat);
507  IonNeighborElecs.getNeighborList(iat).push_back(jel);
508  }
509  }
510  }
511 
512  hf_terms -= forces_;
513  pulay_terms -= PulayTerm;
514 }
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
std::vector< NonLocalData > tmove_xy_
std::vector< NonLocalECPComponent * > PP
the set of local-potentials (one for each ion)
int myTableIndex
index of distance table for the ion-el pair
RandomBase< FullPrecRealType > * myRNG
random number generator
NeighborLists IonNeighborElecs
neighborlist of ions
QMCTraits::TensorType generateRandomRotationMatrix(RandomBase< QMCTraits::FullPrecRealType > &rng)
Create a random 3D rotation matrix using a random generator.
NeighborLists ElecNeighborIons
neighborlist of electrons
Return_t value_
current value
Definition: OperatorBase.h:524
std::vector< int > & getNeighborList(int source)
get the neighbor list of the source particle
Definition: NeighborLists.h:32
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
unique NonLocalECPComponent to remove
ParticleSet::ParticlePos PulayTerm
Pulay force vector.
void prepareGroup(ParticleSet &P, int ig)
Prepare internal data for updating WFC correspond to a particle group Particle groups usually corresp...
TrialWaveFunction & Psi
target TrialWaveFunction

◆ evaluate()

NonLocalECPotential::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 113 of file NonLocalECPotential.cpp.

References NonLocalECPotential::evaluateImpl(), and OperatorBase::value_.

114 {
115  evaluateImpl(P, false);
116  return value_;
117 }
void evaluateImpl(ParticleSet &P, bool Tmove, bool keepGrid=false)
the actual implementation, used by evaluate and evaluateWithToperator
Return_t value_
current value
Definition: OperatorBase.h:524

◆ evaluateDeterministic()

NonLocalECPotential::Return_t evaluateDeterministic ( ParticleSet P)
overridevirtual

Evaluate the local energy contribution of this component, deterministically based on current state.

The correct behavior of this routine requires estimators with non-deterministic components in their evaluate() function to override this function.

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

Reimplemented from OperatorBase.

Definition at line 119 of file NonLocalECPotential.cpp.

References NonLocalECPotential::evaluateImpl(), and OperatorBase::value_.

120 {
121  evaluateImpl(P, false, true);
122  return value_;
123 }
void evaluateImpl(ParticleSet &P, bool Tmove, bool keepGrid=false)
the actual implementation, used by evaluate and evaluateWithToperator
Return_t value_
current value
Definition: OperatorBase.h:524

◆ evaluateImpl()

void evaluateImpl ( ParticleSet P,
bool  Tmove,
bool  keepGrid = false 
)
private

the actual implementation, used by evaluate and evaluateWithToperator

Parameters
Pparticle set
Tmovewhether Txy for Tmove is updated
keepGrid.If true, does not randomize the quadrature grid before evaluation.

Definition at line 175 of file NonLocalECPotential.cpp.

References qmcplusplus::abs(), APP_ABORT, qmcplusplus::app_log(), NonLocalECPotential::ComputeForces, NonLocalECPotential::ElecNeighborIons, ParticleSet::first(), ForceBase::forces_, qmcplusplus::generateRandomRotationMatrix(), ParticleSet::getDistTableAB(), NeighborLists::getNeighborList(), ParticleSet::getTotalNum(), ParticleSet::groups(), NonLocalECPotential::IonNeighborElecs, ParticleSet::last(), NonLocalECPotential::myRNG, NonLocalECPotential::myTableIndex, NonLocalECPotential::NumIons, NonLocalECPotential::PP, NonLocalECPotential::PPset, TrialWaveFunction::prepareGroup(), NonLocalECPotential::Psi, OperatorBase::streaming_particles_, Array< T, D, ALLOC >::sum(), NonLocalECPotential::tmove_xy_, TraceManager::trace_tol, NonLocalECPotential::use_DLA, OperatorBase::value_, NonLocalECPotential::Ve_sample, and NonLocalECPotential::Vi_sample.

Referenced by NonLocalECPotential::evaluate(), NonLocalECPotential::evaluateDeterministic(), and NonLocalECPotential::evaluateWithToperator().

176 {
177  if (Tmove)
178  tmove_xy_.clear();
179 
180  value_ = 0.0;
181 #if !defined(REMOVE_TRACEMANAGER)
182  auto& Ve_samp = *Ve_sample;
183  auto& Vi_samp = *Vi_sample;
185  {
186  Ve_samp = 0.0;
187  Vi_samp = 0.0;
188  }
189 #endif
190  for (int ipp = 0; ipp < PPset.size(); ipp++)
191  if (PPset[ipp])
192  if (!keep_grid)
193  PPset[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*myRNG));
194 
195  //loop over all the ions
196  const auto& myTable = P.getDistTableAB(myTableIndex);
197  // clear all the electron and ion neighbor lists
198  for (int iat = 0; iat < NumIons; iat++)
199  IonNeighborElecs.getNeighborList(iat).clear();
200  for (int jel = 0; jel < P.getTotalNum(); jel++)
201  ElecNeighborIons.getNeighborList(jel).clear();
202 
203  if (ComputeForces)
204  {
205  forces_ = 0;
206  for (int ig = 0; ig < P.groups(); ++ig) //loop over species
207  {
208  Psi.prepareGroup(P, ig);
209  for (int jel = P.first(ig); jel < P.last(ig); ++jel)
210  {
211  const auto& dist = myTable.getDistRow(jel);
212  const auto& displ = myTable.getDisplRow(jel);
213  std::vector<int>& NeighborIons = ElecNeighborIons.getNeighborList(jel);
214  for (int iat = 0; iat < NumIons; iat++)
215  if (PP[iat] != nullptr && dist[iat] < PP[iat]->getRmax())
216  {
217  Real pairpot = PP[iat]->evaluateOneWithForces(P, iat, Psi, jel, dist[iat], -displ[iat], forces_[iat]);
218  if (Tmove)
219  PP[iat]->contributeTxy(jel, tmove_xy_);
220  value_ += pairpot;
221  NeighborIons.push_back(iat);
222  IonNeighborElecs.getNeighborList(iat).push_back(jel);
223  }
224  }
225  }
226  }
227  else
228  {
229  for (int ig = 0; ig < P.groups(); ++ig) //loop over species
230  {
231  Psi.prepareGroup(P, ig);
232  for (int jel = P.first(ig); jel < P.last(ig); ++jel)
233  {
234  const auto& dist = myTable.getDistRow(jel);
235  const auto& displ = myTable.getDisplRow(jel);
236  std::vector<int>& NeighborIons = ElecNeighborIons.getNeighborList(jel);
237  for (int iat = 0; iat < NumIons; iat++)
238  if (PP[iat] != nullptr && dist[iat] < PP[iat]->getRmax())
239  {
240  Real pairpot = PP[iat]->evaluateOne(P, iat, Psi, jel, dist[iat], -displ[iat], use_DLA);
241  if (Tmove)
242  PP[iat]->contributeTxy(jel, tmove_xy_);
243 
244  value_ += pairpot;
245  NeighborIons.push_back(iat);
246  IonNeighborElecs.getNeighborList(iat).push_back(jel);
247 
249  {
250  Ve_samp(jel) += 0.5 * pairpot;
251  Vi_samp(iat) += 0.5 * pairpot;
252  }
253  }
254  }
255  }
256  }
257 
258 #if !defined(TRACE_CHECK)
260  {
261  Return_t Vnow = value_;
262  Real Visum = Vi_sample->sum();
263  Real Vesum = Ve_sample->sum();
264  Real Vsum = Vesum + Visum;
265  if (std::abs(Vsum - Vnow) > TraceManager::trace_tol)
266  {
267  app_log() << "accumtest: NonLocalECPotential::evaluate()" << std::endl;
268  app_log() << "accumtest: tot:" << Vnow << std::endl;
269  app_log() << "accumtest: sum:" << Vsum << std::endl;
270  APP_ABORT("Trace check failed");
271  }
272  if (std::abs(Vesum - Visum) > TraceManager::trace_tol)
273  {
274  app_log() << "sharetest: NonLocalECPotential::evaluate()" << std::endl;
275  app_log() << "sharetest: e share:" << Vesum << std::endl;
276  app_log() << "sharetest: i share:" << Visum << std::endl;
277  APP_ABORT("Trace check failed");
278  }
279  }
280 #endif
281 }
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
std::vector< NonLocalData > tmove_xy_
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< NonLocalECPComponent * > PP
the set of local-potentials (one for each ion)
int myTableIndex
index of distance table for the ion-el pair
bool ComputeForces
true if we should compute forces
Array< TraceReal, 1 > * Ve_sample
single particle trace samples
RandomBase< FullPrecRealType > * myRNG
random number generator
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
NeighborLists IonNeighborElecs
neighborlist of ions
QMCTraits::TensorType generateRandomRotationMatrix(RandomBase< QMCTraits::FullPrecRealType > &rng)
Create a random 3D rotation matrix using a random generator.
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
Type_t sum() const
Definition: OhmmsArray.h:214
bool use_DLA
true, determinant localization approximation(DLA) is enabled
NeighborLists ElecNeighborIons
neighborlist of electrons
Return_t value_
current value
Definition: OperatorBase.h:524
std::vector< int > & getNeighborList(int source)
get the neighbor list of the source particle
Definition: NeighborLists.h:32
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
unique NonLocalECPComponent to remove
void prepareGroup(ParticleSet &P, int ig)
Prepare internal data for updating WFC correspond to a particle group Particle groups usually corresp...
TrialWaveFunction & Psi
target TrialWaveFunction

◆ evaluateOneBodyOpMatrix()

void evaluateOneBodyOpMatrix ( ParticleSet P,
const TWFFastDerivWrapper psi,
std::vector< ValueMatrix > &  B 
)
overridevirtual

Evaluate "B" matrix for observable.

Filippi scheme for computing fast derivatives.

Parameters
[in]Ptarget particle set (electrons)
[in]psi,TrialWavefunction wrapper for fast derivatives.
[in,out]B.List of B matrices for each species.
Returns
Void

Reimplemented from OperatorBase.

Definition at line 553 of file NonLocalECPotential.cpp.

References B(), NonLocalECPotential::ElecNeighborIons, ParticleSet::first(), qmcplusplus::generateRandomRotationMatrix(), ParticleSet::getDistTableAB(), NeighborLists::getNeighborList(), ParticleSet::getTotalNum(), ParticleSet::groups(), NonLocalECPotential::IonNeighborElecs, ParticleSet::last(), NonLocalECPotential::myRNG, NonLocalECPotential::myTableIndex, NonLocalECPotential::NumIons, NonLocalECPotential::PP, and NonLocalECPotential::PPset.

556 {
557  bool keepGrid = true;
558  for (int ipp = 0; ipp < PPset.size(); ipp++)
559  if (PPset[ipp])
560  if (!keepGrid)
561  PPset[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*myRNG));
562 
563  //loop over all the ions
564  const auto& myTable = P.getDistTableAB(myTableIndex);
565  // clear all the electron and ion neighbor lists
566  for (int iat = 0; iat < NumIons; iat++)
567  IonNeighborElecs.getNeighborList(iat).clear();
568  for (int jel = 0; jel < P.getTotalNum(); jel++)
569  ElecNeighborIons.getNeighborList(jel).clear();
570 
571  for (int ig = 0; ig < P.groups(); ++ig) //loop over species
572  {
573  for (int jel = P.first(ig); jel < P.last(ig); ++jel)
574  {
575  const auto& dist = myTable.getDistRow(jel);
576  const auto& displ = myTable.getDisplRow(jel);
577  auto& NeighborIons = ElecNeighborIons.getNeighborList(jel);
578  for (int iat = 0; iat < NumIons; iat++)
579  if (PP[iat] != nullptr && dist[iat] < PP[iat]->getRmax())
580  {
581  PP[iat]->evaluateOneBodyOpMatrixContribution(P, iat, psi, jel, dist[iat], -displ[iat], B);
582  NeighborIons.push_back(iat);
583  IonNeighborElecs.getNeighborList(iat).push_back(jel);
584  }
585  }
586  }
587 }
std::vector< NonLocalECPComponent * > PP
the set of local-potentials (one for each ion)
int myTableIndex
index of distance table for the ion-el pair
RandomBase< FullPrecRealType > * myRNG
random number generator
NeighborLists IonNeighborElecs
neighborlist of ions
QMCTraits::TensorType generateRandomRotationMatrix(RandomBase< QMCTraits::FullPrecRealType > &rng)
Create a random 3D rotation matrix using a random generator.
NeighborLists ElecNeighborIons
neighborlist of electrons
std::vector< int > & getNeighborList(int source)
get the neighbor list of the source particle
Definition: NeighborLists.h:32
double B(double x, int k, int i, const std::vector< double > &t)
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
unique NonLocalECPComponent to remove

◆ evaluateOneBodyOpMatrixForceDeriv()

void evaluateOneBodyOpMatrixForceDeriv ( ParticleSet P,
ParticleSet source,
const TWFFastDerivWrapper psi,
const int  iat,
std::vector< std::vector< ValueMatrix >> &  Bforce 
)
overridevirtual

Evaluate "dB/dR" matrices for observable.

Filippi scheme for computing fast derivatives.

Parameters
[in]P,targetparticle set (electrons)
[in]source,ionparticle set
[in]psi,TrialWavefunction wrapper for fast derivatives.
[in]iat

Reimplemented from OperatorBase.

Definition at line 589 of file NonLocalECPotential.cpp.

References NonLocalECPotential::ElecNeighborIons, ParticleSet::first(), qmcplusplus::generateRandomRotationMatrix(), ParticleSet::getDistTableAB(), NeighborLists::getNeighborList(), ParticleSet::getTotalNum(), ParticleSet::groups(), NonLocalECPotential::IonNeighborElecs, ParticleSet::last(), NonLocalECPotential::myRNG, NonLocalECPotential::myTableIndex, NonLocalECPotential::NumIons, NonLocalECPotential::PP, and NonLocalECPotential::PPset.

594 {
595  bool keepGrid = true;
596  for (int ipp = 0; ipp < PPset.size(); ipp++)
597  if (PPset[ipp])
598  if (!keepGrid)
599  PPset[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*myRNG));
600 
601  //loop over all the ions
602  const auto& myTable = P.getDistTableAB(myTableIndex);
603  // clear all the electron and ion neighbor lists
604  for (int iat = 0; iat < NumIons; iat++)
605  IonNeighborElecs.getNeighborList(iat).clear();
606  for (int jel = 0; jel < P.getTotalNum(); jel++)
607  ElecNeighborIons.getNeighborList(jel).clear();
608 
609  for (int ig = 0; ig < P.groups(); ++ig) //loop over species
610  {
611  for (int jel = P.first(ig); jel < P.last(ig); ++jel)
612  {
613  const auto& dist = myTable.getDistRow(jel);
614  const auto& displ = myTable.getDisplRow(jel);
615  auto& NeighborIons = ElecNeighborIons.getNeighborList(jel);
616  for (int iat = 0; iat < NumIons; iat++)
617  if (PP[iat] != nullptr && dist[iat] < PP[iat]->getRmax())
618  {
619  PP[iat]->evaluateOneBodyOpMatrixdRContribution(P, source, iat, iat_source, psi, jel, dist[iat], -displ[iat],
620  Bforce);
621  NeighborIons.push_back(iat);
622  IonNeighborElecs.getNeighborList(iat).push_back(jel);
623  }
624  }
625  }
626 }
std::vector< NonLocalECPComponent * > PP
the set of local-potentials (one for each ion)
int myTableIndex
index of distance table for the ion-el pair
RandomBase< FullPrecRealType > * myRNG
random number generator
NeighborLists IonNeighborElecs
neighborlist of ions
QMCTraits::TensorType generateRandomRotationMatrix(RandomBase< QMCTraits::FullPrecRealType > &rng)
Create a random 3D rotation matrix using a random generator.
NeighborLists ElecNeighborIons
neighborlist of electrons
std::vector< int > & getNeighborList(int source)
get the neighbor list of the source particle
Definition: NeighborLists.h:32
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
unique NonLocalECPComponent to remove

◆ evaluateValueAndDerivatives()

NonLocalECPotential::Return_t evaluateValueAndDerivatives ( ParticleSet P,
const opt_variables_type optvars,
const Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
override

Definition at line 22 of file NonLocalECPotential.deriv.cpp.

References qmcplusplus::generateRandomRotationMatrix(), DistanceTableAB::getDistRow(), ParticleSet::getDistTableAB(), ParticleSet::getTotalNum(), NonLocalECPotential::myRNG, NonLocalECPotential::myTableIndex, NonLocalECPotential::NumIons, NonLocalECPotential::PP, NonLocalECPotential::PPset, NonLocalECPotential::Psi, and OperatorBase::value_.

26 {
27  value_ = 0.0;
28  for (int ipp = 0; ipp < PPset.size(); ipp++)
29  if (PPset[ipp])
30  PPset[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*myRNG));
31 
32  /* evaluating TWF ratio values requires calling prepareGroup
33  * In evaluate() we first loop over species and call prepareGroup before looping over all the electrons of a species
34  * Here it is not necessary because TWF::evaluateLog has been called and precomputed data is up-to-date
35  */
36  const auto& myTable = P.getDistTableAB(myTableIndex);
37  for (int jel = 0; jel < P.getTotalNum(); jel++)
38  {
39  const auto& dist = myTable.getDistRow(jel);
40  const auto& displ = myTable.getDisplRow(jel);
41  for (int iat = 0; iat < NumIons; iat++)
42  if (PP[iat] != nullptr && dist[iat] < PP[iat]->getRmax())
43  value_ += PP[iat]->evaluateValueAndDerivatives(P, iat, Psi, jel, dist[iat], -displ[iat], optvars, dlogpsi,
44  dhpsioverpsi);
45  }
46  return value_;
47 }
std::vector< NonLocalECPComponent * > PP
the set of local-potentials (one for each ion)
int myTableIndex
index of distance table for the ion-el pair
RandomBase< FullPrecRealType > * myRNG
random number generator
QMCTraits::TensorType generateRandomRotationMatrix(RandomBase< QMCTraits::FullPrecRealType > &rng)
Create a random 3D rotation matrix using a random generator.
Return_t value_
current value
Definition: OperatorBase.h:524
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
unique NonLocalECPComponent to remove
TrialWaveFunction & Psi
target TrialWaveFunction

◆ evaluateWithIonDerivs()

NonLocalECPotential::Return_t evaluateWithIonDerivs ( ParticleSet P,
ParticleSet ions,
TrialWaveFunction psi,
ParticleSet::ParticlePos hf_term,
ParticleSet::ParticlePos pulay_term 
)
overridevirtual

Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase.

Parameters
Ptarget particle set (electrons)
ionssource particle set (ions)
psiTrial wave function
hf_termsAdds OperatorBase's contribution to Re [(dH)Psi]/Psi
pulay_termsAdds OperatorBase's contribution to Re [(H-E_L)dPsi]/Psi
Returns
Contribution of OperatorBase to Local Energy.

Reimplemented from OperatorBase.

Definition at line 516 of file NonLocalECPotential.cpp.

References NonLocalECPotential::evalIonDerivsImpl(), and OperatorBase::value_.

521 {
522  evalIonDerivsImpl(P, ions, psi, hf_terms, pulay_terms);
523  return value_;
524 }
Return_t value_
current value
Definition: OperatorBase.h:524
void evalIonDerivsImpl(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms, bool keepGrid=false)

◆ evaluateWithIonDerivsDeterministic()

NonLocalECPotential::Return_t evaluateWithIonDerivsDeterministic ( ParticleSet P,
ParticleSet ions,
TrialWaveFunction psi,
ParticleSet::ParticlePos hf_term,
ParticleSet::ParticlePos pulay_term 
)
overridevirtual

Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase.

If there's no stochastic component, defaults to evaluateWithIonDerivs. If not otherwise specified, this defaults to evaluate().

Parameters
Ptarget particle set (electrons)
ionssource particle set (ions)
psiTrial wave function
hf_termsAdds OperatorBase's contribution to Re [(dH)Psi]/Psi
pulay_termsAdds OperatorBase's contribution to Re [(H-E_L)dPsi]/Psi
Returns
Contribution of OperatorBase to Local Energy.

Reimplemented from OperatorBase.

Definition at line 526 of file NonLocalECPotential.cpp.

References NonLocalECPotential::evalIonDerivsImpl(), and OperatorBase::value_.

532 {
533  evalIonDerivsImpl(P, ions, psi, hf_terms, pulay_terms, true);
534  return value_;
535 }
Return_t value_
current value
Definition: OperatorBase.h:524
void evalIonDerivsImpl(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms, bool keepGrid=false)

◆ evaluateWithToperator()

NonLocalECPotential::Return_t evaluateWithToperator ( ParticleSet P)
overridevirtual

Evaluate the local energy contribution of this component with Toperators updated if requested.

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

Reimplemented from OperatorBase.

Definition at line 132 of file NonLocalECPotential.cpp.

References NonLocalECPotential::evaluateImpl(), qmcplusplus::TMOVE_V0, qmcplusplus::TMOVE_V3, NonLocalECPotential::UseTMove, and OperatorBase::value_.

133 {
134  if (UseTMove == TMOVE_V0 || UseTMove == TMOVE_V3)
135  evaluateImpl(P, true);
136  else
137  evaluateImpl(P, false);
138  return value_;
139 }
void evaluateImpl(ParticleSet &P, bool Tmove, bool keepGrid=false)
the actual implementation, used by evaluate and evaluateWithToperator
Return_t value_
current value
Definition: OperatorBase.h:524

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 130 of file NonLocalECPotential.h.

References OhmmsElementBase::getName(), and NonLocalECPotential::IonConfig.

131  {
132  os << "NonLocalECPotential: " << IonConfig.getName();
133  return true;
134  }
const std::string & getName() const
return the name
ParticleSet & IonConfig
reference to the center ion

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 50 of file NonLocalECPotential.h.

50 { return "NonLocalECPotential"; }

◆ makeClone()

std::unique_ptr< OperatorBase > makeClone ( ParticleSet qp,
TrialWaveFunction psi 
)
overridevirtual

Implements OperatorBase.

Definition at line 794 of file NonLocalECPotential.cpp.

References NonLocalECPotential::ComputeForces, NonLocalECPotential::IonConfig, NonLocalECPotential::PPset, and NonLocalECPotential::use_DLA.

Referenced by qmcplusplus::TEST_CASE().

795 {
796  std::unique_ptr<NonLocalECPotential> myclone =
797  std::make_unique<NonLocalECPotential>(IonConfig, qp, psi, ComputeForces, use_DLA);
798  for (int ig = 0; ig < PPset.size(); ++ig)
799  if (PPset[ig])
800  myclone->addComponent(ig, std::make_unique<NonLocalECPComponent>(*PPset[ig], qp));
801  return myclone;
802 }
ParticleSet & IonConfig
reference to the center ion
bool ComputeForces
true if we should compute forces
bool use_DLA
true, determinant localization approximation(DLA) is enabled
std::vector< std::unique_ptr< NonLocalECPComponent > > PPset
unique NonLocalECPComponent to remove

◆ makeNonLocalMovesPbyP()

int makeNonLocalMovesPbyP ( ParticleSet P)

make non local moves with particle-by-particle moves

Parameters
Pparticle set
Returns
the number of accepted moves

Definition at line 627 of file NonLocalECPotential.cpp.

References ParticleSet::acceptMove(), TrialWaveFunction::acceptMove(), TrialWaveFunction::calcRatioGrad(), TrialWaveFunction::completeUpdates(), NonLocalECPotential::computeOneElectronTxy(), NonLocalData::Delta, ParticleSet::donePbyP(), NonLocalECPotential::elecTMAffected, ParticleSet::first(), ParticleSet::getDistTableAB(), ParticleSet::getGroupID(), ParticleSet::getTotalNum(), NonLocalTOperator::groupByElectron(), ParticleSet::groups(), ParticleSet::last(), ParticleSet::makeMoveAndCheck(), NonLocalECPotential::markAffectedElecs(), NonLocalECPotential::myRNG, NonLocalECPotential::myTableIndex, NonLocalECPotential::nonLocalOps, NonLocalData::PID, TrialWaveFunction::prepareGroup(), NonLocalECPotential::Psi, NonLocalTOperator::selectMove(), qmcplusplus::TMOVE_V0, qmcplusplus::TMOVE_V1, qmcplusplus::TMOVE_V3, NonLocalECPotential::tmove_xy_, and NonLocalECPotential::UseTMove.

Referenced by QMCHamiltonian::makeNonLocalMoves(), and QMCHamiltonian::mw_makeNonLocalMoves().

628 {
629  int NonLocalMoveAccepted = 0;
630  auto& RandomGen(*myRNG);
631  if (UseTMove == TMOVE_V0)
632  {
633  const NonLocalData* oneTMove = nonLocalOps.selectMove(RandomGen(), tmove_xy_);
634  //make a non-local move
635  if (oneTMove)
636  {
637  const int iat = oneTMove->PID;
638  Psi.prepareGroup(P, P.getGroupID(iat));
639  GradType grad_iat;
640  if (P.makeMoveAndCheck(iat, oneTMove->Delta) && Psi.calcRatioGrad(P, iat, grad_iat) != ValueType(0))
641  {
642  Psi.acceptMove(P, iat, true);
643  P.acceptMove(iat);
644  NonLocalMoveAccepted++;
645  }
646  }
647  }
648  else if (UseTMove == TMOVE_V1)
649  {
650  GradType grad_iat;
651  //make a non-local move per particle
652  for (int ig = 0; ig < P.groups(); ++ig) //loop over species
653  {
654  Psi.prepareGroup(P, ig);
655  for (int iat = P.first(ig); iat < P.last(ig); ++iat)
656  {
657  computeOneElectronTxy(P, iat);
658  const NonLocalData* oneTMove = nonLocalOps.selectMove(RandomGen(), tmove_xy_);
659  if (oneTMove)
660  {
661  if (P.makeMoveAndCheck(iat, oneTMove->Delta) && Psi.calcRatioGrad(P, iat, grad_iat) != ValueType(0))
662  {
663  Psi.acceptMove(P, iat, true);
664  P.acceptMove(iat);
665  NonLocalMoveAccepted++;
666  }
667  }
668  }
669  }
670  }
671  else if (UseTMove == TMOVE_V3)
672  {
673  elecTMAffected.assign(P.getTotalNum(), false);
674  nonLocalOps.groupByElectron(P.getTotalNum(), tmove_xy_);
675  GradType grad_iat;
676  //make a non-local move per particle
677  for (int ig = 0; ig < P.groups(); ++ig) //loop over species
678  {
679  Psi.prepareGroup(P, ig);
680  for (int iat = P.first(ig); iat < P.last(ig); ++iat)
681  {
682  const NonLocalData* oneTMove;
683  if (elecTMAffected[iat])
684  {
685  // recompute Txy for the given electron effected by Tmoves
686  computeOneElectronTxy(P, iat);
687  oneTMove = nonLocalOps.selectMove(RandomGen(), tmove_xy_);
688  }
689  else
690  oneTMove = nonLocalOps.selectMove(RandomGen(), iat);
691  if (oneTMove)
692  {
693  if (P.makeMoveAndCheck(iat, oneTMove->Delta) && Psi.calcRatioGrad(P, iat, grad_iat) != ValueType(0))
694  {
695  Psi.acceptMove(P, iat, true);
696  // mark all affected electrons
697  markAffectedElecs(P.getDistTableAB(myTableIndex), iat);
698  P.acceptMove(iat);
699  NonLocalMoveAccepted++;
700  }
701  }
702  }
703  }
704  }
705 
706  if (NonLocalMoveAccepted > 0)
707  {
709  // this step also updates electron positions on the device.
710  P.donePbyP(true);
711  }
712 
713  return NonLocalMoveAccepted;
714 }
void groupByElectron(size_t num_elec, const std::vector< NonLocalData > &txy)
sort all the Txy elements by electron
QTBase::GradType GradType
Definition: Configuration.h:62
std::vector< NonLocalData > tmove_xy_
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false)
update the state with the new data
int myTableIndex
index of distance table for the ion-el pair
NonLocalTOperator nonLocalOps
non local operator
QTBase::ValueType ValueType
Definition: Configuration.h:60
void computeOneElectronTxy(ParticleSet &P, const int ref_elec)
compute the T move transition probability for a given electron member variable nonLocalOps.Txy is updated
RandomBase< FullPrecRealType > * myRNG
random number generator
void markAffectedElecs(const DistanceTableAB &myTable, int iel)
mark all the electrons affected by Tmoves and update ElecNeighborIons and IonNeighborElecs ...
std::vector< bool > elecTMAffected
ture if an electron is affected by other electrons moved by T-moves
const NonLocalData * selectMove(RealType prob, const std::vector< NonLocalData > &txy)
select the move for a given probability
void prepareGroup(ParticleSet &P, int ig)
Prepare internal data for updating WFC correspond to a particle group Particle groups usually corresp...
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...
TrialWaveFunction & Psi
target TrialWaveFunction
void completeUpdates()
complete all the delayed or asynchronous operations before leaving the p-by-p move region...

◆ markAffectedElecs()

void markAffectedElecs ( const DistanceTableAB myTable,
int  iel 
)
private

mark all the electrons affected by Tmoves and update ElecNeighborIons and IonNeighborElecs

Parameters
myTableelectron ion distance table
ielreference electron Note this function should be called before acceptMove for a Tmove

Definition at line 716 of file NonLocalECPotential.cpp.

References NonLocalECPotential::ElecNeighborIons, NonLocalECPotential::elecTMAffected, DistanceTableAB::getDistRow(), NeighborLists::getNeighborList(), DistanceTableAB::getTempDists(), NonLocalECPotential::IonNeighborElecs, NonLocalECPotential::NumIons, and NonLocalECPotential::PP.

Referenced by NonLocalECPotential::makeNonLocalMovesPbyP().

717 {
718  std::vector<int>& NeighborIons = ElecNeighborIons.getNeighborList(iel);
719  for (int iat = 0; iat < NumIons; iat++)
720  {
721  if (PP[iat] == nullptr)
722  continue;
723  Real old_distance = 0.0;
724  Real new_distance = 0.0;
725  old_distance = myTable.getDistRow(iel)[iat];
726  new_distance = myTable.getTempDists()[iat];
727  bool moved = false;
728  // move out
729  if (old_distance < PP[iat]->getRmax() && new_distance >= PP[iat]->getRmax())
730  {
731  moved = true;
732  std::vector<int>& NeighborElecs = IonNeighborElecs.getNeighborList(iat);
733  auto iter_at = std::find(NeighborIons.begin(), NeighborIons.end(), iat);
734  auto iter_el = std::find(NeighborElecs.begin(), NeighborElecs.end(), iel);
735  *iter_at = NeighborIons.back();
736  *iter_el = NeighborElecs.back();
737  NeighborIons.pop_back();
738  NeighborElecs.pop_back();
739  elecTMAffected[iel] = true;
740  }
741  // move in
742  if (old_distance >= PP[iat]->getRmax() && new_distance < PP[iat]->getRmax())
743  {
744  moved = true;
745  std::vector<int>& NeighborElecs = IonNeighborElecs.getNeighborList(iat);
746  NeighborElecs.push_back(iel);
747  NeighborIons.push_back(iat);
748  }
749  // move around
750  if (moved || (old_distance < PP[iat]->getRmax() && new_distance < PP[iat]->getRmax()))
751  {
752  std::vector<int>& NeighborElecs = IonNeighborElecs.getNeighborList(iat);
753  for (int jel = 0; jel < NeighborElecs.size(); ++jel)
754  elecTMAffected[NeighborElecs[jel]] = true;
755  }
756  }
757 }
std::vector< NonLocalECPComponent * > PP
the set of local-potentials (one for each ion)
NeighborLists IonNeighborElecs
neighborlist of ions
NeighborLists ElecNeighborIons
neighborlist of electrons
std::vector< bool > elecTMAffected
ture if an electron is affected by other electrons moved by T-moves
std::vector< int > & getNeighborList(int source)
get the neighbor list of the source particle
Definition: NeighborLists.h:32

◆ mw_evaluate()

void mw_evaluate ( const RefVectorWithLeader< OperatorBase > &  o_list,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list 
) const
overridevirtual

Evaluate the contribution of this component of multiple walkers.

Take o_list and p_list update evaluation result variables in o_list? really should reduce vector of local_energies. matching the ordering and size of o list the this can be call for 1 or more QMCHamiltonians

Parameters
o_list
wf_list
p_list

Temporary raw omp pragma for simple thread parallelism ignoring the driver level concurrency

TODO: replace this with a proper abstraction. It should adequately describe the behavior and strictly limit the activation of this level concurrency to when it is intended. It is unlikely to belong in this function.

This implicitly depends on openmp work division logic. Essentially adhoc runtime crowds over which we have given up control of thread/global scope. How many walkers per thread? How to handle their data movement if any of these hamiltonians should be accelerated? We can neither reason about or describe it in C++

As I understand it it should only be required for as long as the AMD openmp offload compliler is incapable of running multiple threads. They should/must fix their compiler before delivery of frontier and it should be removed at that point at latest

If you want 16 threads of 1 walker that should be 16 crowds of 1 not one crowd of 16 with openmp thrown in at hamiltonian level. If this must be different from the other crowd batching. Make this a reasoned about and controlled level of concurency blocking at the driver level.

This is only thread safe only if each walker has a complete set of anything involved in an Operator.evaluate.

Reimplemented from OperatorBase.

Definition at line 125 of file NonLocalECPotential.cpp.

References NonLocalECPotential::mw_evaluateImpl().

128 {
129  mw_evaluateImpl(o_list, wf_list, p_list, false, std::nullopt);
130 }
static void mw_evaluateImpl(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, bool Tmove, std::optional< ListenerOption< Real >> listeners, bool keepGrid=false)
the actual implementation for batched walkers, used by mw_evaluate, mw_evaluateWithToperator mw_evalu...

◆ mw_evaluateImpl()

void mw_evaluateImpl ( const RefVectorWithLeader< OperatorBase > &  o_list,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
bool  Tmove,
std::optional< ListenerOption< Real >>  listeners,
bool  keepGrid = false 
)
staticprotected

the actual implementation for batched walkers, used by mw_evaluate, mw_evaluateWithToperator mw_evaluatePerPaticleWithToperator

Parameters
o_listthe list of NonLocalECPotential in a walker batch
wf_listthe list of TrialWaveFunction in a walker batch
p_listthe list of ParticleSet in a walker batch
Tmovewhether Txy for Tmove is updated
listenersoptional listeners which allow per particle and reduced to share impl

Definition at line 283 of file NonLocalECPotential.cpp.

References qmcplusplus::abs(), APP_ABORT, qmcplusplus::Units::charge::e, qmcplusplus::generateRandomRotationMatrix(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), NonLocalECPComponent::mw_evaluateOne(), TrialWaveFunction::mw_prepareGroup(), NonLocalECPotential::nlpp_jobs, NonLocalECPotential::Psi, ListenerVector< T >::report, and NonLocalECPotential::tmove_xy_.

Referenced by NonLocalECPotential::mw_evaluate(), TestNonLocalECPotential::mw_evaluateImpl(), NonLocalECPotential::mw_evaluatePerParticle(), NonLocalECPotential::mw_evaluatePerParticleWithToperator(), and NonLocalECPotential::mw_evaluateWithToperator().

289 {
290  auto& O_leader = o_list.getCastedLeader<NonLocalECPotential>();
291  ParticleSet& pset_leader = p_list.getLeader();
292  const size_t nw = o_list.size();
293 
294  if (O_leader.ComputeForces)
295  APP_ABORT("NonLocalECPotential::mw_evaluateImpl(): Forces not imlpemented\n");
296 
297  for (size_t iw = 0; iw < nw; iw++)
298  {
299  auto& O = o_list.getCastedElement<NonLocalECPotential>(iw);
300  const ParticleSet& P(p_list[iw]);
301 
302  if (Tmove)
303  O.tmove_xy_.clear();
304 
305  if (!keep_grid)
306  for (int ipp = 0; ipp < O.PPset.size(); ipp++)
307  if (O.PPset[ipp])
308  O.PPset[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*O.myRNG));
309 
310  //loop over all the ions
311  const auto& myTable = P.getDistTableAB(O.myTableIndex);
312  // clear all the electron and ion neighbor lists
313  for (int iat = 0; iat < O.NumIons; iat++)
314  O.IonNeighborElecs.getNeighborList(iat).clear();
315  for (int jel = 0; jel < P.getTotalNum(); jel++)
316  O.ElecNeighborIons.getNeighborList(jel).clear();
317 
318  for (int ig = 0; ig < P.groups(); ++ig) //loop over species
319  {
320  auto& joblist = O.nlpp_jobs[ig];
321  joblist.clear();
322 
323  for (int jel = P.first(ig); jel < P.last(ig); ++jel)
324  {
325  const auto& dist = myTable.getDistRow(jel);
326  const auto& displ = myTable.getDisplRow(jel);
327  std::vector<int>& NeighborIons = O.ElecNeighborIons.getNeighborList(jel);
328  for (int iat = 0; iat < O.NumIons; iat++)
329  if (O.PP[iat] != nullptr && dist[iat] < O.PP[iat]->getRmax())
330  {
331  NeighborIons.push_back(iat);
332  O.IonNeighborElecs.getNeighborList(iat).push_back(jel);
333  joblist.emplace_back(iat, jel, dist[iat], -displ[iat]);
334  }
335  }
336  }
337 
338  O.value_ = 0.0;
339  }
340 
341  if (listeners)
342  {
343  auto& ve_samples = O_leader.mw_res_handle_.getResource().ve_samples;
344  auto& vi_samples = O_leader.mw_res_handle_.getResource().vi_samples;
345  ve_samples.resize(nw, pset_leader.getTotalNum());
346  vi_samples.resize(nw, O_leader.IonConfig.getTotalNum());
347  }
348 
349  // the VP of the first NonLocalECPComponent is responsible for holding the shared resource.
350  auto pp_component = std::find_if(O_leader.PPset.begin(), O_leader.PPset.end(), [](auto& ptr) { return bool(ptr); });
351  assert(pp_component != std::end(O_leader.PPset));
352 
353  RefVector<NonLocalECPotential> ecp_potential_list;
354  RefVectorWithLeader<NonLocalECPComponent> ecp_component_list(**pp_component);
355  RefVectorWithLeader<ParticleSet> pset_list(pset_leader);
356  RefVectorWithLeader<TrialWaveFunction> psi_list(O_leader.Psi);
357  // we are moving away from internally stored Psi, double check before Psi gets finally removed.
358  assert(&O_leader.Psi == &wf_list.getLeader());
359  for (size_t iw = 0; iw < nw; iw++)
360  assert(&o_list.getCastedElement<NonLocalECPotential>(iw).Psi == &wf_list[iw]);
361 
362  RefVector<const NLPPJob<Real>> batch_list;
363  std::vector<Real> pairpots(nw);
364 
365  ecp_potential_list.reserve(nw);
366  ecp_component_list.reserve(nw);
367  pset_list.reserve(nw);
368  psi_list.reserve(nw);
369  batch_list.reserve(nw);
370 
371  for (int ig = 0; ig < pset_leader.groups(); ++ig) //loop over species
372  {
373  TrialWaveFunction::mw_prepareGroup(wf_list, p_list, ig);
374 
375  // find the max number of jobs of all the walkers
376  size_t max_num_jobs = 0;
377  for (size_t iw = 0; iw < nw; iw++)
378  {
379  const auto& O = o_list.getCastedElement<NonLocalECPotential>(iw);
380  max_num_jobs = std::max(max_num_jobs, O.nlpp_jobs[ig].size());
381  }
382 
383  for (size_t jobid = 0; jobid < max_num_jobs; jobid++)
384  {
385  ecp_potential_list.clear();
386  ecp_component_list.clear();
387  pset_list.clear();
388  psi_list.clear();
389  batch_list.clear();
390  for (size_t iw = 0; iw < nw; iw++)
391  {
392  auto& O = o_list.getCastedElement<NonLocalECPotential>(iw);
393  if (jobid < O.nlpp_jobs[ig].size())
394  {
395  const auto& job = O.nlpp_jobs[ig][jobid];
396  ecp_potential_list.push_back(O);
397  ecp_component_list.push_back(*O.PP[job.ion_id]);
398  pset_list.push_back(p_list[iw]);
399  psi_list.push_back(wf_list[iw]);
400  batch_list.push_back(job);
401  }
402  }
403 
404  NonLocalECPComponent::mw_evaluateOne(ecp_component_list, pset_list, psi_list, batch_list, pairpots,
405  O_leader.mw_res_handle_.getResource().collection, O_leader.use_DLA);
406 
407  // Right now this is just over walker but could and probably should be over a set
408  // larger than the walker count. The easiest way to not complicate the per particle
409  // reporting code would be to add the crowd walker index to the nlpp job meta data.
410  for (size_t j = 0; j < ecp_potential_list.size(); j++)
411  {
412  ecp_potential_list[j].get().value_ += pairpots[j];
413  if (Tmove)
414  ecp_component_list[j].contributeTxy(batch_list[j].get().electron_id, ecp_potential_list[j].get().tmove_xy_);
415 
416  if (listeners)
417  {
418  auto& ve_samples = O_leader.mw_res_handle_.getResource().ve_samples;
419  auto& vi_samples = O_leader.mw_res_handle_.getResource().vi_samples;
420  // CAUTION! This may not be so simple in the future
421  int iw = j;
422  ve_samples(iw, batch_list[j].get().electron_id) += pairpots[j];
423  vi_samples(iw, batch_list[j].get().ion_id) += pairpots[j];
424  }
425 
426 #ifdef DEBUG_NLPP_BATCHED
427  Real check_value =
428  ecp_component_list[j].evaluateOne(pset_list[j], batch_list[j].get().ion_id, psi_list[j],
429  batch_list[j].get().electron_id, batch_list[j].get().ion_elec_dist,
430  batch_list[j].get().ion_elec_displ, O_leader.use_DLA);
431  if (std::abs(check_value - pairpots[j]) > 1e-5)
432  std::cout << "check " << check_value << " wrong " << pairpots[j] << " diff "
433  << std::abs(check_value - pairpots[j]) << std::endl;
434 #endif
435  }
436  }
437  }
438 
439  if (listeners)
440  {
441  // Motivation for this repeated definition is to make factoring this listener code out easy
442  // and making it ignorable when reading this function.
443  auto& ve_samples = O_leader.mw_res_handle_.getResource().ve_samples;
444  auto& vi_samples = O_leader.mw_res_handle_.getResource().vi_samples;
445  int num_electrons = pset_leader.getTotalNum();
446  for (int iw = 0; iw < nw; ++iw)
447  {
448  Vector<Real> ve_sample(ve_samples.begin(iw), num_electrons);
449  Vector<Real> vi_sample(vi_samples.begin(iw), O_leader.NumIons);
450  for (const ListenerVector<Real>& listener : listeners->electron_values)
451  listener.report(iw, O_leader.getName(), ve_sample);
452  for (const ListenerVector<Real>& listener : listeners->ion_values)
453  listener.report(iw, O_leader.getName(), vi_sample);
454  }
455  ve_samples = 0.0;
456  vi_samples = 0.0;
457  }
458 }
std::vector< NonLocalData > tmove_xy_
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
static void mw_prepareGroup(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig)
batched version of prepareGroup
static void mw_evaluateOne(const RefVectorWithLeader< NonLocalECPComponent > &ecp_component_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVectorWithLeader< TrialWaveFunction > &psi_list, const RefVector< const NLPPJob< RealType >> &joblist, std::vector< RealType > &pairpots, ResourceCollection &collection, bool use_DLA)
Evaluate the nonlocal pp contribution via randomized quadrature grid to total energy from ion "iat" a...
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
QMCTraits::TensorType generateRandomRotationMatrix(RandomBase< QMCTraits::FullPrecRealType > &rng)
Create a random 3D rotation matrix using a random generator.
NonLocalECPotential(ParticleSet &ions, ParticleSet &els, TrialWaveFunction &psi, bool computeForces, bool enable_DLA)
constructor

◆ mw_evaluatePerParticle()

void mw_evaluatePerParticle ( const RefVectorWithLeader< OperatorBase > &  o_list,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const std::vector< ListenerVector< Real >> &  listeners,
const std::vector< ListenerVector< Real >> &  listeners_ions 
) const
override

Definition at line 151 of file NonLocalECPotential.cpp.

References NonLocalECPotential::mw_evaluateImpl().

156 {
157  std::optional<ListenerOption<Real>> l_opt(std::in_place, listeners, listeners_ions);
158  mw_evaluateImpl(o_list, wf_list, p_list, false, l_opt);
159 }
static void mw_evaluateImpl(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, bool Tmove, std::optional< ListenerOption< Real >> listeners, bool keepGrid=false)
the actual implementation for batched walkers, used by mw_evaluate, mw_evaluateWithToperator mw_evalu...

◆ mw_evaluatePerParticleWithToperator()

void mw_evaluatePerParticleWithToperator ( const RefVectorWithLeader< OperatorBase > &  o_list,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const std::vector< ListenerVector< Real >> &  listeners,
const std::vector< ListenerVector< Real >> &  listeners_ions 
) const
override

Definition at line 161 of file NonLocalECPotential.cpp.

References NonLocalECPotential::mw_evaluateImpl(), qmcplusplus::TMOVE_V0, qmcplusplus::TMOVE_V3, and NonLocalECPotential::UseTMove.

167 {
168  std::optional<ListenerOption<Real>> l_opt(std::in_place, listeners, listeners_ions);
169  if (UseTMove == TMOVE_V0 || UseTMove == TMOVE_V3)
170  mw_evaluateImpl(o_list, wf_list, p_list, true, l_opt);
171  else
172  mw_evaluateImpl(o_list, wf_list, p_list, false, l_opt);
173 }
static void mw_evaluateImpl(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, bool Tmove, std::optional< ListenerOption< Real >> listeners, bool keepGrid=false)
the actual implementation for batched walkers, used by mw_evaluate, mw_evaluateWithToperator mw_evalu...

◆ mw_evaluateWithToperator()

void mw_evaluateWithToperator ( const RefVectorWithLeader< OperatorBase > &  o_list,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list 
) const
overridevirtual

Evaluate the contribution of this component of multiple walkers.

Parameters
o_list
wf_list
p_list

Reimplemented from OperatorBase.

Definition at line 141 of file NonLocalECPotential.cpp.

References NonLocalECPotential::mw_evaluateImpl(), qmcplusplus::TMOVE_V0, qmcplusplus::TMOVE_V3, and NonLocalECPotential::UseTMove.

144 {
145  if (UseTMove == TMOVE_V0 || UseTMove == TMOVE_V3)
146  mw_evaluateImpl(o_list, wf_list, p_list, true, std::nullopt);
147  else
148  mw_evaluateImpl(o_list, wf_list, p_list, false, std::nullopt);
149 }
static void mw_evaluateImpl(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, bool Tmove, std::optional< ListenerOption< Real >> listeners, bool keepGrid=false)
the actual implementation for batched walkers, used by mw_evaluate, mw_evaluateWithToperator mw_evalu...

◆ put()

bool put ( xmlNodePtr  cur)
inlineoverridevirtual

Do nothing.

Implements OperatorBase.

Definition at line 128 of file NonLocalECPotential.h.

128 { return true; }

◆ registerObservables()

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

add to observable descriptor for hdf5 The default implementation is to register a scalar for this->value_

Parameters
h5desccontains a set of hdf5 descriptors for a scalar observable
gidhdf5 group to which the observables belong

Reimplemented from OperatorBase.

Definition at line 827 of file NonLocalECPotential.cpp.

References NonLocalECPotential::ComputeForces, ForceBase::first_force_index_, ForceBase::n_nuc_, OHMMS_DIM, OperatorBase::registerObservables(), and qmcplusplus::Units::time::s.

828 {
829  using namespace std::string_literals;
830 
831  OperatorBase::registerObservables(h5list, file);
832  if (ComputeForces)
833  {
834  std::vector<int> ndim(2);
835  ndim[0] = n_nuc_;
836  ndim[1] = OHMMS_DIM;
837  h5list.push_back({{"FNL"s}});
838  auto& h5o1 = h5list.back();
839  h5o1.set_dimensions(ndim, first_force_index_);
840  }
841 }
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->va...
bool ComputeForces
true if we should compute forces
#define OHMMS_DIM
Definition: config.h:64

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
overridevirtual

return a shared resource to a collection

Reimplemented from OperatorBase.

Definition at line 787 of file NonLocalECPotential.cpp.

References RefVectorWithLeader< T >::getCastedLeader(), and ResourceCollection::takebackResource().

789 {
790  auto& O_leader = o_list.getCastedLeader<NonLocalECPotential>();
791  collection.takebackResource(O_leader.mw_res_handle_);
792 }
NonLocalECPotential(ParticleSet &ions, ParticleSet &els, TrialWaveFunction &psi, bool computeForces, bool enable_DLA)
constructor

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
overridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 47 of file NonLocalECPotential.cpp.

47 {}

◆ setComputeForces()

void setComputeForces ( bool  val)
inlineoverridevirtual

Set the flag whether to compute forces or not.

Parameters
valThe boolean value for computing forces

Reimplemented from OperatorBase.

Definition at line 168 of file NonLocalECPotential.h.

References NonLocalECPotential::ComputeForces.

168 { ComputeForces = val; }
bool ComputeForces
true if we should compute forces

◆ setNonLocalMoves() [1/2]

void setNonLocalMoves ( xmlNodePtr  cur)
inline

set non local moves options

Parameters
curthe xml input

Definition at line 107 of file NonLocalECPotential.h.

References NonLocalECPotential::nonLocalOps, NonLocalTOperator::put(), and NonLocalECPotential::UseTMove.

Referenced by QMCHamiltonian::setNonLocalMoves().

107 { UseTMove = nonLocalOps.put(cur); }
NonLocalTOperator nonLocalOps
non local operator
int put(xmlNodePtr cur)
initialize the parameters

◆ setNonLocalMoves() [2/2]

void setNonLocalMoves ( const std::string &  non_local_move_option,
const double  tau,
const double  alpha,
const double  gamma 
)
inline

Definition at line 109 of file NonLocalECPotential.h.

References NonLocalECPotential::nonLocalOps, NonLocalTOperator::thingsThatShouldBeInMyConstructor(), and NonLocalECPotential::UseTMove.

113  {
114  UseTMove = nonLocalOps.thingsThatShouldBeInMyConstructor(non_local_move_option, tau, alpha, gamma);
115  }
int thingsThatShouldBeInMyConstructor(const std::string &non_local_move_option, const double tau, const double alpha, const double gamma)
replacement for put because wouldn&#39;t it be cool to know what the classes configuration actually is...
NonLocalTOperator nonLocalOps
non local operator

◆ setObservables()

void setObservables ( QMCTraits::PropertySetType plist)
overridevirtual

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 843 of file NonLocalECPotential.cpp.

References NonLocalECPotential::ComputeForces, ForceBase::first_force_index_, ForceBase::forces_, ForceBase::n_nuc_, OHMMS_DIM, and OperatorBase::setObservables().

844 {
846  if (ComputeForces)
847  {
848  int index = first_force_index_;
849  for (int iat = 0; iat < n_nuc_; iat++)
850  {
851  for (int x = 0; x < OHMMS_DIM; x++)
852  {
853  plist[index++] = forces_[iat][x];
854  // plist[index++] = PulayTerm[iat][x];
855  }
856  }
857  }
858 }
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
bool ComputeForces
true if we should compute forces
#define OHMMS_DIM
Definition: config.h:64
virtual void setObservables(PropertySetType &plist)
Set the values evaluated by this object to plist Default implementation is to assign Value which is u...

◆ setParticlePropertyList()

void setParticlePropertyList ( QMCTraits::PropertySetType plist,
int  offset 
)
overridevirtual

Reimplemented from OperatorBase.

Definition at line 861 of file NonLocalECPotential.cpp.

References NonLocalECPotential::ComputeForces, ForceBase::first_force_index_, ForceBase::forces_, ForceBase::n_nuc_, OHMMS_DIM, and OperatorBase::setParticlePropertyList().

862 {
864  if (ComputeForces)
865  {
866  int index = first_force_index_ + offset;
867  for (int iat = 0; iat < n_nuc_; iat++)
868  {
869  for (int x = 0; x < OHMMS_DIM; x++)
870  {
871  plist[index++] = forces_[iat][x];
872  // plist[index++] = PulayTerm[iat][x];
873  }
874  }
875  }
876 }
ParticleSet::ParticlePos forces_
Definition: ForceBase.h:87
bool ComputeForces
true if we should compute forces
#define OHMMS_DIM
Definition: config.h:64
virtual void setParticlePropertyList(PropertySetType &plist, int offset)

◆ setRandomGenerator()

void setRandomGenerator ( RandomBase< FullPrecRealType > *  rng)
inlineoverridevirtual

set the internal RNG pointer as the given pointer

Parameters
rnginput RNG pointer

Reimplemented from OperatorBase.

Definition at line 155 of file NonLocalECPotential.h.

References NonLocalECPotential::myRNG.

Referenced by QMCHamiltonian::setRandomGenerator(), and qmcplusplus::TEST_CASE().

155 { myRNG = rng; }
RandomBase< FullPrecRealType > * myRNG
random number generator

Friends And Related Function Documentation

◆ testing::TestNonLocalECPotential

friend class testing::TestNonLocalECPotential
friend

Definition at line 260 of file NonLocalECPotential.h.

Member Data Documentation

◆ ComputeForces

◆ ElecNeighborIons

◆ elecTMAffected

std::vector<bool> elecTMAffected
private

ture if an electron is affected by other electrons moved by T-moves

Definition at line 215 of file NonLocalECPotential.h.

Referenced by NonLocalECPotential::makeNonLocalMovesPbyP(), and NonLocalECPotential::markAffectedElecs().

◆ IonConfig

◆ IonNeighborElecs

◆ mw_res_handle_

mult walker shared resource

Definition at line 231 of file NonLocalECPotential.h.

Referenced by NonLocalECPotential::acquireResource().

◆ myRNG

◆ myTableIndex

◆ nlpp_jobs

std::vector<std::vector<NLPPJob<Real> > > nlpp_jobs
private

NLPP job list of ion-electron pairs by spin group.

Definition at line 229 of file NonLocalECPotential.h.

Referenced by NonLocalECPotential::mw_evaluateImpl(), and NonLocalECPotential::NonLocalECPotential().

◆ nonLocalOps

NonLocalTOperator nonLocalOps
private

non local operator

Definition at line 217 of file NonLocalECPotential.h.

Referenced by NonLocalECPotential::makeNonLocalMovesPbyP(), and NonLocalECPotential::setNonLocalMoves().

◆ NumIons

◆ Peln

ParticleSet& Peln
private

reference to the electrons

Definition at line 207 of file NonLocalECPotential.h.

Referenced by NonLocalECPotential::checkoutParticleQuantities().

◆ PP

◆ PPset

◆ Psi

◆ PulayTerm

ParticleSet::ParticlePos PulayTerm
private

Pulay force vector.

Definition at line 219 of file NonLocalECPotential.h.

Referenced by NonLocalECPotential::evalIonDerivsImpl(), and NonLocalECPotential::NonLocalECPotential().

◆ tmove_xy_

◆ use_DLA

bool use_DLA
protected

true, determinant localization approximation(DLA) is enabled

Definition at line 199 of file NonLocalECPotential.h.

Referenced by NonLocalECPotential::computeOneElectronTxy(), NonLocalECPotential::evaluateImpl(), and NonLocalECPotential::makeClone().

◆ UseTMove

◆ Ve_sample

◆ Vi_sample

◆ qmcplusplus::OperatorBase

class qmcplusplus::OperatorBase

An abstract class for Local Energy operators.

Return_t is defined as RealTye. The types should be checked when using complex wave functions.

Definition at line 59 of file OperatorBase.h.

+ Inheritance diagram for OperatorBase:
+ Collaboration diagram for OperatorBase:

Public Types

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

 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...
 
virtual std::string getClassName () const =0
 return class name 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 resetTargetParticleSet (ParticleSet &P)=0
 Reset the data with the target ParticleSet. More...
 
virtual Return_t evaluate (ParticleSet &P)=0
 Evaluate the local energy contribution of this component. More...
 
virtual bool get (std::ostream &os) const =0
 write about the class More...
 
virtual std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi)=0
 
virtual void addObservables (PropertySetType &plist, BufferType &collectables)
 named values to the property list Default implementaton uses addValue(plist_) 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 registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 
virtual void setObservables (PropertySetType &plist)
 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...
 
virtual void setParticlePropertyList (PropertySetType &plist, int offset)
 
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...
 

Protected Member Functions

virtual bool put (xmlNodePtr cur)=0
 Read the input parameter. More...
 
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

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_
 

Private Member Functions

bool energyDomainValid (EnergyDomains edomain) const noexcept
 return whether the energy domain is valid More...
 
bool quantumDomainValid (QuantumDomains qdomain) const noexcept
 return whether the quantum domain is valid More...
 

Private Attributes

bool streaming_scalars_
 
Array< RealType, 1 > * value_sample_
 array to store sample value More...
 
bool has_listener_ = false
 Is there a per particle listener sadly this is necessary due to state machines. More...
 
QuantumDomains quantum_domain_
 quantum_domain_ of the (particle) operator, default = no_quantum_domain More...
 
EnergyDomains energy_domain_
 energy domain of the operator (kinetic/potential), default = no_energy_domain More...
 

Member Typedef Documentation

◆ BufferType

typedef for the serialized buffer

PooledData<RealType> is used to serialized an anonymous buffer

Definition at line 75 of file OperatorBase.h.

◆ GradMatrix

Definition at line 69 of file OperatorBase.h.

◆ ParticleScalar

typedef for the ParticleScalar

Definition at line 81 of file OperatorBase.h.

◆ Return_t

type of return value of evaluate

Definition at line 64 of file OperatorBase.h.

◆ SPOMap

typedef for SPOMap

Definition at line 84 of file OperatorBase.h.

◆ ValueMatrix

For fast derivative evaluation.

Definition at line 68 of file OperatorBase.h.

◆ Walker_t

typedef for the walker

Definition at line 78 of file OperatorBase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

enum for update_mode

Enumerator
PRIMARY 
OPTIMIZABLE 
RATIOUPDATE 
PHYSICAL 
COLLECTABLE 
NONLOCAL 

Definition at line 105 of file OperatorBase.h.

◆ EnergyDomains

enum to denote energy domain of operators

Enumerator
KINETIC 
POTENTIAL 
NO_ENERGY_DOMAIN 

Definition at line 87 of file OperatorBase.h.

◆ QuantumDomains

Constructor & Destructor Documentation

◆ OperatorBase()

Construct a new Operator Base object Default and unique empty constructor.

Initializes with default values.

Definition at line 28 of file OperatorBase.cpp.

References OperatorBase::PRIMARY, and OperatorBase::update_mode_.

29  : value_(0.0),
30  my_index_(-1),
31  t_walker_(0),
32 #if !defined(REMOVE_TRACEMANAGER)
33  streaming_particles_(false),
34  have_required_traces_(false),
35  streaming_scalars_(false),
36 #endif
39 {
40  update_mode_.set(PRIMARY, 1);
41 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
Walker_t * t_walker_
reference to the current walker
Definition: OperatorBase.h:541
Return_t value_
current value
Definition: OperatorBase.h:524
QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615
EnergyDomains energy_domain_
energy domain of the operator (kinetic/potential), default = no_energy_domain
Definition: OperatorBase.h:617
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521

◆ ~OperatorBase()

virtual ~OperatorBase ( )
virtualdefault

Member Function Documentation

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
virtual

Acquire a shared resource from a collection.

Parameters
collection
o_list

Reimplemented in CoulombPBCAB, CoulombPBCAA, BareKineticEnergy, NonLocalECPotential, and SOECPotential.

Definition at line 205 of file OperatorBase.cpp.

207 {}

◆ add2Hamiltonian()

void add2Hamiltonian ( ParticleSet qp,
TrialWaveFunction psi,
QMCHamiltonian targetH 
)
virtual

TODO: add docs.

Parameters
qp
psi
targetH

Reimplemented in ACForce.

Definition at line 215 of file OperatorBase.cpp.

References QMCHamiltonian::addOperator(), OperatorBase::makeClone(), OperatorBase::name_, OperatorBase::PHYSICAL, and OperatorBase::update_mode_.

216 {
217  std::unique_ptr<OperatorBase> myclone = makeClone(qp, psi);
218  if (myclone)
219  {
220  targetH.addOperator(std::move(myclone), name_, update_mode_[PHYSICAL]);
221  }
222 }
virtual std::unique_ptr< OperatorBase > makeClone(ParticleSet &qp, TrialWaveFunction &psi)=0
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

◆ addObservables()

void addObservables ( PropertySetType plist,
BufferType collectables 
)
virtual

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

Parameters
plistRecordNameProperty
collectablesObservables that are accumulated by evaluate

Reimplemented in OrbitalImages, CoulombPBCAB, DensityMatrices1B, CoulombPBCAA, NonLocalECPotential, CoulombPotential< T >, StressPBC, ForceChiesaPBCAA, ForwardWalking, ForceCeperley, ACForce, LatticeDeviationEstimator, SpinDensity, PairCorrEstimator, SelfHealingOverlapLegacy, StaticStructureFactor, SkAllEstimator, SpeciesKineticEnergy, BareForce, DensityEstimator, SkEstimator, EnergyDensityEstimator, and MomentumEstimator.

Definition at line 56 of file OperatorBase.cpp.

References OperatorBase::addValue().

56 { addValue(plist); }
void addValue(PropertySetType &plist)
named values to the property list

◆ addValue()

void addValue ( PropertySetType plist)
protected

named values to the property list

Parameters
plistRecordNameProperty

Previously addObservables but it is renamed and a non-virtial function.

Definition at line 355 of file OperatorBase.cpp.

References RecordNamedProperty< T >::add(), OperatorBase::COLLECTABLE, OperatorBase::my_index_, OperatorBase::name_, and OperatorBase::update_mode_.

Referenced by CoulombPotential< T >::addObservables(), CoulombPBCAA::addObservables(), NonLocalECPotential::addObservables(), and OperatorBase::addObservables().

356 {
358  my_index_ = plist.add(name_.c_str());
359 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
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

◆ checkoutParticleQuantities()

void checkoutParticleQuantities ( TraceManager tm)
protectedvirtual

◆ checkoutScalarQuantities()

void checkoutScalarQuantities ( TraceManager tm)
protectedvirtual

Reimplemented in DensityMatrices1B, and EnergyDensityEstimator.

Definition at line 277 of file OperatorBase.cpp.

References TraceManager::checkout_real(), OperatorBase::name_, OperatorBase::request_, TraceRequest::streaming_scalar(), OperatorBase::streaming_scalars_, and OperatorBase::value_sample_.

Referenced by OperatorBase::checkoutTraceQuantities().

278 {
280  if (streaming_scalars_)
281  value_sample_ = tm.checkout_real<1>(name_);
282 }
bool streaming_scalar(const std::string &name)
Definition: TraceManager.h:242
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
std::string name_
name of this object
Definition: OperatorBase.h:527
Array< RealType, 1 > * value_sample_
array to store sample value
Definition: OperatorBase.h:606

◆ checkoutTraceQuantities()

void checkoutTraceQuantities ( TraceManager tm)

Checkout trace arrays Derived classes must guard individual checkouts using request info.

Parameters
tm

Definition at line 254 of file OperatorBase.cpp.

References OperatorBase::checkoutParticleQuantities(), and OperatorBase::checkoutScalarQuantities().

255 {
258 }
virtual void checkoutParticleQuantities(TraceManager &tm)
virtual void checkoutScalarQuantities(TraceManager &tm)

◆ collectScalarQuantities()

void collectScalarQuantities ( )
protectedvirtual

Reimplemented in DensityMatrices1B, and EnergyDensityEstimator.

Definition at line 284 of file OperatorBase.cpp.

References OperatorBase::streaming_scalars_, and OperatorBase::value_.

Referenced by OperatorBase::collectScalarTraces().

285 {
286  if (streaming_scalars_)
287  (*value_sample_)(0) = value_;
288 }
Return_t value_
current value
Definition: OperatorBase.h:524

◆ collectScalarTraces()

void collectScalarTraces ( )

Collect scalar trace data.

Definition at line 260 of file OperatorBase.cpp.

References OperatorBase::collectScalarQuantities().

virtual void collectScalarQuantities()

◆ contributeParticleQuantities()

void contributeParticleQuantities ( )
protectedvirtual

◆ contributeScalarQuantities()

void contributeScalarQuantities ( )
protectedvirtual

Reimplemented in DensityMatrices1B, and EnergyDensityEstimator.

Definition at line 275 of file OperatorBase.cpp.

References TraceRequest::contribute_scalar(), OperatorBase::name_, and OperatorBase::request_.

Referenced by OperatorBase::contributeTraceQuantities().

TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
std::string name_
name of this object
Definition: OperatorBase.h:527
void contribute_scalar(const std::string &name, bool default_quantity=false)
Definition: TraceManager.h:189

◆ contributeTraceQuantities()

void contributeTraceQuantities ( )

Make trace quantities available.

Definition at line 248 of file OperatorBase.cpp.

References OperatorBase::contributeParticleQuantities(), and OperatorBase::contributeScalarQuantities().

249 {
252 }
virtual void contributeScalarQuantities()
virtual void contributeParticleQuantities()

◆ createResource()

void createResource ( ResourceCollection collection) const
virtual

Initialize a shared resource and hand it to a collection.

Parameters
collection

Reimplemented in CoulombPBCAB, CoulombPBCAA, BareKineticEnergy, NonLocalECPotential, and SOECPotential.

Definition at line 203 of file OperatorBase.cpp.

203 {}

◆ deleteParticleQuantities()

void deleteParticleQuantities ( )
protectedvirtual

◆ deleteScalarQuantities()

void deleteScalarQuantities ( )
protectedvirtual

Reimplemented in DensityMatrices1B, and EnergyDensityEstimator.

Definition at line 290 of file OperatorBase.cpp.

References OperatorBase::streaming_scalars_, and OperatorBase::value_sample_.

Referenced by OperatorBase::deleteTraceQuantities().

291 {
292  if (streaming_scalars_)
293  delete value_sample_;
294 }
Array< RealType, 1 > * value_sample_
array to store sample value
Definition: OperatorBase.h:606

◆ deleteTraceQuantities()

◆ dependsOnWaveFunction()

virtual bool dependsOnWaveFunction ( ) const
inlinevirtual

return true if this operator depends on a wavefunction

Reimplemented in DensityMatrices1B, L2Potential, BareKineticEnergy, Pressure, NonLocalECPotential, ACForce, SOECPotential, and MomentumEstimator.

Definition at line 124 of file OperatorBase.h.

Referenced by OperatorBase::evaluateValueAndDerivatives().

124 { return false; }

◆ energyDomainValid()

bool energyDomainValid ( EnergyDomains  edomain) const
privatenoexcept

return whether the energy domain is valid

Definition at line 362 of file OperatorBase.cpp.

Referenced by OperatorBase::setEnergyDomain().

◆ evaluate()

◆ evaluateDeterministic()

OperatorBase::Return_t evaluateDeterministic ( ParticleSet P)
virtual

Evaluate the local energy contribution of this component, deterministically based on current state.

The correct behavior of this routine requires estimators with non-deterministic components in their evaluate() function to override this function.

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

Reimplemented in NonLocalECPotential, and SOECPotential.

Definition at line 79 of file OperatorBase.cpp.

References OperatorBase::evaluate().

79 { return evaluate(P); }
virtual Return_t evaluate(ParticleSet &P)=0
Evaluate the local energy contribution of this component.

◆ evaluateOneBodyOpMatrix()

virtual void evaluateOneBodyOpMatrix ( ParticleSet P,
const TWFFastDerivWrapper psi,
std::vector< ValueMatrix > &  B 
)
inlinevirtual

Evaluate "B" matrix for observable.

Filippi scheme for computing fast derivatives.

Parameters
[in]Ptarget particle set (electrons)
[in]psi,TrialWavefunction wrapper for fast derivatives.
[in,out]B.List of B matrices for each species.
Returns
Void

Reimplemented in BareKineticEnergy, and NonLocalECPotential.

Definition at line 387 of file OperatorBase.h.

Referenced by qmcplusplus::TEST_CASE().

390  {}

◆ evaluateOneBodyOpMatrixForceDeriv()

virtual void evaluateOneBodyOpMatrixForceDeriv ( ParticleSet P,
ParticleSet source,
const TWFFastDerivWrapper psi,
const int  iat,
std::vector< std::vector< ValueMatrix >> &  Bforce 
)
inlinevirtual

Evaluate "dB/dR" matrices for observable.

Filippi scheme for computing fast derivatives.

Parameters
[in]P,targetparticle set (electrons)
[in]source,ionparticle set
[in]psi,TrialWavefunction wrapper for fast derivatives.
[in]iat

Reimplemented in BareKineticEnergy, and NonLocalECPotential.

Definition at line 402 of file OperatorBase.h.

Referenced by qmcplusplus::TEST_CASE().

407  {}

◆ evaluateValueAndDerivatives()

OperatorBase::Return_t evaluateValueAndDerivatives ( ParticleSet P,
const opt_variables_type optvars,
const Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
virtual

Evaluate value and derivatives wrt the optimizables.

Default uses evaluate.

Parameters
P
optvars
dlogpsi
dhpsioverpsi
Returns
Return_t

Reimplemented in SOECPotential.

Definition at line 168 of file OperatorBase.cpp.

References OperatorBase::dependsOnWaveFunction(), OperatorBase::evaluate(), and OperatorBase::getClassName().

172 {
173  if (dependsOnWaveFunction())
174  throw std::logic_error("Bug!! " + getClassName() +
175  "::evaluateValueAndDerivatives"
176  "must be overloaded when the OperatorBase depends on a wavefunction.");
177 
178  return evaluate(P);
179 }
virtual Return_t evaluate(ParticleSet &P)=0
Evaluate the local energy contribution of this component.
virtual bool dependsOnWaveFunction() const
return true if this operator depends on a wavefunction
Definition: OperatorBase.h:124
virtual std::string getClassName() const =0
return class name

◆ evaluateWithIonDerivs()

OperatorBase::Return_t evaluateWithIonDerivs ( ParticleSet P,
ParticleSet ions,
TrialWaveFunction psi,
ParticleSet::ParticlePos hf_term,
ParticleSet::ParticlePos pulay_term 
)
virtual

Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase.

Parameters
Ptarget particle set (electrons)
ionssource particle set (ions)
psiTrial wave function
hf_termsAdds OperatorBase's contribution to Re [(dH)Psi]/Psi
pulay_termsAdds OperatorBase's contribution to Re [(H-E_L)dPsi]/Psi
Returns
Contribution of OperatorBase to Local Energy.

Reimplemented in CoulombPotential< T >, CoulombPBCAB, BareKineticEnergy, CoulombPBCAA, NonLocalECPotential, and LocalECPotential.

Definition at line 181 of file OperatorBase.cpp.

References OperatorBase::evaluate().

Referenced by OperatorBase::evaluateWithIonDerivsDeterministic().

186 {
187  return evaluate(P);
188 }
virtual Return_t evaluate(ParticleSet &P)=0
Evaluate the local energy contribution of this component.

◆ evaluateWithIonDerivsDeterministic()

OperatorBase::Return_t evaluateWithIonDerivsDeterministic ( ParticleSet P,
ParticleSet ions,
TrialWaveFunction psi,
ParticleSet::ParticlePos hf_term,
ParticleSet::ParticlePos pulay_term 
)
virtual

Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase.

If there's no stochastic component, defaults to evaluateWithIonDerivs. If not otherwise specified, this defaults to evaluate().

Parameters
Ptarget particle set (electrons)
ionssource particle set (ions)
psiTrial wave function
hf_termsAdds OperatorBase's contribution to Re [(dH)Psi]/Psi
pulay_termsAdds OperatorBase's contribution to Re [(H-E_L)dPsi]/Psi
Returns
Contribution of OperatorBase to Local Energy.

Reimplemented in NonLocalECPotential.

Definition at line 190 of file OperatorBase.cpp.

References OperatorBase::evaluateWithIonDerivs().

195 {
196  return evaluateWithIonDerivs(P, ions, psi, hf_term, pulay_term);
197 }
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...

◆ evaluateWithToperator()

OperatorBase::Return_t evaluateWithToperator ( ParticleSet P)
virtual

Evaluate the local energy contribution of this component with Toperators updated if requested.

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

Reimplemented in NonLocalECPotential.

Definition at line 143 of file OperatorBase.cpp.

References OperatorBase::evaluate().

143 { return evaluate(P); }
virtual Return_t evaluate(ParticleSet &P)=0
Evaluate the local energy contribution of this component.

◆ get()

◆ getClassName()

◆ getEnsembleAverage()

OperatorBase::Return_t getEnsembleAverage ( )
virtual

Return an average value by collective operation.

Definition at line 201 of file OperatorBase.cpp.

201 { return 0.0; }

◆ getMode()

bool getMode ( const int  i) const
noexcept

Return the mode i.

Parameters
iindex among PRIMARY, OPTIMIZABLE, RATIOUPDATE, PHYSICAL

Definition at line 240 of file OperatorBase.cpp.

240 { return update_mode_[i]; }
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521

◆ getName()

std::string getName ( ) const
noexcept

getter a copy of my_name_, rvalue small string optimization

Returns
std::string copy of my_name_ member

Definition at line 47 of file OperatorBase.cpp.

References OperatorBase::name_.

Referenced by QMCHamiltonian::initialize_traces(), and QMCHamiltonian::updateComponent().

47 { return name_; }
std::string name_
name of this object
Definition: OperatorBase.h:527

◆ getRequest()

TraceRequest & getRequest ( )
noexcept

Get request_ member.

Returns
TraceRequest& reference to request_

Definition at line 52 of file OperatorBase.cpp.

References OperatorBase::request_.

52 { return request_; }
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531

◆ getRequiredTraces()

void getRequiredTraces ( TraceManager tm)
virtual

TODO: add docs.

Parameters
tm

Reimplemented in DensityMatrices1B, and EnergyDensityEstimator.

Definition at line 225 of file OperatorBase.cpp.

225 {};

◆ getUpdateMode()

std::bitset< 8 > & getUpdateMode ( )
noexcept

get update_mode_ reference

Returns
std::bitset<8>& reference of get_update_mode_

Definition at line 43 of file OperatorBase.cpp.

References OperatorBase::update_mode_.

43 { return update_mode_; }
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521

◆ getValue()

OperatorBase::Return_t getValue ( ) const
noexcept

get a copy of value_

Returns
Return_t copy of value_

Definition at line 45 of file OperatorBase.cpp.

References OperatorBase::value_.

Referenced by TestSOECPotential::evalFast(), qmcplusplus::TEST_CASE(), qmcplusplus::test_CoulombPBCAA_3p(), and QMCHamiltonian::updateComponent().

45 { return value_; }
Return_t value_
current value
Definition: OperatorBase.h:524

◆ hasListener()

bool hasListener ( ) const
noexcept

Definition at line 244 of file OperatorBase.cpp.

References OperatorBase::has_listener_.

244 { return has_listener_; }
bool has_listener_
Is there a per particle listener sadly this is necessary due to state machines.
Definition: OperatorBase.h:612

◆ informOfPerParticleListener()

virtual void informOfPerParticleListener ( )
inlinevirtual

Reimplemented in CoulombPBCAB, and CoulombPBCAA.

Definition at line 471 of file OperatorBase.h.

References OperatorBase::has_listener_.

Referenced by CoulombPBCAA::informOfPerParticleListener(), and CoulombPBCAB::informOfPerParticleListener().

471 { has_listener_ = true; }
bool has_listener_
Is there a per particle listener sadly this is necessary due to state machines.
Definition: OperatorBase.h:612

◆ isClassical()

bool isClassical ( ) const
noexcept

Definition at line 230 of file OperatorBase.cpp.

References OperatorBase::CLASSICAL, and OperatorBase::quantum_domain_.

Referenced by QMCHamiltonian::initialize_traces().

230 { return quantum_domain_ == CLASSICAL; }
QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615

◆ isClassicalClassical()

bool isClassicalClassical ( ) const
noexcept

Definition at line 234 of file OperatorBase.cpp.

References OperatorBase::CLASSICAL_CLASSICAL, and OperatorBase::quantum_domain_.

Referenced by QMCHamiltonian::initialize_traces().

QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615

◆ isNonLocal()

bool isNonLocal ( ) const
noexcept

TODO: add docs.

Returns
true
false

Definition at line 242 of file OperatorBase.cpp.

References OperatorBase::NONLOCAL, and OperatorBase::update_mode_.

242 { return update_mode_[NONLOCAL]; }
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521

◆ isQuantum()

bool isQuantum ( ) const
noexcept

Definition at line 232 of file OperatorBase.cpp.

References OperatorBase::QUANTUM, and OperatorBase::quantum_domain_.

Referenced by QMCHamiltonian::initialize_traces().

232 { return quantum_domain_ == QUANTUM; }
QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615

◆ isQuantumClassical()

bool isQuantumClassical ( ) const
noexcept

Definition at line 236 of file OperatorBase.cpp.

References OperatorBase::QUANTUM_CLASSICAL, and OperatorBase::quantum_domain_.

Referenced by QMCHamiltonian::initialize_traces().

236 { return quantum_domain_ == QUANTUM_CLASSICAL; }
QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615

◆ isQuantumQuantum()

bool isQuantumQuantum ( ) const
noexcept

Definition at line 238 of file OperatorBase.cpp.

References OperatorBase::quantum_domain_, and OperatorBase::QUANTUM_QUANTUM.

Referenced by QMCHamiltonian::initialize_traces().

238 { return quantum_domain_ == QUANTUM_QUANTUM; }
QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615

◆ makeClone()

◆ mw_evaluate()

void mw_evaluate ( const RefVectorWithLeader< OperatorBase > &  o_list,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list 
) const
virtual

Evaluate the contribution of this component of multiple walkers.

Take o_list and p_list update evaluation result variables in o_list? really should reduce vector of local_energies. matching the ordering and size of o list the this can be call for 1 or more QMCHamiltonians

Parameters
o_list
wf_list
p_list

Temporary raw omp pragma for simple thread parallelism ignoring the driver level concurrency

TODO: replace this with a proper abstraction. It should adequately describe the behavior and strictly limit the activation of this level concurrency to when it is intended. It is unlikely to belong in this function.

This implicitly depends on openmp work division logic. Essentially adhoc runtime crowds over which we have given up control of thread/global scope. How many walkers per thread? How to handle their data movement if any of these hamiltonians should be accelerated? We can neither reason about or describe it in C++

As I understand it it should only be required for as long as the AMD openmp offload compliler is incapable of running multiple threads. They should/must fix their compiler before delivery of frontier and it should be removed at that point at latest

If you want 16 threads of 1 walker that should be 16 crowds of 1 not one crowd of 16 with openmp thrown in at hamiltonian level. If this must be different from the other crowd batching. Make this a reasoned about and controlled level of concurency blocking at the driver level.

This is only thread safe only if each walker has a complete set of anything involved in an Operator.evaluate.

Reimplemented in CoulombPBCAA, NonLocalECPotential, and SOECPotential.

Definition at line 81 of file OperatorBase.cpp.

References OperatorBase::evaluate(), and RefVectorWithLeader< T >::getLeader().

Referenced by CoulombPBCAA::mw_evaluate(), OperatorBase::mw_evaluatePerParticle(), BareKineticEnergy::mw_evaluateWithParameterDerivatives(), and OperatorBase::mw_evaluateWithToperator().

84 {
85  assert(this == &o_list.getLeader());
86 /** Temporary raw omp pragma for simple thread parallelism
87  * ignoring the driver level concurrency
88  *
89  * TODO: replace this with a proper abstraction. It should adequately describe the behavior
90  * and strictly limit the activation of this level concurrency to when it is intended.
91  * It is unlikely to belong in this function.
92  *
93  * This implicitly depends on openmp work division logic. Essentially adhoc runtime
94  * crowds over which we have given up control of thread/global scope.
95  * How many walkers per thread? How to handle their data movement if any of these
96  * hamiltonians should be accelerated? We can neither reason about or describe it in C++
97  *
98  * As I understand it it should only be required for as long as the AMD openmp offload
99  * compliler is incapable of running multiple threads. They should/must fix their compiler
100  * before delivery of frontier and it should be removed at that point at latest
101  *
102  * If you want 16 threads of 1 walker that should be 16 crowds of 1
103  * not one crowd of 16 with openmp thrown in at hamiltonian level.
104  * If this must be different from the other crowd batching. Make this a reasoned about
105  * and controlled level of concurency blocking at the driver level.
106  *
107  * This is only thread safe only if each walker has a complete
108  * set of anything involved in an Operator.evaluate.
109  */
110 #pragma omp parallel for
111  for (int iw = 0; iw < o_list.size(); iw++)
112  o_list[iw].evaluate(p_list[iw]);
113 }
virtual Return_t evaluate(ParticleSet &P)=0
Evaluate the local energy contribution of this component.

◆ mw_evaluatePerParticle()

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
virtual

Evaluate the contribution of this component of multiple walkers per particle and report to registerd listeners from objects in Estimators.

Base class implementation decays to the mw_evaluate so if not overridden the estimator doesn't hear from this operator.

specialized versions of this should take advantage of multiwalker resources to reduce the resource cost of collecting these values.

Reimplemented in CoulombPBCAB, and CoulombPBCAA.

Definition at line 115 of file OperatorBase.cpp.

References OperatorBase::mw_evaluate().

120 {
121  mw_evaluate(o_list, wf_list, p_list);
122 }
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.

◆ mw_evaluatePerParticleWithToperator()

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
virtual

Evaluate the contribution of this component of multiple walkers per particle and report to registerd listeners from objects in Estimators.

default implementation decays to the mw_evaluatePerParticle.

specialized versions of this should take advantage of multiwalker resources to reduce the resource cost of collecting these values.

Definition at line 155 of file OperatorBase.cpp.

References OperatorBase::mw_evaluateWithToperator().

161 {
162  // This may or may not be what is expected.
163  // It the responsibility of the derived type to override this if the
164  // desired behavior is instead to call mw_evaluatePerParticle
165  mw_evaluateWithToperator(o_list, wf_list, p_list);
166 }
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.

◆ mw_evaluateWithParameterDerivatives()

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
virtual

TODO: add docs.

Parameters
o_list
p_list
optvars
dlogpsi
dhpsioverpsi

Definition at line 125 of file OperatorBase.cpp.

References RecordArray< T >::getNumOfParams().

130 {
131  const int nparam = dlogpsi.getNumOfParams();
132  for (int iw = 0; iw < o_list.size(); iw++)
133  {
134  const Vector<ValueType> dlogpsi_record_view(const_cast<ValueType*>(dlogpsi[iw]), nparam);
135  Vector<ValueType> dhpsioverpsi_record_view(dhpsioverpsi[iw], nparam);
136 
137  o_list[iw].evaluateValueAndDerivatives(p_list[iw], optvars, dlogpsi_record_view, dhpsioverpsi_record_view);
138  }
139 }

◆ mw_evaluateWithToperator()

void mw_evaluateWithToperator ( const RefVectorWithLeader< OperatorBase > &  o_list,
const RefVectorWithLeader< TrialWaveFunction > &  wf_list,
const RefVectorWithLeader< ParticleSet > &  p_list 
) const
virtual

Evaluate the contribution of this component of multiple walkers.

Parameters
o_list
wf_list
p_list

Reimplemented in NonLocalECPotential.

Definition at line 145 of file OperatorBase.cpp.

References OperatorBase::mw_evaluate().

Referenced by OperatorBase::mw_evaluatePerParticleWithToperator().

148 {
149  // Only in NLPP evaluateWithToperator doesn't decay to evaluate. All other derived classes don't
150  // provide evaluateWithToperator specialization but may provide mw_evaluate optimization.
151  // Thus decaying to mw_evaluate is better than decalying to a loop over evaluateWithToperator
152  mw_evaluate(o_list, wf_list, p_list);
153 }
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.

◆ oneBodyQuantumDomain()

void oneBodyQuantumDomain ( const ParticleSet P)
protected

set quantum domain for one-body operator

Definition at line 319 of file OperatorBase.cpp.

References APP_ABORT, OperatorBase::CLASSICAL, ParticleSet::is_classical(), ParticleSet::is_quantum(), OperatorBase::QUANTUM, and OperatorBase::quantum_domain_.

Referenced by BareKineticEnergy::BareKineticEnergy(), GridExternalPotential::GridExternalPotential(), and HarmonicExternalPotential::HarmonicExternalPotential().

320 {
321  if (P.is_classical())
323  else if (P.is_quantum())
325  else
326  APP_ABORT("OperatorBase::oneBodyQuantumDomain\n quantum domain of input particles is invalid");
327 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615

◆ put()

◆ quantumDomainValid()

bool quantumDomainValid ( QuantumDomains  qdomain) const
privatenoexcept

return whether the quantum domain is valid

Definition at line 364 of file OperatorBase.cpp.

Referenced by OperatorBase::setQuantumDomain().

◆ registerCollectables()

◆ registerObservables()

void registerObservables ( std::vector< ObservableHelper > &  h5desc,
hdf_archive file 
) const
virtual

add to observable descriptor for hdf5 The default implementation is to register a scalar for this->value_

Parameters
h5desccontains a set of hdf5 descriptors for a scalar observable
gidhdf5 group to which the observables belong

Reimplemented in NonLocalECPotential, StressPBC, ForceChiesaPBCAA, ForceCeperley, and BareForce.

Definition at line 58 of file OperatorBase.cpp.

References OperatorBase::COLLECTABLE, OperatorBase::my_index_, OperatorBase::name_, qmcplusplus::oh, ObservableHelper::set_dimensions(), and OperatorBase::update_mode_.

Referenced by NonLocalECPotential::registerObservables().

59 {
60  const bool collect = update_mode_.test(COLLECTABLE);
61  //exclude collectables
62  if (!collect)
63  {
64  h5desc.emplace_back(hdf_path{name_});
65  auto& oh = h5desc.back();
66  std::vector<int> onedim(1, 1);
67  oh.set_dimensions(onedim, my_index_);
68  }
69 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
std::string name_
name of this object
Definition: OperatorBase.h:527
void set_dimensions(const std::vector< int > &dims, int first)
set the shape of this observable
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521
ObservableHelper oh

◆ rejectedMove()

OperatorBase::Return_t rejectedMove ( ParticleSet P)
virtual

TODO: add docs.

Parameters
P
Returns
Return_t

Reimplemented in ForwardWalking.

Definition at line 141 of file OperatorBase.cpp.

141 { return 0; }

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< OperatorBase > &  o_list 
) const
virtual

Return a shared resource to a collection.

Parameters
collection
o_list

Reimplemented in CoulombPBCAB, CoulombPBCAA, BareKineticEnergy, NonLocalECPotential, and SOECPotential.

Definition at line 209 of file OperatorBase.cpp.

211 {}

◆ resetTargetParticleSet()

◆ setComputeForces()

void setComputeForces ( bool  compute)
protectedvirtual

Reimplemented in NonLocalECPotential.

Definition at line 301 of file OperatorBase.cpp.

301 {}

◆ setEnergyDomain()

void setEnergyDomain ( EnergyDomains  edomain)
protected

Set the Energy Domain.

Parameters
edomain

Definition at line 303 of file OperatorBase.cpp.

References APP_ABORT, OperatorBase::energy_domain_, and OperatorBase::energyDomainValid().

Referenced by BareKineticEnergy::BareKineticEnergy(), CoulombPBCAA::CoulombPBCAA(), CoulombPBCAB::CoulombPBCAB(), CoulombPotential< T >::CoulombPotential(), GridExternalPotential::GridExternalPotential(), HarmonicExternalPotential::HarmonicExternalPotential(), L2Potential::L2Potential(), LocalECPotential::LocalECPotential(), NonLocalECPotential::NonLocalECPotential(), and SOECPotential::SOECPotential().

304 {
305  if (energyDomainValid(edomain))
306  energy_domain_ = edomain;
307  else
308  APP_ABORT("QMCHamiltonainBase::setEnergyDomain\n input energy domain is invalid");
309 }
bool energyDomainValid(EnergyDomains edomain) const noexcept
return whether the energy domain is valid
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
EnergyDomains energy_domain_
energy domain of the operator (kinetic/potential), default = no_energy_domain
Definition: OperatorBase.h:617

◆ setHistories()

void setHistories ( Walker_t ThisWalker)
virtual

Definition at line 77 of file OperatorBase.cpp.

References OperatorBase::t_walker_.

Referenced by qmcplusplus::TEST_CASE().

77 { t_walker_ = &(ThisWalker); }
Walker_t * t_walker_
reference to the current walker
Definition: OperatorBase.h:541

◆ setName()

void setName ( const std::string  name)
noexcept

Set my_name member, uses small string optimization (pass by value)

Parameters
nameinput

Definition at line 49 of file OperatorBase.cpp.

Referenced by ACForce::ACForce().

49 { name_ = name; }
std::string name_
name of this object
Definition: OperatorBase.h:527

◆ setObservables()

◆ setParticlePropertyList()

◆ setQuantumDomain()

void setQuantumDomain ( QuantumDomains  qdomain)
protected

set quantum domain

Definition at line 311 of file OperatorBase.cpp.

References APP_ABORT, OperatorBase::quantum_domain_, and OperatorBase::quantumDomainValid().

312 {
313  if (quantumDomainValid(qdomain))
314  quantum_domain_ = qdomain;
315  else
316  APP_ABORT("QMCHamiltonainBase::setQuantumDomain\n input quantum domain is invalid");
317 }
bool quantumDomainValid(QuantumDomains qdomain) const noexcept
return whether the quantum domain is valid
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615

◆ setRandomGenerator()

void setRandomGenerator ( RandomBase< FullPrecRealType > *  rng)
virtual

Set the Random Generator object TODO: add docs.

Parameters
rng

Reimplemented in DensityMatrices1B, NonLocalECPotential, SOECPotential, and MomentumEstimator.

Definition at line 213 of file OperatorBase.cpp.

213 {}

◆ twoBodyQuantumDomain() [1/2]

void twoBodyQuantumDomain ( const ParticleSet P)
protected

set quantum domain for two-body operator

Definition at line 329 of file OperatorBase.cpp.

References APP_ABORT, OperatorBase::CLASSICAL_CLASSICAL, ParticleSet::is_classical(), ParticleSet::is_quantum(), OperatorBase::quantum_domain_, and OperatorBase::QUANTUM_QUANTUM.

Referenced by CoulombPBCAA::CoulombPBCAA(), CoulombPBCAB::CoulombPBCAB(), CoulombPotential< T >::CoulombPotential(), L2Potential::L2Potential(), LocalECPotential::LocalECPotential(), NonLocalECPotential::NonLocalECPotential(), and SOECPotential::SOECPotential().

330 {
331  if (P.is_classical())
333  else if (P.is_quantum())
335  else
336  APP_ABORT("OperatorBase::twoBodyQuantumDomain(P)\n quantum domain of input particles is invalid");
337 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615

◆ twoBodyQuantumDomain() [2/2]

void twoBodyQuantumDomain ( const ParticleSet P1,
const ParticleSet P2 
)
protected

set quantum domain for two-body operator

Definition at line 339 of file OperatorBase.cpp.

References APP_ABORT, OperatorBase::CLASSICAL_CLASSICAL, ParticleSet::is_classical(), ParticleSet::is_quantum(), OperatorBase::QUANTUM_CLASSICAL, OperatorBase::quantum_domain_, and OperatorBase::QUANTUM_QUANTUM.

340 {
341  const bool c1 = P1.is_classical();
342  const bool c2 = P2.is_classical();
343  const bool q1 = P1.is_quantum();
344  const bool q2 = P2.is_quantum();
345  if (c1 && c2)
347  else if ((q1 && c2) || (c1 && q2))
349  else if (q1 && q2)
351  else
352  APP_ABORT("OperatorBase::twoBodyQuantumDomain(P1,P2)\n quantum domain of input particles is invalid");
353 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
QuantumDomains quantum_domain_
quantum_domain_ of the (particle) operator, default = no_quantum_domain
Definition: OperatorBase.h:615

◆ updateSource()

void updateSource ( ParticleSet s)
virtual

Update data associated with a particleset.

Default implementation does nothing. Only A-A interactions for s needs to implement its own method.

Parameters
ssource particle set

Reimplemented in CoulombPotential< T >, and CoulombPBCAA.

Definition at line 199 of file OperatorBase.cpp.

199 {}

Member Data Documentation

◆ energy_domain_

EnergyDomains energy_domain_
private

energy domain of the operator (kinetic/potential), default = no_energy_domain

Definition at line 617 of file OperatorBase.h.

Referenced by OperatorBase::setEnergyDomain().

◆ has_listener_

bool has_listener_ = false
private

Is there a per particle listener sadly this is necessary due to state machines.

Definition at line 612 of file OperatorBase.h.

Referenced by OperatorBase::hasListener(), and OperatorBase::informOfPerParticleListener().

◆ have_required_traces_

◆ my_index_

int my_index_
protected

starting index of this object

Definition at line 535 of file OperatorBase.h.

Referenced by MomentumEstimator::addObservables(), EnergyDensityEstimator::addObservables(), SkEstimator::addObservables(), DensityEstimator::addObservables(), BareForce::addObservables(), SpeciesKineticEnergy::addObservables(), SkAllEstimator::addObservables(), StaticStructureFactor::addObservables(), PairCorrEstimator::addObservables(), SelfHealingOverlapLegacy::addObservables(), SpinDensity::addObservables(), LatticeDeviationEstimator::addObservables(), ForwardWalking::addObservables(), ForceChiesaPBCAA::addObservables(), DensityMatrices1B::addObservables(), CoulombPBCAB::addObservables(), OperatorBase::addValue(), ForwardWalking::calculate(), MomentumEstimator::evaluate(), SkEstimator::evaluate(), SkAllEstimator::evaluate(), PairCorrEstimator::evaluate(), StaticStructureFactor::evaluate(), SelfHealingOverlapLegacy::evaluate(), SpinDensity::evaluate(), MomentumEstimator::makeClone(), SkEstimator::makeClone(), SkAllEstimator::makeClone(), MomentumEstimator::registerCollectables(), DensityEstimator::registerCollectables(), SkEstimator::registerCollectables(), SkAllEstimator::registerCollectables(), StaticStructureFactor::registerCollectables(), PairCorrEstimator::registerCollectables(), SelfHealingOverlapLegacy::registerCollectables(), SpinDensity::registerCollectables(), OperatorBase::registerObservables(), MomentumEstimator::setObservables(), SkEstimator::setObservables(), SkAllEstimator::setObservables(), SpeciesKineticEnergy::setObservables(), LatticeDeviationEstimator::setObservables(), ForwardWalking::setObservables(), OperatorBase::setObservables(), MomentumEstimator::setParticlePropertyList(), SkEstimator::setParticlePropertyList(), SkAllEstimator::setParticlePropertyList(), ForwardWalking::setParticlePropertyList(), and OperatorBase::setParticlePropertyList().

◆ name_

std::string name_
protected

name of this object

Definition at line 527 of file OperatorBase.h.

Referenced by ACForce::add2Hamiltonian(), OperatorBase::add2Hamiltonian(), SpeciesKineticEnergy::addObservables(), LatticeDeviationEstimator::addObservables(), ForceChiesaPBCAA::addObservables(), CoulombPBCAB::addObservables(), OperatorBase::addValue(), BareForce::BareForce(), GridExternalPotential::checkoutParticleQuantities(), NonLocalECPotential::checkoutParticleQuantities(), BareKineticEnergy::checkoutParticleQuantities(), HarmonicExternalPotential::checkoutParticleQuantities(), LocalECPotential::checkoutParticleQuantities(), CoulombPotential< T >::checkoutParticleQuantities(), CoulombPBCAB::checkoutParticleQuantities(), CoulombPBCAA::checkoutParticleQuantities(), OperatorBase::checkoutScalarQuantities(), GridExternalPotential::contributeParticleQuantities(), NonLocalECPotential::contributeParticleQuantities(), HarmonicExternalPotential::contributeParticleQuantities(), BareKineticEnergy::contributeParticleQuantities(), LocalECPotential::contributeParticleQuantities(), CoulombPotential< T >::contributeParticleQuantities(), CoulombPBCAB::contributeParticleQuantities(), CoulombPBCAA::contributeParticleQuantities(), OperatorBase::contributeScalarQuantities(), ForceCeperley::ForceCeperley(), ForceChiesaPBCAA::ForceChiesaPBCAA(), SpeciesKineticEnergy::get(), DensityEstimator::get(), LatticeDeviationEstimator::get(), PairCorrEstimator::get(), OperatorBase::getName(), BareKineticEnergy::mw_evaluatePerParticle(), CoulombPBCAB::mw_evaluatePerParticle(), EnergyDensityEstimator::put(), StaticStructureFactor::put(), SelfHealingOverlapLegacy::put(), SpinDensity::put(), OrbitalImages::put(), EnergyDensityEstimator::registerCollectables(), SkEstimator::registerCollectables(), DensityEstimator::registerCollectables(), SkAllEstimator::registerCollectables(), SpeciesKineticEnergy::registerCollectables(), StaticStructureFactor::registerCollectables(), SpinDensity::registerCollectables(), LatticeDeviationEstimator::registerCollectables(), DensityMatrices1B::registerCollectables(), OperatorBase::registerObservables(), StaticStructureFactor::report(), StaticStructureFactor::reset(), SpinDensity::reset(), SelfHealingOverlapLegacy::SelfHealingOverlapLegacy(), and StressPBC::StressPBC().

◆ new_value_

Return_t new_value_
protected

a new value for a proposed move

Definition at line 538 of file OperatorBase.h.

Referenced by CoulombPBCAA::updateSource().

◆ quantum_domain_

◆ request_

◆ streaming_particles_

◆ streaming_scalars_

◆ t_walker_

◆ update_mode_

◆ value_

Return_t value_
protected

current value

Definition at line 524 of file OperatorBase.h.

Referenced by OperatorBase::collectScalarQuantities(), CoulombPBCAA::CoulombPBCAA(), CoulombPotential< T >::CoulombPotential(), NonLocalECPotential::evalIonDerivsImpl(), ChiesaCorrection::evaluate(), SpeciesKineticEnergy::evaluate(), SOECPotential::evaluate(), GridExternalPotential::evaluate(), LatticeDeviationEstimator::evaluate(), Pressure::evaluate(), HarmonicExternalPotential::evaluate(), NonLocalECPotential::evaluate(), BareKineticEnergy::evaluate(), ACForce::evaluate(), LocalECPotential::evaluate(), L2Potential::evaluate(), MPC::evaluate(), CoulombPBCAA::evaluate(), CoulombPBCAB::evaluate(), CoulombPotential< T >::evaluate(), LocalECPotential::evaluate_orig(), BareKineticEnergy::evaluate_orig(), GridExternalPotential::evaluate_sp(), LocalECPotential::evaluate_sp(), HarmonicExternalPotential::evaluate_sp(), BareKineticEnergy::evaluate_sp(), CoulombPBCAB::evaluate_sp(), CoulombPBCAA::evaluate_sp(), SOECPotential::evaluateDeterministic(), NonLocalECPotential::evaluateDeterministic(), SOECPotential::evaluateImpl(), NonLocalECPotential::evaluateImpl(), SOECPotential::evaluateValueAndDerivatives(), NonLocalECPotential::evaluateValueAndDerivatives(), LocalECPotential::evaluateWithIonDerivs(), NonLocalECPotential::evaluateWithIonDerivs(), BareKineticEnergy::evaluateWithIonDerivs(), CoulombPBCAA::evaluateWithIonDerivs(), CoulombPBCAB::evaluateWithIonDerivs(), CoulombPotential< T >::evaluateWithIonDerivs(), NonLocalECPotential::evaluateWithIonDerivsDeterministic(), NonLocalECPotential::evaluateWithToperator(), OperatorBase::getValue(), CoulombPBCAA::mw_evaluate(), BareKineticEnergy::mw_evaluatePerParticle(), CoulombPBCAA::mw_evaluatePerParticle(), CoulombPBCAB::mw_evaluatePerParticle(), LatticeDeviationEstimator::setObservables(), ACForce::setObservables(), OperatorBase::setObservables(), ACForce::setParticlePropertyList(), OperatorBase::setParticlePropertyList(), CoulombPBCAA::updateSource(), and CoulombPotential< T >::updateSource().

◆ value_sample_

Array<RealType, 1>* value_sample_
private

array to store sample value

Definition at line 606 of file OperatorBase.h.

Referenced by OperatorBase::checkoutScalarQuantities(), and OperatorBase::deleteScalarQuantities().

◆ qmcplusplus::Pressure

struct qmcplusplus::Pressure

Evaluate the Bare Pressure.

P=/frac{2T+V}{d* /Omega} where d is the dimension of space and /Omega is the volume.

Definition at line 32 of file Pressure.h.

+ Inheritance diagram for Pressure:
+ Collaboration diagram for Pressure:

Public Types

using WP = WalkerProperties::Indexes
 
- 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

 Pressure (ParticleSet &P)
 constructor More...
 
 ~Pressure () override
 destructor More...
 
bool dependsOnWaveFunction () const override
 return true if this operator depends on a wavefunction More...
 
std::string getClassName () const override
 return class name More...
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
bool put (xmlNodePtr cur) override
 implements the virtual function. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) final
 
- Public Member Functions inherited from OperatorBase
 OperatorBase ()
 Construct a new Operator Base object Default and unique empty constructor. More...
 
virtual ~OperatorBase ()=default
 
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 addObservables (PropertySetType &plist, BufferType &collectables)
 named values to the property list Default implementaton uses addValue(plist_) 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 registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 
virtual void setObservables (PropertySetType &plist)
 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...
 
virtual void setParticlePropertyList (PropertySetType &plist, int offset)
 
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

double pNorm
 

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_
 

Member Typedef Documentation

◆ WP

Definition at line 34 of file Pressure.h.

Constructor & Destructor Documentation

◆ Pressure()

Pressure ( ParticleSet P)
inline

constructor

Pressure operators need to be re-evaluated during optimization.

Definition at line 43 of file Pressure.h.

References ParticleSet::getLattice(), OperatorBase::OPTIMIZABLE, Pressure::pNorm, and OperatorBase::update_mode_.

44  {
45  update_mode_.set(OPTIMIZABLE, 1);
46  pNorm = 1.0 / (P.getLattice().DIM * P.getLattice().Volume);
47  }
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521

◆ ~Pressure()

~Pressure ( )
inlineoverride

destructor

Definition at line 49 of file Pressure.h.

49 {}

Member Function Documentation

◆ dependsOnWaveFunction()

bool dependsOnWaveFunction ( ) const
inlineoverridevirtual

return true if this operator depends on a wavefunction

Reimplemented from OperatorBase.

Definition at line 51 of file Pressure.h.

51 { return true; }

◆ evaluate()

Return_t evaluate ( ParticleSet P)
inlineoverridevirtual

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 55 of file Pressure.h.

References Pressure::pNorm, ParticleSet::PropertyList, and OperatorBase::value_.

56  {
57  value_ = 2.0 * P.PropertyList[WP::LOCALENERGY] - P.PropertyList[WP::LOCALPOTENTIAL];
58  value_ *= pNorm;
59  return 0.0;
60  }
Return_t value_
current value
Definition: OperatorBase.h:524

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 127 of file Pressure.h.

128  {
129  os << "Pressure";
130  return true;
131  }

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 52 of file Pressure.h.

52 { return "Pressure"; }

◆ makeClone()

std::unique_ptr<OperatorBase> makeClone ( ParticleSet qp,
TrialWaveFunction psi 
)
inlinefinalvirtual

Implements OperatorBase.

Definition at line 133 of file Pressure.h.

134  {
135  return std::make_unique<Pressure>(qp);
136  }

◆ put()

bool put ( xmlNodePtr  cur)
inlineoverridevirtual

implements the virtual function.

Nothing is done but should check the mass

Implements OperatorBase.

Definition at line 67 of file Pressure.h.

67 { return true; }

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
inlineoverridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 53 of file Pressure.h.

References ParticleSet::getLattice(), and Pressure::pNorm.

53 { pNorm = 1.0 / (P.getLattice().DIM * P.getLattice().Volume); }

Member Data Documentation

◆ pNorm

double pNorm

◆ qmcplusplus::SpaceWarpTransformation

class qmcplusplus::SpaceWarpTransformation

This implements the differential space warp transformation for ZVZB estimators given by Sorella & Capriotti J.

Chem. Phys., 133, 23411 (2010), https://doi.org/10.1063/1.3516208

Definition at line 26 of file SpaceWarpTransformation.h.

+ Inheritance diagram for SpaceWarpTransformation:
+ Collaboration diagram for SpaceWarpTransformation:

Public Member Functions

 SpaceWarpTransformation (ParticleSet &elns, const ParticleSet &ions)
 
RealType f (RealType r)
 Space warp transformation function F(r). More...
 
RealType df (RealType r)
 Derivative of space warp transformation function F(r) w.r.t. More...
 
void setPow (RealType swpow_in)
 Sets the exponent for power law space warp transformation. More...
 
void getSWT (int iat, ParticleScalar &w, Force_t &grad_w)
 Generates required space warp quantities to generate the actual "Space Warp" contribution to the iat-th force component. More...
 
void computeSWT (ParticleSet &elec, const ParticleSet &ions, Force_t &dEl, ParticleGradient &dlogpsi, Force_t &el_contribution, Force_t &psi_contribution)
 Takes in precomputed grad(E_L) and grad(logPsi) and computes the ZV and ZB space warp contributions to the force. More...
 

Private Types

using ParticleScalar = ParticleSet::ParticleScalar
 
using Force_t = ParticleSet::ParticlePos
 
using ParticleGradient = ParticleSet::ParticleGradient
 

Private Member Functions

void computeSWTIntermediates (ParticleSet &P, const ParticleSet &ions)
 Computes intermediate matrices required to build all space warp components and gradients. More...
 

Private Attributes

const int myTableIndex
 The electron-ion table index in electron table. More...
 
const int Nelec
 
const int Nions
 
RealType swpow
 Power of space warp transformation. Right now, r^{-swpow}. More...
 
Matrix< RealTypewarpval
 Nelec x Nion matrix of F(|r_i-R_J|) More...
 
Matrix< PosTypegradval
 Nelec x Nion matrix of F(|r_i-R_J|) More...
 

Additional Inherited Members

- 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 > >
 

Member Typedef Documentation

◆ Force_t

Definition at line 29 of file SpaceWarpTransformation.h.

◆ ParticleGradient

Definition at line 30 of file SpaceWarpTransformation.h.

◆ ParticleScalar

Definition at line 28 of file SpaceWarpTransformation.h.

Constructor & Destructor Documentation

◆ SpaceWarpTransformation()

SpaceWarpTransformation ( ParticleSet elns,
const ParticleSet ions 
)

Definition at line 6 of file SpaceWarpTransformation.cpp.

References SpaceWarpTransformation::gradval, SpaceWarpTransformation::Nelec, SpaceWarpTransformation::Nions, Matrix< T, Alloc >::resize(), and SpaceWarpTransformation::warpval.

7  : myTableIndex(elns.addTable(ions)), Nelec(elns.getTotalNum()), Nions(ions.getTotalNum()), swpow(4.0)
8 {
10  gradval.resize(Nelec, Nions);
11 }
Matrix< PosType > gradval
Nelec x Nion matrix of F(|r_i-R_J|)
RealType swpow
Power of space warp transformation. Right now, r^{-swpow}.
Matrix< RealType > warpval
Nelec x Nion matrix of F(|r_i-R_J|)
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
const int myTableIndex
The electron-ion table index in electron table.

Member Function Documentation

◆ computeSWT()

void computeSWT ( ParticleSet elec,
const ParticleSet ions,
Force_t dEl,
ParticleGradient dlogpsi,
Force_t el_contribution,
Force_t psi_contribution 
)

Takes in precomputed grad(E_L) and grad(logPsi) and computes the ZV and ZB space warp contributions to the force.

Parameters
[in]elec,electronparticle set.
[in]ions,ionparticle set.
[in]dEl,grad_i(E_L)for each electron i. E_L is the local energy.
[in]dlogpsi,grad_i(logPsi)for each electron i.
[out]el_contribution,Thezero-variance contribution from space warp.
[out]psi_contribution,thezero-bias contribution from space warp. Modifies the grad_I(logPsi) terms.

Definition at line 53 of file SpaceWarpTransformation.cpp.

References SpaceWarpTransformation::computeSWTIntermediates(), qmcplusplus::convertToReal(), SpaceWarpTransformation::getSWT(), SpaceWarpTransformation::Nelec, SpaceWarpTransformation::Nions, and Vector< T, Alloc >::resize().

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

59 {
60  el_contribution = 0;
61  psi_contribution = 0;
63  Force_t gradw;
64  w.resize(Nelec);
65  gradw.resize(Nelec);
66 
67  PosType gwfn = 0;
68  computeSWTIntermediates(P, ions);
69 
70  for (size_t iat = 0; iat < Nions; iat++)
71  {
72  w = 0;
73  gradw = 0;
74  getSWT(iat, w, gradw);
75  for (size_t iel = 0; iel < Nelec; iel++)
76  {
77  el_contribution[iat] += w[iel] * dEl[iel];
78 
79 #if defined(QMC_COMPLEX)
80  convertToReal(dlogpsi[iel], gwfn);
81 #else
82  gwfn = dlogpsi[iel];
83 #endif
84  psi_contribution[iat] += w[iel] * gwfn + 0.5 * gradw[iel];
85  }
86  }
87  //REMOVE ME
88  //app_log()<<"FINAL SPACE WARP TRANSFORM\n";
89  //app_log()<<" Using dEl="<<dEl<<std::endl;
90  //app_log()<<" Using dlogpsi="<<dlogpsi<<std::endl;
91 
92  //app_log()<<"Space warp EL piece\n";
93  //app_log()<<" EL = "<<el_contribution<<std::endl;
94  //app_log()<<"Space warp logpsi piece\n";
95  //app_log()<<" psipiece = "<<psi_contribution<<std::endl;
96 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
void convertToReal(const T1 &in, T2 &out)
generic conversion from type T1 to type T2 using implicit conversion
Definition: ConvertToReal.h:32
QMCTraits::PosType PosType
ParticleSet::ParticleScalar ParticleScalar
void computeSWTIntermediates(ParticleSet &P, const ParticleSet &ions)
Computes intermediate matrices required to build all space warp components and gradients.
void getSWT(int iat, ParticleScalar &w, Force_t &grad_w)
Generates required space warp quantities to generate the actual "Space Warp" contribution to the iat-...

◆ computeSWTIntermediates()

void computeSWTIntermediates ( ParticleSet P,
const ParticleSet ions 
)
private

Computes intermediate matrices required to build all space warp components and gradients.

The intermediates calculated are "warpval" and "gradval".

Parameters
[in]P,theelectron particle set.
[in]ions,theion particle set.

Definition at line 19 of file SpaceWarpTransformation.cpp.

References SpaceWarpTransformation::df(), SpaceWarpTransformation::f(), ParticleSet::getDistTableAB(), SpaceWarpTransformation::gradval, SpaceWarpTransformation::myTableIndex, SpaceWarpTransformation::Nelec, SpaceWarpTransformation::Nions, and SpaceWarpTransformation::warpval.

Referenced by SpaceWarpTransformation::computeSWT().

20 {
21  const auto& d_ab(P.getDistTableAB(myTableIndex));
22  for (size_t iel = 0; iel < Nelec; ++iel)
23  {
24  const auto& dist = d_ab.getDistRow(iel);
25  const auto& dr = d_ab.getDisplRow(iel);
26  for (size_t ionid = 0; ionid < Nions; ++ionid)
27  {
28  warpval[iel][ionid] = f(dist[ionid]);
29  gradval[iel][ionid] = -dr[ionid] *
30  (df(dist[ionid]) / dist[ionid]); //because there's a -1 in distance table displacement definition. R-r :(.
31  }
32  }
33 }
Matrix< PosType > gradval
Nelec x Nion matrix of F(|r_i-R_J|)
RealType df(RealType r)
Derivative of space warp transformation function F(r) w.r.t.
Matrix< RealType > warpval
Nelec x Nion matrix of F(|r_i-R_J|)
const int myTableIndex
The electron-ion table index in electron table.
RealType f(RealType r)
Space warp transformation function F(r).

◆ df()

Derivative of space warp transformation function F(r) w.r.t.

r.

Parameters
[in]r,thedistance
[out]valueof F'(r)

Definition at line 15 of file SpaceWarpTransformation.cpp.

References qmcplusplus::pow(), and SpaceWarpTransformation::swpow.

Referenced by SpaceWarpTransformation::computeSWTIntermediates(), and qmcplusplus::TEST_CASE().

15 { return -swpow * std::pow(r, -(swpow + 1)); }
RealType swpow
Power of space warp transformation. Right now, r^{-swpow}.
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)

◆ f()

Space warp transformation function F(r).

Parameters
[in]r,thedistance
[out]valueof F(r)

Definition at line 13 of file SpaceWarpTransformation.cpp.

References qmcplusplus::pow(), and SpaceWarpTransformation::swpow.

Referenced by SpaceWarpTransformation::computeSWTIntermediates(), and qmcplusplus::TEST_CASE().

13 { return std::pow(r, -swpow); }
RealType swpow
Power of space warp transformation. Right now, r^{-swpow}.
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)

◆ getSWT()

void getSWT ( int  iat,
ParticleScalar w,
Force_t grad_w 
)

Generates required space warp quantities to generate the actual "Space Warp" contribution to the iat-th force component.

Parameters
[in]iatthe ion index for the force.
[out]w,w_iat(r_i)for each i, where i is the electron index.
[out]grad_w,grad_iw_iat(r_i) for each i, where i is the electron index.

Definition at line 37 of file SpaceWarpTransformation.cpp.

References SpaceWarpTransformation::gradval, SpaceWarpTransformation::Nelec, SpaceWarpTransformation::Nions, and SpaceWarpTransformation::warpval.

Referenced by SpaceWarpTransformation::computeSWT().

38 {
39  for (size_t iel = 0; iel < Nelec; iel++)
40  {
41  RealType warpdenom = 0.0;
42  PosType denomgrad = 0.0;
43  for (size_t ionid = 0; ionid < Nions; ionid++)
44  {
45  warpdenom += warpval[iel][ionid];
46  denomgrad += gradval[iel][ionid];
47  }
48  w[iel] = warpval[iel][iat] / warpdenom;
49  grad_w[iel] = gradval[iel][iat] / warpdenom - w[iel] * denomgrad / warpdenom;
50  }
51 }
Matrix< PosType > gradval
Nelec x Nion matrix of F(|r_i-R_J|)
Matrix< RealType > warpval
Nelec x Nion matrix of F(|r_i-R_J|)
QMCTraits::PosType PosType
QMCTraits::RealType RealType

◆ setPow()

void setPow ( RealType  swpow_in)
inline

Sets the exponent for power law space warp transformation.

Parameters
[in]swpow_inthe exponent

Definition at line 53 of file SpaceWarpTransformation.h.

References SpaceWarpTransformation::swpow.

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

53 { swpow = swpow_in; };
RealType swpow
Power of space warp transformation. Right now, r^{-swpow}.

Member Data Documentation

◆ gradval

◆ myTableIndex

const int myTableIndex
private

The electron-ion table index in electron table.

Definition at line 91 of file SpaceWarpTransformation.h.

Referenced by SpaceWarpTransformation::computeSWTIntermediates().

◆ Nelec

◆ Nions

◆ swpow

RealType swpow
private

Power of space warp transformation. Right now, r^{-swpow}.

Definition at line 96 of file SpaceWarpTransformation.h.

Referenced by SpaceWarpTransformation::df(), SpaceWarpTransformation::f(), and SpaceWarpTransformation::setPow().

◆ warpval