QMCPACK
ParticleSetPool.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 /**@file ParticleSetPool.h
16  * @brief Declaration of ParticleSetPool
17  */
18 #ifndef QMCPLUSPLUS_PARTICLESETPOOL_H
19 #define QMCPLUSPLUS_PARTICLESETPOOL_H
20 
23 #include "Message/MPIObjectBase.h"
24 #include "SimulationCell.h"
25 
26 namespace qmcplusplus
27 {
28 /** @ingroup qmcapp
29  * @brief Manage a collection of ParticleSet objects
30  *
31  * This object handles <particleset> elements and
32  * functions as a builder class for ParticleSet objects.
33  */
35 {
36 public:
37  using PoolType = std::map<std::string, const std::unique_ptr<ParticleSet>>;
38 
39  /** constructor
40  * @param aname xml tag
41  */
42  ParticleSetPool(Communicate* c, const char* aname = "particleset");
44 
45  ParticleSetPool(const ParticleSetPool&) = delete;
46  ParticleSetPool& operator=(const ParticleSetPool&) = delete;
49 
50  bool put(xmlNodePtr cur);
51  bool get(std::ostream& os) const;
52  void reset();
53 
54  void output_particleset_info(Libxml2Document& doc, xmlNodePtr root);
55 
56  /** initialize the supercell shared by all the particle sets
57  *
58  * return value is never checked anywhere
59  * side effect simulation_cell_ UPtr<ParticleLayout> is set
60  * to particle layout created on heap.
61  * This is later directly assigned to pset member variable Lattice.
62  */
63  bool readSimulationCellXML(xmlNodePtr cur);
64 
65  ///return true, if the pool is empty
66  inline bool empty() const { return myPool.empty(); }
67 
68  /** add a ParticleSet* to the pool with its ownership transferred
69  * ParticleSet built outside the ParticleSetPool must be constructed with
70  * the simulation cell from this->simulation_cell_.
71  */
72  void addParticleSet(std::unique_ptr<ParticleSet>&& p);
73 
74  /** get a named ParticleSet
75  * @param pname name of the ParticleSet
76  * @return a MCWalkerConfiguration object with pname
77  *
78  * When the named ParticleSet is not in this object, return 0.
79  */
80  ParticleSet* getParticleSet(const std::string& pname);
81 
82  /** get a named MCWalkerConfiguration
83  * @param pname name of the MCWalkerConfiguration
84  * @return a MCWalkerConfiguration object with pname
85  *
86  * When the named MCWalkerConfiguration is not in this object, return 0.
87  */
88  MCWalkerConfiguration* getWalkerSet(const std::string& pname);
89 
90  /** get the Pool object
91  */
92  inline const PoolType& getPool() const { return myPool; }
93 
94  /// get simulation cell
95  const auto& getSimulationCell() const { return *simulation_cell_; }
96 
97  /// set simulation cell
98  void setSimulationCell(const SimulationCell& simulation_cell) { *simulation_cell_ = simulation_cell; }
99 
100  /** randomize a particleset particleset/@random='yes' && particleset@random_source exists
101  */
102  void randomize();
103 
104 private:
105  /** global simulation cell
106  *
107  * updated by
108  * - readSimulationCellXML() parsing <simulationcell> element
109  * - setSimulationCell()
110  */
111  std::unique_ptr<SimulationCell> simulation_cell_;
112  /** List of ParticleSet owned
113  *
114  * Each ParticleSet has to have a unique name which is used as a key for the map.
115  */
117  /** xml node for random initialization.
118  *
119  * randomize() process initializations just before starting qmc sections
120  */
121  std::vector<xmlNodePtr> randomize_nodes;
122 };
123 } // namespace qmcplusplus
124 #endif
MCWalkerConfiguration * getWalkerSet(const std::string &pname)
get a named MCWalkerConfiguration
void setSimulationCell(const SimulationCell &simulation_cell)
set simulation cell
class that handles xmlDoc
Definition: Libxml2Doc.h:76
ParticleSetPool(Communicate *c, const char *aname="particleset")
constructor
A set of walkers that are to be advanced by Metropolis Monte Carlo.
Base class for any object which needs to know about a MPI communicator.
Definition: MPIObjectBase.h:26
void reset()
reset is used to initialize and evaluate the distance tables
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
bool put(xmlNodePtr cur)
process an xml element
void addParticleSet(std::unique_ptr< ParticleSet > &&p)
add a ParticleSet* to the pool with its ownership transferred ParticleSet built outside the ParticleS...
declaration of MPIObjectBase
std::map< std::string, const std::unique_ptr< ParticleSet > > PoolType
void output_particleset_info(Libxml2Document &doc, xmlNodePtr root)
Declaration of OhmmsElementBase and define xml-related macros.
ParticleSetPool & operator=(const ParticleSetPool &)=delete
Wrapping information on parallelism.
Definition: Communicate.h:68
std::unique_ptr< SimulationCell > simulation_cell_
global simulation cell
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
ParticleSet * getParticleSet(const std::string &pname)
get a named ParticleSet
Manage a collection of ParticleSet objects.
std::vector< xmlNodePtr > randomize_nodes
xml node for random initialization.
bool readSimulationCellXML(xmlNodePtr cur)
initialize the supercell shared by all the particle sets
void randomize()
randomize a particleset particleset/=&#39;yes&#39; && particleset exists
const PoolType & getPool() const
get the Pool object
Declaration of a MCWalkerConfiguration.
bool empty() const
return true, if the pool is empty
const auto & getSimulationCell() const
get simulation cell
PoolType myPool
List of ParticleSet owned.