QMCPACK
eeI_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 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
10 // Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
11 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
12 //
13 // File created by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 #include "Particle/DistanceTable.h"
18 #include "eeI_JastrowBuilder.h"
22 
23 namespace qmcplusplus
24 {
26  : WaveFunctionComponentBuilder(comm, target), sourcePtcl(&source)
27 {
28  ClassName = "eeI_JastroBuilder";
29 }
30 
31 
32 template<typename J3type>
33 bool eeI_JastrowBuilder::putkids(xmlNodePtr kids, J3type& J3)
34 {
35  auto& jname = J3.getName();
38  //read in xml
39  while (kids != NULL)
40  {
41  std::string kidsname = (char*)kids->name;
42  if (kidsname == "correlation")
43  {
44  RealType ee_cusp = 0.0;
45  RealType eI_cusp = 0.0;
46  std::string iSpecies, eSpecies1("u"), eSpecies2("u");
47  OhmmsAttributeSet rAttrib;
48  rAttrib.add(iSpecies, "ispecies");
49  rAttrib.add(eSpecies1, "especies1");
50  rAttrib.add(eSpecies2, "especies2");
51  rAttrib.add(ee_cusp, "ecusp");
52  rAttrib.add(eI_cusp, "icusp");
53  rAttrib.put(kids);
54  using FT = typename J3type::FuncType;
55  const auto coef_id = extractCoefficientsID(kids);
56  auto functor =
57  std::make_unique<FT>(coef_id.empty() ? jname + "_" + iSpecies + eSpecies1 + eSpecies2 : coef_id, ee_cusp, eI_cusp);
58  functor->iSpecies = iSpecies;
59  functor->eSpecies1 = eSpecies1;
60  functor->eSpecies2 = eSpecies2;
61  int iNum = iSet.findSpecies(iSpecies);
62  int eNum1 = eSet.findSpecies(eSpecies1);
63  int eNum2 = eSet.findSpecies(eSpecies2);
64  if (iNum == iSet.size())
65  {
66  APP_ABORT("ion species " + iSpecies + " requested for Jastrow " + jname + " does not exist in ParticleSet " +
67  sourcePtcl->getName());
68  }
69  std::string illegal_eSpecies;
70  if (eNum1 == eSet.size())
71  illegal_eSpecies = eSpecies1;
72  if (eNum2 == eSet.size())
73  {
74  if (illegal_eSpecies.size())
75  illegal_eSpecies += " and ";
76  illegal_eSpecies += eSpecies2;
77  }
78  if (illegal_eSpecies.size())
79  APP_ABORT("electron species " + illegal_eSpecies + " requested for Jastrow " + jname +
80  " does not exist in ParticleSet " + targetPtcl.getName());
81  functor->put(kids);
82  if (sourcePtcl->getLattice().SuperCellEnum != SUPERCELL_OPEN)
83  {
84  const RealType WSRadius = sourcePtcl->getLattice().WignerSeitzRadius;
85  if (functor->cutoff_radius > WSRadius)
86  {
87  if (functor->cutoff_radius - WSRadius > 1e-4)
88  {
89  APP_ABORT(" The eeI Jastrow cutoff specified should not be larger than Wigner-Seitz radius.");
90  }
91  else
92  {
93  app_log() << " The eeI Jastrow cutoff specified is slightly larger than the Wigner-Seitz radius.";
94  app_log() << " Setting to Wigner-Seitz radius = " << WSRadius << ".\n";
95  functor->cutoff_radius = WSRadius;
96  functor->reset();
97  }
98  }
99  if (functor->cutoff_radius < 1.0e-6)
100  {
101  app_log() << " eeI functor rcut is currently zero.\n"
102  << " Setting to Wigner-Seitz radius = " << WSRadius << std::endl;
103  functor->cutoff_radius = WSRadius;
104  functor->reset();
105  }
106  }
107  else if (functor->cutoff_radius < 1.0e-6)
108  {
109  APP_ABORT(" eeI Jastrow cutoff unspecified. Cutoff must be given when using open boundary conditions");
110  }
111  J3.addFunc(iNum, eNum1, eNum2, std::move(functor));
112  }
113  kids = kids->next;
114  }
115  //check that each ion species has up and down components
116  J3.check_complete();
117  return true;
118 }
119 
120 std::unique_ptr<WaveFunctionComponent> eeI_JastrowBuilder::buildComponent(xmlNodePtr cur)
121 {
122  ReportEngine PRE(ClassName, "put(xmlNodePtr)");
123  xmlNodePtr kids = cur->xmlChildrenNode;
124 
125  // Create a three-body Jastrow
126  if (sourcePtcl)
127  {
128  std::string ftype("polynomial");
129  OhmmsAttributeSet tAttrib;
130  tAttrib.add(ftype, "function");
131  tAttrib.put(cur);
132 
133  std::string input_name(getXMLAttributeValue(cur, "name"));
134  std::string jname = input_name.empty() ? "JeeI_" + ftype : input_name;
136  if (ftype == "polynomial")
137  {
139  auto J3 = std::make_unique<J3Type>(jname, *sourcePtcl, targetPtcl);
140  putkids(kids, *J3);
141  return J3;
142  }
143  else
144  {
145  std::ostringstream err_msg;
146  err_msg << "Unknown function \"" << ftype << "\" in"
147  << " eeI_JastrowBuilder. Aborting.\n";
148  APP_ABORT(err_msg.str());
149  }
150  }
151  else
152  APP_ABORT("You must specify the \"source\" particleset for a three-body Jastrow.\n");
153  return nullptr;
154 }
155 
156 } // namespace qmcplusplus
const std::string & getName() const
return the name
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
An abstract class for wave function builders.
std::ostream & app_log()
Definition: OutputManager.h:65
if(c->rank()==0)
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
eeI_JastrowBuilder(Communicate *comm, ParticleSet &target, ParticleSet &source)
int size() const
return the number of species
Definition: SpeciesSet.h:53
ParticleSet & targetPtcl
reference to the particle set on which targetPsi is defined
Wrapping information on parallelism.
Definition: Communicate.h:68
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
bool putkids(xmlNodePtr kids, J3type &J3)
Final class and should not be derived.
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
declaration of ProgressReportEngine
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::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...
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
const auto & getLattice() const
Definition: ParticleSet.h:251
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
Custom container for set of attributes for a set of species.
Definition: SpeciesSet.h:33
int findSpecies(const std::string &name) const
if the input species is not found, add a new species
Definition: SpeciesSet.h:114
std::string extractCoefficientsID(xmlNodePtr cur)
return the id of the first coefficients. If not found, return an emtpy string
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
Specialization for three-body Jastrow function using multiple functors.