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

Public Member Functions

 kSpaceJastrowBuilder (Communicate *comm, ParticleSet &target, const ParticleSet &source)
 
std::unique_ptr< WaveFunctionComponentbuildComponent (xmlNodePtr cur) override
 process a xml node at cur More...
 
void outputJastrow (kSpaceJastrow *jastrow)
 
- 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)
 

Public Attributes

const ParticleSetsourcePtcl
 
std::map< std::string, kSpaceJastrow::SymmetryTypeSymmMap
 

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 25 of file kSpaceJastrowBuilder.h.

Constructor & Destructor Documentation

◆ kSpaceJastrowBuilder()

kSpaceJastrowBuilder ( Communicate comm,
ParticleSet target,
const ParticleSet source 
)
inline

Member Function Documentation

◆ buildComponent()

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

process a xml node at cur

Implements WaveFunctionComponentBuilder.

Definition at line 40 of file kSpaceJastrowBuilder.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::app_error(), qmcplusplus::app_log(), qmcplusplus::app_warning(), kSpaceJastrow::CRYSTAL, QMCState::io_node, kSpaceJastrowBuilder::outputJastrow(), OhmmsAttributeSet::put(), qmcplusplus::putContent2(), qmcplusplus::qmc_common, kSpaceJastrowBuilder::sourcePtcl, kSpaceJastrowBuilder::SymmMap, and WaveFunctionComponentBuilder::targetPtcl.

Referenced by JastrowBuilder::buildkSpace(), and qmcplusplus::TEST_CASE().

41 {
42  xmlNodePtr kids = cur->xmlChildrenNode;
43  kSpaceJastrow::SymmetryType oneBodySymm, twoBodySymm;
44  RealType kc1, kc2;
45  std::string symm1_opt, symm2_opt, id1_opt, id2_opt, spin1_opt("no"), spin2_opt("no");
46  std::vector<RealType> oneBodyCoefs, twoBodyCoefs;
47  // Initialize options
48  kc1 = kc2 = 0.0;
49  oneBodySymm = twoBodySymm = kSpaceJastrow::CRYSTAL;
50  id1_opt = "cG1";
51  id2_opt = "cG2";
52  while (kids != NULL)
53  {
54  std::string kidsname = (char*)kids->name;
55  std::vector<RealType>* coefs(NULL);
56  std::string* id_opt(NULL);
57  if (kidsname == "correlation")
58  {
59  std::string type_opt;
60  OhmmsAttributeSet attrib;
61  attrib.add(type_opt, "type");
62  attrib.put(kids);
63  if (type_opt == "One-Body")
64  {
65  attrib.add(symm1_opt, "symmetry");
66  attrib.add(kc1, "kc");
67  attrib.add(spin1_opt, "spinDependent");
68  coefs = &oneBodyCoefs;
69  id_opt = &id1_opt;
70  }
71  else if (type_opt == "Two-Body")
72  {
73  attrib.add(symm2_opt, "symmetry");
74  attrib.add(kc2, "kc");
75  attrib.add(spin2_opt, "spinDependent");
76  coefs = &twoBodyCoefs;
77  id_opt = &id2_opt;
78  }
79  else
80  app_warning() << " Unrecognized kSpace type \"" << type_opt
81  << "\" in kSpaceJastrowBuilder::put(xmlNotPtr cur).\n";
82  attrib.put(kids);
83  // Read the coefficients
84  if (coefs)
85  {
86  xmlNodePtr xmlCoefs = kids->xmlChildrenNode;
87  while (xmlCoefs != NULL)
88  {
89  std::string cname((const char*)xmlCoefs->name);
90  if (cname == "coefficients")
91  {
92  std::string type("0"), id("0");
93  OhmmsAttributeSet cAttrib;
94  cAttrib.add(*id_opt, "id");
95  cAttrib.add(type, "type");
96  cAttrib.put(xmlCoefs);
97  if (type != "Array")
98  {
99  app_error() << "Unknown coefficients type "
100  ""
101  << type
102  << ""
103  " in kSpaceJastrowBuilder.\n"
104  << "Resetting to "
105  "Array"
106  ".\n";
107  xmlNewProp(xmlCoefs, (const xmlChar*)"type", (const xmlChar*)"Array");
108  }
109  //vector<T> can be read by this
110  putContent2(*coefs, xmlCoefs);
111  app_log() << " Read " << coefs->size() << " coefficients for type " << type_opt << std::endl;
112  }
113  xmlCoefs = xmlCoefs->next;
114  }
115  }
116  }
117  else if (kidsname != "text")
118  {
119  app_warning() << "Unrecognized section \"" << kidsname << "\" in kSpaceJastrowBuilder.\n";
120  }
121  kids = kids->next;
122  }
123  // Now build the kSpaceJastrow
124  std::map<std::string, kSpaceJastrow::SymmetryType>::iterator symm1 = SymmMap.find(symm1_opt);
125  if (symm1 != SymmMap.end())
126  oneBodySymm = symm1->second;
127  std::map<std::string, kSpaceJastrow::SymmetryType>::iterator symm2 = SymmMap.find(symm2_opt);
128  if (symm2 != SymmMap.end())
129  twoBodySymm = symm2->second;
130  auto jastrow = std::make_unique<kSpaceJastrow>(sourcePtcl, targetPtcl, oneBodySymm, kc1, id1_opt, spin1_opt == "yes",
131  twoBodySymm, kc2, id2_opt, spin2_opt == "yes");
132  jastrow->setCoefficients(oneBodyCoefs, twoBodyCoefs);
133  if (qmc_common.io_node)
134  outputJastrow(jastrow.get());
135  //jastrow->addOptimizables(targetPsi.VarList);
136  return jastrow;
137 }
std::ostream & app_warning()
Definition: OutputManager.h:69
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::ostream & app_error()
Definition: OutputManager.h:67
std::map< std::string, kSpaceJastrow::SymmetryType > SymmMap
ParticleSet & targetPtcl
reference to the particle set on which targetPsi is defined
bool putContent2(std::vector< T > &a, xmlNodePtr cur)
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
bool io_node
true, print out file
Definition: qmc_common.h:39
QMCTraits::RealType RealType
void outputJastrow(kSpaceJastrow *jastrow)
QMCState qmc_common
a unique QMCState during a run
Definition: qmc_common.cpp:111
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

