QMCPACK
SPOSetBuilder Class Referenceabstract

base class for the real SPOSet builder More...

+ Inheritance diagram for SPOSetBuilder:
+ Collaboration diagram for SPOSetBuilder:

Public Types

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

 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)
 

Public Attributes

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

Protected Member Functions

virtual std::unique_ptr< SPOSetcreateSPOSetFromXML (xmlNodePtr cur)=0
 create an sposet from xml (legacy) More...
 
virtual std::unique_ptr< SPOSetcreateSPOSet (xmlNodePtr cur, SPOSetInputInfo &input_info)
 create an sposet from a general xml request More...
 

Protected Attributes

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

Detailed Description

base class for the real SPOSet builder

Warning
{ We have not quite figured out how to use real/complex efficiently. There are three cases we have to deal with
  • real basis functions and real coefficients
  • real basis functions and complex coefficients
  • complex basis functions and complex coefficients For now, we decide to keep both real and complex basis sets and expect the user classes { KNOW} what they need to use. }

Definition at line 47 of file SPOSetBuilder.h.

Member Typedef Documentation

◆ energies_t

using energies_t = std::vector<RealType>

Definition at line 51 of file SPOSetBuilder.h.

◆ indices_t

using indices_t = std::vector<int>

Definition at line 50 of file SPOSetBuilder.h.

Constructor & Destructor Documentation

◆ SPOSetBuilder()

SPOSetBuilder ( const std::string &  type_name,
Communicate comm 
)

Definition at line 22 of file SPOSetBuilder.cpp.

References SPOSetBuilder::reserve_states().

23  : MPIObjectBase(comm), legacy(true), type_name_(type_name)
24 {
26 }
const std::string type_name_
type name of the SPO objects built by this builder.
Definition: SPOSetBuilder.h:87
bool legacy
whether implementation conforms only to legacy standard
Definition: SPOSetBuilder.h:54
MPIObjectBase(Communicate *c)
constructor with communicator
void reserve_states(int nsets=1)
reserve space for states (usually only one set, multiple for e.g. spin dependent einspline) ...

◆ ~SPOSetBuilder()

virtual ~SPOSetBuilder ( )
inlinevirtual

Definition at line 60 of file SPOSetBuilder.h.

60 {}

Member Function Documentation

◆ clear_states()

void clear_states ( int  index = 0)
inline

clear state information

Definition at line 69 of file SPOSetBuilder.h.

References SPOSetBuilder::states.

Referenced by BsplineReader::create_spline_set(), and SHOSetBuilder::update_basis_states().

69 { states[index]->clear(); }
std::vector< std::unique_ptr< SPOSetInfo > > states
state info of all possible states available in the basis
Definition: SPOSetBuilder.h:57

◆ createRotatedSPOSet()

std::unique_ptr< SPOSet > createRotatedSPOSet ( xmlNodePtr  cur)

create orbital rotation transformation from xml and save the resulting SPOSet

Definition at line 127 of file SPOSetBuilder.cpp.

References OhmmsAttributeSet::add(), Communicate::barrier_and_abort(), SPOSetBuilder::createSPOSet(), MPIObjectBase::myComm, processChildren(), OhmmsAttributeSet::put(), and putContent().

128 {
129  std::string spo_object_name;
130  std::string method;
131  OhmmsAttributeSet attrib;
132  attrib.add(spo_object_name, "name");
133  attrib.add(method, "method", {"global", "history"});
134  attrib.put(cur);
135 
136  std::unique_ptr<SPOSet> sposet;
137  processChildren(cur, [&](const std::string& cname, const xmlNodePtr element) {
138  if (cname == "sposet")
139  {
140  sposet = createSPOSet(element);
141  }
142  });
143 
144  if (!sposet)
145  myComm->barrier_and_abort("Rotated SPO needs an SPOset");
146 
147  if (!sposet->isRotationSupported())
148  myComm->barrier_and_abort("Orbital rotation not supported with '" + sposet->getName() + "' of type '" +
149  sposet->getClassName() + "'.");
150 
151  sposet->storeParamsBeforeRotation();
152  auto rot_spo = std::make_unique<RotatedSPOs>(spo_object_name, std::move(sposet));
153 
154  if (method == "history")
155  rot_spo->set_use_global_rotation(false);
156 
157  processChildren(cur, [&](const std::string& cname, const xmlNodePtr element) {
158  if (cname == "opt_vars")
159  {
160  std::vector<RealType> params;
161  putContent(params, element);
162  rot_spo->setRotationParameters(params);
163  }
164  });
165  return rot_spo;
166 }
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
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
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
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 barrier_and_abort(const std::string &msg) const
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
std::unique_ptr< SPOSet > createSPOSet(xmlNodePtr cur)
create an sposet from xml and save the resulting SPOSet

