QMCPACK
VirtualParticleSet Class Reference

A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtual moves are defined as moves being proposed but will never be accepted. More...

+ Inheritance diagram for VirtualParticleSet:
+ Collaboration diagram for VirtualParticleSet:

Public Member Functions

const ParticleSetgetRefPS () const
 ParticleSet this object refers to. More...
 
bool isOnSphere () const
 
const Vector< int, OffloadPinnedAllocator< int > > & getMultiWalkerRefPctls () const
 
 VirtualParticleSet (const ParticleSet &p, int nptcl, size_t dt_count_limit=0)
 constructor More...
 
 ~VirtualParticleSet ()
 
void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
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 More...
 
size_t getTotalNum () const
 
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 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...
 

Static Public Member Functions

static void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< VirtualParticleSet > &vp_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< VirtualParticleSet > &vp_list)
 release external resource Note: use RAII ResourceCollectionTeamLock whenever possible More...
 
static const RefVectorWithLeader< const DistanceTableABextractDTRefList (const RefVectorWithLeader< const VirtualParticleSet > &vp_list, int id)
 Extract list of Distance Tables. More...
 
static const std::vector< QMCTraits::PosTypeextractVPCoords (const RefVectorWithLeader< const VirtualParticleSet > &vp_list)
 Extract list of VP coordinates, flattened over all walkers. More...
 
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)
 
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)
 
static RefVectorWithLeader< ParticleSetRefVectorWithLeaderParticleSet (const RefVectorWithLeader< VirtualParticleSet > &vp_list)
 
static size_t countVPs (const RefVectorWithLeader< const VirtualParticleSet > &vp_list)
 
static size_t countVPs (const RefVectorWithLeader< VirtualParticleSet > &vp_list)
 
- 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)
 

Public Attributes

int refPtcl
 Reference particle. More...
 
int refSourcePtcl
 Reference source particle, used when onSphere=true. More...
 
- 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
 

Private Member Functions

Vector< int, OffloadPinnedAllocator< int > > & getMultiWalkerRefPctls ()
 

Private Attributes

bool onSphere
 true, if virtual particles are on a sphere for NLPP More...
 
ResourceHandle< VPMultiWalkerMemmw_mem_handle_
 multi walker resource More...
 
std::optional< std::reference_wrapper< const ParticleSet > > refPS
 ParticleSet this object refers to after makeMoves. More...
 

Additional Inherited Members

- 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
 
- 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...
 
- 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...
 

Detailed Description

A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtual moves are defined as moves being proposed but will never be accepted.

VirtualParticleSet is introduced to avoid changing any internal states of the physical ParticleSet. For this reason, the physical ParticleSet is always marked const. It is heavily used by non-local PP evaluations.

Definition at line 39 of file VirtualParticleSet.h.

Constructor & Destructor Documentation

◆ VirtualParticleSet()

VirtualParticleSet ( const ParticleSet p,
int  nptcl,
size_t  dt_count_limit = 0 
)

constructor

Parameters
pParticleSet whose virtual moves are handled by this object
nptclnumber of virtual particles
dt_count_limitdistance tables corresepond to [0, dt_count_limit) of the reference particle set are created

Definition at line 40 of file VirtualParticleSet.cpp.

References ParticleSet::addTable(), ParticleSet::coordinates_, ParticleSet::getDistTable(), ParticleSet::getNumDistTables(), ParticleSet::isSpinor(), qmcplusplus::MW_EVALUATE_RESULT_NO_TRANSFER_TO_HOST, qmcplusplus::NEED_VP_FULL_TABLE_ON_HOST, ParticleSet::R, Vector< T, Alloc >::resize(), ParticleSet::setName(), ParticleSet::setSpinor(), ParticleSet::spins, and ParticleSet::TotalNum.

