QMCPACK
WaveFunctionPool.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 WaveFunctionPool.h
15  * @brief Declaration of WaveFunctionPool
16  */
17 #ifndef QMCPLUSPLUS_WAVEFUNCTIONPOOL_H
18 #define QMCPLUSPLUS_WAVEFUNCTIONPOOL_H
19 
21 #include "Message/MPIObjectBase.h"
24 #include <map>
25 #include <string>
26 
27 namespace qmcplusplus
28 {
29 class ParticleSetPool;
30 class ParticleSet;
31 
32 /** @ingroup qmcapp
33  * @brief Manage a collection of TrialWaveFunction objects
34  *
35  * This object handles <wavefunction> elements and
36  * functions as a builder class for TrialWaveFunction objects.
37  */
39 {
40 public:
41  using PoolType = std::map<std::string, const std::unique_ptr<TrialWaveFunction>>;
42 
43  WaveFunctionPool(const RuntimeOptions& runtime_options,
44  ParticleSetPool& pset_pool,
45  Communicate* c,
46  const char* aname = "wavefunction");
47  WaveFunctionPool(const WaveFunctionPool&) = delete;
51 
53 
54  bool put(xmlNodePtr cur);
55 
56  inline bool empty() const { return myPool.empty(); }
57 
59 
60  TrialWaveFunction* getWaveFunction(const std::string& pname)
61  {
62  if (auto pit(myPool.find(pname)); pit == myPool.end())
63  {
64  if (myPool.empty())
65  return nullptr;
66  else
67  return myPool.begin()->second.get();
68  }
69  else
70  return pit->second.get();
71  }
72 
73  /** return a xmlNode containing Jastrow
74  * @param id name of the wave function
75  *
76  * If the wavefunction with id does not exist, return 0
77  */
78  xmlNodePtr getWaveFunctionNode(const std::string& id);
79 
80  /** get the Pool object
81  */
82  inline const PoolType& getPool() const { return myPool; }
83 
84  /** add a TrialWaveFunction* to myPool
85  */
86  void addFactory(std::unique_ptr<TrialWaveFunction> psi, bool primary);
87 
88 private:
89  /// @brief top-level runtime options from project data information
91 
92  /// pointer to the primary TrialWaveFunction
94 
95  /// storage of WaveFunctionFactory
97 
98  /** pointer to ParticleSetPool
99  *
100  * TrialWaveFunction needs to know which ParticleSet object
101  * is used as an input object for the evaluations.
102  */
104 };
105 } // namespace qmcplusplus
106 #endif
WaveFunctionPool & operator=(const WaveFunctionPool &)=delete
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
TrialWaveFunction * primary_psi_
pointer to the primary TrialWaveFunction
xmlNodePtr getWaveFunctionNode(const std::string &id)
return a xmlNode containing Jastrow
void addFactory(std::unique_ptr< TrialWaveFunction > psi, bool primary)
add a TrialWaveFunction* to myPool
declaration of MPIObjectBase
const RuntimeOptions & runtime_options_
top-level runtime options from project data information
Declaration of OhmmsElementBase and define xml-related macros.
Wrapping information on parallelism.
Definition: Communicate.h:68
Manage a collection of ParticleSet objects.
ParticleSetPool & ptcl_pool_
pointer to ParticleSetPool
WaveFunctionPool(const RuntimeOptions &runtime_options, ParticleSetPool &pset_pool, Communicate *c, const char *aname="wavefunction")
Class to represent a many-body trial wave function.
Declaration of a WaveFunctionFactory.
const PoolType & getPool() const
get the Pool object
std::map< std::string, const std::unique_ptr< TrialWaveFunction > > PoolType
TrialWaveFunction * getWaveFunction(const std::string &pname)
PoolType myPool
storage of WaveFunctionFactory
Manage a collection of TrialWaveFunction objects.
TrialWaveFunction * getPrimary()