QMCPACK
GridExternalPotential Class Reference

This class allows one to read in an arbitrary external potential. More...

+ Inheritance diagram for GridExternalPotential:
+ Collaboration diagram for GridExternalPotential:

Public Member Functions

 GridExternalPotential (ParticleSet &P)
 
std::string getClassName () const override
 return class name More...
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
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 &P, TrialWaveFunction &psi) final
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
Return_t evaluate (ParticleSet &P, std::vector< NonLocalData > &Txy)
 
void contributeParticleQuantities () override
 
void checkoutParticleQuantities (TraceManager &tm) override
 
void deleteParticleQuantities () 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...
 

Private Member Functions

Return_t evaluate_sp (ParticleSet &P)
 

Private Attributes

const ParticleSetps_
 
std::shared_ptr< UBspline_3d_d > spline_data_
 
Array< TraceReal, 1 > * v_sample_
 single particle trace sample array 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 setComputeForces (bool compute)
 
void setEnergyDomain (EnergyDomains edomain)
 Set the Energy Domain. More...
 
void setQuantumDomain (QuantumDomains qdomain)
 set quantum domain More...
 
void oneBodyQuantumDomain (const ParticleSet &P)
 set quantum domain for one-body operator More...
 
void twoBodyQuantumDomain (const ParticleSet &P)
 set quantum domain for two-body operator More...
 
void twoBodyQuantumDomain (const ParticleSet &P1, const ParticleSet &P2)
 set quantum domain for two-body operator More...
 
void addValue (PropertySetType &plist)
 named values to the property list More...
 
- Protected Attributes inherited from OperatorBase
std::bitset< 8 > update_mode_
 set the current update mode More...
 
Return_t value_
 current value More...
 
std::string name_
 name of this object More...
 
TraceRequest request_
 whether traces are being collected More...
 
int my_index_
 starting index of this object More...
 
Return_t new_value_
 a new value for a proposed move More...
 
Walker_tt_walker_
 reference to the current walker More...
 
bool streaming_particles_
 
bool have_required_traces_
 

Detailed Description

This class allows one to read in an arbitrary external potential.

Definition at line 27 of file GridExternalPotential.h.

Constructor & Destructor Documentation

◆ GridExternalPotential()

Definition at line 21 of file GridExternalPotential.cpp.

References OperatorBase::oneBodyQuantumDomain(), OperatorBase::POTENTIAL, and OperatorBase::setEnergyDomain().

21  : ps_(P)
22 {
25 }
void oneBodyQuantumDomain(const ParticleSet &P)
set quantum domain for one-body operator
void setEnergyDomain(EnergyDomains edomain)
Set the Energy Domain.

Member Function Documentation

◆ checkoutParticleQuantities()

void checkoutParticleQuantities ( TraceManager tm)
overridevirtual

Reimplemented from OperatorBase.

Definition at line 144 of file GridExternalPotential.cpp.

References TraceManager::checkout_real(), OperatorBase::name_, GridExternalPotential::ps_, OperatorBase::request_, TraceRequest::streaming_array(), OperatorBase::streaming_particles_, and GridExternalPotential::v_sample_.

145 {
148  v_sample_ = tm.checkout_real<1>(name_, ps_);
149 }
bool streaming_array(const std::string &name)
Definition: TraceManager.h:249
Array< TraceReal, 1 > * v_sample_
single particle trace sample array
TraceRequest request_
whether traces are being collected
Definition: OperatorBase.h:531
std::string name_
name of this object
Definition: OperatorBase.h:527

◆ contributeParticleQuantities()

void contributeParticleQuantities ( )
overridevirtual

Reimplemented from OperatorBase.

Definition at line 142 of file GridExternalPotential.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 151 of file GridExternalPotential.cpp.

References OperatorBase::streaming_particles_, and GridExternalPotential::v_sample_.

152 {
154  delete v_sample_;
155 }
Array< TraceReal, 1 > * v_sample_
single particle trace sample array

◆ evaluate() [1/2]

GridExternalPotential::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 112 of file GridExternalPotential.cpp.

References GridExternalPotential::evaluate_sp(), ParticleSet::getLattice(), ParticleSet::getTotalNum(), ParticleSet::R, GridExternalPotential::spline_data_, OperatorBase::streaming_particles_, and OperatorBase::value_.

Referenced by GridExternalPotential::evaluate().

113 {
114 #if !defined(REMOVE_TRACEMANAGER)
116  value_ = evaluate_sp(P);
117  else
118  {
119 #endif
120  value_ = 0.0;
121  for (int i = 0; i < P.getTotalNum(); ++i)
122  {
123  PosType r = P.R[i];
124  P.getLattice().applyMinimumImage(r);
125  double val = 0.0;
126  eval_UBspline_3d_d(spline_data_.get(), r[0], r[1], r[2], &val);
127 
128  value_ += val;
129  }
130 #if !defined(REMOVE_TRACEMANAGER)
131  }
132 #endif
133  return value_;
134 }
QMCTraits::PosType PosType
Return_t value_
current value
Definition: OperatorBase.h:524
std::shared_ptr< UBspline_3d_d > spline_data_

