QMCPACK
QMC Application Group

Application-level classes to manage QMC simulations. More...

Files

file  qmcapp.cpp
 a main function for QMC simulation.
 

Classes

class  ParticleSetPool
 Manage a collection of ParticleSet objects. More...
 
class  WaveFunctionPool
 Manage a collection of TrialWaveFunction objects. More...
 
class  HamiltonianPool
 Manage a collection of QMCHamiltonian objects. More...
 
class  QMCAppBase
 Base class for QMC applications and utilities. More...
 
class  QMCMain
 Main application to perform QMC simulations. More...
 

Detailed Description

Application-level classes to manage QMC simulations.

The classes in this group are responsble for handling of major xml elements under <simulation>.


Class Documentation

◆ qmcplusplus::ParticleSetPool

class qmcplusplus::ParticleSetPool

Manage a collection of ParticleSet objects.

This object handles <particleset> elements and functions as a builder class for ParticleSet objects.

Definition at line 34 of file ParticleSetPool.h.

+ Inheritance diagram for ParticleSetPool:
+ Collaboration diagram for ParticleSetPool:

Public Types

using PoolType = std::map< std::string, const std::unique_ptr< ParticleSet > >
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 

Public Member Functions

 ParticleSetPool (Communicate *c, const char *aname="particleset")
 constructor More...
 
 ~ParticleSetPool ()
 
 ParticleSetPool (const ParticleSetPool &)=delete
 
ParticleSetPooloperator= (const ParticleSetPool &)=delete
 
 ParticleSetPool (ParticleSetPool &&pset) noexcept
 
ParticleSetPooloperator= (ParticleSetPool &&)=default
 
bool put (xmlNodePtr cur)
 process an xml element More...
 
bool get (std::ostream &os) const
 
void reset ()
 reset is used to initialize and evaluate the distance tables More...
 
void output_particleset_info (Libxml2Document &doc, xmlNodePtr root)
 
bool readSimulationCellXML (xmlNodePtr cur)
 initialize the supercell shared by all the particle sets More...
 
bool empty () const
 return true, if the pool is empty More...
 
void addParticleSet (std::unique_ptr< ParticleSet > &&p)
 add a ParticleSet* to the pool with its ownership transferred ParticleSet built outside the ParticleSetPool must be constructed with the simulation cell from this->simulation_cell_. More...
 
ParticleSetgetParticleSet (const std::string &pname)
 get a named ParticleSet More...
 
MCWalkerConfigurationgetWalkerSet (const std::string &pname)
 get a named MCWalkerConfiguration More...
 
const PoolTypegetPool () const
 get the Pool object More...
 
const auto & getSimulationCell () const
 get simulation cell More...
 
void setSimulationCell (const SimulationCell &simulation_cell)
 set simulation cell More...
 
void randomize ()
 randomize a particleset particleset/='yes' && particleset exists More...
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 

Private Attributes

std::unique_ptr< SimulationCellsimulation_cell_
 global simulation cell More...
 
PoolType myPool
 List of ParticleSet owned. More...
 
std::vector< xmlNodePtr > randomize_nodes
 xml node for random initialization. More...
 

Additional Inherited Members

- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 

Member Typedef Documentation

◆ PoolType

using PoolType = std::map<std::string, const std::unique_ptr<ParticleSet> >

Definition at line 37 of file ParticleSetPool.h.

Constructor & Destructor Documentation

◆ ParticleSetPool() [1/3]

ParticleSetPool ( Communicate c,
const char *  aname = "particleset" 
)

constructor

Parameters
anamexml tag

Definition at line 33 of file ParticleSetPool.cpp.

References MPIObjectBase::ClassName, and MPIObjectBase::myName.

34  : MPIObjectBase(c), simulation_cell_(std::make_unique<SimulationCell>())
35 {
36  ClassName = "ParticleSetPool";
37  myName = aname;
38 }
std::string myName
name of the object
Definition: MPIObjectBase.h:67
std::unique_ptr< SimulationCell > simulation_cell_
global simulation cell
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
MPIObjectBase(Communicate *c)
constructor with communicator

◆ ~ParticleSetPool()

~ParticleSetPool ( )
default

◆ ParticleSetPool() [2/3]

ParticleSetPool ( const ParticleSetPool )
delete

◆ ParticleSetPool() [3/3]

ParticleSetPool ( ParticleSetPool &&  pset)
noexcept

Definition at line 40 of file ParticleSetPool.cpp.

References MPIObjectBase::ClassName.

41  : MPIObjectBase(other.myComm), simulation_cell_(std::move(other.simulation_cell_)), myPool(std::move(other.myPool))
42 {
43  ClassName = other.ClassName;
44  myName = other.myName;
45 }
std::string myName
name of the object
Definition: MPIObjectBase.h:67
std::unique_ptr< SimulationCell > simulation_cell_
global simulation cell
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
MPIObjectBase(Communicate *c)
constructor with communicator
PoolType myPool
List of ParticleSet owned.

Member Function Documentation

◆ addParticleSet()

void addParticleSet ( std::unique_ptr< ParticleSet > &&  p)

add a ParticleSet* to the pool with its ownership transferred ParticleSet built outside the ParticleSetPool must be constructed with the simulation cell from this->simulation_cell_.

Definition at line 67 of file ParticleSetPool.cpp.

References LOGMSG, ParticleSetPool::myPool, and ParticleSetPool::simulation_cell_.

