![]() |
QMCPACK
|
Base class to control the walkers for DMC simulations. More...
Public Types | |
enum | { ENERGY_INDEX = 0, ENERGY_SQ_INDEX, WALKERSIZE_INDEX, WEIGHT_INDEX, EREF_INDEX, R2ACCEPTED_INDEX, R2PROPOSED_INDEX, FNSIZE_INDEX, RNONESIZE_INDEX, RNSIZE_INDEX, B_ENERGY_INDEX, B_WGT_INDEX, SENTWALKERS_INDEX, LE_MAX } |
An enum to access curData and accumData for reduction. More... | |
using | Walker_t = MCWalkerConfiguration::Walker_t |
typedef of Walker_t More... | |
using | FullPrecRealType = QMCTraits::FullPrecRealType |
typedef of FullPrecRealType More... | |
using | IndexType = QMCTraits::IndexType |
typedef of IndexType More... | |
![]() | |
using | mpi_comm_type = Communicate::mpi_comm_type |
Public Member Functions | |
WalkerControlBase (Communicate *c) | |
default constructor More... | |
virtual | ~WalkerControlBase () |
empty destructor to clean up the derived classes More... | |
void | start () |
start a block More... | |
void | setWalkerID (MCWalkerConfiguration &walkers) |
start controller and initialize the IDs of walkers More... | |
void | measureProperties (int iter) |
take averages and writes to a file More... | |
void | setTrialEnergy (FullPrecRealType et) |
set the trial energy More... | |
FullPrecRealType | getValue (int i) |
return a value accumulated during a block More... | |
FullPrecRealType | getCurrentValue (int i) |
return a current value More... | |
int | doNotBranch (int iter, MCWalkerConfiguration &W) |
legacy: return global population update properties without branching More... | |
int | sortWalkers (MCWalkerConfiguration &W) |
legacy: sort Walkers between good and bad and prepare branching More... | |
int | applyNmaxNmin (int current_population) |
legacy: apply per rank limit Nmax and Nmin More... | |
int | copyWalkers (MCWalkerConfiguration &W) |
legacy: copy good walkers to W More... | |
virtual void | reset () |
reset to accumulate data More... | |
virtual int | branch (int iter, MCWalkerConfiguration &W, FullPrecRealType trigger) |
legacy: perform branch and swap walkers as required More... | |
bool | put (xmlNodePtr cur) |
void | setMinMax (int nw_in, int nmax_in) |
int | get_n_max () const |
int | get_n_min () const |
FullPrecRealType | get_target_sigma () const |
MCDataType< FullPrecRealType > & | get_ensemble_property () |
void | set_ensemble_property (MCDataType< FullPrecRealType > &ensemble_property) |
IndexType | get_num_contexts () const |
IndexType | get_method () const |
void | set_method (IndexType method) |
![]() | |
MPIObjectBase (Communicate *c) | |
constructor with communicator More... | |
int | rank () const |
return the rank of the communicator More... | |
int | getGroupID () const |
return the group id of the communicator More... | |
Communicate * | getCommunicator () const |
return myComm More... | |
Communicate & | getCommRef () const |
return a TEMPORARY reference to Communicate More... | |
mpi_comm_type | getMPI () const |
return MPI communicator if one wants to use MPI directly More... | |
bool | is_manager () const |
return true if the rank == 0 More... | |
const std::string & | getName () const |
return the name More... | |
void | setName (const std::string &aname) |
Static Public Member Functions | |
static std::vector< IndexType > | syncFutureWalkersPerRank (Communicate *comm, IndexType n_walkers) |
Protected Attributes | |
IndexType | method_ |
id for the method More... | |
IndexType | n_min_ |
minimum number of walkers More... | |
IndexType | n_max_ |
maximum number of walkers More... | |
IndexType | MaxCopy |
maximum copy per walker More... | |
IndexType | NumWalkers |
current number of walkers per processor More... | |
FullPrecRealType | trialEnergy |
trial energy energy More... | |
FullPrecRealType | target_sigma_ |
target sigma to limit fluctuations of the trial energy More... | |
std::vector< int > | NumPerRank |
number of particle per rank More... | |
std::vector< int > | OffSet |
offset of the particle index More... | |
std::vector< int > | FairOffSet |
offset of the particle index for a fair distribution More... | |
std::filesystem::path | dmcFname |
filename for dmc.dat More... | |
std::unique_ptr< std::ofstream > | dmcStream |
file to save energy histogram More... | |
IndexType | NumWalkersCreated |
Number of walkers created by this rank. More... | |
IndexType | MyContext |
context id More... | |
IndexType | num_contexts_ |
number of contexts More... | |
IndexType | SwapMode |
0 is default More... | |
std::vector< FullPrecRealType > | accumData |
any accumulated data over a block More... | |
std::vector< FullPrecRealType > | curData |
any temporary data includes many ridiculous conversions of integral types to and from fp More... | |
std::vector< std::unique_ptr< Walker_t > > | good_w |
temporary storage for good and bad walkers More... | |
std::vector< std::unique_ptr< Walker_t > > | bad_w |
std::vector< int > | ncopy_w |
temporary storage for copy counters More... | |
bool | use_nonblocking |
Use non-blocking isend/irecv. More... | |
MCDataType< FullPrecRealType > | ensemble_property_ |
ensemble properties More... | |
![]() | |
Communicate * | myComm |
pointer to Communicate More... | |
std::string | ClassName |
class Name More... | |
std::string | myName |
name of the object More... | |
Base class to control the walkers for DMC simulations.
The virtual functions are implemented for a serial execution with a usual birth/death process. Inherited classes implement other WalkerControl algorithms by implementing branch function.
Definition at line 52 of file WalkerControlBase.h.
typedef of FullPrecRealType
Definition at line 58 of file WalkerControlBase.h.
using IndexType = QMCTraits::IndexType |
typedef of IndexType
Definition at line 60 of file WalkerControlBase.h.
typedef of Walker_t
Definition at line 56 of file WalkerControlBase.h.
anonymous enum |
An enum to access curData and accumData for reduction.
curData is larger than this //LE_MAX + n_rank * T
Definition at line 66 of file WalkerControlBase.h.
WalkerControlBase | ( | Communicate * | c | ) |
default constructor
Set the SwapMode to zero so that instantiation can be done
Definition at line 33 of file WalkerControlBase.cpp.
References WalkerControlBase::accumData, WalkerControlBase::curData, WalkerControlBase::FairOffSet, WalkerControlBase::LE_MAX, WalkerControlBase::method_, MPIObjectBase::myComm, WalkerControlBase::MyContext, WalkerControlBase::num_contexts_, WalkerControlBase::NumPerRank, WalkerControlBase::OffSet, Communicate::rank(), and Communicate::size().
|
virtualdefault |
empty destructor to clean up the derived classes
int applyNmaxNmin | ( | int | current_population | ) |
legacy: apply per rank limit Nmax and Nmin
legacy population limiting
Definition at line 276 of file WalkerControlBase.cpp.
References APP_ABORT, qmcplusplus::app_error(), qmcplusplus::app_warning(), WalkerControlBase::bad_w, WalkerControlBase::good_w, omptarget::min(), WalkerControlBase::MyContext, WalkerControlBase::n_max_, WalkerControlBase::n_min_, WalkerControlBase::ncopy_w, WalkerControlBase::num_contexts_, and WalkerControlBase::NumPerRank.
Referenced by WalkerControlMPI::branch(), and WalkerControlBase::branch().
|
virtual |
legacy: perform branch and swap walkers as required
Reimplemented in WalkerControlMPI, WalkerReconfigurationMPI, and WalkerReconfiguration.
Definition at line 190 of file WalkerControlBase.cpp.
References WalkerControlBase::applyNmaxNmin(), WalkerControlBase::copyWalkers(), WalkerControlBase::ensemble_property_, WalkerConfigurations::EnsembleProperty, WalkerControlBase::measureProperties(), WalkerControlBase::NumPerRank, WalkerControlBase::sortWalkers(), and qmcplusplus::walker.
int copyWalkers | ( | MCWalkerConfiguration & | W | ) |
legacy: copy good walkers to W
copy good walkers to W
Good walkers are copied based on the registered number of copies Bad walkers are recycled to avoid memory allocation and deallocation.
Definition at line 384 of file WalkerControlBase.cpp.
References WalkerControlBase::bad_w, WalkerConfigurations::begin(), MCWalkerConfiguration::clear(), WalkerConfigurations::getActiveWalkers(), WalkerControlBase::good_w, WalkerConfigurations::insert(), WalkerControlBase::MyContext, WalkerControlBase::ncopy_w, and WalkerControlBase::num_contexts_.
Referenced by WalkerControlMPI::branch(), and WalkerControlBase::branch().
int doNotBranch | ( | int | iter, |
MCWalkerConfiguration & | W | ||
) |
legacy: return global population update properties without branching
Definition at line 143 of file WalkerControlBase.cpp.
References Communicate::allreduce(), WalkerControlBase::B_ENERGY_INDEX, WalkerControlBase::B_WGT_INDEX, WalkerControlBase::curData, qmcplusplus::Units::charge::e, MCDataType< T >::Energy, WalkerControlBase::ENERGY_INDEX, WalkerControlBase::ENERGY_SQ_INDEX, WalkerControlBase::ensemble_property_, WalkerControlBase::EREF_INDEX, WalkerControlBase::FNSIZE_INDEX, WalkerControlBase::MaxCopy, WalkerControlBase::measureProperties(), omptarget::min(), MPIObjectBase::myComm, WalkerControlBase::R2ACCEPTED_INDEX, WalkerControlBase::R2PROPOSED_INDEX, WalkerControlBase::RNONESIZE_INDEX, WalkerControlBase::RNSIZE_INDEX, WalkerControlBase::trialEnergy, qmcplusplus::walker, WalkerControlBase::WALKERSIZE_INDEX, and WalkerControlBase::WEIGHT_INDEX.
|
inline |
Definition at line 159 of file WalkerControlBase.h.
References WalkerControlBase::ensemble_property_.
|
inline |
Definition at line 165 of file WalkerControlBase.h.
References WalkerControlBase::method_.
|
inline |
Definition at line 156 of file WalkerControlBase.h.
References WalkerControlBase::n_max_.
|
inline |
Definition at line 157 of file WalkerControlBase.h.
References WalkerControlBase::n_min_.
|
inline |
Definition at line 164 of file WalkerControlBase.h.
References WalkerControlBase::num_contexts_.
|
inline |
Definition at line 158 of file WalkerControlBase.h.
References WalkerControlBase::target_sigma_.
|
inline |
return a current value
i | index of the data |
use enum for i, see DMCEnergyEstimator
Definition at line 119 of file WalkerControlBase.h.
References WalkerControlBase::curData.
|
inline |
return a value accumulated during a block
i | index of the data |
use enum for i, see DMCEnergyEstimator
Definition at line 112 of file WalkerControlBase.h.
References WalkerControlBase::accumData.
void measureProperties | ( | int | iter | ) |
take averages and writes to a file
Depends on alot of state.
Does not depend on state refactored to PopulationAdjustment directly
Definition at line 100 of file WalkerControlBase.cpp.
References MCDataType< T >::AlternateEnergy, WalkerControlBase::B_ENERGY_INDEX, WalkerControlBase::B_WGT_INDEX, WalkerControlBase::curData, WalkerControlBase::dmcStream, MCDataType< T >::Energy, WalkerControlBase::ENERGY_INDEX, WalkerControlBase::ENERGY_SQ_INDEX, WalkerControlBase::ensemble_property_, WalkerControlBase::FNSIZE_INDEX, MCDataType< T >::LivingFraction, WalkerControlBase::num_contexts_, MCDataType< T >::NumSamples, MCDataType< T >::R2Accepted, WalkerControlBase::R2ACCEPTED_INDEX, MCDataType< T >::R2Proposed, WalkerControlBase::R2PROPOSED_INDEX, WalkerControlBase::RNONESIZE_INDEX, MCDataType< T >::RNSamples, WalkerControlBase::RNSIZE_INDEX, WalkerControlBase::SENTWALKERS_INDEX, WalkerControlBase::trialEnergy, MCDataType< T >::Variance, WalkerControlBase::WALKERSIZE_INDEX, MCDataType< T >::Weight, and WalkerControlBase::WEIGHT_INDEX.
Referenced by WalkerReconfiguration::branch(), WalkerReconfigurationMPI::branch(), WalkerControlMPI::branch(), WalkerControlBase::branch(), and WalkerControlBase::doNotBranch().
bool put | ( | xmlNodePtr | cur | ) |
Definition at line 431 of file WalkerControlBase.cpp.
References ParameterSet::add(), APP_ABORT, qmcplusplus::app_log(), WalkerControlBase::MaxCopy, WalkerControlBase::n_max_, WalkerControlBase::n_min_, ParameterSet::put(), WalkerControlBase::setMinMax(), WalkerControlBase::target_sigma_, and WalkerControlBase::use_nonblocking.
|
virtual |
reset to accumulate data
Definition at line 137 of file WalkerControlBase.cpp.
References WalkerControlBase::accumData, and WalkerControlBase::curData.
|
inline |
Definition at line 160 of file WalkerControlBase.h.
References WalkerControlBase::ensemble_property_.
|
inline |
Definition at line 166 of file WalkerControlBase.h.
References WalkerControlBase::method_.
Referenced by qmcplusplus::createWalkerController().
void setMinMax | ( | int | nw_in, |
int | nmax_in | ||
) |
Definition at line 470 of file WalkerControlBase.cpp.
References WalkerControlBase::MaxCopy, WalkerControlBase::method_, WalkerControlBase::n_max_, WalkerControlBase::n_min_, and WalkerControlBase::num_contexts_.
Referenced by qmcplusplus::createWalkerController(), and WalkerControlBase::put().
|
inline |
set the trial energy
Definition at line 105 of file WalkerControlBase.h.
References WalkerControlBase::trialEnergy.
void setWalkerID | ( | MCWalkerConfiguration & | walkers | ) |
start controller and initialize the IDs of walkers
Definition at line 83 of file WalkerControlBase.cpp.
References WalkerControlBase::MyContext, WalkerControlBase::num_contexts_, WalkerControlBase::NumWalkersCreated, WalkerControlBase::start(), qmcplusplus::walker, and qmcplusplus::hdf::walkers.
int sortWalkers | ( | MCWalkerConfiguration & | W | ) |
legacy: sort Walkers between good and bad and prepare branching
evaluate curData and mark the bad/good walkers.
not a sort changes internal state of walkers to copy and how many of each copy
Each good walker has a counter registering the number of copies needed to be generated from this walker. Bad walkers will be either recycled or removed later.
Definition at line 223 of file WalkerControlBase.cpp.
References WalkerControlBase::B_ENERGY_INDEX, WalkerControlBase::B_WGT_INDEX, WalkerControlBase::bad_w, WalkerControlBase::curData, qmcplusplus::Units::charge::e, WalkerControlBase::ENERGY_INDEX, WalkerControlBase::ENERGY_SQ_INDEX, WalkerControlBase::EREF_INDEX, WalkerControlBase::FNSIZE_INDEX, WalkerControlBase::good_w, WalkerControlBase::MaxCopy, omptarget::min(), WalkerControlBase::ncopy_w, WalkerControlBase::NumWalkers, WalkerControlBase::R2ACCEPTED_INDEX, WalkerControlBase::R2PROPOSED_INDEX, WalkerControlBase::RNONESIZE_INDEX, WalkerControlBase::RNSIZE_INDEX, qmcplusplus::walker, WalkerControlBase::WALKERSIZE_INDEX, and WalkerControlBase::WEIGHT_INDEX.
Referenced by WalkerControlMPI::branch(), and WalkerControlBase::branch().
void start | ( | ) |
start a block
Definition at line 60 of file WalkerControlBase.cpp.
References WalkerControlBase::dmcFname, WalkerControlBase::dmcStream, Communicate::getName(), MPIObjectBase::myComm, and WalkerControlBase::MyContext.
Referenced by WalkerControlBase::setWalkerID().
|
static |
|
protected |
any accumulated data over a block
Definition at line 203 of file WalkerControlBase.h.
Referenced by WalkerControlBase::getValue(), WalkerControlBase::reset(), and WalkerControlBase::WalkerControlBase().
|
protected |
Definition at line 207 of file WalkerControlBase.h.
Referenced by WalkerControlBase::applyNmaxNmin(), WalkerControlBase::copyWalkers(), WalkerControlBase::sortWalkers(), and WalkerControlMPI::swapWalkersSimple().
|
protected |
any temporary data includes many ridiculous conversions of integral types to and from fp
Definition at line 205 of file WalkerControlBase.h.
Referenced by WalkerControlMPI::branch(), WalkerControlBase::doNotBranch(), WalkerControlBase::getCurrentValue(), WalkerReconfiguration::getIndexPermutation(), WalkerControlBase::measureProperties(), WalkerControlBase::reset(), WalkerControlBase::sortWalkers(), WalkerReconfigurationMPI::swapWalkers(), and WalkerControlBase::WalkerControlBase().
|
protected |
filename for dmc.dat
Definition at line 191 of file WalkerControlBase.h.
Referenced by WalkerControlBase::start().
|
protected |
file to save energy histogram
Definition at line 193 of file WalkerControlBase.h.
Referenced by WalkerControlBase::measureProperties(), and WalkerControlBase::start().
|
protected |
ensemble properties
Definition at line 214 of file WalkerControlBase.h.
Referenced by WalkerReconfiguration::branch(), WalkerReconfigurationMPI::branch(), WalkerControlMPI::branch(), WalkerControlBase::branch(), WalkerControlBase::doNotBranch(), WalkerControlBase::get_ensemble_property(), WalkerControlBase::measureProperties(), and WalkerControlBase::set_ensemble_property().
|
protected |
offset of the particle index for a fair distribution
Definition at line 188 of file WalkerControlBase.h.
Referenced by WalkerControlMPI::branch(), WalkerControlMPI::swapWalkersSimple(), and WalkerControlBase::WalkerControlBase().
|
protected |
temporary storage for good and bad walkers
Definition at line 207 of file WalkerControlBase.h.
Referenced by WalkerControlBase::applyNmaxNmin(), WalkerControlBase::copyWalkers(), WalkerControlBase::sortWalkers(), and WalkerControlMPI::swapWalkersSimple().
|
protected |
maximum copy per walker
Definition at line 176 of file WalkerControlBase.h.
Referenced by WalkerControlBase::doNotBranch(), WalkerControlBase::put(), WalkerControlBase::setMinMax(), and WalkerControlBase::sortWalkers().
|
protected |
id for the method
Definition at line 170 of file WalkerControlBase.h.
Referenced by WalkerControlBase::get_method(), WalkerControlBase::set_method(), WalkerControlBase::setMinMax(), and WalkerControlBase::WalkerControlBase().
|
protected |
context id
Definition at line 197 of file WalkerControlBase.h.
Referenced by WalkerControlBase::applyNmaxNmin(), WalkerControlMPI::branch(), WalkerControlBase::copyWalkers(), WalkerReconfiguration::getIndexPermutation(), WalkerReconfigurationMPI::recvWalkers(), WalkerReconfigurationMPI::sendWalkers(), WalkerControlBase::setWalkerID(), WalkerControlBase::start(), WalkerReconfigurationMPI::swapWalkers(), WalkerControlMPI::swapWalkersSimple(), and WalkerControlBase::WalkerControlBase().
|
protected |
maximum number of walkers
Definition at line 174 of file WalkerControlBase.h.
Referenced by WalkerControlBase::applyNmaxNmin(), WalkerControlBase::get_n_max(), WalkerControlBase::put(), and WalkerControlBase::setMinMax().
|
protected |
minimum number of walkers
Definition at line 172 of file WalkerControlBase.h.
Referenced by WalkerControlBase::applyNmaxNmin(), WalkerControlBase::get_n_min(), WalkerControlBase::put(), and WalkerControlBase::setMinMax().
|
protected |
temporary storage for copy counters
Definition at line 209 of file WalkerControlBase.h.
Referenced by WalkerControlBase::applyNmaxNmin(), WalkerControlBase::copyWalkers(), WalkerControlBase::sortWalkers(), WalkerReconfigurationMPI::swapWalkers(), and WalkerControlMPI::swapWalkersSimple().
|
protected |
number of contexts
Definition at line 199 of file WalkerControlBase.h.
Referenced by WalkerControlBase::applyNmaxNmin(), WalkerControlMPI::branch(), WalkerControlBase::copyWalkers(), WalkerControlBase::get_num_contexts(), WalkerReconfiguration::getIndexPermutation(), WalkerControlBase::measureProperties(), WalkerReconfigurationMPI::recvWalkers(), WalkerReconfigurationMPI::sendWalkers(), WalkerControlBase::setMinMax(), WalkerControlBase::setWalkerID(), WalkerReconfigurationMPI::swapWalkers(), WalkerControlMPI::swapWalkersSimple(), and WalkerControlBase::WalkerControlBase().
|
protected |
number of particle per rank
Definition at line 184 of file WalkerControlBase.h.
Referenced by WalkerControlBase::applyNmaxNmin(), WalkerControlMPI::branch(), WalkerControlBase::branch(), WalkerControlMPI::swapWalkersSimple(), and WalkerControlBase::WalkerControlBase().
|
protected |
current number of walkers per processor
Definition at line 178 of file WalkerControlBase.h.
Referenced by WalkerControlMPI::branch(), and WalkerControlBase::sortWalkers().
|
protected |
Number of walkers created by this rank.
Definition at line 195 of file WalkerControlBase.h.
Referenced by WalkerReconfiguration::getIndexPermutation(), WalkerReconfigurationMPI::recvWalkers(), WalkerControlBase::setWalkerID(), and WalkerReconfigurationMPI::swapWalkers().
|
protected |
offset of the particle index
Definition at line 186 of file WalkerControlBase.h.
Referenced by WalkerControlBase::WalkerControlBase().
|
protected |
0 is default
Definition at line 201 of file WalkerControlBase.h.
Referenced by WalkerControlMPI::WalkerControlMPI(), WalkerReconfiguration::WalkerReconfiguration(), and WalkerReconfigurationMPI::WalkerReconfigurationMPI().
|
protected |
target sigma to limit fluctuations of the trial energy
Definition at line 182 of file WalkerControlBase.h.
Referenced by WalkerControlBase::get_target_sigma(), and WalkerControlBase::put().
|
protected |
trial energy energy
Definition at line 180 of file WalkerControlBase.h.
Referenced by WalkerControlBase::doNotBranch(), WalkerControlBase::measureProperties(), and WalkerControlBase::setTrialEnergy().
|
protected |
Use non-blocking isend/irecv.
Definition at line 211 of file WalkerControlBase.h.
Referenced by WalkerControlBase::put(), and WalkerControlMPI::swapWalkersSimple().