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

Public Member Functions

 CountingJastrowBuilder (Communicate *comm, ParticleSet &target, ParticleSet &source)
 
 CountingJastrowBuilder (Communicate *comm, ParticleSet &target)
 
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)
 

Private Member Functions

std::unique_ptr< WaveFunctionComponentcreateCJ (xmlNodePtr cur)
 

Private Attributes

std::string NameOpt
 
std::string TypeOpt
 
std::string RegionOpt
 
std::string SourceOpt
 
ParticleSetSourcePtcl
 

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

Detailed Description

Definition at line 19 of file CountingJastrowBuilder.h.

Constructor & Destructor Documentation

◆ CountingJastrowBuilder() [1/2]

CountingJastrowBuilder ( Communicate comm,
ParticleSet target,
ParticleSet source 
)

Definition at line 20 of file CountingJastrowBuilder.cpp.

References MPIObjectBase::ClassName, OhmmsElementBase::getName(), CountingJastrowBuilder::NameOpt, CountingJastrowBuilder::RegionOpt, CountingJastrowBuilder::SourceOpt, CountingJastrowBuilder::SourcePtcl, and CountingJastrowBuilder::TypeOpt.

21  : WaveFunctionComponentBuilder(comm, target), SourcePtcl(&source)
22 {
23  ClassName = "CountingJastrowBuilder";
24  NameOpt = "0";
25  TypeOpt = "Counting";
26  RegionOpt = "voronoi";
28 }
const std::string & getName() const
return the name
WaveFunctionComponentBuilder(Communicate *comm, ParticleSet &p)
constructor
std::string ClassName
class Name
Definition: MPIObjectBase.h:65

◆ CountingJastrowBuilder() [2/2]

Member Function Documentation

◆ buildComponent()

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

process a xml node at cur

Implements WaveFunctionComponentBuilder.

Definition at line 215 of file CountingJastrowBuilder.cpp.

References OhmmsAttributeSet::add(), CountingJastrowBuilder::createCJ(), CountingJastrowBuilder::NameOpt, OhmmsAttributeSet::put(), CountingJastrowBuilder::RegionOpt, and CountingJastrowBuilder::TypeOpt.

Referenced by qmcplusplus::TEST_CASE().

216 {
217  OhmmsAttributeSet oAttrib;
218  oAttrib.add(RegionOpt, "region");
219  oAttrib.add(TypeOpt, "type");
220  oAttrib.add(NameOpt, "name");
221  oAttrib.put(cur);
222  return createCJ(cur);
223 }
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::unique_ptr< WaveFunctionComponent > createCJ(xmlNodePtr cur)
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

◆ createCJ()

std::unique_ptr< WaveFunctionComponent > createCJ ( xmlNodePtr  cur)
private

Definition at line 41 of file CountingJastrowBuilder.cpp.

References OhmmsAttributeSet::add(), APP_ABORT, qmcplusplus::app_log(), qmcplusplus::Units::charge::C, MPIObjectBase::ClassName, ParticleSet::getSpeciesSet(), I, qmcplusplus::Units::energy::J, OhmmsAttributeSet::put(), putContent(), ParticleSet::R, CountingJastrowBuilder::RegionOpt, CountingJastrowBuilder::SourcePtcl, qmcplusplus::sqrt(), and WaveFunctionComponentBuilder::targetPtcl.

Referenced by CountingJastrowBuilder::buildComponent().