Referenced by qmcplusplus::TEST_CASE(), qmcplusplus::test_diamond_2x1x1_xml_input(), qmcplusplus::test_hcpBe_rotation(), qmcplusplus::test_He_sto3g_xml_input(), qmcplusplus::test_lcao_spinor(), qmcplusplus::test_lcao_spinor_excited(), qmcplusplus::test_lcao_spinor_ion_derivs(), qmcplusplus::test_LiH_msd(), qmcplusplus::test_LiH_msd_xml_input(), qmcplusplus::test_LiH_msd_xml_input_with_positron(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

68 {
69  const auto pit(myPool.find(p->getName()));
70  if (pit == myPool.end())
71  {
72  auto& pname = p->getName();
73  LOGMSG(" Adding " << pname << " ParticleSet to the pool")
75  throw std::runtime_error("Bug detected! ParticleSetPool::addParticleSet requires p created with the simulation "
76  "cell from ParticleSetPool.");
77  myPool.emplace(pname, std::move(p));
78  }
79  else
80  throw std::runtime_error(p->getName() + " exists. Cannot be added again.");
81 }
ParticleSetPool(Communicate *c, const char *aname="particleset")
constructor
if(c->rank()==0)
void addParticleSet(std::unique_ptr< ParticleSet > &&p)
add a ParticleSet* to the pool with its ownership transferred ParticleSet built outside the ParticleS...
std::unique_ptr< SimulationCell > simulation_cell_
global simulation cell
bool get(std::ostream &os) const
const std::string & getName() const
return the name
Definition: MPIObjectBase.h:54
const auto & getSimulationCell() const
get simulation cell
PoolType myPool
List of ParticleSet owned.
#define LOGMSG(msg)
Definition: OutputManager.h:82

◆ empty()

bool empty ( ) const
inline

return true, if the pool is empty

Definition at line 66 of file ParticleSetPool.h.

References ParticleSetPool::myPool.

66 { return myPool.empty(); }
PoolType myPool
List of ParticleSet owned.

◆ get()

bool get ( std::ostream &  os) const

Definition at line 205 of file ParticleSetPool.cpp.

References OutputManagerClass::isDebugActive(), ParticleSetPool::myPool, outputManager, and qmcplusplus::pset.

Referenced by qmcplusplus::TEST_CASE(), and QMCFiniteSize::validateXML().

206 {
207  os << "ParticleSetPool has: " << std::endl << std::endl;
208  os.setf(std::ios::scientific, std::ios::floatfield);
209  os.precision(14);
210  for (const auto& [name, pset] : myPool)
212  pset->print(os, 0);
213  else
214  pset->print(os, 10 /* maxParticlesToPrint */);
215  return true;
216 }
OutputManagerClass outputManager(Verbosity::HIGH)
bool isDebugActive() const
Definition: OutputManager.h:45
PoolType myPool
List of ParticleSet owned.

◆ getParticleSet()

ParticleSet * getParticleSet ( const std::string &  pname)

get a named ParticleSet

Parameters
pnamename of the ParticleSet
Returns
a MCWalkerConfiguration object with pname

When the named ParticleSet is not in this object, return 0.

Definition at line 49 of file ParticleSetPool.cpp.

References ParticleSet::get(), and ParticleSetPool::myPool.

Referenced by ParticleSetPool::getWalkerSet(), QMCFiniteSize::initBreakup(), InitMolecularSystem::put(), ParticleSetPool::put(), WaveFunctionPool::put(), HamiltonianPool::put(), qmcplusplus::TEST_CASE(), and QMCFiniteSize::wfnPut().

50 {
51  if (auto pit = myPool.find(pname); pit == myPool.end())
52  return nullptr;
53  else
54  return pit->second.get();
55 }
PoolType myPool
List of ParticleSet owned.

◆ getPool()

◆ getSimulationCell()

◆ getWalkerSet()

MCWalkerConfiguration * getWalkerSet ( const std::string &  pname)

get a named MCWalkerConfiguration

Parameters
pnamename of the MCWalkerConfiguration
Returns
a MCWalkerConfiguration object with pname

When the named MCWalkerConfiguration is not in this object, return 0.

Definition at line 57 of file ParticleSetPool.cpp.

References ParticleSetPool::getParticleSet().

Referenced by qmcplusplus::testing::createDriver(), and qmcplusplus::TEST_CASE().

58 {
59  auto mc = dynamic_cast<MCWalkerConfiguration*>(getParticleSet(pname));
60  if (mc == nullptr)
61  {
62  throw std::runtime_error("ParticleSePool::getWalkerSet missing " + pname);
63  }
64  return mc;
65 }
ParticleSet * getParticleSet(const std::string &pname)
get a named ParticleSet

◆ operator=() [1/2]

ParticleSetPool& operator= ( const ParticleSetPool )
delete

◆ operator=() [2/2]

ParticleSetPool& operator= ( ParticleSetPool &&  )
default

◆ output_particleset_info()

void output_particleset_info ( Libxml2Document doc,
xmlNodePtr  root 
)

Definition at line 218 of file ParticleSetPool.cpp.

References Libxml2Document::addChild(), qmcplusplus::doc, and ParticleSetPool::myPool.

219 {
220  xmlNodePtr particles_info = doc.addChild(root, "particles");
221  PoolType::const_iterator it(myPool.begin()), it_end(myPool.end());
222  while (it != it_end)
223  {
224  xmlNodePtr particle = doc.addChild(particles_info, "particle");
225  doc.addChild(particle, "name", (*it).second->getName());
226  doc.addChild(particle, "size", (*it).second->getTotalNum());
227  ++it;
228  }
229 }
void addChild(xmlNodePtr newnode)
Definition: Libxml2Doc.cpp:111
PoolType myPool
List of ParticleSet owned.

◆ put()

bool put ( xmlNodePtr  cur)

process an xml element

Parameters
curcurrent xmlNodePtr
Returns
true, if successful.

Creating MCWalkerConfiguration for all the ParticleSet objects.

Definition at line 117 of file ParticleSetPool.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_summary(), qmcplusplus::app_warning(), Communicate::barrier_and_abort(), PlatformSelector< KIND >::candidate_values(), qmcplusplus::DC_POS, qmcplusplus::DC_POS_OFFLOAD, ParticleSetPool::getParticleSet(), ParticleSet::getTotalNum(), ParticleSet::groups(), MPIObjectBase::myComm, ParticleSetPool::myPool, qmcplusplus::OMPTARGET, OhmmsAttributeSet::put(), ParticleSetPool::randomize_nodes, XMLParticleParser::readXML(), PlatformSelector< KIND >::selectPlatform(), ParticleSet::setName(), ParticleSet::setSpinor(), and ParticleSetPool::simulation_cell_.

Referenced by MinimalParticlePool::make_H2(), MinimalParticlePool::parseParticleSetXML(), QMCFiniteSize::processPWH(), qmcplusplus::setupParticleSetPool(), qmcplusplus::setupParticleSetPoolBe(), qmcplusplus::TEST_CASE(), and QMCFiniteSize::validateXML().

118 {
119  ReportEngine PRE("ParticleSetPool", "put");
120  std::string id("e");
121  std::string role("none");
122  std::string randomR("no");
123  std::string randomsrc;
124  std::string useGPU;
125  std::string spinor;
126  OhmmsAttributeSet pAttrib;
127  pAttrib.add(id, "id");
128  pAttrib.add(id, "name");
129  pAttrib.add(role, "role");
130  pAttrib.add(randomR, "random");
131  pAttrib.add(randomsrc, "randomsrc");
132  pAttrib.add(randomsrc, "random_source");
133  pAttrib.add(spinor, "spinor", {"no", "yes"});
134  pAttrib.add(useGPU, "gpu", CPUOMPTargetSelector::candidate_values);
135  pAttrib.put(cur);
136  //backward compatibility
137  if (id == "e" && role == "none")
138  role = "MC";
139  ParticleSet* pTemp = getParticleSet(id);
140  if (pTemp == 0)
141  {
142  const bool use_offload = CPUOMPTargetSelector::selectPlatform(useGPU) == PlatformKind::OMPTARGET;
143  app_summary() << std::endl;
144  app_summary() << " Particle Set" << std::endl;
145  app_summary() << " ------------" << std::endl;
146  app_summary() << " Name: " << id << " Offload : " << (use_offload ? "yes" : "no") << std::endl;
147  app_summary() << std::endl;
148 
149  // select OpenMP offload implementation in ParticleSet.
150  if (use_offload)
151  pTemp = new MCWalkerConfiguration(*simulation_cell_, DynamicCoordinateKind::DC_POS_OFFLOAD);
152  else
153  pTemp = new MCWalkerConfiguration(*simulation_cell_, DynamicCoordinateKind::DC_POS);
154 
155  myPool.emplace(id, pTemp);
156 
157  try
158  {
159  XMLParticleParser pread(*pTemp);
160  pread.readXML(cur);
161  }
162  catch (const UniformCommunicateError& ue)
163  {
164  myComm->barrier_and_abort(ue.what());
165  }
166 
167  //if random_source is given, create a node <init target="" soruce=""/>
168  if (randomR == "yes" && !randomsrc.empty())
169  {
170  xmlNodePtr anode = xmlNewNode(NULL, (const xmlChar*)"init");
171  xmlNewProp(anode, (const xmlChar*)"source", (const xmlChar*)randomsrc.c_str());
172  xmlNewProp(anode, (const xmlChar*)"target", (const xmlChar*)id.c_str());
173  randomize_nodes.push_back(anode);
174  }
175  pTemp->setName(id);
176  pTemp->setSpinor(spinor == "yes");
177  app_summary() << " Particle set size: " << pTemp->getTotalNum() << " Groups : " << pTemp->groups() << std::endl;
178  app_summary() << std::endl;
179  return true;
180  }
181  else
182  {
183  app_warning() << "Particle set " << id << " is already created. Ignoring this section." << std::endl;
184  }
185  app_summary() << std::endl;
186  return true;
187 }
std::ostream & app_warning()
Definition: OutputManager.h:69
std::ostream & app_summary()
Definition: OutputManager.h:63
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::unique_ptr< SimulationCell > simulation_cell_
global simulation cell
ParticleSet * getParticleSet(const std::string &pname)
get a named ParticleSet
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::vector< xmlNodePtr > randomize_nodes
xml node for random initialization.
static PlatformKind selectPlatform(std::string_view value)
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
List of ParticleSet owned.
const std::vector< std::string > candidate_values

◆ randomize()

void randomize ( )

randomize a particleset particleset/='yes' && particleset exists

Definition at line 189 of file ParticleSetPool.cpp.

References qmcplusplus::app_log(), InitMolecularSystem::put(), and ParticleSetPool::randomize_nodes.

Referenced by MinimalParticlePool::make_H2(), MinimalParticlePool::parseParticleSetXML(), and qmcplusplus::TEST_CASE().

190 {
191  app_log() << "ParticleSetPool::randomize " << randomize_nodes.size() << " ParticleSet"
192  << (randomize_nodes.size() == 1 ? "" : "s") << "." << std::endl;
193  bool success = true;
194  for (int i = 0; i < randomize_nodes.size(); ++i)
195  {
196  InitMolecularSystem moinit(*this);
197  success &= moinit.put(randomize_nodes[i]);
198  xmlFreeNode(randomize_nodes[i]);
199  }
200  randomize_nodes.clear();
201  if (!success)
202  throw std::runtime_error("ParticleSePool::randomize failed to randomize some Particlesets!");
203 }
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< xmlNodePtr > randomize_nodes
xml node for random initialization.

◆ readSimulationCellXML()

bool readSimulationCellXML ( xmlNodePtr  cur)

initialize the supercell shared by all the particle sets

return value is never checked anywhere side effect simulation_cell_ UPtr<ParticleLayout> is set to particle layout created on heap. This is later directly assigned to pset member variable Lattice.

Definition at line 83 of file ParticleSetPool.cpp.

References qmcplusplus::app_log(), qmcplusplus::app_summary(), Communicate::barrier_and_abort(), OutputManagerClass::isHighActive(), MPIObjectBase::myComm, outputManager, LatticeParser::put(), and ParticleSetPool::simulation_cell_.

Referenced by MinimalParticlePool::parseParticleSetXML(), QMCFiniteSize::processPWH(), and qmcplusplus::TEST_CASE().

84 {
85  ReportEngine PRE("ParticleSetPool", "putLattice");
86 
87  bool lattice_defined = false;
88  try
89  {
90  LatticeParser a(simulation_cell_->lattice_);
91  lattice_defined = a.put(cur);
92  }
93  catch (const UniformCommunicateError& ue)
94  {
95  myComm->barrier_and_abort(ue.what());
96  }
97 
98  if (lattice_defined)
99  {
100  app_log() << " Overwriting global supercell " << std::endl;
101  simulation_cell_->resetLRBox();
103  simulation_cell_->lattice_.print(app_log(), 2);
104  else
105  simulation_cell_->lattice_.print(app_summary(), 1);
106  }
107  return lattice_defined;
108 }
bool isHighActive() const
Definition: OutputManager.h:47
std::ostream & app_log()
Definition: OutputManager.h:65
std::ostream & app_summary()
Definition: OutputManager.h:63
OutputManagerClass outputManager(Verbosity::HIGH)
std::unique_ptr< SimulationCell > simulation_cell_
global simulation cell
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
void barrier_and_abort(const std::string &msg) const

◆ reset()

void reset ( )

reset is used to initialize and evaluate the distance tables

Definition at line 233 of file ParticleSetPool.cpp.

References ParticleSetPool::myPool, and qmcplusplus::pset.

234 {
235  for (const auto& [key, pset] : myPool)
236  pset->update();
237 }
PoolType myPool
List of ParticleSet owned.

◆ setSimulationCell()

void setSimulationCell ( const SimulationCell simulation_cell)
inline

set simulation cell

Definition at line 98 of file ParticleSetPool.h.

References ParticleSetPool::simulation_cell_.

Referenced by qmcplusplus::TEST_CASE(), qmcplusplus::test_diamond_2x1x1_xml_input(), qmcplusplus::test_hcpBe_rotation(), and qmcplusplus::testTrialWaveFunction_diamondC_2x1x1().

98 { *simulation_cell_ = simulation_cell; }
std::unique_ptr< SimulationCell > simulation_cell_
global simulation cell

Member Data Documentation

◆ myPool

◆ randomize_nodes

std::vector<xmlNodePtr> randomize_nodes
private

xml node for random initialization.

randomize() process initializations just before starting qmc sections

Definition at line 121 of file ParticleSetPool.h.

Referenced by ParticleSetPool::put(), and ParticleSetPool::randomize().

◆ simulation_cell_

std::unique_ptr<SimulationCell> simulation_cell_
private

◆ qmcplusplus::WaveFunctionPool

class qmcplusplus::WaveFunctionPool

Manage a collection of TrialWaveFunction objects.

This object handles <wavefunction> elements and functions as a builder class for TrialWaveFunction objects.

Definition at line 38 of file WaveFunctionPool.h.

+ Inheritance diagram for WaveFunctionPool:
+ Collaboration diagram for WaveFunctionPool:

Public Types

using PoolType = std::map< std::string, const std::unique_ptr< TrialWaveFunction > >
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 

Public Member Functions

 WaveFunctionPool (const RuntimeOptions &runtime_options, ParticleSetPool &pset_pool, Communicate *c, const char *aname="wavefunction")
 
 WaveFunctionPool (const WaveFunctionPool &)=delete
 
WaveFunctionPooloperator= (const WaveFunctionPool &)=delete
 
 WaveFunctionPool (WaveFunctionPool &&)=default
 
WaveFunctionPooloperator= (WaveFunctionPool &&)=delete
 
 ~WaveFunctionPool ()
 
bool put (xmlNodePtr cur)
 
bool empty () const
 
TrialWaveFunctiongetPrimary ()
 
TrialWaveFunctiongetWaveFunction (const std::string &pname)
 
xmlNodePtr getWaveFunctionNode (const std::string &id)
 return a xmlNode containing Jastrow More...
 
const PoolTypegetPool () const
 get the Pool object More...
 
void addFactory (std::unique_ptr< TrialWaveFunction > psi, bool primary)
 add a TrialWaveFunction* to myPool More...
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 

Private Attributes

const RuntimeOptionsruntime_options_
 top-level runtime options from project data information More...
 
TrialWaveFunctionprimary_psi_
 pointer to the primary TrialWaveFunction More...
 
PoolType myPool
 storage of WaveFunctionFactory More...
 
ParticleSetPoolptcl_pool_
 pointer to ParticleSetPool More...
 

Additional Inherited Members

- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 

Member Typedef Documentation

◆ PoolType

using PoolType = std::map<std::string, const std::unique_ptr<TrialWaveFunction> >

Definition at line 41 of file WaveFunctionPool.h.

Constructor & Destructor Documentation

◆ WaveFunctionPool() [1/3]

WaveFunctionPool ( const RuntimeOptions runtime_options,
ParticleSetPool pset_pool,
Communicate c,
const char *  aname = "wavefunction" 
)

Definition at line 25 of file WaveFunctionPool.cpp.

References MPIObjectBase::ClassName, and MPIObjectBase::myName.

29  : MPIObjectBase(c), runtime_options_(runtime_options), primary_psi_(nullptr), ptcl_pool_(pset_pool)
30 {
31  ClassName = "WaveFunctionPool";
32  myName = aname;
33 }
TrialWaveFunction * primary_psi_
pointer to the primary TrialWaveFunction
std::string myName
name of the object
Definition: MPIObjectBase.h:67
const RuntimeOptions & runtime_options_
top-level runtime options from project data information
ParticleSetPool & ptcl_pool_
pointer to ParticleSetPool
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
MPIObjectBase(Communicate *c)
constructor with communicator

◆ WaveFunctionPool() [2/3]

WaveFunctionPool ( const WaveFunctionPool )
delete

◆ WaveFunctionPool() [3/3]

◆ ~WaveFunctionPool()

~WaveFunctionPool ( )
default

Member Function Documentation

◆ addFactory()

void addFactory ( std::unique_ptr< TrialWaveFunction psi,
bool  primary 
)

add a TrialWaveFunction* to myPool

Definition at line 57 of file WaveFunctionPool.cpp.

References qmcplusplus::app_log(), WaveFunctionPool::myPool, and WaveFunctionPool::primary_psi_.

Referenced by WaveFunctionPool::put(), and qmcplusplus::TEST_CASE().

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 }
TrialWaveFunction * primary_psi_
pointer to the primary TrialWaveFunction
std::ostream & app_log()
Definition: OutputManager.h:65
PoolType myPool
storage of WaveFunctionFactory

