QMCPACK
Orbital builder group

Builder classes to add WaveFunctionComponent to a TrialWaveFunction. More...

Classes

class  AGPDeterminantBuilder
 An abstract class for wave function builders. More...
 

Detailed Description

Builder classes to add WaveFunctionComponent to a TrialWaveFunction.

Builder classes to build WaveFunctionComponent.


Class Documentation

◆ qmcplusplus::AGPDeterminantBuilder

class qmcplusplus::AGPDeterminantBuilder

An abstract class for wave function builders.

Definition at line 31 of file AGPDeterminantBuilder.h.

+ Inheritance diagram for AGPDeterminantBuilder:
+ Collaboration diagram for AGPDeterminantBuilder:

Public Member Functions

 AGPDeterminantBuilder (Communicate *comm, ParticleSet &els, const PSetMap &pset)
 
std::unique_ptr< WaveFunctionComponentbuildComponent (xmlNodePtr cur) override
 process a xml node at cur More...
 
- Public Member Functions inherited from WaveFunctionComponentBuilder
 WaveFunctionComponentBuilder (Communicate *comm, ParticleSet &p)
 constructor More...
 
virtual ~WaveFunctionComponentBuilder ()=default
 
- 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<typename BasisBuilderT >
bool createAGP (BasisBuilderT *abuilder, xmlNodePtr cur)
 

Protected Attributes

const PSetMapptclPool
 reference to a PSetMap More...
 
std::unique_ptr< SPOSetBuilderFactorymySPOSetBuilderFactory
 basiset Factory More...
 
std::unique_ptr< AGPDeterminantagpDet
 AGPDeterminant. More...
 
std::string funcOpt
 
std::string transformOpt
 
- Protected Attributes inherited from WaveFunctionComponentBuilder
ParticleSettargetPtcl
 reference to the particle set on which targetPsi is defined More...
 
xmlNodePtr myNode
 xmlNode operated by this object 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...
 

Additional Inherited Members

- Public Types inherited from WaveFunctionComponentBuilder
using RealType = WaveFunctionComponent::RealType
 
using ValueType = WaveFunctionComponent::ValueType
 
using PosType = WaveFunctionComponent::PosType
 
using GradType = WaveFunctionComponent::GradType
 
using PSetMap = std::map< std::string, const std::unique_ptr< ParticleSet > >
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 
- Static Public Attributes inherited from WaveFunctionComponentBuilder
static std::string wfs_tag = "wavefunction"
 reserved tags for the elements associated with the many-body wavefunctions More...
 
static std::string param_tag = "parameter"
 the element name for a parameter More...
 
static std::string dtable_tag = "distancetable"
 the element name for a distancetable More...
 
static std::string jastrow_tag = "jastrow"
 the element name for jatrow More...
 
static std::string detset_tag = "determinantset"
 the element name for a set of Slater determinants, contains 1..* Slater determinants More...
 
static std::string sd_tag = "slaterdeterminant"
 the element name for a Slater determinant, contains 1..* determinants More...
 
static std::string det_tag = "determinant"
 the element name for a determinant, may contain (0..*) orbital or parameter element More...
 
static std::string rn_tag = "determinant_rn"
 the element name for a released node determinant, may contain (0..*) orbital or parameter element More...
 
static std::string spo_tag = "psi"
 the element name for single-particle orbital More...
 
static std::string sposet_tag = "sposet"
 the element name for single-particle orbital set More...
 
static std::string ionorb_tag = "ionwf"
 the element name for an ion wavefunction More...
 
static std::string backflow_tag = "backflow"
 the element name for a backflow transformation More...
 
static std::string multisd_tag = "multideterminant"
 the element name for a multi slater determinant wavefunction More...
 

Constructor & Destructor Documentation

◆ AGPDeterminantBuilder()

AGPDeterminantBuilder ( Communicate comm,
ParticleSet els,
const PSetMap pset 
)

Definition at line 25 of file AGPDeterminantBuilder.cpp.

27 {}
const PSetMap & ptclPool
reference to a PSetMap
WaveFunctionComponentBuilder(Communicate *comm, ParticleSet &p)
constructor

Member Function Documentation

◆ buildComponent()

std::unique_ptr< WaveFunctionComponent > buildComponent ( xmlNodePtr  cur)
overridevirtual

process a xml node at cur

Implements WaveFunctionComponentBuilder.

Definition at line 95 of file AGPDeterminantBuilder.cpp.