◆ outputJastrow()

void outputJastrow ( kSpaceJastrow jastrow)

Definition at line 140 of file kSpaceJastrowBuilder.cpp.

References MPIObjectBase::getGroupID(), MPIObjectBase::is_manager(), QMCState::mpi_groups, kSpaceJastrow::printOneBody(), kSpaceJastrow::printTwoBody(), and qmcplusplus::qmc_common.

Referenced by kSpaceJastrowBuilder::buildComponent().

141 {
142  std::array<char, 32> fname;
143  int fname_len{0};
144  int taskid = is_manager() ? getGroupID() : -1;
145 
146  // output one-body jastrow
147  if (qmc_common.mpi_groups > 1)
148  fname_len = std::snprintf(fname.data(), fname.size(), "Jk1.g%03d.dat", taskid);
149  else
150  fname_len = std::snprintf(fname.data(), fname.size(), "Jk1.dat");
151  if (fname_len < 0)
152  throw std::runtime_error("Error generating filename");
153 
154  std::ofstream fout(std::string(fname.data(), fname_len));
155  fout << "# kx ky kz coeff_real coeff_imag" << std::endl;
156  jastrow->printOneBody(fout);
157  fout.close();
158 
159  // output two-body jastrow
160  if (qmc_common.mpi_groups > 1)
161  fname_len = std::snprintf(fname.data(), fname.size(), "Jk2.g%03d.dat", taskid);
162  else
163  fname_len = std::snprintf(fname.data(), fname.size(), "Jk2.dat");
164  if (fname_len < 0)
165  throw std::runtime_error("Error generating filename");
166  fout.open(std::string(fname.data(), fname_len));
167  fout << "# kx ky kz coeff_real coeff_imag" << std::endl;
168  jastrow->printTwoBody(fout);
169  fout.close();
170 }
int getGroupID() const
return the group id of the communicator
Definition: MPIObjectBase.h:38
int mpi_groups
number of mpi groups
Definition: qmc_common.h:33
bool is_manager() const
return true if the rank == 0
Definition: MPIObjectBase.h:51
QMCState qmc_common
a unique QMCState during a run
Definition: qmc_common.cpp:111

Member Data Documentation

◆ sourcePtcl

const ParticleSet& sourcePtcl

Definition at line 28 of file kSpaceJastrowBuilder.h.

Referenced by kSpaceJastrowBuilder::buildComponent().

◆ SymmMap


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