QMCPACK
HamiltonianPool.cpp
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: Jordan E. Vincent, University of Illinois at Urbana-Champaign
8 // Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
9 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
10 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
11 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
12 //
13 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 /**@file HamiltonianPool.cpp
18  * @brief Implements HamiltonianPool operators.
19  */
20 #include "HamiltonianPool.h"
23 #include "OhmmsData/AttributeSet.h"
24 #include "Concurrency/OpenMP.h"
26 
27 namespace qmcplusplus
28 {
30  WaveFunctionPool& psi_pool,
31  Communicate* c,
32  const char* aname)
33  : MPIObjectBase(c), curH(0), ptcl_pool_(pset_pool), psi_pool_(psi_pool), curDoc(0)
34 {
35  ClassName = "HamiltonianPool";
36  myName = aname;
37 }
38 
40 {
41  PoolType::iterator it(myPool.begin());
42  while (it != myPool.end())
43  {
44  delete (*it).second;
45  ++it;
46  }
47 }
48 
49 bool HamiltonianPool::put(xmlNodePtr cur)
50 {
51  ReportEngine PRE("HamiltonianPool", "put");
52  std::string id("h0"), target("e"), role("extra");
53  OhmmsAttributeSet hAttrib;
54  hAttrib.add(id, "id");
55  hAttrib.add(id, "name");
56  hAttrib.add(role, "role");
57  hAttrib.add(target, "target");
58  hAttrib.put(cur);
60  if (qp == 0)
61  {
62  //never a good thing
63  PRE.error("No target particle " + target + " exists.");
64  return false;
65  }
66  bool set2Primary = false;
67  //first Hamiltonian is set to the primary Hamiltonian
68  if (myPool.empty() || role == "primary")
69  set2Primary = true;
71  PoolType::iterator hit(myPool.find(id));
72  if (hit == myPool.end())
73  {
75  curH->setName(id);
76  myPool[id] = curH;
77  }
78  else
79  curH = (*hit).second;
80  bool success = curH->put(cur);
81  if (set2Primary)
82  primaryH = curH->getH();
83  return success;
84 }
85 
86 bool HamiltonianPool::get(std::ostream& os) const
87 {
88  for(auto& [name, factory] : myPool)
89  {
90  os << " Hamiltonian " << name << std::endl;
91  factory->getH()->get(os);
92  }
93  os << std::endl;
94  return true;
95 }
96 
98 } // namespace qmcplusplus
QMCHamiltonian * primaryH
pointer to the primary QMCHamiltonian
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
HamiltonianPool(ParticleSetPool &pset_pool, WaveFunctionPool &psi_pool, Communicate *c, const char *aname="hamiltonian")
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::string myName
name of the object
Definition: MPIObjectBase.h:67
Wrapping information on parallelism.
Definition: Communicate.h:68
bool get(std::ostream &os) const
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
WaveFunctionPool & psi_pool_
pointer to WaveFunctionPool
ParticleSet * getParticleSet(const std::string &pname)
get a named ParticleSet
Final class and should not be derived.
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
Declaration of WaveFunctionPool.
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
declaration of ProgressReportEngine
Factory class to build a many-body wavefunction.
Manage a collection of ParticleSet objects.
ParticleSetPool & ptcl_pool_
pointer to ParticleSetPool
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
QMCHamiltonian * curH
pointer to a current QMCHamiltonian to be built.
Declaration of HamiltonianPool.
void error(const std::string &msg, bool fatal=false)
const PoolType & getPool() const
get the Pool object
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42
PoolType myPool
storage for HamiltonianFactory
Manage a collection of TrialWaveFunction objects.
Declaration of ParticleSetPool.