◆ createSPOSet() [1/2]

std::unique_ptr< SPOSet > createSPOSet ( xmlNodePtr  cur)

create an sposet from xml and save the resulting SPOSet

Definition at line 45 of file SPOSetBuilder.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_log(), qmcplusplus::app_summary(), qmcplusplus::app_warning(), Communicate::barrier_and_abort(), MPIObjectBase::ClassName, SPOSetBuilder::createSPOSetFromXML(), SPOSetBuilder::legacy, SPOSetInputInfo::legacy_request, MPIObjectBase::myComm, OhmmsAttributeSet::put(), putContent(), and SPOSetBuilder::type_name_.

Referenced by SPOSetBuilder::createRotatedSPOSet(), and qmcplusplus::TEST_CASE().

46 {
47  std::string spo_object_name;
48  std::string optimize("no");
49 
50  OhmmsAttributeSet attrib;
51  attrib.add(spo_object_name, "id");
52  attrib.add(spo_object_name, "name");
53  attrib.add(optimize, "optimize");
54  attrib.put(cur);
55 
56  app_summary() << std::endl;
57  app_summary() << " Single particle orbitals (SPO)" << std::endl;
58  app_summary() << " ------------------------------" << std::endl;
59  app_summary() << " Name: " << spo_object_name << " Type: " << type_name_
60  << " Builder class name: " << ClassName << std::endl;
61  app_summary() << std::endl;
62 
63  if (spo_object_name.empty())
64  myComm->barrier_and_abort("SPOSet object \"name\" attribute not given in the input!");
65 
66  // read specialized sposet construction requests
67  // and translate them into a set of orbital indices
68  SPOSetInputInfo input_info(cur);
69 
70  // process general sposet construction requests
71  // and preserve legacy interface
72  std::unique_ptr<SPOSet> sposet;
73 
74  try
75  {
76  if (legacy && input_info.legacy_request)
77  sposet = createSPOSetFromXML(cur);
78  else
79  sposet = createSPOSet(cur, input_info);
80  }
81  catch (const UniformCommunicateError& ue)
82  {
83  myComm->barrier_and_abort(ue.what());
84  }
85 
86  if (!sposet)
87  myComm->barrier_and_abort("SPOSetBuilder::createSPOSet sposet creation failed");
88 
89  if (optimize == "rotation" || optimize == "yes")
90  {
91  app_warning() << "Specifying orbital rotation via optimize tag is deprecated. Use the rotated_spo element instead"
92  << std::endl;
93 
94  sposet->storeParamsBeforeRotation();
95  // create sposet with rotation
96  auto& sposet_ref = *sposet;
97  app_log() << " SPOSet " << sposet_ref.getName() << " is optimizable\n";
98  if (!sposet_ref.isRotationSupported())
99  myComm->barrier_and_abort("Orbital rotation not supported with '" + sposet_ref.getName() + "' of type '" +
100  sposet_ref.getClassName() + "'.");
101  auto rot_spo = std::make_unique<RotatedSPOs>(sposet_ref.getName(), std::move(sposet));
102  xmlNodePtr tcur = cur->xmlChildrenNode;
103  while (tcur != NULL)
104  {
105  std::string cname((const char*)(tcur->name));
106  if (cname == "opt_vars")
107  {
108  std::vector<RealType> params;
109  putContent(params, tcur);
110  rot_spo->setRotationParameters(params);
111  }
112  tcur = tcur->next;
113  }
114  sposet = std::move(rot_spo);
115  }
116 
117  if (sposet->getName().empty())
118  app_warning() << "SPOSet object doesn't have a name." << std::endl;
119  if (!spo_object_name.empty() && sposet->getName() != spo_object_name)
120  app_warning() << "SPOSet object name mismatched! input name: " << spo_object_name
121  << " object name: " << sposet->getName() << std::endl;
122 
123  sposet->checkObject();
124  return sposet;
125 }
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
const std::string type_name_
type name of the SPO objects built by this builder.
Definition: SPOSetBuilder.h:87
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
bool legacy
whether implementation conforms only to legacy standard
Definition: SPOSetBuilder.h:54
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::ostream & app_warning()
Definition: OutputManager.h:69
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 barrier_and_abort(const std::string &msg) const
std::unique_ptr< SPOSet > createSPOSet(xmlNodePtr cur)
create an sposet from xml and save the resulting SPOSet
virtual std::unique_ptr< SPOSet > createSPOSetFromXML(xmlNodePtr cur)=0
create an sposet from xml (legacy)
std::ostream & app_log()
Definition: OutputManager.h:65
std::ostream & app_summary()
Definition: OutputManager.h:63

