QMCPACK
PSdispatcher.cpp
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) 2021 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "PSdispatcher.h"
14 
15 namespace qmcplusplus
16 {
17 PSdispatcher::PSdispatcher(bool use_batch) : use_batch_(use_batch) {}
18 
21  const std::vector<bool>& recompute,
22  bool pbyp) const
23 {
24  if (use_batch_)
25  ParticleSet::mw_loadWalker(p_list, walkers, recompute, pbyp);
26  else
27  for (size_t iw = 0; iw < p_list.size(); iw++)
28  if (recompute[iw])
29  {
30  p_list[iw].loadWalker(walkers[iw], false);
31  // loadWalker and mw_loadWalker doesn't have the same behavior. Need the following update call.
32  p_list[iw].update(true);
33  }
34 }
35 
36 void PSdispatcher::flex_update(const RefVectorWithLeader<ParticleSet>& p_list, bool skipSK) const
37 {
38  if (use_batch_)
39  ParticleSet::mw_update(p_list, skipSK);
40  else
41  for (ParticleSet& pset : p_list)
42  pset.update(skipSK);
43 }
44 
45 template<CoordsType CT>
47  int iat,
48  const MCCoords<CT>& displs) const
49 {
50  if (use_batch_)
51  ParticleSet::mw_makeMove(p_list, iat, displs);
52  else
53  for (size_t iw = 0; iw < p_list.size(); iw++)
54  if constexpr (CT == CoordsType::POS_SPIN)
55  p_list[iw].makeMoveWithSpin(iat, displs.positions[iw], displs.spins[iw]);
56  else
57  p_list[iw].makeMove(iat, displs.positions[iw]);
58 }
59 
60 template<CoordsType CT>
62  int iat,
63  const std::vector<bool>& isAccepted,
64  bool forward_mode) const
65 {
66  if (use_batch_)
67  ParticleSet::mw_accept_rejectMove<CT>(p_list, iat, isAccepted, forward_mode);
68  else
69  for (size_t iw = 0; iw < p_list.size(); iw++)
70  p_list[iw].accept_rejectMove(iat, isAccepted[iw], forward_mode);
71 }
72 
74 {
75  if (use_batch_)
77  else
78  for (ParticleSet& pset : p_list)
79  pset.donePbyP();
80 }
81 
83  const RefVector<Walker_t>& walkers) const
84 {
85  if (use_batch_)
87  else
88  for (size_t iw = 0; iw < p_list.size(); iw++)
89  p_list[iw].saveWalker(walkers[iw]);
90 }
91 
92 template void PSdispatcher::flex_makeMove<CoordsType::POS>(const RefVectorWithLeader<ParticleSet>& p_list,
93  int iat,
94  const MCCoords<CoordsType::POS>& displs) const;
95 template void PSdispatcher::flex_makeMove<CoordsType::POS_SPIN>(const RefVectorWithLeader<ParticleSet>& p_list,
96  int iat,
97  const MCCoords<CoordsType::POS_SPIN>& displs) const;
98 template void PSdispatcher::flex_accept_rejectMove<CoordsType::POS>(const RefVectorWithLeader<ParticleSet>& p_list,
99  int iat,
100  const std::vector<bool>& isAccepted,
101  bool forward_mode) const;
102 template void PSdispatcher::flex_accept_rejectMove<CoordsType::POS_SPIN>(const RefVectorWithLeader<ParticleSet>& p_list,
103  int iat,
104  const std::vector<bool>& isAccepted,
105  bool forward_mode) const;
106 } // namespace qmcplusplus
void flex_accept_rejectMove(const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool forward_mode=true) const
static void mw_makeMove(const RefVectorWithLeader< ParticleSet > &p_list, int iat, const MCCoords< CT > &displs)
batched version of makeMove
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void flex_saveWalker(const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< Walker_t > &walkers) const
PSdispatcher(bool use_batch)
const char walkers[]
Definition: HDFVersion.h:36
static void mw_saveWalker(const RefVectorWithLeader< ParticleSet > &psets, const RefVector< Walker_t > &walkers)
batched version of saveWalker
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
void flex_loadWalker(const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< Walker_t > &walkers, const std::vector< bool > &recompute, bool pbyp) const
std::vector< std::reference_wrapper< T > > RefVector
void flex_update(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false) const
static void mw_update(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
batched version of update
static void mw_donePbyP(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
batched version of donePbyP
void flex_donePbyP(const RefVectorWithLeader< ParticleSet > &p_list) const
static void mw_loadWalker(const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< Walker_t > &walkers, const std::vector< bool > &recompute, bool pbyp)
batched version of loadWalker
void flex_makeMove(const RefVectorWithLeader< ParticleSet > &p_list, int iat, const MCCoords< CT > &displs) const