QMCPACK
SPOSetBuilderFactory Class Reference
+ Inheritance diagram for SPOSetBuilderFactory:
+ Collaboration diagram for SPOSetBuilderFactory:

Public Types

using SPOMap = SPOSet::SPOMap
 
using PSetMap = 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

 SPOSetBuilderFactory (Communicate *comm, ParticleSet &els, const PSetMap &psets)
 constructor More...
 
 ~SPOSetBuilderFactory ()
 
std::unique_ptr< SPOSetBuildercreateSPOSetBuilder (xmlNodePtr rootNode)
 
const SPOSetgetSPOSet (const std::string &name) const
 returns a named sposet from the pool only use in serial portion of execution ie during initialization prior to threaded code More...
 
void buildSPOSetCollection (xmlNodePtr cur)
 
bool empty () const
 
void addSPOSet (std::unique_ptr< SPOSet >)
 add an SPOSet to sposets map. More...
 
SPOMap && exportSPOSets ()
 
- 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

ParticleSettargetPtcl
 reference to the target particle More...
 
const PSetMapptclPool
 reference to the particle pool More...
 
SPOMap sposets
 list of all sposets created by the builders of this factory More...
 

Static Private Attributes

static std::string basisset_tag = "basisset"
 

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...
 

Detailed Description

Definition at line 25 of file SPOSetBuilderFactory.h.

Member Typedef Documentation

◆ PSetMap

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

Definition at line 29 of file SPOSetBuilderFactory.h.

◆ SPOMap

Definition at line 28 of file SPOSetBuilderFactory.h.

Constructor & Destructor Documentation

◆ SPOSetBuilderFactory()

SPOSetBuilderFactory ( Communicate comm,
ParticleSet els,
const PSetMap psets 
)

constructor

Parameters
commcommunicator
elsreference to the electrons
ionsreference to the ions
elsreference to the electrons
psireference to the wavefunction
ionsreference to the ions

Definition at line 63 of file SPOSetBuilderFactory.cpp.

References MPIObjectBase::ClassName.

64  : MPIObjectBase(comm), targetPtcl(els), ptclPool(psets)
65 {
66  ClassName = "SPOSetBuilderFactory";
67 }
const PSetMap & ptclPool
reference to the particle pool
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
ParticleSet & targetPtcl
reference to the target particle
MPIObjectBase(Communicate *c)
constructor with communicator

◆ ~SPOSetBuilderFactory()

Definition at line 69 of file SPOSetBuilderFactory.cpp.

References DEBUG_MEMORY.

69 { DEBUG_MEMORY("SPOSetBuilderFactory::~SPOSetBuilderFactory"); }
#define DEBUG_MEMORY(msg)
Definition: Configuration.h:31

Member Function Documentation

◆ addSPOSet()

void addSPOSet ( std::unique_ptr< SPOSet spo)

add an SPOSet to sposets map.

This is only used to handle legacy SPOSet input styles without using sposet_collection

Definition at line 216 of file SPOSetBuilderFactory.cpp.

References Communicate::barrier_and_abort(), MPIObjectBase::myComm, and SPOSetBuilderFactory::sposets.

Referenced by SlaterDetBuilder::buildComponent(), SPOSetBuilderFactory::buildSPOSetCollection(), and SlaterDetBuilder::putDeterminant().

217 {
218  if (spo->getName().empty())
219  myComm->barrier_and_abort("sposet created in sposet_collection must have a name!");
220 
221  if (sposets.find(spo->getName()) != sposets.end())
222  myComm->barrier_and_abort("The name of each sposet must be unique! '" + spo->getName() + "' exists.");
223  else
224  sposets.emplace(spo->getName(), std::move(spo));
225 }
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
SPOMap sposets
list of all sposets created by the builders of this factory
void barrier_and_abort(const std::string &msg) const

◆ buildSPOSetCollection()

void buildSPOSetCollection ( xmlNodePtr  cur)

Definition at line 165 of file SPOSetBuilderFactory.cpp.

References OhmmsAttributeSet::add(), SPOSetBuilderFactory::addSPOSet(), qmcplusplus::app_summary(), Communicate::barrier_and_abort(), SPOSetBuilderFactory::createSPOSetBuilder(), MPIObjectBase::myComm, processChildren(), SPOSetBuilderFactory::ptclPool, OhmmsAttributeSet::put(), SPOSetScanner::put(), Communicate::rank(), SPOSetBuilderFactory::sposets, and SPOSetBuilderFactory::targetPtcl.

Referenced by WaveFunctionFactory::buildTWF().

