QMCPACK
LCAOrbitalBuilder.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: Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
10 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 // Ye Luo, yeluo@anl.gov, Argonne National Laboratory
12 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
13 //
14 // File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp.
15 //////////////////////////////////////////////////////////////////////////////////////
16 
17 
18 #include "LCAOrbitalBuilder.h"
19 #include <PlatformSelector.hpp>
20 #include "OhmmsData/AttributeSet.h"
22 #include "MultiQuinticSpline1D.h"
25 #include "SoaAtomicBasisSet.h"
26 #include "SoaLocalizedBasisSet.h"
27 #include "LCAOrbitalSet.h"
28 #include "AOBasisBuilder.h"
29 #include "MultiFunctorAdapter.h"
30 #if !defined(QMC_COMPLEX)
33 #endif
34 #include "hdf/hdf_archive.h"
35 #include "Message/CommOperators.h"
37 #include "CPU/math.hpp"
38 
39 #include <array>
40 
41 namespace qmcplusplus
42 {
43 /** traits for a localized basis set; used by createBasisSet
44  *
45  * T radial function value type
46  * ORBT orbital value type, can be complex
47  * ROT {0=numuerica;, 1=gto; 2=sto}
48  * SH {0=cartesian, 1=spherical}
49  * If too confusing, inroduce enumeration.
50  */
51 template<typename T, typename ORBT, int ROT, int SH>
52 struct ao_traits
53 {};
54 
55 /** specialization for numerical-cartesian AO */
56 template<typename T, typename ORBT>
57 struct ao_traits<T, ORBT, 0, 0>
58 {
63 };
64 
65 /** specialization for numerical-spherical AO */
66 template<typename T, typename ORBT>
67 struct ao_traits<T, ORBT, 0, 1>
68 {
73 };
74 
75 /** specialization for GTO-cartesian AO */
76 template<typename T, typename ORBT>
77 struct ao_traits<T, ORBT, 1, 0>
78 {
83 };
84 
85 /** specialization for GTO-cartesian AO */
86 template<typename T, typename ORBT>
87 struct ao_traits<T, ORBT, 1, 1>
88 {
93 };
94 
95 /** specialization for STO-spherical AO */
96 template<typename T, typename ORBT>
97 struct ao_traits<T, ORBT, 2, 1>
98 {
103 };
104 
105 /** specialization for STO-cartesian AO */
106 template<typename T, typename ORBT>
107 struct ao_traits<T, ORBT, 2, 0>
108 {
113 };
114 
115 
116 inline bool is_same(const xmlChar* a, const char* b) { return !strcmp((const char*)a, b); }
117 
119 
121  : SPOSetBuilder("LCAO", comm),
122  targetPtcl(els),
123  sourcePtcl(ions),
124  h5_path(""),
125  SuperTwist(0.0),
126  doCuspCorrection(false)
127 {
128  ClassName = "LCAOrbitalBuilder";
129  ReportEngine PRE(ClassName, "createBasisSet");
130 
131  std::string cuspC("no"); // cusp correction
132  OhmmsAttributeSet aAttrib;
133  aAttrib.add(cuspC, "cuspCorrection");
134  aAttrib.add(h5_path, "href");
135  aAttrib.add(PBCImages, "PBCimages");
136  aAttrib.add(SuperTwist, "twist");
138  aAttrib.put(cur);
139 
140  if (cuspC == "yes")
141  doCuspCorrection = true;
142  //Evaluate the Phase factor. Equals 1 for OBC.
144 
145  // no need to wait but load the basis set
146  processChildren(cur, [&](const std::string& cname, const xmlNodePtr element) {
147  if (cname == "basisset")
148  {
149  std::string basisset_name_input(getXMLAttributeValue(element, "name"));
150  std::string basisset_name(basisset_name_input.empty() ? "LCAOBSet" : basisset_name_input);
151  if (basisset_map_.find(basisset_name) != basisset_map_.end())
152  {
153  std::ostringstream err_msg;
154  err_msg << "Cannot create basisset " << basisset_name << " which already exists." << std::endl;
155  throw std::runtime_error(err_msg.str());
156  }
157  if (h5_path != "")
158  basisset_map_[basisset_name] = loadBasisSetFromH5(element);
159  else
160  basisset_map_[basisset_name] = loadBasisSetFromXML(element, cur);
161  }
162  });
163 
164  // deprecated h5 basis set handling when basisset element is missing
165  if (basisset_map_.size() == 0 && h5_path != "")
166  {
167  app_warning() << "!!!!!!! Deprecated input style: missing basisset element. "
168  << "LCAO needs an explicit basisset XML element. " << "Fallback on loading an implicit one."
169  << std::endl;
170  basisset_map_["LCAOBSet"] = loadBasisSetFromH5(cur);
171  }
172 
173  if (basisset_map_.size() == 0)
174  throw std::runtime_error("No basisset found in the XML input!");
175 }
176 
178 {
179  //properly cleanup
180 }
181 
183 {
184  std::string keyOpt;
185  std::string transformOpt;
186  OhmmsAttributeSet aAttrib;
187  aAttrib.add(keyOpt, "keyword");
188  aAttrib.add(keyOpt, "key");
189  aAttrib.add(transformOpt, "transform");
190  aAttrib.put(cur);
191 
192  int radialOrbType = -1;
193  if (transformOpt == "yes" || keyOpt == "NMO")
194  radialOrbType = 0;
195  else
196  {
197  if (keyOpt == "GTO")
198  radialOrbType = 1;
199  if (keyOpt == "STO")
200  radialOrbType = 2;
201  }
202  return radialOrbType;
203 }
204 
205 std::unique_ptr<BasisSet_t> LCAOrbitalBuilder::loadBasisSetFromXML(xmlNodePtr cur, xmlNodePtr parent)
206 {
207  ReportEngine PRE(ClassName, "loadBasisSetFromXML(xmlNodePtr)");
208  int ylm = -1;
209  {
210  xmlNodePtr cur1 = cur->xmlChildrenNode;
211  while (cur1 != NULL && ylm < 0)
212  {
213  if (is_same(cur1->name, "atomicBasisSet"))
214  {
215  std::string sph;
216  OhmmsAttributeSet att;
217  att.add(sph, "angular");
218  att.put(cur1);
219  ylm = (sph == "cartesian") ? 0 : 1;
220  }
221  cur1 = cur1->next;
222  }
223  }
224 
225  if (ylm < 0)
226  PRE.error("Missing angular attribute of atomicBasisSet.", true);
227 
228  int radialOrbType = determineRadialOrbType(cur);
229  if (radialOrbType < 0)
230  {
231  app_warning() << "Radial orbital type cannot be determined based on the attributes of basisset line. "
232  << "Trying the parent element." << std::endl;
233  radialOrbType = determineRadialOrbType(parent);
234  }
235 
236  if (radialOrbType < 0)
237  PRE.error("Unknown radial function for LCAO orbitals. Specify keyword=\"NMO/GTO/STO\" .", true);
238 
239  BasisSet_t* myBasisSet = nullptr;
240  /** process atomicBasisSet per ion species */
241  switch (radialOrbType)
242  {
243  case (0): //numerical
244  app_log() << " LCAO: SoaAtomicBasisSet<MultiQuintic," << ylm << ">" << std::endl;
245  if (ylm)
246  myBasisSet = createBasisSet<0, 1>(cur);
247  else
248  myBasisSet = createBasisSet<0, 0>(cur);
249  break;
250  case (1): //gto
251  app_log() << " LCAO: SoaAtomicBasisSet<MultiGTO," << ylm << ">" << std::endl;
252  if (ylm)
253  myBasisSet = createBasisSet<1, 1>(cur);
254  else
255  myBasisSet = createBasisSet<1, 0>(cur);
256  break;
257  case (2): //sto
258  app_log() << " LCAO: SoaAtomicBasisSet<MultiSTO," << ylm << ">" << std::endl;
259  if (ylm)
260  myBasisSet = createBasisSet<2, 1>(cur);
261  else
262  myBasisSet = createBasisSet<2, 0>(cur);
263  break;
264  default:
265  PRE.error("Cannot construct SoaAtomicBasisSet<ROT,YLM>.", true);
266  break;
267  }
268 
269  return std::unique_ptr<BasisSet_t>(myBasisSet);
270 }
271 
272 std::unique_ptr<BasisSet_t> LCAOrbitalBuilder::loadBasisSetFromH5(xmlNodePtr parent)
273 {
274  ReportEngine PRE(ClassName, "loadBasisSetFromH5()");
275 
276  hdf_archive hin(myComm);
277  int ylm = -1;
278  if (myComm->rank() == 0)
279  {
280  if (!hin.open(h5_path, H5F_ACC_RDONLY))
281  PRE.error("Could not open H5 file", true);
282 
283  hin.push("basisset", false);
284 
285  std::string sph;
286  std::string ElemID0 = "atomicBasisSet0";
287 
288  hin.push(ElemID0.c_str(), false);
289 
290  if (!hin.readEntry(sph, "angular"))
291  PRE.error("Could not find name of basisset group in H5; Probably Corrupt H5 file", true);
292  ylm = (sph == "cartesian") ? 0 : 1;
293  hin.close();
294  }
295 
296  myComm->bcast(ylm);
297  if (ylm < 0)
298  PRE.error("Missing angular attribute of atomicBasisSet.", true);
299 
300  int radialOrbType = determineRadialOrbType(parent);
301  if (radialOrbType < 0)
302  PRE.error("Unknown radial function for LCAO orbitals. Specify keyword=\"NMO/GTO/STO\" .", true);
303 
304  BasisSet_t* myBasisSet = nullptr;
305  /** process atomicBasisSet per ion species */
306  switch (radialOrbType)
307  {
308  case (0): //numerical
309  app_log() << " LCAO: SoaAtomicBasisSet<MultiQuintic," << ylm << ">" << std::endl;
310  if (ylm)
311  myBasisSet = createBasisSetH5<0, 1>();
312  else
313  myBasisSet = createBasisSetH5<0, 0>();
314  break;
315  case (1): //gto
316  app_log() << " LCAO: SoaAtomicBasisSet<MultiGTO," << ylm << ">" << std::endl;
317  if (ylm)
318  myBasisSet = createBasisSetH5<1, 1>();
319  else
320  myBasisSet = createBasisSetH5<1, 0>();
321  break;
322  case (2): //sto
323  app_log() << " LCAO: SoaAtomicBasisSet<MultiSTO," << ylm << ">" << std::endl;
324  myBasisSet = createBasisSetH5<2, 1>();
325  break;
326  default:
327  PRE.error("Cannot construct SoaAtomicBasisSet<ROT,YLM>.", true);
328  break;
329  }
330  return std::unique_ptr<BasisSet_t>(myBasisSet);
331 }
332 
333 
334 template<int I, int J>
336 {
337  ReportEngine PRE(ClassName, "createBasisSet(xmlNodePtr)");
338 
339  using ao_type = typename ao_traits<RealType, ValueType, I, J>::ao_type;
340  using basis_type = typename ao_traits<RealType, ValueType, I, J>::basis_type;
341 
342  basis_type* mBasisSet = new basis_type(sourcePtcl, targetPtcl);
343 
344  //list of built centers
345  std::vector<std::string> ao_built_centers;
346 
347  /** process atomicBasisSet per ion species */
348  cur = cur->xmlChildrenNode;
349  while (cur != NULL) //loop over unique ioons
350  {
351  std::string cname((const char*)(cur->name));
352 
353  if (cname == "atomicBasisSet")
354  {
355  std::string elementType;
356  std::string sph;
357  OhmmsAttributeSet att;
358  att.add(elementType, "elementType");
359  att.put(cur);
360 
361  if (elementType.empty())
362  PRE.error("Missing elementType attribute of atomicBasisSet.", true);
363 
364  auto it = std::find(ao_built_centers.begin(), ao_built_centers.end(), elementType);
365  if (it == ao_built_centers.end())
366  {
367  AOBasisBuilder<ao_type> any(elementType, myComm);
368  any.put(cur);
369  auto aoBasis = any.createAOSet(cur);
370  if (aoBasis)
371  {
372  //add the new atomic basis to the basis set
373  int activeCenter = sourcePtcl.getSpeciesSet().findSpecies(elementType);
374  mBasisSet->add(activeCenter, std::move(aoBasis));
375  }
376  ao_built_centers.push_back(elementType);
377  }
378  }
379  cur = cur->next;
380  } // done with basis set
381  mBasisSet->setBasisSetSize(-1);
383  return mBasisSet;
384 }
385 
386 
387 template<int I, int J>
389 {
390  ReportEngine PRE(ClassName, "createBasisSetH5(xmlNodePtr)");
391 
392  using ao_type = typename ao_traits<RealType, ValueType, I, J>::ao_type;
393  using basis_type = typename ao_traits<RealType, ValueType, I, J>::basis_type;
394 
395  basis_type* mBasisSet = new basis_type(sourcePtcl, targetPtcl);
396 
397  //list of built centers
398  std::vector<std::string> ao_built_centers;
399 
400  int Nb_Elements(0);
401  std::string basiset_name;
402 
403  /** process atomicBasisSet per ion species */
404  app_log() << "Reading BasisSet from HDF5 file:" << h5_path << std::endl;
405 
406  hdf_archive hin(myComm);
407  if (myComm->rank() == 0)
408  {
409  if (!hin.open(h5_path, H5F_ACC_RDONLY))
410  PRE.error("Could not open H5 file", true);
411 
412  hin.push("basisset", false);
413 
414  hin.read(Nb_Elements, "NbElements");
415  }
416 
417  myComm->bcast(Nb_Elements);
418  if (Nb_Elements < 1)
419  PRE.error("Missing elementType attribute of atomicBasisSet.", true);
420 
421  for (int i = 0; i < Nb_Elements; i++)
422  {
423  std::string elementType, dataset;
424  std::stringstream tempElem;
425  std::string ElemID0 = "atomicBasisSet", ElemType;
426  tempElem << ElemID0 << i;
427  ElemType = tempElem.str();
428 
429  if (myComm->rank() == 0)
430  {
431  hin.push(ElemType.c_str(), false);
432 
433  if (!hin.readEntry(basiset_name, "name"))
434  PRE.error("Could not find name of basisset group in H5; Probably Corrupt H5 file", true);
435  if (!hin.readEntry(elementType, "elementType"))
436  PRE.error("Could not read elementType in H5; Probably Corrupt H5 file", true);
437  }
438  myComm->bcast(basiset_name);
439  myComm->bcast(elementType);
440 
441  auto it = std::find(ao_built_centers.begin(), ao_built_centers.end(), elementType);
442  if (it == ao_built_centers.end())
443  {
444  AOBasisBuilder<ao_type> any(elementType, myComm);
445  any.putH5(hin);
446  auto aoBasis = any.createAOSetH5(hin);
447  if (aoBasis)
448  {
449  //add the new atomic basis to the basis set
450  int activeCenter = sourcePtcl.getSpeciesSet().findSpecies(elementType);
451  mBasisSet->add(activeCenter, std::move(aoBasis));
452  }
453  ao_built_centers.push_back(elementType);
454  }
455 
456  if (myComm->rank() == 0)
457  hin.pop();
458  }
459 
460  if (myComm->rank() == 0)
461  {
462  hin.pop();
463  hin.close();
464  }
465  mBasisSet->setBasisSetSize(-1);
467  return mBasisSet;
468 }
469 
470 
471 std::unique_ptr<SPOSet> LCAOrbitalBuilder::createSPOSetFromXML(xmlNodePtr cur)
472 {
473  ReportEngine PRE(ClassName, "createSPO(xmlNodePtr)");
474  std::string spo_name(""), cusp_file(""), optimize("no");
475  std::string basisset_name("LCAOBSet");
476  size_t norbs(0);
477  OhmmsAttributeSet spoAttrib;
478  spoAttrib.add(spo_name, "name");
479  spoAttrib.add(spo_name, "id");
480  spoAttrib.add(cusp_file, "cuspInfo");
481  spoAttrib.add(basisset_name, "basisset");
482  spoAttrib.add(norbs, "size");
483  spoAttrib.add(norbs, "orbitals", {}, TagStatus::DELETED);
484  spoAttrib.put(cur);
485 
487 
488  // look for coefficients element. If found the MO coefficients matrix is not identity
489  bool identity = true;
490  processChildren(cur, [&](const std::string& cname, const xmlNodePtr element) {
491  if (cname.find("coeff") < cname.size() || cname == "parameter" || cname == "Var")
492  identity = false;
493  });
494 
495  std::unique_ptr<BasisSet_t> myBasisSet;
496  if (basisset_map_.find(basisset_name) == basisset_map_.end())
497  myComm->barrier_and_abort("basisset \"" + basisset_name + "\" cannot be found\n");
498  else
499  myBasisSet.reset(basisset_map_[basisset_name]->makeClone());
500 
501  if (norbs == 0)
502  norbs = myBasisSet->getBasisSetSize();
503 
504  std::unique_ptr<SPOSet> sposet;
505  if (doCuspCorrection)
506  {
507 #if defined(QMC_COMPLEX)
509  "LCAOrbitalBuilder::createSPOSetFromXML cusp correction is not supported on complex LCAO.");
510 #else
511  app_summary() << " Using cusp correction." << std::endl;
512  if (useOffload)
513  app_warning() << " LCAO with cusp correction doesn't support OpenMP offload. Running on CPU." << std::endl;
514  auto lcwc = std::make_unique<LCAOrbitalSetWithCorrection>(spo_name, std::move(myBasisSet), norbs, identity,
516  if (!identity)
517  loadMO(lcwc->lcao, cur);
518  sposet = std::move(lcwc);
519 #endif
520  }
521  else
522  {
523  if (useOffload)
524  app_summary() << " Running OpenMP offload code path." << std::endl;
525  else
526  app_summary() << " Running on CPU." << std::endl;
527  auto lcos = std::make_unique<LCAOrbitalSet>(spo_name, std::move(myBasisSet), norbs, identity, useOffload);
528  if (!identity)
529  loadMO(*lcos, cur);
530  sposet = std::move(lcos);
531  }
532 
533 #if !defined(QMC_COMPLEX)
534  if (doCuspCorrection)
535  {
536  // Create a temporary particle set to use for cusp initialization.
537  // The particle coordinates left at the end are unsuitable for further computations.
538  // The coordinates get set to nuclear positions, which leads to zero e-N distance,
539  // which causes a NaN in SoaAtomicBasisSet.h
540  // This problem only appears when the electron positions are specified in the input.
541  // The random particle placement step executes after this part of the code, overwriting
542  // the leftover positions from the cusp initialization.
543  ParticleSet tmp_targetPtcl(targetPtcl);
544 
545  const int num_centers = sourcePtcl.getTotalNum();
546  auto& lcwc = dynamic_cast<LCAOrbitalSetWithCorrection&>(*sposet);
547 
548  const int orbital_set_size = lcwc.getOrbitalSetSize();
549  Matrix<CuspCorrectionParameters> info(num_centers, orbital_set_size);
550 
551  // set a default file name if not given
552  if (cusp_file.empty())
553  cusp_file = spo_name + ".cuspInfo.xml";
554 
555  bool file_exists(myComm->rank() == 0 && std::ifstream(cusp_file).good());
557  app_log() << " Cusp correction file " << cusp_file << (file_exists ? " exits." : " doesn't exist.") << std::endl;
558 
559  // validate file if it exists
560  if (file_exists)
561  {
562  bool valid = 0;
563  if (myComm->rank() == 0)
564  valid = readCuspInfo(cusp_file, spo_name, orbital_set_size, info);
565  myComm->bcast(valid);
566  if (!valid)
567  myComm->barrier_and_abort("Invalid cusp correction file " + cusp_file);
568 #ifdef HAVE_MPI
569  for (int orb_idx = 0; orb_idx < orbital_set_size; orb_idx++)
570  for (int center_idx = 0; center_idx < num_centers; center_idx++)
571  broadcastCuspInfo(info(center_idx, orb_idx), *myComm, 0);
572 #endif
573  }
574  else
575  {
576  generateCuspInfo(info, tmp_targetPtcl, sourcePtcl, lcwc.lcao, spo_name, *myComm);
577  if (myComm->rank() == 0)
578  saveCusp(cusp_file, info, spo_name);
579  }
580 
581  applyCuspCorrection(info, tmp_targetPtcl, sourcePtcl, lcwc.lcao, lcwc.cusp, spo_name);
582  }
583 #endif
584 
585  sposet->finalizeConstruction();
586  return sposet;
587 }
588 
589 
590 /** Parse the xml file for information on the Dirac determinants.
591  *@param cur the current xmlNode
592  */
593 bool LCAOrbitalBuilder::loadMO(LCAOrbitalSet& spo, xmlNodePtr cur)
594 {
595 #undef FunctionName
596 #define FunctionName \
597  printf("Calling FunctionName from %s\n", __FUNCTION__); \
598  FunctionNameReal
599  //Check if HDF5 present
600  ReportEngine PRE("LCAOrbitalBuilder", "put(xmlNodePtr)");
601 
602  //initialize the number of orbital by the basis set size
603  std::string debugc("no");
604  double orbital_mix_magnitude = 0.0;
605  bool PBC = false;
606  OhmmsAttributeSet aAttrib;
607  aAttrib.add(debugc, "debug");
608  aAttrib.add(orbital_mix_magnitude, "orbital_mix_magnitude");
609  aAttrib.put(cur);
610  xmlNodePtr occ_ptr = NULL;
611  xmlNodePtr coeff_ptr = NULL;
612  cur = cur->xmlChildrenNode;
613  while (cur != NULL)
614  {
615  std::string cname((const char*)(cur->name));
616  if (cname == "occupation")
617  {
618  occ_ptr = cur;
619  }
620  else if (cname.find("coeff") < cname.size() || cname == "parameter" || cname == "Var")
621  {
622  coeff_ptr = cur;
623  }
624  cur = cur->next;
625  }
626  if (coeff_ptr == NULL)
627  {
628  app_log() << " Using Identity for the LCOrbitalSet " << std::endl;
629  return true;
630  }
631  bool success = putOccupation(spo, occ_ptr);
632  if (h5_path == "")
633  success = putFromXML(spo, coeff_ptr);
634  else
635  {
636  hdf_archive hin(myComm);
637 
638  if (myComm->rank() == 0)
639  {
640  if (!hin.open(h5_path, H5F_ACC_RDONLY))
641  APP_ABORT("LCAOrbitalBuilder::putFromH5 missing or incorrect path to H5 file.");
642 
643  try
644  {
645  hin.push("PBC", false);
646  PBC = true;
647  }
648  catch (const std::exception& e)
649  {
650  app_debug() << e.what() << std::endl;
651  PBC = false;
652  }
653 
654  if (PBC)
655  hin.read(PBC, "PBC");
656 
657  hin.close();
658  }
659  myComm->bcast(PBC);
660  if (PBC)
661  success = putPBCFromH5(spo, coeff_ptr);
662  else
663  success = putFromH5(spo, coeff_ptr);
664  }
665 
666  // Ye: used to construct cusp correction
667  //bool success2 = transformSPOSet();
668  if (debugc == "yes")
669  {
670  app_log() << " Single-particle orbital coefficients dims=" << spo.C->rows() << " x " << spo.C->cols()
671  << std::endl;
672  app_log() << *spo.C << std::endl;
673  }
674 
675  return success;
676 }
677 
678 bool LCAOrbitalBuilder::putFromXML(LCAOrbitalSet& spo, xmlNodePtr coeff_ptr)
679 {
680  int norbs = 0;
681  OhmmsAttributeSet aAttrib;
682  aAttrib.add(norbs, "size");
683  aAttrib.add(norbs, "orbitals", {}, TagStatus::DELETED);
684  aAttrib.put(coeff_ptr);
685  if (norbs < spo.getOrbitalSetSize())
686  {
687  return false;
688  APP_ABORT("LCAOrbitalBuilder::putFromXML missing or incorrect size");
689  }
690  if (norbs)
691  {
692  std::vector<ValueType> Ctemp;
693  int BasisSetSize = spo.getBasisSetSize();
694  Ctemp.resize(norbs * BasisSetSize);
695  putContent(Ctemp, coeff_ptr);
696  int n = 0, i = 0;
697  std::vector<ValueType>::iterator cit(Ctemp.begin());
698  while (i < spo.getOrbitalSetSize())
699  {
700  if (Occ[n] > std::numeric_limits<RealType>::epsilon())
701  {
702  std::copy(cit, cit + BasisSetSize, (*spo.C)[i]);
703  i++;
704  }
705  n++;
706  cit += BasisSetSize;
707  }
708  }
709  return true;
710 }
711 
712 /** read data from a hdf5 file
713  * @param norb number of orbitals to be initialized
714  * @param coeff_ptr xmlnode for coefficients
715  */
716 bool LCAOrbitalBuilder::putFromH5(LCAOrbitalSet& spo, xmlNodePtr coeff_ptr)
717 {
718  int setVal = -1;
719  int neig;
720  OhmmsAttributeSet aAttrib;
721  aAttrib.add(setVal, "spindataset");
722  aAttrib.add(neig, "size", {}, TagStatus::DEPRECATED);
723  aAttrib.add(neig, "orbitals", {}, TagStatus::DELETED);
724  aAttrib.put(coeff_ptr);
725  hdf_archive hin(myComm);
726  if (myComm->rank() == 0)
727  {
728  if (!hin.open(h5_path, H5F_ACC_RDONLY))
729  APP_ABORT("LCAOrbitalBuilder::putFromH5 missing or incorrect path to H5 file.");
730 
731  Matrix<RealType> Ctemp;
732  std::array<char, 72> name;
733 
734 
735  //This is to make sure of Backward compatibility with previous tags.
736  int name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_", setVal);
737  if (name_len < 0)
738  throw std::runtime_error("Error generating name");
739  std::string setname(name.data(), name_len);
740  if (!hin.readEntry(Ctemp, setname))
741  {
742  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/KPTS_0/eigenset_", setVal);
743  if (name_len < 0)
744  throw std::runtime_error("Error generating name");
745  setname = std::string(name.data(), name_len);
746  hin.read(Ctemp, setname);
747  }
748  hin.close();
749 
750  if (Ctemp.cols() != spo.getBasisSetSize())
751  {
752  std::ostringstream err_msg;
753  err_msg << "Basis set size " << spo.getBasisSetSize() << " mismatched the number of MO coefficients columns "
754  << Ctemp.cols() << " from h5." << std::endl;
755  myComm->barrier_and_abort(err_msg.str());
756  }
757 
758  int norbs = spo.getOrbitalSetSize();
759  if (Ctemp.rows() < norbs)
760  {
761  std::ostringstream err_msg;
762  err_msg << "Need " << norbs << " orbitals. Insufficient rows of MO coefficients " << Ctemp.rows() << " from h5."
763  << std::endl;
764  myComm->barrier_and_abort(err_msg.str());
765  }
766 
767  int n = 0, i = 0;
768  while (i < norbs)
769  {
770  if (Occ[n] > 0.0)
771  {
772  std::copy(Ctemp[n], Ctemp[n + 1], (*spo.C)[i]);
773  i++;
774  }
775  n++;
776  }
777  }
778  myComm->bcast(spo.C->data(), spo.C->size());
779  return true;
780 }
781 
782 
783 /** read data from a hdf5 file
784  * @param norb number of orbitals to be initialized
785  * @param coeff_ptr xmlnode for coefficients
786  */
787 bool LCAOrbitalBuilder::putPBCFromH5(LCAOrbitalSet& spo, xmlNodePtr coeff_ptr)
788 {
789  ReportEngine PRE("LCAOrbitalBuilder", "LCAOrbitalBuilder::putPBCFromH5");
790  int setVal = -1;
791  int neig;
792  bool IsComplex = false;
793  bool MultiDet = false;
794  PosType SuperTwist(0.0);
795  PosType SuperTwistH5(0.0);
796  OhmmsAttributeSet aAttrib;
797  aAttrib.add(setVal, "spindataset");
798  aAttrib.add(neig, "size", {}, TagStatus::DEPRECATED);
799  aAttrib.add(neig, "orbitals", {}, TagStatus::DELETED);
800  aAttrib.put(coeff_ptr);
801  hdf_archive hin(myComm);
802 
803  xmlNodePtr curtemp = coeff_ptr;
804 
805  std::string xmlTag("determinantset");
806  std::string MSDTag("sposet");
807  std::string SDTag("determinant");
808  std::string EndTag("qmcsystem");
809  std::string curname;
810 
811  do
812  {
813  std::stringstream ss;
814  curtemp = curtemp->parent;
815  ss << curtemp->name;
816  ss >> curname;
817  if (curname == MSDTag)
818  MultiDet = true; ///Used to know if running an MSD calculation - needed for order of Orbitals.
819  if (curname == SDTag)
820  MultiDet = false;
821 
822  } while ((xmlTag != curname) && (curname != EndTag) && curname != "sposet_collection");
823  if (curname == EndTag)
824  {
825  APP_ABORT(
826  "Could not find in wf file the \"sposet\" or \"determinant\" tags. Please verify input or contact developers");
827  }
828 
829  aAttrib.add(SuperTwist, "twist");
830  aAttrib.put(curtemp);
831 
832  if (myComm->rank() == 0)
833  {
834  if (!hin.open(h5_path, H5F_ACC_RDONLY))
835  APP_ABORT("LCAOrbitalBuilder::putFromH5 missing or incorrect path to H5 file.");
836  hin.push("parameters");
837  hin.read(IsComplex, "IsComplex");
838  hin.pop();
839 
840  std::string setname("/Super_Twist/Coord");
841  hin.read(SuperTwistH5, setname);
842  if (std::abs(SuperTwistH5[0] - SuperTwist[0]) >= 1e-6 || std::abs(SuperTwistH5[1] - SuperTwist[1]) >= 1e-6 ||
843  std::abs(SuperTwistH5[2] - SuperTwist[2]) >= 1e-6)
844  {
845  app_log() << "Super Twist in XML : " << SuperTwist[0] << " In H5:" << SuperTwistH5[0] << std::endl;
846  app_log() << " " << SuperTwist[1] << " " << SuperTwistH5[1] << std::endl;
847  app_log() << " " << SuperTwist[2] << " " << SuperTwistH5[2] << std::endl;
848  app_log() << "Diff in Coord x :" << std::abs(SuperTwistH5[0] - SuperTwist[0]) << std::endl;
849  app_log() << " y :" << std::abs(SuperTwistH5[1] - SuperTwist[1]) << std::endl;
850  app_log() << " z :" << std::abs(SuperTwistH5[2] - SuperTwist[2]) << std::endl;
851  APP_ABORT("Requested Super Twist in XML and Super Twist in HDF5 do not Match!!! Aborting.");
852  }
853  //SuperTwist=SuperTwistH5;
854  Matrix<ValueType> Ctemp;
855  LoadFullCoefsFromH5(hin, setVal, SuperTwist, Ctemp, MultiDet);
856 
857  int n = 0, i = 0;
858  while (i < spo.getOrbitalSetSize())
859  {
860  if (Occ[n] > 0.0)
861  {
862  std::copy(Ctemp[n], Ctemp[n + 1], (*spo.C)[i]);
863  i++;
864  }
865  n++;
866  }
867 
868  hin.close();
869  }
870 #ifdef HAVE_MPI
871  myComm->comm.broadcast_n(spo.C->data(), spo.C->size());
872 #endif
873  return true;
874 }
875 
876 
877 bool LCAOrbitalBuilder::putOccupation(LCAOrbitalSet& spo, xmlNodePtr occ_ptr)
878 {
879  //die??
880  if (spo.getBasisSetSize() == 0)
881  {
882  APP_ABORT("LCAOrbitalBuilder::putOccupation detected ZERO BasisSetSize");
883  return false;
884  }
885  Occ.resize(std::max(spo.getBasisSetSize(), spo.getOrbitalSetSize()));
886  Occ = 0.0;
887  for (int i = 0; i < spo.getOrbitalSetSize(); i++)
888  Occ[i] = 1.0;
889  std::vector<int> occ_in;
890  std::string occ_mode("table");
891  if (occ_ptr == NULL)
892  {
893  occ_mode = "ground";
894  }
895  else
896  {
897  const std::string o(getXMLAttributeValue(occ_ptr, "mode"));
898  if (!o.empty())
899  occ_mode = o;
900  }
901  //Do nothing if mode == ground
902  if (occ_mode == "excited")
903  {
904  putContent(occ_in, occ_ptr);
905  for (int k = 0; k < occ_in.size(); k++)
906  {
907  if (occ_in[k] < 0) //remove this, -1 is to adjust the base
908  Occ[-occ_in[k] - 1] = 0.0;
909  else
910  Occ[occ_in[k] - 1] = 1.0;
911  }
912  }
913  else if (occ_mode == "table")
914  {
915  putContent(Occ, occ_ptr);
916  }
917  return true;
918 }
919 
921  const std::string& setname,
923 {
924  hin.read(Creal, setname);
925 }
926 
928  int setVal,
929  PosType& SuperTwist,
930  Matrix<std::complex<RealType>>& Ctemp,
931  bool MultiDet)
932 {
933  Matrix<RealType> Creal;
934  Matrix<RealType> Ccmplx;
935 
936  std::array<char, 72> name;
937  int name_len{0};
938  ///When running Single Determinant calculations, MO coeff loaded based on occupation and lowest eingenvalue.
939  ///However, for solids with multideterminants, orbitals are order by kpoints; first all MOs for kpoint 1, then 2 etc
940  /// The multideterminants occupation is specified in the input/HDF5 and theefore as long as there is consistency between
941  /// the order in which we read the orbitals and the occupation, we are safe. In the case of Multideterminants generated
942  /// by pyscf and Quantum Package, They are stored in the same order as generated for quantum package and one should use
943  /// the orbitals labelled eigenset_unsorted.
944 
945  if (MultiDet == false)
946  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_", setVal);
947  else
948  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_unsorted_", setVal);
949  if (name_len < 0)
950  throw std::runtime_error("Error generating name");
951 
952  std::string setname(name.data(), name_len);
953  readRealMatrixFromH5(hin, setname, Creal);
954 
955  bool IsComplex = true;
956  hin.read(IsComplex, "/parameters/IsComplex");
957  if (IsComplex == false)
958  {
959  Ccmplx.resize(Creal.rows(), Creal.cols());
960  Ccmplx = 0.0;
961  }
962  else
963  {
964  setname += "_imag";
965  readRealMatrixFromH5(hin, setname, Ccmplx);
966  }
967 
968  Ctemp.resize(Creal.rows(), Creal.cols());
969  for (int i = 0; i < Ctemp.rows(); i++)
970  for (int j = 0; j < Ctemp.cols(); j++)
971  Ctemp[i][j] = std::complex<RealType>(Creal[i][j], Ccmplx[i][j]);
972 }
973 
975  int setVal,
976  PosType& SuperTwist,
977  Matrix<RealType>& Creal,
978  bool MultiDet)
979 {
980  bool IsComplex = false;
981  hin.read(IsComplex, "/parameters/IsComplex");
982  if (IsComplex &&
983  (std::abs(SuperTwist[0]) >= 1e-6 || std::abs(SuperTwist[1]) >= 1e-6 || std::abs(SuperTwist[2]) >= 1e-6))
984  {
985  std::string setname("This Wavefunction is Complex and you are using the real version of QMCPACK. "
986  "Please re-run this job with the Complex build of QMCPACK.");
987  APP_ABORT(setname.c_str());
988  }
989 
990  std::array<char, 72> name;
991  int name_len{0};
992  bool PBC = false;
993  hin.read(PBC, "/PBC/PBC");
994  if (MultiDet && PBC)
995  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_unsorted_", setVal);
996  else
997  name_len = std::snprintf(name.data(), name.size(), "%s%d", "/Super_Twist/eigenset_", setVal);
998  if (name_len < 0)
999  throw std::runtime_error("Error generating name");
1000 
1001  readRealMatrixFromH5(hin, std::string(name.data(), name_len), Creal);
1002 }
1003 
1004 /// Periodic Image Phase Factors computation to be determined
1006  PosType SuperTwist,
1007  Vector<RealType, OffloadPinnedAllocator<RealType>>& LocPeriodicImagePhaseFactors,
1008  Array<RealType, 2, OffloadPinnedAllocator<RealType>>& LocPeriodicImageDisplacements)
1009 {
1010  // Allow computation to continue with no HDF file if the system has open boundary conditions.
1011  // The complex build is usually only used with open BC for testing.
1012  bool usesOpenBC = PBCImages[0] == 0 && PBCImages[1] == 0 && PBCImages[2] == 0;
1013 
1014  ///Exp(ik.g) where i is imaginary, k is the supertwist and g is the translation vector PBCImage.
1015  if (h5_path != "" && !usesOpenBC)
1016  {
1017  hdf_archive hin(myComm);
1018  if (myComm->rank() == 0)
1019  {
1020  if (!hin.open(h5_path, H5F_ACC_RDONLY))
1021  APP_ABORT("Could not open H5 file");
1022 
1023  hin.push("Cell", false);
1024 
1025  hin.read(Lattice, "LatticeVectors");
1026  hin.close();
1027  }
1028  for (int i = 0; i < 3; i++)
1029  for (int j = 0; j < 3; j++)
1030  myComm->bcast(Lattice(i, j));
1031  }
1032  else if (!usesOpenBC)
1033  {
1034  APP_ABORT("Attempting to run PBC LCAO with no HDF5 support. Behaviour is unknown. Safer to exit");
1035  }
1036 
1037  const int Nx = PBCImages[0] + 1;
1038  const int Ny = PBCImages[1] + 1;
1039  const int Nz = PBCImages[2] + 1;
1040  const int NbImages = Nx * Ny * Nz;
1041  LocPeriodicImagePhaseFactors.resize(NbImages);
1042  LocPeriodicImageDisplacements.resize(NbImages, 3);
1043  for (size_t ix = 0; ix < Nx; ix++)
1044  for (size_t iy = 0; iy < Ny; iy++)
1045  for (size_t iz = 0; iz < Nz; iz++)
1046  {
1047  const size_t i = iz + Nz * (iy + Ny * ix);
1048  int TransX = ((ix % 2) * 2 - 1) * ((ix + 1) / 2);
1049  int TransY = ((iy % 2) * 2 - 1) * ((iy + 1) / 2);
1050  int TransZ = ((iz % 2) * 2 - 1) * ((iz + 1) / 2);
1051  LocPeriodicImagePhaseFactors[i] = 1.0;
1052  for (size_t idim = 0; idim < 3; idim++)
1053  LocPeriodicImageDisplacements(i, idim) =
1054  TransX * Lattice(0, idim) + TransY * Lattice(1, idim) + TransZ * Lattice(2, idim);
1055  }
1056 }
1057 
1059  PosType SuperTwist,
1060  Vector<std::complex<RealType>, OffloadPinnedAllocator<std::complex<RealType>>>& LocPeriodicImagePhaseFactors,
1061  Array<RealType, 2, OffloadPinnedAllocator<RealType>>& LocPeriodicImageDisplacements)
1062 {
1063  // Allow computation to continue with no HDF file if the system has open boundary conditions.
1064  // The complex build is usually only used with open BC for testing.
1065  bool usesOpenBC = PBCImages[0] == 0 && PBCImages[1] == 0 && PBCImages[2] == 0;
1066 
1067  ///Exp(ik.g) where i is imaginary, k is the supertwist and g is the translation vector PBCImage.
1068  if (h5_path != "" && !usesOpenBC)
1069  {
1070  hdf_archive hin(myComm);
1071  if (myComm->rank() == 0)
1072  {
1073  if (!hin.open(h5_path, H5F_ACC_RDONLY))
1074  APP_ABORT("Could not open H5 file");
1075 
1076  hin.push("Cell", false);
1077 
1078  hin.read(Lattice, "LatticeVectors");
1079  hin.close();
1080  }
1081  for (int i = 0; i < 3; i++)
1082  for (int j = 0; j < 3; j++)
1083  myComm->bcast(Lattice(i, j));
1084  }
1085  else if (!usesOpenBC)
1086  {
1087  APP_ABORT("Attempting to run PBC LCAO with no HDF5 support. Behaviour is unknown. Safer to exit");
1088  }
1089 
1090  int phase_idx = 0;
1091  int TransX, TransY, TransZ;
1092  RealType phase;
1093  const int Nx = PBCImages[0] + 1;
1094  const int Ny = PBCImages[1] + 1;
1095  const int Nz = PBCImages[2] + 1;
1096  const int NbImages = Nx * Ny * Nz;
1097  LocPeriodicImagePhaseFactors.resize(NbImages);
1098  LocPeriodicImageDisplacements.resize(NbImages, 3);
1099  for (size_t ix = 0; ix < Nx; ix++)
1100  for (size_t iy = 0; iy < Ny; iy++)
1101  for (size_t iz = 0; iz < Nz; iz++)
1102  {
1103  const size_t i = iz + Nz * (iy + Ny * ix);
1104  int TransX = ((ix % 2) * 2 - 1) * ((ix + 1) / 2);
1105  int TransY = ((iy % 2) * 2 - 1) * ((iy + 1) / 2);
1106  int TransZ = ((iz % 2) * 2 - 1) * ((iz + 1) / 2);
1107  RealType s, c;
1108  PosType Val;
1109  for (size_t idim = 0; idim < 3; idim++)
1110  {
1111  Val[idim] = TransX * Lattice(0, idim) + TransY * Lattice(1, idim) + TransZ * Lattice(2, idim);
1112  LocPeriodicImageDisplacements(i, idim) = Val[idim];
1113  }
1114 
1115  phase = dot(SuperTwist, Val);
1116  qmcplusplus::sincos(phase, &s, &c);
1117 
1118  LocPeriodicImagePhaseFactors[i] = std::complex<RealType>(c, s);
1119  }
1120 }
1121 } // namespace qmcplusplus
a class that defines a supercell in D-dimensional Euclean space.
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
multivalue implementation for OneDimQuintic Real valued only calling any eval method with r >= r_max ...
bool loadMO(LCAOrbitalSet &spo, xmlNodePtr cur)
Parse the xml file for information on the Dirac determinants.
bool file_exists(const std::string &name)
ParticleSet & targetPtcl
target ParticleSet
Vector< ValueType, OffloadPinnedAllocator< ValueType > > PeriodicImagePhaseFactors
Periodic Image Phase Factors. Correspond to the phase from the PBCImages. Computed only once...
std::ostream & app_warning()
Definition: OutputManager.h:69
bool open(const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
open a file
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
A localized basis set derived from SoaBasisSetBase<ORBT>
int rank() const
return the rank
Definition: Communicate.h:116
int getBasisSetSize() const
return the size of the basis set
Definition: LCAOrbitalSet.h:78
#define app_debug
Definition: OutputManager.h:75
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
size_t getTotalNum() const
Definition: ParticleSet.h:493
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
void close()
close all the open groups and file
Definition: hdf_archive.cpp:38
bool putPBCFromH5(LCAOrbitalSet &spo, xmlNodePtr coeff_ptr)
read data from a hdf5 file
std::string useGPU
Captured gpu input string.
void LoadFullCoefsFromH5(hdf_archive &hin, int setVal, PosType &SuperTwist, Matrix< std::complex< RealType >> &Ctemp, bool MultiDet)
class to add cusp correction to LCAOrbitalSet.
Vector< RealType > Occ
occupation number
std::unique_ptr< BasisSet_t > loadBasisSetFromXML(xmlNodePtr cur, xmlNodePtr parent)
load a basis set from XML input
class to handle hdf file
Definition: hdf_archive.h:51
bool is_same(const xmlChar *a, const char *b)
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
void saveCusp(const std::string &filename, const Matrix< CuspCorrectionParameters > &info, const std::string &id)
save cusp correction info to a file.
SoaSphericalTensor that evaluates the Real Spherical Harmonics.
void broadcastCuspInfo(CuspCorrectionParameters &param, Communicate &Comm, int root)
Broadcast cusp correction parameters.
void applyCuspCorrection(const Matrix< CuspCorrectionParameters > &info, ParticleSet &targetPtcl, ParticleSet &sourcePtcl, LCAOrbitalSet &lcao, SoaCuspCorrection &cusp, const std::string &id)
generic functor that computes a set of 1D functors
size_type cols() const
Definition: OhmmsMatrix.h:78
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
bool readCuspInfo(const std::string &cuspInfoFile, const std::string &objectName, int OrbitalSetSize, Matrix< CuspCorrectionParameters > &info)
Read cusp correction parameters from XML file.
std::enable_if_t< IsComplex_t< T >::value, bool > IsComplex
Wrapping information on parallelism.
Definition: Communicate.h:68
PosType SuperTwist
Coordinates Super Twist.
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
base class for the real SPOSet builder
Definition: SPOSetBuilder.h:47
atomic basisset builder
std::map< std::string, std::unique_ptr< BasisSet_t > > basisset_map_
localized basis set map
int determineRadialOrbType(xmlNodePtr cur) const
determine radial orbital type based on "keyword" and "transform" attributes
Array< RealType, 2, OffloadPinnedAllocator< RealType > > PeriodicImageDisplacements
ParticleSet & sourcePtcl
source ParticleSet
Final class and should not be derived.
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
declaration of ProgressReportEngine
void generateCuspInfo(Matrix< CuspCorrectionParameters > &info, const ParticleSet &targetPtcl, const ParticleSet &sourcePtcl, const LCAOrbitalSet &lcao, const std::string &id, Communicate &Comm)
std::shared_ptr< OffloadValueMatrix > C
pointer to matrix containing the coefficients
Definition: LCAOrbitalSet.h:42
LCAOrbitalBuilder(ParticleSet &els, ParticleSet &ions, Communicate *comm, xmlNodePtr cur)
constructor
int getOrbitalSetSize() const
return the size of the orbitals
Definition: SPOSet.h:88
std::unique_ptr< SPOSet > createSPOSetFromXML(xmlNodePtr cur) override
create an sposet from xml (legacy)
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
bool putOccupation(LCAOrbitalSet &spo, xmlNodePtr occ_ptr)
static PlatformKind selectPlatform(std::string_view value)
Tensor< double, 3 > Lattice
Store Lattice parameters from HDF5 to use in PeriodicImagePhaseFactors.
OMPallocator is an allocator with fused device and dualspace allocator functionality.
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...
size_type rows() const
Definition: OhmmsMatrix.h:77
std::string h5_path
Path to HDF5 Wavefunction.
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
void push(const std::string &gname, bool createit=true)
push a group to the group stack
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
BasisSet_t * createBasisSet(xmlNodePtr cur)
create basis set
bool putFromXML(LCAOrbitalSet &spo, xmlNodePtr coeff_ptr)
void readRealMatrixFromH5(hdf_archive &hin, const std::string &setname, Matrix< LCAOrbitalBuilder::RealType > &Creal) const
read matrix from h5 file
bool putFromH5(LCAOrbitalSet &spo, xmlNodePtr coeff_ptr)
read data from a hdf5 file
void processChildren(const xmlNodePtr cur, const F &functor)
process through all the children of an XML element F is a lambda or functor void F/[](const std::stri...
Definition: libxmldefs.h:175
std::unique_ptr< COT > createAOSet(xmlNodePtr cur)
TinyVector< int, 3 > PBCImages
Number of periodic Images for Orbital evaluation.
void error(const std::string &msg, bool fatal=false)
traits for a localized basis set; used by createBasisSet
void sincos(T a, T *restrict s, T *restrict c)
sincos function wrapper
Definition: math.hpp:62
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void read(T &data, const std::string &aname)
read the data from the group aname and check status runtime error is issued on I/O error ...
Definition: hdf_archive.h:306
void bcast(T &)
std::unique_ptr< BasisSet_t > loadBasisSetFromH5(xmlNodePtr parent)
load a basis set from h5 file
class to handle linear combinations of basis orbitals used to evaluate the Dirac determinants.
Definition: LCAOrbitalSet.h:30
int findSpecies(const std::string &name) const
if the input species is not found, add a new species
Definition: SpeciesSet.h:114
std::unique_ptr< COT > createAOSetH5(hdf_archive &hin)
void barrier_and_abort(const std::string &msg) const
bool readEntry(T &data, const std::string &aname)
read the data from the group aname and return status use read() for inbuilt error checking ...
Definition: hdf_archive.h:293
A D-dimensional Array class based on PETE.
Definition: OhmmsArray.h:25
A derived class from BasisSetBase.
bool doCuspCorrection
Enable cusp correction.
CartesianTensor according to Gamess order.
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
bool put(xmlNodePtr cur)
SoaBasisSetBase< ValueType > basis_type
Definition: LCAOrbitalSet.h:33
bool putH5(hdf_archive &hin)
void EvalPeriodicImagePhaseFactors(PosType SuperTwist, Vector< RealType, OffloadPinnedAllocator< RealType >> &LocPeriodicImagePhaseFactors, Array< RealType, 2, OffloadPinnedAllocator< RealType >> &LocPeriodicImageDisplacements)
Periodic Image Phase Factors computation to be determined.
const std::vector< std::string > candidate_values
Assume that coeffs.D1 and the LogLightGrid r_values.size() are equal Therefore r must be < r_max...
Base for real basis set.
Definition: BasisSetBase.h:132