◆ empty()

bool empty ( ) const
inline

Definition at line 56 of file WaveFunctionPool.h.

References WaveFunctionPool::myPool.

56 { return myPool.empty(); }
PoolType myPool
storage of WaveFunctionFactory

◆ getPool()

const PoolType& getPool ( ) const
inline

get the Pool object

Definition at line 82 of file WaveFunctionPool.h.

References WaveFunctionPool::myPool.

Referenced by HamiltonianPool::put().

82 { return myPool; }
PoolType myPool
storage of WaveFunctionFactory

◆ getPrimary()

TrialWaveFunction* getPrimary ( )
inline

Definition at line 58 of file WaveFunctionPool.h.

References WaveFunctionPool::primary_psi_.

58 { return primary_psi_; }
TrialWaveFunction * primary_psi_
pointer to the primary TrialWaveFunction

◆ getWaveFunction()

TrialWaveFunction* getWaveFunction ( const std::string &  pname)
inline

Definition at line 60 of file WaveFunctionPool.h.

References WaveFunctionPool::myPool.

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  }
PoolType myPool
storage of WaveFunctionFactory

◆ getWaveFunctionNode()

xmlNodePtr getWaveFunctionNode ( const std::string &  id)

return a xmlNode containing Jastrow

Parameters
idname of the wave function

If the wavefunction with id does not exist, return 0

Definition at line 69 of file WaveFunctionPool.cpp.

References WaveFunctionPool::myPool, and qmcplusplus::Units::second.

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 }
PoolType myPool
storage of WaveFunctionFactory

◆ operator=() [1/2]

WaveFunctionPool& operator= ( const WaveFunctionPool )
delete

◆ operator=() [2/2]

WaveFunctionPool& operator= ( WaveFunctionPool &&  )
delete

◆ put()

bool put ( xmlNodePtr  cur)

Definition at line 37 of file WaveFunctionPool.cpp.

References OhmmsAttributeSet::add(), WaveFunctionPool::addFactory(), Communicate::barrier_and_abort(), WaveFunctionFactory::buildTWF(), ParticleSetPool::getParticleSet(), ParticleSetPool::getPool(), MPIObjectBase::myComm, WaveFunctionPool::myPool, WaveFunctionPool::ptcl_pool_, OhmmsAttributeSet::put(), and WaveFunctionPool::runtime_options_.

Referenced by MinimalWaveFunctionPool::make_diamondC_1x1x1(), MinimalWaveFunctionPool::make_O2_spinor(), and MinimalWaveFunctionPool::make_O2_spinor_J12().

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 
46  ParticleSet* qp = ptcl_pool_.getParticleSet(target);
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 }
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
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
ParticleSet * getParticleSet(const std::string &pname)
get a named ParticleSet
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
ParticleSetPool & ptcl_pool_
pointer to ParticleSetPool
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

Member Data Documentation

◆ myPool

◆ primary_psi_

TrialWaveFunction* primary_psi_
private

pointer to the primary TrialWaveFunction

Definition at line 93 of file WaveFunctionPool.h.

Referenced by WaveFunctionPool::addFactory(), and WaveFunctionPool::getPrimary().

◆ ptcl_pool_

ParticleSetPool& ptcl_pool_
private

pointer to ParticleSetPool

TrialWaveFunction needs to know which ParticleSet object is used as an input object for the evaluations.

Definition at line 103 of file WaveFunctionPool.h.

Referenced by WaveFunctionPool::put().

◆ runtime_options_

const RuntimeOptions& runtime_options_
private

top-level runtime options from project data information

Definition at line 90 of file WaveFunctionPool.h.

Referenced by WaveFunctionPool::put().

◆ qmcplusplus::HamiltonianPool

class qmcplusplus::HamiltonianPool

Manage a collection of QMCHamiltonian objects.

This object handles <hamiltonian> elements and functions as a builder class for QMCHamiltonian objects.

Definition at line 40 of file HamiltonianPool.h.

+ Inheritance diagram for HamiltonianPool:
+ Collaboration diagram for HamiltonianPool:

Public Types

using PoolType = std::map< std::string, HamiltonianFactory * >
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 

Public Member Functions

 HamiltonianPool (ParticleSetPool &pset_pool, WaveFunctionPool &psi_pool, Communicate *c, const char *aname="hamiltonian")
 
 HamiltonianPool (const HamiltonianPool &)=delete
 
HamiltonianPooloperator= (const HamiltonianPool &)=delete
 
 HamiltonianPool (HamiltonianPool &&)=default
 
HamiltonianPooloperator= (HamiltonianPool &&)=delete
 
 ~HamiltonianPool ()
 
bool put (xmlNodePtr cur)
 
bool get (std::ostream &os) const
 
void reset ()
 
bool empty () const
 
QMCHamiltoniangetPrimary ()
 return the pointer to the primary QMCHamiltonian More...
 
QMCHamiltoniangetHamiltonian (const std::string &pname)
 return the pointer to a QMCHamiltonian with the name More...
 
void setDocument (Libxml2Document *doc)
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 

Private Attributes

QMCHamiltonianprimaryH
 pointer to the primary QMCHamiltonian More...
 
QMCHamiltoniancurH
 pointer to a current QMCHamiltonian to be built. More...
 
ParticleSetPoolptcl_pool_
 pointer to ParticleSetPool More...
 
WaveFunctionPoolpsi_pool_
 pointer to WaveFunctionPool More...
 
Libxml2DocumentcurDoc
 point to the working document More...
 
PoolType myPool
 storage for HamiltonianFactory More...
 

Additional Inherited Members

- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 

Member Typedef Documentation

◆ PoolType

using PoolType = std::map<std::string, HamiltonianFactory*>

Definition at line 43 of file HamiltonianPool.h.

Constructor & Destructor Documentation

◆ HamiltonianPool() [1/3]

HamiltonianPool ( ParticleSetPool pset_pool,
WaveFunctionPool psi_pool,
Communicate c,
const char *  aname = "hamiltonian" 
)

Definition at line 29 of file HamiltonianPool.cpp.

References MPIObjectBase::ClassName, and MPIObjectBase::myName.

33  : MPIObjectBase(c), curH(0), ptcl_pool_(pset_pool), psi_pool_(psi_pool), curDoc(0)
34 {
35  ClassName = "HamiltonianPool";
36  myName = aname;
37 }
Libxml2Document * curDoc
point to the working document
std::string myName
name of the object
Definition: MPIObjectBase.h:67
WaveFunctionPool & psi_pool_
pointer to WaveFunctionPool
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.
MPIObjectBase(Communicate *c)
constructor with communicator

◆ HamiltonianPool() [2/3]

HamiltonianPool ( const HamiltonianPool )
delete

◆ HamiltonianPool() [3/3]

HamiltonianPool ( HamiltonianPool &&  )
default

◆ ~HamiltonianPool()

Definition at line 39 of file HamiltonianPool.cpp.

References HamiltonianPool::myPool.

40 {
41  PoolType::iterator it(myPool.begin());
42  while (it != myPool.end())
43  {
44  delete (*it).second;
45  ++it;
46  }
47 }
PoolType myPool
storage for HamiltonianFactory

Member Function Documentation

◆ empty()

bool empty ( ) const
inline

Definition at line 59 of file HamiltonianPool.h.

References HamiltonianPool::myPool.

Referenced by qmcplusplus::TEST_CASE().

59 { return myPool.empty(); }
PoolType myPool
storage for HamiltonianFactory

◆ get()

bool get ( std::ostream &  os) const

Definition at line 86 of file HamiltonianPool.cpp.

References HamiltonianPool::myPool.

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 }
PoolType myPool
storage for HamiltonianFactory

◆ getHamiltonian()

QMCHamiltonian* getHamiltonian ( const std::string &  pname)
inline

return the pointer to a QMCHamiltonian with the name

Parameters
pnamename of the QMCHamiltonian

Definition at line 71 of file HamiltonianPool.h.

References HamiltonianPool::myPool.

Referenced by qmcplusplus::TEST_CASE().

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  }
PoolType myPool
storage for HamiltonianFactory

◆ getPrimary()

QMCHamiltonian* getPrimary ( )
inline

return the pointer to the primary QMCHamiltonian

The first QMCHamiltonian is assigned to the primaryH. The last QMCHamiltonian with role="primary" will be the primaryH.

Definition at line 66 of file HamiltonianPool.h.

References HamiltonianPool::primaryH.

66 { return primaryH; }
QMCHamiltonian * primaryH
pointer to the primary QMCHamiltonian

◆ operator=() [1/2]

HamiltonianPool& operator= ( const HamiltonianPool )
delete

◆ operator=() [2/2]

HamiltonianPool& operator= ( HamiltonianPool &&  )
delete

◆ put()

bool put ( xmlNodePtr  cur)

Definition at line 49 of file HamiltonianPool.cpp.

References OhmmsAttributeSet::add(), HamiltonianPool::curH, ReportEngine::error(), ParticleSetPool::getParticleSet(), WaveFunctionPool::getPool(), ParticleSetPool::getPool(), MPIObjectBase::myComm, HamiltonianPool::myPool, HamiltonianPool::primaryH, HamiltonianPool::psi_pool_, HamiltonianPool::ptcl_pool_, and OhmmsAttributeSet::put().

Referenced by MinimalHamiltonianPool::make_hamWithEE(), MinimalHamiltonianPool::makeHamWithEEEI(), and qmcplusplus::TEST_CASE().

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);
59  ParticleSet* qp = ptcl_pool_.getParticleSet(target);
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;
70  HamiltonianFactory* curH = 0;
71  PoolType::iterator hit(myPool.find(id));
72  if (hit == myPool.end())
73  {
74  curH = new HamiltonianFactory(id, *qp, ptcl_pool_.getPool(), psi_pool_.getPool(), myComm);
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 }
QMCHamiltonian * primaryH
pointer to the primary QMCHamiltonian
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
WaveFunctionPool & psi_pool_
pointer to WaveFunctionPool
ParticleSet * getParticleSet(const std::string &pname)
get a named ParticleSet
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
ParticleSetPool & ptcl_pool_
pointer to ParticleSetPool
QMCHamiltonian * curH
pointer to a current QMCHamiltonian to be built.
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

◆ reset()

void reset ( )

Definition at line 97 of file HamiltonianPool.cpp.

97 {}

◆ setDocument()

void setDocument ( Libxml2Document doc)
inline

Definition at line 85 of file HamiltonianPool.h.

References HamiltonianPool::curDoc, and qmcplusplus::doc.

85 { curDoc = doc; }
Libxml2Document * curDoc
point to the working document

Member Data Documentation

◆ curDoc

Libxml2Document* curDoc
private

point to the working document

Definition at line 114 of file HamiltonianPool.h.

Referenced by HamiltonianPool::setDocument().

◆ curH

QMCHamiltonian* curH
private

pointer to a current QMCHamiltonian to be built.

Definition at line 94 of file HamiltonianPool.h.

Referenced by HamiltonianPool::put().

◆ myPool

◆ primaryH

QMCHamiltonian* primaryH
private

pointer to the primary QMCHamiltonian

Definition at line 90 of file HamiltonianPool.h.

