QMCPACK
LCAOrbitalBuilder Class Reference

SPOSetBuilder using new LCAOrbitalSet and Soa versions. More...

+ Inheritance diagram for LCAOrbitalBuilder:
+ Collaboration diagram for LCAOrbitalBuilder:

Public Types

using BasisSet_t = LCAOrbitalSet::basis_type
 
using BasissetMap = std::map< std::string, std::unique_ptr< BasisSet_t > >
 
- Public Types inherited from SPOSetBuilder
using indices_t = std::vector< int >
 
using energies_t = std::vector< RealType >
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 

Public Member Functions

 LCAOrbitalBuilder (ParticleSet &els, ParticleSet &ions, Communicate *comm, xmlNodePtr cur)
 constructor More...
 
 ~LCAOrbitalBuilder () override
 
std::unique_ptr< SPOSetcreateSPOSetFromXML (xmlNodePtr cur) override
 create an sposet from xml (legacy) More...
 
const BasissetMapgetBasissetMap () const
 
- Public Member Functions inherited from SPOSetBuilder
 SPOSetBuilder (const std::string &type_name, Communicate *comm)
 
virtual ~SPOSetBuilder ()
 
void reserve_states (int nsets=1)
 reserve space for states (usually only one set, multiple for e.g. spin dependent einspline) More...
 
void modify_states (int index=0)
 allow modification of state information More...
 
void clear_states (int index=0)
 clear state information More...
 
std::unique_ptr< SPOSetcreateSPOSet (xmlNodePtr cur)
 create an sposet from xml and save the resulting SPOSet More...
 
std::unique_ptr< SPOSetcreateRotatedSPOSet (xmlNodePtr cur)
 create orbital rotation transformation from xml and save the resulting SPOSet More...
 
const std::string & getTypeName () const
 
- 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)
 

Protected Member Functions

template<int I, int J>
BasisSet_tcreateBasisSet (xmlNodePtr cur)
 create basis set More...
 
template<int I, int J>
BasisSet_tcreateBasisSetH5 ()
 
bool loadMO (LCAOrbitalSet &spo, xmlNodePtr cur)
 Parse the xml file for information on the Dirac determinants. More...
 
bool putOccupation (LCAOrbitalSet &spo, xmlNodePtr occ_ptr)
 
bool putFromXML (LCAOrbitalSet &spo, xmlNodePtr coeff_ptr)
 
bool putFromH5 (LCAOrbitalSet &spo, xmlNodePtr coeff_ptr)
 read data from a hdf5 file More...
 
bool putPBCFromH5 (LCAOrbitalSet &spo, xmlNodePtr coeff_ptr)
 read data from a hdf5 file More...
 
void LoadFullCoefsFromH5 (hdf_archive &hin, int setVal, PosType &SuperTwist, Matrix< std::complex< RealType >> &Ctemp, bool MultiDet)
 
void LoadFullCoefsFromH5 (hdf_archive &hin, int setVal, PosType &SuperTwist, Matrix< RealType > &Creal, bool Multidet)
 
void EvalPeriodicImagePhaseFactors (PosType SuperTwist, Vector< RealType, OffloadPinnedAllocator< RealType >> &LocPeriodicImagePhaseFactors, Array< RealType, 2, OffloadPinnedAllocator< RealType >> &LocPeriodicImageDisplacements)
 Periodic Image Phase Factors computation to be determined. More...
 
void EvalPeriodicImagePhaseFactors (PosType SuperTwist, Vector< std::complex< RealType >, OffloadPinnedAllocator< std::complex< RealType >>> &LocPeriodicImagePhaseFactors, Array< RealType, 2, OffloadPinnedAllocator< RealType >> &LocPeriodicImageDisplacements)
 
void readRealMatrixFromH5 (hdf_archive &hin, const std::string &setname, Matrix< LCAOrbitalBuilder::RealType > &Creal) const
 read matrix from h5 file More...
 
- Protected Member Functions inherited from SPOSetBuilder
virtual std::unique_ptr< SPOSetcreateSPOSet (xmlNodePtr cur, SPOSetInputInfo &input_info)
 create an sposet from a general xml request More...
 

Protected Attributes

ParticleSettargetPtcl
 target ParticleSet More...
 
ParticleSetsourcePtcl
 source ParticleSet More...
 
std::map< std::string, std::unique_ptr< BasisSet_t > > basisset_map_
 localized basis set map More...
 
bool cuspCorr
 if true, add cusp correction to orbitals More...
 
std::string h5_path
 Path to HDF5 Wavefunction. More...
 
TinyVector< int, 3 > PBCImages
 Number of periodic Images for Orbital evaluation. More...
 
PosType SuperTwist
 Coordinates Super Twist. More...
 
Vector< ValueType, OffloadPinnedAllocator< ValueType > > PeriodicImagePhaseFactors
 Periodic Image Phase Factors. Correspond to the phase from the PBCImages. Computed only once. More...
 
Array< RealType, 2, OffloadPinnedAllocator< RealType > > PeriodicImageDisplacements
 
Tensor< double, 3 > Lattice
 Store Lattice parameters from HDF5 to use in PeriodicImagePhaseFactors. More...
 
bool doCuspCorrection
 Enable cusp correction. More...
 
std::string useGPU
 Captured gpu input string. More...
 
Vector< RealTypeOcc
 occupation number More...
 
- Protected Attributes inherited from SPOSetBuilder
const std::string type_name_
 type name of the SPO objects built by this builder. 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...
 

Private Member Functions

std::unique_ptr< BasisSet_tloadBasisSetFromXML (xmlNodePtr cur, xmlNodePtr parent)
 load a basis set from XML input More...
 
std::unique_ptr< BasisSet_tloadBasisSetFromH5 (xmlNodePtr parent)
 load a basis set from h5 file More...
 
int determineRadialOrbType (xmlNodePtr cur) const
 determine radial orbital type based on "keyword" and "transform" attributes More...
 

Additional Inherited Members

- Public Attributes inherited from SPOSetBuilder
bool legacy
 whether implementation conforms only to legacy standard More...
 
std::vector< std::unique_ptr< SPOSetInfo > > states
 state info of all possible states available in the basis More...
 

Detailed Description

SPOSetBuilder using new LCAOrbitalSet and Soa versions.

Reimplement MolecularSPOSetBuilder

Definition at line 33 of file LCAOrbitalBuilder.h.

Member Typedef Documentation

◆ BasisSet_t

Definition at line 36 of file LCAOrbitalBuilder.h.

◆ BasissetMap

using BasissetMap = std::map<std::string, std::unique_ptr<BasisSet_t> >

Definition at line 46 of file LCAOrbitalBuilder.h.

Constructor & Destructor Documentation

◆ LCAOrbitalBuilder()

LCAOrbitalBuilder ( ParticleSet els,
ParticleSet ions,
Communicate comm,
xmlNodePtr  cur 
)

constructor

Parameters
elsreference to the electrons
ionsreference to the ions

Definition at line 120 of file LCAOrbitalBuilder.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_warning(), LCAOrbitalBuilder::basisset_map_, PlatformSelector< KIND >::candidate_values(), MPIObjectBase::ClassName, LCAOrbitalBuilder::doCuspCorrection, LCAOrbitalBuilder::EvalPeriodicImagePhaseFactors(), getXMLAttributeValue(), LCAOrbitalBuilder::h5_path, LCAOrbitalBuilder::loadBasisSetFromH5(), LCAOrbitalBuilder::loadBasisSetFromXML(), LCAOrbitalBuilder::PBCImages, LCAOrbitalBuilder::PeriodicImageDisplacements, LCAOrbitalBuilder::PeriodicImagePhaseFactors, processChildren(), OhmmsAttributeSet::put(), LCAOrbitalBuilder::SuperTwist, and LCAOrbitalBuilder::useGPU.