166 {
167  std::string collection_name;
168  std::string collection_type;
169  OhmmsAttributeSet attrib;
170  attrib.add(collection_name, "name");
171  attrib.add(collection_type, "type");
172  attrib.put(cur);
173 
174  // use collection_type as collection_name if collection_name is not given
175  if (collection_name.empty())
176  collection_name = collection_type;
177 
178  app_summary() << std::endl;
179  app_summary() << " Single particle orbitals (SPO) collection" << std::endl;
180  app_summary() << " -----------------------------------------" << std::endl;
181  app_summary() << " Name: " << collection_name << " Type input: " << collection_type << std::endl;
182  app_summary() << std::endl;
183 
184  // create the SPOSet builder
185  auto bb = createSPOSetBuilder(cur);
186 
187  // going through a list of sposet entries
188  int nsposets = 0;
189  processChildren(cur, [&](const std::string& cname, const xmlNodePtr element) {
190  if (cname == "sposet")
191  {
192  addSPOSet(std::unique_ptr<SPOSet>(bb->createSPOSet(element)));
193  nsposets++;
194  }
195  if (cname == "rotated_sposet")
196  {
197  addSPOSet(std::unique_ptr<SPOSet>(bb->createRotatedSPOSet(element)));
198  nsposets++;
199  }
200  });
201 
202  if (nsposets == 0)
203  myComm->barrier_and_abort("SPOSetBuilderFactory::buildSPOSetCollection no <sposet/> elements found");
204 
205  // going through a list of spo_scanner entries
206  processChildren(cur, [&](const std::string& cname, const xmlNodePtr element) {
207  if (cname == "spo_scanner")
208  if (myComm->rank() == 0)
209  {
210  SPOSetScanner ascanner(sposets, targetPtcl, ptclPool);
211  ascanner.put(element);
212  }
213  });
214 }
const PSetMap & ptclPool
reference to the particle pool
int rank() const
return the rank
Definition: Communicate.h:116
std::ostream & app_summary()
Definition: OutputManager.h:63
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
void addSPOSet(std::unique_ptr< SPOSet >)
add an SPOSet to sposets map.
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
ParticleSet & targetPtcl
reference to the target particle
void processChildren(const xmlNodePtr cur, const F &functor)
process through all the children of an XML element F is a lambda or functor void F/[](const std::stri...
Definition: libxmldefs.h:175
SPOMap sposets
list of all sposets created by the builders of this factory
std::unique_ptr< SPOSetBuilder > createSPOSetBuilder(xmlNodePtr rootNode)
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

◆ createSPOSetBuilder()

std::unique_ptr< SPOSetBuilder > createSPOSetBuilder ( xmlNodePtr  rootNode)

Definition at line 71 of file SPOSetBuilderFactory.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_log(), Communicate::barrier_and_abort(), MPIObjectBase::ClassName, ReportEngine::error(), ReportEngine::flush(), ParticleSet::get(), ParticleSet::isSpinor(), qmcplusplus::lowerCase(), MPIObjectBase::myComm, SPOSetBuilderFactory::ptclPool, OhmmsAttributeSet::put(), and SPOSetBuilderFactory::targetPtcl.

Referenced by SlaterDetBuilder::buildComponent(), SPOSetBuilderFactory::buildSPOSetCollection(), qmcplusplus::test_C_diamond(), qmcplusplus::test_cartesian_ao(), qmcplusplus::TEST_CASE(), qmcplusplus::test_dirac_ao(), qmcplusplus::test_EtOH_mw(), qmcplusplus::test_HCN(), qmcplusplus::test_He(), qmcplusplus::test_He_mw(), qmcplusplus::test_lcao_spinor(), qmcplusplus::test_lcao_spinor_excited(), qmcplusplus::test_lcao_spinor_ion_derivs(), and qmcplusplus::test_Ne().

72 {
73  ReportEngine PRE(ClassName, "createSPOSetBuilder");
74  std::string sourceOpt("ion0");
75  std::string type("");
76  std::string name("");
77  OhmmsAttributeSet aAttrib;
78  aAttrib.add(sourceOpt, "source");
79  aAttrib.add(type, "type");
80  aAttrib.add(name, "name");
81 
82  if (rootNode != NULL)
83  aAttrib.put(rootNode);
84 
85  std::string type_in = type;
86  type = lowerCase(type);
87 
88  //when name is missing, type becomes the input
89  if (name.empty())
90  name = type_in;
91 
92  std::unique_ptr<SPOSetBuilder> bb;
93 
94  if (type == "composite")
95  {
96  app_log() << "Composite SPO set with existing SPOSets." << std::endl;
97  bb = std::make_unique<CompositeSPOSetBuilder>(myComm, *this);
98  }
99  else if (type == "jellium" || type == "heg" || type == "free")
100  {
101  app_log() << "Free-particle SPO set" << std::endl;
102  bb = std::make_unique<FreeOrbitalBuilder>(targetPtcl, myComm, rootNode);
103  }
104  else if (type == "sho")
105  {
106  app_log() << "Harmonic Oscillator SPO set" << std::endl;
107  bb = std::make_unique<SHOSetBuilder>(targetPtcl, myComm);
108  }
109  else if (type == "PWBasis" || type == "PW" || type == "pw")
110  {
111  app_log() << "Planewave basis SPO set" << std::endl;
112  bb = std::make_unique<PWOrbitalSetBuilder>(targetPtcl, myComm, rootNode);
113  }
114 #if OHMMS_DIM == 3
115  else if (type.find("spline") < type.size())
116  {
117  if (targetPtcl.isSpinor())
118  {
119 #ifdef QMC_COMPLEX
120  app_log() << "Einspline Spinor Set\n";
121  bb = std::make_unique<EinsplineSpinorSetBuilder>(targetPtcl, ptclPool, myComm, rootNode);
122 #else
123  PRE.error("Use of einspline spinors requires QMC_COMPLEX=1. Rebuild with this option");
124 #endif
125  }
126  else
127  {
128 #if defined(HAVE_EINSPLINE)
129  PRE << "EinsplineSetBuilder: using libeinspline for B-spline orbitals.\n";
130  bb = std::make_unique<EinsplineSetBuilder>(targetPtcl, ptclPool, myComm, rootNode);
131 #else
132  PRE.error("Einspline is missing for B-spline orbitals", true);
133 #endif
134  }
135  }
136  else if (type == "molecularorbital" || type == "mo")
137  {
138  ParticleSet* ions = nullptr;
139  //initialize with the source tag
140  auto pit(ptclPool.find(sourceOpt));
141  if (pit == ptclPool.end())
142  PRE.error("Missing basisset/@source.", true);
143  else
144  ions = pit->second.get();
145  if (targetPtcl.isSpinor())
146 #ifdef QMC_COMPLEX
147  bb = std::make_unique<LCAOSpinorBuilder>(targetPtcl, *ions, myComm, rootNode);
148 #else
149  PRE.error("Use of lcao spinors requires QMC_COMPLEX=1. Rebuild with this option");
150 #endif
151  else
152  bb = std::make_unique<LCAOrbitalBuilder>(targetPtcl, *ions, myComm, rootNode);
153  }
154 #endif //OHMMS_DIM==3
155  PRE.flush();
156 
157  if (!bb)
158  myComm->barrier_and_abort("SPOSetBuilderFactory::createSPOSetBuilder SPOSetBuilder creation failed.");
159 
160  app_log() << " Created SPOSet builder named '" << name << "' of type " << type << std::endl;
161  return bb;
162 }
const PSetMap & ptclPool
reference to the particle pool
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::string lowerCase(const std::string_view s)
++17
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
ParticleSet & targetPtcl
reference to the target particle
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

◆ empty()

bool empty ( ) const
inline

Definition at line 50 of file SPOSetBuilderFactory.h.

References SPOSetBuilderFactory::sposets.

Referenced by SlaterDetBuilder::buildComponent().

50 { return sposets.empty(); }
SPOMap sposets
list of all sposets created by the builders of this factory

◆ exportSPOSets()

SPOMap&& exportSPOSets ( )
inline

Definition at line 57 of file SPOSetBuilderFactory.h.

References SPOSetBuilderFactory::sposets.

Referenced by WaveFunctionFactory::buildTWF().

57 { return std::move(sposets); }
SPOMap sposets
list of all sposets created by the builders of this factory

◆ getSPOSet()

const SPOSet * getSPOSet ( const std::string &  name) const

returns a named sposet from the pool only use in serial portion of execution ie during initialization prior to threaded code

Definition at line 46 of file SPOSetBuilderFactory.cpp.

References SPOSetBuilderFactory::sposets.

Referenced by SlaterDetBuilder::buildComponent(), CompositeSPOSetBuilder::createSPOSetFromXML(), and SlaterDetBuilder::putDeterminant().

47 {
48  if (auto spoit = sposets.find(name); spoit == sposets.end())
49  {
50  // keep this commented until legacy input styles are moved.
51  // In legacy input styles, this look up may fail and need to build SPOSet on the fly.
52  return nullptr;
53  }
54  else
55  return spoit->second.get();
56 }
SPOMap sposets
list of all sposets created by the builders of this factory

Member Data Documentation

◆ basisset_tag

std::string basisset_tag = "basisset"
staticprivate

Definition at line 69 of file SPOSetBuilderFactory.h.

◆ ptclPool

const PSetMap& ptclPool
private

reference to the particle pool

Definition at line 64 of file SPOSetBuilderFactory.h.

Referenced by SPOSetBuilderFactory::buildSPOSetCollection(), and SPOSetBuilderFactory::createSPOSetBuilder().

◆ sposets

◆ targetPtcl

ParticleSet& targetPtcl
private

reference to the target particle

Definition at line 61 of file SPOSetBuilderFactory.h.

Referenced by SPOSetBuilderFactory::buildSPOSetCollection(), and SPOSetBuilderFactory::createSPOSetBuilder().


The documentation for this class was generated from the following files: