QMCPACK
JastrowBuilder.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
10 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 // Luke Shulenburger, lshulen@sandia.gov, Sandia National Laboratories
12 //
13 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 #include "JastrowBuilder.h"
19 #if OHMMS_DIM == 3
22 #endif
25 #include "OhmmsData/AttributeSet.h"
26 
27 namespace qmcplusplus
28 {
30  : WaveFunctionComponentBuilder(comm, p), ptclPool(psets)
31 {
32  resetOptions();
33  ClassName = "JastrowBuilder";
34 }
35 
37 {
38  JastrowType = 0;
39  nameOpt = "0";
40  typeOpt = "Two";
41  funcOpt = "any";
42  spinOpt = "yes";
43  transformOpt = "no";
45 }
46 
47 std::unique_ptr<WaveFunctionComponent> JastrowBuilder::buildComponent(xmlNodePtr cur)
48 {
49  myNode = cur;
50  resetOptions();
51  OhmmsAttributeSet oAttrib;
52  oAttrib.add(typeOpt, "type");
53  oAttrib.add(nameOpt, "name");
54  oAttrib.add(funcOpt, "function");
55  oAttrib.add(transformOpt, "transform");
56  oAttrib.add(sourceOpt, "source");
57  oAttrib.add(spinOpt, "spin");
58  oAttrib.put(cur);
59  if (nameOpt[0] == '0')
60  {
61  APP_ABORT(" JastrowBuilder::put does not have name!\n");
62  return nullptr;
63  }
64  app_summary() << std::endl;
65  app_summary() << " Jastrow" << std::endl;
66  app_summary() << " -------" << std::endl;
67  app_summary() << " Name: " << nameOpt << " Type: " << typeOpt << " Function: " << funcOpt << std::endl;
68  app_summary() << std::endl;
69 
70  if (typeOpt.find("One") < typeOpt.size())
71  return buildOneBody(cur);
72  else if (typeOpt.find("Two") < typeOpt.size())
73  return buildTwoBody(cur);
74  else if (typeOpt.find("eeI") < typeOpt.size())
75  return build_eeI(cur);
76  else if (typeOpt.find("kSpace") < typeOpt.size())
77  return buildkSpace(cur);
78  else if (typeOpt.find("Counting") < typeOpt.size())
79  return buildCounting(cur);
80  else
81  {
82  APP_ABORT(" JastrowBuilder::buildComponent unknown type!\n");
83  return nullptr;
84  }
85 }
86 
87 std::unique_ptr<WaveFunctionComponent> JastrowBuilder::buildCounting(xmlNodePtr cur)
88 {
89  ReportEngine PRE(ClassName, "addCounting(xmlNodePtr)");
90  std::unique_ptr<CountingJastrowBuilder> cjb;
91  auto pa_it(ptclPool.find(sourceOpt));
92  if (pa_it != ptclPool.end() && sourceOpt != targetPtcl.getName()) // source is not target
93  cjb = std::make_unique<CountingJastrowBuilder>(myComm, targetPtcl, *pa_it->second);
94  else
95  cjb = std::make_unique<CountingJastrowBuilder>(myComm, targetPtcl);
96  return cjb->buildComponent(cur);
97 }
98 
99 std::unique_ptr<WaveFunctionComponent> JastrowBuilder::buildkSpace(xmlNodePtr cur)
100 {
101  app_log() << " JastrowBuilder::buildkSpace(xmlNodePtr)" << std::endl;
102  auto pa_it(ptclPool.find(sourceOpt));
103  if (pa_it == ptclPool.end())
104  {
105  app_warning() << " JastrowBuilder::buildkSpace failed. " << sourceOpt << " does not exist" << std::endl;
106  return nullptr;
107  }
108  app_log() << "\n Using kSpaceJastrowBuilder for reciprocal-space Jastrows" << std::endl;
109  kSpaceJastrowBuilder sBuilder(myComm, targetPtcl, *pa_it->second);
110  return sBuilder.buildComponent(cur);
111 }
112 
113 std::unique_ptr<WaveFunctionComponent> JastrowBuilder::buildOneBody(xmlNodePtr cur)
114 {
115  ReportEngine PRE(ClassName, "addOneBody(xmlNodePtr)");
116  if (sourceOpt == targetPtcl.getName())
117  {
118  PRE.error("One-Body Jastrow Function needs a source different from " + targetPtcl.getName() +
119  "\nExit JastrowBuilder::buildOneBody.\n");
120  return nullptr;
121  }
122  auto pa_it(ptclPool.find(sourceOpt));
123  if (pa_it == ptclPool.end())
124  {
125  PRE.error("JastrowBuilder::buildOneBody failed. " + sourceOpt + " does not exist.");
126  return nullptr;
127  }
128  //use lowercase, to be handled by parser later
129  RadialJastrowBuilder rb(myComm, targetPtcl, *pa_it->second);
130  return rb.buildComponent(cur);
131 }
132 
133 std::unique_ptr<WaveFunctionComponent> JastrowBuilder::build_eeI(xmlNodePtr cur)
134 {
135 #if OHMMS_DIM == 3
136  ReportEngine PRE(ClassName, "add_eeI(xmlNodePtr)");
137  auto pit(ptclPool.find(sourceOpt));
138  if (pit == ptclPool.end())
139  {
140  app_error() << " JastrowBuilder::build_eeI requires a source attribute. " << sourceOpt << " is invalid "
141  << std::endl;
142  APP_ABORT(" JastrowBuilder::build_eeI");
143  return nullptr;
144  }
145  ParticleSet& sourcePtcl = *((*pit).second);
146  eeI_JastrowBuilder jb(myComm, targetPtcl, sourcePtcl);
147  return jb.buildComponent(cur);
148 #else
149  APP_ABORT(" eeI is not valid for OHMMS_DIM != 3 ");
150  return nullptr;
151 #endif
152 }
153 
154 
155 std::unique_ptr<WaveFunctionComponent> JastrowBuilder::buildTwoBody(xmlNodePtr cur)
156 {
157  ReportEngine PRE(ClassName, "addTwoBody(xmlNodePtr)");
159  return rb.buildComponent(cur);
160 }
161 
162 } // namespace qmcplusplus
const std::string & getName() const
return the name
std::ostream & app_warning()
Definition: OutputManager.h:69
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
An abstract class for wave function builders.
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::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
std::unique_ptr< WaveFunctionComponent > buildCounting(xmlNodePtr cur)
build number-counting term
std::ostream & app_error()
Definition: OutputManager.h:67
JastrowBuilder using an analytic 1d functor Should be able to eventually handle all one and two body ...
ParticleSet & targetPtcl
reference to the particle set on which targetPsi is defined
Wrapping information on parallelism.
Definition: Communicate.h:68
std::string spinOpt
<jastrow spin="...">
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
Final class and should not be derived.
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
std::unique_ptr< WaveFunctionComponent > build_eeI(xmlNodePtr cur)
build electron-electron ion term
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
declaration of ProgressReportEngine
std::unique_ptr< WaveFunctionComponent > buildTwoBody(xmlNodePtr cur)
build two-body term
xmlNodePtr myNode
xmlNode operated by this object
std::string sourceOpt
<jastrow source="...">
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::unique_ptr< WaveFunctionComponent > buildOneBody(xmlNodePtr cur)
build one-body term
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
void resetOptions()
reset the options
std::string funcOpt
<jastrow function="...">
const PSetMap & ptclPool
particleset pool to get ParticleSet other than the target
void error(const std::string &msg, bool fatal=false)
std::string transformOpt
<jastrow transform="...">
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
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::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
int JastrowType
index for the jastrow type: 1, 2, 3
std::unique_ptr< WaveFunctionComponent > buildkSpace(xmlNodePtr cur)
build k-Space term
std::string typeOpt
<jastrow type="...">
std::string nameOpt
<jastrow name="...">
JastrowBuilder(Communicate *comm, ParticleSet &p, const PSetMap &psets)