121  : SPOSetBuilder("LCAO", comm),
122  targetPtcl(els),
123  sourcePtcl(ions),
124  h5_path(""),
125  SuperTwist(0.0),
126  doCuspCorrection(false)
127 {
128  ClassName = "LCAOrbitalBuilder";
129  ReportEngine PRE(ClassName, "createBasisSet");
130 
131  std::string cuspC("no"); // cusp correction
132  OhmmsAttributeSet aAttrib;
133  aAttrib.add(cuspC, "cuspCorrection");
134  aAttrib.add(h5_path, "href");
135  aAttrib.add(PBCImages, "PBCimages");
136  aAttrib.add(SuperTwist, "twist");
138  aAttrib.put(cur);
139 
140  if (cuspC == "yes")
141  doCuspCorrection = true;
142  //Evaluate the Phase factor. Equals 1 for OBC.
144 
145  // no need to wait but load the basis set
146  processChildren(cur, [&](const std::string& cname, const xmlNodePtr element) {
147  if (cname == "basisset")
148  {
149  std::string basisset_name_input(getXMLAttributeValue(element, "name"));
150  std::string basisset_name(basisset_name_input.empty() ? "LCAOBSet" : basisset_name_input);
151  if (basisset_map_.find(basisset_name) != basisset_map_.end())
152  {
153  std::ostringstream err_msg;
154  err_msg << "Cannot create basisset " << basisset_name << " which already exists." << std::endl;
155  throw std::runtime_error(err_msg.str());
156  }
157  if (h5_path != "")
158  basisset_map_[basisset_name] = loadBasisSetFromH5(element);
159  else
160  basisset_map_[basisset_name] = loadBasisSetFromXML(element, cur);
161  }
162  });
163 
164  // deprecated h5 basis set handling when basisset element is missing
165  if (basisset_map_.size() == 0 && h5_path != "")
166  {
167  app_warning() << "!!!!!!! Deprecated input style: missing basisset element. "
168  << "LCAO needs an explicit basisset XML element. " << "Fallback on loading an implicit one."
169  << std::endl;
170  basisset_map_["LCAOBSet"] = loadBasisSetFromH5(cur);
171  }
172 
173  if (basisset_map_.size() == 0)
174  throw std::runtime_error("No basisset found in the XML input!");
175 }
ParticleSet & targetPtcl
target ParticleSet
Vector< ValueType, OffloadPinnedAllocator< ValueType > > PeriodicImagePhaseFactors
Periodic Image Phase Factors. Correspond to the phase from the PBCImages. Computed only once...
std::ostream & app_warning()
Definition: OutputManager.h:69
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::string useGPU
Captured gpu input string.
std::unique_ptr< BasisSet_t > loadBasisSetFromXML(xmlNodePtr cur, xmlNodePtr parent)
load a basis set from XML input
SPOSetBuilder(const std::string &type_name, Communicate *comm)
PosType SuperTwist
Coordinates Super Twist.
std::map< std::string, std::unique_ptr< BasisSet_t > > basisset_map_
localized basis set map
Array< RealType, 2, OffloadPinnedAllocator< RealType > > PeriodicImageDisplacements
ParticleSet & sourcePtcl
source ParticleSet
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
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...
std::string h5_path
Path to HDF5 Wavefunction.
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
TinyVector< int, 3 > PBCImages
Number of periodic Images for Orbital evaluation.
std::unique_ptr< BasisSet_t > loadBasisSetFromH5(xmlNodePtr parent)
load a basis set from h5 file
bool doCuspCorrection
Enable cusp correction.
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 EvalPeriodicImagePhaseFactors(PosType SuperTwist, Vector< RealType, OffloadPinnedAllocator< RealType >> &LocPeriodicImagePhaseFactors, Array< RealType, 2, OffloadPinnedAllocator< RealType >> &LocPeriodicImageDisplacements)
Periodic Image Phase Factors computation to be determined.
const std::vector< std::string > candidate_values

◆ ~LCAOrbitalBuilder()

~LCAOrbitalBuilder ( )
override

Definition at line 177 of file LCAOrbitalBuilder.cpp.

178 {
179  //properly cleanup
180 }

Member Function Documentation

◆ createBasisSet()

LCAOrbitalBuilder::BasisSet_t * createBasisSet ( xmlNodePtr  cur)
protected

create basis set

Use ao_traits<T,I,J> to match (ROT)x(SH) combo

process atomicBasisSet per ion species

Definition at line 335 of file LCAOrbitalBuilder.cpp.

References OhmmsAttributeSet::add(), MPIObjectBase::ClassName, AOBasisBuilder< COT >::createAOSet(), ReportEngine::error(), SpeciesSet::findSpecies(), ParticleSet::getSpeciesSet(), MPIObjectBase::myComm, LCAOrbitalBuilder::PBCImages, LCAOrbitalBuilder::PeriodicImageDisplacements, LCAOrbitalBuilder::PeriodicImagePhaseFactors, OhmmsAttributeSet::put(), AOBasisBuilder< COT >::put(), LCAOrbitalBuilder::sourcePtcl, LCAOrbitalBuilder::SuperTwist, and LCAOrbitalBuilder::targetPtcl.

336 {
337  ReportEngine PRE(ClassName, "createBasisSet(xmlNodePtr)");
338 
339  using ao_type = typename ao_traits<RealType, ValueType, I, J>::ao_type;
340  using basis_type = typename ao_traits<RealType, ValueType, I, J>::basis_type;
341 
342  basis_type* mBasisSet = new basis_type(sourcePtcl, targetPtcl);
343 
344  //list of built centers
345  std::vector<std::string> ao_built_centers;
346 
347  /** process atomicBasisSet per ion species */
348  cur = cur->xmlChildrenNode;
349  while (cur != NULL) //loop over unique ioons
350  {
351  std::string cname((const char*)(cur->name));
352 
353  if (cname == "atomicBasisSet")
354  {
355  std::string elementType;
356  std::string sph;
357  OhmmsAttributeSet att;
358  att.add(elementType, "elementType");
359  att.put(cur);
360 
361  if (elementType.empty())
362  PRE.error("Missing elementType attribute of atomicBasisSet.", true);
363 
364  auto it = std::find(ao_built_centers.begin(), ao_built_centers.end(), elementType);
365  if (it == ao_built_centers.end())
366  {
367  AOBasisBuilder<ao_type> any(elementType, myComm);
368  any.put(cur);
369  auto aoBasis = any.createAOSet(cur);
370  if (aoBasis)
371  {
372  //add the new atomic basis to the basis set
373  int activeCenter = sourcePtcl.getSpeciesSet().findSpecies(elementType);
374  mBasisSet->add(activeCenter, std::move(aoBasis));
375  }
376  ao_built_centers.push_back(elementType);
377  }
378  }
379  cur = cur->next;
380  } // done with basis set
381  mBasisSet->setBasisSetSize(-1);
383  return mBasisSet;
384 }
ParticleSet & targetPtcl
target ParticleSet
Vector< ValueType, OffloadPinnedAllocator< ValueType > > PeriodicImagePhaseFactors
Periodic Image Phase Factors. Correspond to the phase from the PBCImages. Computed only once...
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
PosType SuperTwist
Coordinates Super Twist.
Array< RealType, 2, OffloadPinnedAllocator< RealType > > PeriodicImageDisplacements
ParticleSet & sourcePtcl
source 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::string ClassName
class Name
Definition: MPIObjectBase.h:65
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
TinyVector< int, 3 > PBCImages
Number of periodic Images for Orbital evaluation.
int findSpecies(const std::string &name) const
if the input species is not found, add a new species
Definition: SpeciesSet.h:114
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

◆ createBasisSetH5()

LCAOrbitalBuilder::BasisSet_t * createBasisSetH5 ( )
protected

process atomicBasisSet per ion species

Definition at line 388 of file LCAOrbitalBuilder.cpp.

References qmcplusplus::app_log(), Communicate::bcast(), MPIObjectBase::ClassName, hdf_archive::close(), AOBasisBuilder< COT >::createAOSetH5(), ReportEngine::error(), SpeciesSet::findSpecies(), ParticleSet::getSpeciesSet(), LCAOrbitalBuilder::h5_path, MPIObjectBase::myComm, hdf_archive::open(), LCAOrbitalBuilder::PBCImages, LCAOrbitalBuilder::PeriodicImageDisplacements, LCAOrbitalBuilder::PeriodicImagePhaseFactors, hdf_archive::pop(), hdf_archive::push(), AOBasisBuilder< COT >::putH5(), Communicate::rank(), hdf_archive::read(), hdf_archive::readEntry(), LCAOrbitalBuilder::sourcePtcl, LCAOrbitalBuilder::SuperTwist, and LCAOrbitalBuilder::targetPtcl.

