QMCPACK
MCWalkerConfiguration Class Reference

A set of walkers that are to be advanced by Metropolis Monte Carlo. More...

+ Inheritance diagram for MCWalkerConfiguration:
+ Collaboration diagram for MCWalkerConfiguration:

Public Types

enum  { Update_All = 0, Update_Walker, Update_Particle }
 enumeration for update More...
 
using Walker_t = WalkerConfigurations::Walker_t
 
using PropertyContainer_t = Walker_t::PropertyContainer_t
 container type of the Properties of a Walker More...
 
using WalkerList_t = std::vector< std::unique_ptr< Walker_t > >
 container type of Walkers More...
 
using iterator = WalkerList_t::iterator
 FIX: a type alias of iterator for an object should not be for just one of many objects it holds. More...
 
using const_iterator = WalkerList_t::const_iterator
 const_iterator of Walker container More...
 
using ReptileList_t = UPtrVector< Reptile >
 
- Public Types inherited from ParticleSet
enum  quantum_domains { no_quantum_domain = 0, classical, quantum }
 
using Walker_t = Walker< QMCTraits, PtclOnLatticeTraits >
 walker type More...
 
using PropertyContainer_t = Walker_t::PropertyContainer_t
 container type to store the property More...
 
using Buffer_t = PooledData< RealType >
 buffer type for a serialized buffer More...
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 
- Public Types inherited from OhmmsElementBase
enum  { useLIBXML = 0, useLIBXMLPP, usePLAIN }
 enumeration to choose the xml parser More...
 
- Public Types inherited from PtclOnLatticeTraits
using ParticleLayout = CrystalLattice< OHMMS_PRECISION, OHMMS_DIM >
 
using QTFull = QMCTraits::QTFull
 
using Index_t = int
 
using Scalar_t = QTFull::RealType
 
using Complex_t = QTFull::ComplexType
 
using SingleParticleIndex = ParticleLayout::SingleParticleIndex
 
using SingleParticlePos = ParticleLayout::SingleParticlePos
 
using Tensor_t = ParticleLayout::Tensor_t
 
using ParticleIndex = ParticleAttrib< Index_t >
 
using ParticleScalar = ParticleAttrib< Scalar_t >
 
using ParticlePos = ParticleAttrib< SingleParticlePos >
 
using ParticleTensor = ParticleAttrib< Tensor_t >
 
using ParticleGradient = ParticleAttrib< QTFull::GradType >
 
using ParticleLaplacian = ParticleAttrib< QTFull::ValueType >
 
using SingleParticleValue = QTFull::ValueType
 
- Public Types inherited from WalkerConfigurations
using Walker_t = Walker< QMCTraits, PtclOnLatticeTraits >
 walker type More...
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
using walker_list__t = std::vector< std::unique_ptr< Walker_t > >
 container type of Walkers More...
 
using iterator = walker_list__t::iterator
 FIX: a type alias of iterator for an object should not be for just one of many objects it holds. More...
 
using const_iterator = walker_list__t::const_iterator
 const_iterator of Walker container More...
 

Public Member Functions

 MCWalkerConfiguration (const SimulationCell &simulation_cell, const DynamicCoordinateKind kind=DynamicCoordinateKind::DC_POS)
 default constructor More...
 
 MCWalkerConfiguration (const MCWalkerConfiguration &mcw)
 default constructor: copy only ParticleSet More...
 
 ~MCWalkerConfiguration ()
 
void createWalkers (int numWalkers)
 create numWalkers Walkers More...
 
void resize (int numWalkers, int numPtcls)
 clean up the walker list and make a new list More...
 
void resizeWalkerHistories ()
 resize Walker::PropertyHistory and Walker::PHindex: More...
 
void sample (iterator it, RealType tauinv)
 make random moves for all the walkers More...
 
int getParticleNum () const
 return the number of particles per walker More...
 
void setLocalEnergy (RealType e)
 set LocalEnergy More...
 
RealType getLocalEnergy () const
 return LocalEnergy More...
 
MultiChain * getPolymer ()
 
void setPolymer (MultiChain *chain)
 
void resetWalkerProperty (int ncopy=1)
 reset the Property container of all the walkers More...
 
bool updatePbyP () const
 
void clear ()
 clean up the walker list More...
 
- Public Member Functions inherited from ParticleSet
 ParticleSet (const SimulationCell &simulation_cell, const DynamicCoordinateKind kind=DynamicCoordinateKind::DC_POS)
 default constructor More...
 
 ParticleSet (const ParticleSet &p)
 copy constructor More...
 
 ~ParticleSet () override
 default destructor More...
 
void create (const std::vector< int > &agroup)
 create grouped particles More...
 
void print (std::ostream &os, const size_t maxParticlesToPrint=0) const
 print particle coordinates to a std::ostream More...
 
bool get (std::ostream &os) const override
 dummy. For satisfying OhmmsElementBase. More...
 
bool put (std::istream &) override
 dummy. For satisfying OhmmsElementBase. More...
 
void reset () override
 dummy. For satisfying OhmmsElementBase. More...
 
bool put (xmlNodePtr cur) override
 initialize ParticleSet from xmlNode More...
 
void setQuantumDomain (quantum_domains qdomain)
 specify quantum_domain of particles More...
 
void set_quantum ()
 
bool is_classical () const
 
bool is_quantum () const
 
bool quantumDomainValid (quantum_domains qdomain) const
 check whether quantum domain is valid for particles More...
 
bool quantumDomainValid () const
 check whether quantum domain is valid for particles More...
 