42 {
43  ReportEngine PRE(ClassName, "createCJ(xmlNodePtr)");
44  using RegionType = CountingGaussianRegion;
45  using FunctorType = CountingGaussian;
46  using CJOrbitalType = CountingJastrow<RegionType>;
47 
48  SpeciesSet& species(targetPtcl.getSpeciesSet());
49 
50  auto C = std::make_unique<RegionType>(targetPtcl);
51 
52  Matrix<RealType> F;
53  bool opt_C = true, opt_F = true;
54  bool debug_flag = false;
55  int period = 0, seqlen = 0;
56 
57  // standard child loop
58  cur = cur->xmlChildrenNode;
59  while (cur != NULL)
60  {
61  std::string cname((const char*)cur->name);
62  // create counting region, populate with functions
63  if (cname == "region")
64  {
65  // read in opt_C option
66  OhmmsAttributeSet oAttrib;
67  std::string opt = "true";
68  std::string type = RegionOpt;
69  oAttrib.add(opt, "opt");
70  oAttrib.add(type, "type");
71  oAttrib.put(cur);
72  opt_C = (opt == "true" || opt == "yes");
73  // add based on <function /> tags
74  xmlNodePtr cur2 = cur->xmlChildrenNode;
75  if (type == "normalized_gaussian")
76  {
77  while (cur2 != NULL)
78  {
79  std::string cname2((const char*)cur2->name);
80  if (cname2 == "function")
81  {
82  // read id
83  std::string fid;
84  OhmmsAttributeSet oAttrib2;
85  oAttrib2.add(fid, "id");
86  oAttrib2.put(cur2);
87  // get functor, add to function
88  auto func = std::make_unique<FunctorType>(fid);
89  func->put(cur2);
90  C->addFunc(std::move(func), fid);
91  }
92  cur2 = cur2->next;
93  }
94  }
95  // add functions based on source
96  else if (type == "voronoi")
97  {
98  RealType alpha = 1.0;
99  while (cur2 != NULL)
100  {
101  std::string cname2((const char*)cur2->name);
102  if (cname2 == "var")
103  {
104  // read id
105  std::string vname;
106  OhmmsAttributeSet oAttrib2;
107  oAttrib2.add(vname, "name");
108  oAttrib2.put(cur2);
109  if (vname == "alpha")
110  {
111  putContent(alpha, cur2);
112  }
113  }
114  cur2 = cur2->next;
115  }
116  // read in source
117  if (SourcePtcl == NULL)
118  {
119  // quit with error - need a valid source
120  }
121  std::ostringstream os;
122  // add a function for each source particle
123  for (int i = 0; i < SourcePtcl->R.size(); ++i)
124  {
125  PosType gr = SourcePtcl->R[i];
126  bool opt_g = opt_C && (i != 0);
127  os.str("");
128  os << "g" << i;
129  std::string fid = os.str();
130  auto func = std::make_unique<FunctorType>(fid, alpha, gr, opt_g);
131  C->addFunc(std::move(func), fid);
132  }
133  // set default F value to all zeroes with appropriate dimension
134  if (F.size() == 0)
135  {
136  int Fdim = SourcePtcl->R.size();
137  F.resize(Fdim, Fdim);
138  for (int I = 0; I < Fdim; ++I)
139  for (int J = 0; J < Fdim; ++J)
140  F(I, J) = 0;
141  }
142  }
143  // read in the counting region
144  C->put(cur);
145  }
146  if (cname == "var")
147  {
148  OhmmsAttributeSet oAttrib;
149  std::string namestr = "none";
150  oAttrib.add(namestr, "name");
151  oAttrib.put(cur);
152  if (namestr == "F")
153  {
154  // read in opt_F option and form
155  std::string form = "upper_triang";
156  std::string opt = "true";
157  OhmmsAttributeSet rAttrib2;
158  rAttrib2.add(opt, "opt");
159  rAttrib2.add(form, "form");
160  rAttrib2.put(cur);
161  opt_F = (opt == "yes" || opt == "true");
162  // read in F matrix
163  if (form == "upper_triang")
164  {
165  // read in upper triangle, set dimension
166  std::vector<RealType> F_utri;
167  putContent(F_utri, cur);
168  int Fdim = (std::sqrt(8 * F_utri.size() + 1) - 1) / 2;
169 
170  if (!(F_utri.size() == Fdim * (Fdim + 1) / 2))
171  {
172  std::ostringstream err;
173  err << "CountingJastrow::put: F needs to be the upper-triangular component of a square matrix: "
174  << F_utri.size() << " != " << Fdim * (Fdim + 1) / 2 << std::endl;
175  APP_ABORT(err.str());
176  }
177  // set F from upper triangular elements
178  F.resize(Fdim, Fdim);
179  auto it = F_utri.begin();
180  for (int I = 0; I < Fdim; ++I)
181  for (int J = I; J < Fdim; ++J, ++it)
182  F(I, J) = F(J, I) = (*it);
183  }
184  else if (form == "full_matrix")
185  putContent(F, cur);
186 
187  // transform the F matrix to put a zero in the lower-right corner
188 
189  RealType x = F(F.rows() - 1, F.cols() - 1);
190  for (int I = 0; I < F.rows(); ++I)
191  for (int J = 0; J < F.cols(); ++J)
192  F(I, J) -= x;
193  }
194  if (namestr == "debug")
195  {
196  // read in debug options
197  OhmmsAttributeSet rAttrib2;
198  debug_flag = true;
199  rAttrib2.add(period, "period");
200  rAttrib2.add(seqlen, "seqlen");
201  rAttrib2.put(cur);
202  }
203  }
204  cur = cur->next;
205  }
206  auto CJ = std::make_unique<CJOrbitalType>(targetPtcl, std::move(C), F, opt_C, opt_F);
207 
208  CJ->addDebug(debug_flag, seqlen, period);
209  CJ->initialize();
210  CJ->reportStatus(app_log());
211 
212  return CJ;
213 }
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
ParticleSet & targetPtcl
reference to the particle set on which targetPsi is defined
QMCTraits::PosType PosType
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
ParticlePos R
Position.
Definition: ParticleSet.h:79
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
std::complex< double > 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
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
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

Member Data Documentation

◆ NameOpt

std::string NameOpt
private

◆ RegionOpt

◆ SourceOpt

std::string SourceOpt
private

◆ SourcePtcl

◆ TypeOpt

std::string TypeOpt
private

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