24 template<
class COT,
typename ORBT>
31 std::unique_ptr<Resource>
makeClone()
const override 33 return std::make_unique<SoaLocalizedBSetMultiWalkerMem>(*this);
40 template<
class COT,
typename ORBT>
43 collection.
addResource(std::make_unique<SoaLocalizedBSetMultiWalkerMem>());
44 for (
int i = 0; i < LOBasisSet.size(); i++)
45 LOBasisSet[i]->createResource(collection);
47 template<
class COT,
typename ORBT>
52 auto& loc_basis_leader = basisset_list.template getCastedLeader<SoaLocalizedBasisSet<COT, ORBT>>();
53 assert(
this == &loc_basis_leader);
56 auto& basisset_leader = loc_basis_leader.LOBasisSet;
57 for (
int i = 0; i < basisset_leader.size(); i++)
59 const auto one_species_basis_list(extractOneSpeciesBasisRefList(basisset_list, i));
60 basisset_leader[i]->acquireResource(collection, one_species_basis_list);
63 template<
class COT,
typename ORBT>
68 auto& loc_basis_leader = basisset_list.template getCastedLeader<SoaLocalizedBasisSet<COT, ORBT>>();
69 assert(
this == &loc_basis_leader);
72 auto& basisset_leader = loc_basis_leader.LOBasisSet;
73 for (
int i = 0; i < basisset_leader.size(); i++)
75 const auto one_species_basis_list(extractOneSpeciesBasisRefList(basisset_list, i));
76 basisset_leader[i]->releaseResource(collection, one_species_basis_list);
79 template<
class COT,
typename ORBT>
84 auto& loc_basis_leader = basisset_list.template getCastedLeader<SoaLocalizedBasisSet<COT, ORBT>>();
86 one_species_basis_list.reserve(basisset_list.size());
87 for (
size_t iw = 0; iw < basisset_list.size(); iw++)
88 one_species_basis_list.push_back(
90 return one_species_basis_list;
94 template<
class COT,
typename ORBT>
107 template<
class COT,
typename ORBT>
110 NumCenters(a.NumCenters),
111 NumTargets(a.NumTargets),
113 myTableIndex(a.myTableIndex),
114 SuperTwist(a.SuperTwist),
115 BasisOffset(a.BasisOffset)
119 LOBasisSet.push_back(std::make_unique<COT>(*elem));
122 template<
class COT,
typename ORBT>
129 for (
int i = 0; i < LOBasisSet.size(); ++i)
130 LOBasisSet[i]->setPBCParams(PBCImages, Sup_Twist, phase_factor, pbc_displacements);
132 SuperTwist = Sup_Twist;
135 template<
class COT,
typename ORBT>
138 const auto& IonID(ions_.GroupID);
139 if (BasisSetSize > 0 && nbs == BasisSetSize)
142 if (
auto& mapping = ions_.get_map_storage_to_input(); mapping.empty())
146 for (
int c = 0; c < NumCenters; c++)
147 BasisOffset[c + 1] = BasisOffset[c] + LOBasisSet[IonID[c]]->getBasisSetSize();
148 BasisSetSize = BasisOffset[NumCenters];
153 std::vector<int> map_input_to_storage(mapping.size());
154 for (
int c = 0; c < NumCenters; c++)
155 map_input_to_storage[mapping[c]] = c;
157 std::vector<size_t> basis_offset_input_order(BasisOffset.size(), 0);
158 for (
int c = 0; c < NumCenters; c++)
159 basis_offset_input_order[c + 1] =
160 basis_offset_input_order[c] + LOBasisSet[IonID[map_input_to_storage[c]]]->getBasisSetSize();
162 for (
int c = 0; c < NumCenters; c++)
163 BasisOffset[c] = basis_offset_input_order[mapping[c]];
165 BasisSetSize = basis_offset_input_order[NumCenters];
169 template<
class COT,
typename ORBT>
171 std::vector<bool>& is_s_orbital)
const 173 const auto& IonID(ions_.GroupID);
174 for (
int c = 0; c < NumCenters; c++)
176 int idx = BasisOffset[c];
177 int bss = LOBasisSet[IonID[c]]->getBasisSetSize();
178 std::vector<bool> local_is_s_orbital(bss);
179 LOBasisSet[IonID[c]]->queryOrbitalsForSType(local_is_s_orbital);
180 for (
int k = 0; k < bss; k++)
184 is_s_orbital[idx++] = local_is_s_orbital[k];
188 is_s_orbital[idx++] =
false;
194 template<
class COT,
typename ORBT>
197 const auto& IonID(ions_.GroupID);
198 const auto& coordR = P.
activeR(iat);
201 const auto& displ = (P.
getActivePtcl() == iat) ? d_table.getTempDispls() : d_table.getDisplRow(iat);
204 for (
int c = 0; c < NumCenters; c++)
206 Tv[0] = (ions_.R[c][0] - coordR[0]) - displ[c][0];
207 Tv[1] = (ions_.R[c][1] - coordR[1]) - displ[c][1];
208 Tv[2] = (ions_.R[c][2] - coordR[2]) - displ[c][2];
209 LOBasisSet[IonID[c]]->evaluateVGL(P.
getLattice(), dist[c], displ[c], BasisOffset[c], vgl, Tv);
213 template<
class COT,
typename ORBT>
219 assert(
this == &basis_list.getLeader());
220 auto& basis_leader = basis_list.template getCastedLeader<SoaLocalizedBasisSet<COT, ORBT>>();
221 const auto& IonID(ions_.GroupID);
224 size_t Nw = P_list.size();
225 assert(vgl_v.
size(0) == 5);
226 assert(vgl_v.
size(1) == Nw);
227 assert(vgl_v.
size(2) == BasisSetSize);
229 auto& Tv_list = basis_leader.mw_mem_handle_.getResource().Tv_list;
230 auto& displ_list_tr = basis_leader.mw_mem_handle_.getResource().displ_list_tr;
231 Tv_list.resize(3 * NumCenters * Nw);
232 displ_list_tr.resize(3 * NumCenters * Nw);
234 for (
size_t iw = 0; iw < P_list.size(); iw++)
236 const auto& coordR = P_list[iw].activeR(iat);
237 const auto& d_table = P_list[iw].getDistTableAB(myTableIndex);
238 const auto& displ = (P_list[iw].getActivePtcl() == iat) ? d_table.getTempDispls() : d_table.getDisplRow(iat);
239 for (
int c = 0; c < NumCenters; c++)
240 for (
size_t idim = 0; idim < 3; idim++)
242 Tv_list[idim + 3 * (iw + c * Nw)] = (ions_.R[c][idim] - coordR[idim]) - displ[c][idim];
243 displ_list_tr[idim + 3 * (iw + c * Nw)] = displ[c][idim];
246 #if defined(QMC_COMPLEX) 249 displ_list_tr.updateTo();
251 for (
int c = 0; c < NumCenters; c++)
253 auto one_species_basis_list = extractOneSpeciesBasisRefList(basis_list, IonID[c]);
254 LOBasisSet[IonID[c]]->mw_evaluateVGL(one_species_basis_list, pset_leader.getLattice(), vgl_v, displ_list_tr,
255 Tv_list, Nw, BasisSetSize, c, BasisOffset[c], NumCenters);
260 template<
class COT,
typename ORBT>
263 const auto& IonID(ions_.GroupID);
264 const auto& coordR = P.
activeR(iat);
267 const auto& displ = (P.
getActivePtcl() == iat) ? d_table.getTempDispls() : d_table.getDisplRow(iat);
269 for (
int c = 0; c < NumCenters; c++)
271 Tv[0] = (ions_.R[c][0] - coordR[0]) - displ[c][0];
272 Tv[1] = (ions_.R[c][1] - coordR[1]) - displ[c][1];
273 Tv[2] = (ions_.R[c][2] - coordR[2]) - displ[c][2];
274 LOBasisSet[IonID[c]]->evaluateVGH(P.
getLattice(), dist[c], displ[c], BasisOffset[c], vgh, Tv);
278 template<
class COT,
typename ORBT>
283 const auto& IonID(ions_.GroupID);
284 const auto& coordR = P.
activeR(iat);
287 const auto& displ = (P.
getActivePtcl() == iat) ? d_table.getTempDispls() : d_table.getDisplRow(iat);
289 for (
int c = 0; c < NumCenters; c++)
291 Tv[0] = (ions_.R[c][0] - coordR[0]) - displ[c][0];
292 Tv[1] = (ions_.R[c][1] - coordR[1]) - displ[c][1];
293 Tv[2] = (ions_.R[c][2] - coordR[2]) - displ[c][2];
294 LOBasisSet[IonID[c]]->evaluateVGHGH(P.
getLattice(), dist[c], displ[c], BasisOffset[c], vghgh, Tv);
299 template<
class COT,
typename ORBT>
304 assert(
this == &basis_list.getLeader());
305 auto& basis_leader = basis_list.template getCastedLeader<SoaLocalizedBasisSet<COT, ORBT>>();
307 const size_t nVPs = vp_basis_v.
size(0);
308 assert(vp_basis_v.
size(1) == BasisSetSize);
309 const auto& IonID(ions_.GroupID);
314 const auto dt_list(vps_leader.extractDTRefList(vp_list, myTableIndex));
315 const auto coordR_list(vps_leader.extractVPCoords(vp_list));
317 auto& Tv_list = basis_leader.
mw_mem_handle_.getResource().Tv_list;
318 auto& displ_list_tr = basis_leader.mw_mem_handle_.getResource().displ_list_tr;
319 Tv_list.resize(3 * NumCenters * nVPs);
320 displ_list_tr.resize(3 * NumCenters * nVPs);
325 for (
size_t iw = 0; iw < vp_list.size(); iw++)
326 for (
int iat = 0; iat < vp_list[iw].getTotalNum(); iat++)
328 const auto& displ = dt_list[iw].getDisplRow(iat);
329 for (
int c = 0; c < NumCenters; c++)
330 for (
size_t idim = 0; idim < 3; idim++)
332 Tv_list[idim + 3 * (index + c * nVPs)] = (ions_.R[c][idim] - coordR_list[index][idim]) - displ[c][idim];
333 displ_list_tr[idim + 3 * (index + c * nVPs)] = displ[c][idim];
337 #if defined(QMC_COMPLEX) 340 displ_list_tr.updateTo();
343 for (
int c = 0; c < NumCenters; c++)
345 auto one_species_basis_list = extractOneSpeciesBasisRefList(basis_list, IonID[c]);
346 LOBasisSet[IonID[c]]->mw_evaluateV(one_species_basis_list, vps_leader.getLattice(), vp_basis_v, displ_list_tr,
347 Tv_list, nVPs, BasisSetSize, c, BasisOffset[c], NumCenters);
351 template<
class COT,
typename ORBT>
354 const auto& IonID(ions_.GroupID);
355 const auto& coordR = P.
activeR(iat);
358 const auto& displ = (P.
getActivePtcl() == iat) ? d_table.getTempDispls() : d_table.getDisplRow(iat);
361 for (
int c = 0; c < NumCenters; c++)
363 Tv[0] = (ions_.R[c][0] - coordR[0]) - displ[c][0];
364 Tv[1] = (ions_.R[c][1] - coordR[1]) - displ[c][1];
365 Tv[2] = (ions_.R[c][2] - coordR[2]) - displ[c][2];
366 LOBasisSet[IonID[c]]->evaluateV(P.
getLattice(), dist[c], displ[c], vals + BasisOffset[c], Tv);
370 template<
class COT,
typename ORBT>
376 assert(
this == &basis_list.getLeader());
377 auto& basis_leader = basis_list.template getCastedLeader<SoaLocalizedBasisSet<COT, ORBT>>();
378 const auto& IonID(ions_.GroupID);
381 size_t Nw = P_list.size();
382 assert(vals.
size(0) == Nw);
383 assert(vals.
size(1) == BasisSetSize);
385 auto& Tv_list = basis_leader.mw_mem_handle_.getResource().Tv_list;
386 auto& displ_list_tr = basis_leader.mw_mem_handle_.getResource().displ_list_tr;
387 Tv_list.resize(3 * NumCenters * Nw);
388 displ_list_tr.resize(3 * NumCenters * Nw);
390 for (
size_t iw = 0; iw < P_list.size(); iw++)
392 const auto& coordR = P_list[iw].activeR(iat);
393 const auto& d_table = P_list[iw].getDistTableAB(myTableIndex);
394 const auto& displ = (P_list[iw].getActivePtcl() == iat) ? d_table.getTempDispls() : d_table.getDisplRow(iat);
396 for (
int c = 0; c < NumCenters; c++)
397 for (
size_t idim = 0; idim < 3; idim++)
399 Tv_list[idim + 3 * (iw + c * Nw)] = (ions_.R[c][idim] - coordR[idim]) - displ[c][idim];
400 displ_list_tr[idim + 3 * (iw + c * Nw)] = displ[c][idim];
403 #if defined(QMC_COMPLEX) 406 displ_list_tr.updateTo();
408 for (
int c = 0; c < NumCenters; c++)
410 auto one_species_basis_list = extractOneSpeciesBasisRefList(basis_list, IonID[c]);
411 LOBasisSet[IonID[c]]->mw_evaluateV(one_species_basis_list, pset_leader.getLattice(), vals, displ_list_tr, Tv_list,
412 Nw, BasisSetSize, c, BasisOffset[c], NumCenters);
417 template<
class COT,
typename ORBT>
425 auto* restrict gx = vgl.data(1);
426 auto* restrict gy = vgl.data(2);
427 auto* restrict gz = vgl.data(3);
429 for (
int ib = 0; ib < BasisSetSize; ib++)
436 const auto& IonID(ions_.GroupID);
439 const auto& displ = (P.
getActivePtcl() == iat) ? d_table.getTempDispls() : d_table.getDisplRow(iat);
441 const auto& coordR = P.
activeR(iat);
444 Tv[0] = (ions_.R[jion][0] - coordR[0]) - displ[jion][0];
445 Tv[1] = (ions_.R[jion][1] - coordR[1]) - displ[jion][1];
446 Tv[2] = (ions_.R[jion][2] - coordR[2]) - displ[jion][2];
452 LOBasisSet[IonID[jion]]->evaluateVGL(P.
getLattice(), dist[jion], displ[jion], BasisOffset[jion], vgl, Tv);
455 template<
class COT,
typename ORBT>
463 auto* restrict gx = vghgh.data(1);
464 auto* restrict gy = vghgh.data(2);
465 auto* restrict gz = vghgh.data(3);
467 auto* restrict hxx = vghgh.data(4);
468 auto* restrict hxy = vghgh.data(5);
469 auto* restrict hxz = vghgh.data(6);
470 auto* restrict hyy = vghgh.data(7);
471 auto* restrict hyz = vghgh.data(8);
472 auto* restrict hzz = vghgh.data(9);
474 auto* restrict gxxx = vghgh.data(10);
475 auto* restrict gxxy = vghgh.data(11);
476 auto* restrict gxxz = vghgh.data(12);
477 auto* restrict gxyy = vghgh.data(13);
478 auto* restrict gxyz = vghgh.data(14);
479 auto* restrict gxzz = vghgh.data(15);
480 auto* restrict gyyy = vghgh.data(16);
481 auto* restrict gyyz = vghgh.data(17);
482 auto* restrict gyzz = vghgh.data(18);
483 auto* restrict gzzz = vghgh.data(19);
486 for (
int ib = 0; ib < BasisSetSize; ib++)
513 const auto& IonID(ions.
GroupID);
516 const auto& displ = (P.
getActivePtcl() == iat) ? d_table.getTempDispls() : d_table.getDisplRow(iat);
522 const auto& coordR = P.
activeR(iat);
525 Tv[0] = (ions_.R[jion][0] - coordR[0]) - displ[jion][0];
526 Tv[1] = (ions_.R[jion][1] - coordR[1]) - displ[jion][1];
527 Tv[2] = (ions_.R[jion][2] - coordR[2]) - displ[jion][2];
528 LOBasisSet[IonID[jion]]->evaluateVGHGH(P.
getLattice(), dist[jion], displ[jion], BasisOffset[jion], vghgh, Tv);
531 template<
class COT,
typename ORBT>
534 LOBasisSet[icenter] = std::move(aos);
Index_t getActivePtcl() const
return active particle id
void evaluateVGL(const ParticleSet &P, int iat, vgl_type &vgl) override
compute VGL
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
void takebackResource(ResourceHandle< RS > &res_handle)
void setBasisSetSize(int nbs) override
set BasisSetSize and allocate mVGL container
helper functions for EinsplineSetBuilder
A localized basis set derived from SoaBasisSetBase<ORBT>
typename COT::RealType RealType
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.
size_t getTotalNum() const
For distance tables of virtual particle (VP) sets constructed based on this table, whether full table is needed on host The corresponding DT of VP need to set MW_EVALUATE_RESULT_NO_TRANSFER_TO_HOST accordingly.
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
SoaSphericalTensor that evaluates the Real Spherical Harmonics.
SoaLocalizedBSetMultiWalkerMem()
QMCTraits::ValueType ValueType
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
ParticleIndex GroupID
Species ID.
int getTotalNum() const
return the number of species
const DistanceTableAB & getDistTableAB(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAB
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< SoaBasisSetBase< ORBT >> &basisset_list) const override
return a shared resource to collection
Specialized paritlce class for atomistic simulations.
QTBase::ValueType ValueType
const DistRow & getTempDists() const
return the temporary distances when a move is proposed
typename BaseType::vgh_type vgh_type
void add(int icenter, std::unique_ptr< COT > aos)
add a new set of Centered Atomic Orbitals
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to collection
const PosType & activeR(int iat) const
return the active position if the particle is active or the return current position if not ...
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
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Vector< RealType, OffloadPinnedAllocator< RealType > > Tv_list
Vector< RealType, OffloadPinnedAllocator< RealType > > displ_list_tr
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
whether full table needs to be ready at anytime or not during PbyP Optimization can be implemented du...
std::vector< size_t > BasisOffset
container to store the offsets of the basis functions for each center Due to potential reordering of ...
typename BaseType::vghgh_type vghgh_type
std::unique_ptr< Resource > makeClone() const override
const auto & getLattice() const
std::vector< std::unique_ptr< COT > > LOBasisSet
container of the unique pointers to the Atomic Orbitals
SoaLocalizedBSetMultiWalkerMem(const SoaLocalizedBSetMultiWalkerMem &)
ResourceHandle< RS > lendResource()
SoaLocalizedBasisSet(ParticleSet &ions, ParticleSet &els)
constructor
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
A D-dimensional Array class based on PETE.
size_t NumTargets
number of quantum particles
A derived class from BasisSetBase.
CartesianTensor according to Gamess order.
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< SoaBasisSetBase< ORBT >> &basisset_list) const override
acquire a shared resource from collection
ResourceHandle< VPMultiWalkerMem > mw_mem_handle_
multi walker resource
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
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
Assume that coeffs.D1 and the LogLightGrid r_values.size() are equal Therefore r must be < r_max...