References OhmmsAttributeSet::add(), AGPDeterminantBuilder::agpDet, APP_ABORT, qmcplusplus::app_log(), ParticleSet::first(), AGPDeterminantBuilder::funcOpt, getNodeName(), ParticleSet::groups(), MPIObjectBase::myComm, AGPDeterminantBuilder::mySPOSetBuilderFactory, AGPDeterminantBuilder::ptclPool, OhmmsAttributeSet::put(), BasisSetBase< T >::resize(), WaveFunctionComponentBuilder::targetPtcl, and AGPDeterminantBuilder::transformOpt.

96 {
97  if (agpDet)
98  {
99  APP_ABORT(" AGPDeterminantBuilder::put exits. AGPDeterminant has been already created.\n");
100  return std::unique_ptr<AGPDeterminant>();
101  }
102  app_log() << " AGPDeterminantBuilder Creating AGPDeterminant." << std::endl;
103  xmlNodePtr curRoot = cur;
104  bool success = true;
105  std::string tname;
106  xmlNodePtr cPtr = NULL;
107  xmlNodePtr uPtr = NULL;
108  OhmmsAttributeSet oAttrib;
109  oAttrib.add(funcOpt, "function");
110  oAttrib.add(transformOpt, "transform");
111  oAttrib.put(cur);
112  cur = cur->children;
113  while (cur != NULL)
114  {
115  std::string cname(getNodeName(cur));
116  if (cname.find("coeff") < cname.size())
117  {
118  cPtr = cur;
119  }
120  else if (cname.find("un") < cname.size())
121  {
122  uPtr = cur;
123  }
124  cur = cur->next;
125  }
126  if (cPtr == NULL)
127  {
128  std::ostringstream err_msg;
129  err_msg << " AGPDeterminantBuilder::put Cannot create AGPDeterminant." << std::endl
130  << " Missing <coefficients/>" << std::endl;
131  APP_ABORT(err_msg.str());
132  return nullptr;
133  }
135  {
136  mySPOSetBuilderFactory = std::make_unique<SPOSetBuilderFactory>(myComm, targetPtcl, ptclPool);
137  mySPOSetBuilderFactory->createSPOSetBuilder(curRoot);
138  }
139  // mmorales: this needs to be fixed after changes to BasisSetfactory
140  // BasisSetBase<RealType>* myBasisSet=mySPOSetBuilderFactory->getBasisSet();
141  BasisSetBase<RealType>* myBasisSet = 0; //=mySPOSetBuilderFactory->getBasisSet();
142  int nup = targetPtcl.first(1), ndown = 0;
143  if (targetPtcl.groups() > 1)
144  ndown = targetPtcl.first(2) - nup;
145  myBasisSet->resize(nup + ndown);
146  agpDet = std::make_unique<AGPDeterminant>(myBasisSet);
147  agpDet->resize(nup, ndown);
148  //set Lambda: possible to move to AGPDeterminant
149  int offset = 1;
150  xmlNodePtr tcur = cPtr->xmlChildrenNode;
151  while (tcur != NULL)
152  {
153  if (xmlStrEqual(tcur->name, (const xmlChar*)"lambda"))
154  {
155  int i = atoi((const char*)(xmlGetProp(tcur, (const xmlChar*)"i")));
156  int j = atoi((const char*)(xmlGetProp(tcur, (const xmlChar*)"j")));
157  double c = atof((const char*)(xmlGetProp(tcur, (const xmlChar*)"c")));
158  agpDet->Lambda(i - offset, j - offset) = c;
159  if (i != j)
160  {
161  agpDet->Lambda(j - offset, i - offset) = c;
162  }
163  }
164  tcur = tcur->next;
165  }
166  if (uPtr != NULL)
167  {
168  tcur = uPtr->xmlChildrenNode;
169  while (tcur != NULL)
170  {
171  if (xmlStrEqual(tcur->name, (const xmlChar*)"lambda"))
172  {
173  int i = atoi((const char*)(xmlGetProp(tcur, (const xmlChar*)"i")));
174  int j = atoi((const char*)(xmlGetProp(tcur, (const xmlChar*)"j")));
175  double c = atof((const char*)(xmlGetProp(tcur, (const xmlChar*)"c")));
176  agpDet->LambdaUP(j - offset, i - offset) = c;
177  }
178  tcur = tcur->next;
179  }
180  app_log() << " AGPDeterminantBuilder::put Coefficients for the unpaired electrons " << std::endl;
181  app_log() << agpDet->LambdaUP << std::endl;
182  }
183  if (agpDet)
184  return std::move(agpDet);
185 
186  APP_ABORT("failed to create an AGP determinant!\n");
187  return nullptr;
188 }
const PSetMap & ptclPool
reference to a PSetMap
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
ParticleSet & targetPtcl
reference to the particle set on which targetPsi is defined
int groups() const
return the number of groups
Definition: ParticleSet.h:511
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::unique_ptr< AGPDeterminant > agpDet
AGPDeterminant.
std::unique_ptr< SPOSetBuilderFactory > mySPOSetBuilderFactory
basiset Factory
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42
std::string getNodeName(xmlNodePtr cur)
Definition: libxmldefs.cpp:15