41  : ParticleSet(p.getSimulationCell())
42 {
43  setName("virtual");
44 
45  //initialize local data structure
46  setSpinor(p.isSpinor());
47  TotalNum = nptcl;
48  R.resize(nptcl);
49  if (isSpinor())
50  spins.resize(nptcl);
51  coordinates_->resize(nptcl);
52 
53  //create distancetables
54  assert(dt_count_limit <= p.getNumDistTables());
55  if (dt_count_limit == 0)
56  dt_count_limit = p.getNumDistTables();
57  for (int i = 0; i < dt_count_limit; ++i)
58  if (p.getDistTable(i).getModes() & DTModes::NEED_VP_FULL_TABLE_ON_HOST)
59  addTable(p.getDistTable(i).get_origin());
60  else
61  addTable(p.getDistTable(i).get_origin(), DTModes::MW_EVALUATE_RESULT_NO_TRANSFER_TO_HOST);
62 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
void setName(const std::string &aname)
Definition: ParticleSet.h:237
ParticleScalar spins
internal spin variables for dynamical spin calculations
Definition: ParticleSet.h:81
size_t TotalNum
total number of particles
Definition: ParticleSet.h:642
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.
ParticleSet(const SimulationCell &simulation_cell, const DynamicCoordinateKind kind=DynamicCoordinateKind::DC_POS)
default constructor
Definition: ParticleSet.cpp:58
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
ParticlePos R
Position.
Definition: ParticleSet.h:79
std::unique_ptr< DynamicCoordinates > coordinates_
internal representation of R. It can be an SoA copy of R
Definition: ParticleSet.h:648
void setSpinor(bool is_spinor)
Definition: ParticleSet.h:257
skip data transfer back to host after mw_evalaute full distance table.

◆ ~VirtualParticleSet()

~VirtualParticleSet ( )
default

Member Function Documentation

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< VirtualParticleSet > &  vp_list 
)
static

acquire external resource and assocaite it with the list of ParticleSet Note: use RAII ResourceCollectionTeamLock whenever possible

Definition at line 82 of file VirtualParticleSet.cpp.

References ParticleSet::acquireResource(), RefVectorWithLeader< T >::getLeader(), ResourceCollection::lendResource(), and VirtualParticleSet::RefVectorWithLeaderParticleSet().

84 {
85  auto& vp_leader = vp_list.getLeader();
86  vp_leader.mw_mem_handle_ = collection.lendResource<VPMultiWalkerMem>();
87 
88  auto p_list = RefVectorWithLeaderParticleSet(vp_list);
89  ParticleSet::acquireResource(collection, p_list);
90 }
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...
static RefVectorWithLeader< ParticleSet > RefVectorWithLeaderParticleSet(const RefVectorWithLeader< VirtualParticleSet > &vp_list)

◆ countVPs() [1/2]

static size_t countVPs ( const RefVectorWithLeader< const VirtualParticleSet > &  vp_list)
inlinestatic

Definition at line 146 of file VirtualParticleSet.h.

Referenced by LCAOrbitalSet::mw_evaluateDetRatios(), VirtualParticleSet::mw_makeMoves(), and VirtualParticleSet::mw_makeMovesWithSpin().

147  {
148  size_t nVPs = 0;
149  for (const VirtualParticleSet& vp : vp_list)
150  nVPs += vp.getTotalNum();
151  return nVPs;
152  }
VirtualParticleSet(const ParticleSet &p, int nptcl, size_t dt_count_limit=0)
constructor

◆ countVPs() [2/2]

static size_t countVPs ( const RefVectorWithLeader< VirtualParticleSet > &  vp_list)
inlinestatic

Definition at line 154 of file VirtualParticleSet.h.

155  {
156  size_t nVPs = 0;
157  for (const VirtualParticleSet& vp : vp_list)
158  nVPs += vp.getTotalNum();
159  return nVPs;
160  }
VirtualParticleSet(const ParticleSet &p, int nptcl, size_t dt_count_limit=0)
constructor

◆ createResource()