389 {
390  ReportEngine PRE(ClassName, "createBasisSetH5(xmlNodePtr)");
391 
392  using ao_type = typename ao_traits<RealType, ValueType, I, J>::ao_type;
393  using basis_type = typename ao_traits<RealType, ValueType, I, J>::basis_type;
394 
395  basis_type* mBasisSet = new basis_type(sourcePtcl, targetPtcl);
396 
397  //list of built centers
398  std::vector<std::string> ao_built_centers;
399 
400  int Nb_Elements(0);
401  std::string basiset_name;
402 
403  /** process atomicBasisSet per ion species */
404  app_log() << "Reading BasisSet from HDF5 file:" << h5_path << std::endl;
405 
406  hdf_archive hin(myComm);
407  if (myComm->rank() == 0)
408  {
409  if (!hin.open(h5_path, H5F_ACC_RDONLY))
410  PRE.error("Could not open H5 file", true);
411 
412  hin.push("basisset", false);
413 
414  hin.read(Nb_Elements, "NbElements");
415  }
416 
417  myComm->bcast(Nb_Elements);
418  if (Nb_Elements < 1)
419  PRE.error("Missing elementType attribute of atomicBasisSet.", true);
420 
421  for (int i = 0; i < Nb_Elements; i++)
422  {
423  std::string elementType, dataset;
424  std::stringstream tempElem;
425  std::string ElemID0 = "atomicBasisSet", ElemType;
426  tempElem << ElemID0 << i;
427  ElemType = tempElem.str();
428 
429  if (myComm->rank() == 0)
430  {
431  hin.push(ElemType.c_str(), false);
432 
433  if (!hin.readEntry(basiset_name, "name"))
434  PRE.error("Could not find name of basisset group in H5; Probably Corrupt H5 file", true);
435  if (!hin.readEntry(elementType, "elementType"))
436  PRE.error("Could not read elementType in H5; Probably Corrupt H5 file", true);
437  }
438  myComm->bcast(basiset_name);
439  myComm->bcast(elementType);
440 
441  auto it = std::find(ao_built_centers.begin(), ao_built_centers.end(), elementType);
442  if (it == ao_built_centers.end())
443  {
444  AOBasisBuilder<ao_type> any(elementType, myComm);
445  any.putH5(hin);
446  auto aoBasis = any.createAOSetH5(hin);
447  if (aoBasis)
448  {
449  //add the new atomic basis to the basis set
450  int activeCenter = sourcePtcl.getSpeciesSet().findSpecies(elementType);
451  mBasisSet->add(activeCenter, std::move(aoBasis));
452  }
453  ao_built_centers.push_back(elementType);
454  }
455 
456  if (myComm->rank() == 0)
457  hin.pop();
458  }
459 
460  if (myComm->rank() == 0)
461  {
462  hin.pop();
463  hin.close();
464  }
465  mBasisSet->setBasisSetSize(-1);
467  return mBasisSet;
468 }
ParticleSet & targetPtcl
target ParticleSet
Vector< ValueType, OffloadPinnedAllocator< ValueType > > PeriodicImagePhaseFactors
Periodic Image Phase Factors. Correspond to the phase from the PBCImages. Computed only once...
int rank() const
return the rank
Definition: Communicate.h:116
std::ostream & app_log()
Definition: OutputManager.h:65
PosType SuperTwist
Coordinates Super Twist.
Array< RealType, 2, OffloadPinnedAllocator< RealType > > PeriodicImageDisplacements
ParticleSet & sourcePtcl
source ParticleSet
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
std::string h5_path
Path to HDF5 Wavefunction.
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
TinyVector< int, 3 > PBCImages
Number of periodic Images for Orbital evaluation.
void bcast(T &)
int findSpecies(const std::string &name) const
if the input species is not found, add a new species
Definition: SpeciesSet.h:114

◆ createSPOSetFromXML()

std::unique_ptr< SPOSet > createSPOSetFromXML ( xmlNodePtr  cur)
overridevirtual

create an sposet from xml (legacy)

Implements SPOSetBuilder.

Reimplemented in LCAOSpinorBuilder.

Definition at line 471 of file LCAOrbitalBuilder.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_log(), qmcplusplus::app_summary(), qmcplusplus::app_warning(), qmcplusplus::applyCuspCorrection(), Communicate::barrier_and_abort(), LCAOrbitalBuilder::basisset_map_, Communicate::bcast(), qmcplusplus::broadcastCuspInfo(), MPIObjectBase::ClassName, DELETED, LCAOrbitalBuilder::doCuspCorrection, file_exists(), qmcplusplus::generateCuspInfo(), SPOSet::getOrbitalSetSize(), ParticleSet::getTotalNum(), LCAOrbitalBuilder::loadMO(), MPIObjectBase::myComm, qmcplusplus::OMPTARGET, processChildren(), OhmmsAttributeSet::put(), Communicate::rank(), qmcplusplus::readCuspInfo(), qmcplusplus::saveCusp(), PlatformSelector< KIND >::selectPlatform(), LCAOrbitalBuilder::sourcePtcl, LCAOrbitalBuilder::targetPtcl, and LCAOrbitalBuilder::useGPU.

Referenced by qmcplusplus::test_LCAO_DiamondC_2x1x1_cplx(), and qmcplusplus::test_LCAO_DiamondC_2x1x1_real().

472 {
473  ReportEngine PRE(ClassName, "createSPO(xmlNodePtr)");
474  std::string spo_name(""), cusp_file(""), optimize("no");
475  std::string basisset_name("LCAOBSet");
476  size_t norbs(0);
477  OhmmsAttributeSet spoAttrib;
478  spoAttrib.add(spo_name, "name");
479  spoAttrib.add(spo_name, "id");
480  spoAttrib.add(cusp_file, "cuspInfo");
481  spoAttrib.add(basisset_name, "basisset");
482  spoAttrib.add(norbs, "size");
483  spoAttrib.add(norbs, "orbitals", {}, TagStatus::DELETED);
484  spoAttrib.put(cur);
485 
487 
488  // look for coefficients element. If found the MO coefficients matrix is not identity
489  bool identity = true;
490  processChildren(cur, [&](const std::string& cname, const xmlNodePtr element) {
491  if (cname.find("coeff") < cname.size() || cname == "parameter" || cname == "Var")
492  identity = false;
493  });
494 
495  std::unique_ptr<BasisSet_t> myBasisSet;
496  if (basisset_map_.find(basisset_name) == basisset_map_.end())
497  myComm->barrier_and_abort("basisset \"" + basisset_name + "\" cannot be found\n");
498  else
499  myBasisSet.reset(basisset_map_[basisset_name]->makeClone());
500 
501  if (norbs == 0)
502  norbs = myBasisSet->getBasisSetSize();
503 
504  std::unique_ptr<SPOSet> sposet;
505  if (doCuspCorrection)
506  {
507 #if defined(QMC_COMPLEX)
509  "LCAOrbitalBuilder::createSPOSetFromXML cusp correction is not supported on complex LCAO.");
510 #else
511  app_summary() << " Using cusp correction." << std::endl;
512  if (useOffload)
513  app_warning() << " LCAO with cusp correction doesn't support OpenMP offload. Running on CPU." << std::endl;
514  auto lcwc = std::make_unique<LCAOrbitalSetWithCorrection>(spo_name, std::move(myBasisSet), norbs, identity,
516  if (!identity)
517  loadMO(lcwc->lcao, cur);
518  sposet = std::move(lcwc);
519 #endif
520  }
521  else
522  {
523  if (useOffload)
524  app_summary() << " Running OpenMP offload code path." << std::endl;
525  else
526  app_summary() << " Running on CPU." << std::endl;
527  auto lcos = std::make_unique<LCAOrbitalSet>(spo_name, std::move(myBasisSet), norbs, identity, useOffload);
528  if (!identity)
529  loadMO(*lcos, cur);
530  sposet = std::move(lcos);
531  }
532 
533 #if !defined(QMC_COMPLEX)
534  if (doCuspCorrection)
535  {
536  // Create a temporary particle set to use for cusp initialization.
537  // The particle coordinates left at the end are unsuitable for further computations.
538  // The coordinates get set to nuclear positions, which leads to zero e-N distance,
539  // which causes a NaN in SoaAtomicBasisSet.h
540  // This problem only appears when the electron positions are specified in the input.
541  // The random particle placement step executes after this part of the code, overwriting
542  // the leftover positions from the cusp initialization.
543  ParticleSet tmp_targetPtcl(targetPtcl);
544 
545  const int num_centers = sourcePtcl.getTotalNum();
546  auto& lcwc = dynamic_cast<LCAOrbitalSetWithCorrection&>(*sposet);
547 
548  const int orbital_set_size = lcwc.getOrbitalSetSize();
549  Matrix<CuspCorrectionParameters> info(num_centers, orbital_set_size);
550 
551  // set a default file name if not given
552  if (cusp_file.empty())
553  cusp_file = spo_name + ".cuspInfo.xml";
554 
555  bool file_exists(myComm->rank() == 0 && std::ifstream(cusp_file).good());
557  app_log() << " Cusp correction file " << cusp_file << (file_exists ? " exits." : " doesn't exist.") << std::endl;
558 
559  // validate file if it exists
560  if (file_exists)
561  {
562  bool valid = 0;
563  if (myComm->rank() == 0)
564  valid = readCuspInfo(cusp_file, spo_name, orbital_set_size, info);
565  myComm->bcast(valid);
566  if (!valid)
567  myComm->barrier_and_abort("Invalid cusp correction file " + cusp_file);
568 #ifdef HAVE_MPI
569  for (int orb_idx = 0; orb_idx < orbital_set_size; orb_idx++)
570  for (int center_idx = 0; center_idx < num_centers; center_idx++)
571  broadcastCuspInfo(info(center_idx, orb_idx), *myComm, 0);
572 #endif
573  }
574  else
575  {
576  generateCuspInfo(info, tmp_targetPtcl, sourcePtcl, lcwc.lcao, spo_name, *myComm);
577  if (myComm->rank() == 0)
578  saveCusp(cusp_file, info, spo_name);
579  }
580 
581  applyCuspCorrection(info, tmp_targetPtcl, sourcePtcl, lcwc.lcao, lcwc.cusp, spo_name);
582  }
583 #endif
584 
585  sposet->finalizeConstruction();
586  return sposet;
587 }
bool loadMO(LCAOrbitalSet &spo, xmlNodePtr cur)
Parse the xml file for information on the Dirac determinants.
bool file_exists(const std::string &name)
ParticleSet & targetPtcl
target ParticleSet
std::ostream & app_warning()
Definition: OutputManager.h:69
int rank() const
return the rank
Definition: Communicate.h:116
size_t getTotalNum() const
Definition: ParticleSet.h:493
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::string useGPU
Captured gpu input string.
void saveCusp(const std::string &filename, const Matrix< CuspCorrectionParameters > &info, const std::string &id)
save cusp correction info to a file.
void broadcastCuspInfo(CuspCorrectionParameters &param, Communicate &Comm, int root)
Broadcast cusp correction parameters.
void applyCuspCorrection(const Matrix< CuspCorrectionParameters > &info, ParticleSet &targetPtcl, ParticleSet &sourcePtcl, LCAOrbitalSet &lcao, SoaCuspCorrection &cusp, const std::string &id)
bool readCuspInfo(const std::string &cuspInfoFile, const std::string &objectName, int OrbitalSetSize, Matrix< CuspCorrectionParameters > &info)
Read cusp correction parameters from XML file.
std::map< std::string, std::unique_ptr< BasisSet_t > > basisset_map_
localized basis set map
ParticleSet & sourcePtcl
source ParticleSet
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
void generateCuspInfo(Matrix< CuspCorrectionParameters > &info, const ParticleSet &targetPtcl, const ParticleSet &sourcePtcl, const LCAOrbitalSet &lcao, const std::string &id, Communicate &Comm)
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
static PlatformKind selectPlatform(std::string_view value)
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
void bcast(T &)
void barrier_and_abort(const std::string &msg) const
bool doCuspCorrection
Enable cusp correction.
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