◆ createAGP()

bool createAGP ( BasisBuilderT *  abuilder,
xmlNodePtr  cur 
)
protected

Definition at line 30 of file AGPDeterminantBuilder.cpp.

References AGPDeterminantBuilder::agpDet, qmcplusplus::app_log(), castXMLCharToChar(), ParticleSet::first(), ParticleSet::groups(), and WaveFunctionComponentBuilder::targetPtcl.

31 {
32  bool spinpolarized = false;
33  typename BasisBuilderT::BasisSetType* basisSet = 0;
34  cur = cur->xmlChildrenNode;
35  while (cur != NULL)
36  {
37  std::string cname(castXMLCharToChar(cur->name));
38  if (cname == "coefficient" || cname == "coefficients")
39  {
40  if (agpDet == nullptr)
41  {
42  int nup = targetPtcl.first(1), ndown = 0;
43  if (targetPtcl.groups() > 1)
44  ndown = targetPtcl.first(2) - nup;
45  basisSet->resize(nup + ndown);
46  agpDet = std::make_unique<AGPDeterminant>(basisSet);
47  agpDet->resize(nup, ndown);
48  }
49  int offset = 1;
50  xmlNodePtr tcur = cur->xmlChildrenNode;
51  while (tcur != NULL)
52  {
53  if (xmlStrEqual(tcur->name, (const xmlChar*)"lambda"))
54  {
55  int i = atoi((const char*)(xmlGetProp(tcur, (const xmlChar*)"i")));
56  int j = atoi((const char*)(xmlGetProp(tcur, (const xmlChar*)"j")));
57  double c = atof((const char*)(xmlGetProp(tcur, (const xmlChar*)"c")));
58  agpDet->Lambda(i - offset, j - offset) = c;
59  if (i != j)
60  {
61  agpDet->Lambda(j - offset, i - offset) = c;
62  }
63  }
64  tcur = tcur->next;
65  }
66  }
67  else if (cname == "unpaired")
68  {
69  spinpolarized = true;
70  int offset = 1;
71  xmlNodePtr tcur = cur->xmlChildrenNode;
72  while (tcur != NULL)
73  {
74  if (xmlStrEqual(tcur->name, (const xmlChar*)"lambda"))
75  {
76  int i = atoi((const char*)(xmlGetProp(tcur, (const xmlChar*)"i")));
77  int j = atoi((const char*)(xmlGetProp(tcur, (const xmlChar*)"j")));
78  double c = atof((const char*)(xmlGetProp(tcur, (const xmlChar*)"c")));
79  agpDet->LambdaUP(j - offset, i - offset) = c;
80  }
81  tcur = tcur->next;
82  }
83  }
84  cur = cur->next;
85  }
86  //app_log() << agpDet->Lambda << std::endl;
87  if (spinpolarized)
88  {
89  app_log() << " Coefficients for the unpaired electrons " << std::endl;
90  app_log() << agpDet->LambdaUP << std::endl;
91  }
92  return true;
93 }
std::ostream & app_log()
Definition: OutputManager.h:65
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
ParticleSet & targetPtcl
reference to the particle set on which targetPsi is defined
int groups() const
return the number of groups
Definition: ParticleSet.h:511
char * castXMLCharToChar(xmlChar *c)
assign a value from a node. Use specialization for classes.
Definition: libxmldefs.h:62
std::unique_ptr< AGPDeterminant > agpDet
AGPDeterminant.

Member Data Documentation

◆ agpDet

std::unique_ptr<AGPDeterminant> agpDet
protected

◆ funcOpt

std::string funcOpt
protected

Definition at line 46 of file AGPDeterminantBuilder.h.

Referenced by AGPDeterminantBuilder::buildComponent().

◆ mySPOSetBuilderFactory

std::unique_ptr<SPOSetBuilderFactory> mySPOSetBuilderFactory
protected

basiset Factory

Definition at line 43 of file AGPDeterminantBuilder.h.

Referenced by AGPDeterminantBuilder::buildComponent().

◆ ptclPool

const PSetMap& ptclPool
protected

reference to a PSetMap

Definition at line 41 of file AGPDeterminantBuilder.h.

Referenced by AGPDeterminantBuilder::buildComponent().

◆ transformOpt

std::string transformOpt
protected

Definition at line 47 of file AGPDeterminantBuilder.h.

Referenced by AGPDeterminantBuilder::buildComponent().