Referenced by HamiltonianPool::getPrimary(), and HamiltonianPool::put().

◆ psi_pool_

WaveFunctionPool& psi_pool_
private

pointer to WaveFunctionPool

For those OperatorBase that depends on TrialWaveFunction, e.g., NonLocalPPotential.

Definition at line 110 of file HamiltonianPool.h.

Referenced by HamiltonianPool::put().

◆ ptcl_pool_

ParticleSetPool& ptcl_pool_
private

pointer to ParticleSetPool

QMCHamiltonian needs to know which ParticleSet object is used as an input object for the evaluations. Any number of ParticleSet can be used to describe a QMCHamiltonian.

Definition at line 103 of file HamiltonianPool.h.

Referenced by HamiltonianPool::put().

◆ qmcplusplus::QMCAppBase

class qmcplusplus::QMCAppBase

Base class for QMC applications and utilities.

Definition at line 34 of file QMCAppBase.h.

+ Inheritance diagram for QMCAppBase:
+ Collaboration diagram for QMCAppBase:

Public Member Functions

 QMCAppBase ()
 constructor More...
 
virtual ~QMCAppBase ()
 destructor More...
 
bool parse (const std::string &infile)
 parse an input file More...
 
void saveXml ()
 save the xml document More...
 
virtual bool validateXML ()=0
 validate the input file More...
 
virtual bool execute ()=0
 execute the main function More...
 
const std::string & getTitle () const
 

Protected Member Functions

bool pushDocument (const std::string &infile)
 open a new document More...
 
void popDocument ()
 close the current document More...
 

Protected Attributes

std::stack< Libxml2Document * > xml_doc_stack_
 stack of xml document More...
 
ProjectData my_project_
 project description More...
 
RandomNumberControl my_random_control_
 random number controller More...
 

Constructor & Destructor Documentation

◆ QMCAppBase()

QMCAppBase ( )
default

constructor

◆ ~QMCAppBase()

~QMCAppBase ( )
virtual

destructor

Definition at line 22 of file QMCAppBase.cpp.

References QMCAppBase::popDocument(), and QMCAppBase::xml_doc_stack_.

23 {
24  while (!xml_doc_stack_.empty())
25  {
26  popDocument();
27  }
28 }
void popDocument()
close the current document
Definition: QMCAppBase.cpp:46
std::stack< Libxml2Document * > xml_doc_stack_
stack of xml document
Definition: QMCAppBase.h:64

Member Function Documentation

◆ execute()

virtual bool execute ( )
pure virtual

execute the main function

Implemented in QMCMain, and QMCFiniteSize.

◆ getTitle()

const std::string & getTitle ( ) const

Definition at line 82 of file QMCAppBase.cpp.

References ProjectData::getTitle(), and QMCAppBase::my_project_.

82 { return my_project_.getTitle(); }
const std::string & getTitle() const noexcept
returns the title of the project <project id="det_qmc_short_sdbatch_vmcbatch_mwalkers" series="0"> tr...
ProjectData my_project_
project description
Definition: QMCAppBase.h:67

◆ parse()

bool parse ( const std::string &  infile)

parse an input file

Parameters
infilefile to be parsed.
Returns
true if the input file is a valid xml file
Parameters
infilename of an input file
Returns
true, if the document is a valid xml file.

The data members m_doc and m_root point to the "current" document and root element.

Definition at line 64 of file QMCAppBase.cpp.

References qmcplusplus::app_summary(), and QMCAppBase::pushDocument().

Referenced by main(), and qmcplusplus::TEST_CASE().

65 {
66  app_summary() << " Input XML = " << infile << std::endl;
67  return pushDocument(infile);
68 }
std::ostream & app_summary()
Definition: OutputManager.h:63
bool pushDocument(const std::string &infile)
open a new document
Definition: QMCAppBase.cpp:30

◆ popDocument()

void popDocument ( )
protected

close the current document

Definition at line 46 of file QMCAppBase.cpp.

References QMCAppBase::xml_doc_stack_.

Referenced by QMCFiniteSize::validateXML(), QMCMain::validateXML(), and QMCAppBase::~QMCAppBase().

47 {
48  if (!xml_doc_stack_.empty())
49  //Check if the stack is empty
50  {
51  Libxml2Document* adoc = xml_doc_stack_.top();
52  delete adoc;
53  xml_doc_stack_.pop();
54  }
55 }
class that handles xmlDoc
Definition: Libxml2Doc.h:76
std::stack< Libxml2Document * > xml_doc_stack_
stack of xml document
Definition: QMCAppBase.h:64

◆ pushDocument()

bool pushDocument ( const std::string &  infile)
protected

open a new document

Definition at line 30 of file QMCAppBase.cpp.

References qmcplusplus::app_error(), Libxml2Document::parse(), and QMCAppBase::xml_doc_stack_.

Referenced by QMCAppBase::parse(), QMCFiniteSize::validateXML(), and QMCMain::validateXML().

31 {
32  Libxml2Document* adoc = new Libxml2Document();
33  bool success = adoc->parse(infile);
34  if (success)
35  {
36  xml_doc_stack_.push(adoc);
37  }
38  else
39  {
40  app_error() << "File " << infile << " is invalid" << std::endl;
41  delete adoc;
42  }
43  return success;
44 }
class that handles xmlDoc
Definition: Libxml2Doc.h:76
std::ostream & app_error()
Definition: OutputManager.h:67
bool parse(const std::string &fname)
Definition: Libxml2Doc.cpp:180
std::stack< Libxml2Document * > xml_doc_stack_
stack of xml document
Definition: QMCAppBase.h:64

◆ saveXml()

void saveXml ( )

save the xml document

Definition at line 70 of file QMCAppBase.cpp.

References qmcplusplus::app_log(), ProjectData::currentMainRoot(), QMCAppBase::my_project_, and QMCAppBase::xml_doc_stack_.

Referenced by QMCMain::execute().

71 {
72  if (!xml_doc_stack_.empty())
73  {
74  std::string newxml(my_project_.currentMainRoot());
75  newxml.append(".cont.xml");
76  app_log() << "\n========================================================="
77  << "\n A new xml input file : " << newxml << std::endl;
78  xml_doc_stack_.top()->dump(newxml);
79  }
80 }
std::ostream & app_log()
Definition: OutputManager.h:65
ProjectData my_project_
project description
Definition: QMCAppBase.h:67
const std::string & currentMainRoot() const noexcept
returns the projectmain of the project, the series id is incremented at every QMC section <project id...
std::stack< Libxml2Document * > xml_doc_stack_
stack of xml document
Definition: QMCAppBase.h:64

◆ validateXML()

virtual bool validateXML ( )
pure virtual

validate the input file

Implemented in QMCMain, and QMCFiniteSize.

Member Data Documentation

◆ my_project_

ProjectData my_project_
protected

◆ my_random_control_

RandomNumberControl my_random_control_
protected

random number controller

Definition at line 70 of file QMCAppBase.h.

Referenced by QMCMain::execute(), and QMCMain::validateXML().

◆ xml_doc_stack_

◆ qmcplusplus::QMCMain

class qmcplusplus::QMCMain

Main application to perform QMC simulations.

This is a generalized QMC application which can handle multiple ParticleSet, TrialWaveFunction and QMCHamiltonian objects.

Definition at line 35 of file QMCMain.h.

+ Inheritance diagram for QMCMain:
+ Collaboration diagram for QMCMain:

Public Member Functions

 QMCMain (Communicate *c)
 
 ~QMCMain () override
 
bool validateXML () override
 validate the main document and (read the walker sets !) More...
 
bool execute () override
 execute the main function More...
 
ParticleSetPoolgetParticlePool ()
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 
- Public Member Functions inherited from QMCAppBase
 QMCAppBase ()
 constructor More...
 
virtual ~QMCAppBase ()
 destructor More...
 
bool parse (const std::string &infile)
 parse an input file More...
 
void saveXml ()
 save the xml document More...
 
const std::string & getTitle () const
 

Private Member Functions

bool runQMC (xmlNodePtr cur, bool reuse)
 execute <qmc> element More...
 
bool setMCWalkers (xmlXPathContextPtr cur)
 add <mcwalkerset> elements to continue a run More...
 
bool processPWH (xmlNodePtr cur)
 add unique ParticleSet, TrialWaveFunction and QMCHamiltonian elements to Pool objects More...
 
void executeLoop (xmlNodePtr cur)
 execute loop More...
 
bool executeDebugSection (xmlNodePtr cur)
 execute <debug> element More...
 
bool executeQMCSection (xmlNodePtr cur, bool reuse=false)
 execute qmc More...
 
bool executeCMCSection (xmlNodePtr cur)
 execute <cmc> element More...
 

Private Attributes

std::unique_ptr< ParticleSetPoolparticle_set_pool_
 ParticleSet Pool. More...
 
std::unique_ptr< WaveFunctionPoolpsi_pool_
 TrialWaveFunction Pool. More...
 
std::unique_ptr< HamiltonianPoolham_pool_
 QMCHamiltonian Pool. More...
 
MCWalkerConfigurationqmc_system_
 current MCWalkerConfiguration More...
 
std::optional< EstimatorManagerInputestimator_manager_input_
 Global estimators defined outside of <qmc> nodes. More...
 
bool first_qmc_
 flag to indicate that a qmc is the first QMC More...
 
std::unique_ptr< QMCDriverInterfacelast_driver_
 the last driver object. Should be in a loop only. More...
 
std::unique_ptr< SimpleFixedNodeBranchlast_branch_engine_legacy_driver_
 last branch engine used by legacy drivers More...
 
std::vector< xmlNodePtr > walker_set_
 xml mcwalkerset elements for output More...
 
std::vector< xmlNodePtr > walker_set_in_
 xml mcwalkerset read-in elements More...
 
xmlNodePtr walker_logs_xml_
 walkerlogs xml More...
 
xmlNodePtr traces_xml_
 traces xml More...
 
std::vector< std::pair< xmlNodePtr, bool > > qmc_action_
 qmc sections More...
 
xmlNodePtr last_input_node_
 pointer to the last node of the main inputfile More...
 

Additional Inherited Members

- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 
- Protected Member Functions inherited from QMCAppBase
bool pushDocument (const std::string &infile)
 open a new document More...
 
void popDocument ()
 close the current document More...
 
- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 
- Protected Attributes inherited from QMCAppBase
std::stack< Libxml2Document * > xml_doc_stack_
 stack of xml document More...
 
ProjectData my_project_
 project description More...
 
RandomNumberControl my_random_control_
 random number controller More...
 

Constructor & Destructor Documentation

◆ QMCMain()

QMCMain ( Communicate c)

Definition at line 58 of file QMCMain.cpp.

References qmcplusplus::app_log(), qmcplusplus::app_summary(), OHMMS::Controller, GET_MACRO_VAL, DeviceManager::getGlobal(), qmcplusplus::getGlobalTimerManager(), Communicate::getGroupID(), DeviceManager::getNumDevices(), Communicate::getNumGroups(), DeviceManager::initializeGlobalDeviceManager(), ProjectData::isComplex(), QMCAppBase::my_project_, MPIObjectBase::myComm, Communicate::NodeComm(), OHMMS_PRECISION, omp_get_num_threads(), omp_get_thread_num(), QMCState::print_git_info_if_present(), qmcplusplus::print_mem(), QMCState::print_options(), qmcplusplus::qmc_common, and Communicate::size().

59  : MPIObjectBase(c),
60  QMCAppBase(),
61  particle_set_pool_(std::make_unique<ParticleSetPool>(myComm)),
62  psi_pool_(std::make_unique<WaveFunctionPool>(my_project_.getRuntimeOptions(), *particle_set_pool_, myComm)),
63  ham_pool_(std::make_unique<HamiltonianPool>(*particle_set_pool_, *psi_pool_, myComm)),
64  qmc_system_(nullptr),
65  first_qmc_(true),
66  walker_logs_xml_(NULL)
67 #if !defined(REMOVE_TRACEMANAGER)
68  ,
69  traces_xml_(NULL)
70 #endif
71 {
73  // assign accelerators within a node
74  DeviceManager::initializeGlobalDeviceManager(node_comm.rank(), node_comm.size());
75 
76  app_summary() << "================================================================\n"
77  << " QMCPACK " << QMCPACK_VERSION_MAJOR << "." << QMCPACK_VERSION_MINOR << "."
78  << QMCPACK_VERSION_PATCH << "\n"
79  << "\n"
80  << " (c) Copyright 2003-2023 QMCPACK developers\n"
81  << "\n"
82  << " Please cite:\n"
83  << " J. Kim et al. J. Phys. Cond. Mat. 30 195901 (2018)\n"
84  << " https://doi.org/10.1088/1361-648X/aab9c3\n"
85  << " and\n"
86  << " P. Kent et al. J. Chem. Phys. 152 174105 (2020)\n"
87  << " https://doi.org/10.1063/5.0004860\n";
89  app_summary() << "================================================================\n";
91  // clang-format off
92  app_summary()
93 #if !defined(HAVE_MPI)
94  << "\n Built without MPI. Running in serial or with OMP threads." << std::endl
95 #endif
96  << "\n Total number of MPI ranks = " << OHMMS::Controller->size()
97  << "\n Number of MPI groups = " << myComm->getNumGroups()
98  << "\n MPI group ID = " << myComm->getGroupID()
99  << "\n Number of ranks in group = " << myComm->size()
100  << "\n MPI ranks per node = " << node_comm.size()
101 #if defined(ENABLE_OFFLOAD) || defined(ENABLE_CUDA) || defined(ENABLE_HIP) || defined(ENABLE_SYCL)
102  << "\n Accelerators per node = " << DeviceManager::getGlobal().getNumDevices()
103 #endif
104  << std::endl;
105  // clang-format on
106 
107 #pragma omp parallel
108  {
109  const int L1_tid = omp_get_thread_num();
110  if (L1_tid == 0)
111  app_summary() << " OMP 1st level threads = " << omp_get_num_threads() << std::endl;
112 #pragma omp parallel
113  {
114  const int L2_tid = omp_get_thread_num();
115  const int L2_num_threads = omp_get_num_threads();
116  if (L1_tid == 0 && L2_tid == 0)
117  {
118  if (L2_num_threads == 1)
119  app_summary() << " OMP nested threading disabled or only 1 thread on the 2nd level" << std::endl;
120  else
121  app_summary() << " OMP 2nd level threads = " << L2_num_threads << std::endl;
122  }
123  }
124  }
125  app_summary() << "\n Precision used in this calculation, see definitions in the manual:"
126  << "\n Base precision = " << GET_MACRO_VAL(OHMMS_PRECISION)
127  << "\n Full precision = " << GET_MACRO_VAL(OHMMS_PRECISION_FULL) << std::endl;
128 
129  // Record features configured in cmake or selected via command-line arguments to the printout
130  app_summary() << std::endl;
131 #if !defined(ENABLE_OFFLOAD) && !defined(ENABLE_CUDA) && !defined(ENABLE_HIP) && !defined(ENABLE_SYCL)
132  app_summary() << " CPU only build" << std::endl;
133 #else // GPU case
134 #if defined(ENABLE_OFFLOAD)
135  app_summary() << " OpenMP target offload to accelerators build option is enabled" << std::endl;
136 #endif
137 #if defined(ENABLE_HIP)
138  app_summary() << " HIP acceleration with direct HIP source code build option is enabled" << std::endl;
139 #endif
140 
141 #if defined(QMC_CUDA2HIP) && defined(ENABLE_CUDA)
142  app_summary() << " HIP acceleration with CUDA source code build option is enabled" << std::endl;
143 #elif defined(ENABLE_CUDA)
144  app_summary() << " CUDA acceleration build option is enabled" << std::endl;
145 #elif defined(ENABLE_SYCL)
146  app_summary() << " SYCL acceleration build option is enabled" << std::endl;
147 #endif
148 #endif // GPU case end
149 
150  if (my_project_.isComplex())
151  app_summary() << " Complex build. QMC_COMPLEX=ON" << std::endl;
152  else
153  app_summary() << " Real build. QMC_COMPLEX=OFF" << std::endl;
154 
155 #ifdef ENABLE_TIMERS
156  app_summary() << " Timer build option is enabled. Current timer level is "
157  << getGlobalTimerManager().get_timer_threshold_string() << std::endl;
158 #endif
159  app_summary() << std::endl;
160 
161  print_mem("when QMCPACK starts", app_summary());
162  app_summary() << std::endl;
163 }
void print_git_info_if_present(std::ostream &os)
Print git info (commit hash, etc) if project was build from git repository.
Definition: qmc_common.cpp:99
#define OHMMS_PRECISION
Definition: config.h:70
std::ostream & app_log()
Definition: OutputManager.h:65
std::ostream & app_summary()
Definition: OutputManager.h:63
bool isComplex() const noexcept
std::unique_ptr< ParticleSetPool > particle_set_pool_
ParticleSet Pool.
Definition: QMCMain.h:49
xmlNodePtr traces_xml_
traces xml
Definition: QMCMain.h:82
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
void print_mem(const std::string &title, std::ostream &log)
Definition: MemoryUsage.cpp:30
int size() const
return the number of tasks
Definition: Communicate.h:118
std::unique_ptr< WaveFunctionPool > psi_pool_
TrialWaveFunction Pool.
Definition: QMCMain.h:52
const RuntimeOptions & getRuntimeOptions() const noexcept
Wrapping information on parallelism.
Definition: Communicate.h:68
static const DeviceManager & getGlobal()
global instance accessor
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
int getGroupID() const
return the group id
Definition: Communicate.h:121
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
bool first_qmc_
flag to indicate that a qmc is the first QMC
Definition: QMCMain.h:64
std::unique_ptr< HamiltonianPool > ham_pool_
QMCHamiltonian Pool.
Definition: QMCMain.h:55
ProjectData my_project_
project description
Definition: QMCAppBase.h:67
omp_int_t omp_get_num_threads()
Definition: OpenMP.h:27
#define GET_MACRO_VAL(arg)
Definition: QMCMain.cpp:54
Communicate NodeComm() const
provide a node/shared-memory communicator from current (parent) communicator
int getNumGroups() const
return the number of intra_comms which belong to the same group
Definition: Communicate.h:123
void print_options(std::ostream &os)
print command-line options
Definition: qmc_common.cpp:86
MCWalkerConfiguration * qmc_system_
current MCWalkerConfiguration
Definition: QMCMain.h:58
TimerManager< NewTimer > & getGlobalTimerManager()
QMCAppBase()
constructor
QMCState qmc_common
a unique QMCState during a run
Definition: qmc_common.cpp:111
MPIObjectBase(Communicate *c)
constructor with communicator
xmlNodePtr walker_logs_xml_
walkerlogs xml
Definition: QMCMain.h:79
static void initializeGlobalDeviceManager(int local_rank, int local_size)
initialize the global instance of DeviceManager arguments are the same as the constructor ...

◆ ~QMCMain()

~QMCMain ( )
override

Definition at line 165 of file QMCMain.cpp.

References CloneManager::clearClones(), and QMCMain::last_driver_.

166 {
167  // free last_driver before clearing P,Psi,H clones
168  last_driver_.reset();
170 }
std::unique_ptr< QMCDriverInterface > last_driver_
the last driver object. Should be in a loop only.
Definition: QMCMain.h:67

Member Function Documentation

◆ execute()

bool execute ( )
overridevirtual

execute the main function

Implements QMCAppBase.

Definition at line 172 of file QMCMain.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_error(), qmcplusplus::app_log(), Communicate::barrier(), Communicate::barrier_and_abort(), OHMMS::Controller, qmcplusplus::createGlobalTimer(), ProjectData::currentMainRoot(), QMCState::dryrun, Timer::elapsed(), ERRORMSG, QMCMain::executeCMCSection(), QMCMain::executeDebugSection(), QMCMain::executeLoop(), QMCMain::executeQMCSection(), InfoStream::flush(), QMCMain::ham_pool_, infoLog, infoSummary, RandomNumberControl::initialize(), MPIObjectBase::is_manager(), QMCMain::last_input_node_, QMCAppBase::my_project_, QMCAppBase::my_random_control_, MPIObjectBase::myComm, QMCMain::particle_set_pool_, OhmmsAttributeSet::put(), QMCMain::qmc_action_, qmcplusplus::qmc_common, QMCState::qmc_counter, qmcplusplus::run_time_manager, QMCAppBase::saveXml(), Communicate::size(), TimerType< CLOCK >::start(), TimerType< CLOCK >::stop(), qmcplusplus::timer_level_coarse, QMCMain::validateXML(), QMCMain::walker_set_, and QMCAppBase::xml_doc_stack_.

173 {
174  Timer t0;
175  if (xml_doc_stack_.empty())
176  {
177  ERRORMSG("No valid input file exists! Aborting QMCMain::execute")
178  return false;
179  }
180 
181  std::string simulationType = "realspaceQMC";
182  { // mmorales: is this necessary??? Don't want to leave xmlNodes lying around unused
183  xmlNodePtr cur = xml_doc_stack_.top()->getRoot();
184  OhmmsAttributeSet simType;
185  simType.add(simulationType, "type");
186  simType.add(simulationType, "name");
187  simType.add(simulationType, "method");
188  simType.put(cur);
189  }
190 
191 #ifdef BUILD_AFQMC
192  if (simulationType == "afqmc")
193  {
195  app_log() << std::endl
196  << "/*************************************************\n"
197  << " ******** This is an AFQMC calculation ********\n"
198  << " *************************************************" << std::endl;
199  xmlNodePtr cur = xml_doc_stack_.top()->getRoot();
200 
201  xmlXPathContextPtr m_context = xml_doc_stack_.top()->getXPathContext();
202  //initialize the random number generator
203  xmlNodePtr rptr = my_random_control_.initialize(m_context);
204 
205  auto world = boost::mpi3::environment::get_world_instance();
206  afqmc::AFQMCFactory afqmc_fac(world);
207  if (!afqmc_fac.parse(cur))
208  {
209  app_log() << " Error in AFQMCFactory::parse() ." << std::endl;
210  return false;
211  }
212  cur = xml_doc_stack_.top()->getRoot();
213  return afqmc_fac.execute(cur);
214  }
215 #else
216  if (simulationType == "afqmc")
217  {
218  app_error() << " Executable not compiled with AFQMC. Recompile with BUILD_AFQMC set to 1." << std::endl;
219  return false;
220  }
221 #endif
222 
224  t2.start();
225 
227  t3.start();
228 
229  //validate the input file
230  bool success = validateXML();
231  if (!success)
232  myComm->barrier_and_abort("QMCMain::execute. Input document does not contain valid objects");
233 
234  //initialize all the instances of distance tables and evaluate them
235  particle_set_pool_->reset();
236  infoSummary.flush();
237  infoLog.flush();
238  app_log() << " Initialization Execution time = " << std::setprecision(4) << t0.elapsed() << " secs" << std::endl;
239  //write stuff
240  app_log() << "=========================================================\n";
241  app_log() << " Summary of QMC systems \n";
242  app_log() << "=========================================================\n";
243  particle_set_pool_->get(app_log());
244  ham_pool_->get(app_log());
246  t3.stop();
247  if (qmc_common.dryrun)
248  {
249  app_log() << " dryrun == 1 : Skipping all QMC and loop elements " << std::endl;
250  return true;
251  }
252  Timer t1;
254  for (int qa = 0; qa < qmc_action_.size(); qa++)
255  {
256  if (run_time_manager.isStopNeeded())
257  break;
258  xmlNodePtr cur = qmc_action_[qa].first;
259  std::string cname((const char*)cur->name);
260  if (cname == "qmc" || cname == "optimize")
261  {
262  executeQMCSection(cur);
263  qmc_common.qmc_counter++; // increase the counter
264  }
265  else if (cname == "loop")
266  {
268  executeLoop(cur);
270  }
271  else if (cname == "cmc")
272  {
273  executeCMCSection(cur);
274  }
275  else if (cname == "debug")
276  {
277  executeDebugSection(cur);
278  app_log() << " Debug is done. Skip the rest of the input " << std::endl;
279  break;
280  }
281  }
282  // free if m_qmcation owns the memory of xmlNodePtr before clearing
283  for (auto& qmcactionPair : qmc_action_)
284  if (!qmcactionPair.second)
285  xmlFreeNode(qmcactionPair.first);
286 
287  qmc_action_.clear();
288  t2.stop();
289  app_log() << " Total Execution time = " << std::setprecision(4) << t1.elapsed() << " secs" << std::endl;
290  if (is_manager())
291  {
292  //generate multiple files
293  xmlNodePtr mcptr = NULL;
294  if (walker_set_.size())
295  mcptr = walker_set_[0];
296  //remove input mcwalkerset but one
297  for (int i = 1; i < walker_set_.size(); i++)
298  {
299  xmlUnlinkNode(walker_set_[i]);
300  xmlFreeNode(walker_set_[i]);
301  }
302  walker_set_.clear(); //empty the container
303  std::ostringstream np_str, v_str;
304  np_str << myComm->size();
305  HDFVersion cur_version;
306  v_str << cur_version[0] << " " << cur_version[1];
307  xmlNodePtr newmcptr = xmlNewNode(NULL, (const xmlChar*)"mcwalkerset");
308  xmlNewProp(newmcptr, (const xmlChar*)"fileroot", (const xmlChar*)my_project_.currentMainRoot().c_str());
309  xmlNewProp(newmcptr, (const xmlChar*)"node", (const xmlChar*)"-1");
310  xmlNewProp(newmcptr, (const xmlChar*)"nprocs", (const xmlChar*)np_str.str().c_str());
311  xmlNewProp(newmcptr, (const xmlChar*)"version", (const xmlChar*)v_str.str().c_str());
312  xmlNewProp(newmcptr, (const xmlChar*)"collected", (const xmlChar*)"yes");
313  if (mcptr == NULL)
314  {
315  xmlAddNextSibling(last_input_node_, newmcptr);
316  }
317  else
318  {
319  xmlReplaceNode(mcptr, newmcptr);
320  xmlFreeNode(mcptr);
321  }
322  saveXml();
323  }
324  return true;
325 }
TimerType< ChronoClock > NewTimer
Definition: NewTimer.h:234
#define ERRORMSG(msg)
Definition: OutputManager.h:86
void barrier() const
std::vector< xmlNodePtr > walker_set_
xml mcwalkerset elements for output
Definition: QMCMain.h:73
bool executeQMCSection(xmlNodePtr cur, bool reuse=false)
execute qmc
Definition: QMCMain.cpp:695
InfoStream infoSummary
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::ostream & app_error()
Definition: OutputManager.h:67
std::unique_ptr< ParticleSetPool > particle_set_pool_
ParticleSet Pool.
Definition: QMCMain.h:49
RunTimeManager< ChronoClock > run_time_manager
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
xmlNodePtr last_input_node_
pointer to the last node of the main inputfile
Definition: QMCMain.h:88
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
void executeLoop(xmlNodePtr cur)
execute loop
Definition: QMCMain.cpp:327
void saveXml()
save the xml document
Definition: QMCAppBase.cpp:70
int size() const
return the number of tasks
Definition: Communicate.h:118
InfoStream infoLog
xmlNodePtr initialize(xmlXPathContextPtr)
bool dryrun
true, if it is a dryrun
Definition: qmc_common.h:37
std::vector< std::pair< xmlNodePtr, bool > > qmc_action_
qmc sections
Definition: QMCMain.h:85
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::unique_ptr< HamiltonianPool > ham_pool_
QMCHamiltonian Pool.
Definition: QMCMain.h:55
ProjectData my_project_
project description
Definition: QMCAppBase.h:67
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
int qmc_counter
init for <qmc> section
Definition: qmc_common.h:31
RandomNumberControl my_random_control_
random number controller
Definition: QMCAppBase.h:70
const std::string & currentMainRoot() const noexcept
returns the projectmain of the project, the series id is incremented at every QMC section <project id...
bool validateXML() override
validate the main document and (read the walker sets !)
Definition: QMCMain.cpp:376
void flush()
flush stream buffer
Definition: InfoStream.cpp:39
bool is_manager() const
return true if the rank == 0
Definition: MPIObjectBase.h:51
bool executeCMCSection(xmlNodePtr cur)
execute <cmc> element
Definition: QMCMain.cpp:712
QMCState qmc_common
a unique QMCState during a run
Definition: qmc_common.cpp:111
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
std::stack< Libxml2Document * > xml_doc_stack_
stack of xml document
Definition: QMCAppBase.h:64
bool executeDebugSection(xmlNodePtr cur)
execute <debug> element
Definition: QMCMain.cpp:687

◆ executeCMCSection()

bool executeCMCSection ( xmlNodePtr  cur)
private

execute <cmc> element

Definition at line 712 of file QMCMain.cpp.

References qmcplusplus::abs(), OhmmsAttributeSet::add(), qmcplusplus::app_log(), qmcplusplus::Units::charge::e, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), QMCHamiltonian::getObservable(), QMCHamiltonian::getObservableName(), ParticleSet::getTotalNum(), QMCMain::ham_pool_, qmcplusplus::makeGaussRandomWithEngine(), QMCMain::particle_set_pool_, QMCMain::psi_pool_, OhmmsAttributeSet::put(), QMCMain::qmc_system_, ParticleSet::R, Random, QMCHamiltonian::sizeOfObservables(), ParticleSet::update(), and QMCHamiltonian::updateSource().

Referenced by QMCMain::execute().

713 {
714  bool success = true;
715  std::string target("ion0");
717  a.add(target, "target");
718  a.put(cur);
719 
720  MCWalkerConfiguration* ions = particle_set_pool_->getWalkerSet(target);
721  TrialWaveFunction* primaryPsi = psi_pool_->getPrimary();
722  QMCHamiltonian* primaryH = ham_pool_->getPrimary();
723 
724  app_log() << "QMCMain::executeCMCSection moving " << target << " by dummy move." << std::endl;
725 
726  int nat = ions->getTotalNum();
727  ParticleSet::ParticlePos deltaR(nat);
728 
729  makeGaussRandomWithEngine(deltaR, Random); //generate random displacement
730  qmc_system_->update();
731 
732  double logpsi1 = primaryPsi->evaluateLog(*qmc_system_);
733  std::cout << "logpsi1 " << logpsi1 << std::endl;
734 
735  double eloc1 = primaryH->evaluate(*qmc_system_);
736  std::cout << "Local Energy " << eloc1 << std::endl;
737 
738  for (int i = 0; i < primaryH->sizeOfObservables(); i++)
739  app_log() << " HamTest " << primaryH->getObservableName(i) << " " << primaryH->getObservable(i) << std::endl;
740 
741  for (int iat = 0; iat < nat; ++iat)
742  {
743  ions->R[iat] += deltaR[iat];
744 
745  ions->update(); //update position and distance table of itself
746  primaryH->updateSource(*ions);
747 
748  qmc_system_->update();
749  double logpsi2 = primaryPsi->evaluateLog(*qmc_system_);
750  double eloc2 = primaryH->evaluate(*qmc_system_);
751 
752  std::cout << "\nION " << iat << " " << ions->R[iat] << std::endl;
753  std::cout << "logpsi " << logpsi2 << std::endl;
754  std::cout << "Local Energy " << eloc2 << std::endl;
755  for (int i = 0; i < primaryH->sizeOfObservables(); i++)
756  app_log() << " HamTest " << primaryH->getObservableName(i) << " " << primaryH->getObservable(i) << std::endl;
757 
758  ions->R[iat] -= deltaR[iat];
759  ions->update(); //update position and distance table of itself
760  primaryH->updateSource(*ions);
761 
762  qmc_system_->update();
763  double logpsi3 = primaryPsi->evaluateLog(*qmc_system_);
764  double eloc3 = primaryH->evaluate(*qmc_system_);
765 
766  if (std::abs(eloc1 - eloc3) > 1e-12)
767  {
768  std::cout << "ERROR Energies are different " << std::endl;
769  }
770  }
771  return success;
772 }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::unique_ptr< ParticleSetPool > particle_set_pool_
ParticleSet Pool.
Definition: QMCMain.h:49
#define Random
void update(bool skipSK=false)
update the internal data
std::unique_ptr< WaveFunctionPool > psi_pool_
TrialWaveFunction Pool.
Definition: QMCMain.h:52
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::unique_ptr< HamiltonianPool > ham_pool_
QMCHamiltonian Pool.
Definition: QMCMain.h:55
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
MCWalkerConfiguration * qmc_system_
current MCWalkerConfiguration
Definition: QMCMain.h:58
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
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)

◆ executeDebugSection()

bool executeDebugSection ( xmlNodePtr  cur)
private

execute <debug> element

Definition at line 687 of file QMCMain.cpp.

References qmcplusplus::app_log().

Referenced by QMCMain::execute().

688 {
689  app_log() << "QMCMain::executeDebugSection " << std::endl;
690  app_log() << " Use this to debug new features with <debug/> in the input file " << std::endl;
691 
692  return true;
693 }
std::ostream & app_log()
Definition: OutputManager.h:65

◆ executeLoop()

void executeLoop ( xmlNodePtr  cur)
private

execute loop

Definition at line 327 of file QMCMain.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_log(), qmcplusplus::app_warning(), QMCMain::executeQMCSection(), QMCMain::last_driver_, OhmmsAttributeSet::put(), qmcplusplus::qmc_common, QMCState::qmc_counter, and qmcplusplus::run_time_manager.

Referenced by QMCMain::execute().

328 {
329  int niter = 1;
331  a.add(niter, "max");
332  a.put(cur);
333  //reset qmc_counter
335  app_log() << "Loop execution max-interations = " << niter << std::endl;
336  for (int iter = 0; iter < niter; iter++)
337  {
338  if (run_time_manager.isStopNeeded())
339  break;
340  xmlNodePtr tcur = cur->children;
341  while (tcur != NULL)
342  {
343  std::string cname((const char*)tcur->name);
344  if (cname == "qmc")
345  {
346  //prevent completed is set
347  bool success = executeQMCSection(tcur, true);
348  if (!success)
349  {
350  app_warning() << " Terminated loop execution. A sub section returns false." << std::endl;
351  return;
352  }
353  qmc_common.qmc_counter++; // increase the counter
354  }
355  tcur = tcur->next;
356  }
357  }
358  // Destroy the last driver at the end of a loop with no further reuse of a driver needed.
359  last_driver_.reset(nullptr);
360 }
std::ostream & app_warning()
Definition: OutputManager.h:69
bool executeQMCSection(xmlNodePtr cur, bool reuse=false)
execute qmc
Definition: QMCMain.cpp:695
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
RunTimeManager< ChronoClock > run_time_manager
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
int qmc_counter
init for <qmc> section
Definition: qmc_common.h:31
std::unique_ptr< QMCDriverInterface > last_driver_
the last driver object. Should be in a loop only.
Definition: QMCMain.h:67
QMCState qmc_common
a unique QMCState during a run
Definition: qmc_common.cpp:111
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