◆ determineRadialOrbType()

int determineRadialOrbType ( xmlNodePtr  cur) const
private

determine radial orbital type based on "keyword" and "transform" attributes

Definition at line 182 of file LCAOrbitalBuilder.cpp.

References OhmmsAttributeSet::add(), and OhmmsAttributeSet::put().

Referenced by LCAOrbitalBuilder::loadBasisSetFromH5(), and LCAOrbitalBuilder::loadBasisSetFromXML().

183 {
184  std::string keyOpt;
185  std::string transformOpt;
186  OhmmsAttributeSet aAttrib;
187  aAttrib.add(keyOpt, "keyword");
188  aAttrib.add(keyOpt, "key");
189  aAttrib.add(transformOpt, "transform");
190  aAttrib.put(cur);
191 
192  int radialOrbType = -1;
193  if (transformOpt == "yes" || keyOpt == "NMO")
194  radialOrbType = 0;
195  else
196  {
197  if (keyOpt == "GTO")
198  radialOrbType = 1;
199  if (keyOpt == "STO")
200  radialOrbType = 2;
201  }
202  return radialOrbType;
203 }
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
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

◆ EvalPeriodicImagePhaseFactors() [1/2]

void EvalPeriodicImagePhaseFactors ( PosType  SuperTwist,
Vector< RealType, OffloadPinnedAllocator< RealType >> &  LocPeriodicImagePhaseFactors,
Array< RealType, 2, OffloadPinnedAllocator< RealType >> &  LocPeriodicImageDisplacements 
)
protected

Periodic Image Phase Factors computation to be determined.

Exp(ik.g) where i is imaginary, k is the supertwist and g is the translation vector PBCImage.

Definition at line 1005 of file LCAOrbitalBuilder.cpp.

References APP_ABORT, Communicate::bcast(), hdf_archive::close(), LCAOrbitalBuilder::h5_path, LCAOrbitalBuilder::Lattice, MPIObjectBase::myComm, hdf_archive::open(), LCAOrbitalBuilder::PBCImages, hdf_archive::push(), Communicate::rank(), and hdf_archive::read().

Referenced by LCAOrbitalBuilder::LCAOrbitalBuilder().

1009 {
1010  // Allow computation to continue with no HDF file if the system has open boundary conditions.
1011  // The complex build is usually only used with open BC for testing.
1012  bool usesOpenBC = PBCImages[0] == 0 && PBCImages[1] == 0 && PBCImages[2] == 0;
1013 
1014  ///Exp(ik.g) where i is imaginary, k is the supertwist and g is the translation vector PBCImage.
1015  if (h5_path != "" && !usesOpenBC)
1016  {
1017  hdf_archive hin(myComm);
1018  if (myComm->rank() == 0)
1019  {
1020  if (!hin.open(h5_path, H5F_ACC_RDONLY))
1021  APP_ABORT("Could not open H5 file");
1022 
1023  hin.push("Cell", false);
1024 
1025  hin.read(Lattice, "LatticeVectors");
1026  hin.close();
1027  }
1028  for (int i = 0; i < 3; i++)
1029  for (int j = 0; j < 3; j++)
1030  myComm->bcast(Lattice(i, j));
1031  }
1032  else if (!usesOpenBC)
1033  {
1034  APP_ABORT("Attempting to run PBC LCAO with no HDF5 support. Behaviour is unknown. Safer to exit");
1035  }
1036 
1037  const int Nx = PBCImages[0] + 1;
1038  const int Ny = PBCImages[1] + 1;
1039  const int Nz = PBCImages[2] + 1;
1040  const int NbImages = Nx * Ny * Nz;
1041  LocPeriodicImagePhaseFactors.resize(NbImages);
1042  LocPeriodicImageDisplacements.resize(NbImages, 3);
1043  for (size_t ix = 0; ix < Nx; ix++)
1044  for (size_t iy = 0; iy < Ny; iy++)
1045  for (size_t iz = 0; iz < Nz; iz++)
1046  {
1047  const size_t i = iz + Nz * (iy + Ny * ix);
1048  int TransX = ((ix % 2) * 2 - 1) * ((ix + 1) / 2);
1049  int TransY = ((iy % 2) * 2 - 1) * ((iy + 1) / 2);
1050  int TransZ = ((iz % 2) * 2 - 1) * ((iz + 1) / 2);
1051  LocPeriodicImagePhaseFactors[i] = 1.0;
1052  for (size_t idim = 0; idim < 3; idim++)
1053  LocPeriodicImageDisplacements(i, idim) =
1054  TransX * Lattice(0, idim) + TransY * Lattice(1, idim) + TransZ * Lattice(2, idim);
1055  }
1056 }
int rank() const
return the rank
Definition: Communicate.h:116
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
Tensor< double, 3 > Lattice
Store Lattice parameters from HDF5 to use in PeriodicImagePhaseFactors.
std::string h5_path
Path to HDF5 Wavefunction.
TinyVector< int, 3 > PBCImages
Number of periodic Images for Orbital evaluation.
void bcast(T &)

◆ EvalPeriodicImagePhaseFactors() [2/2]

void EvalPeriodicImagePhaseFactors ( PosType  SuperTwist,
Vector< std::complex< RealType >, OffloadPinnedAllocator< std::complex< RealType >>> &  LocPeriodicImagePhaseFactors,
Array< RealType, 2, OffloadPinnedAllocator< RealType >> &  LocPeriodicImageDisplacements 
)
protected

Exp(ik.g) where i is imaginary, k is the supertwist and g is the translation vector PBCImage.

Definition at line 1058 of file LCAOrbitalBuilder.cpp.

References APP_ABORT, Communicate::bcast(), hdf_archive::close(), qmcplusplus::dot(), LCAOrbitalBuilder::h5_path, LCAOrbitalBuilder::Lattice, MPIObjectBase::myComm, hdf_archive::open(), LCAOrbitalBuilder::PBCImages, hdf_archive::push(), Communicate::rank(), hdf_archive::read(), qmcplusplus::Units::time::s, qmcplusplus::sincos(), and LCAOrbitalBuilder::SuperTwist.