◆ evaluate() [2/2]

GridExternalPotential::Return_t evaluate ( ParticleSet P,
std::vector< NonLocalData > &  Txy 
)

Definition at line 136 of file GridExternalPotential.cpp.

References GridExternalPotential::evaluate().

137 {
138  return evaluate(P);
139 }
Return_t evaluate(ParticleSet &P) override
Evaluate the local energy contribution of this component.

◆ evaluate_sp()

GridExternalPotential::Return_t evaluate_sp ( ParticleSet P)
private

Definition at line 157 of file GridExternalPotential.cpp.

References qmcplusplus::dot(), ParticleSet::getTotalNum(), ParticleSet::R, GridExternalPotential::v_sample_, and OperatorBase::value_.

Referenced by GridExternalPotential::evaluate().

158 {
159  Array<TraceReal, 1>& V_samp = *v_sample_;
160  value_ = 0.0;
161  for (int i = 0; i < P.getTotalNum(); ++i)
162  {
163  PosType r = P.R[i];
164  RealType v1 = dot(r, r);
165  V_samp(i) = v1;
166  value_ += v1;
167  }
168  return value_;
169 }
Array< TraceReal, 1 > * v_sample_
single particle trace sample array
QMCTraits::PosType PosType
QMCTraits::RealType RealType
Return_t value_
current value
Definition: OperatorBase.h:524
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 99 of file GridExternalPotential.cpp.

100 {
101  os << "External grid potential" << std::endl;
102  return true;
103 }

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 32 of file GridExternalPotential.h.

32 { return "GridExternalPotential"; }

◆ makeClone()

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

Implements OperatorBase.

Definition at line 106 of file GridExternalPotential.cpp.

107 {
108  return std::make_unique<GridExternalPotential>(*this);
109 }

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

Read the input parameter.

Parameters
curxml node for a OperatorBase object

Implements OperatorBase.

Definition at line 27 of file GridExternalPotential.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_log(), Array< T, D, ALLOC >::data(), hdf_archive::open(), OhmmsAttributeSet::put(), hdf_archive::read(), GridExternalPotential::spline_data_, and qmcplusplus::sqrt().

28 {
29  using std::sqrt;
30 
31 
32  OhmmsAttributeSet attrib;
33 
34  /*
35  Future update must include differing grid sizes in the x, y, and z directions.
36 
37  Everything is the same size for now.
38  */
39 
40  Ugrid grid;
41  grid.start = -2.0;
42  grid.end = 2.0;
43  grid.num = 11;
44  BCtype_d BC;
45  BC.lCode = NATURAL;
46  BC.rCode = NATURAL;
47  std::string file_name;
48  std::string dataset_name;
49  bool pbc;
50 
51  attrib.add(grid.start, "start");
52  attrib.add(grid.end, "end");
53  attrib.add(grid.num, "num");
54  attrib.add(file_name, "file_name");
55  attrib.add(dataset_name, "dataset_name");
56  attrib.add(pbc, "pbc");
57  attrib.put(cur);
58 
59  double delta = (grid.end - grid.start) / (grid.num - 1);
60 
61 
62  if (pbc)
63  {
64  BC.lCode = PERIODIC;
65  BC.rCode = PERIODIC;
66  delta = (grid.end - grid.start) / (grid.num);
67  }
68 
69  Array<double, 3> data(grid.num, grid.num, grid.num);
70 
71  hdf_archive hin;
72  bool read_okay = hin.open(file_name, H5F_ACC_RDONLY);
73  if (!read_okay)
74  {
75  app_log() << "Failed to open HDF5 file: " << file_name << "." << std::endl;
76  }
77  else
78  {
79  app_log() << " ==============================\n"
80  << " Information of grid:\n"
81  << " Grid start: " << grid.start << std::endl
82  << " Grid end: " << grid.end << std::endl
83  << " Grid num: " << grid.num << std::endl
84  << " Grid delta: " << delta << std::endl
85  << " Grid file_name: " << file_name << std::endl
86  << " Grid dataset_name: " << dataset_name << std::endl
87  << " Periodic: " << pbc << std::endl
88  << " ==============================\n";
89  }
90 
91  hin.read(data, dataset_name);
92 
93  spline_data_.reset(create_UBspline_3d_d(grid, grid, grid, BC, BC, BC, data.data()), destroy_Bspline);
94 
95  return true;
96 }
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
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
std::shared_ptr< UBspline_3d_d > spline_data_
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)
inlineoverridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 34 of file GridExternalPotential.h.

34 {}

Member Data Documentation

◆ ps_

const ParticleSet& ps_
private

◆ spline_data_

std::shared_ptr<UBspline_3d_d> spline_data_
private

◆ v_sample_


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