void createResource ( ResourceCollection collection) const

initialize a shared resource and hand it to a collection

Definition at line 76 of file VirtualParticleSet.cpp.

References ResourceCollection::addResource(), and ParticleSet::createResource().

Referenced by qmcplusplus::TEST_CASE(), qmcplusplus::test_LCAO_DiamondC_2x1x1_cplx(), and qmcplusplus::test_LCAO_DiamondC_2x1x1_real().

77 {
78  collection.addResource(std::make_unique<VPMultiWalkerMem>());
79  ParticleSet::createResource(collection);
80 }
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection

◆ extractDTRefList()

const RefVectorWithLeader< const DistanceTableAB > extractDTRefList ( const RefVectorWithLeader< const VirtualParticleSet > &  vp_list,
int  id 
)
static

Extract list of Distance Tables.

Definition at line 101 of file VirtualParticleSet.cpp.

References RefVectorWithLeader< T >::getLeader().

104 {
105  RefVectorWithLeader<const DistanceTableAB> dt_list(vp_list.getLeader().getDistTableAB(id));
106  dt_list.reserve(vp_list.size());
107  for (const VirtualParticleSet& vp : vp_list)
108  {
109  const auto& d_table = vp.getDistTableAB(id);
110  dt_list.push_back(d_table);
111  }
112  return dt_list;
113 }
VirtualParticleSet(const ParticleSet &p, int nptcl, size_t dt_count_limit=0)
constructor

◆ extractVPCoords()

const std::vector< QMCTraits::PosType > extractVPCoords ( const RefVectorWithLeader< const VirtualParticleSet > &  vp_list)
static

Extract list of VP coordinates, flattened over all walkers.

Definition at line 116 of file VirtualParticleSet.cpp.

118 {
119  std::vector<QMCTraits::PosType> coords_list;
120  for (const VirtualParticleSet& vp : vp_list)
121  for (int iat = 0; iat < vp.getTotalNum(); iat++)
122  coords_list.push_back(vp.R[iat]);
123 
124  return coords_list;
125 }
VirtualParticleSet(const ParticleSet &p, int nptcl, size_t dt_count_limit=0)
constructor

◆ getMultiWalkerRefPctls() [1/2]

Vector< int, OffloadPinnedAllocator< int > > & getMultiWalkerRefPctls ( )
private

Definition at line 66 of file VirtualParticleSet.cpp.

References VirtualParticleSet::mw_mem_handle_.

67 {
68  return mw_mem_handle_.getResource().mw_refPctls;
69 }
ResourceHandle< VPMultiWalkerMem > mw_mem_handle_
multi walker resource

◆ getMultiWalkerRefPctls() [2/2]

const Vector< int, OffloadPinnedAllocator< int > > & getMultiWalkerRefPctls ( ) const

Definition at line 71 of file VirtualParticleSet.cpp.

References VirtualParticleSet::mw_mem_handle_.

72 {
73  return mw_mem_handle_.getResource().mw_refPctls;
74 }
ResourceHandle< VPMultiWalkerMem > mw_mem_handle_
multi walker resource

◆ getRefPS()

◆ getTotalNum()

◆ isOnSphere()

bool isOnSphere ( ) const
inline

Definition at line 61 of file VirtualParticleSet.h.

References VirtualParticleSet::onSphere.

Referenced by HybridRepCplx< SPLINEBASE >::evaluateDetRatios(), and HybridRepReal< SPLINEBASE >::evaluateDetRatios().

61 { return onSphere; }
bool onSphere
true, if virtual particles are on a sphere for NLPP

◆ makeMoves()

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

Parameters
refpreference particle set
jelreference particle that all the VP moves from
deltaVPosition delta for virtual moves.
sphereset true if VP are on a sphere around the reference source particle
iatreference source particle

Definition at line 129 of file VirtualParticleSet.cpp.