1062 {
1063  // Allow computation to continue with no HDF file if the system has open boundary conditions.
1064  // The complex build is usually only used with open BC for testing.
1065  bool usesOpenBC = PBCImages[0] == 0 && PBCImages[1] == 0 && PBCImages[2] == 0;
1066 
1067  ///Exp(ik.g) where i is imaginary, k is the supertwist and g is the translation vector PBCImage.
1068  if (h5_path != "" && !usesOpenBC)
1069  {
1070  hdf_archive hin(myComm);
1071  if (myComm->rank() == 0)
1072  {
1073  if (!hin.open(h5_path, H5F_ACC_RDONLY))
1074  APP_ABORT("Could not open H5 file");
1075 
1076  hin.push("Cell", false);
1077 
1078  hin.read(Lattice, "LatticeVectors");
1079  hin.close();
1080  }
1081  for (int i = 0; i < 3; i++)
1082  for (int j = 0; j < 3; j++)
1083  myComm->bcast(Lattice(i, j));
1084  }
1085  else if (!usesOpenBC)
1086  {
1087  APP_ABORT("Attempting to run PBC LCAO with no HDF5 support. Behaviour is unknown. Safer to exit");
1088  }
1089 
1090  int phase_idx = 0;
1091  int TransX, TransY, TransZ;
1092  RealType phase;
1093  const int Nx = PBCImages[0] + 1;
1094  const int Ny = PBCImages[1] + 1;
1095  const int Nz = PBCImages[2] + 1;
1096  const int NbImages = Nx * Ny * Nz;
1097  LocPeriodicImagePhaseFactors.resize(NbImages);
1098  LocPeriodicImageDisplacements.resize(NbImages, 3);
1099  for (size_t ix = 0; ix < Nx; ix++)
1100  for (size_t iy = 0; iy < Ny; iy++)
1101  for (size_t iz = 0; iz < Nz; iz++)
1102  {
1103  const size_t i = iz + Nz * (iy + Ny * ix);
1104  int TransX = ((ix % 2) * 2 - 1) * ((ix + 1) / 2);
1105  int TransY = ((iy % 2) * 2 - 1) * ((iy + 1) / 2);
1106  int TransZ = ((iz % 2) * 2 - 1) * ((iz + 1) / 2);
1107  RealType s, c;
1108  PosType Val;
1109  for (size_t idim = 0; idim < 3; idim++)
1110  {
1111  Val[idim] = TransX * Lattice(0, idim) + TransY * Lattice(1, idim) + TransZ * Lattice(2, idim);
1112  LocPeriodicImageDisplacements(i, idim) = Val[idim];
1113  }
1114 
1115  phase = dot(SuperTwist, Val);
1116  qmcplusplus::sincos(phase, &s, &c);
1117 
1118  LocPeriodicImagePhaseFactors[i] = std::complex<RealType>(c, s);
1119  }
1120 }
int rank() const
return the rank
Definition: Communicate.h:116
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
QMCTraits::PosType PosType
PosType SuperTwist
Coordinates Super Twist.
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
Tensor< double, 3 > Lattice
Store Lattice parameters from HDF5 to use in PeriodicImagePhaseFactors.
std::string h5_path
Path to HDF5 Wavefunction.
QMCTraits::RealType RealType
TinyVector< int, 3 > PBCImages
Number of periodic Images for Orbital evaluation.
void sincos(T a, T *restrict s, T *restrict c)
sincos function wrapper
Definition: math.hpp:62
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void bcast(T &)

◆ getBasissetMap()

const BasissetMap& getBasissetMap ( ) const
inline

Definition at line 47 of file LCAOrbitalBuilder.h.

References LCAOrbitalBuilder::basisset_map_.

Referenced by qmcplusplus::TEST_CASE().

47 { return basisset_map_; }
std::map< std::string, std::unique_ptr< BasisSet_t > > basisset_map_
localized basis set map

◆ loadBasisSetFromH5()

std::unique_ptr< BasisSet_t > loadBasisSetFromH5 ( xmlNodePtr  parent)
private

load a basis set from h5 file

process atomicBasisSet per ion species

Definition at line 272 of file LCAOrbitalBuilder.cpp.

References qmcplusplus::app_log(), Communicate::bcast(), MPIObjectBase::ClassName, hdf_archive::close(), LCAOrbitalBuilder::determineRadialOrbType(), ReportEngine::error(), LCAOrbitalBuilder::h5_path, MPIObjectBase::myComm, hdf_archive::open(), hdf_archive::push(), Communicate::rank(), and hdf_archive::readEntry().

Referenced by LCAOrbitalBuilder::LCAOrbitalBuilder().

273 {
274  ReportEngine PRE(ClassName, "loadBasisSetFromH5()");
275 
276  hdf_archive hin(myComm);
277  int ylm = -1;
278  if (myComm->rank() == 0)
279  {
280  if (!hin.open(h5_path, H5F_ACC_RDONLY))
281  PRE.error("Could not open H5 file", true);
282 
283  hin.push("basisset", false);
284 
285  std::string sph;
286  std::string ElemID0 = "atomicBasisSet0";
287 
288  hin.push(ElemID0.c_str(), false);
289 
290  if (!hin.readEntry(sph, "angular"))
291  PRE.error("Could not find name of basisset group in H5; Probably Corrupt H5 file", true);
292  ylm = (sph == "cartesian") ? 0 : 1;
293  hin.close();
294  }
295 
296  myComm->bcast(ylm);
297  if (ylm < 0)
298  PRE.error("Missing angular attribute of atomicBasisSet.", true);
299 
300  int radialOrbType = determineRadialOrbType(parent);
301  if (radialOrbType < 0)
302  PRE.error("Unknown radial function for LCAO orbitals. Specify keyword=\"NMO/GTO/STO\" .", true);
303 
304  BasisSet_t* myBasisSet = nullptr;
305  /** process atomicBasisSet per ion species */
306  switch (radialOrbType)
307  {
308  case (0): //numerical
309  app_log() << " LCAO: SoaAtomicBasisSet<MultiQuintic," << ylm << ">" << std::endl;
310  if (ylm)
311  myBasisSet = createBasisSetH5<0, 1>();
312  else
313  myBasisSet = createBasisSetH5<0, 0>();
314  break;
315  case (1): //gto
316  app_log() << " LCAO: SoaAtomicBasisSet<MultiGTO," << ylm << ">" << std::endl;
317  if (ylm)
318  myBasisSet = createBasisSetH5<1, 1>();
319  else
320  myBasisSet = createBasisSetH5<1, 0>();
321  break;
322  case (2): //sto
323  app_log() << " LCAO: SoaAtomicBasisSet<MultiSTO," << ylm << ">" << std::endl;
324  myBasisSet = createBasisSetH5<2, 1>();
325  break;
326  default:
327  PRE.error("Cannot construct SoaAtomicBasisSet<ROT,YLM>.", true);
328  break;
329  }
330  return std::unique_ptr<BasisSet_t>(myBasisSet);
331 }
int rank() const
return the rank
Definition: Communicate.h:116
std::ostream & app_log()
Definition: OutputManager.h:65
int determineRadialOrbType(xmlNodePtr cur) const
determine radial orbital type based on "keyword" and "transform" attributes
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
LCAOrbitalSet::basis_type BasisSet_t
std::string h5_path
Path to HDF5 Wavefunction.
void bcast(T &)

◆ loadBasisSetFromXML()

std::unique_ptr< BasisSet_t > loadBasisSetFromXML ( xmlNodePtr  cur,
xmlNodePtr  parent 
)
private

load a basis set from XML input

process atomicBasisSet per ion species

Definition at line 205 of file LCAOrbitalBuilder.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_log(), qmcplusplus::app_warning(), MPIObjectBase::ClassName, LCAOrbitalBuilder::determineRadialOrbType(), ReportEngine::error(), qmcplusplus::is_same(), and OhmmsAttributeSet::put().

Referenced by LCAOrbitalBuilder::LCAOrbitalBuilder().

206 {
207  ReportEngine PRE(ClassName, "loadBasisSetFromXML(xmlNodePtr)");
208  int ylm = -1;
209  {
210  xmlNodePtr cur1 = cur->xmlChildrenNode;
211  while (cur1 != NULL && ylm < 0)
212  {
213  if (is_same(cur1->name, "atomicBasisSet"))
214  {
215  std::string sph;
216  OhmmsAttributeSet att;
217  att.add(sph, "angular");
218  att.put(cur1);
219  ylm = (sph == "cartesian") ? 0 : 1;
220  }
221  cur1 = cur1->next;
222  }
223  }
224 
225  if (ylm < 0)
226  PRE.error("Missing angular attribute of atomicBasisSet.", true);
227 
228  int radialOrbType = determineRadialOrbType(cur);
229  if (radialOrbType < 0)
230  {
231  app_warning() << "Radial orbital type cannot be determined based on the attributes of basisset line. "
232  << "Trying the parent element." << std::endl;
233  radialOrbType = determineRadialOrbType(parent);
234  }
235 
236  if (radialOrbType < 0)
237  PRE.error("Unknown radial function for LCAO orbitals. Specify keyword=\"NMO/GTO/STO\" .", true);
238 
239  BasisSet_t* myBasisSet = nullptr;
240  /** process atomicBasisSet per ion species */
241  switch (radialOrbType)
242  {
243  case (0): //numerical
244  app_log() << " LCAO: SoaAtomicBasisSet<MultiQuintic," << ylm << ">" << std::endl;
245  if (ylm)
246  myBasisSet = createBasisSet<0, 1>(cur);
247  else
248  myBasisSet = createBasisSet<0, 0>(cur);
249  break;
250  case (1): //gto
251  app_log() << " LCAO: SoaAtomicBasisSet<MultiGTO," << ylm << ">" << std::endl;
252  if (ylm)
253  myBasisSet = createBasisSet<1, 1>(cur);
254  else
255  myBasisSet = createBasisSet<1, 0>(cur);
256  break;
257  case (2): //sto
258  app_log() << " LCAO: SoaAtomicBasisSet<MultiSTO," << ylm << ">" << std::endl;
259  if (ylm)
260  myBasisSet = createBasisSet<2, 1>(cur);
261  else
262  myBasisSet = createBasisSet<2, 0>(cur);
263  break;
264  default:
265  PRE.error("Cannot construct SoaAtomicBasisSet<ROT,YLM>.", true);
266  break;
267  }
268 
269  return std::unique_ptr<BasisSet_t>(myBasisSet);
270 }
std::ostream & app_warning()
Definition: OutputManager.h:69
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
bool is_same(const xmlChar *a, const char *b)
int determineRadialOrbType(xmlNodePtr cur) const
determine radial orbital type based on "keyword" and "transform" attributes
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
LCAOrbitalSet::basis_type BasisSet_t
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