◆ executeQMCSection()

bool executeQMCSection ( xmlNodePtr  cur,
bool  reuse = false 
)
private

execute qmc

Parameters
curqmc xml node
reuseif true, reuse the driver built from the last QMC section. This should be used by loop only.
Returns
true, if a section is successfully executed.

Definition at line 695 of file QMCMain.cpp.

References OhmmsAttributeSet::add(), QMCMain::first_qmc_, QMCMain::particle_set_pool_, OhmmsAttributeSet::put(), QMCMain::qmc_system_, QMCMain::runQMC(), and RandomNumberControl::test().

Referenced by QMCMain::execute(), and QMCMain::executeLoop().

696 {
697  std::string target("e");
698  std::string random_test("no");
700  a.add(target, "target");
701  a.add(random_test, "testrng");
702  a.put(cur);
703  if (random_test == "yes")
705  if (qmc_system_ == nullptr)
706  qmc_system_ = particle_set_pool_->getWalkerSet(target);
707  bool success = runQMC(cur, reuse);
708  first_qmc_ = false;
709  return success;
710 }
bool runQMC(xmlNodePtr cur, bool reuse)
execute <qmc> element
Definition: QMCMain.cpp:586
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::unique_ptr< ParticleSetPool > particle_set_pool_
ParticleSet Pool.
Definition: QMCMain.h:49
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
bool first_qmc_
flag to indicate that a qmc is the first QMC
Definition: QMCMain.h:64
MCWalkerConfiguration * qmc_system_
current MCWalkerConfiguration
Definition: QMCMain.h:58
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

◆ getParticlePool()

ParticleSetPool& getParticlePool ( )
inline

Definition at line 45 of file QMCMain.h.

References QMCMain::particle_set_pool_.

45 { return *particle_set_pool_; }
std::unique_ptr< ParticleSetPool > particle_set_pool_
ParticleSet Pool.
Definition: QMCMain.h:49

◆ processPWH()

bool processPWH ( xmlNodePtr  cur)
private

add unique ParticleSet, TrialWaveFunction and QMCHamiltonian elements to Pool objects

grep basic objects and add to Pools

Parameters
curxml node
Returns
false, if contains qmc actions
Parameters
curcurrent node

Recursive search all the xml elements with particleset, wavefunction and hamiltonian tags

Definition at line 522 of file QMCMain.cpp.

References qmcplusplus::app_log(), Communicate::barrier_and_abort(), QMCMain::estimator_manager_input_, QMCMain::ham_pool_, MPIObjectBase::myComm, QMCMain::particle_set_pool_, QMCMain::psi_pool_, and QMCMain::qmc_action_.

Referenced by QMCMain::validateXML().

523 {
524  //return true and will be ignored
525  if (cur == NULL)
526  return true;
527  bool inputnode = false;
528  //save the root to grep @tilematrix
529  xmlNodePtr cur_root = cur;
530  cur = cur->children;
531  while (cur != NULL)
532  {
533  std::string cname((const char*)cur->name);
534  if (cname == "simulationcell")
535  {
536  inputnode = true;
537  particle_set_pool_->readSimulationCellXML(cur);
538  }
539  else if (cname == "particleset")
540  {
541  inputnode = true;
542  particle_set_pool_->put(cur);
543  }
544  else if (cname == "wavefunction")
545  {
546  inputnode = true;
547  psi_pool_->put(cur);
548  }
549  else if (cname == "hamiltonian")
550  {
551  inputnode = true;
552  ham_pool_->put(cur);
553  }
554  else if (cname == "estimators")
555  {
556  inputnode = true;
557  try
558  {
560  throw UniformCommunicateError(
561  "QMCMain::validateXML. Illegal Input, only one global <estimators> node is permitted");
562  estimator_manager_input_ = std::optional<EstimatorManagerInput>(std::in_place, cur);
563  }
564  catch (const UniformCommunicateError& ue)
565  {
566  myComm->barrier_and_abort(ue.what());
567  }
568  }
569  else
570  //add to m_qmcaction
571  {
572  qmc_action_.push_back(std::pair<xmlNodePtr, bool>(xmlCopyNode(cur, 1), false));
573  }
574  cur = cur->next;
575  }
576  //flush
577  app_log().flush();
578  return inputnode;
579 }
std::optional< EstimatorManagerInput > estimator_manager_input_
Global estimators defined outside of <qmc> nodes.
Definition: QMCMain.h:61
std::ostream & app_log()
Definition: OutputManager.h:65
std::unique_ptr< ParticleSetPool > particle_set_pool_
ParticleSet Pool.
Definition: QMCMain.h:49
std::unique_ptr< WaveFunctionPool > psi_pool_
TrialWaveFunction Pool.
Definition: QMCMain.h:52
std::vector< std::pair< xmlNodePtr, bool > > qmc_action_
qmc sections
Definition: QMCMain.h:85
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
std::unique_ptr< HamiltonianPool > ham_pool_
QMCHamiltonian Pool.
Definition: QMCMain.h:55
void barrier_and_abort(const std::string &msg) const

◆ runQMC()

bool runQMC ( xmlNodePtr  cur,
bool  reuse 
)
private

execute <qmc> element

prepare for a QMC run

Parameters
curqmc xml node
reuseif true, reuse the driver built from the last QMC section. This should be used by loop only.

Ye: I think this can be merged with executeQMCSection

Parameters
curqmc element
reuseif true, the current call is from a loop
Returns
true, if a valid QMCDriver is set.

Definition at line 586 of file QMCMain.cpp.

References ProjectData::advance(), qmcplusplus::app_log(), QMCDriverFactory::DriverAssemblyState::append_run, Communicate::barrier_and_abort(), qmcplusplus::createGlobalTimer(), QMCDriverFactory::createQMCDriver(), ProjectData::currentMainRoot(), Timer::elapsed(), QMCMain::estimator_manager_input_, QMCMain::first_qmc_, InfoStream::flush(), QMCMain::ham_pool_, infoLog, infoSummary, QMCMain::last_branch_engine_legacy_driver_, QMCMain::last_driver_, QMCAppBase::my_project_, MPIObjectBase::myComm, QMCMain::particle_set_pool_, QMCMain::psi_pool_, QMCMain::qmc_system_, QMCDriverFactory::readSection(), qmcplusplus::timer_level_coarse, QMCMain::traces_xml_, QMCMain::walker_logs_xml_, and QMCMain::walker_set_in_.

Referenced by QMCMain::executeQMCSection().

