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

Public Member Functions

 eeI_JastrowBuilder (Communicate *comm, ParticleSet &target, ParticleSet &source)
 
std::unique_ptr< WaveFunctionComponent > buildComponent (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...
 
Communicate * getCommunicator () const
 return myComm More...
 
Communicate & getCommRef () 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

ParticleSet * sourcePtcl
 

Private Member Functions

template<typename J3type >
bool putkids (xmlNodePtr kids, J3type &J3)
 

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
ParticleSet & targetPtcl
 reference to the particle set on which targetPsi is defined More...
 
xmlNodePtr myNode
 xmlNode operated by this object More...
 
- Protected Attributes inherited from MPIObjectBase
Communicate * myComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 

Detailed Description

Definition at line 23 of file eeI_JastrowBuilder.h.

Constructor & Destructor Documentation

◆ eeI_JastrowBuilder()

eeI_JastrowBuilder ( Communicate *  comm,
ParticleSet &  target,
ParticleSet &  source 
)

Definition at line 25 of file eeI_JastrowBuilder.cpp.

References MPIObjectBase::ClassName.

26  : WaveFunctionComponentBuilder(comm, target), sourcePtcl(&source)
27 {
28  ClassName = "eeI_JastroBuilder";
29 }
WaveFunctionComponentBuilder(Communicate *comm, ParticleSet &p)
constructor
std::string ClassName
class Name
Definition: MPIObjectBase.h:65

Member Function Documentation

◆ buildComponent()

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

process a xml node at cur

Implements WaveFunctionComponentBuilder.

Definition at line 120 of file eeI_JastrowBuilder.cpp.

References OhmmsAttributeSet::add(), APP_ABORT, MPIObjectBase::ClassName, ParticleSet::getSpeciesSet(), getXMLAttributeValue(), OhmmsAttributeSet::put(), eeI_JastrowBuilder::putkids(), eeI_JastrowBuilder::sourcePtcl, and WaveFunctionComponentBuilder::targetPtcl.

Referenced by JastrowBuilder::build_eeI(), and qmcplusplus::test_J3_polynomial3D().

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;
135  SpeciesSet& iSet = sourcePtcl->getSpeciesSet();
136  if (ftype == "polynomial")
137  {
138  using J3Type = JeeIOrbitalSoA<PolynomialFunctor3D>;
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 }
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
bool putkids(xmlNodePtr kids, J3type &J3)
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
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
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

◆ putkids()

bool putkids ( xmlNodePtr  kids,
J3type &  J3 
)
private

Definition at line 33 of file eeI_JastrowBuilder.cpp.

References OhmmsAttributeSet::add(), APP_ABORT, qmcplusplus::app_log(), qmcplusplus::Units::charge::e, qmcplusplus::extractCoefficientsID(), SpeciesSet::findSpecies(), ParticleSet::getLattice(), OhmmsElementBase::getName(), ParticleSet::getSpeciesSet(), qmcplusplus::if(), OhmmsAttributeSet::put(), SpeciesSet::size(), eeI_JastrowBuilder::sourcePtcl, qmcplusplus::SUPERCELL_OPEN, and WaveFunctionComponentBuilder::targetPtcl.

Referenced by eeI_JastrowBuilder::buildComponent().

34 {
35  auto& jname = J3.getName();
36  SpeciesSet& iSet = sourcePtcl->getSpeciesSet();
37  SpeciesSet& eSet = targetPtcl.getSpeciesSet();
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 }
const std::string & getName() const
return the name
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
ParticleSet & targetPtcl
reference to the particle set on which targetPsi is defined
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
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
QMCTraits::RealType RealType
const auto & getLattice() const
Definition: ParticleSet.h:251
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

Member Data Documentation

◆ sourcePtcl

ParticleSet* sourcePtcl

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