◆ LoadFullCoefsFromH5() [1/2]

void LoadFullCoefsFromH5 ( hdf_archive hin,
int  setVal,
PosType SuperTwist,
Matrix< std::complex< RealType >> &  Ctemp,
bool  MultiDet 
)
protected

When running Single Determinant calculations, MO coeff loaded based on occupation and lowest eingenvalue. However, for solids with multideterminants, orbitals are order by kpoints; first all MOs for kpoint 1, then 2 etc The multideterminants occupation is specified in the input/HDF5 and theefore as long as there is consistency between the order in which we read the orbitals and the occupation, we are safe. In the case of Multideterminants generated by pyscf and Quantum Package, They are stored in the same order as generated for quantum package and one should use the orbitals labelled eigenset_unsorted.

Definition at line 927 of file LCAOrbitalBuilder.cpp.

References Matrix< T, Alloc >::cols(), hdf_archive::read(), LCAOrbitalBuilder::readRealMatrixFromH5(), Matrix< T, Alloc >::resize(), and Matrix< T, Alloc >::rows().

Referenced by LCAOrbitalBuilder::putPBCFromH5().

932 {
933  Matrix<RealType> Creal;
934  Matrix<RealType> Ccmplx;
935 
936  std::array<char, 72> name;
937  int name_len{0};
938  ///When running Single Determinant calculations, MO coeff loaded based on occupation and lowest eingenvalue.
939  ///However, for solids with multideterminants, orbitals are order by kpoints; first all MOs for kpoint 1, then 2 etc
940  /// The multideterminants occupation is specified in the input/HDF5 and theefore as long as there is consistency between
941  /// the order in which we read the orbitals and the occupation, we are safe. In the case of Multideterminants generated
942  /// by pyscf and Quantum Package, They are stored in the same order as generated for quantum package and one should use
943  /// the orbitals labelled eigenset_unsorted.
944 
945  if (MultiDet == false)
946  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_", setVal);
947  else
948  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_unsorted_", setVal);
949  if (name_len < 0)
950  throw std::runtime_error("Error generating name");
951 
952  std::string setname(name.data(), name_len);
953  readRealMatrixFromH5(hin, setname, Creal);
954 
955  bool IsComplex = true;
956  hin.read(IsComplex, "/parameters/IsComplex");
957  if (IsComplex == false)
958  {
959  Ccmplx.resize(Creal.rows(), Creal.cols());
960  Ccmplx = 0.0;
961  }
962  else
963  {
964  setname += "_imag";
965  readRealMatrixFromH5(hin, setname, Ccmplx);
966  }
967 
968  Ctemp.resize(Creal.rows(), Creal.cols());
969  for (int i = 0; i < Ctemp.rows(); i++)
970  for (int j = 0; j < Ctemp.cols(); j++)
971  Ctemp[i][j] = std::complex<RealType>(Creal[i][j], Ccmplx[i][j]);
972 }
std::enable_if_t< IsComplex_t< T >::value, bool > IsComplex
void readRealMatrixFromH5(hdf_archive &hin, const std::string &setname, Matrix< LCAOrbitalBuilder::RealType > &Creal) const
read matrix from h5 file

◆ LoadFullCoefsFromH5() [2/2]

void LoadFullCoefsFromH5 ( hdf_archive hin,
int  setVal,
PosType SuperTwist,
Matrix< RealType > &  Creal,
bool  Multidet 
)
protected

Definition at line 974 of file LCAOrbitalBuilder.cpp.

References qmcplusplus::abs(), APP_ABORT, qmcplusplus::Units::charge::e, hdf_archive::read(), LCAOrbitalBuilder::readRealMatrixFromH5(), and LCAOrbitalBuilder::SuperTwist.

979 {
980  bool IsComplex = false;
981  hin.read(IsComplex, "/parameters/IsComplex");
982  if (IsComplex &&
983  (std::abs(SuperTwist[0]) >= 1e-6 || std::abs(SuperTwist[1]) >= 1e-6 || std::abs(SuperTwist[2]) >= 1e-6))
984  {
985  std::string setname("This Wavefunction is Complex and you are using the real version of QMCPACK. "
986  "Please re-run this job with the Complex build of QMCPACK.");
987  APP_ABORT(setname.c_str());
988  }
989 
990  std::array<char, 72> name;
991  int name_len{0};
992  bool PBC = false;
993  hin.read(PBC, "/PBC/PBC");
994  if (MultiDet && PBC)
995  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_unsorted_", setVal);
996  else
997  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_", setVal);
998  if (name_len < 0)
999  throw std::runtime_error("Error generating name");
1000 
1001  readRealMatrixFromH5(hin, std::string(name.data(), name_len), Creal);
1002 }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::enable_if_t< IsComplex_t< T >::value, bool > IsComplex
PosType SuperTwist
Coordinates Super Twist.
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void readRealMatrixFromH5(hdf_archive &hin, const std::string &setname, Matrix< LCAOrbitalBuilder::RealType > &Creal) const
read matrix from h5 file

◆ loadMO()

bool loadMO ( LCAOrbitalSet spo,
xmlNodePtr  cur 
)
protected

Parse the xml file for information on the Dirac determinants.

Parameters
curthe current xmlNode

Definition at line 593 of file LCAOrbitalBuilder.cpp.

References OhmmsAttributeSet::add(), APP_ABORT, app_debug, qmcplusplus::app_log(), Communicate::bcast(), LCAOrbitalSet::C, hdf_archive::close(), qmcplusplus::Units::charge::e, LCAOrbitalBuilder::h5_path, MPIObjectBase::myComm, hdf_archive::open(), hdf_archive::push(), OhmmsAttributeSet::put(), LCAOrbitalBuilder::putFromH5(), LCAOrbitalBuilder::putFromXML(), LCAOrbitalBuilder::putOccupation(), LCAOrbitalBuilder::putPBCFromH5(), Communicate::rank(), and hdf_archive::read().

Referenced by LCAOrbitalBuilder::createSPOSetFromXML().

594 {
595 #undef FunctionName
596 #define FunctionName \
597  printf("Calling FunctionName from %s\n", __FUNCTION__); \
598  FunctionNameReal
599  //Check if HDF5 present
600  ReportEngine PRE("LCAOrbitalBuilder", "put(xmlNodePtr)");
601 
602  //initialize the number of orbital by the basis set size
603  std::string debugc("no");
604  double orbital_mix_magnitude = 0.0;
605  bool PBC = false;
606  OhmmsAttributeSet aAttrib;
607  aAttrib.add(debugc, "debug");
608  aAttrib.add(orbital_mix_magnitude, "orbital_mix_magnitude");
609  aAttrib.put(cur);
610  xmlNodePtr occ_ptr = NULL;
611  xmlNodePtr coeff_ptr = NULL;
612  cur = cur->xmlChildrenNode;
613  while (cur != NULL)
614  {
615  std::string cname((const char*)(cur->name));
616  if (cname == "occupation")
617  {
618  occ_ptr = cur;
619  }
620  else if (cname.find("coeff") < cname.size() || cname == "parameter" || cname == "Var")
621  {
622  coeff_ptr = cur;
623  }
624  cur = cur->next;
625  }
626  if (coeff_ptr == NULL)
627  {
628  app_log() << " Using Identity for the LCOrbitalSet " << std::endl;
629  return true;
630  }
631  bool success = putOccupation(spo, occ_ptr);
632  if (h5_path == "")
633  success = putFromXML(spo, coeff_ptr);
634  else
635  {
636  hdf_archive hin(myComm);
637 
638  if (myComm->rank() == 0)
639  {
640  if (!hin.open(h5_path, H5F_ACC_RDONLY))
641  APP_ABORT("LCAOrbitalBuilder::putFromH5 missing or incorrect path to H5 file.");
642 
643  try
644  {
645  hin.push("PBC", false);
646  PBC = true;
647  }
648  catch (const std::exception& e)
649  {
650  app_debug() << e.what() << std::endl;
651  PBC = false;
652  }
653 
654  if (PBC)
655  hin.read(PBC, "PBC");
656 
657  hin.close();
658  }
659  myComm->bcast(PBC);
660  if (PBC)
661  success = putPBCFromH5(spo, coeff_ptr);
662  else
663  success = putFromH5(spo, coeff_ptr);
664  }
665 
666  // Ye: used to construct cusp correction
667  //bool success2 = transformSPOSet();
668  if (debugc == "yes")
669  {
670  app_log() << " Single-particle orbital coefficients dims=" << spo.C->rows() << " x " << spo.C->cols()
671  << std::endl;
672  app_log() << *spo.C << std::endl;
673  }
674 
675  return success;
676 }
int rank() const
return the rank
Definition: Communicate.h:116
#define app_debug
Definition: OutputManager.h:75
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
bool putPBCFromH5(LCAOrbitalSet &spo, xmlNodePtr coeff_ptr)
read data from a hdf5 file
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
bool putOccupation(LCAOrbitalSet &spo, xmlNodePtr occ_ptr)
std::string h5_path
Path to HDF5 Wavefunction.
bool putFromXML(LCAOrbitalSet &spo, xmlNodePtr coeff_ptr)
bool putFromH5(LCAOrbitalSet &spo, xmlNodePtr coeff_ptr)
read data from a hdf5 file
void bcast(T &)
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