int addTable (const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
 add a distance table More...
 
auto & getDistTable (int table_ID) const
 get a distance table by table_ID More...
 
const DistanceTableAAgetDistTableAA (int table_ID) const
 get a distance table by table_ID and dyanmic_cast to DistanceTableAA More...
 
const DistanceTableABgetDistTableAB (int table_ID) const
 get a distance table by table_ID and dyanmic_cast to DistanceTableAB More...
 
void resetCollectables ()
 reset all the collectable quantities during a MC iteration More...
 
void update (bool skipSK=false)
 update the internal data More...
 
void createSK ()
 create Structure Factor with PBCs More...
 
bool hasSK () const
 
const StructFactgetSK () const
 return Structure Factor More...
 
void turnOnPerParticleSK ()
 Turn on per particle storage in Structure Factor. More...
 
bool getPerParticleSKState () const
 Get state (on/off) of per particle storage in Structure Factor. More...
 
SpeciesSetgetSpeciesSet ()
 retrun the SpeciesSet of this particle set More...
 
const SpeciesSetgetSpeciesSet () const
 retrun the const SpeciesSet of this particle set More...
 
const std::string & parentName () const
 return parent's name More...
 
void setName (const std::string &aname)
 
const DynamicCoordinatesgetCoordinates () const
 
void resetGroups ()
 
const auto & getSimulationCell () const
 
const auto & getLattice () const
 
auto & getPrimitiveLattice () const
 
const auto & getLRBox () const
 
bool isSameMass () const
 
bool isSpinor () const
 
void setSpinor (bool is_spinor)
 
Index_t getActivePtcl () const
 return active particle id More...
 
const PosTypegetActivePos () const
 
Scalar_t getActiveSpinVal () const
 
const PosTypeactiveR (int iat) const
 return the active position if the particle is active or the return current position if not More...
 
const Scalar_tactiveSpin (int iat) const
 return the active spin value if the particle is active or return the current spin value if not More...
 
void makeMove (Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
 move the iat-th particle to active_pos_ More...
 
void makeMoveWithSpin (Index_t iat, const SingleParticlePos &displ, const Scalar_t &sdispl)
 makeMove, but now includes an update to the spin variable More...
 
bool makeMoveAndCheck (Index_t iat, const SingleParticlePos &displ)
 move the iat-th particle to active_pos_ More...
 
bool makeMoveAndCheckWithSpin (Index_t iat, const SingleParticlePos &displ, const Scalar_t &sdispl)
 makeMoveAndCheck, but now includes an update to the spin variable More...
 
void makeVirtualMoves (const SingleParticlePos &newpos)
 Handles virtual moves for all the particles to a single newpos. More...
 
bool makeMoveAllParticles (const Walker_t &awalker, const ParticlePos &deltaR, RealType dt)
 move all the particles of a walker More...
 
bool makeMoveAllParticles (const Walker_t &awalker, const ParticlePos &deltaR, const std::vector< RealType > &dt)
 
bool makeMoveAllParticlesWithDrift (const Walker_t &awalker, const ParticlePos &drift, const ParticlePos &deltaR, RealType dt)
 move all the particles including the drift More...
 
bool makeMoveAllParticlesWithDrift (const Walker_t &awalker, const ParticlePos &drift, const ParticlePos &deltaR, const std::vector< RealType > &dt)
 
void accept_rejectMove (Index_t iat, bool accepted, bool forward_mode=true)
 accept or reject a proposed move Two operation modes: The using and updating distance tables via ParticleSet operate in two modes, regular and forward modes. More...
 
void acceptMove (Index_t iat)
 accept the move and update the particle attribute by the proposed move in regular mode More...
 
void rejectMove (Index_t iat)
 reject a proposed move in regular mode More...
 
void initPropertyList ()
 
int addProperty (const std::string &pname)
 
int addPropertyHistory (int leng)
 
void convert (const ParticlePos &pin, ParticlePos &pout)
 
void convert2Unit (const ParticlePos &pin, ParticlePos &pout)
 
void convert2Cart (const ParticlePos &pin, ParticlePos &pout)
 
void convert2Unit (ParticlePos &pout)
 
void convert2Cart (ParticlePos &pout)
 
void convert2UnitInBox (const ParticlePos &pint, ParticlePos &pout)
 
void convert2CartInBox (const ParticlePos &pint, ParticlePos &pout)
 
void applyBC (const ParticlePos &pin, ParticlePos &pout)
 
void applyBC (ParticlePos &pos)
 
void applyBC (const ParticlePos &pin, ParticlePos &pout, int first, int last)
 
void applyMinimumImage (ParticlePos &pinout) const
 
void loadWalker (Walker_t &awalker, bool pbyp)
 load a Walker_t to the current ParticleSet More...
 
void saveWalker (Walker_t &awalker)
 save this to awalker More...
 
void donePbyP (bool skipSK=false)
 update structure factor and unmark active_ptcl_ More...
 
FullPrecRealType *restrict getPropertyBase ()
 return the address of the values of Hamiltonian terms More...
 
const FullPrecRealType *restrict getPropertyBase () const
 return the address of the values of Hamiltonian terms More...
 
FullPrecRealType *restrict getPropertyBase (int i)
 return the address of the i-th properties More...
 
const FullPrecRealType *restrict getPropertyBase (int i) const
 return the address of the i-th properties More...
 
void setTwist (const SingleParticlePos &t)
 
const SingleParticlePosgetTwist () const
 
void randomizeFromSource (ParticleSet &src)
 Initialize particles around another ParticleSet Used to initialize an electron ParticleSet by an ion ParticleSet. More...
 
const std::string & species_from_index (int i)
 get species name of particle i More...
 
size_t getTotalNum () const
 
void clear ()
 
int groups () const
 return the number of groups More...
 
int first (int igroup) const
 return the first index of a group i More...
 
int last (int igroup) const
 return the last index of a group i More...
 
int getGroupID (int iat) const
 return the group id of a given particle in the particle set. More...
 
int groupsize (int igroup) const
 return the size of a group More...
 
template<typename ATList >
void createAttributeList (ATList &AttribList)
 add attributes to list for IO More...
 
void setMapStorageToInput (const std::vector< int > &mapping)
 
const std::vector< int > & get_map_storage_to_input () const
 
int getNumDistTables () const
 
auto & get_group_offsets () const
 
void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
- Public Member Functions inherited from OhmmsElementBase
 OhmmsElementBase (const char *aname="none")
 constructor with a name More...
 
virtual ~OhmmsElementBase ()
 destructor More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 set name More...
 
void setIOMode (int imode)
 set iomode More...
 
virtual bool add (xmlNodePtr parent)
 add a xmlNode to the children list of parent More...
 
void put (const std::string &s)
 read from string More...
 
virtual void begin_node (std::ostream &os) const
 write the start of a node More...
 
virtual void end_node (std::ostream &os) const
 write the end of a node More...
 
- Public Member Functions inherited from WalkerConfigurations
 WalkerConfigurations ()
 
 ~WalkerConfigurations ()
 default destructor More...
 
 WalkerConfigurations (const WalkerConfigurations &)=delete
 
WalkerConfigurationsoperator= (const WalkerConfigurations &)=delete
 
 WalkerConfigurations (WalkerConfigurations &&)=default
 
WalkerConfigurationsoperator= (WalkerConfigurations &&)=default
 
void createWalkers (int numWalkers, size_t numPtcls)
 create numWalkers Walkers More...
 
void createWalkers (iterator first, iterator last)
 create walkers More...
 
void copyWalkers (iterator first, iterator last, iterator start)
 copy walkers More...
 
iterator destroyWalkers (iterator first, iterator last)
 destroy Walkers from itstart to itend More...
 
void destroyWalkers (int nw)
 destroy Walkers More...
 
void resize (int numWalkers, size_t numPtcls)
 clean up the walker list and make a new list More...
 
size_t getActiveWalkers () const
 return the number of active walkers More...
 
size_t getGlobalNumWalkers () const
 return the total number of active walkers among a MPI group More...
 
void setWalkerOffsets (const std::vector< int > &o)
 return the total number of active walkers among a MPI group More...
 
const std::vector< int > & getWalkerOffsets () const
 
iterator begin ()
 return the first iterator More...
 
iterator end ()
 return the last iterator, [begin(), end()) More...
 
const_iterator begin () const
 return the first const_iterator More...
 
const_iterator end () const
 return the last const_iterator [begin(), end()) More...
 
void clear ()
 clear the walker_list_ without destroying them More...
 
template<class INPUT_ITER >
void insert (iterator it, INPUT_ITER first, INPUT_ITER last)
 insert elements More...
 
void push_back (std::unique_ptr< Walker_t > awalker)
 add Walker_t* at the end More...
 
void pop_back ()
 delete the last Walker_t* More...
 
Walker_toperator[] (int i)
 
const Walker_toperator[] (int i) const
 
void reset ()
 reset the Walkers More...
 
void putConfigurations (Walker_t::RealType *target, QMCTraits::FullPrecRealType *weights) const
 save the particle positions of all the walkers into target More...
 

Public Attributes

ReptileList_t ReptileList
 a collection of reptiles contained in MCWalkerConfiguration. More...
 
Reptilereptile
 
- Public Attributes inherited from ParticleSet
quantum_domains quantum_domain
 quantum_domain of the particles, default = classical More...
 
int current_step
 current MC step More...
 
ParticleIndex GroupID
 Species ID. More...
 
ParticlePos R
 Position. More...
 
ParticleScalar spins
 internal spin variables for dynamical spin calculations More...
 
ParticleGradient G
 gradients of the particles More...
 
ParticleLaplacian L
 laplacians of the particles More...
 
ParticleScalar Mass
 mass of each particle More...
 
ParticleScalar Z
 charge of each particle More...
 
Index_t activeBead
 the index of the active bead for particle-by-particle moves More...
 
Index_t direction
 the direction reptile traveling More...
 
std::vector< TinyVector< int, OHMMS_DIM > > DensityReducedGvecs
 Particle density in G-space for MPC interaction. More...
 
std::vector< ComplexTypeDensity_G
 
Array< RealType, OHMMS_DIMDensity_r
 
std::vector< TinyVector< int, OHMMS_DIM > > VHXCReducedGvecs
 DFT potential. More...
 
std::vector< ComplexTypeVHXC_G [2]
 
Array< RealType, OHMMS_DIMVHXC_r [2]
 
PropertySetType PropertyList
 name-value map of Walker Properties More...
 
PropertyContainer_t Properties
 properties of the current walker More...
 
Buffer_t Collectables
 observables in addition to those registered in Properties/PropertyList More...
 
std::vector< std::vector< FullPrecRealType > > PropertyHistory
 Property history vector. More...
 
std::vector< int > PHindex
 
- Public Attributes inherited from WalkerConfigurations
MCDataType< FullPrecRealTypeEnsembleProperty
 

Protected Attributes

bool ReadyForPbyP
 true if the buffer is ready for particle-by-particle updates More...
 
int UpdateMode
 update-mode index More...
 
RealType LocalEnergy
 
- Protected Attributes inherited from ParticleSet
const SimulationCellsimulation_cell_
 reference to global simulation cell More...
 
bool same_mass_
 true if the particles have the same mass More...
 
bool is_spinor_
 true is a dynamic spin calculation More...
 
Index_t active_ptcl_
 the index of the active particle during particle-by-particle moves More...
 
SingleParticlePos active_pos_
 the proposed position of active_ptcl_ during particle-by-particle moves More...
 
Scalar_t active_spin_val_
 the proposed spin of active_ptcl_ during particle-by-particle moves More...
 
std::vector< int > map_storage_to_input_
 Map storage index to the input index. More...
 
SpeciesSet my_species_
 SpeciesSet of particles. More...
 
std::unique_ptr< StructFactstructure_factor_
 Structure factor. More...
 
ResourceHandle< SKMultiWalkerMemmw_structure_factor_data_handle_
 multi walker structure factor data More...
 
std::map< std::string, int > myDistTableMap
 map to handle distance tables More...
 
std::vector< std::unique_ptr< DistanceTable > > DistTables
 distance tables that need to be updated by moving this ParticleSet More...
 
std::vector< std::string > distTableDescriptions
 Descriptions from distance table creation. Same order as DistTables. More...
 
TimerList_t myTimers
 
SingleParticlePos myTwist
 
std::string ParentName
 
size_t TotalNum
 total number of particles More...
 
std::shared_ptr< Vector< int, OMPallocator< int > > > group_offsets_
 array to handle a group of distinct particles per species More...
 
std::unique_ptr< DynamicCoordinatescoordinates_
 internal representation of R. It can be an SoA copy of R More...
 
- Protected Attributes inherited from OhmmsElementBase
int myIOMode
 the type of IO mode: default is useLIBXML More...
 
std::string myName
 the name of the node, corresponds to the xml tag More...
 
- Protected Attributes inherited from WalkerConfigurations
walker_list__t walker_list_
 a collection of walkers More...
 

Private Attributes

MultiChain * Polymer
 
SampleStack samples
 

Friends

class MCPopulation
 
int numSamples () const
 
void setNumSamples (int n)
 set the number of max samples More...
 
void saveEnsemble ()
 save the position of current walkers to SampleStack More...
 
void saveEnsemble (iterator first, iterator last)
 save the position of current walkers More...
 
void loadSample (ParticleSet &pset, size_t iw) const
 load a single sample from SampleStack More...
 
void loadEnsemble ()
 load SampleStack data to the current list of walker configurations More...
 
void loadEnsemble (std::vector< MCWalkerConfiguration *> &others, bool doclean=true)
 load the SampleStacks of others to the current list of walker configurations More...
 
void clearEnsemble ()
 clear the ensemble More...
 
const SampleStackgetSampleStack () const
 
SampleStackgetSampleStack ()
 
int getMaxSamples () const
 Transitional forwarding methods. More...
 
static bool dumpEnsemble (std::vector< MCWalkerConfiguration *> &others, HDFWalkerOutput &out, int np, int nBlock)
 dump Samples to a file More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ParticleSet
static void mw_update (const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
 batched version of update More...
 
template<CoordsType CT>
static void mw_makeMove (const RefVectorWithLeader< ParticleSet > &p_list, int iat, const MCCoords< CT > &displs)
 batched version of makeMove More...
 
static void mw_makeMove (const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< SingleParticlePos > &displs)
 
static void mw_makeSpinMove (const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< Scalar_t > &sdispls)
 batched version makeMove for spin variable only More...
 
template<CoordsType CT>
static void mw_accept_rejectMove (const RefVectorWithLeader< ParticleSet > &p_list, Index_t iat, const std::vector< bool > &isAccepted, bool forward_mode=true)
 batched version of acceptMove and rejectMove fused, templated on CoordsType More...
 
static void mw_accept_rejectMove (const RefVectorWithLeader< ParticleSet > &p_list, Index_t iat, const std::vector< bool > &isAccepted, bool forward_mode=true)
 batched version of acceptMove and rejectMove fused More...
 
static void mw_accept_rejectSpinMove (const RefVectorWithLeader< ParticleSet > &p_list, Index_t iat, const std::vector< bool > &isAccepted)
 batched version of acceptMove and reject Move fused, but only for spins More...
 
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 More...
 
static void mw_saveWalker (const RefVectorWithLeader< ParticleSet > &psets, const RefVector< Walker_t > &walkers)
 batched version of saveWalker More...
 
static void mw_donePbyP (const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
 batched version of donePbyP More...
 
static void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< ParticleSet > &p_list)
 acquire external resource and assocaite it with the list of ParticleSet Note: use RAII ResourceCollectionTeamLock whenever possible More...
 
static void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< ParticleSet > &p_list)
 release external resource Note: use RAII ResourceCollectionTeamLock whenever possible More...
 
static RefVectorWithLeader< DistanceTableextractDTRefList (const RefVectorWithLeader< ParticleSet > &p_list, int id)
 
static RefVectorWithLeader< DynamicCoordinatesextractCoordsRefList (const RefVectorWithLeader< ParticleSet > &p_list)
 
static RefVectorWithLeader< StructFactextractSKRefList (const RefVectorWithLeader< ParticleSet > &p_list)
 
- Protected Member Functions inherited from ParticleSet
void computeNewPosDistTables (Index_t iat, const SingleParticlePos &newpos, bool maybe_accept=true)
 compute temporal DistTables and SK for a new particle position More...
 
void acceptMoveForwardMode (Index_t iat)
 actual implemenation for accepting a proposed move in forward mode More...
 
void rejectMoveForwardMode (Index_t iat)
 reject a proposed move in forward mode More...
 
void resize (size_t numPtcl)
 resize internal storage More...
 
- Static Protected Member Functions inherited from ParticleSet
static void mw_computeNewPosDistTables (const RefVectorWithLeader< ParticleSet > &p_list, Index_t iat, const std::vector< SingleParticlePos > &new_positions, bool maybe_accept=true)
 compute temporal DistTables and SK for a new particle position for each walker in a batch More...
 

Detailed Description

A set of walkers that are to be advanced by Metropolis Monte Carlo.

As a derived class from ParticleSet, MCWalkerConfiguration interacts with QMCHamiltonian and TrialWaveFunction as a ParticleSet, while QMCDrivers use it as multiple walkers whose configurations are advanced according to MC algorithms.

Each walker is represented by Walker<PosVector_t> and MCWalkerConfiguration contains a list of the walkers. This class enables two possible moves:

  • move the entire active walkers, similarly to molecu. Suitable for small and big systems with a small time step.
  • move a particle for each walker. Suitable for large systems.

Definition at line 55 of file MCWalkerConfiguration.h.

Member Typedef Documentation

◆ const_iterator

using const_iterator = WalkerList_t::const_iterator

const_iterator of Walker container

Definition at line 74 of file MCWalkerConfiguration.h.

◆ iterator

using iterator = WalkerList_t::iterator

FIX: a type alias of iterator for an object should not be for just one of many objects it holds.

Definition at line 72 of file MCWalkerConfiguration.h.

◆ PropertyContainer_t

container type of the Properties of a Walker

Definition at line 68 of file MCWalkerConfiguration.h.

◆ ReptileList_t

Definition at line 76 of file MCWalkerConfiguration.h.

◆ Walker_t

◆ WalkerList_t

using WalkerList_t = std::vector<std::unique_ptr<Walker_t> >

container type of Walkers

Definition at line 70 of file MCWalkerConfiguration.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

enumeration for update

Enumerator
Update_All 
Update_Walker 

move all the active walkers

Update_Particle 

move a walker by walker

move a particle by particle

Definition at line 59 of file MCWalkerConfiguration.h.

60  {
61  Update_All = 0, ///move all the active walkers
62  Update_Walker, ///move a walker by walker
63  Update_Particle ///move a particle by particle
64  };

Constructor & Destructor Documentation

◆ MCWalkerConfiguration() [1/2]

default constructor

Definition at line 35 of file MCWalkerConfiguration.cpp.

36  : ParticleSet(simulation_cell, kind), ReadyForPbyP(false), UpdateMode(Update_Walker), reptile(0), Polymer(0)
37 {}
ParticleSet(const SimulationCell &simulation_cell, const DynamicCoordinateKind kind=DynamicCoordinateKind::DC_POS)
default constructor
Definition: ParticleSet.cpp:58
bool ReadyForPbyP
true if the buffer is ready for particle-by-particle updates

◆ MCWalkerConfiguration() [2/2]

default constructor: copy only ParticleSet

Definition at line 39 of file MCWalkerConfiguration.cpp.

References SampleStack::clearEnsemble(), MCWalkerConfiguration::getMaxSamples(), WalkerConfigurations::getWalkerOffsets(), ParticleSet::Properties, MCWalkerConfiguration::samples, SampleStack::setMaxSamples(), and WalkerConfigurations::setWalkerOffsets().

41 {
43  samples.setMaxSamples(mcw.getMaxSamples());
44  setWalkerOffsets(mcw.getWalkerOffsets());
45  Properties = mcw.Properties;
46 }
PropertyContainer_t Properties
properties of the current walker
Definition: ParticleSet.h:119
void setWalkerOffsets(const std::vector< int > &o)
return the total number of active walkers among a MPI group
void clearEnsemble()
clear the ensemble
Definition: SampleStack.cpp:51
ParticleSet(const SimulationCell &simulation_cell, const DynamicCoordinateKind kind=DynamicCoordinateKind::DC_POS)
default constructor
Definition: ParticleSet.cpp:58
bool ReadyForPbyP
true if the buffer is ready for particle-by-particle updates
void setMaxSamples(size_t n, size_t number_of_ranks=1)
set the number of max samples per rank.
Definition: SampleStack.cpp:23

◆ ~MCWalkerConfiguration()

~MCWalkerConfiguration ( )
default

Member Function Documentation

◆ clear()

void clear
inline

clean up the walker list

Definition at line 136 of file WalkerConfigurations.h.

Referenced by WalkerControlBase::copyWalkers().

136 { walker_list_.clear(); }
walker_list__t walker_list_
a collection of walkers

◆ clearEnsemble()

void clearEnsemble ( )

clear the ensemble

Definition at line 250 of file MCWalkerConfiguration.cpp.

References SampleStack::clearEnsemble(), and MCWalkerConfiguration::samples.

250 { samples.clearEnsemble(); }
void clearEnsemble()
clear the ensemble
Definition: SampleStack.cpp:51

◆ createWalkers()

void createWalkers ( int  numWalkers)

create numWalkers Walkers

Append Walkers to WalkerList.

Definition at line 50 of file MCWalkerConfiguration.cpp.

References WalkerConfigurations::createWalkers(), WalkerConfigurations::getActiveWalkers(), qmcplusplus::n, ParticleSet::R, MCWalkerConfiguration::resizeWalkerHistories(), ParticleSet::spins, ParticleSet::TotalNum, and WalkerConfigurations::walker_list_.

Referenced by QMCDriver::addWalkers(), QMCFixedSampleLinearOptimize::finish(), DMC::resetUpdateEngines(), and qmcplusplus::TEST_CASE().

51 {
52  const int old_nw = getActiveWalkers();
54  // no pre-existing walkers, need to initialized based on particleset.
55  if (old_nw == 0)
56  for (auto& awalker : walker_list_)
57  {
58  awalker->R = R;
59  awalker->spins = spins;
60  }
62 }
ParticleScalar spins
internal spin variables for dynamical spin calculations
Definition: ParticleSet.h:81
void resizeWalkerHistories()
resize Walker::PropertyHistory and Walker::PHindex:
size_t getActiveWalkers() const
return the number of active walkers
size_t TotalNum
total number of particles
Definition: ParticleSet.h:642
void createWalkers(int numWalkers, size_t numPtcls)
create numWalkers Walkers
ParticlePos R
Position.
Definition: ParticleSet.h:79
walker_list__t walker_list_
a collection of walkers

◆ dumpEnsemble()

bool dumpEnsemble ( std::vector< MCWalkerConfiguration *> &  others,
HDFWalkerOutput out,
int  np,
int  nBlock 
)
static

dump Samples to a file

Parameters
othersMCWalkerConfigurations whose samples will be collected
outengine to write the samples to state_0/walkers
npnumber of processors
Returns
true with non-zero samples

CAUTION: The current implementation assumes the same amount of active walkers on all the MPI ranks.

Definition at line 183 of file MCWalkerConfiguration.cpp.

References HDFWalkerOutput::dump(), WalkerConfigurations::getActiveWalkers(), omptarget::min(), WalkerConfigurations::push_back(), MCWalkerConfiguration::sample(), and WalkerConfigurations::setWalkerOffsets().

Referenced by VMC::run(), and CSVMC::run().

187 {
188  WalkerConfigurations wctemp;
189  for (auto* mcwc : others)
190  {
191  const auto& astack(mcwc->getSampleStack());
192  const size_t sample_size = std::min(mcwc->getMaxSamples(), mcwc->numSamples());
193  for (int j = 0; j < sample_size; ++j)
194  {
195  const auto& sample = astack.getSample(j);
196  const size_t num_ptcls = sample.getNumPtcls();
197  auto awalker = std::make_unique<Walker_t>(num_ptcls);
198  sample.convertToWalker(*awalker);
199  wctemp.push_back(std::move(awalker));
200  }
201  }
202  const int w = wctemp.getActiveWalkers();
203  if (w == 0)
204  return false;
205 
206  // The following code assumes the same amount of active walkers on all the MPI ranks
207  std::vector<int> nwoff(np + 1, 0);
208  for (int ip = 0; ip < np; ++ip)
209  nwoff[ip + 1] = nwoff[ip] + w;
210  wctemp.setWalkerOffsets(nwoff);
211  out.dump(wctemp, nBlock);
212  return true;
213 }
void sample(iterator it, RealType tauinv)
make random moves for all the walkers
T min(T a, T b)

◆ getLocalEnergy()

RealType getLocalEnergy ( ) const
inline

return LocalEnergy

Definition at line 114 of file MCWalkerConfiguration.h.

References MCWalkerConfiguration::LocalEnergy.

◆ getMaxSamples()

int getMaxSamples ( ) const

◆ getParticleNum()

int getParticleNum ( ) const
inline

return the number of particles per walker

Definition at line 104 of file MCWalkerConfiguration.h.

References ParticleSet::R, and Vector< T, Alloc >::size().

104 { return R.size(); }
size_type size() const
return the current size
Definition: OhmmsVector.h:162
ParticlePos R
Position.
Definition: ParticleSet.h:79

◆ getPolymer()

MultiChain* getPolymer ( )
inline

Definition at line 116 of file MCWalkerConfiguration.h.

References MCWalkerConfiguration::Polymer.

◆ getSampleStack() [1/2]

const SampleStack& getSampleStack ( ) const
inline

◆ getSampleStack() [2/2]

SampleStack& getSampleStack ( )
inline

Definition at line 152 of file MCWalkerConfiguration.h.

References MCWalkerConfiguration::samples.

◆ loadEnsemble() [1/2]

void loadEnsemble ( )

load SampleStack data to the current list of walker configurations

load SampleStack to walker_list_

Definition at line 164 of file MCWalkerConfiguration.cpp.

References SampleStack::clearEnsemble(), MCSample::convertToWalker(), SampleStack::empty(), SampleStack::getMaxSamples(), SampleStack::getNumSamples(), SampleStack::getSample(), omptarget::min(), ParticleSet::PropertyList, MCWalkerConfiguration::resizeWalkerHistories(), MCWalkerConfiguration::samples, RecordNamedProperty< T >::size(), ParticleSet::TotalNum, and WalkerConfigurations::walker_list_.

Referenced by DMC::resetUpdateEngines().

165 {
167  int nsamples = std::min(samples.getMaxSamples(), samples.getNumSamples());
168  if (samples.empty() || nsamples == 0)
169  return;
170  Walker_t::PropertyContainer_t prop(1, PropertyList.size(), 1, WP::MAXPROPERTIES);
171  walker_list_.resize(nsamples);
172  for (int i = 0; i < nsamples; ++i)
173  {
174  auto awalker = std::make_unique<Walker_t>(TotalNum);
175  awalker->Properties.copy(prop);
176  samples.getSample(i).convertToWalker(*awalker);
177  walker_list_[i] = std::move(awalker);
178  }
181 }
size_t getMaxSamples() const
Definition: SampleStack.h:34
void resizeWalkerHistories()
resize Walker::PropertyHistory and Walker::PHindex:
size_t TotalNum
total number of particles
Definition: ParticleSet.h:642
size_t getNumSamples() const
Definition: SampleStack.h:41
ConstantSizeMatrix< FullPrecRealType, std::allocator< FullPrecRealType > > PropertyContainer_t
typedef for the property container, fixed size
Definition: Walker.h:75
T min(T a, T b)
void clearEnsemble()
clear the ensemble
Definition: SampleStack.cpp:51
PropertySetType PropertyList
name-value map of Walker Properties
Definition: ParticleSet.h:112
WalkerProperties::Indexes WP
Definition: ParticleSet.cpp:34
const MCSample & getSample(size_t i) const
Definition: SampleStack.cpp:31
void convertToWalker(Walker_t &w) const
Definition: MCSample.h:61
Indexes
an enum denoting index of physical properties
walker_list__t walker_list_
a collection of walkers

◆ loadEnsemble() [2/2]

void loadEnsemble ( std::vector< MCWalkerConfiguration *> &  others,
bool  doclean = true 
)

load the SampleStacks of others to the current list of walker configurations

Definition at line 217 of file MCWalkerConfiguration.cpp.

References MCSample::convertToWalker(), MCWalkerConfiguration::getMaxSamples(), SampleStack::getSample(), MCWalkerConfiguration::getSampleStack(), omptarget::min(), MCWalkerConfiguration::numSamples(), WalkerConfigurations::pop_back(), ParticleSet::PropertyList, MCWalkerConfiguration::resizeWalkerHistories(), RecordNamedProperty< T >::size(), ParticleSet::TotalNum, and WalkerConfigurations::walker_list_.

218 {
220  std::vector<int> off(others.size() + 1, 0);
221  for (int i = 0; i < others.size(); ++i)
222  {
223  off[i + 1] = off[i] + std::min(others[i]->getMaxSamples(), others[i]->numSamples());
224  }
225  int nw_tot = off.back();
226  if (nw_tot)
227  {
228  Walker_t::PropertyContainer_t prop(1, PropertyList.size(), 1, WP::MAXPROPERTIES);
229  while (walker_list_.size())
230  pop_back();
231  walker_list_.resize(nw_tot);
232  for (int i = 0; i < others.size(); ++i)
233  {
234  SampleStack& astack(others[i]->getSampleStack());
235  for (int j = 0, iw = off[i]; iw < off[i + 1]; ++j, ++iw)
236  {
237  auto awalker = std::make_unique<Walker_t>(TotalNum);
238  awalker->Properties.copy(prop);
239  astack.getSample(j).convertToWalker(*awalker);
240  walker_list_[iw] = std::move(awalker);
241  }
242  if (doclean)
243  others[i]->clearEnsemble();
244  }
245  }
246  if (doclean)
248 }
void resizeWalkerHistories()
resize Walker::PropertyHistory and Walker::PHindex:
size_t TotalNum
total number of particles
Definition: ParticleSet.h:642
void pop_back()
delete the last Walker_t*
int getMaxSamples() const
Transitional forwarding methods.
ConstantSizeMatrix< FullPrecRealType, std::allocator< FullPrecRealType > > PropertyContainer_t
typedef for the property container, fixed size
Definition: Walker.h:75
T min(T a, T b)
PropertySetType PropertyList
name-value map of Walker Properties
Definition: ParticleSet.h:112
WalkerProperties::Indexes WP
Definition: ParticleSet.cpp:34
Indexes
an enum denoting index of physical properties
const SampleStack & getSampleStack() const
walker_list__t walker_list_
a collection of walkers

◆ loadSample()

void loadSample ( ParticleSet pset,
size_t  iw 
) const

load a single sample from SampleStack

Definition at line 160 of file MCWalkerConfiguration.cpp.

References SampleStack::loadSample(), qmcplusplus::pset, and MCWalkerConfiguration::samples.

Referenced by QMCCostFunction::checkConfigurations(), and QMCCostFunction::correlatedSampling().

160 { samples.loadSample(pset, iw); }
void loadSample(ParticleSet &pset, size_t iw) const
load a single sample from SampleStack
Definition: SampleStack.cpp:45

◆ numSamples()

◆ resetWalkerProperty()

void resetWalkerProperty ( int  ncopy = 1)

reset the Property container of all the walkers

Definition at line 97 of file MCWalkerConfiguration.cpp.

References APP_ABORT, qmcplusplus::app_error(), qmcplusplus::app_log(), qmcplusplus::Units::distance::m, ParticleSet::Properties, ParticleSet::PropertyList, ConstantSizeMatrix< T, ALLOC >::resize(), MCWalkerConfiguration::resizeWalkerHistories(), RecordNamedProperty< T >::size(), qmcplusplus::walker, and WalkerConfigurations::walker_list_.

Referenced by QMCDriver::process(), and qmcplusplus::TEST_CASE().

98 {
99  int m(PropertyList.size());
100  app_log() << " Resetting Properties of the walkers " << ncopy << " x " << m << std::endl;
101  try
102  {
103  Properties.resize(ncopy, m);
104  }
105  catch (std::domain_error& de)
106  {
107  app_error() << de.what() << '\n'
108  << "This is likely because some object has attempted to add walker properties\n"
109  << " in excess of WALKER_MAX_PROPERTIES.\n"
110  << "build with cmake ... -DWALKER_MAX_PROPERTIES=at_least_properties_required" << std::endl;
111  APP_ABORT("Fatal Exception");
112  }
113 
114  for (auto& walker : walker_list_)
115  {
116  walker->resizeProperty(ncopy, m);
117  walker->Weight = 1.0;
118  }
120 }
PropertyContainer_t Properties
properties of the current walker
Definition: ParticleSet.h:119
void resizeWalkerHistories()
resize Walker::PropertyHistory and Walker::PHindex:
std::ostream & app_log()
Definition: OutputManager.h:65
std::ostream & app_error()
Definition: OutputManager.h:67
PropertySetType PropertyList
name-value map of Walker Properties
Definition: ParticleSet.h:112
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
walker_list__t walker_list_
a collection of walkers

◆ resize()

void resize ( int  numWalkers,
int  numPtcls 
)

clean up the walker list and make a new list

Definition at line 65 of file MCWalkerConfiguration.cpp.

References qmcplusplus::app_warning(), WalkerConfigurations::getActiveWalkers(), ParticleSet::R, WalkerConfigurations::resize(), ParticleSet::resize(), ParticleSet::spins, ParticleSet::TotalNum, and WalkerConfigurations::walker_list_.

66 {
67  if (TotalNum && walker_list_.size())
68  app_warning() << "MCWalkerConfiguration::resize cleans up the walker list." << std::endl;
69  const int old_nw = getActiveWalkers();
70  ParticleSet::resize(unsigned(numPtcls));
72  // no pre-existing walkers, need to initialized based on particleset.
73  if (old_nw == 0)
74  for (auto& awalker : walker_list_)
75  {
76  awalker->R = R;
77  awalker->spins = spins;
78  }
79 }
std::ostream & app_warning()
Definition: OutputManager.h:69
ParticleScalar spins
internal spin variables for dynamical spin calculations
Definition: ParticleSet.h:81
size_t getActiveWalkers() const
return the number of active walkers
size_t TotalNum
total number of particles
Definition: ParticleSet.h:642
void resize(size_t numPtcl)
resize internal storage
Definition: ParticleSet.h:683
ParticlePos R
Position.
Definition: ParticleSet.h:79
void resize(int numWalkers, size_t numPtcls)
clean up the walker list and make a new list
walker_list__t walker_list_
a collection of walkers

◆ resizeWalkerHistories()

void resizeWalkerHistories ( )

resize Walker::PropertyHistory and Walker::PHindex:

Definition at line 122 of file MCWalkerConfiguration.cpp.

References ParticleSet::PHindex, ParticleSet::PropertyHistory, and WalkerConfigurations::walker_list_.

Referenced by MCWalkerConfiguration::createWalkers(), MCWalkerConfiguration::loadEnsemble(), and MCWalkerConfiguration::resetWalkerProperty().

123 {
124  //using std::vector<std::vector<RealType> > is too costly.
125  int np = PropertyHistory.size();
126  if (np)
127  for (int iw = 0; iw < walker_list_.size(); ++iw)
129  np = PHindex.size();
130  if (np)
131  for (int iw = 0; iw < walker_list_.size(); ++iw)
133  ;
134 }
std::vector< std::vector< FullPrecRealType > > PropertyHistory
Property history vector.
Definition: ParticleSet.h:129
std::vector< int > PHindex
Definition: ParticleSet.h:130
walker_list__t walker_list_
a collection of walkers

◆ sample()

void sample ( iterator  it,
RealType  tauinv 
)

make random moves for all the walkers

Make Metropolis move to the walkers and save in a temporary array.

make a random move for a walker

Parameters
itthe iterator of the first walker to work on
tauinvinverse of the time step

R + D + X

Definition at line 87 of file MCWalkerConfiguration.cpp.

Referenced by MCWalkerConfiguration::dumpEnsemble().

88 {
89  throw std::runtime_error("MCWalkerConfiguration::sample obsolete");
90  // makeGaussRandom(R);
91  // R *= tauinv;
92  // R += (*it)->R + (*it)->Drift;
93 }

◆ saveEnsemble() [1/2]

void saveEnsemble ( )

save the position of current walkers to SampleStack

save the current walkers to SampleStack

Definition at line 147 of file MCWalkerConfiguration.cpp.

References WalkerConfigurations::walker_list_.

147 { saveEnsemble(walker_list_.begin(), walker_list_.end()); }
void saveEnsemble()
save the position of current walkers to SampleStack
walker_list__t walker_list_
a collection of walkers

◆ saveEnsemble() [2/2]

void saveEnsemble ( iterator  first,
iterator  last 
)

save the position of current walkers

save the [first,last) walkers to SampleStack

Definition at line 151 of file MCWalkerConfiguration.cpp.

References SampleStack::appendSample(), ParticleSet::first(), ParticleSet::last(), and MCWalkerConfiguration::samples.

152 {
153  for (; first != last; first++)
154  {
155  samples.appendSample(MCSample(**first));
156  }
157 }
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
void appendSample(MCSample &&sample)
Definition: SampleStack.cpp:33

◆ setLocalEnergy()

void setLocalEnergy ( RealType  e)
inline

set LocalEnergy

Parameters
ecurrent average Local Energy

Definition at line 110 of file MCWalkerConfiguration.h.

References qmcplusplus::Units::charge::e, and MCWalkerConfiguration::LocalEnergy.

◆ setNumSamples()

void setNumSamples ( int  n)

set the number of max samples

allocate the SampleStack

Parameters
nnumber of samples per thread

Definition at line 139 of file MCWalkerConfiguration.cpp.

References SampleStack::clearEnsemble(), qmcplusplus::n, MCWalkerConfiguration::samples, and SampleStack::setMaxSamples().

140 {
143 }
void clearEnsemble()
clear the ensemble
Definition: SampleStack.cpp:51
void setMaxSamples(size_t n, size_t number_of_ranks=1)
set the number of max samples per rank.
Definition: SampleStack.cpp:23

◆ setPolymer()

void setPolymer ( MultiChain *  chain)
inline

Definition at line 118 of file MCWalkerConfiguration.h.

References MCWalkerConfiguration::Polymer.

118 { Polymer = chain; }

◆ updatePbyP()

bool updatePbyP ( ) const
inline

Definition at line 122 of file MCWalkerConfiguration.h.

References MCWalkerConfiguration::ReadyForPbyP.

122 { return ReadyForPbyP; }
bool ReadyForPbyP
true if the buffer is ready for particle-by-particle updates

Friends And Related Function Documentation

◆ MCPopulation

friend class MCPopulation
friend

Definition at line 171 of file MCWalkerConfiguration.h.

Member Data Documentation

◆ LocalEnergy

RealType LocalEnergy
protected

◆ Polymer

MultiChain* Polymer
private

◆ ReadyForPbyP

bool ReadyForPbyP
protected

true if the buffer is ready for particle-by-particle updates

Definition at line 160 of file MCWalkerConfiguration.h.

Referenced by MCWalkerConfiguration::updatePbyP().

◆ reptile

◆ ReptileList

ReptileList_t ReptileList

a collection of reptiles contained in MCWalkerConfiguration.

Definition at line 168 of file MCWalkerConfiguration.h.

Referenced by RMC::resetReptiles(), and RMC::resetRun().

◆ samples

◆ UpdateMode

int UpdateMode
protected

update-mode index

Definition at line 162 of file MCWalkerConfiguration.h.


The documentation for this class was generated from the following files: