QMCPACK
WaveFunctionPool.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: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
8 // Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
9 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
10 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 /**@file WaveFunctionPool.cpp
17  * @brief Implements WaveFunctionPool operators.
18  */
19 #include "WaveFunctionPool.h"
21 #include "OhmmsData/AttributeSet.h"
22 
23 namespace qmcplusplus
24 {
26  ParticleSetPool& pset_pool,
27  Communicate* c,
28  const char* aname)
29  : MPIObjectBase(c), runtime_options_(runtime_options), primary_psi_(nullptr), ptcl_pool_(pset_pool)
30 {
31  ClassName = "WaveFunctionPool";
32  myName = aname;
33 }
34 
36 
37 bool WaveFunctionPool::put(xmlNodePtr cur)
38 {
39  std::string target("e"), role("extra");
40  OhmmsAttributeSet pAttrib;
41  pAttrib.add(target, "target");
42  pAttrib.add(target, "ref");
43  pAttrib.add(role, "role");
44  pAttrib.put(cur);
45 
47 
48  if (qp == nullptr)
49  myComm->barrier_and_abort("target particle set named '" + target + "' not found");
50 
51  WaveFunctionFactory psiFactory(*qp, ptcl_pool_.getPool(), myComm);
52  auto psi = psiFactory.buildTWF(cur, runtime_options_);
53  addFactory(std::move(psi), myPool.empty() || role == "primary");
54  return true;
55 }
56 
57 void WaveFunctionPool::addFactory(std::unique_ptr<TrialWaveFunction> psi, bool primary)
58 {
59  if (myPool.find(psi->getName()) != myPool.end())
60  throw std::runtime_error(" " + psi->getName() + " exists. Cannot be added.");
61 
62  app_log() << " Adding " << psi->getName() << " TrialWaveFunction to the pool" << std::endl;
63 
64  if (primary)
65  primary_psi_ = psi.get();
66  myPool.emplace(psi->getName(), std::move(psi));
67 }
68 
69 xmlNodePtr WaveFunctionPool::getWaveFunctionNode(const std::string& id)
70 {
71  if (myPool.empty())
72  return NULL;
73  if (auto it(myPool.find(id)); it == myPool.end())
74  return (*myPool.begin()).second->getNode();
75  else
76  return (*it).second->getNode();
77 }
78 } // namespace qmcplusplus
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
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
xmlNodePtr getWaveFunctionNode(const std::string &id)
return a xmlNode containing Jastrow
std::string myName
name of the object
Definition: MPIObjectBase.h:67
void addFactory(std::unique_ptr< TrialWaveFunction > psi, bool primary)
add a TrialWaveFunction* to myPool
const RuntimeOptions & runtime_options_
top-level runtime options from project data information
Wrapping information on parallelism.
Definition: Communicate.h:68
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
std::unique_ptr< TrialWaveFunction > buildTWF(xmlNodePtr cur, const RuntimeOptions &runtime_options)
read from xmlNode
ParticleSet * getParticleSet(const std::string &pname)
get a named ParticleSet
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
Manage a collection of ParticleSet objects.
Factory class to build a many-body wavefunction.
ParticleSetPool & ptcl_pool_
pointer to ParticleSetPool
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
WaveFunctionPool(const RuntimeOptions &runtime_options, ParticleSetPool &pset_pool, Communicate *c, const char *aname="wavefunction")
const PoolType & getPool() const
get the Pool object
void barrier_and_abort(const std::string &msg) const
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 of WaveFunctionFactory
Declaration of ParticleSetPool.