◆ putFromH5()

bool putFromH5 ( LCAOrbitalSet spo,
xmlNodePtr  coeff_ptr 
)
protected

read data from a hdf5 file

Parameters
norbnumber of orbitals to be initialized
coeff_ptrxmlnode for coefficients

Definition at line 716 of file LCAOrbitalBuilder.cpp.

References OhmmsAttributeSet::add(), APP_ABORT, Communicate::barrier_and_abort(), Communicate::bcast(), LCAOrbitalSet::C, hdf_archive::close(), Matrix< T, Alloc >::cols(), copy(), DELETED, DEPRECATED, LCAOrbitalSet::getBasisSetSize(), SPOSet::getOrbitalSetSize(), LCAOrbitalBuilder::h5_path, MPIObjectBase::myComm, qmcplusplus::n, LCAOrbitalBuilder::Occ, hdf_archive::open(), OhmmsAttributeSet::put(), Communicate::rank(), hdf_archive::read(), hdf_archive::readEntry(), and Matrix< T, Alloc >::rows().

Referenced by LCAOrbitalBuilder::loadMO().

717 {
718  int setVal = -1;
719  int neig;
720  OhmmsAttributeSet aAttrib;
721  aAttrib.add(setVal, "spindataset");
722  aAttrib.add(neig, "size", {}, TagStatus::DEPRECATED);
723  aAttrib.add(neig, "orbitals", {}, TagStatus::DELETED);
724  aAttrib.put(coeff_ptr);
725  hdf_archive hin(myComm);
726  if (myComm->rank() == 0)
727  {
728  if (!hin.open(h5_path, H5F_ACC_RDONLY))
729  APP_ABORT("LCAOrbitalBuilder::putFromH5 missing or incorrect path to H5 file.");
730 
731  Matrix<RealType> Ctemp;
732  std::array<char, 72> name;
733 
734 
735  //This is to make sure of Backward compatibility with previous tags.
736  int name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_", setVal);
737  if (name_len < 0)
738  throw std::runtime_error("Error generating name");
739  std::string setname(name.data(), name_len);
740  if (!hin.readEntry(Ctemp, setname))
741  {
742  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/KPTS_0/eigenset_", setVal);
743  if (name_len < 0)
744  throw std::runtime_error("Error generating name");
745  setname = std::string(name.data(), name_len);
746  hin.read(Ctemp, setname);
747  }
748  hin.close();
749 
750  if (Ctemp.cols() != spo.getBasisSetSize())
751  {
752  std::ostringstream err_msg;
753  err_msg << "Basis set size " << spo.getBasisSetSize() << " mismatched the number of MO coefficients columns "
754  << Ctemp.cols() << " from h5." << std::endl;
755  myComm->barrier_and_abort(err_msg.str());
756  }
757 
758  int norbs = spo.getOrbitalSetSize();
759  if (Ctemp.rows() < norbs)
760  {
761  std::ostringstream err_msg;
762  err_msg << "Need " << norbs << " orbitals. Insufficient rows of MO coefficients " << Ctemp.rows() << " from h5."
763  << std::endl;
764  myComm->barrier_and_abort(err_msg.str());
765  }
766 
767  int n = 0, i = 0;
768  while (i < norbs)
769  {
770  if (Occ[n] > 0.0)
771  {
772  std::copy(Ctemp[n], Ctemp[n + 1], (*spo.C)[i]);
773  i++;
774  }
775  n++;
776  }
777  }
778  myComm->bcast(spo.C->data(), spo.C->size());
779  return true;
780 }
int rank() const
return the rank
Definition: Communicate.h:116
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
Vector< RealType > Occ
occupation number
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::string h5_path
Path to HDF5 Wavefunction.
void bcast(T &)
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

◆ putFromXML()

bool putFromXML ( LCAOrbitalSet spo,
xmlNodePtr  coeff_ptr 
)
protected

Definition at line 678 of file LCAOrbitalBuilder.cpp.

References OhmmsAttributeSet::add(), APP_ABORT, LCAOrbitalSet::C, copy(), DELETED, LCAOrbitalSet::getBasisSetSize(), SPOSet::getOrbitalSetSize(), qmcplusplus::n, LCAOrbitalBuilder::Occ, OhmmsAttributeSet::put(), and putContent().

Referenced by LCAOrbitalBuilder::loadMO().

679 {
680  int norbs = 0;
681  OhmmsAttributeSet aAttrib;
682  aAttrib.add(norbs, "size");
683  aAttrib.add(norbs, "orbitals", {}, TagStatus::DELETED);
684  aAttrib.put(coeff_ptr);
685  if (norbs < spo.getOrbitalSetSize())
686  {
687  return false;
688  APP_ABORT("LCAOrbitalBuilder::putFromXML missing or incorrect size");
689  }
690  if (norbs)
691  {
692  std::vector<ValueType> Ctemp;
693  int BasisSetSize = spo.getBasisSetSize();
694  Ctemp.resize(norbs * BasisSetSize);
695  putContent(Ctemp, coeff_ptr);
696  int n = 0, i = 0;
697  std::vector<ValueType>::iterator cit(Ctemp.begin());
698  while (i < spo.getOrbitalSetSize())
699  {
700  if (Occ[n] > std::numeric_limits<RealType>::epsilon())
701  {
702  std::copy(cit, cit + BasisSetSize, (*spo.C)[i]);
703  i++;
704  }
705  n++;
706  cit += BasisSetSize;
707  }
708  }
709  return true;
710 }
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
Vector< RealType > Occ
occupation number
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
bool putContent(T &a, xmlNodePtr cur)
replaces a&#39;s value with the first "element" in the "string" returned by XMLNodeString{cur}.
Definition: libxmldefs.h:88
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

◆ putOccupation()

bool putOccupation ( LCAOrbitalSet spo,
xmlNodePtr  occ_ptr 
)
protected

Definition at line 877 of file LCAOrbitalBuilder.cpp.

References APP_ABORT, LCAOrbitalSet::getBasisSetSize(), SPOSet::getOrbitalSetSize(), getXMLAttributeValue(), LCAOrbitalBuilder::Occ, putContent(), and Vector< T, Alloc >::resize().

Referenced by LCAOrbitalBuilder::loadMO(), and LCAOSpinorBuilder::putFromH5().

