QMCPACK
SoaLocalizedBasisSet.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:
8 //
9 // File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp.
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 /** @file SoaLocalizedBasisSet.h
14  * @brief A derived class from BasisSetBase
15  *
16  * This is intended as a replacement for MolecularWaveFunctionComponent and
17  * any other localized basis set.
18  */
19 #ifndef QMCPLUSPLUS_SOA_LOCALIZEDBASISSET_H
20 #define QMCPLUSPLUS_SOA_LOCALIZEDBASISSET_H
21 
22 #include <memory>
25 
26 namespace qmcplusplus
27 {
28 /** A localized basis set derived from SoaBasisSetBase<ORBT>
29  *
30  * This class performs the evaluation of the basis functions and their
31  * derivatives for each of the N-particles in a configuration.
32  * The template parameter COT denotes Centered-Orbital-Type which provides
33  * a set of localized orbitals associated with a center.
34  * The template parameter ORBT denotes the orbital value return type
35  */
36 template<class COT, typename ORBT>
38 {
39 public:
40  using RealType = typename COT::RealType;
43 
44  using vgl_type = typename BaseType::vgl_type;
45  using vgh_type = typename BaseType::vgh_type;
46  using vghgh_type = typename BaseType::vghgh_type;
47  using PosType = typename ParticleSet::PosType;
50 
52 
53  ///number of centers, e.g., ions
54  size_t NumCenters;
55  ///number of quantum particles
56  size_t NumTargets;
57  ///ion particle set
59  ///number of quantum particles
60  const int myTableIndex;
61  ///Global Coordinate of Supertwist read from HDF5
63 
64 
65  /** container to store the offsets of the basis functions for each center
66  * Due to potential reordering of ions, offsets can be in any order.
67  */
68  std::vector<size_t> BasisOffset;
69 
70  /** container of the unique pointers to the Atomic Orbitals
71  *
72  * size of LOBasisSet = number of unique centers
73  */
74  std::vector<std::unique_ptr<COT>> LOBasisSet;
75 
76  /** constructor
77  * @param ions ionic system
78  * @param els electronic system
79  */
81 
82  /** copy constructor */
84 
85  /** makeClone */
86  BaseType* makeClone() const override { return new SoaLocalizedBasisSet<COT, ORBT>(*this); }
87 
88  /** set Number of periodic Images to evaluate the orbitals.
89  Set to 0 for non-PBC, and set manually in the input.
90  Passes the pre-computed phase factor for evaluation of complex wavefunction. If WF is real Phase_factor is real and equals 1 if gamma or -1 if non-Gamma.
91  */
92  void setPBCParams(const TinyVector<int, 3>& PBCImages,
93  const TinyVector<double, 3> Sup_Twist,
95  const Array<RealType, 2, OffloadPinnedAllocator<RealType>>& pbc_displacements);
96 
97  /** set BasisSetSize and allocate mVGL container
98  */
99  void setBasisSetSize(int nbs) override;
100 
101  /** Determine which orbitals are S-type. Used by cusp correction.
102  */
103  void queryOrbitalsForSType(const std::vector<bool>& corrCenter, std::vector<bool>& is_s_orbital) const override;
104 
105  /** compute VGL
106  * @param P quantum particleset
107  * @param iat active particle
108  * @param vgl Matrix(5,BasisSetSize)
109  * @param trialMove if true, use getTempDists()/getTempDispls()
110  */
111  void evaluateVGL(const ParticleSet& P, int iat, vgl_type& vgl) override;
112 
113  /** compute V using packed array with all walkers
114  * @param basis_list list of basis sets (one for each walker)
115  * @param P_list list of quantum particleset (one for each walker)
116  * @param iat active particle
117  * @param v Array(n_walkers, BasisSetSize)
118  */
120  const RefVectorWithLeader<ParticleSet>& P_list,
121  int iat,
122  OffloadMWVArray& v) override;
123 
124  /** compute V using packed array with all walkers
125  * @param basis_list list of basis sets (one for each walker)
126  * @param vp_list list of quantum virtual particleset (one for each walker)
127  * @param v Array(n_walkers, BasisSetSize)
128  */
131  OffloadMWVArray& v) override;
132 
133 
134  /** compute VGL using packed array with all walkers
135  * @param basis_list list of basis sets (one for each walker)
136  * @param P_list list of quantum particleset (one for each walker)
137  * @param iat active particle
138  * @param vgl Array(n_walkers, 5, BasisSetSize)
139  */
141  const RefVectorWithLeader<ParticleSet>& P_list,
142  int iat,
143  OffloadMWVGLArray& vgl) override;
144 
145  /** compute VGH
146  * @param P quantum particleset
147  * @param iat active particle
148  * @param vgl Matrix(10,BasisSetSize)
149  * @param trialMove if true, use getTempDists()/getTempDispls()
150  */
151  void evaluateVGH(const ParticleSet& P, int iat, vgh_type& vgh) override;
152 
153  /** compute VGHGH
154  * @param P quantum particleset
155  * @param iat active particle
156  * @param vghgh Matrix(20,BasisSetSize)
157  * @param trialMove if true, use getTempDists()/getTempDispls()
158  */
159  void evaluateVGHGH(const ParticleSet& P, int iat, vghgh_type& vghgh) override;
160 
161  /** compute values for the iat-paricle move
162  *
163  * Always uses getTempDists() and getTempDispls()
164  * Tv is a translation vector; In PBC, in order to reduce the number
165  * of images that need to be summed over when generating the AO the
166  * nearest image displacement, dr, is used. Tv corresponds to the
167  * translation that takes the 'general displacement' (displacement
168  * between ion position and electron position) to the nearest image
169  * displacement. We need to keep track of Tv because it must be add
170  * as a phase factor, i.e., exp(i*k*Tv).
171  */
172  void evaluateV(const ParticleSet& P, int iat, ORBT* restrict vals) override;
173 
174  void evaluateGradSourceV(const ParticleSet& P, int iat, const ParticleSet& ions, int jion, vgl_type& vgl) override;
175 
176  void evaluateGradSourceVGL(const ParticleSet& P,
177  int iat,
178  const ParticleSet& ions,
179  int jion,
180  vghgh_type& vghgh) override;
181 
182  /** add a new set of Centered Atomic Orbitals
183  * @param icenter the index of the center
184  * @param aos a set of Centered Atomic Orbitals
185  */
186  void add(int icenter, std::unique_ptr<COT> aos);
187 
188 
189  /** initialize a shared resource and hand it to collection
190  */
191  void createResource(ResourceCollection& collection) const override;
192 
193  /** acquire a shared resource from collection
194  */
195  void acquireResource(ResourceCollection& collection,
196  const RefVectorWithLeader<SoaBasisSetBase<ORBT>>& basisset_list) const override;
197 
198  /** return a shared resource to collection
199  */
200  void releaseResource(ResourceCollection& collection,
201  const RefVectorWithLeader<SoaBasisSetBase<ORBT>>& basisset_list) const override;
202 
203 
204  /** helper function for extracting a list of atomic basis sets for a single species (indexed by `id`)
205  * from a list of basis sets
206  */
208  const RefVectorWithLeader<SoaBasisSetBase<ORBT>>& basisset_list,
209  int id);
210 
211 private:
212  /// multi walker shared memory buffer
214  /// multi walker resource handle
216 };
217 } // namespace qmcplusplus
218 #endif
void evaluateVGL(const ParticleSet &P, int iat, vgl_type &vgl) override
compute VGL
void setBasisSetSize(int nbs) override
set BasisSetSize and allocate mVGL container
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
A localized basis set derived from SoaBasisSetBase<ORBT>
void setPBCParams(const TinyVector< int, 3 > &PBCImages, const TinyVector< double, 3 > Sup_Twist, const Vector< ValueType, OffloadPinnedAllocator< ValueType >> &phase_factor, const Array< RealType, 2, OffloadPinnedAllocator< RealType >> &pbc_displacements)
set Number of periodic Images to evaluate the orbitals.
ResourceHandle manages the temporary resource referenced from a collection.
void queryOrbitalsForSType(const std::vector< bool > &corrCenter, std::vector< bool > &is_s_orbital) const override
Determine which orbitals are S-type.
size_t NumCenters
number of centers, e.g., ions
void evaluateVGHGH(const ParticleSet &P, int iat, vghgh_type &vghgh) override
compute VGHGH
void evaluateV(const ParticleSet &P, int iat, ORBT *restrict vals) override
compute values for the iat-paricle move
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< SoaBasisSetBase< ORBT >> &basisset_list) const override
return a shared resource to collection
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
QTBase::ValueType ValueType
Definition: Configuration.h:60
typename BaseType::vgh_type vgh_type
VectorSoaContainer< ORBT, 10 > vgh_type
Definition: BasisSetBase.h:136
PosType SuperTwist
Global Coordinate of Supertwist read from HDF5.
void add(int icenter, std::unique_ptr< COT > aos)
add a new set of Centered Atomic Orbitals
QTBase::PosType PosType
Definition: Configuration.h:61
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to collection
OMPallocator is an allocator with fused device and dualspace allocator functionality.
void evaluateGradSourceV(const ParticleSet &P, int iat, const ParticleSet &ions, int jion, vgl_type &vgl) override
void mw_evaluateVGL(const RefVectorWithLeader< SoaBasisSetBase< ORBT >> &basis_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, OffloadMWVGLArray &vgl) override
compute VGL using packed array with all walkers
QMCTraits::RealType RealType
std::vector< size_t > BasisOffset
container to store the offsets of the basis functions for each center Due to potential reordering of ...
VectorSoaContainer< ORBT, 20 > vghgh_type
Definition: BasisSetBase.h:137
Array< ValueType, 3, OffloadPinnedAllocator< ValueType > > OffloadMWVGLArray
typename BaseType::vghgh_type vghgh_type
std::vector< std::unique_ptr< COT > > LOBasisSet
container of the unique pointers to the Atomic Orbitals
LatticeGaussianProduct::ValueType ValueType
Array< ValueType, 2, OffloadPinnedAllocator< ValueType > > OffloadMWVArray
const int myTableIndex
number of quantum particles
SoaLocalizedBasisSet(ParticleSet &ions, ParticleSet &els)
constructor
VectorSoaContainer< ORBT, OHMMS_DIM+2 > vgl_type
Definition: BasisSetBase.h:135
void mw_evaluateValue(const RefVectorWithLeader< SoaBasisSetBase< ORBT >> &basis_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, OffloadMWVArray &v) override
compute V using packed array with all walkers
ResourceHandle< SoaLocalizedBSetMultiWalkerMem > mw_mem_handle_
multi walker resource handle
A D-dimensional Array class based on PETE.
Definition: OhmmsArray.h:25
size_t NumTargets
number of quantum particles
BaseType * makeClone() const override
makeClone
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< SoaBasisSetBase< ORBT >> &basisset_list) const override
acquire a shared resource from collection
const ParticleSet & ions_
ion particle set
typename BaseType::vgl_type vgl_type
static RefVectorWithLeader< COT > extractOneSpeciesBasisRefList(const RefVectorWithLeader< SoaBasisSetBase< ORBT >> &basisset_list, int id)
helper function for extracting a list of atomic basis sets for a single species (indexed by id) from ...
void evaluateGradSourceVGL(const ParticleSet &P, int iat, const ParticleSet &ions, int jion, vghgh_type &vghgh) override
void evaluateVGH(const ParticleSet &P, int iat, vgh_type &vgh) override
compute VGH
int BasisSetSize
size of the basis set
Definition: BasisSetBase.h:143
typename ParticleSet::PosType PosType
void mw_evaluateValueVPs(const RefVectorWithLeader< SoaBasisSetBase< ORBT >> &basis_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, OffloadMWVArray &v) override
compute V using packed array with all walkers
Declaration of a base class of BasisSet.
Base for real basis set.
Definition: BasisSetBase.h:132