◆ createSPOSet() [2/2]

std::unique_ptr< SPOSet > createSPOSet ( xmlNodePtr  cur,
SPOSetInputInfo input_info 
)
protectedvirtual

create an sposet from a general xml request

Reimplemented in EinsplineSetBuilder, CompositeSPOSetBuilder, and SHOSetBuilder.

Definition at line 38 of file SPOSetBuilder.cpp.

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

39 {
40  myComm->barrier_and_abort("BasisSetBase::createSPOSet(cur,input_info) has not been implemented");
41  return 0;
42 }
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
void barrier_and_abort(const std::string &msg) const

◆ createSPOSetFromXML()

virtual std::unique_ptr<SPOSet> createSPOSetFromXML ( xmlNodePtr  cur)
protectedpure virtual

◆ getTypeName()

const std::string& getTypeName ( ) const
inline

Definition at line 77 of file SPOSetBuilder.h.

References SPOSetBuilder::type_name_.

77 { return type_name_; }
const std::string type_name_
type name of the SPO objects built by this builder.
Definition: SPOSetBuilder.h:87

◆ modify_states()

void modify_states ( int  index = 0)
inline

allow modification of state information

Definition at line 66 of file SPOSetBuilder.h.

References SPOSetBuilder::states.

66 { states[index]->modify(); }
std::vector< std::unique_ptr< SPOSetInfo > > states
state info of all possible states available in the basis
Definition: SPOSetBuilder.h:57

◆ reserve_states()

void reserve_states ( int  nsets = 1)

reserve space for states (usually only one set, multiple for e.g. spin dependent einspline)

Definition at line 29 of file SPOSetBuilder.cpp.

References qmcplusplus::Units::time::s, and SPOSetBuilder::states.

Referenced by SPOSetBuilder::SPOSetBuilder().

30 {
31  int sets_needed = nsets - states.size();
32  if (sets_needed > 0)
33  for (int s = 0; s < sets_needed; ++s)
34  states.push_back(std::make_unique<SPOSetInfo>());
35 }
std::vector< std::unique_ptr< SPOSetInfo > > states
state info of all possible states available in the basis
Definition: SPOSetBuilder.h:57

Member Data Documentation

◆ legacy

bool legacy

whether implementation conforms only to legacy standard

Definition at line 54 of file SPOSetBuilder.h.

Referenced by SPOSetBuilder::createSPOSet(), and SHOSetBuilder::SHOSetBuilder().

◆ states

◆ type_name_

const std::string type_name_
protected

type name of the SPO objects built by this builder.

Definition at line 87 of file SPOSetBuilder.h.

Referenced by SPOSetBuilder::createSPOSet(), and SPOSetBuilder::getTypeName().


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