References qmcplusplus::if(), ParticleSet::isSpinor(), VirtualParticleSet::onSphere, ParticleSet::R, VirtualParticleSet::refPS, VirtualParticleSet::refPtcl, VirtualParticleSet::refSourcePtcl, Vector< T, Alloc >::size(), ParticleSet::spins, and ParticleSet::update().

Referenced by NonLocalECPComponent::evaluateOne(), SOECPComponent::evaluateOneExactSpinIntegration(), NonLocalECPComponent::evaluateOneWithForces(), NonLocalECPComponent::evaluateValueAndDerivatives(), WaveFunctionTester::runRatioV(), qmcplusplus::TEST_CASE(), qmcplusplus::test_DiracDeterminant_first(), qmcplusplus::test_DiracDeterminantBatched_first(), qmcplusplus::test_J3_polynomial3D(), qmcplusplus::test_LiH_msd(), and qmcplusplus::test_Ne().

134 {
135  if (sphere && iat < 0)
136  throw std::runtime_error(
137  "VirtualParticleSet::makeMoves is invoked incorrectly, the flag sphere=true requires iat specified!");
138  onSphere = sphere;
139  refPS = refp;
140  refPtcl = jel;
141  refSourcePtcl = iat;
142  assert(R.size() == deltaV.size());
143  for (size_t ivp = 0; ivp < R.size(); ivp++)
144  R[ivp] = refp.R[jel] + deltaV[ivp];
145  if (refp.isSpinor())
146  for (size_t ivp = 0; ivp < R.size(); ivp++)
147  spins[ivp] = refp.spins[jel]; //no spin deltas in this API
148  update();
149 }
std::optional< std::reference_wrapper< const ParticleSet > > refPS
ParticleSet this object refers to after makeMoves.
ParticleScalar spins
internal spin variables for dynamical spin calculations
Definition: ParticleSet.h:81
if(c->rank()==0)
int refSourcePtcl
Reference source particle, used when onSphere=true.
int refPtcl
Reference particle.
void update(bool skipSK=false)
update the internal data
size_type size() const
return the current size
Definition: OhmmsVector.h:162
ParticlePos R
Position.
Definition: ParticleSet.h:79
bool onSphere
true, if virtual particles are on a sphere for NLPP

◆ makeMovesWithSpin()

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

Parameters
refpreference particle set
jelreference particle that all the VP moves from
deltaVPosition delta for virtual moves.
deltaSSpin delta for virtual moves.
sphereset true if VP are on a sphere around the reference source particle
iatreference source particle

Definition at line 152 of file VirtualParticleSet.cpp.

References ParticleSet::isSpinor(), VirtualParticleSet::onSphere, ParticleSet::R, VirtualParticleSet::refPS, VirtualParticleSet::refPtcl, VirtualParticleSet::refSourcePtcl, Vector< T, Alloc >::size(), ParticleSet::spins, and ParticleSet::update().

Referenced by SOECPComponent::evaluateOne(), and SOECPComponent::evaluateValueAndDerivatives().

158 {
159  assert(refp.isSpinor());
160  if (sphere && iat < 0)
161  throw std::runtime_error(
162  "VirtualParticleSet::makeMovesWithSpin is invoked incorrectly, the flag sphere=true requires iat specified!");
163  onSphere = sphere;
164  refPS = refp;
165  refPtcl = jel;
166  refSourcePtcl = iat;
167  assert(R.size() == deltaV.size());
168  assert(spins.size() == deltaS.size());
169  for (size_t ivp = 0; ivp < R.size(); ivp++)
170  {
171  R[ivp] = refp.R[jel] + deltaV[ivp];
172  spins[ivp] = refp.spins[jel] + deltaS[ivp];
173  }
174  update();
175 }
std::optional< std::reference_wrapper< const ParticleSet > > refPS
ParticleSet this object refers to after makeMoves.
ParticleScalar spins
internal spin variables for dynamical spin calculations
Definition: ParticleSet.h:81
int refSourcePtcl
Reference source particle, used when onSphere=true.
int refPtcl
Reference particle.
void update(bool skipSK=false)
update the internal data
size_type size() const
return the current size
Definition: OhmmsVector.h:162
ParticlePos R
Position.
Definition: ParticleSet.h:79
bool onSphere
true, if virtual particles are on a sphere for NLPP

