37 std::unique_ptr<Resource>
makeClone()
const override {
return std::make_unique<VPMultiWalkerMem>(*this); }
55 if (dt_count_limit == 0)
57 for (
int i = 0; i < dt_count_limit; ++i)
78 collection.
addResource(std::make_unique<VPMultiWalkerMem>());
106 dt_list.reserve(vp_list.size());
109 const auto& d_table = vp.getDistTableAB(
id);
110 dt_list.push_back(d_table);
119 std::vector<QMCTraits::PosType> coords_list;
121 for (
int iat = 0; iat < vp.getTotalNum(); iat++)
122 coords_list.push_back(vp.R[iat]);
131 const std::vector<PosType>& deltaV,
135 if (sphere && iat < 0)
136 throw std::runtime_error(
137 "VirtualParticleSet::makeMoves is invoked incorrectly, the flag sphere=true requires iat specified!");
142 assert(
R.
size() == deltaV.size());
143 for (
size_t ivp = 0; ivp <
R.
size(); ivp++)
144 R[ivp] = refp.
R[jel] + deltaV[ivp];
146 for (
size_t ivp = 0; ivp <
R.
size(); ivp++)
154 const std::vector<PosType>& deltaV,
155 const std::vector<RealType>& deltaS,
160 if (sphere && iat < 0)
161 throw std::runtime_error(
162 "VirtualParticleSet::makeMovesWithSpin is invoked incorrectly, the flag sphere=true requires iat specified!");
167 assert(
R.
size() == deltaV.size());
169 for (
size_t ivp = 0; ivp <
R.
size(); ivp++)
171 R[ivp] = refp.
R[jel] + deltaV[ivp];
179 const RefVector<
const std::vector<PosType>>& deltaV_list,
184 vp_leader.onSphere = sphere;
187 const size_t nVPs =
countVPs(vp_list);
188 auto& mw_refPctls = vp_leader.getMultiWalkerRefPctls();
189 mw_refPctls.resize(nVPs);
192 p_list.reserve(vp_list.size());
195 for (
int iw = 0; iw < vp_list.size(); iw++)
198 const std::vector<PosType>& deltaV(deltaV_list[iw]);
202 vp.
refPS = refp_list[iw];
205 assert(vp.
R.
size() == deltaV.size());
206 for (
size_t k = 0; k < vp.
R.
size(); k++, ivp++)
208 vp.
R[k] = refp_list[iw].R[vp.
refPtcl] + deltaV[k];
209 if (vp_leader.isSpinor())
213 p_list.push_back(vp);
217 mw_refPctls.updateTo();
223 const RefVector<
const std::vector<PosType>>& deltaV_list,
224 const RefVector<
const std::vector<RealType>>& deltaS_list,
229 if (!vp_leader.isSpinor())
230 throw std::runtime_error(
231 "VirtualParticleSet::mw_makeMovesWithSpin should not be called if particle sets aren't spionor types");
232 vp_leader.onSphere = sphere;
235 const size_t nVPs =
countVPs(vp_list);
236 auto& mw_refPctls = vp_leader.getMultiWalkerRefPctls();
237 mw_refPctls.resize(nVPs);
240 p_list.reserve(vp_list.size());
243 for (
int iw = 0; iw < vp_list.size(); iw++)
246 const std::vector<PosType>& deltaV(deltaV_list[iw]);
247 const std::vector<RealType>& deltaS(deltaS_list[iw]);
251 vp.
refPS = refp_list[iw];
254 assert(vp.
R.
size() == deltaV.size());
255 assert(vp.
spins.
size() == deltaS.size());
257 for (
size_t k = 0; k < vp.
R.
size(); k++, ivp++)
259 vp.
R[k] = refp_list[iw].R[vp.
refPtcl] + deltaV[k];
260 vp.
spins[k] = refp_list[iw].spins[vp.
refPtcl] + deltaS[k];
263 p_list.push_back(vp);
267 mw_refPctls.updateTo();
void resize(size_type n, Type_t val=Type_t())
Resize the container.
void setName(const std::string &aname)
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
std::optional< std::reference_wrapper< const ParticleSet > > refPS
ParticleSet this object refers to after makeMoves.
void takebackResource(ResourceHandle< RS > &res_handle)
helper functions for EinsplineSetBuilder
std::unique_ptr< Resource > makeClone() const override
ParticleScalar spins
internal spin variables for dynamical spin calculations
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
size_t TotalNum
total number of particles
static void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< VirtualParticleSet > &vp_list)
release external resource Note: use RAII ResourceCollectionTeamLock whenever possible ...
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.
static void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< ParticleSet > &p_list)
release external resource Note: use RAII ResourceCollectionTeamLock whenever possible ...
void makeMovesWithSpin(const ParticleSet &refp, int jel, const std::vector< PosType > &deltaV, const std::vector< RealType > &deltaS, bool sphere=false, int iat=-1)
move virtual particles to new postions and update distance tables
int refSourcePtcl
Reference source particle, used when onSphere=true.
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
void makeMoves(const ParticleSet &refp, int jel, const std::vector< PosType > &deltaV, bool sphere=false, int iat=-1)
move virtual particles to new postions and update distance tables
int getNumDistTables() const
int refPtcl
Reference particle.
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
void update(bool skipSK=false)
update the internal data
A proxy class to the quantum ParticleSet.
static void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< VirtualParticleSet > &vp_list)
acquire external resource and assocaite it with the list of ParticleSet Note: use RAII ResourceCollec...
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
Specialized paritlce class for atomistic simulations.
Vector< int, OffloadPinnedAllocator< int > > & getMultiWalkerRefPctls()
size_type size() const
return the current size
Vector< int, OffloadPinnedAllocator< int > > mw_refPctls
multi walker reference particle
VPMultiWalkerMem(const VPMultiWalkerMem &)
static const std::vector< QMCTraits::PosType > extractVPCoords(const RefVectorWithLeader< const VirtualParticleSet > &vp_list)
Extract list of VP coordinates, flattened over all walkers.
static void mw_makeMoves(const RefVectorWithLeader< VirtualParticleSet > &vp_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< const std::vector< PosType >> &deltaV_list, const RefVector< const NLPPJob< RealType >> &joblist, bool sphere)
VirtualParticleSet(const ParticleSet &p, int nptcl, size_t dt_count_limit=0)
constructor
auto & getDistTable(int table_ID) const
get a distance table by table_ID
static void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< ParticleSet > &p_list)
acquire external resource and assocaite it with the list of ParticleSet Note: use RAII ResourceCollec...
std::unique_ptr< DynamicCoordinates > coordinates_
internal representation of R. It can be an SoA copy of R
static void mw_makeMovesWithSpin(const RefVectorWithLeader< VirtualParticleSet > &vp_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< const std::vector< PosType >> &deltaV_list, const RefVector< const std::vector< RealType >> &deltaS_list, const RefVector< const NLPPJob< RealType >> &joblist, bool sphere)
std::vector< std::reference_wrapper< T > > RefVector
static RefVectorWithLeader< ParticleSet > RefVectorWithLeaderParticleSet(const RefVectorWithLeader< VirtualParticleSet > &vp_list)
static void mw_update(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
batched version of update
meta data for NLPP calculation of a pair of ion and electron This is not just meta data...
static size_t countVPs(const RefVectorWithLeader< const VirtualParticleSet > &vp_list)
ResourceHandle< RS > lendResource()
void setSpinor(bool is_spinor)
bool onSphere
true, if virtual particles are on a sphere for NLPP
ResourceHandle< VPMultiWalkerMem > mw_mem_handle_
multi walker resource
static const RefVectorWithLeader< const DistanceTableAB > extractDTRefList(const RefVectorWithLeader< const VirtualParticleSet > &vp_list, int id)
Extract list of Distance Tables.
skip data transfer back to host after mw_evalaute full distance table.