587 {
588  std::unique_ptr<QMCDriverInterface> qmc_driver;
589  bool append_run = false;
590 
591  if (reuse && last_driver_)
592  qmc_driver = std::move(last_driver_);
593  else
594  {
595  QMCDriverFactory driver_factory(my_project_);
596  try
597  {
598  QMCDriverFactory::DriverAssemblyState das = driver_factory.readSection(cur);
599  qmc_driver = driver_factory.createQMCDriver(cur, das, estimator_manager_input_, *qmc_system_, *particle_set_pool_,
601  append_run = das.append_run;
602  }
603  catch (const UniformCommunicateError& ue)
604  {
605  myComm->barrier_and_abort(ue.what());
606  }
607  }
608 
609  if (qmc_driver)
610  {
612  {
613  last_branch_engine_legacy_driver_->resetRun(cur);
614  qmc_driver->setBranchEngine(std::move(last_branch_engine_legacy_driver_));
615  }
616 
617  //advance the project id
618  //if it is NOT the first qmc node and qmc/@append!='yes'
619  if (!first_qmc_ && !append_run)
621 
622  qmc_driver->setStatus(my_project_.currentMainRoot(), "", append_run);
623  // PD:
624  // Q: How does walker_set_in end up being non empty?
625  // A: Anytime that we aren't doing a restart.
626  // So put walkers is an exceptional call. This code does not tell a useful
627  // story of a QMCDriver's life.
628  qmc_driver->putWalkers(walker_set_in_);
629 #if !defined(REMOVE_TRACEMANAGER)
630  qmc_driver->putTraces(traces_xml_);
631 #endif
632  qmc_driver->putWalkerLogs(walker_logs_xml_);
633  {
634  ScopedTimer qmc_run_timer(createGlobalTimer(qmc_driver->getEngineName(), timer_level_coarse));
635  Timer process_and_run;
636  qmc_driver->process(cur);
637  infoSummary.flush();
638  infoLog.flush();
639 
640  qmc_driver->run();
641  app_log() << " " << qmc_driver->getEngineName() << " Execution time = " << std::setprecision(4)
642  << process_and_run.elapsed() << " secs" << std::endl;
643  }
644  // transfer the states of a driver before its destruction
645  last_branch_engine_legacy_driver_ = qmc_driver->getBranchEngine();
646  // save the driver in a driver loop
647  if (reuse)
648  last_driver_ = std::move(qmc_driver);
649  return true;
650  }
651  else
652  {
653  // Ye: in which case, the code hits this?
654  return false;
655  }
656 }
InfoStream infoSummary
std::optional< EstimatorManagerInput > estimator_manager_input_
Global estimators defined outside of <qmc> nodes.
Definition: QMCMain.h:61
std::ostream & app_log()
Definition: OutputManager.h:65
std::unique_ptr< ParticleSetPool > particle_set_pool_
ParticleSet Pool.
Definition: QMCMain.h:49
void advance()
increment a series number and reset project_root_
Definition: ProjectData.cpp:81
xmlNodePtr traces_xml_
traces xml
Definition: QMCMain.h:82
std::unique_ptr< SimpleFixedNodeBranch > last_branch_engine_legacy_driver_
last branch engine used by legacy drivers
Definition: QMCMain.h:70
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::unique_ptr< WaveFunctionPool > psi_pool_
TrialWaveFunction Pool.
Definition: QMCMain.h:52
InfoStream infoLog
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
bool first_qmc_
flag to indicate that a qmc is the first QMC
Definition: QMCMain.h:64
std::unique_ptr< HamiltonianPool > ham_pool_
QMCHamiltonian Pool.
Definition: QMCMain.h:55
ProjectData my_project_
project description
Definition: QMCAppBase.h:67
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
const std::string & currentMainRoot() const noexcept
returns the projectmain of the project, the series id is incremented at every QMC section <project id...
std::vector< xmlNodePtr > walker_set_in_
xml mcwalkerset read-in elements
Definition: QMCMain.h:76
std::unique_ptr< QMCDriverInterface > last_driver_
the last driver object. Should be in a loop only.
Definition: QMCMain.h:67
void flush()
flush stream buffer
Definition: InfoStream.cpp:39
MCWalkerConfiguration * qmc_system_
current MCWalkerConfiguration
Definition: QMCMain.h:58
void barrier_and_abort(const std::string &msg) const
xmlNodePtr walker_logs_xml_
walkerlogs xml
Definition: QMCMain.h:79

◆ setMCWalkers()

bool setMCWalkers ( xmlXPathContextPtr  context_)
private

add <mcwalkerset> elements to continue a run

Reads walkers sets from the restart file during XML validation.

TODO: Move this, it is not a concern of QMCMain

Definition at line 663 of file QMCMain.cpp.

References OhmmsAttributeSet::add(), MPIObjectBase::myComm, OhmmsAttributeSet::put(), RandomNumberControl::read(), OhmmsXPathObject::size(), QMCMain::walker_set_, and QMCMain::walker_set_in_.

Referenced by QMCMain::validateXML().

664 {
665  OhmmsXPathObject result("/simulation/mcwalkerset", context_);
666  for (int iconf = 0; iconf < result.size(); iconf++)
667  {
668  xmlNodePtr mc_ptr = result[iconf];
669  walker_set_.push_back(mc_ptr);
670  walker_set_in_.push_back(mc_ptr);
671  }
672  //use the last mcwalkerset to initialize random numbers if possible
673  if (result.size())
674  {
675  std::string fname;
677  a.add(fname, "fileroot");
678  a.add(fname, "href");
679  a.add(fname, "src");
680  a.put(result[result.size() - 1]);
681  if (fname.size())
683  }
684  return true;
685 }
static void read(const std::string &fname, Communicate *comm)
read in parallel or serial
std::vector< xmlNodePtr > walker_set_
xml mcwalkerset elements for output
Definition: QMCMain.h:73
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
class to handle xmlXPathObject
Definition: Libxml2Doc.h:26
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::vector< xmlNodePtr > walker_set_in_
xml mcwalkerset read-in elements
Definition: QMCMain.h:76
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

◆ validateXML()

bool validateXML ( )
overridevirtual

validate the main document and (read the walker sets !)

Returns
false, if any of the basic objects is not properly created.

Current xml schema is changing. Instead validating the input file, we use xpath to create necessary objects. The order follows

  • project: determine the simulation title and sequence
  • random: initialize random number generator
  • particleset: create all the particleset
  • wavefunction: create wavefunctions
  • hamiltonian: create hamiltonians Finally, if /simulation/mcwalkerset exists, read the configurations from the external files. TODO: Move this out of what should be a stateless call

Implements QMCAppBase.

Definition at line 376 of file QMCMain.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_log(), qmcplusplus::app_summary(), qmcplusplus::app_warning(), Communicate::barrier_and_abort(), OhmmsXPathObject::empty(), ProjectData::get(), getXMLAttributeValue(), qmcplusplus::ham, QMCMain::ham_pool_, RandomNumberControl::initialize(), QMCMain::last_input_node_, QMCAppBase::my_project_, QMCAppBase::my_random_control_, MPIObjectBase::myComm, QMCMain::particle_set_pool_, QMCAppBase::popDocument(), QMCMain::processPWH(), QMCMain::psi_pool_, QMCAppBase::pushDocument(), InitMolecularSystem::put(), OhmmsAttributeSet::put(), ProjectData::put(), QMCMain::qmc_action_, qmcplusplus::qmc_common, ProjectData::reset(), ProjectData::setCommunicator(), QMCMain::setMCWalkers(), QMCHamiltonian::size(), QMCMain::traces_xml_, QMCState::use_density, QMCMain::walker_logs_xml_, and QMCAppBase::xml_doc_stack_.

Referenced by QMCMain::execute().

377 {
378  xmlXPathContextPtr m_context = xml_doc_stack_.top()->getXPathContext();
379  OhmmsXPathObject result("//project", m_context);
381  if (result.empty())
382  {
383  app_warning() << "Project is not defined" << std::endl;
384  my_project_.reset();
385  }
386  else
387  {
388  try
389  {
390  my_project_.put(result[0]);
391  }
392  catch (const UniformCommunicateError& ue)
393  {
394  myComm->barrier_and_abort(ue.what());
395  }
396  }
397  app_summary() << std::endl;
399  app_summary() << std::endl;
400  OhmmsXPathObject ham("//hamiltonian", m_context);
401  if (ham.empty())
402  {
403  qmc_common.use_density = true;
404  }
405  else
406  {
407  for (int i = 0; i < ham.size(); ++i)
408  {
409  xmlNodePtr cur = ham[i]->children;
410  while (cur != NULL)
411  {
412  std::string aname = "0";
414  a.add(aname, "type");
415  a.put(cur);
416  if (aname == "mpc" || aname == "MPC")
417  {
418  qmc_common.use_density = true;
419  }
420  cur = cur->next;
421  }
422  }
423  }
425  {
426  app_log() << " hamiltonian has MPC. Will read density if it is found." << std::endl << std::endl;
427  }
428 
429  //initialize the random number generator
430  xmlNodePtr rptr = my_random_control_.initialize(m_context);
431  //preserve the input order
432  xmlNodePtr cur = xml_doc_stack_.top()->getRoot()->children;
433  last_input_node_ = NULL;
434  while (cur != NULL)
435  {
436  std::string cname((const char*)cur->name);
437  bool inputnode = true;
438  if (cname == "particleset")
439  {
440  particle_set_pool_->put(cur);
441  }
442  else if (cname == "wavefunction")
443  {
444  psi_pool_->put(cur);
445  }
446  else if (cname == "hamiltonian")
447  {
448  ham_pool_->put(cur);
449  }
450  else if (cname == "include")
451  {
452  //file is provided
453  const std::string include_name(getXMLAttributeValue(cur, "href"));
454  if (!include_name.empty())
455  {
456  bool success = pushDocument(include_name);
457  if (success)
458  {
459  inputnode = processPWH(xml_doc_stack_.top()->getRoot());
460  popDocument();
461  }
462  else
463  myComm->barrier_and_abort("Invalid XML document");
464  }
465  else
466  myComm->barrier_and_abort(R"(tag "include" must include an "href" attribute.)");
467  }
468  else if (cname == "qmcsystem")
469  {
470  inputnode = processPWH(cur);
471  }
472  else if (cname == "init")
473  {
474  InitMolecularSystem moinit(*particle_set_pool_);
475  moinit.put(cur);
476  }
477 #if !defined(REMOVE_TRACEMANAGER)
478  else if (cname == "traces")
479  {
480  traces_xml_ = cur;
481  }
482 #endif
483  else if (cname == "walkerlogs")
484  {
485  walker_logs_xml_ = cur;
486  }
487  else
488  {
489  //everything else goes to m_qmcaction
490  qmc_action_.push_back(std::pair<xmlNodePtr, bool>(cur, true));
491  inputnode = false;
492  }
493  if (inputnode)
494  last_input_node_ = cur;
495  cur = cur->next;
496  }
497 
498  if (particle_set_pool_->empty())
499  myComm->barrier_and_abort("QMCMain::validateXML. Illegal input. Missing particleset.");
500 
501  if (psi_pool_->empty())
502  myComm->barrier_and_abort("QMCMain::validateXML. Illegal input. Missing wavefunction.");
503 
504  if (ham_pool_->empty())
505  myComm->barrier_and_abort("QMCMain::validateXML. Illegal input. Missing Hamiltonian.");
506 
507  //randomize any particleset with random="yes" && random_source="ion0"
508  particle_set_pool_->randomize();
509 
510  setMCWalkers(m_context);
511 
512  return true;
513 }
std::ostream & app_warning()
Definition: OutputManager.h:69
void setCommunicator(Communicate *c)
Definition: ProjectData.cpp:50
std::ostream & app_log()
Definition: OutputManager.h:65
std::ostream & app_summary()
Definition: OutputManager.h:63
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::unique_ptr< ParticleSetPool > particle_set_pool_
ParticleSet Pool.
Definition: QMCMain.h:49
xmlNodePtr traces_xml_
traces xml
Definition: QMCMain.h:82
xmlNodePtr last_input_node_
pointer to the last node of the main inputfile
Definition: QMCMain.h:88
std::unique_ptr< WaveFunctionPool > psi_pool_
TrialWaveFunction Pool.
Definition: QMCMain.h:52
class to handle xmlXPathObject
Definition: Libxml2Doc.h:26
xmlNodePtr initialize(xmlXPathContextPtr)
bool put(std::istream &is)
Definition: ProjectData.cpp:60
std::vector< std::pair< xmlNodePtr, bool > > qmc_action_
qmc sections
Definition: QMCMain.h:85
bool processPWH(xmlNodePtr cur)
add unique ParticleSet, TrialWaveFunction and QMCHamiltonian elements to Pool objects ...
Definition: QMCMain.cpp:522
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
int size() const
return the number of Hamiltonians
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::unique_ptr< HamiltonianPool > ham_pool_
QMCHamiltonian Pool.
Definition: QMCMain.h:55
ProjectData my_project_
project description
Definition: QMCAppBase.h:67
bool pushDocument(const std::string &infile)
open a new document
Definition: QMCAppBase.cpp:30
std::string getXMLAttributeValue(const xmlNodePtr cur, const std::string_view name)
get the value string for attribute name if name is unfound in cur you get an empty string back this i...
RandomNumberControl my_random_control_
random number controller
Definition: QMCAppBase.h:70
bool setMCWalkers(xmlXPathContextPtr cur)
add <mcwalkerset> elements to continue a run
Definition: QMCMain.cpp:663
bool get(std::ostream &os) const
Definition: ProjectData.cpp:52
void popDocument()
close the current document
Definition: QMCAppBase.cpp:46
QMCState qmc_common
a unique QMCState during a run
Definition: qmc_common.cpp:111
void barrier_and_abort(const std::string &msg) const
xmlNodePtr walker_logs_xml_
walkerlogs xml
Definition: QMCMain.h:79
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
std::stack< Libxml2Document * > xml_doc_stack_
stack of xml document
Definition: QMCAppBase.h:64
void reset()
Construct the root name with title_ and m_series.
Definition: ProjectData.cpp:97
bool use_density
true, if density is used, e.g. MPC
Definition: qmc_common.h:35

Member Data Documentation

◆ estimator_manager_input_

std::optional<EstimatorManagerInput> estimator_manager_input_
private

Global estimators defined outside of <qmc> nodes.

Definition at line 61 of file QMCMain.h.

Referenced by QMCMain::processPWH(), and QMCMain::runQMC().

◆ first_qmc_

bool first_qmc_
private

flag to indicate that a qmc is the first QMC

Definition at line 64 of file QMCMain.h.

Referenced by QMCMain::executeQMCSection(), and QMCMain::runQMC().

◆ ham_pool_

std::unique_ptr<HamiltonianPool> ham_pool_
private

◆ last_branch_engine_legacy_driver_

std::unique_ptr<SimpleFixedNodeBranch> last_branch_engine_legacy_driver_
private

last branch engine used by legacy drivers

Definition at line 70 of file QMCMain.h.

Referenced by QMCMain::runQMC().

◆ last_driver_

std::unique_ptr<QMCDriverInterface> last_driver_
private

the last driver object. Should be in a loop only.

Definition at line 67 of file QMCMain.h.

Referenced by QMCMain::executeLoop(), QMCMain::runQMC(), and QMCMain::~QMCMain().

◆ last_input_node_

xmlNodePtr last_input_node_
private

pointer to the last node of the main inputfile

Definition at line 88 of file QMCMain.h.

Referenced by QMCMain::execute(), and QMCMain::validateXML().

◆ particle_set_pool_

◆ psi_pool_

std::unique_ptr<WaveFunctionPool> psi_pool_
private

◆ qmc_action_

std::vector<std::pair<xmlNodePtr, bool> > qmc_action_
private

qmc sections

Definition at line 85 of file QMCMain.h.

Referenced by QMCMain::execute(), QMCMain::processPWH(), and QMCMain::validateXML().

◆ qmc_system_

MCWalkerConfiguration* qmc_system_
private

◆ traces_xml_

xmlNodePtr traces_xml_
private

traces xml

Definition at line 82 of file QMCMain.h.

Referenced by QMCMain::runQMC(), and QMCMain::validateXML().

◆ walker_logs_xml_

xmlNodePtr walker_logs_xml_
private

walkerlogs xml

Definition at line 79 of file QMCMain.h.

Referenced by QMCMain::runQMC(), and QMCMain::validateXML().

◆ walker_set_

std::vector<xmlNodePtr> walker_set_
private

xml mcwalkerset elements for output

Definition at line 73 of file QMCMain.h.

Referenced by QMCMain::execute(), and QMCMain::setMCWalkers().

◆ walker_set_in_

std::vector<xmlNodePtr> walker_set_in_
private

xml mcwalkerset read-in elements

Definition at line 76 of file QMCMain.h.

Referenced by QMCMain::runQMC(), and QMCMain::setMCWalkers().