QMCPACK
SOECPotential.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2020 QMCPACK developers.
6 //
7 // File developed by: Cody A. Melton, cmelton@sandia.gov, Sandia National Laboratories
8 //
9 // File created by: Cody A. Melton, cmelton@sandia.gov, Sandia National Laboratories
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef QMCPLUSPLUS_SO_ECPOTENTIAL_H
13 #define QMCPLUSPLUS_SO_ECPOTENTIAL_H
14 
16 #include "Particle/NeighborLists.h"
17 
18 namespace qmcplusplus
19 {
20 template<typename T>
21 struct NLPPJob;
22 
23 namespace testing
24 {
25 class TestSOECPotential;
26 }
27 
29 {
32 
33 public:
34  SOECPotential(ParticleSet& ions, ParticleSet& els, TrialWaveFunction& psi, bool use_exact_spin);
35  ~SOECPotential() override;
36 
37  bool dependsOnWaveFunction() const override { return true; }
38  std::string getClassName() const override { return "SOECPotential"; }
39  void resetTargetParticleSet(ParticleSet& P) override;
40 
41  Return_t evaluate(ParticleSet& P) override;
43 
45  const opt_variables_type& optvars,
46  const Vector<ValueType>& dlogpsi,
47  Vector<ValueType>& dhpsioverpsi) override;
48 
51  const RefVectorWithLeader<ParticleSet>& p_list) const override;
52 
56  const std::vector<ListenerVector<Real>>& listeners,
57  const std::vector<ListenerVector<Real>>& listeners_ions) const override;
58 
59  bool put(xmlNodePtr cur) override { return true; }
60 
61  bool get(std::ostream& os) const override
62  {
63  os << "SOECPotential: " << ion_config_.getName();
64  return true;
65  }
66 
67  std::unique_ptr<OperatorBase> makeClone(ParticleSet& qp, TrialWaveFunction& psi) final;
68 
69  void addComponent(int groupID, std::unique_ptr<SOECPComponent>&& pp);
70 
72 
73  //initialize shared resource and hand to collection
74  void createResource(ResourceCollection& collection) const override;
75 
76  //acquire a shared resource
77  void acquireResource(ResourceCollection& collection, const RefVectorWithLeader<OperatorBase>& o_list) const override;
78 
79  //return a shared resource to a collection
80  void releaseResource(ResourceCollection& collection, const RefVectorWithLeader<OperatorBase>& o_list) const override;
81 
82 protected:
84  std::vector<SOECPComponent*> pp_;
85  std::vector<std::unique_ptr<SOECPComponent>> ppset_;
88  static void mw_evaluateImpl(const RefVectorWithLeader<OperatorBase>& o_list,
91  std::optional<ListenerOption<Real>> listeners,
92  bool keep_grid = false);
93 
94 private:
95  ///number of ions
96  int num_ions_;
97  ///index of distance table for ion-el pair
99  ///reference to the electrons
101  ///neighborlist of electrons
103  ///neighborlist of ions
105  //job list for evaluation
106  std::vector<std::vector<NLPPJob<RealType>>> sopp_jobs_;
107  //multi walker resource
109 
110  //flag to use fast evaluation
111  const bool use_exact_spin_;
112 
113  void evaluateImpl(ParticleSet& elec, bool keep_grid = false);
114 
115  //for testing
117 };
118 
119 } // namespace qmcplusplus
120 
121 #endif
void evaluateImpl(ParticleSet &elec, bool keep_grid=false)
std::vector< std::unique_ptr< SOECPComponent > > ppset_
Definition: SOECPotential.h:85
const std::string & getName() const
return the name
std::unique_ptr< OperatorBase > makeClone(ParticleSet &qp, TrialWaveFunction &psi) final
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
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.
QTBase::RealType RealType
Definition: Configuration.h:58
ResourceHandle manages the temporary resource referenced from a collection.
Return_t evaluateValueAndDerivatives(ParticleSet &P, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
Evaluate value and derivatives wrt the optimizables.
bool put(xmlNodePtr cur) override
Read the input parameter.
Definition: SOECPotential.h:59
An object of this type is a listener expecting a callback to the report function with a vector of val...
Definition: Listener.hpp:38
std::vector< std::vector< NLPPJob< RealType > > > sopp_jobs_
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
Return a shared resource to a collection.
NeighborLists ion_neighbor_elecs_
neighborlist of ions
void createResource(ResourceCollection &collection) const override
Initialize a shared resource and hand it to a collection.
int my_table_index_
index of distance table for ion-el pair
Definition: SOECPotential.h:98
Return_t evaluate(ParticleSet &P) override
Evaluate the local energy contribution of this component.
std::vector< SOECPComponent * > pp_
Definition: SOECPotential.h:84
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
QMCTraits::RealType Real
Definition: SOECPotential.h:31
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
NeighborLists elec_neighbor_ions_
neighborlist of electrons
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
Acquire a shared resource from a collection.
static void mw_evaluateImpl(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, std::optional< ListenerOption< Real >> listeners, bool keep_grid=false)
ResourceHandle< SOECPotentialMultiWalkerResource > mw_res_handle_
int num_ions_
number of ions
Definition: SOECPotential.h:96
void setRandomGenerator(RandomBase< FullPrecRealType > *rng) override
Set the Random Generator object TODO: add docs.
Definition: SOECPotential.h:71
bool dependsOnWaveFunction() const override
return true if this operator depends on a wavefunction
Definition: SOECPotential.h:37
An abstract class for Local Energy operators.
Definition: OperatorBase.h:59
Return_t evaluateDeterministic(ParticleSet &P) override
Evaluate the local energy contribution of this component, deterministically based on current state...
std::string getClassName() const override
return class name
Definition: SOECPotential.h:38
Class to represent a many-body trial wave function.
void addComponent(int groupID, std::unique_ptr< SOECPComponent > &&pp)
ParticleSet & peln_
reference to the electrons
TrialWaveFunction & psi_
Definition: SOECPotential.h:87
RandomBase< FullPrecRealType > * my_rng_
Definition: SOECPotential.h:83
SOECPotential(ParticleSet &ions, ParticleSet &els, TrialWaveFunction &psi, bool use_exact_spin)
constructor
Convenience container for common optional element to mw_eval.._impl.
Definition: Listener.hpp:76
void resetTargetParticleSet(ParticleSet &P) override
Reset the data with the target ParticleSet.
BareKineticEnergy::Return_t Return_t
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