QMCPACK
BasisSetBase.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
8 // Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
9 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
10 // Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
11 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
12 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
13 //
14 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
15 //////////////////////////////////////////////////////////////////////////////////////
16 
17 
18 /** @file BasisSetBase.h
19  * @brief Declaration of a base class of BasisSet
20  */
21 #ifndef QMCPLUSPLUS_BASISSETBASE_H
22 #define QMCPLUSPLUS_BASISSETBASE_H
23 
24 #include "Particle/ParticleSet.h"
28 
29 
30 namespace qmcplusplus
31 {
32 /** base class for a basis set
33  *
34  * Define a common storage for the derived classes and
35  * provides a minimal set of interfaces to get/set BasisSetSize.
36  */
37 template<typename T>
38 struct BasisSetBase : public OrbitalSetTraits<T>
39 {
40  enum
41  {
43  };
58 
59 
60  ///size of the basis set
62  ///index of the particle
64  ///counter to keep track
65  unsigned long Counter;
66  ///phi[i] the value of the i-th basis set
68  ///dphi[i] the gradient of the i-th basis set
70  ///d2phi[i] the laplacian of the i-th basis set
72  ///grad_grad_Phi[i] the full hessian of the i-th basis set
74  ///grad_grad_grad_Phi the full hessian of the i-th basis set
76  ///container to store value, laplacian and gradient
78 
82 
83  ///default constructor
85  ///virtual destructor
86  virtual ~BasisSetBase() {}
87  /** resize the container */
88  void resize(int ntargets)
89  {
90  if (BasisSetSize)
91  {
92  Phi.resize(BasisSetSize);
93  dPhi.resize(BasisSetSize);
94  d2Phi.resize(BasisSetSize);
97  Temp.resize(BasisSetSize, MAXINDEX);
98  Y.resize(ntargets, BasisSetSize);
99  dY.resize(ntargets, BasisSetSize);
100  d2Y.resize(ntargets, BasisSetSize);
101  }
102  else
103  {
104  app_error() << " BasisSetBase::BasisSetSize == 0" << std::endl;
105  }
106  }
107 
108  ///clone the basis set
109  virtual BasisSetBase* makeClone() const = 0;
110  /** return the basis set size */
111  inline IndexType getBasisSetSize() const { return BasisSetSize; }
112 
113  ///resize the basis set
114  virtual void setBasisSetSize(int nbs) = 0;
115 
116  virtual void evaluateWithHessian(const ParticleSet& P, int iat) = 0;
117  virtual void evaluateWithThirdDeriv(const ParticleSet& P, int iat) = 0;
118  virtual void evaluateThirdDerivOnly(const ParticleSet& P, int iat) = 0;
119  virtual void evaluateForWalkerMove(const ParticleSet& P) = 0;
120  virtual void evaluateForWalkerMove(const ParticleSet& P, int iat) = 0;
121  virtual void evaluateForPtclMove(const ParticleSet& P, int iat) = 0;
122  virtual void evaluateAllForPtclMove(const ParticleSet& P, int iat) = 0;
123  virtual void evaluateForPtclMoveWithHessian(const ParticleSet& P, int iat) = 0;
124 };
125 
126 /** Base for real basis set
127  *
128  * Equivalent to BasisSetBase with minimum requirements
129  * Used by LCAO
130  */
131 template<typename T>
133 {
134  using value_type = T;
141 
142  ///size of the basis set
144 
145  virtual ~SoaBasisSetBase() = default;
146  inline int getBasisSetSize() { return BasisSetSize; }
147 
148  virtual SoaBasisSetBase<T>* makeClone() const = 0;
149  virtual void setBasisSetSize(int nbs) = 0;
150 
151  //Evaluates value, gradient, and laplacian for electron "iat". Parks them into a temporary data structure "vgl".
152  virtual void evaluateVGL(const ParticleSet& P, int iat, vgl_type& vgl) = 0;
153  //Evaluates value, gradient, and laplacian for electron "iat". places them in a offload array for batched code.
154  virtual void mw_evaluateVGL(const RefVectorWithLeader<SoaBasisSetBase<T>>& basis_list,
155  const RefVectorWithLeader<ParticleSet>& P_list,
156  int iat,
157  OffloadMWVGLArray& vgl) = 0;
158  //Evaluates value for electron "iat". places it in a offload array for batched code.
159  virtual void mw_evaluateValue(const RefVectorWithLeader<SoaBasisSetBase<T>>& basis_list,
160  const RefVectorWithLeader<ParticleSet>& P_list,
161  int iat,
162  OffloadMWVArray& v) = 0;
163  //Evaluates value for all the electrons of the virtual particles. places it in a offload array for batched code.
164  virtual void mw_evaluateValueVPs(const RefVectorWithLeader<SoaBasisSetBase<T>>& basis_list,
166  OffloadMWVArray& v) = 0;
167  //Evaluates value, gradient, and Hessian for electron "iat". Parks them into a temporary data structure "vgh".
168  virtual void evaluateVGH(const ParticleSet& P, int iat, vgh_type& vgh) = 0;
169  //Evaluates value, gradient, and Hessian, and Gradient Hessian for electron "iat". Parks them into a temporary data structure "vghgh".
170  virtual void evaluateVGHGH(const ParticleSet& P, int iat, vghgh_type& vghgh) = 0;
171  //Evaluates the x,y, and z components of ionic gradient associated with "jion" of value. Parks the raw data into "vgl" container.
172  virtual void evaluateGradSourceV(const ParticleSet& P, int iat, const ParticleSet& ions, int jion, vgl_type& vgl) = 0;
173  //Evaluates the x,y, and z components of ionic gradient associated with "jion" value, gradient, and laplacian.
174  // Parks the raw data into "vghgh" container.
175  virtual void evaluateGradSourceVGL(const ParticleSet& P,
176  int iat,
177  const ParticleSet& ions,
178  int jion,
179  vghgh_type& vghgh) = 0;
180  virtual void evaluateV(const ParticleSet& P, int iat, value_type* restrict vals) = 0;
181 
182  virtual bool is_S_orbital(int mo_idx, int ao_idx) { return false; }
183 
184  /// Determine which orbitals are S-type. Used for cusp correction.
185  virtual void queryOrbitalsForSType(const std::vector<bool>& corrCenter, std::vector<bool>& is_s_orbital) const {}
186 
187  /** initialize a shared resource and hand it to collection
188  */
189  virtual void createResource(ResourceCollection& collection) const {}
190 
191  /** acquire a shared resource from collection
192  */
193  virtual void acquireResource(ResourceCollection& collection,
194  const RefVectorWithLeader<SoaBasisSetBase>& bset_list) const
195  {}
196 
197  /** return a shared resource to collection
198  */
199  virtual void releaseResource(ResourceCollection& collection,
200  const RefVectorWithLeader<SoaBasisSetBase>& bset_list) const
201  {}
202 };
203 
204 } // namespace qmcplusplus
205 #endif
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
Fixed-size array.
Definition: OhmmsTinyMeta.h:30
virtual void evaluateForWalkerMove(const ParticleSet &P)=0
virtual void evaluateWithThirdDeriv(const ParticleSet &P, int iat)=0
GradVector dPhi
dphi[i] the gradient of the i-th basis set
Definition: BasisSetBase.h:69
ValueVector Phi
phi[i] the value of the i-th basis set
Definition: BasisSetBase.h:67
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
virtual void mw_evaluateVGL(const RefVectorWithLeader< SoaBasisSetBase< T >> &basis_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, OffloadMWVGLArray &vgl)=0
virtual void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< SoaBasisSetBase > &bset_list) const
acquire a shared resource from collection
Definition: BasisSetBase.h:193
typename OrbitalSetTraits< T >::RealType RealType
Definition: BasisSetBase.h:44
virtual void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< SoaBasisSetBase > &bset_list) const
return a shared resource to collection
Definition: BasisSetBase.h:199
std::ostream & app_error()
Definition: OutputManager.h:67
virtual void evaluateWithHessian(const ParticleSet &P, int iat)=0
virtual void evaluateVGHGH(const ParticleSet &P, int iat, vghgh_type &vghgh)=0
SoA adaptor class for Vector<TinyVector<T,D> >
BasisSetBase()
default constructor
Definition: BasisSetBase.h:84
base class for a basis set
Definition: BasisSetBase.h:38
typename OrbitalSetTraits< T >::HessType HessType
Definition: BasisSetBase.h:47
#define OHMMS_DIM
Definition: config.h:64
A proxy class to the quantum ParticleSet.
typename OrbitalSetTraits< T >::GradMatrix GradMatrix
Definition: BasisSetBase.h:52
typename OrbitalSetTraits< T >::ValueVector ValueVector
Definition: BasisSetBase.h:49
virtual ~BasisSetBase()
virtual destructor
Definition: BasisSetBase.h:86
ValueMatrix Temp
container to store value, laplacian and gradient
Definition: BasisSetBase.h:77
virtual BasisSetBase * makeClone() const =0
clone the basis set
typename OrbitalSetTraits< T >::GradVector GradVector
Definition: BasisSetBase.h:51
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
typename OrbitalSetTraits< T >::ValueMatrix ValueMatrix
Definition: BasisSetBase.h:50
typename OrbitalSetTraits< T >::HessMatrix HessMatrix
Definition: BasisSetBase.h:54
Tensor<T,D> class for D by D tensor.
Definition: OhmmsTinyMeta.h:32
QTBase::ValueType ValueType
Definition: Configuration.h:60
typename OrbitalSetTraits< T >::ValueType ValueType
Definition: BasisSetBase.h:45
virtual void mw_evaluateValueVPs(const RefVectorWithLeader< SoaBasisSetBase< T >> &basis_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, OffloadMWVArray &v)=0
Array< ValueType, 3, OffloadPinnedAllocator< ValueType > > OffloadMWVGLArray
Definition: BasisSetBase.h:139
typename OrbitalSetTraits< T >::HessVector HessVector
Definition: BasisSetBase.h:53
VectorSoaContainer< T, 10 > vgh_type
Definition: BasisSetBase.h:136
GGGVector grad_grad_grad_Phi
grad_grad_grad_Phi the full hessian of the i-th basis set
Definition: BasisSetBase.h:75
virtual bool is_S_orbital(int mo_idx, int ao_idx)
Definition: BasisSetBase.h:182
virtual void setBasisSetSize(int nbs)=0
typename OrbitalSetTraits< T >::IndexVector IndexVector
Definition: BasisSetBase.h:48
virtual void evaluateThirdDerivOnly(const ParticleSet &P, int iat)=0
virtual void evaluateVGH(const ParticleSet &P, int iat, vgh_type &vgh)=0
virtual void evaluateForPtclMoveWithHessian(const ParticleSet &P, int iat)=0
IndexType getBasisSetSize() const
return the basis set size
Definition: BasisSetBase.h:111
typename OrbitalSetTraits< T >::IndexType IndexType
Definition: BasisSetBase.h:46
unsigned long Counter
counter to keep track
Definition: BasisSetBase.h:65
virtual void evaluateGradSourceVGL(const ParticleSet &P, int iat, const ParticleSet &ions, int jion, vghgh_type &vghgh)=0
VectorSoaContainer< T, 20 > vghgh_type
Definition: BasisSetBase.h:137
virtual void evaluateV(const ParticleSet &P, int iat, value_type *restrict vals)=0
virtual void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to collection
Definition: BasisSetBase.h:189
virtual void evaluateGradSourceV(const ParticleSet &P, int iat, const ParticleSet &ions, int jion, vgl_type &vgl)=0
virtual SoaBasisSetBase< T > * makeClone() const =0
virtual ~SoaBasisSetBase()=default
ValueVector d2Phi
d2phi[i] the laplacian of the i-th basis set
Definition: BasisSetBase.h:71
void resize(int ntargets)
resize the container
Definition: BasisSetBase.h:88
HessVector grad_grad_Phi
grad_grad_Phi[i] the full hessian of the i-th basis set
Definition: BasisSetBase.h:73
IndexType ActivePtcl
index of the particle
Definition: BasisSetBase.h:63
trait class to handel a set of Orbitals
VectorSoaContainer< T, OHMMS_DIM+2 > vgl_type
Definition: BasisSetBase.h:135
virtual void evaluateVGL(const ParticleSet &P, int iat, vgl_type &vgl)=0
virtual void evaluateForPtclMove(const ParticleSet &P, int iat)=0
A D-dimensional Array class based on PETE.
Definition: OhmmsArray.h:25
Array< ValueType, 2, OffloadPinnedAllocator< ValueType > > OffloadMWVArray
Definition: BasisSetBase.h:140
virtual void queryOrbitalsForSType(const std::vector< bool > &corrCenter, std::vector< bool > &is_s_orbital) const
Determine which orbitals are S-type. Used for cusp correction.
Definition: BasisSetBase.h:185
QMCTraits::FullPrecRealType value_type
virtual void mw_evaluateValue(const RefVectorWithLeader< SoaBasisSetBase< T >> &basis_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, OffloadMWVArray &v)=0
IndexType BasisSetSize
size of the basis set
Definition: BasisSetBase.h:61
virtual void evaluateAllForPtclMove(const ParticleSet &P, int iat)=0
int BasisSetSize
size of the basis set
Definition: BasisSetBase.h:143
Base for real basis set.
Definition: BasisSetBase.h:132
virtual void setBasisSetSize(int nbs)=0
resize the basis set