878 {
879  //die??
880  if (spo.getBasisSetSize() == 0)
881  {
882  APP_ABORT("LCAOrbitalBuilder::putOccupation detected ZERO BasisSetSize");
883  return false;
884  }
885  Occ.resize(std::max(spo.getBasisSetSize(), spo.getOrbitalSetSize()));
886  Occ = 0.0;
887  for (int i = 0; i < spo.getOrbitalSetSize(); i++)
888  Occ[i] = 1.0;
889  std::vector<int> occ_in;
890  std::string occ_mode("table");
891  if (occ_ptr == NULL)
892  {
893  occ_mode = "ground";
894  }
895  else
896  {
897  const std::string o(getXMLAttributeValue(occ_ptr, "mode"));
898  if (!o.empty())
899  occ_mode = o;
900  }
901  //Do nothing if mode == ground
902  if (occ_mode == "excited")
903  {
904  putContent(occ_in, occ_ptr);
905  for (int k = 0; k < occ_in.size(); k++)
906  {
907  if (occ_in[k] < 0) //remove this, -1 is to adjust the base
908  Occ[-occ_in[k] - 1] = 0.0;
909  else
910  Occ[occ_in[k] - 1] = 1.0;
911  }
912  }
913  else if (occ_mode == "table")
914  {
915  putContent(Occ, occ_ptr);
916  }
917  return true;
918 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
Vector< RealType > Occ
occupation number
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
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...
bool putContent(T &a, xmlNodePtr cur)
replaces a&#39;s value with the first "element" in the "string" returned by XMLNodeString{cur}.
Definition: libxmldefs.h:88

◆ putPBCFromH5()

bool putPBCFromH5 ( LCAOrbitalSet spo,
xmlNodePtr  coeff_ptr 
)
protected

read data from a hdf5 file

Parameters
norbnumber of orbitals to be initialized
coeff_ptrxmlnode for coefficients

Used to know if running an MSD calculation - needed for order of Orbitals.

Definition at line 787 of file LCAOrbitalBuilder.cpp.

References qmcplusplus::abs(), OhmmsAttributeSet::add(), APP_ABORT, qmcplusplus::app_log(), LCAOrbitalSet::C, hdf_archive::close(), copy(), DELETED, DEPRECATED, qmcplusplus::Units::charge::e, SPOSet::getOrbitalSetSize(), LCAOrbitalBuilder::h5_path, LCAOrbitalBuilder::LoadFullCoefsFromH5(), MPIObjectBase::myComm, qmcplusplus::n, LCAOrbitalBuilder::Occ, hdf_archive::open(), hdf_archive::pop(), hdf_archive::push(), OhmmsAttributeSet::put(), Communicate::rank(), hdf_archive::read(), and LCAOrbitalBuilder::SuperTwist.

Referenced by LCAOrbitalBuilder::loadMO().

788 {
789  ReportEngine PRE("LCAOrbitalBuilder", "LCAOrbitalBuilder::putPBCFromH5");
790  int setVal = -1;
791  int neig;
792  bool IsComplex = false;
793  bool MultiDet = false;
794  PosType SuperTwist(0.0);
795  PosType SuperTwistH5(0.0);
796  OhmmsAttributeSet aAttrib;
797  aAttrib.add(setVal, "spindataset");
798  aAttrib.add(neig, "size", {}, TagStatus::DEPRECATED);
799  aAttrib.add(neig, "orbitals", {}, TagStatus::DELETED);
800  aAttrib.put(coeff_ptr);
801  hdf_archive hin(myComm);
802 
803  xmlNodePtr curtemp = coeff_ptr;
804 
805  std::string xmlTag("determinantset");
806  std::string MSDTag("sposet");
807  std::string SDTag("determinant");
808  std::string EndTag("qmcsystem");
809  std::string curname;
810 
811  do
812  {
813  std::stringstream ss;
814  curtemp = curtemp->parent;
815  ss << curtemp->name;
816  ss >> curname;
817  if (curname == MSDTag)
818  MultiDet = true; ///Used to know if running an MSD calculation - needed for order of Orbitals.
819  if (curname == SDTag)
820  MultiDet = false;
821 
822  } while ((xmlTag != curname) && (curname != EndTag) && curname != "sposet_collection");
823  if (curname == EndTag)
824  {
825  APP_ABORT(
826  "Could not find in wf file the \"sposet\" or \"determinant\" tags. Please verify input or contact developers");
827  }
828 
829  aAttrib.add(SuperTwist, "twist");
830  aAttrib.put(curtemp);
831 
832  if (myComm->rank() == 0)
833  {
834  if (!hin.open(h5_path, H5F_ACC_RDONLY))
835  APP_ABORT("LCAOrbitalBuilder::putFromH5 missing or incorrect path to H5 file.");
836  hin.push("parameters");
837  hin.read(IsComplex, "IsComplex");
838  hin.pop();
839 
840  std::string setname("/Super_Twist/Coord");
841  hin.read(SuperTwistH5, setname);
842  if (std::abs(SuperTwistH5[0] - SuperTwist[0]) >= 1e-6 || std::abs(SuperTwistH5[1] - SuperTwist[1]) >= 1e-6 ||
843  std::abs(SuperTwistH5[2] - SuperTwist[2]) >= 1e-6)
844  {
845  app_log() << "Super Twist in XML : " << SuperTwist[0] << " In H5:" << SuperTwistH5[0] << std::endl;
846  app_log() << " " << SuperTwist[1] << " " << SuperTwistH5[1] << std::endl;
847  app_log() << " " << SuperTwist[2] << " " << SuperTwistH5[2] << std::endl;
848  app_log() << "Diff in Coord x :" << std::abs(SuperTwistH5[0] - SuperTwist[0]) << std::endl;
849  app_log() << " y :" << std::abs(SuperTwistH5[1] - SuperTwist[1]) << std::endl;
850  app_log() << " z :" << std::abs(SuperTwistH5[2] - SuperTwist[2]) << std::endl;
851  APP_ABORT("Requested Super Twist in XML and Super Twist in HDF5 do not Match!!! Aborting.");
852  }
853  //SuperTwist=SuperTwistH5;
854  Matrix<ValueType> Ctemp;
855  LoadFullCoefsFromH5(hin, setVal, SuperTwist, Ctemp, MultiDet);
856 
857  int n = 0, i = 0;
858  while (i < spo.getOrbitalSetSize())
859  {
860  if (Occ[n] > 0.0)
861  {
862  std::copy(Ctemp[n], Ctemp[n + 1], (*spo.C)[i]);
863  i++;
864  }
865  n++;
866  }
867 
868  hin.close();
869  }
870 #ifdef HAVE_MPI
871  myComm->comm.broadcast_n(spo.C->data(), spo.C->size());
872 #endif
873  return true;
874 }
int rank() const
return the rank
Definition: Communicate.h:116
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
void LoadFullCoefsFromH5(hdf_archive &hin, int setVal, PosType &SuperTwist, Matrix< std::complex< RealType >> &Ctemp, bool MultiDet)
Vector< RealType > Occ
occupation number
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
QMCTraits::PosType PosType
std::enable_if_t< IsComplex_t< T >::value, bool > IsComplex
PosType SuperTwist
Coordinates Super Twist.
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::string h5_path
Path to HDF5 Wavefunction.
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

◆ readRealMatrixFromH5()

void readRealMatrixFromH5 ( hdf_archive hin,
const std::string &  setname,
Matrix< LCAOrbitalBuilder::RealType > &  Creal 
) const
protected

read matrix from h5 file

Parameters
[in]hinhdf5 arhive to be read from
setnamewhere to read from in hdf5 archive
[out]Crealmatrix read from h5

added in header to allow use from derived class LCAOSpinorBuilder as well

Definition at line 920 of file LCAOrbitalBuilder.cpp.

References hdf_archive::read().

Referenced by LCAOrbitalBuilder::LoadFullCoefsFromH5(), and LCAOSpinorBuilder::putFromH5().

923 {
924  hin.read(Creal, setname);
925 }

Member Data Documentation

◆ basisset_map_

std::map<std::string, std::unique_ptr<BasisSet_t> > basisset_map_
protected

◆ cuspCorr

bool cuspCorr
protected

if true, add cusp correction to orbitals

Definition at line 57 of file LCAOrbitalBuilder.h.

◆ doCuspCorrection

bool doCuspCorrection
protected

Enable cusp correction.

Definition at line 71 of file LCAOrbitalBuilder.h.

Referenced by LCAOrbitalBuilder::createSPOSetFromXML(), and LCAOrbitalBuilder::LCAOrbitalBuilder().

◆ h5_path

◆ Lattice

Tensor<double, 3> Lattice
protected

Store Lattice parameters from HDF5 to use in PeriodicImagePhaseFactors.

Definition at line 68 of file LCAOrbitalBuilder.h.

Referenced by LCAOrbitalBuilder::EvalPeriodicImagePhaseFactors().

◆ Occ

◆ PBCImages

TinyVector<int, 3> PBCImages
protected

◆ PeriodicImageDisplacements

◆ PeriodicImagePhaseFactors

Vector<ValueType, OffloadPinnedAllocator<ValueType> > PeriodicImagePhaseFactors
protected

Periodic Image Phase Factors. Correspond to the phase from the PBCImages. Computed only once.

Definition at line 65 of file LCAOrbitalBuilder.h.

Referenced by LCAOrbitalBuilder::createBasisSet(), LCAOrbitalBuilder::createBasisSetH5(), and LCAOrbitalBuilder::LCAOrbitalBuilder().

◆ sourcePtcl

◆ SuperTwist

◆ targetPtcl

◆ useGPU

std::string useGPU
protected

Captured gpu input string.

Definition at line 73 of file LCAOrbitalBuilder.h.

Referenced by LCAOrbitalBuilder::createSPOSetFromXML(), and LCAOrbitalBuilder::LCAOrbitalBuilder().


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