◆ mw_makeMoves()

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 
)
static

Definition at line 177 of file VirtualParticleSet.cpp.

References VirtualParticleSet::countVPs(), NLPPJob< T >::electron_id, RefVectorWithLeader< T >::getLeader(), NLPPJob< T >::ion_id, ParticleSet::mw_update(), VirtualParticleSet::onSphere, ParticleSet::R, VirtualParticleSet::refPS, VirtualParticleSet::refPtcl, VirtualParticleSet::refSourcePtcl, Vector< T, Alloc >::size(), and ParticleSet::spins.

Referenced by NonLocalECPComponent::mw_evaluateOne(), qmcplusplus::test_J1_spline(), qmcplusplus::test_J3_polynomial3D(), qmcplusplus::test_LCAO_DiamondC_2x1x1_cplx(), qmcplusplus::test_LCAO_DiamondC_2x1x1_real(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

182 {
183  auto& vp_leader = vp_list.getLeader();
184  vp_leader.onSphere = sphere;
185  vp_leader.refPS = refp_list.getLeader();
186 
187  const size_t nVPs = countVPs(vp_list);
188  auto& mw_refPctls = vp_leader.getMultiWalkerRefPctls();
189  mw_refPctls.resize(nVPs);
190 
191  RefVectorWithLeader<ParticleSet> p_list(vp_leader);
192  p_list.reserve(vp_list.size());
193 
194  size_t ivp = 0;
195  for (int iw = 0; iw < vp_list.size(); iw++)
196  {
197  VirtualParticleSet& vp(vp_list[iw]);
198  const std::vector<PosType>& deltaV(deltaV_list[iw]);
199  const NLPPJob<RealType>& job(joblist[iw]);
200 
201  vp.onSphere = sphere;
202  vp.refPS = refp_list[iw];
203  vp.refPtcl = job.electron_id;
204  vp.refSourcePtcl = job.ion_id;
205  assert(vp.R.size() == deltaV.size());
206  for (size_t k = 0; k < vp.R.size(); k++, ivp++)
207  {
208  vp.R[k] = refp_list[iw].R[vp.refPtcl] + deltaV[k];
209  if (vp_leader.isSpinor())
210  vp.spins[k] = refp_list[iw].spins[vp.refPtcl]; //no spin deltas in this API
211  mw_refPctls[ivp] = vp.refPtcl;
212  }
213  p_list.push_back(vp);
214  }
215  assert(ivp == nVPs);
216 
217  mw_refPctls.updateTo();
218  ParticleSet::mw_update(p_list);
219 }
VirtualParticleSet(const ParticleSet &p, int nptcl, size_t dt_count_limit=0)
constructor
static void mw_update(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
batched version of update
static size_t countVPs(const RefVectorWithLeader< const VirtualParticleSet > &vp_list)

◆ mw_makeMovesWithSpin()

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 
)
static

Definition at line 221 of file VirtualParticleSet.cpp.

References VirtualParticleSet::countVPs(), NLPPJob< T >::electron_id, RefVectorWithLeader< T >::getLeader(), NLPPJob< T >::ion_id, ParticleSet::mw_update(), VirtualParticleSet::onSphere, ParticleSet::R, VirtualParticleSet::refPS, VirtualParticleSet::refPtcl, VirtualParticleSet::refSourcePtcl, Vector< T, Alloc >::size(), and ParticleSet::spins.

Referenced by SOECPComponent::mw_evaluateOne().

227 {
228  auto& vp_leader = vp_list.getLeader();
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;
233  vp_leader.refPS = refp_list.getLeader();
234 
235  const size_t nVPs = countVPs(vp_list);
236  auto& mw_refPctls = vp_leader.getMultiWalkerRefPctls();
237  mw_refPctls.resize(nVPs);
238 
239  RefVectorWithLeader<ParticleSet> p_list(vp_leader);
240  p_list.reserve(vp_list.size());
241 
242  size_t ivp = 0;
243  for (int iw = 0; iw < vp_list.size(); iw++)
244  {
245  VirtualParticleSet& vp(vp_list[iw]);
246  const std::vector<PosType>& deltaV(deltaV_list[iw]);
247  const std::vector<RealType>& deltaS(deltaS_list[iw]);
248  const NLPPJob<RealType>& job(joblist[iw]);
249 
250  vp.onSphere = sphere;
251  vp.refPS = refp_list[iw];
252  vp.refPtcl = job.electron_id;
253  vp.refSourcePtcl = job.ion_id;
254  assert(vp.R.size() == deltaV.size());
255  assert(vp.spins.size() == deltaS.size());
256  assert(vp.R.size() == vp.spins.size());
257  for (size_t k = 0; k < vp.R.size(); k++, ivp++)
258  {
259  vp.R[k] = refp_list[iw].R[vp.refPtcl] + deltaV[k];
260  vp.spins[k] = refp_list[iw].spins[vp.refPtcl] + deltaS[k];
261  mw_refPctls[ivp] = vp.refPtcl;
262  }
263  p_list.push_back(vp);
264  }
265  assert(ivp == nVPs);
266 
267  mw_refPctls.updateTo();
268  ParticleSet::mw_update(p_list);
269 }
VirtualParticleSet(const ParticleSet &p, int nptcl, size_t dt_count_limit=0)
constructor
static void mw_update(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
batched version of update
static size_t countVPs(const RefVectorWithLeader< const VirtualParticleSet > &vp_list)

◆ RefVectorWithLeaderParticleSet()

static RefVectorWithLeader<ParticleSet> RefVectorWithLeaderParticleSet ( const RefVectorWithLeader< VirtualParticleSet > &  vp_list)
inlinestatic

Definition at line 136 of file VirtualParticleSet.h.

References RefVectorWithLeader< T >::getLeader().

Referenced by VirtualParticleSet::acquireResource(), and VirtualParticleSet::releaseResource().

138  {
139  RefVectorWithLeader<ParticleSet> ref_list(vp_list.getLeader());
140  ref_list.reserve(ref_list.size());
141  for (VirtualParticleSet& vp : vp_list)
142  ref_list.push_back(vp);
143  return ref_list;
144  }
VirtualParticleSet(const ParticleSet &p, int nptcl, size_t dt_count_limit=0)
constructor

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< VirtualParticleSet > &  vp_list 
)
static

release external resource Note: use RAII ResourceCollectionTeamLock whenever possible

Definition at line 92 of file VirtualParticleSet.cpp.

References RefVectorWithLeader< T >::getLeader(), VirtualParticleSet::RefVectorWithLeaderParticleSet(), ParticleSet::releaseResource(), and ResourceCollection::takebackResource().

94 {
95  collection.takebackResource(vp_list.getLeader().mw_mem_handle_);
96  auto p_list = RefVectorWithLeaderParticleSet(vp_list);
97  ParticleSet::releaseResource(collection, p_list);
98 }
static void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< ParticleSet > &p_list)
release external resource Note: use RAII ResourceCollectionTeamLock whenever possible ...
static RefVectorWithLeader< ParticleSet > RefVectorWithLeaderParticleSet(const RefVectorWithLeader< VirtualParticleSet > &vp_list)

Member Data Documentation

◆ mw_mem_handle_

◆ onSphere

◆ refPS

std::optional<std::reference_wrapper<const ParticleSet> > refPS
private

◆ refPtcl

◆ refSourcePtcl


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