QMCPACK
HamiltonianPool.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: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 //
10 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 /**@file HamiltonianPool.h
15  * @brief Declaration of HamiltonianPool
16  */
17 #ifndef QMCPLUSPLUS_QMCHAMILTONIANS_H
18 #define QMCPLUSPLUS_QMCHAMILTONIANS_H
19 
22 #include "Message/MPIObjectBase.h"
23 #include <map>
24 
25 struct Libxml2Document;
26 
27 namespace qmcplusplus
28 {
29 class ParticleSet;
30 class MCWalkerConfiguration;
31 class ParticleSetPool;
32 class WaveFunctionPool;
33 
34 /** @ingroup qmcapp
35  * @brief Manage a collection of QMCHamiltonian objects
36  *
37  * This object handles <hamiltonian> elements and
38  * functions as a builder class for QMCHamiltonian objects.
39  */
41 {
42 public:
43  using PoolType = std::map<std::string, HamiltonianFactory*>;
44 
46  WaveFunctionPool& psi_pool,
47  Communicate* c,
48  const char* aname = "hamiltonian");
49  HamiltonianPool(const HamiltonianPool&) = delete;
50  HamiltonianPool& operator=(const HamiltonianPool&) = delete;
51  HamiltonianPool(HamiltonianPool&&) = default;
54 
55  bool put(xmlNodePtr cur);
56  bool get(std::ostream& os) const;
57  void reset();
58 
59  inline bool empty() const { return myPool.empty(); }
60 
61  /** return the pointer to the primary QMCHamiltonian
62  *
63  * The first QMCHamiltonian is assigned to the primaryH.
64  * The last QMCHamiltonian with role="primary" will be the primaryH.
65  */
66  inline QMCHamiltonian* getPrimary() { return primaryH; }
67 
68  /** return the pointer to a QMCHamiltonian with the name
69  * @param pname name of the QMCHamiltonian
70  */
71  inline QMCHamiltonian* getHamiltonian(const std::string& pname)
72  {
73  PoolType::iterator hit(myPool.find(pname));
74  if (hit == myPool.end())
75  {
76  if (myPool.empty())
77  return nullptr;
78  else
79  return (*(myPool.begin())).second->getH();
80  }
81  else
82  return (*hit).second->getH();
83  }
84 
86 
87 private:
88  /** pointer to the primary QMCHamiltonian
89  */
91 
92  /** pointer to a current QMCHamiltonian to be built.
93  */
95 
96  /** pointer to ParticleSetPool
97  *
98  * QMCHamiltonian needs to know which ParticleSet object
99  * is used as an input object for the evaluations.
100  * Any number of ParticleSet can be used to describe
101  * a QMCHamiltonian.
102  */
104 
105  /** pointer to WaveFunctionPool
106  *
107  * For those OperatorBase that depends on TrialWaveFunction,
108  * e.g., NonLocalPPotential.
109  */
111 
112 
113  /** point to the working document */
115 
116  /** storage for HamiltonianFactory */
118 };
119 } // namespace qmcplusplus
120 #endif
QMCHamiltonian * primaryH
pointer to the primary QMCHamiltonian
class that handles xmlDoc
Definition: Libxml2Doc.h:76
Base class for any object which needs to know about a MPI communicator.
Definition: MPIObjectBase.h:26
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Libxml2Document * curDoc
point to the working document
HamiltonianPool(ParticleSetPool &pset_pool, WaveFunctionPool &psi_pool, Communicate *c, const char *aname="hamiltonian")
Collection of Local Energy Operators.
declaration of MPIObjectBase
Declaration of OhmmsElementBase and define xml-related macros.
Wrapping information on parallelism.
Definition: Communicate.h:68
WaveFunctionPool & psi_pool_
pointer to WaveFunctionPool
std::map< std::string, HamiltonianFactory * > PoolType
Manage a collection of ParticleSet objects.
ParticleSetPool & ptcl_pool_
pointer to ParticleSetPool
void setDocument(Libxml2Document *doc)
Declaration of a HamiltonianFactory.
QMCHamiltonian * curH
pointer to a current QMCHamiltonian to be built.
QMCHamiltonian * getHamiltonian(const std::string &pname)
return the pointer to a QMCHamiltonian with the name
QMCHamiltonian * getPrimary()
return the pointer to the primary QMCHamiltonian
PoolType myPool
storage for HamiltonianFactory
Manage a collection of TrialWaveFunction objects.
Manage a collection of QMCHamiltonian objects.
HamiltonianPool & operator=(const HamiltonianPool &)=delete