QMCPACK
QMCGaussianParserBase.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: Jordan E. Vincent, 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 // Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
11 // Anouar Benali, benali@anl.gov, Argonne National Laboratory
12 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
13 //
14 // File created by: Jordan E. Vincent, University of Illinois at Urbana-Champaign
15 //////////////////////////////////////////////////////////////////////////////////////
16 
17 
18 #include "QMCGaussianParserBase.h"
19 #include <iterator>
20 #include <algorithm>
21 #include <array>
22 #include <numeric>
23 #include "hdf/hdf_archive.h"
24 #include <set>
25 #include <map>
26 #include <sstream>
27 #include <bitset>
28 #include <iomanip>
30 #include "ModernStringUtils.hpp"
31 
32 //std::vector<std::string> QMCGaussianParserBase::IonName;
34 std::map<int, std::string> QMCGaussianParserBase::IonName;
35 std::vector<std::string> QMCGaussianParserBase::gShellType;
36 std::vector<int> QMCGaussianParserBase::gShellID;
37 
38 const std::vector<double> QMCGaussianParserBase::gCoreTable = {
39  0, /* index zero*/
40  1, 2, /*H He */
41  2, 2, 2, 2, 2, 2, 2, 10, /*Li-Ne*/
42  10, 10, 10, 10, 10, 10, 10, 18, /*Na-Ar*/
43  18, 18, 18, 18, 18, 18, 18, 18, 18, 18, /*N-Zn*/
44  28, 28, 28, 28, 28, 36, /*Ga-Kr*/
45  36, 36, 36, 36, 36, 36, 36, 36, 36, 36, /*Rb-Cd*/
46  46, 46, 46, 46, 46, 54, /*In-Xe*/
47  60, 60, 60, 60, 60, 60, 60, 60, 60, /*Cs- */
48  60, 60, 60, 60, 60, 60, 60, 60, 60, /* Lu*/
49  60, 60, 60, 60, 60, 60, 60, 60, 60, /*Hf-Hg*/
50  78, 78, 78, 78, 78, 78, /*Tl-Rn*/
51 };
52 
54  : multideterminant(false),
55  multidetH5(false),
56  BohrUnit(true),
57  SpinRestricted(false),
58  Periodicity(false),
59  UseHDF5(false),
60  PBC(false),
61  production(false),
62  zeroCI(false),
63  orderByExcitation(false),
64  addJastrow(true),
65  addJastrow3Body(false),
66  ECP(false),
67  debug(false),
68  Structure(false),
69  DoCusp(false),
70  FixValence(false),
71  singledetH5(false),
72  optDetCoeffs(false),
73  usingCSF(false),
74  isSpinor(false),
75  NumberOfAtoms(0),
76  NumberOfEls(0),
77  target_state(0),
78  SpinMultiplicity(0),
79  NumberOfAlpha(0),
80  NumberOfBeta(0),
81  SizeOfBasisSet(0),
82  numMO(0),
83  readNO(0),
84  readGuess(0),
85  numMO2print(-1),
86  ci_size(0),
87  ci_nca(0),
88  ci_ncb(0),
89  ci_nea(0),
90  ci_neb(0),
91  ci_nstates(0),
92  NbKpts(0),
93  nbexcitedstates(0),
94  ci_threshold(1e-20),
95  Title("sample"),
96  basisType("Gaussian"),
97  basisName("generic"),
98  Normalized("no"),
99  CurrentCenter(""),
100  outputFile(""),
101  angular_type("spherical"),
102  expandYlm("Gamess"),
103  h5file(""),
104  multih5file(""),
105  WFS_name("wfj"),
106  CodeName(""),
107  IonSystem(simulation_cell),
108  gShell(0),
109  gNumber(0),
110  gBound(0),
111  Occ_alpha(0),
112  Occ_beta(0),
113  X(0),
114  Y(0),
115  Z(0)
116 {}
117 
119  : multideterminant(false),
120  multidetH5(false),
121  BohrUnit(true),
122  SpinRestricted(false),
123  Periodicity(false),
124  UseHDF5(false),
125  PBC(false),
126  production(false),
127  zeroCI(false),
128  orderByExcitation(false),
129  addJastrow(true),
130  addJastrow3Body(false),
131  ECP(false),
132  debug(false),
133  Structure(false),
134  DoCusp(false),
135  FixValence(false),
136  singledetH5(false),
137  optDetCoeffs(false),
138  usingCSF(false),
139  isSpinor(false),
140  NumberOfAtoms(0),
141  NumberOfEls(0),
142  target_state(0),
143  SpinMultiplicity(0),
144  NumberOfAlpha(0),
145  NumberOfBeta(0),
146  SizeOfBasisSet(0),
147  numMO(0),
148  readNO(0),
149  readGuess(0),
150  numMO2print(-1),
151  ci_size(0),
152  ci_nca(0),
153  ci_ncb(0),
154  ci_nea(0),
155  ci_neb(0),
156  ci_nstates(0),
157  NbKpts(0),
158  nbexcitedstates(0),
159  ci_threshold(1e-20),
160  Title("sample"),
161  basisType("Gaussian"),
162  basisName("generic"),
163  Normalized("no"),
164  CurrentCenter(""),
165  outputFile(""),
166  angular_type("spherical"),
167  expandYlm("Gamess"),
168  h5file(""),
169  multih5file(""),
170  WFS_name("wfj"),
171  CodeName(""),
172  IonSystem(simulation_cell),
173  gShell(0),
174  gNumber(0),
175  gBound(0),
176  Occ_alpha(0),
177  Occ_beta(0),
178  X(0),
179  Y(0),
180  Z(0)
181 {
185  std::cout << "Index of ion charge " << IonChargeIndex << std::endl;
186  std::cout << "Index of valence charge " << ValenceChargeIndex << std::endl;
187  Image.resize(3);
188  Image[0] = 8;
189  Image[1] = 8;
190  Image[2] = 8;
191  createGridNode(argc, argv);
192 }
193 
195 {
196  IonName[1] = "H";
197  IonName[2] = "He";
198  IonName[3] = "Li";
199  IonName[4] = "Be";
200  IonName[5] = "B";
201  IonName[6] = "C";
202  IonName[7] = "N";
203  IonName[8] = "O";
204  IonName[9] = "F";
205  IonName[10] = "Ne";
206  IonName[11] = "Na";
207  IonName[12] = "Mg";
208  IonName[13] = "Al";
209  IonName[14] = "Si";
210  IonName[15] = "P";
211  IonName[16] = "S";
212  IonName[17] = "Cl";
213  IonName[18] = "Ar";
214  IonName[19] = "K";
215  IonName[20] = "Ca";
216  IonName[21] = "Sc";
217  IonName[22] = "Ti";
218  IonName[23] = "V";
219  IonName[24] = "Cr";
220  IonName[25] = "Mn";
221  IonName[26] = "Fe";
222  IonName[27] = "Co";
223  IonName[28] = "Ni";
224  IonName[29] = "Cu";
225  IonName[30] = "Zn";
226  IonName[31] = "Ga";
227  IonName[32] = "Ge";
228  IonName[33] = "As";
229  IonName[34] = "Se";
230  IonName[35] = "Br";
231  IonName[36] = "Kr";
232  IonName[37] = "Rb";
233  IonName[38] = "Sr";
234  IonName[39] = "Y";
235  IonName[40] = "Zr";
236  IonName[41] = "Nb";
237  IonName[42] = "Mo";
238  IonName[43] = "Tc";
239  IonName[44] = "Ru";
240  IonName[45] = "Rh";
241  IonName[46] = "Pd";
242  IonName[47] = "Ag";
243  IonName[48] = "Cd";
244  IonName[49] = "In";
245  IonName[50] = "Sn";
246  IonName[51] = "Sb";
247  IonName[52] = "Te";
248  IonName[53] = "I";
249  IonName[54] = "Xe";
250  IonName[55] = "Cs";
251  IonName[56] = "Ba";
252  IonName[57] = "La";
253  IonName[58] = "Ce";
254  IonName[59] = "Pr";
255  IonName[60] = "Nd";
256  IonName[61] = "Pm";
257  IonName[62] = "Sm";
258  IonName[63] = "Eu";
259  IonName[64] = "Gd";
260  IonName[65] = "Tb";
261  IonName[66] = "Dy";
262  IonName[67] = "Ho";
263  IonName[68] = "Er";
264  IonName[69] = "Tm";
265  IonName[70] = "Yb";
266  IonName[71] = "Lu";
267  IonName[72] = "Hf";
268  IonName[73] = "Ta";
269  IonName[74] = "W";
270  IonName[75] = "Re";
271  IonName[76] = "Os";
272  IonName[77] = "Ir";
273  IonName[78] = "Pt";
274  IonName[79] = "Au";
275  IonName[80] = "Hg";
276  IonName[81] = "Tl";
277  IonName[82] = "Pb";
278  IonName[83] = "Bi";
279  IonName[84] = "Po";
280  IonName[85] = "At";
281  IonName[86] = "Rn";
282  IonName[87] = "Fr";
283  IonName[88] = "Ra";
284  IonName[89] = "Ac";
285  IonName[90] = "Th";
286  IonName[91] = "Pa";
287  IonName[92] = "U";
288  IonName[93] = "Np";
289  gShellType.resize(10);
290  gShellType[1] = "s";
291  gShellType[2] = "sp";
292  gShellType[3] = "p";
293  gShellType[4] = "d";
294  gShellType[5] = "f";
295  gShellType[6] = "g";
296  gShellType[7] = "h";
297  gShellType[8] = "h1";
298  gShellType[9] = "h2";
299  gShellID.resize(10);
300  gShellID[1] = 0;
301  gShellID[2] = 0;
302  gShellID[3] = 1; //gShellID[4]=2; gShellID[5]=3; gShellID[6]=4; gShellID[7]=5;
303  for (int i = 4, l = 2; i < gShellID.size(); ++i, ++l)
304  gShellID[i] = l;
305 }
306 
308 {
309  if (isSpinor)
310  {
311  Occ_alpha.resize(numMO, 0);
312  for (int i = 0; i < NumberOfAlpha; i++)
313  Occ_alpha[i] = 1;
314  }
315  else
316  {
317  int ds = SpinMultiplicity - 1;
318  NumberOfBeta = (NumberOfEls - ds) / 2;
320  if (!SpinRestricted)
321  //UHF
322  {
323  std::multimap<value_type, int> e;
324  for (int i = 0; i < numMO; i++)
325  e.insert(std::pair<value_type, int>(EigVal_alpha[i], 0));
326  for (int i = 0; i < numMO; i++)
327  e.insert(std::pair<value_type, int>(EigVal_beta[i], 1));
328  int n = 0;
329  std::multimap<value_type, int>::iterator it(e.begin());
330  LOGMSG("Unrestricted HF. Sorted eigen values")
331  while (n < NumberOfEls && it != e.end())
332  {
333  LOGMSG(n << " " << (*it).first << " " << (*it).second)
334  ++it;
335  ++n;
336  }
337  }
338  //}
339  LOGMSG("Number of alpha electrons " << NumberOfAlpha)
340  LOGMSG("Number of beta electrons " << NumberOfBeta)
341  Occ_alpha.resize(numMO, 0);
342  Occ_beta.resize(numMO, 0);
343  for (int i = 0; i < NumberOfAlpha; i++)
344  Occ_alpha[i] = 1;
345  for (int i = 0; i < NumberOfBeta; i++)
346  Occ_beta[i] = 1;
347  }
348 }
349 
350 xmlNodePtr QMCGaussianParserBase::createElectronSet(const std::string& ion_tag)
351 {
353  els.setName("e");
354  if (!isSpinor)
355  {
356  std::vector<int> nel(2);
357  nel[0] = NumberOfAlpha;
358  nel[1] = NumberOfBeta;
359  els.create(nel);
360  int iu = els.getSpeciesSet().addSpecies("u");
361  int id = els.getSpeciesSet().addSpecies("d");
362  int ic = els.getSpeciesSet().addAttribute("charge");
363  els.getSpeciesSet()(ic, iu) = -1;
364  els.getSpeciesSet()(ic, id) = -1;
365  }
366  else
367  {
368  std::vector<int> nel(1);
369  nel[0] = NumberOfAlpha;
370  assert(NumberOfBeta == 0);
371  els.create(nel);
372  int iu = els.getSpeciesSet().addSpecies("u");
373  int ic = els.getSpeciesSet().addAttribute("charge");
374  els.getSpeciesSet()(ic, iu) = -1;
375  }
376 
377  xmlNodePtr cur = xmlNewNode(NULL, (const xmlChar*)"particleset");
378  xmlNewProp(cur, (const xmlChar*)"name", (const xmlChar*)els.getName().c_str());
379  xmlNewProp(cur, (const xmlChar*)"random", (const xmlChar*)"yes");
380  xmlNewProp(cur, (const xmlChar*)"randomsrc", (const xmlChar*)ion_tag.c_str());
381  if (isSpinor)
382  xmlNewProp(cur, (const xmlChar*)"spinor", (const xmlChar*)"yes");
383 
384 
385  //Electron up
386  {
387  std::ostringstream ng;
388  ng << els.last(0) - els.first(0);
389  xmlNodePtr g = xmlNewNode(NULL, (const xmlChar*)"group");
390  xmlNewProp(g, (const xmlChar*)"name", (const xmlChar*)"u");
391  xmlNewProp(g, (const xmlChar*)"size", (const xmlChar*)ng.str().c_str());
392  xmlNodePtr p = xmlNewTextChild(g, NULL, (const xmlChar*)"parameter", (const xmlChar*)"-1");
393  xmlNewProp(p, (const xmlChar*)"name", (const xmlChar*)"charge");
394  xmlAddChild(cur, g);
395  }
396  //Electron dn
397  if (!isSpinor)
398  {
399  std::ostringstream ng;
400  ng << els.last(1) - els.first(1);
401  xmlNodePtr g = xmlNewNode(NULL, (const xmlChar*)"group");
402  xmlNewProp(g, (const xmlChar*)"name", (const xmlChar*)"d");
403  xmlNewProp(g, (const xmlChar*)"size", (const xmlChar*)ng.str().c_str());
404  xmlNodePtr p = xmlNewTextChild(g, NULL, (const xmlChar*)"parameter", (const xmlChar*)"-1");
405  xmlNewProp(p, (const xmlChar*)"name", (const xmlChar*)"charge");
406  xmlAddChild(cur, g);
407  }
408  return cur;
409 }
410 
411 
413 {
414  xmlNodePtr cur = xmlNewNode(NULL, (const xmlChar*)"simulationcell");
415  std::ostringstream vec;
416  vec.setf(std::ios::scientific, std::ios::floatfield);
417  vec.setf(std::ios::right, std::ios::adjustfield);
418  vec.precision(14);
419  vec << "\n";
420  vec << std::setw(22) << X[0] << std::setw(22) << X[1] << std::setw(22) << X[2] << std::setw(22) << "\n";
421  vec << std::setw(22) << Y[0] << std::setw(22) << Y[1] << std::setw(22) << Y[2] << std::setw(22) << "\n";
422  vec << std::setw(22) << Z[0] << std::setw(22) << Z[1] << std::setw(22) << Z[2] << std::setw(22) << "\n";
423 
424  xmlNodePtr LatVec = xmlNewTextChild(cur, NULL, (const xmlChar*)"parameter", (const xmlChar*)vec.str().c_str());
425  xmlNewProp(LatVec, (const xmlChar*)"name", (const xmlChar*)"lattice");
426  xmlAddChild(cur, LatVec);
427 
428  xmlNodePtr bconds = xmlNewTextChild(cur, NULL, (const xmlChar*)"parameter", (const xmlChar*)"p p p");
429  xmlNewProp(bconds, (const xmlChar*)"name", (const xmlChar*)"bconds");
430  xmlAddChild(cur, bconds);
431 
432  xmlNodePtr LRDim = xmlNewTextChild(cur, NULL, (const xmlChar*)"parameter", (const xmlChar*)"15");
433  xmlNewProp(LRDim, (const xmlChar*)"name", (const xmlChar*)"LR_dim_cutoff");
434  xmlAddChild(cur, LRDim);
435 
436  return cur;
437 }
439 {
440  const double ang_to_bohr = 1.889725989;
441  if (!BohrUnit)
442  {
443  IonSystem.R *= ang_to_bohr;
444  }
445  SpeciesSet& ionSpecies = IonSystem.getSpeciesSet();
446  for (int i = 0; i < ionSpecies.getTotalNum(); i++)
447  {
448  int z = static_cast<int>(ionSpecies(AtomicNumberIndex, i));
449  double valence = ionSpecies(IonChargeIndex, i);
450  if (FixValence)
451  {
452  if (z > gCoreTable.size())
453  return nullptr;
454  else if (valence > gCoreTable[z])
455  valence -= gCoreTable[z];
456  }
457  ionSpecies(ValenceChargeIndex, i) = valence;
458  ionSpecies(AtomicNumberIndex, i) = z;
459  }
461  if (UseHDF5)
462  {
463  hdf_archive hout;
464  hout.open(h5file.c_str(), H5F_ACC_RDWR);
465  hout.push("atoms", true);
466  hout.write(NumberOfAtoms, "number_of_atoms");
467  auto nbspecies = ionSpecies.getTotalNum();
468  hout.write(nbspecies, "number_of_species");
469  Matrix<double> Position(NumberOfAtoms, 3);
470  std::vector<int> speciesID;
471  speciesID.resize(NumberOfAtoms);
472  for (auto i = 0; i < NumberOfAtoms; i++)
473  {
474  Position[i][0] = IonSystem.R[i][0];
475  Position[i][1] = IonSystem.R[i][1];
476  Position[i][2] = IonSystem.R[i][2];
477  speciesID[i] = IonSystem.GroupID[i];
478  }
479 
480  hout.write(speciesID, "species_ids");
481  hout.write(Position, "positions");
482 
483  for (auto i = 0; i < nbspecies; i++)
484  {
485  std::ostringstream SpecieID;
486  SpecieID << "species_" << i;
487  hout.push(SpecieID.str().c_str(), true);
488  int z = static_cast<int>(ionSpecies(AtomicNumberIndex, i));
489  double valence = ionSpecies(IonChargeIndex, i);
490  if (FixValence)
491  {
492  if (z > gCoreTable.size())
493  return nullptr;
494  else if (valence > gCoreTable[z])
495  valence -= gCoreTable[z];
496  }
497  hout.write(z, "charge");
498  hout.write(z, "atomic_number");
499  hout.write(valence, "core");
500  hout.write(IonName[static_cast<int>(ionSpecies(AtomicNumberIndex, i))], "name");
501  hout.pop();
502  }
503 
504  hout.close();
505  }
506  return o.createNode(Periodicity);
507 }
508 
509 
511 {
512  xmlNodePtr bset = xmlNewNode(NULL, (const xmlChar*)"basisset");
513  xmlNewProp(bset, (const xmlChar*)"name", (const xmlChar*)"LCAOBSet");
514  xmlNodePtr cur = NULL;
515  std::map<int, int> species;
516  int gtot = 0;
517  if (!debug)
518  for (int iat = 0; iat < NumberOfAtoms; iat++)
519  {
520  int itype = IonSystem.GroupID[iat];
521  int ng = 0;
522  std::map<int, int>::iterator it = species.find(itype);
523  if (it == species.end())
524  {
525  for (int ig = gBound[iat]; ig < gBound[iat + 1]; ig++)
526  {
527  ng += gNumber[ig];
528  }
529  species[itype] = ng;
530  if (cur)
531  {
532  cur = xmlAddSibling(cur, createCenter(iat, gtot));
533  }
534  else
535  {
536  cur = xmlAddChild(bset, createCenter(iat, gtot));
537  }
538  }
539  else
540  {
541  ng = (*it).second;
542  }
543  gtot += ng;
544  }
545  return bset;
546 }
547 
548 
550 {
551  int counter = 0;
552 
553  xmlNodePtr bset = xmlNewNode(NULL, (const xmlChar*)"basisset");
554  hdf_archive hout;
555  hout.open(h5file.c_str(), H5F_ACC_RDWR);
556  hout.push("basisset", true);
557  std::string BasisSetName("LCAOBSet");
558  hout.write(BasisSetName, "name");
559 
560  std::map<int, int> species;
561  int gtot = 0;
562  for (int iat = 0; iat < NumberOfAtoms; iat++)
563  {
564  int itype = IonSystem.GroupID[iat];
565  int ng = 0;
566  std::map<int, int>::iterator it = species.find(itype);
567  if (it == species.end())
568  {
569  for (int ig = gBound[iat]; ig < gBound[iat + 1]; ig++)
570  {
571  ng += gNumber[ig];
572  }
573  species[itype] = ng;
574  createCenterH5(iat, gtot, counter);
575  counter++;
576  }
577  else
578  {
579  ng = (*it).second;
580  }
581  gtot += ng;
582  }
583  hout.write(counter, "NbElements");
584  hout.close();
585  return bset;
586 }
587 
588 
590 {
592  xmlNodePtr slaterdet = xmlNewNode(NULL, (const xmlChar*)"slaterdeterminant");
593  std::ostringstream up_size, down_size, b_size;
594  up_size << NumberOfAlpha;
595  down_size << NumberOfBeta;
596  b_size << numMO;
597  //create a determinant Up
598  xmlNodePtr udet = xmlNewNode(NULL, (const xmlChar*)"determinant");
599  xmlNewProp(udet, (const xmlChar*)"id", (const xmlChar*)"updet");
600  xmlNewProp(udet, (const xmlChar*)"size", (const xmlChar*)up_size.str().c_str());
601  if (DoCusp == true)
602  xmlNewProp(udet, (const xmlChar*)"cuspInfo", (const xmlChar*)"../updet.cuspInfo.xml");
603 
604  //add occupation
605  xmlNodePtr occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
606  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
607  xmlAddChild(udet, occ_data);
608  //add coefficients
609  xmlNodePtr coeff_data = xmlNewNode(NULL, (const xmlChar*)"coefficient");
610  xmlNewProp(coeff_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
611  xmlNewProp(coeff_data, (const xmlChar*)"spindataset", (const xmlChar*)"0");
612  xmlAddChild(udet, coeff_data);
613  //add udet to slaterdet
614  xmlNodePtr cur = xmlAddChild(slaterdet, udet);
615 
616  hdf_archive hout;
617  hout.open(h5file.c_str(), H5F_ACC_RDWR);
618  hout.push("Super_Twist", true);
619 
621 
622  int n = 0;
623  for (int i = 0; i < numMO; i++)
624  for (int j = 0; j < SizeOfBasisSet; j++)
625  {
626  Ctemp[i][j] = EigVec[n];
627  n++;
628  }
629 
630  hout.write(Ctemp, "eigenset_0");
631 
632  xmlNodePtr ddet;
633  if (isSpinor)
634  {
635  n = numMO * SizeOfBasisSet;
636  for (int i = 0; i < numMO; i++)
637  {
638  for (int j = 0; j < SizeOfBasisSet; j++)
639  {
640  Ctemp[i][j] = EigVec[n];
641  n++;
642  }
643  }
644  hout.write(Ctemp, "eigenset_1");
645  n = 2 * numMO * SizeOfBasisSet;
646  for (int i = 0; i < numMO; i++)
647  {
648  for (int j = 0; j < SizeOfBasisSet; j++)
649  {
650  Ctemp[i][j] = EigVec[n];
651  n++;
652  }
653  }
654  hout.write(Ctemp, "eigenset_0_imag");
655  n = 3 * numMO * SizeOfBasisSet;
656  for (int i = 0; i < numMO; i++)
657  {
658  for (int j = 0; j < SizeOfBasisSet; j++)
659  {
660  Ctemp[i][j] = EigVec[n];
661  n++;
662  }
663  }
664  hout.write(Ctemp, "eigenset_1_imag");
665 
666  hout.write(EigVal_alpha, "eigenval_0");
667  }
668  else
669  {
670  if (SpinRestricted)
671  {
672  ddet = xmlCopyNode(udet, 1);
673  xmlSetProp(ddet, (const xmlChar*)"id", (const xmlChar*)"downdet");
674  xmlSetProp(ddet, (const xmlChar*)"size", (const xmlChar*)down_size.str().c_str());
675  if (DoCusp == true)
676  xmlSetProp(ddet, (const xmlChar*)"cuspInfo", (const xmlChar*)"../downdet.cuspInfo.xml");
677  }
678  else
679  {
680  ddet = xmlCopyNode(udet, 2);
681  xmlSetProp(ddet, (const xmlChar*)"id", (const xmlChar*)"downdet");
682  xmlSetProp(ddet, (const xmlChar*)"size", (const xmlChar*)down_size.str().c_str());
683  if (DoCusp == true)
684  xmlSetProp(ddet, (const xmlChar*)"cuspInfo", (const xmlChar*)"../downdet.cuspInfo.xml");
685  xmlNodePtr o = xmlAddChild(ddet, xmlCopyNode(occ_data, 1));
686  xmlNodePtr c = xmlCopyNode(coeff_data, 1);
687  xmlSetProp(c, (const xmlChar*)"spindataset", (const xmlChar*)"1");
688  o = xmlAddSibling(o, c);
689 
690  n = numMO * SizeOfBasisSet;
691  for (int i = 0; i < numMO; i++)
692  for (int j = 0; j < SizeOfBasisSet; j++)
693  {
694  Ctemp[i][j] = EigVec[n];
695  n++;
696  }
697 
698  hout.write(Ctemp, "eigenset_1");
699  }
700  cur = xmlAddSibling(cur, ddet);
701  }
702 
703  hout.close();
704  return slaterdet;
705 }
706 
707 
709 {
711  xmlNodePtr slaterdet = xmlNewNode(NULL, (const xmlChar*)"slaterdeterminant");
712  std::ostringstream up_size, down_size, b_size;
713  up_size << NumberOfAlpha;
714  down_size << NumberOfBeta;
715  b_size << numMO;
716  //create a determinant Up
717  xmlNodePtr udet = xmlNewNode(NULL, (const xmlChar*)"determinant");
718  xmlNewProp(udet, (const xmlChar*)"id", (const xmlChar*)"updet");
719  xmlNewProp(udet, (const xmlChar*)"size", (const xmlChar*)up_size.str().c_str());
720  if (DoCusp == true)
721  xmlNewProp(udet, (const xmlChar*)"cuspInfo", (const xmlChar*)"../updet.cuspInfo.xml");
722 
723  //add occupation
724  xmlNodePtr occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
725  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
726  xmlAddChild(udet, occ_data);
727  //add coefficients
728  xmlNodePtr coeff_data = xmlNewNode(NULL, (const xmlChar*)"coefficient");
729  xmlNewProp(coeff_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
730  xmlNewProp(coeff_data, (const xmlChar*)"spindataset", (const xmlChar*)"0");
731  xmlAddChild(udet, coeff_data);
732  //add udet to slaterdet
733  xmlNodePtr cur = xmlAddChild(slaterdet, udet);
734 
735  xmlNodePtr ddet;
736  if (SpinRestricted)
737  {
738  ddet = xmlCopyNode(udet, 1);
739  xmlSetProp(ddet, (const xmlChar*)"id", (const xmlChar*)"downdet");
740  xmlSetProp(ddet, (const xmlChar*)"size", (const xmlChar*)down_size.str().c_str());
741  if (DoCusp == true)
742  xmlSetProp(ddet, (const xmlChar*)"cuspInfo", (const xmlChar*)"../downdet.cuspInfo.xml");
743  }
744  else
745  {
746  ddet = xmlCopyNode(udet, 2);
747  xmlSetProp(ddet, (const xmlChar*)"id", (const xmlChar*)"downdet");
748  xmlSetProp(ddet, (const xmlChar*)"size", (const xmlChar*)down_size.str().c_str());
749  if (DoCusp == true)
750  xmlSetProp(ddet, (const xmlChar*)"cuspInfo", (const xmlChar*)"../downdet.cuspInfo.xml");
751  xmlNodePtr o = xmlAddChild(ddet, xmlCopyNode(occ_data, 1));
752  xmlNodePtr c = xmlCopyNode(coeff_data, 1);
753  xmlSetProp(c, (const xmlChar*)"spindataset", (const xmlChar*)"1");
754  o = xmlAddSibling(o, c);
755  }
756  cur = xmlAddSibling(cur, ddet);
757  return slaterdet;
758 }
759 
761 {
763  xmlNodePtr slaterdet = xmlNewNode(NULL, (const xmlChar*)"slaterdeterminant");
764  //check spin-dependent properties
765  std::ostringstream up_size, down_size, b_size, occ;
766  up_size << NumberOfAlpha;
767  down_size << NumberOfBeta;
768  b_size << numMO;
769  //create a determinant Up
770  xmlNodePtr adet = xmlNewNode(NULL, (const xmlChar*)"determinant");
771  xmlNewProp(adet, (const xmlChar*)"id", (const xmlChar*)"updet");
772  xmlNewProp(adet, (const xmlChar*)"size", (const xmlChar*)up_size.str().c_str());
773  if (DoCusp == true)
774  xmlNewProp(adet, (const xmlChar*)"cuspInfo", (const xmlChar*)"../updet.cuspInfo.xml");
775 
776  xmlNodePtr occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
777  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
778  xmlAddChild(adet, occ_data);
779  int btot = numMO * SizeOfBasisSet;
780  int n = btot / 4, b = 0;
781  int dn = btot - n * 4;
782  std::ostringstream eig;
783  eig.setf(std::ios::scientific, std::ios::floatfield);
784  eig.setf(std::ios::right, std::ios::adjustfield);
785  eig.precision(14);
786  eig << "\n";
787  for (int k = 0; k < n; k++)
788  {
789  eig << std::setw(22) << EigVec[b] << std::setw(22) << EigVec[b + 1] << std::setw(22) << EigVec[b + 2]
790  << std::setw(22) << EigVec[b + 3] << "\n";
791  b += 4;
792  }
793  for (int k = 0; k < dn; k++)
794  {
795  eig << std::setw(22) << EigVec[b++];
796  }
797  if (dn)
798  eig << std::endl;
799  xmlNodePtr det_data = xmlNewTextChild(adet, NULL, (const xmlChar*)"coefficient", (const xmlChar*)eig.str().c_str());
800  xmlNewProp(det_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
801  xmlNewProp(det_data, (const xmlChar*)"id", (const xmlChar*)"updetC");
802  xmlNodePtr cur = xmlAddChild(slaterdet, adet);
803  adet = xmlNewNode(NULL, (const xmlChar*)"determinant");
804  xmlNewProp(adet, (const xmlChar*)"id", (const xmlChar*)"downdet");
805  xmlNewProp(adet, (const xmlChar*)"size", (const xmlChar*)down_size.str().c_str());
806  if (DoCusp == true)
807  xmlNewProp(adet, (const xmlChar*)"cuspInfo", (const xmlChar*)"../downdet.cuspInfo.xml");
808 
809  {
810  occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
811  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
812  xmlAddChild(adet, occ_data);
813  std::ostringstream eigD;
814  eigD.setf(std::ios::scientific, std::ios::floatfield);
815  eigD.setf(std::ios::right, std::ios::adjustfield);
816  eigD.precision(14);
817  eigD << "\n";
818  b = numMO * SizeOfBasisSet;
819  for (int k = 0; k < n; k++)
820  {
821  eigD << std::setw(22) << EigVec[b] << std::setw(22) << EigVec[b + 1] << std::setw(22) << EigVec[b + 2]
822  << std::setw(22) << EigVec[b + 3] << "\n";
823  b += 4;
824  }
825  for (int k = 0; k < dn; k++)
826  {
827  eigD << std::setw(22) << EigVec[b++];
828  }
829  if (dn)
830  eigD << std::endl;
831  if (SpinRestricted)
832  det_data = xmlNewTextChild(adet, NULL, (const xmlChar*)"coefficient", (const xmlChar*)eig.str().c_str());
833  else
834  det_data = xmlNewTextChild(adet, NULL, (const xmlChar*)"coefficient", (const xmlChar*)eigD.str().c_str());
835  xmlNewProp(det_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
836  xmlNewProp(det_data, (const xmlChar*)"id", (const xmlChar*)"downdetC");
837  }
838  cur = xmlAddSibling(cur, adet);
839  return slaterdet;
840 }
841 
842 void QMCGaussianParserBase::createSPOSets(xmlNodePtr spoUP, xmlNodePtr spoDN)
843 {
845  std::ostringstream up_size, down_size, b_size, occ, nstates_alpha, nstates_beta;
846  up_size << NumberOfAlpha;
847  down_size << NumberOfBeta;
848  b_size << numMO;
849  nstates_alpha << ci_nstates + ci_nca;
850  nstates_beta << ci_nstates + ci_ncb;
851 
852  xmlNewProp(spoUP, (const xmlChar*)"name", (const xmlChar*)"spo-up");
853  xmlNewProp(spoDN, (const xmlChar*)"name", (const xmlChar*)"spo-dn");
854  xmlNewProp(spoUP, (const xmlChar*)"size", (const xmlChar*)nstates_alpha.str().c_str());
855  xmlNewProp(spoDN, (const xmlChar*)"size", (const xmlChar*)nstates_beta.str().c_str());
856  if (DoCusp == true)
857  {
858  xmlNewProp(spoUP, (const xmlChar*)"cuspInfo", (const xmlChar*)"../spo-up.cuspInfo.xml");
859  xmlNewProp(spoDN, (const xmlChar*)"cuspInfo", (const xmlChar*)"../spo-dn.cuspInfo.xml");
860  }
861  xmlNodePtr occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
862  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
863  xmlAddChild(spoUP, occ_data);
864  int btot = numMO * SizeOfBasisSet;
865  int n = btot / 4, b = 0;
866  int dn = btot - n * 4;
867  std::ostringstream eig;
868  eig.setf(std::ios::scientific, std::ios::floatfield);
869  eig.setf(std::ios::right, std::ios::adjustfield);
870  eig.precision(14);
871  eig << "\n";
872  for (int k = 0; k < n; k++)
873  {
874  eig << std::setw(22) << EigVec[b] << std::setw(22) << EigVec[b + 1] << std::setw(22) << EigVec[b + 2]
875  << std::setw(22) << EigVec[b + 3] << "\n";
876  b += 4;
877  }
878  for (int k = 0; k < dn; k++)
879  {
880  eig << std::setw(22) << EigVec[b++];
881  }
882  if (dn)
883  eig << std::endl;
884  xmlNodePtr det_data = xmlNewTextChild(spoUP, NULL, (const xmlChar*)"coefficient", (const xmlChar*)eig.str().c_str());
885  xmlNewProp(det_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
886  xmlNewProp(det_data, (const xmlChar*)"id", (const xmlChar*)"updetC");
887  {
888  occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
889  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
890  xmlAddChild(spoDN, occ_data);
891  std::ostringstream eigD;
892  eigD.setf(std::ios::scientific, std::ios::floatfield);
893  eigD.setf(std::ios::right, std::ios::adjustfield);
894  eigD.precision(14);
895  eigD << "\n";
896  b = numMO * SizeOfBasisSet;
897  for (int k = 0; k < n; k++)
898  {
899  eigD << std::setw(22) << EigVec[b] << std::setw(22) << EigVec[b + 1] << std::setw(22) << EigVec[b + 2]
900  << std::setw(22) << EigVec[b + 3] << "\n";
901  b += 4;
902  }
903  for (int k = 0; k < dn; k++)
904  {
905  eigD << std::setw(22) << EigVec[b++];
906  }
907  if (dn)
908  eigD << std::endl;
909  if (SpinRestricted)
910  det_data = xmlNewTextChild(spoDN, NULL, (const xmlChar*)"coefficient", (const xmlChar*)eig.str().c_str());
911  else
912  det_data = xmlNewTextChild(spoDN, NULL, (const xmlChar*)"coefficient", (const xmlChar*)eigD.str().c_str());
913  xmlNewProp(det_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
914  xmlNewProp(det_data, (const xmlChar*)"id", (const xmlChar*)"downdetC");
915  }
916 }
917 
918 void QMCGaussianParserBase::createSPOSetsH5(xmlNodePtr spoUP, xmlNodePtr spoDN)
919 {
922  int n = 0;
923  hdf_archive hout;
924  hout.open(h5file.c_str(), H5F_ACC_RDWR);
925  hout.push("Super_Twist", true);
926 
927  std::ostringstream up_size, down_size, b_size, occ, nstates_alpha, nstates_beta;
928  up_size << NumberOfAlpha;
929  down_size << NumberOfBeta;
930  b_size << numMO;
931  nstates_alpha << ci_nstates + ci_nca;
932  ;
933  nstates_beta << ci_nstates + ci_ncb;
934 
935  //create a spoUp
936  xmlNewProp(spoUP, (const xmlChar*)"name", (const xmlChar*)"spo-up");
937  xmlNewProp(spoUP, (const xmlChar*)"size", (const xmlChar*)nstates_alpha.str().c_str());
938 
939  //create a spoDN
940  if (!isSpinor)
941  {
942  xmlNewProp(spoDN, (const xmlChar*)"name", (const xmlChar*)"spo-dn");
943  xmlNewProp(spoDN, (const xmlChar*)"size", (const xmlChar*)nstates_beta.str().c_str());
944  }
945 
946 
947  if (DoCusp == true)
948  {
949  xmlNewProp(spoUP, (const xmlChar*)"cuspInfo", (const xmlChar*)"../spo-up.cuspInfo.xml");
950  if (!isSpinor)
951  xmlNewProp(spoDN, (const xmlChar*)"cuspInfo", (const xmlChar*)"../spo-dn.cuspInfo.xml");
952  }
953 
954 
955  //add occupation UP
956  xmlNodePtr occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
957  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
958  xmlAddChild(spoUP, occ_data);
959 
960 
961  //add coefficients
962  xmlNodePtr coeff_data = xmlNewNode(NULL, (const xmlChar*)"coefficient");
963  xmlNewProp(coeff_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
964  xmlNewProp(coeff_data, (const xmlChar*)"spindataset", (const xmlChar*)"0");
965  xmlAddChild(spoUP, coeff_data);
966 
967 
968  for (int i = 0; i < numMO; i++)
969  for (int j = 0; j < SizeOfBasisSet; j++)
970  {
971  Ctemp[i][j] = EigVec[n];
972  n++;
973  }
974 
975  hout.write(Ctemp, "eigenset_0");
976 
977  if (isSpinor)
978  {
979  n = numMO * SizeOfBasisSet;
980  for (int i = 0; i < numMO; i++)
981  {
982  for (int j = 0; j < SizeOfBasisSet; j++)
983  {
984  Ctemp[i][j] = EigVec[n];
985  n++;
986  }
987  }
988  hout.write(Ctemp, "eigenset_1");
989  n = 2 * numMO * SizeOfBasisSet;
990  for (int i = 0; i < numMO; i++)
991  {
992  for (int j = 0; j < SizeOfBasisSet; j++)
993  {
994  Ctemp[i][j] = EigVec[n];
995  n++;
996  }
997  }
998  hout.write(Ctemp, "eigenset_0_imag");
999  n = 3 * numMO * SizeOfBasisSet;
1000  for (int i = 0; i < numMO; i++)
1001  {
1002  for (int j = 0; j < SizeOfBasisSet; j++)
1003  {
1004  Ctemp[i][j] = EigVec[n];
1005  n++;
1006  }
1007  }
1008  hout.write(Ctemp, "eigenset_1_imag");
1009 
1010  hout.write(EigVal_alpha, "eigenval_0");
1011  }
1012  else
1013  {
1014  //add occupation DN
1015  occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
1016  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
1017  xmlAddChild(spoDN, occ_data);
1018 
1019  coeff_data = xmlNewNode(NULL, (const xmlChar*)"coefficient");
1020  xmlNewProp(coeff_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
1021  if (SpinRestricted)
1022  xmlNewProp(coeff_data, (const xmlChar*)"spindataset", (const xmlChar*)"0");
1023  else
1024  {
1025  xmlNewProp(coeff_data, (const xmlChar*)"spindataset", (const xmlChar*)"1");
1026  n = numMO * SizeOfBasisSet;
1027  for (int i = 0; i < numMO; i++)
1028  for (int j = 0; j < SizeOfBasisSet; j++)
1029  {
1030  Ctemp[i][j] = EigVec[n];
1031  n++;
1032  }
1033  hout.write(Ctemp, "eigenset_1");
1034  }
1035  xmlAddChild(spoDN, coeff_data);
1036  }
1037 
1038  hout.close();
1039 }
1040 
1042 {
1043  xmlNodePtr multislaterdet = xmlNewNode(NULL, (const xmlChar*)"multideterminant");
1044  if (optDetCoeffs)
1045  xmlNewProp(multislaterdet, (const xmlChar*)"optimize", (const xmlChar*)"yes");
1046  else
1047  xmlNewProp(multislaterdet, (const xmlChar*)"optimize", (const xmlChar*)"no");
1048  if (isSpinor)
1049  xmlNewProp(multislaterdet, (const xmlChar*)"spo_0", (const xmlChar*)"spo-up");
1050  else
1051  {
1052  xmlNewProp(multislaterdet, (const xmlChar*)"spo_up", (const xmlChar*)"spo-up");
1053  xmlNewProp(multislaterdet, (const xmlChar*)"spo_dn", (const xmlChar*)"spo-dn");
1054  }
1055  xmlNodePtr detlist = xmlNewNode(NULL, (const xmlChar*)"detlist");
1056  std::ostringstream nstates, cisize, cinca, cincb, cinea, cineb, ci_thr;
1057  cisize << ci_size;
1058  nstates << ci_nstates;
1059  cinca << ci_nca;
1060  cincb << ci_ncb;
1061  cinea << ci_nea;
1062  cineb << ci_neb;
1063  ci_thr << ci_threshold;
1064  xmlNewProp(detlist, (const xmlChar*)"size", (const xmlChar*)cisize.str().c_str());
1065  xmlNewProp(detlist, (const xmlChar*)"type", (const xmlChar*)"DETS");
1066  if (isSpinor)
1067  {
1068  xmlNewProp(detlist, (const xmlChar*)"nc0", (const xmlChar*)cinca.str().c_str());
1069  xmlNewProp(detlist, (const xmlChar*)"ne0", (const xmlChar*)cinea.str().c_str());
1070  }
1071  else
1072  {
1073  xmlNewProp(detlist, (const xmlChar*)"nca", (const xmlChar*)cinca.str().c_str());
1074  xmlNewProp(detlist, (const xmlChar*)"ncb", (const xmlChar*)cincb.str().c_str());
1075  xmlNewProp(detlist, (const xmlChar*)"nea", (const xmlChar*)cinea.str().c_str());
1076  xmlNewProp(detlist, (const xmlChar*)"neb", (const xmlChar*)cineb.str().c_str());
1077  }
1078  xmlNewProp(detlist, (const xmlChar*)"nstates", (const xmlChar*)nstates.str().c_str());
1079  xmlNewProp(detlist, (const xmlChar*)"cutoff", (const xmlChar*)ci_thr.str().c_str());
1080  xmlNewProp(detlist, (const xmlChar*)"href", (const xmlChar*)h5file.c_str());
1081  if (CIcoeff.size() == 0)
1082  {
1083  std::cerr << " CI configuration list is empty. \n";
1084  exit(101);
1085  }
1086  if (CIcoeff.size() != CIalpha.size())
1087  {
1088  std::cerr << " Problem with CI configuration lists. \n";
1089  exit(102);
1090  }
1091  if (!isSpinor && CIcoeff.size() != CIbeta.size())
1092  {
1093  std::cerr << " Problem with CI configuration lists. \n";
1094  exit(102);
1095  }
1096  /// 64 bit fixed width integer
1097  const unsigned bit_kind = 64;
1098  static_assert(bit_kind == sizeof(uint64_t) * 8, "Must be 64 bit fixed width integer");
1099  static_assert(bit_kind == sizeof(unsigned long long) * 8, "Must be 64 bit fixed width integer");
1100  /// the number of 64 bit integers which represent the binary string for occupation
1101  int N_int;
1102  N_int = int(ci_nstates / bit_kind);
1103  if (ci_nstates % bit_kind > 0)
1104  N_int += 1;
1105 
1106  hdf_archive hout;
1107  hout.open(h5file.c_str(), H5F_ACC_RDWR);
1108  hout.push("MultiDet", true);
1109  hout.write(ci_size, "NbDet");
1110  hout.write(ci_nstates, "nstate");
1111  hout.write(CIcoeff, "Coeff");
1112  hout.write(N_int, "Nbits");
1113  hout.write(nbexcitedstates, "nexcitedstate");
1114 
1115  Matrix<uint64_t> tempAlpha(ci_size, N_int);
1116  Matrix<uint64_t> tempBeta(ci_size, N_int);
1117  for (int i = 0; i < CIcoeff.size(); i++)
1118  {
1119  std::string loc_alpha = CIalpha[i].substr(0, ci_nstates);
1120  std::string loc_beta = CIbeta[i].substr(0, ci_nstates);
1121  std::string BiteSizeStringAlpha;
1122  std::string BiteSizeStringBeta;
1123  BiteSizeStringAlpha.resize(N_int * bit_kind);
1124  BiteSizeStringBeta.resize(N_int * bit_kind);
1125 
1126  for (std::size_t n = 0; n < (N_int * bit_kind); n++)
1127  {
1128  BiteSizeStringAlpha[n] = '0';
1129  BiteSizeStringBeta[n] = '0';
1130  }
1131 
1132  for (std::size_t n = 0; n < ci_nstates; n++)
1133  {
1134  BiteSizeStringAlpha[n] = loc_alpha[n];
1135  BiteSizeStringBeta[n] = loc_beta[n];
1136  }
1137 
1138  std::size_t offset = 0;
1139  for (std::size_t l = 0; l < N_int; l++)
1140  {
1141  offset = bit_kind * l;
1142  uint64_t Val;
1143  std::string Var_alpha, Var_beta;
1144  Var_alpha.resize(bit_kind);
1145  Var_beta.resize(bit_kind);
1146 
1147  for (auto j = 0; j < bit_kind; j++)
1148  {
1149  Var_alpha[j] = BiteSizeStringAlpha[j + offset];
1150  Var_beta[j] = BiteSizeStringBeta[j + offset];
1151  }
1152  std::reverse(Var_alpha.begin(), Var_alpha.end());
1153  std::reverse(Var_beta.begin(), Var_beta.end());
1154  std::bitset<bit_kind> bit_alpha(Var_alpha);
1155  std::bitset<bit_kind> bit_beta(Var_beta);
1156  tempAlpha[i][l] = bit_alpha.to_ullong();
1157  tempBeta[i][l] = bit_beta.to_ullong();
1158  }
1159  }
1160  hout.write(tempAlpha, "CI_Alpha");
1161  if (!isSpinor)
1162  hout.write(tempBeta, "CI_Beta");
1163 
1164  hout.pop();
1165  xmlAddChild(multislaterdet, detlist);
1166  hout.close();
1167  return multislaterdet;
1168 }
1169 
1171 {
1172  xmlNodePtr multislaterdet = xmlNewNode(NULL, (const xmlChar*)"multideterminant");
1173  if (optDetCoeffs)
1174  xmlNewProp(multislaterdet, (const xmlChar*)"optimize", (const xmlChar*)"yes");
1175  else
1176  xmlNewProp(multislaterdet, (const xmlChar*)"optimize", (const xmlChar*)"no");
1177  xmlNewProp(multislaterdet, (const xmlChar*)"spo_up", (const xmlChar*)"spo-up");
1178  xmlNewProp(multislaterdet, (const xmlChar*)"spo_dn", (const xmlChar*)"spo-dn");
1179  if (usingCSF)
1180  {
1181  xmlNodePtr detlist = xmlNewNode(NULL, (const xmlChar*)"detlist");
1182  std::ostringstream nstates, cisize, cinca, cincb, cinea, cineb, ci_thr;
1183  cisize << ci_size;
1184  nstates << ci_nstates;
1185  cinca << ci_nca;
1186  cincb << ci_ncb;
1187  cinea << ci_nea;
1188  cineb << ci_neb;
1189  ci_thr << ci_threshold;
1190  xmlNewProp(detlist, (const xmlChar*)"size", (const xmlChar*)cisize.str().c_str());
1191  xmlNewProp(detlist, (const xmlChar*)"type", (const xmlChar*)"CSF");
1192  xmlNewProp(detlist, (const xmlChar*)"nca", (const xmlChar*)cinca.str().c_str());
1193  xmlNewProp(detlist, (const xmlChar*)"ncb", (const xmlChar*)cincb.str().c_str());
1194  xmlNewProp(detlist, (const xmlChar*)"nea", (const xmlChar*)cinea.str().c_str());
1195  xmlNewProp(detlist, (const xmlChar*)"neb", (const xmlChar*)cineb.str().c_str());
1196  xmlNewProp(detlist, (const xmlChar*)"nstates", (const xmlChar*)nstates.str().c_str());
1197  xmlNewProp(detlist, (const xmlChar*)"cutoff", (const xmlChar*)ci_thr.str().c_str());
1198  CIexcitLVL.clear();
1199  for (int i = 0; i < CSFocc.size(); i++)
1200  {
1201  CIexcitLVL.push_back(numberOfExcitationsCSF(CSFocc[i]));
1202  //cout<<CSFocc[i] <<" " <<CIexcitLVL.back() << std::endl;
1203  }
1204  // order dets according to ci coeff
1205  std::vector<std::pair<double, int>> order;
1206  if (orderByExcitation)
1207  {
1208  std::cout << "Ordering csfs by excitation level. \n";
1209  int maxE = *max_element(CIexcitLVL.begin(), CIexcitLVL.end());
1210  std::vector<int> pos(maxE);
1211  int ip1, ip2, cnt = 0, cnt2;
1212  // add by excitations, and do partial sorts of the list
1213  // messy but I dont want std::pair< std::pair<> > types right now
1214  for (int i = maxE; i >= 0; i--)
1215  {
1216  ip1 = ip2 = cnt;
1217  cnt2 = 0;
1218  for (int k = 0; k < CIexcitLVL.size(); k++)
1219  {
1220  if (CIexcitLVL[k] == i)
1221  {
1222  std::pair<double, int> cic(std::abs(coeff2csf[k].second), k);
1223  order.push_back(cic);
1224  cnt2++;
1225  cnt++;
1226  }
1227  }
1228  if (cnt2 > 0)
1229  sort(order.begin() + ip1, order.end());
1230  }
1231  }
1232  else
1233  {
1234  for (int i = 0; i < coeff2csf.size(); i++)
1235  {
1236  std::pair<double, int> cic(std::abs(coeff2csf[i].second), i);
1237  order.push_back(cic);
1238  }
1239  sort(order.begin(), order.end());
1240  }
1241  std::vector<std::pair<double, int>>::reverse_iterator it(order.rbegin());
1242  std::vector<std::pair<double, int>>::reverse_iterator last(order.rend());
1243  int iv = 0;
1244  while (it != last)
1245  {
1246  int nq = (*it).second;
1247  xmlNodePtr csf = xmlNewNode(NULL, (const xmlChar*)"csf");
1248  std::ostringstream qc_coeff;
1249  qc_coeff << coeff2csf[nq].second;
1250  std::ostringstream coeff;
1251  std::ostringstream exct;
1252  exct << CIexcitLVL[nq];
1253  if (zeroCI && iv == 0)
1254  {
1255  coeff << 1.0;
1256  }
1257  else if (zeroCI && iv > 0)
1258  {
1259  coeff << 0.0;
1260  }
1261  else
1262  {
1263  coeff << coeff2csf[nq].second;
1264  }
1265  std::ostringstream tag;
1266  tag << "CSFcoeff_" << iv;
1267  xmlNewProp(csf, (const xmlChar*)"id", (const xmlChar*)tag.str().c_str());
1268  xmlNewProp(csf, (const xmlChar*)"exctLvl", (const xmlChar*)exct.str().c_str());
1269  xmlNewProp(csf, (const xmlChar*)"coeff", (const xmlChar*)coeff.str().c_str());
1270  xmlNewProp(csf, (const xmlChar*)"qchem_coeff", (const xmlChar*)qc_coeff.str().c_str());
1271  xmlNewProp(csf, (const xmlChar*)"occ", (const xmlChar*)CSFocc[nq].substr(0, ci_nstates).c_str());
1272  for (int i = 0; i < CSFexpansion[nq].size(); i++)
1273  {
1274  xmlNodePtr ci = xmlNewNode(NULL, (const xmlChar*)"det");
1275  std::ostringstream coeff0;
1276  coeff0 << CSFexpansion[nq][i];
1277  std::ostringstream tag0;
1278  tag0 << "csf_" << iv << "-" << i;
1279  xmlNewProp(ci, (const xmlChar*)"id", (const xmlChar*)tag0.str().c_str());
1280  xmlNewProp(ci, (const xmlChar*)"coeff", (const xmlChar*)coeff0.str().c_str());
1281  xmlNewProp(ci, (const xmlChar*)"alpha", (const xmlChar*)CSFalpha[nq][i].substr(0, ci_nstates).c_str());
1282  xmlNewProp(ci, (const xmlChar*)"beta", (const xmlChar*)CSFbeta[nq][i].substr(0, ci_nstates).c_str());
1283  xmlAddChild(csf, ci);
1284  }
1285  xmlAddChild(detlist, csf);
1286  it++;
1287  iv++;
1288  }
1289  xmlAddChild(multislaterdet, detlist);
1290  }
1291  else
1292  // usingCSF
1293  {
1294  xmlNodePtr detlist = xmlNewNode(NULL, (const xmlChar*)"detlist");
1295  ci_size = 0;
1296  for (int i = 0; i < CIcoeff.size(); i++)
1297  if (std::abs(CIcoeff[i]) > ci_threshold)
1298  ci_size++;
1299  std::ostringstream nstates, cisize, cinca, cincb, cinea, cineb, ci_thr;
1300  cisize << ci_size;
1301  nstates << ci_nstates;
1302  cinca << ci_nca;
1303  cincb << ci_ncb;
1304  cinea << ci_nea;
1305  cineb << ci_neb;
1306  ci_thr << ci_threshold;
1307  xmlNewProp(detlist, (const xmlChar*)"size", (const xmlChar*)cisize.str().c_str());
1308  xmlNewProp(detlist, (const xmlChar*)"type", (const xmlChar*)"DETS");
1309  xmlNewProp(detlist, (const xmlChar*)"nca", (const xmlChar*)cinca.str().c_str());
1310  xmlNewProp(detlist, (const xmlChar*)"ncb", (const xmlChar*)cincb.str().c_str());
1311  xmlNewProp(detlist, (const xmlChar*)"nea", (const xmlChar*)cinea.str().c_str());
1312  xmlNewProp(detlist, (const xmlChar*)"neb", (const xmlChar*)cineb.str().c_str());
1313  xmlNewProp(detlist, (const xmlChar*)"nstates", (const xmlChar*)nstates.str().c_str());
1314  xmlNewProp(detlist, (const xmlChar*)"cutoff", (const xmlChar*)ci_thr.str().c_str());
1315  if (CIcoeff.size() == 0)
1316  {
1317  std::cerr << " CI configuration list is empty. \n";
1318  exit(101);
1319  }
1320  if (CIcoeff.size() != CIalpha.size() || CIcoeff.size() != CIbeta.size())
1321  {
1322  std::cerr << " Problem with CI configuration lists. \n";
1323  exit(102);
1324  }
1325  int iv = 0;
1326  for (int i = 0; i < CIcoeff.size(); i++)
1327  {
1328  if (std::abs(CIcoeff[i]) > ci_threshold)
1329  {
1330  xmlNodePtr ci = xmlNewNode(NULL, (const xmlChar*)"ci");
1331  std::ostringstream coeff;
1332  std::ostringstream qc_coeff;
1333  qc_coeff << CIcoeff[i];
1334  if (zeroCI && i == 0)
1335  {
1336  coeff << 1.0;
1337  }
1338  else if (zeroCI && i > 0)
1339  {
1340  coeff << 0.0;
1341  }
1342  else
1343  {
1344  coeff << CIcoeff[i];
1345  }
1346  std::ostringstream tag;
1347  tag << "CIcoeff_" << iv++;
1348  xmlNewProp(ci, (const xmlChar*)"id", (const xmlChar*)tag.str().c_str());
1349  xmlNewProp(ci, (const xmlChar*)"coeff", (const xmlChar*)coeff.str().c_str());
1350  xmlNewProp(ci, (const xmlChar*)"qc_coeff", (const xmlChar*)qc_coeff.str().c_str());
1351  xmlNewProp(ci, (const xmlChar*)"alpha", (const xmlChar*)CIalpha[i].substr(0, ci_nstates).c_str());
1352  xmlNewProp(ci, (const xmlChar*)"beta", (const xmlChar*)CIbeta[i].substr(0, ci_nstates).c_str());
1353  xmlAddChild(detlist, ci);
1354  }
1355  }
1356  xmlAddChild(multislaterdet, detlist);
1357  } //usingCSF
1358  return multislaterdet;
1359 }
1360 
1361 void QMCGaussianParserBase::createCenterH5(int iat, int off_, int numelem)
1362 {
1363  CurrentCenter = GroupName[iat];
1364  int numbasisgroups(0);
1365  std::stringstream tempcenter;
1366  std::string CenterID;
1367  tempcenter << CurrentCenter << "";
1368  CenterID = tempcenter.str();
1369  std::stringstream tempElem;
1370  std::string ElemID0 = "atomicBasisSet", ElemID;
1371  tempElem << ElemID0 << numelem;
1372  ElemID = tempElem.str();
1373 
1374  hdf_archive hout;
1375  hout.open(h5file.c_str(), H5F_ACC_RDWR);
1376  hout.push("basisset");
1377  hout.push(ElemID.c_str(), true);
1378  hout.write(basisName, "name");
1379  hout.write(angular_type, "angular");
1380  hout.write(CenterID, "elementType");
1381  hout.write(expandYlm, "expandYlm");
1382  hout.write(Normalized, "normalized");
1383 
1384  double ValgridFirst(1.e-6), ValgridLast(1.e2);
1385  int Valnpts(1001);
1386  std::string gridType("log");
1387  double gridFirst(ValgridFirst);
1388  double gridLast(ValgridLast);
1389  int gridSize(Valnpts);
1390 
1391  hout.write(gridType, "grid_type");
1392  hout.write(gridFirst, "grid_ri");
1393  hout.write(gridLast, "grid_rf");
1394  hout.write(gridSize, "grid_npts");
1395 
1396  for (int ig = gBound[iat], n = 0; ig < gBound[iat + 1]; ig++, n++)
1397  {
1398  createShellH5(n, ig, off_, numelem);
1399  off_ += gNumber[ig];
1400  numbasisgroups = n + 1;
1401  }
1402 
1403  hout.write(numbasisgroups, "NbBasisGroups");
1404  hout.close();
1405 }
1406 
1407 
1408 xmlNodePtr QMCGaussianParserBase::createCenter(int iat, int off_)
1409 {
1410  CurrentCenter = GroupName[iat];
1411 
1412  xmlNodePtr abasis = xmlNewNode(NULL, (const xmlChar*)"atomicBasisSet");
1413  xmlNewProp(abasis, (const xmlChar*)"name", (const xmlChar*)basisName.c_str());
1414  //xmlNewProp(abasis,(const xmlChar*)"angular",(const xmlChar*)"spherical");
1415  xmlNewProp(abasis, (const xmlChar*)"angular", (const xmlChar*)angular_type.c_str());
1416  xmlNewProp(abasis, (const xmlChar*)"type", (const xmlChar*)basisType.c_str());
1417  xmlNewProp(abasis, (const xmlChar*)"elementType", (const xmlChar*)CurrentCenter.c_str());
1418  xmlNewProp(abasis, (const xmlChar*)"normalized", (const xmlChar*)Normalized.c_str());
1419  xmlAddChild(abasis, xmlCopyNode(gridPtr.get(), 1));
1420  for (int ig = gBound[iat], n = 0; ig < gBound[iat + 1]; ig++, n++)
1421  {
1422  createShell(n, ig, off_, abasis);
1423  off_ += gNumber[ig];
1424  }
1425  return abasis;
1426 }
1427 
1428 
1429 void QMCGaussianParserBase::createShellH5(int n, int ig, int off_, int numelem)
1430 {
1431  int gid(gShell[ig]);
1432  int ng(gNumber[ig]);
1433 
1434  std::array<char, 4> l_name;
1435  int l_len = std::snprintf(l_name.data(), l_name.size(), "%d", gShellID[gid]);
1436  if (l_len < 0)
1437  throw std::runtime_error("Error generating l_name");
1438  std::string al_name(l_name.data(), l_len);
1439 
1440  std::array<char, 4> n_name;
1441  int n_len = std::snprintf(n_name.data(), n_name.size(), "%d", n);
1442  if (n_len < 0)
1443  throw std::runtime_error("Error generating n_name");
1444  std::string an_name(n_name.data(), n_len);
1445 
1446  std::string aa_name = CurrentCenter;
1447  aa_name.append(an_name).append(al_name);
1448 
1449  std::string at_name("Gaussian");
1450  std::string basisGroupID = "basisGroup" + an_name;
1451 
1452  std::stringstream tempElem;
1453  std::string ElemID0 = "atomicBasisSet";
1454  tempElem << ElemID0 << numelem;
1455  std::string ElemID = tempElem.str();
1456 
1457  hdf_archive hout;
1458  hout.open(h5file, H5F_ACC_RDWR);
1459  hout.push("basisset");
1460  hout.push(ElemID);
1461  hout.push(basisGroupID, true);
1462  hout.write(aa_name, "rid");
1463  hout.write(n, "n");
1464  hout.write(gShellID[gid], "l");
1465  hout.write(at_name, "type");
1466  hout.write(ng, "NbRadFunc");
1467 
1468  hout.push("radfunctions", true);
1469 
1470  if (gid == 2)
1471  {
1472  std::string basisGroupID2 = "basisGroup2" + aa_name;
1473  std::string valac("1");
1474  hout.push(basisGroupID2.c_str(), true);
1475  hout.write(aa_name, "rid");
1476  hout.write(an_name, "n");
1477  hout.write(valac, "l");
1478  hout.write(at_name, "type");
1479  hout.write(ng, "NbRadFunc");
1480  hout.push("radfunctions2", true);
1481  hout.pop();
1482  hout.pop();
1483  }
1484 
1485  for (int ig = 0, i = off_; ig < ng; ig++, i++)
1486  {
1487  std::stringstream tempdata;
1488  std::string dataradID0 = "DataRad", dataradID;
1489  tempdata << dataradID0 << ig;
1490  dataradID = tempdata.str();
1491  hout.push(dataradID.c_str(), true);
1492  hout.write(gExp[i], "exponent");
1493  hout.write(gC0[i], "contraction");
1494  hout.pop();
1495  if (gid == 2)
1496  {
1497  std::string basisGroupID2 = "basisGroup2" + aa_name;
1498  hout.push(basisGroupID2.c_str());
1499  hout.push("radfunctions2");
1500  std::stringstream tempdata2;
1501  std::string datarad2ID0 = "DataRad2", datarad2ID;
1502  tempdata2 << datarad2ID0 << ig;
1503  datarad2ID = tempdata2.str();
1504  hout.push(datarad2ID.c_str(), true);
1505  hout.write(gExp[i], "exponent");
1506  hout.write(gC1[i], "contraction");
1507  hout.pop();
1508  hout.pop();
1509  }
1510  }
1511  hout.close();
1512 }
1513 
1514 
1515 void QMCGaussianParserBase::createShell(int n, int ig, int off_, xmlNodePtr abasis)
1516 {
1517  int gid(gShell[ig]);
1518  int ng(gNumber[ig]);
1519  xmlNodePtr ag = xmlNewNode(NULL, (const xmlChar*)"basisGroup");
1520  xmlNodePtr ag1 = 0;
1521 
1522  std::array<char, 4> l_name;
1523  int l_len = std::snprintf(l_name.data(), l_name.size(), "%d", gShellID[gid]);
1524  if (l_len < 0)
1525  throw std::runtime_error("Error generating l_name");
1526  std::string al_name(l_name.data(), l_len);
1527 
1528  std::array<char, 4> n_name;
1529  int n_len = std::snprintf(n_name.data(), n_name.size(), "%d", n);
1530  if (n_len < 0)
1531  throw std::runtime_error("Error generating n_name");
1532  std::string an_name(n_name.data(), n_len);
1533 
1534  std::string aa_name = CurrentCenter;
1535  aa_name.append(an_name).append(al_name);
1536 
1537  xmlNewProp(ag, (const xmlChar*)"rid", (const xmlChar*)aa_name.c_str());
1538  xmlNewProp(ag, (const xmlChar*)"n", (const xmlChar*)an_name.c_str());
1539  xmlNewProp(ag, (const xmlChar*)"l", (const xmlChar*)al_name.c_str());
1540  xmlNewProp(ag, (const xmlChar*)"type", (const xmlChar*)"Gaussian");
1541  if (gid == 2)
1542  {
1543  aa_name = CurrentCenter;
1544  aa_name.append(an_name);
1545  ag1 = xmlNewNode(NULL, (const xmlChar*)"basisGroup");
1546  xmlNewProp(ag1, (const xmlChar*)"rid", (const xmlChar*)aa_name.c_str());
1547  xmlNewProp(ag1, (const xmlChar*)"n", (const xmlChar*)an_name.c_str());
1548  xmlNewProp(ag1, (const xmlChar*)"l", (const xmlChar*)"1");
1549  xmlNewProp(ag1, (const xmlChar*)"type", (const xmlChar*)"Gaussian");
1550  }
1551  for (int ig = 0, i = off_; ig < ng; ig++, i++)
1552  {
1553  std::ostringstream a, b, c;
1554  a.setf(std::ios::scientific, std::ios::floatfield);
1555  b.setf(std::ios::scientific, std::ios::floatfield);
1556  a.precision(12);
1557  b.precision(12);
1558  a << gExp[i];
1559  b << gC0[i];
1560  xmlNodePtr anode = xmlNewNode(NULL, (const xmlChar*)"radfunc");
1561  xmlNewProp(anode, (const xmlChar*)"exponent", (const xmlChar*)a.str().c_str());
1562  xmlNewProp(anode, (const xmlChar*)"contraction", (const xmlChar*)b.str().c_str());
1563  xmlAddChild(ag, anode);
1564  if (gid == 2)
1565  {
1566  c.setf(std::ios::scientific, std::ios::floatfield);
1567  c.precision(12);
1568  c << gC1[i];
1569  anode = xmlNewNode(NULL, (const xmlChar*)"radfunc");
1570  xmlNewProp(anode, (const xmlChar*)"exponent", (const xmlChar*)a.str().c_str());
1571  xmlNewProp(anode, (const xmlChar*)"contraction", (const xmlChar*)c.str().c_str());
1572  xmlAddChild(ag1, anode);
1573  }
1574  }
1575  xmlAddChild(abasis, ag);
1576  if (gid == 2)
1577  xmlAddChild(abasis, ag1);
1578 }
1579 
1580 
1582 {
1583  xmlNodePtr j3 = xmlNewNode(NULL, (const xmlChar*)"jastrow");
1584  xmlNewProp(j3, (const xmlChar*)"name", (const xmlChar*)"J3");
1585  xmlNewProp(j3, (const xmlChar*)"type", (const xmlChar*)"eeI");
1586  xmlNewProp(j3, (const xmlChar*)"function", (const xmlChar*)"polynomial");
1587  xmlNewProp(j3, (const xmlChar*)"source", (const xmlChar*)"ion0");
1588  xmlNewProp(j3, (const xmlChar*)"print", (const xmlChar*)"yes");
1589  SpeciesSet& ionSpecies(IonSystem.getSpeciesSet());
1590  for (int i = 0; i < ionSpecies.getTotalNum(); i++)
1591  {
1592  xmlNodePtr uuc = xmlNewNode(NULL, (const xmlChar*)"correlation");
1593  xmlNewProp(uuc, (const xmlChar*)"ispecies", (const xmlChar*)ionSpecies.speciesName[i].c_str());
1594  xmlNewProp(uuc, (const xmlChar*)"especies", (const xmlChar*)"u");
1595  xmlNewProp(uuc, (const xmlChar*)"isize", (const xmlChar*)"3");
1596  xmlNewProp(uuc, (const xmlChar*)"esize", (const xmlChar*)"3");
1597  if (!PBC)
1598  xmlNewProp(uuc, (const xmlChar*)"rcut", (const xmlChar*)"5");
1599 
1600  xmlNodePtr a = xmlNewTextChild(uuc, NULL, (const xmlChar*)"coefficients", (const xmlChar*)"\n ");
1601  std::ostringstream o1;
1602  o1 << "uu" << ionSpecies.speciesName[i];
1603  xmlNewProp(a, (const xmlChar*)"id", (const xmlChar*)o1.str().c_str());
1604  xmlNewProp(a, (const xmlChar*)"type", (const xmlChar*)"Array");
1605  xmlNewProp(a, (const xmlChar*)"optimize", (const xmlChar*)"yes");
1606  xmlAddChild(j3, uuc);
1607 
1608  if (!isSpinor)
1609  {
1610  xmlNodePtr udc = xmlNewNode(NULL, (const xmlChar*)"correlation");
1611  xmlNewProp(udc, (const xmlChar*)"ispecies", (const xmlChar*)ionSpecies.speciesName[i].c_str());
1612  xmlNewProp(udc, (const xmlChar*)"especies1", (const xmlChar*)"u");
1613  xmlNewProp(udc, (const xmlChar*)"especies2", (const xmlChar*)"d");
1614  xmlNewProp(udc, (const xmlChar*)"isize", (const xmlChar*)"3");
1615  xmlNewProp(udc, (const xmlChar*)"esize", (const xmlChar*)"3");
1616  if (!PBC)
1617  xmlNewProp(udc, (const xmlChar*)"rcut", (const xmlChar*)"5");
1618 
1619  xmlNodePtr b = xmlNewTextChild(udc, NULL, (const xmlChar*)"coefficients", (const xmlChar*)"\n ");
1620  std::ostringstream o2;
1621  o2 << "ud" << ionSpecies.speciesName[i];
1622  xmlNewProp(b, (const xmlChar*)"id", (const xmlChar*)o2.str().c_str());
1623  xmlNewProp(b, (const xmlChar*)"type", (const xmlChar*)"Array");
1624  xmlNewProp(b, (const xmlChar*)"optimize", (const xmlChar*)"yes");
1625  xmlAddChild(j3, udc);
1626  }
1627  }
1628  return j3;
1629 }
1630 
1632 {
1633  xmlNodePtr j2 = xmlNewNode(NULL, (const xmlChar*)"jastrow");
1634  xmlNewProp(j2, (const xmlChar*)"name", (const xmlChar*)"J2");
1635  xmlNewProp(j2, (const xmlChar*)"type", (const xmlChar*)"Two-Body");
1636  xmlNewProp(j2, (const xmlChar*)"function", (const xmlChar*)"Bspline");
1637  xmlNewProp(j2, (const xmlChar*)"print", (const xmlChar*)"yes");
1638  if (NumberOfAlpha > 1 || NumberOfBeta > 1)
1639  {
1640  xmlNodePtr uu = xmlNewNode(NULL, (const xmlChar*)"correlation");
1641  if (!PBC)
1642  xmlNewProp(uu, (const xmlChar*)"rcut", (const xmlChar*)"10");
1643  xmlNewProp(uu, (const xmlChar*)"size", (const xmlChar*)"10");
1644  xmlNewProp(uu, (const xmlChar*)"speciesA", (const xmlChar*)"u");
1645  xmlNewProp(uu, (const xmlChar*)"speciesB", (const xmlChar*)"u");
1646  xmlNodePtr a = xmlNewTextChild(uu, NULL, (const xmlChar*)"coefficients",
1647  (const xmlChar*)"0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0");
1648  xmlNewProp(a, (const xmlChar*)"id", (const xmlChar*)"uu");
1649  xmlNewProp(a, (const xmlChar*)"type", (const xmlChar*)"Array");
1650  xmlAddChild(j2, uu);
1651  }
1652  if (NumberOfAlpha > 0 && NumberOfBeta > 0)
1653  {
1654  xmlNodePtr uu = xmlNewNode(NULL, (const xmlChar*)"correlation");
1655  if (!PBC)
1656  xmlNewProp(uu, (const xmlChar*)"rcut", (const xmlChar*)"10");
1657  xmlNewProp(uu, (const xmlChar*)"size", (const xmlChar*)"10");
1658  xmlNewProp(uu, (const xmlChar*)"speciesA", (const xmlChar*)"u");
1659  xmlNewProp(uu, (const xmlChar*)"speciesB", (const xmlChar*)"d");
1660  //xmlNodePtr a = xmlNewNode(NULL,(const xmlChar*)"coefficients");
1661  xmlNodePtr a = xmlNewTextChild(uu, NULL, (const xmlChar*)"coefficients",
1662  (const xmlChar*)"0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0");
1663  xmlNewProp(a, (const xmlChar*)"id", (const xmlChar*)"ud");
1664  xmlNewProp(a, (const xmlChar*)"type", (const xmlChar*)"Array");
1665  // xmlAddChild(uu,a);
1666  xmlAddChild(j2, uu);
1667  }
1668  return j2;
1669 }
1670 
1672 {
1673  xmlNodePtr j1 = xmlNewNode(NULL, (const xmlChar*)"jastrow");
1674  xmlNewProp(j1, (const xmlChar*)"name", (const xmlChar*)"J1");
1675  xmlNewProp(j1, (const xmlChar*)"type", (const xmlChar*)"One-Body");
1676  xmlNewProp(j1, (const xmlChar*)"function", (const xmlChar*)"Bspline");
1677  xmlNewProp(j1, (const xmlChar*)"source", (const xmlChar*)"ion0");
1678  xmlNewProp(j1, (const xmlChar*)"print", (const xmlChar*)"yes");
1679  SpeciesSet& ionSpecies(IonSystem.getSpeciesSet());
1680  for (int i = 0; i < ionSpecies.getTotalNum(); i++)
1681  {
1682  xmlNodePtr c = xmlNewNode(NULL, (const xmlChar*)"correlation");
1683  if (!PBC)
1684  xmlNewProp(c, (const xmlChar*)"rcut", (const xmlChar*)"10");
1685  xmlNewProp(c, (const xmlChar*)"size", (const xmlChar*)"10");
1686  xmlNewProp(c, (const xmlChar*)"cusp", (const xmlChar*)"0");
1687  xmlNewProp(c, (const xmlChar*)"elementType", (const xmlChar*)ionSpecies.speciesName[i].c_str());
1688  xmlNodePtr a = xmlNewTextChild(c, NULL, (const xmlChar*)"coefficients",
1689  (const xmlChar*)"0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0");
1690  std::ostringstream o;
1691  o << 'e' << ionSpecies.speciesName[i];
1692  xmlNewProp(a, (const xmlChar*)"id", (const xmlChar*)o.str().c_str());
1693  xmlNewProp(a, (const xmlChar*)"type", (const xmlChar*)"Array");
1694  xmlAddChild(j1, c);
1695  }
1696  return j1;
1697 }
1698 
1699 void QMCGaussianParserBase::createGridNode(int argc, char** argv)
1700 {
1701  gridPtr = std::unique_ptr<xmlNode, void (*)(xmlNodePtr)>(xmlNewNode(NULL, (const xmlChar*)"grid"), xmlFreeNode);
1702  std::string gridType("log");
1703  std::string gridFirst("1.e-6");
1704  std::string gridLast("1.e2");
1705  std::string gridSize("1001");
1706  int iargc = 0;
1707  while (iargc < argc)
1708  {
1709  std::string a(argv[iargc]);
1710  if (a == "-gridtype")
1711  {
1712  gridType = argv[++iargc];
1713  }
1714  else if (a == "-frst")
1715  {
1716  gridFirst = argv[++iargc];
1717  }
1718  else if (a == "-last")
1719  {
1720  gridLast = argv[++iargc];
1721  }
1722  else if (a == "-size")
1723  {
1724  gridSize = argv[++iargc];
1725  }
1726  else if (a == "-numMO")
1727  {
1728  numMO2print = atoi(argv[++iargc]);
1729  }
1730  ++iargc;
1731  }
1732  xmlNewProp(gridPtr.get(), (const xmlChar*)"type", (const xmlChar*)gridType.c_str());
1733  xmlNewProp(gridPtr.get(), (const xmlChar*)"ri", (const xmlChar*)gridFirst.c_str());
1734  xmlNewProp(gridPtr.get(), (const xmlChar*)"rf", (const xmlChar*)gridLast.c_str());
1735  xmlNewProp(gridPtr.get(), (const xmlChar*)"npts", (const xmlChar*)gridSize.c_str());
1736 }
1737 
1738 void QMCGaussianParserBase::dump(const std::string& psi_tag, const std::string& ion_tag)
1739 {
1740  std::cout << " QMCGaussianParserBase::dump " << std::endl;
1741  if (!Structure)
1742  {
1743  //if (UseHDF5 || multidetH5)
1744  if (UseHDF5)
1745  {
1746  bool IsComplex = (isSpinor) ? true : false;
1747  hdf_archive hout;
1748  hout.create(h5file.c_str(), H5F_ACC_TRUNC);
1749  hout.push("PBC", true);
1750  hout.write(PBC, "PBC");
1751  hout.pop();
1752  //Adding generic code name to the H5 file.
1753  std::string CodeName("generic");
1754  hout.push("application", true);
1755  hout.write(CodeName, "code");
1756  hout.pop();
1757  hout.push("parameters", true);
1758  hout.write(ECP, "ECP");
1759  //Assumes MO-Coeff always real as this path is only for molecules and for generating stand alone H5file.
1760  hout.write(IsComplex, "IsComplex");
1761  hout.write(multideterminant, "Multidet");
1762  hout.write(NumberOfAlpha, "NbAlpha");
1763  hout.write(NumberOfBeta, "NbBeta");
1764  hout.write(NumberOfEls, "NbTotElec");
1765  hout.write(SpinRestricted, "SpinRestricted");
1766  hout.write(BohrUnit, "Unit");
1767  hout.write(numMO, "numAO");
1768  hout.write(numMO, "numMO");
1769  hout.write(SpinMultiplicity, "spin");
1770  hout.pop();
1771  hout.close();
1772  }
1773 
1774  xmlDocPtr doc_p = xmlNewDoc((const xmlChar*)"1.0");
1775  xmlNodePtr qm_root_p = xmlNewNode(NULL, BAD_CAST "qmcsystem");
1776  if (PBC)
1777  {
1778  app_log()
1779  << "ABORT::THIS IS NOT SUPPOSED TO HAPPEN. PBC are ON but you are not in an HDF5 path. Contact developers"
1780  << std::endl;
1781  exit(0);
1782  // xmlAddChild(qm_root_p, createCell());
1783  }
1784  auto ionSet = createIonSet();
1785  if (ionSet != nullptr)
1786  {
1787  xmlAddChild(qm_root_p, ionSet);
1788  xmlAddChild(qm_root_p, createElectronSet(ion_tag));
1789  xmlDocSetRootElement(doc_p, qm_root_p);
1790  std::string fname = Title + ".structure.xml";
1791  xmlSaveFormatFile(fname.c_str(), doc_p, 1);
1792  xmlFreeDoc(doc_p);
1793  }
1794  else
1795  {
1796  xmlFreeNode(qm_root_p);
1797  xmlFreeDoc(doc_p);
1798  throw std::runtime_error("convert4qmc: IonSet creation failed in QMCGaussianParserBase::dump, check out of "
1799  "bounds for valence calculation\n");
1800  }
1801  Structure = true;
1802  }
1803  xmlDocPtr doc = xmlNewDoc((const xmlChar*)"1.0");
1804  xmlNodePtr qm_root = xmlNewNode(NULL, BAD_CAST "qmcsystem");
1805  {
1806  //wavefunction
1807  xmlNodePtr wfPtr = xmlNewNode(NULL, (const xmlChar*)"wavefunction");
1808  xmlNewProp(wfPtr, (const xmlChar*)"name", (const xmlChar*)psi_tag.c_str());
1809  xmlNewProp(wfPtr, (const xmlChar*)"target", (const xmlChar*)"e");
1810  {
1811  xmlNodePtr detPtr = xmlNewNode(NULL, (const xmlChar*)"determinantset");
1812  xmlNewProp(detPtr, (const xmlChar*)"type", (const xmlChar*)"MolecularOrbital");
1813  xmlNewProp(detPtr, (const xmlChar*)"name", (const xmlChar*)"LCAOBSet");
1814  xmlNewProp(detPtr, (const xmlChar*)"source", (const xmlChar*)ion_tag.c_str());
1815  xmlNewProp(detPtr, (const xmlChar*)"transform", (const xmlChar*)"yes");
1816 
1817  if (DoCusp == true)
1818  xmlNewProp(detPtr, (const xmlChar*)"cuspCorrection", (const xmlChar*)"yes");
1819  if (UseHDF5 || singledetH5)
1820  xmlNewProp(detPtr, (const xmlChar*)"href", (const xmlChar*)h5file.c_str());
1821  //BASISSET
1822  {
1823  if (UseHDF5)
1824  {
1825  xmlNodePtr bsetPtr = createBasisSetWithHDF5();
1826  xmlFreeNode(bsetPtr);
1827  }
1828  else
1829  {
1830  if (!singledetH5)
1831  {
1832  xmlNodePtr bsetPtr = createBasisSet();
1833  xmlAddChild(detPtr, bsetPtr);
1834  }
1835  }
1836  if (multideterminant)
1837  {
1838  xmlNodePtr spoupPtr = xmlNewNode(NULL, (const xmlChar*)"sposet");
1839  xmlNewProp(spoupPtr, (const xmlChar*)"basisset", (const xmlChar*)"LCAOBSet");
1840  xmlNodePtr spodnPtr = xmlNewNode(NULL, (const xmlChar*)"sposet");
1841  xmlNewProp(spodnPtr, (const xmlChar*)"basisset", (const xmlChar*)"LCAOBSet");
1842  if (multidetH5)
1843  {
1844  PrepareSPOSetsFromH5(spoupPtr, spodnPtr);
1845  xmlAddChild(detPtr, spoupPtr);
1846  xmlAddChild(detPtr, spodnPtr);
1847  xmlNodePtr multislaterdetPtr = NULL;
1848  multislaterdetPtr = createMultiDeterminantSetFromH5();
1849  xmlAddChild(detPtr, multislaterdetPtr);
1850  }
1851  else
1852  {
1853  if (UseHDF5)
1854  {
1855  createSPOSetsH5(spoupPtr, spodnPtr);
1856  xmlAddChild(detPtr, spoupPtr);
1857  //for spinors, we don't need the spodn so just free it
1858  if (isSpinor)
1859  xmlFreeNode(spodnPtr);
1860  else
1861  xmlAddChild(detPtr, spodnPtr);
1862  xmlNodePtr multislaterdetPtr = NULL;
1863  if (usingCSF)
1864  {
1865  app_log() << "Warning: CSF in HDF5 not implemented. Will attempt to revert multideterminant to xml. It "
1866  "is recommended to verify input for accuracy or avoid using -hdf5"
1867  << std::endl;
1868  multislaterdetPtr = createMultiDeterminantSet();
1869  }
1870  else
1871  multislaterdetPtr = createMultiDeterminantSetCIHDF5();
1872  xmlAddChild(detPtr, multislaterdetPtr);
1873  }
1874  else
1875  {
1876  createSPOSets(spoupPtr, spodnPtr);
1877  xmlAddChild(detPtr, spoupPtr);
1878  xmlAddChild(detPtr, spodnPtr);
1879  xmlNodePtr multislaterdetPtr = NULL;
1880  multislaterdetPtr = createMultiDeterminantSet();
1881  xmlAddChild(detPtr, multislaterdetPtr);
1882  }
1883  }
1884  }
1885  else
1886  {
1887  xmlNodePtr slaterdetPtr = NULL;
1888  if (UseHDF5)
1889  {
1890  slaterdetPtr = createDeterminantSetWithHDF5();
1891  }
1892  else
1893  {
1894  if (singledetH5)
1895  slaterdetPtr = PrepareDeterminantSetFromHDF5();
1896  else
1897  slaterdetPtr = createDeterminantSet();
1898  }
1899  xmlAddChild(detPtr, slaterdetPtr);
1900  }
1901  }
1902  xmlAddChild(wfPtr, detPtr);
1903  if (addJastrow)
1904  {
1905  std::cout << R"(Adding Two-Body and One-Body jastrows with rcut="10" and size="10")" << std::endl;
1906  if (NumberOfEls > 1)
1907  {
1908  xmlAddChild(wfPtr, createJ2());
1909  }
1910  xmlAddChild(wfPtr, createJ1());
1911  if (NumberOfEls > 1)
1912  {
1913  std::cout << "Adding Three-Body jastrows with rcut=\"5\"" << std::endl;
1914  xmlAddChild(wfPtr, createJ3());
1915  }
1916  }
1917  }
1918  xmlAddChild(qm_root, wfPtr);
1919  }
1920  xmlDocSetRootElement(doc, qm_root);
1921  std::string fname = Title + ".wf" + WFS_name + ".xml";
1922  xmlSaveFormatFile(fname.c_str(), doc, 1);
1923  xmlFreeDoc(doc);
1924  if (numMO * SizeOfBasisSet >= 4000 && !UseHDF5)
1925  if (!singledetH5)
1926  std::cout << "Consider using HDF5 via -hdf5 for higher performance and smaller wavefunction files" << std::endl;
1927 }
1928 
1929 void QMCGaussianParserBase::dumpPBC(const std::string& psi_tag, const std::string& ion_tag)
1930 {
1931  std::cout << " QMCGaussianParserBase::dumpPBC " << std::endl;
1932  if (!Structure)
1933  {
1934  xmlDocPtr doc_p = xmlNewDoc((const xmlChar*)"1.0");
1935  xmlNodePtr qm_root_p = xmlNewNode(NULL, BAD_CAST "qmcsystem");
1936  if (PBC)
1937  xmlAddChild(qm_root_p, createCell());
1938 
1939  auto ionSet = createIonSet();
1940  if (ionSet != nullptr)
1941  {
1942  xmlAddChild(qm_root_p, ionSet);
1943  xmlAddChild(qm_root_p, createElectronSet(ion_tag));
1944  xmlDocSetRootElement(doc_p, qm_root_p);
1945  std::string fname = Title + ".structure.xml";
1946  xmlSaveFormatFile(fname.c_str(), doc_p, 1);
1947  xmlFreeDoc(doc_p);
1948  }
1949  else
1950  {
1951  xmlFreeNode(qm_root_p);
1952  xmlFreeDoc(doc_p);
1953  throw std::runtime_error("convert4qmc: IonSet creation failed in QMCGaussianParserBase::dumpPBC, check out of "
1954  "bounds for valence calculation\n");
1955  }
1956  Structure = true;
1957  }
1958  xmlDocPtr doc = xmlNewDoc((const xmlChar*)"1.0");
1959  xmlNodePtr qm_root = xmlNewNode(NULL, BAD_CAST "qmcsystem");
1960  {
1961  //wavefunction
1962  xmlNodePtr wfPtr = xmlNewNode(NULL, (const xmlChar*)"wavefunction");
1963  xmlNewProp(wfPtr, (const xmlChar*)"name", (const xmlChar*)psi_tag.c_str());
1964  xmlNewProp(wfPtr, (const xmlChar*)"target", (const xmlChar*)"e");
1965  {
1966  xmlNodePtr detPtr = xmlNewNode(NULL, (const xmlChar*)"determinantset");
1967  xmlNewProp(detPtr, (const xmlChar*)"type", (const xmlChar*)"MolecularOrbital");
1968  xmlNewProp(detPtr, (const xmlChar*)"name", (const xmlChar*)"LCAOBSet");
1969  xmlNewProp(detPtr, (const xmlChar*)"source", (const xmlChar*)ion_tag.c_str());
1970  xmlNewProp(detPtr, (const xmlChar*)"transform", (const xmlChar*)"yes");
1971 
1972  std::stringstream ss;
1973  ss << std::setprecision(10) << STwist_Coord[0] << " " << std::setprecision(10) << STwist_Coord[1] << " "
1974  << std::setprecision(10) << STwist_Coord[2];
1975  xmlNewProp(detPtr, (const xmlChar*)"twist", (const xmlChar*)(ss.str()).c_str());
1976 
1977  if (DoCusp == true)
1978  xmlNewProp(detPtr, (const xmlChar*)"cuspCorrection", (const xmlChar*)"yes");
1979 
1980  xmlNewProp(detPtr, (const xmlChar*)"href", (const xmlChar*)h5file.c_str());
1981 
1982  std::stringstream sss;
1983  sss << Image[0] << " " << Image[1] << " " << Image[2];
1984  xmlNewProp(detPtr, (const xmlChar*)"PBCimages", (const xmlChar*)(sss.str()).c_str());
1985 
1986  {
1987  if (multideterminant)
1988  {
1989  xmlNodePtr spoupPtr = xmlNewNode(NULL, (const xmlChar*)"sposet");
1990  xmlNodePtr spodnPtr = xmlNewNode(NULL, (const xmlChar*)"sposet");
1991  xmlNewProp(spoupPtr, (const xmlChar*)"basisset", (const xmlChar*)"LCAOBSet");
1992  xmlNewProp(spodnPtr, (const xmlChar*)"basisset", (const xmlChar*)"LCAOBSet");
1993 
1994  PrepareSPOSetsFromH5(spoupPtr, spodnPtr);
1995  xmlAddChild(detPtr, spoupPtr);
1996  xmlAddChild(detPtr, spodnPtr);
1997  xmlNodePtr multislaterdetPtr = NULL;
1998 
1999  multislaterdetPtr = createMultiDeterminantSetFromH5();
2000 
2001 
2002  xmlAddChild(detPtr, multislaterdetPtr);
2003  }
2004  else
2005  {
2006  xmlNodePtr slaterdetPtr = NULL;
2007  slaterdetPtr = PrepareDeterminantSetFromHDF5();
2008  xmlAddChild(detPtr, slaterdetPtr);
2009  }
2010  }
2011  xmlAddChild(wfPtr, detPtr);
2012  if (addJastrow)
2013  {
2014  std::cout << R"(Adding Two-Body and One-Body jastrows with rcut="10" and size="10")" << std::endl;
2015  if (NumberOfEls > 1)
2016  {
2017  xmlAddChild(wfPtr, createJ2());
2018  }
2019  xmlAddChild(wfPtr, createJ1());
2020  if (NumberOfEls > 1)
2021  {
2022  std::cout << "Adding Three-Body jastrows with rcut=\"5\"" << std::endl;
2023  xmlAddChild(wfPtr, createJ3());
2024  }
2025  }
2026  }
2027  xmlAddChild(qm_root, wfPtr);
2028  }
2029  xmlDocSetRootElement(doc, qm_root);
2030  std::string fname = Title + ".wf" + WFS_name + ".xml";
2031  xmlSaveFormatFile(fname.c_str(), doc, 1);
2032  xmlFreeDoc(doc);
2033 }
2034 
2035 
2036 void QMCGaussianParserBase::dumpStdInputProd(const std::string& psi_tag, const std::string& ion_tag)
2037 {
2038  std::cout << " Generating production input file designed for large calculations." << std::endl;
2039  std::cout << " Modify according to the accuracy you would like to achieve. " << std::endl;
2040 
2041  std::string fname = Title + ".qmc.in-wf" + WFS_name + ".xml";
2042 
2043  xmlDocPtr doc_input = xmlNewDoc((const xmlChar*)"1.0");
2044  xmlNodePtr qm_root_input = xmlNewNode(NULL, BAD_CAST "simulation");
2045 
2046  ///Adding Project id
2047  {
2048  xmlNodePtr project = xmlNewNode(NULL, (const xmlChar*)"project");
2049  xmlNewProp(project, (const xmlChar*)"id", (const xmlChar*)Title.c_str());
2050  xmlNewProp(project, (const xmlChar*)"series", (const xmlChar*)"0");
2051  xmlAddChild(qm_root_input, project);
2052  }
2053 
2054  ///Adding Link to Partcle Set and Wave function
2055  {
2056  std::string Ptclname = Title + ".structure.xml";
2057  xmlNodePtr ptcl = xmlNewNode(NULL, (const xmlChar*)"include");
2058  xmlNewProp(ptcl, (const xmlChar*)"href", (const xmlChar*)Ptclname.c_str());
2059  xmlAddChild(qm_root_input, ptcl);
2060 
2061  std::string Wfsname = Title + ".wf" + WFS_name + ".xml";
2062  xmlNodePtr wfs = xmlNewNode(NULL, (const xmlChar*)"include");
2063  xmlNewProp(wfs, (const xmlChar*)"href", (const xmlChar*)Wfsname.c_str());
2064  xmlAddChild(qm_root_input, wfs);
2065  }
2066 
2067  ///Adding Hamiltonian
2068  {
2069  xmlAddChild(qm_root_input, createHamiltonian(ion_tag, psi_tag));
2070  }
2071  ///Adding Optimization Block based on One Shift Only
2072  if (addJastrow)
2073  {
2074  ///Adding a VMC Block to help equilibrate
2075  xmlNodePtr initvmc = xmlNewNode(NULL, (const xmlChar*)"qmc");
2076  xmlNewProp(initvmc, (const xmlChar*)"method", (const xmlChar*)"vmc");
2077  xmlNewProp(initvmc, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2078  xmlNewProp(initvmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1");
2079  //xmlNewProp(initvmc,(const xmlChar*)"gpu", (const xmlChar*)"no");
2080  {
2081  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2082  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2083  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2084  xmlAddChild(initvmc, estimator);
2085 
2086  xmlAddChild(initvmc, parameter(initvmc, "walkers", "1"));
2087  xmlAddChild(initvmc, parameter(initvmc, "samplesperthread", "1"));
2088  xmlAddChild(initvmc, parameter(initvmc, "stepsbetweensamples", "10"));
2089  xmlAddChild(initvmc, parameter(initvmc, "substeps", "5"));
2090  xmlAddChild(initvmc, parameter(initvmc, "warmupSteps", "20"));
2091  xmlAddChild(initvmc, parameter(initvmc, "blocks", "10"));
2092  xmlAddChild(initvmc, parameter(initvmc, "timestep", "0.5"));
2093  xmlAddChild(initvmc, parameter(initvmc, "usedrift", "no"));
2094  }
2095  xmlAddChild(qm_root_input, initvmc);
2096 
2097 
2098  ///Adding First loop of Cheap optimization blocks
2099  xmlNodePtr loopopt1 = xmlNewNode(NULL, (const xmlChar*)"loop");
2100  xmlNewProp(loopopt1, (const xmlChar*)"max", (const xmlChar*)"4");
2101  {
2102  xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc");
2103  xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear");
2104  xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2105  xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1");
2106  //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no");
2107  {
2108  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2109  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2110  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2111  xmlAddChild(initopt, estimator);
2112 
2113  xmlAddChild(initopt, parameter(initopt, "blocks", "20"));
2114  xmlAddChild(initopt, parameter(initopt, "warmupSteps", "2"));
2115  xmlAddChild(initopt, parameter(initopt, "timestep", "0.5"));
2116  xmlAddChild(initopt, parameter(initopt, "walkers", "1"));
2117  xmlAddChild(initopt, parameter(initopt, "samples", "80000"));
2118  xmlAddChild(initopt, parameter(initopt, "substeps", "5"));
2119  xmlAddChild(initopt, parameter(initopt, "usedrift", "no"));
2120  xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly"));
2121  xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.1"));
2122  }
2123  xmlAddChild(loopopt1, initopt);
2124  }
2125  xmlAddChild(qm_root_input, loopopt1);
2126 
2127  ///Adding loop for optimization blocks
2128  xmlNodePtr loopopt = xmlNewNode(NULL, (const xmlChar*)"loop");
2129  xmlNewProp(loopopt, (const xmlChar*)"max", (const xmlChar*)"10");
2130  {
2131  xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc");
2132  xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear");
2133  xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2134  xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1");
2135  //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no");
2136  {
2137  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2138  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2139  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2140  xmlAddChild(initopt, estimator);
2141 
2142  xmlAddChild(initopt, parameter(initopt, "blocks", "40"));
2143  xmlAddChild(initopt, parameter(initopt, "warmupSteps", "5"));
2144  xmlAddChild(initopt, parameter(initopt, "timestep", "0.5"));
2145  xmlAddChild(initopt, parameter(initopt, "walkers", "1"));
2146  xmlAddChild(initopt, parameter(initopt, "samples", "160000"));
2147  xmlAddChild(initopt, parameter(initopt, "substeps", "5"));
2148  xmlAddChild(initopt, parameter(initopt, "usedrift", "no"));
2149  xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly"));
2150  xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.5"));
2151  }
2152  xmlAddChild(loopopt, initopt);
2153  }
2154  xmlAddChild(qm_root_input, loopopt);
2155  }
2156 
2157 
2158  ///Adding a VMC Block to the Input
2159  xmlNodePtr vmc = xmlNewNode(NULL, (const xmlChar*)"qmc");
2160  xmlNewProp(vmc, (const xmlChar*)"method", (const xmlChar*)"vmc");
2161  xmlNewProp(vmc, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2162  xmlNewProp(vmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1");
2163  //xmlNewProp(vmc,(const xmlChar*)"gpu", (const xmlChar*)"no");
2164  {
2165  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2166  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2167  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2168  xmlAddChild(vmc, estimator);
2169 
2170  xmlAddChild(vmc, parameter(vmc, "walkers", "1"));
2171  xmlAddChild(vmc, parameter(vmc, "samplesperthread", "1"));
2172  xmlAddChild(vmc, parameter(vmc, "stepsbetweensamples", "10"));
2173  xmlAddChild(vmc, parameter(vmc, "substeps", "30"));
2174  xmlAddChild(vmc, parameter(vmc, "warmupSteps", "100"));
2175  xmlAddChild(vmc, parameter(vmc, "blocks", "200"));
2176  xmlAddChild(vmc, parameter(vmc, "timestep", "0.1"));
2177  xmlAddChild(vmc, parameter(vmc, "usedrift", "no"));
2178  }
2179  xmlAddChild(qm_root_input, vmc);
2180 
2181  ///Adding a DMC Block to the Input
2182  xmlNodePtr dmc = xmlNewNode(NULL, (const xmlChar*)"qmc");
2183  xmlNewProp(dmc, (const xmlChar*)"method", (const xmlChar*)"dmc");
2184  xmlNewProp(dmc, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2185  xmlNewProp(dmc, (const xmlChar*)"checkpoint", (const xmlChar*)"20");
2186  //xmlNewProp(dmc,(const xmlChar*)"gpu", (const xmlChar*)"no");
2187  {
2188  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2189  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2190  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2191  xmlAddChild(dmc, estimator);
2192 
2193  xmlAddChild(dmc, parameter(dmc, "targetwalkers", "16000"));
2194  xmlAddChild(dmc, parameter(dmc, "reconfiguration", "no"));
2195  xmlAddChild(dmc, parameter(dmc, "warmupSteps", "100"));
2196  xmlAddChild(dmc, parameter(dmc, "timestep", "0.0005"));
2197  xmlAddChild(dmc, parameter(dmc, "steps", "30"));
2198  xmlAddChild(dmc, parameter(dmc, "blocks", "1000"));
2199  xmlAddChild(dmc, parameter(dmc, "nonlocalmoves", "v3"));
2200  }
2201  xmlAddChild(qm_root_input, dmc);
2202 
2203  xmlDocSetRootElement(doc_input, qm_root_input);
2204  xmlSaveFormatFile(fname.c_str(), doc_input, 1);
2205  xmlFreeDoc(doc_input);
2206 }
2207 
2208 void QMCGaussianParserBase::dumpStdInput(const std::string& psi_tag, const std::string& ion_tag)
2209 {
2210  std::cout << " Generating Standard Input file containing VMC, standard optmization, and DMC blocks." << std::endl;
2211  std::cout << " Modify according to the accuracy you would like to achieve. " << std::endl;
2212 
2213  std::string fname = Title + ".qmc.in-wf" + WFS_name + ".xml";
2214 
2215  xmlDocPtr doc_input = xmlNewDoc((const xmlChar*)"1.0");
2216  xmlNodePtr qm_root_input = xmlNewNode(NULL, BAD_CAST "simulation");
2217 
2218  std::ostringstream Comment;
2219  ///Adding Project id
2220  {
2221  Comment.str("");
2222  Comment.clear();
2223  Comment << "\n \nExample QMCPACK input file produced by convert4qmc\n \nIt is recommend to start with only the "
2224  "initial VMC block and adjust\nparameters based on the measured energies, variance, and statistics.\n\n";
2225  xmlNodePtr MyComment = xmlNewComment((const xmlChar*)Comment.str().c_str());
2226  xmlAddChild(qm_root_input, MyComment);
2227  Comment.str("");
2228  Comment.clear();
2229  Comment << "Name and Series number of the project.";
2230  MyComment = xmlNewComment((const xmlChar*)Comment.str().c_str());
2231  xmlAddChild(qm_root_input, MyComment);
2232 
2233  xmlNodePtr project = xmlNewNode(NULL, (const xmlChar*)"project");
2234  xmlNewProp(project, (const xmlChar*)"id", (const xmlChar*)Title.c_str());
2235  xmlNewProp(project, (const xmlChar*)"series", (const xmlChar*)"0");
2236  xmlAddChild(qm_root_input, project);
2237  }
2238 
2239  ///Adding Link to Partcle Set and Wave function
2240  {
2241  Comment.str("");
2242  Comment.clear();
2243  Comment << "Link to the location of the Atomic Coordinates and the location of the Wavefunction.";
2244  xmlNodePtr MyComment = xmlNewComment((const xmlChar*)Comment.str().c_str());
2245  xmlAddChild(qm_root_input, MyComment);
2246  std::string Ptclname = Title + ".structure.xml";
2247  xmlNodePtr ptcl = xmlNewNode(NULL, (const xmlChar*)"include");
2248  xmlNewProp(ptcl, (const xmlChar*)"href", (const xmlChar*)Ptclname.c_str());
2249  xmlAddChild(qm_root_input, ptcl);
2250 
2251  std::string Wfsname = Title + ".wf" + WFS_name + ".xml";
2252  xmlNodePtr wfs = xmlNewNode(NULL, (const xmlChar*)"include");
2253  xmlNewProp(wfs, (const xmlChar*)"href", (const xmlChar*)Wfsname.c_str());
2254  xmlAddChild(qm_root_input, wfs);
2255  }
2256 
2257  ///Adding Hamiltonian
2258  {
2259  Comment.str("");
2260  Comment.clear();
2261  if (ECP == true)
2262  Comment << "Hamiltonian of the system. Default ECP filenames are assumed.";
2263  else
2264  Comment << "Hamiltonian of the system.\n";
2265 
2266  xmlNodePtr MyComment = xmlNewComment((const xmlChar*)Comment.str().c_str());
2267  xmlAddChild(qm_root_input, MyComment);
2268  xmlAddChild(qm_root_input, createHamiltonian(ion_tag, psi_tag));
2269  }
2270 
2271  {
2272  Comment.str("");
2273  Comment.clear();
2274  Comment << "\n \nExample initial VMC to measure initial energy and variance \n\n";
2275  xmlNodePtr MyComment = xmlNewComment((const xmlChar*)Comment.str().c_str());
2276  xmlAddChild(qm_root_input, MyComment);
2277  }
2278  xmlNodePtr initvmc = xmlNewNode(NULL, (const xmlChar*)"qmc");
2279  xmlNewProp(initvmc, (const xmlChar*)"method", (const xmlChar*)"vmc");
2280  xmlNewProp(initvmc, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2281  xmlNewProp(initvmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1");
2282  //xmlNewProp(initvmc,(const xmlChar*)"gpu", (const xmlChar*)"no");
2283  {
2284  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2285  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2286  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2287  xmlAddChild(initvmc, estimator);
2288 
2289  xmlAddChild(initvmc, parameter(initvmc, "warmupSteps", "100"));
2290  xmlAddChild(initvmc, parameter(initvmc, "blocks", "20"));
2291  xmlAddChild(initvmc, parameter(initvmc, "steps", "50"));
2292  xmlAddChild(initvmc, parameter(initvmc, "substeps", "8"));
2293  xmlAddChild(initvmc, parameter(initvmc, "timestep", "0.5"));
2294  xmlAddChild(initvmc, parameter(initvmc, "usedrift", "no"));
2295  }
2296  xmlAddChild(qm_root_input, initvmc);
2297 
2298 
2299  if (addJastrow)
2300  {
2301  ///Adding First loop of Cheap optimization blocks
2302  {
2303  Comment.str("");
2304  Comment.clear();
2305  Comment << "\n \nExample initial VMC optimization \n \nNumber of steps required will be computed from total "
2306  "requested sample \ncount and total number of walkers \n\n";
2307  xmlNodePtr MyComment = xmlNewComment((const xmlChar*)Comment.str().c_str());
2308  xmlAddChild(qm_root_input, MyComment);
2309  }
2310  xmlNodePtr loopopt1 = xmlNewNode(NULL, (const xmlChar*)"loop");
2311  xmlNewProp(loopopt1, (const xmlChar*)"max", (const xmlChar*)"4");
2312  {
2313  xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc");
2314  xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear");
2315  xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2316  xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1");
2317  {
2318  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2319  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2320  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2321  xmlAddChild(initopt, estimator);
2322 
2323  xmlAddChild(initopt, parameter(initopt, "warmupSteps", "100"));
2324  xmlAddChild(initopt, parameter(initopt, "blocks", "20"));
2325  xmlAddChild(initopt, parameter(initopt, "timestep", "0.5"));
2326  xmlAddChild(initopt, parameter(initopt, "walkers", "1"));
2327  xmlAddChild(initopt, parameter(initopt, "samples", "16000"));
2328  xmlAddChild(initopt, parameter(initopt, "substeps", "4"));
2329  xmlAddChild(initopt, parameter(initopt, "usedrift", "no"));
2330  xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly"));
2331  xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.0001"));
2332  }
2333  xmlAddChild(loopopt1, initopt);
2334  }
2335  xmlAddChild(qm_root_input, loopopt1);
2336 
2337  ///Adding loop for optimization blocks
2338  {
2339  Comment.str("");
2340  Comment.clear();
2341  Comment << "\n \nExample follow-up VMC optimization using more samples for greater accuracy\n\n";
2342  xmlNodePtr MyComment = xmlNewComment((const xmlChar*)Comment.str().c_str());
2343  xmlAddChild(qm_root_input, MyComment);
2344  }
2345  xmlNodePtr loopopt = xmlNewNode(NULL, (const xmlChar*)"loop");
2346  xmlNewProp(loopopt, (const xmlChar*)"max", (const xmlChar*)"10");
2347  {
2348  xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc");
2349  xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear");
2350  xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2351  xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1");
2352  //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no");
2353  {
2354  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2355  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2356  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2357  xmlAddChild(initopt, estimator);
2358 
2359  xmlAddChild(initopt, parameter(initopt, "warmupSteps", "100"));
2360  xmlAddChild(initopt, parameter(initopt, "blocks", "20"));
2361  xmlAddChild(initopt, parameter(initopt, "timestep", "0.5"));
2362  xmlAddChild(initopt, parameter(initopt, "walkers", "1"));
2363  xmlAddChild(initopt, parameter(initopt, "samples", "64000"));
2364  xmlAddChild(initopt, parameter(initopt, "substeps", "4"));
2365  xmlAddChild(initopt, parameter(initopt, "usedrift", "no"));
2366  xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly"));
2367  xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.3"));
2368  }
2369  xmlAddChild(loopopt, initopt);
2370  }
2371  xmlAddChild(qm_root_input, loopopt);
2372 
2373 
2374  ///Adding a VMC Block to the Input
2375  {
2376  Comment.str("");
2377  Comment.clear();
2378  Comment
2379  << "\n\nProduction VMC and DMC\n\nExamine the results of the optimization before running these blocks.\ne.g. "
2380  "Choose the best optimized jastrow from all obtained, put in \nwavefunction file, do not reoptimize.\n\n";
2381  xmlNodePtr MyComment = xmlNewComment((const xmlChar*)Comment.str().c_str());
2382  xmlAddChild(qm_root_input, MyComment);
2383  }
2384  xmlNodePtr vmc = xmlNewNode(NULL, (const xmlChar*)"qmc");
2385  xmlNewProp(vmc, (const xmlChar*)"method", (const xmlChar*)"vmc");
2386  xmlNewProp(vmc, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2387  xmlNewProp(vmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1");
2388  //xmlNewProp(vmc,(const xmlChar*)"gpu", (const xmlChar*)"no");
2389  {
2390  std::ostringstream Comment;
2391  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2392  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2393  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2394  xmlAddChild(vmc, estimator);
2395 
2396  xmlAddChild(vmc, parameter(vmc, "warmupSteps", "100"));
2397  xmlAddChild(vmc, parameter(vmc, "blocks", "200"));
2398  xmlAddChild(vmc, parameter(vmc, "steps", "50"));
2399  xmlAddChild(vmc, parameter(vmc, "substeps", "8"));
2400  xmlAddChild(vmc, parameter(vmc, "timestep", "0.5"));
2401  xmlAddChild(vmc, parameter(vmc, "usedrift", "no"));
2402  Comment.str("");
2403  Comment.clear();
2404  Comment << "Sample count should match targetwalker count for DMC. Will be obtained from all nodes.";
2405  xmlNodePtr MyComment = xmlNewComment((const xmlChar*)Comment.str().c_str());
2406  xmlAddChild(vmc, MyComment);
2407  xmlAddChild(vmc, parameter(vmc, "samples", "16000"));
2408  }
2409  xmlAddChild(qm_root_input, vmc);
2410 
2411  ///Adding a DMC Block to the Input
2412  xmlNodePtr dmc = xmlNewNode(NULL, (const xmlChar*)"qmc");
2413  xmlNewProp(dmc, (const xmlChar*)"method", (const xmlChar*)"dmc");
2414  xmlNewProp(dmc, (const xmlChar*)"move", (const xmlChar*)"pbyp");
2415  xmlNewProp(dmc, (const xmlChar*)"checkpoint", (const xmlChar*)"20");
2416  //xmlNewProp(dmc,(const xmlChar*)"gpu", (const xmlChar*)"no");
2417  {
2418  xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator");
2419  xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy");
2420  xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no");
2421  xmlAddChild(dmc, estimator);
2422 
2423  xmlAddChild(dmc, parameter(dmc, "targetwalkers", "16000"));
2424  xmlAddChild(dmc, parameter(dmc, "reconfiguration", "no"));
2425  xmlAddChild(dmc, parameter(dmc, "warmupSteps", "100"));
2426  xmlAddChild(dmc, parameter(dmc, "timestep", "0.0005"));
2427  xmlAddChild(dmc, parameter(dmc, "steps", "30"));
2428  xmlAddChild(dmc, parameter(dmc, "blocks", "1000"));
2429  xmlAddChild(dmc, parameter(dmc, "nonlocalmoves", "v3"));
2430  }
2431  xmlAddChild(qm_root_input, dmc);
2432  }
2433 
2434  xmlDocSetRootElement(doc_input, qm_root_input);
2435  xmlSaveFormatFile(fname.c_str(), doc_input, 1);
2436  xmlFreeDoc(doc_input);
2437 }
2438 
2439 xmlNodePtr QMCGaussianParserBase::createHamiltonian(const std::string& ion_tag, const std::string& psi_tag)
2440 {
2441  xmlNodePtr hamPtr = xmlNewNode(NULL, (const xmlChar*)"hamiltonian");
2442  xmlNewProp(hamPtr, (const xmlChar*)"name", (const xmlChar*)"h0");
2443  xmlNewProp(hamPtr, (const xmlChar*)"type", (const xmlChar*)"generic");
2444  xmlNewProp(hamPtr, (const xmlChar*)"target", (const xmlChar*)"e");
2445 
2446  {
2447  xmlNodePtr pairpot1 = xmlNewNode(NULL, (const xmlChar*)"pairpot");
2448  xmlNewProp(pairpot1, (const xmlChar*)"name", (const xmlChar*)"ElecElec");
2449  xmlNewProp(pairpot1, (const xmlChar*)"type", (const xmlChar*)"coulomb");
2450  xmlNewProp(pairpot1, (const xmlChar*)"source", (const xmlChar*)"e");
2451  xmlNewProp(pairpot1, (const xmlChar*)"target", (const xmlChar*)"e");
2452  xmlNewProp(pairpot1, (const xmlChar*)"physical", (const xmlChar*)"true");
2453  xmlAddChild(hamPtr, pairpot1);
2454 
2455  xmlNodePtr pairpot2 = xmlNewNode(NULL, (const xmlChar*)"pairpot");
2456  xmlNewProp(pairpot2, (const xmlChar*)"name", (const xmlChar*)"IonIon");
2457  xmlNewProp(pairpot2, (const xmlChar*)"type", (const xmlChar*)"coulomb");
2458  xmlNewProp(pairpot2, (const xmlChar*)"source", (const xmlChar*)ion_tag.c_str());
2459  xmlNewProp(pairpot2, (const xmlChar*)"target", (const xmlChar*)ion_tag.c_str());
2460  xmlAddChild(hamPtr, pairpot2);
2461  if (ECP == false)
2462  {
2463  xmlNodePtr pairpot3 = xmlNewNode(NULL, (const xmlChar*)"pairpot");
2464  xmlNewProp(pairpot3, (const xmlChar*)"name", (const xmlChar*)"IonElec");
2465  xmlNewProp(pairpot3, (const xmlChar*)"type", (const xmlChar*)"coulomb");
2466  xmlNewProp(pairpot3, (const xmlChar*)"source", (const xmlChar*)ion_tag.c_str());
2467  xmlNewProp(pairpot3, (const xmlChar*)"target", (const xmlChar*)"e");
2468  xmlAddChild(hamPtr, pairpot3);
2469  }
2470  else
2471  {
2472  std::cout << "Hamiltonian using ECP for Electron Ion=" << ECP << std::endl;
2473  xmlNodePtr pairpot3 = xmlNewNode(NULL, (const xmlChar*)"pairpot");
2474  xmlNewProp(pairpot3, (const xmlChar*)"name", (const xmlChar*)"PseudoPot");
2475  xmlNewProp(pairpot3, (const xmlChar*)"type", (const xmlChar*)"pseudo");
2476  xmlNewProp(pairpot3, (const xmlChar*)"source", (const xmlChar*)ion_tag.c_str());
2477  xmlNewProp(pairpot3, (const xmlChar*)"wavefunction", (const xmlChar*)psi_tag.c_str());
2478  xmlNewProp(pairpot3, (const xmlChar*)"format", (const xmlChar*)"xml");
2479  {
2480  std::vector<std::string> AtomNames(GroupName);
2481  sort(AtomNames.begin(), AtomNames.end());
2482  AtomNames.erase(unique(AtomNames.begin(), AtomNames.end()), AtomNames.end());
2483 
2484  for (int iat = 0; iat < AtomNames.size(); iat++)
2485  {
2486  std::string PPname = AtomNames[iat] + ".qmcpp.xml";
2487  xmlNodePtr a = xmlNewNode(NULL, (const xmlChar*)"pseudo");
2488  xmlNewProp(a, (const xmlChar*)"elementType", (const xmlChar*)AtomNames[iat].c_str());
2489  xmlNewProp(a, (const xmlChar*)"href", (const xmlChar*)PPname.c_str());
2490  xmlAddChild(pairpot3, a);
2491  }
2492  }
2493  xmlAddChild(hamPtr, pairpot3);
2494  }
2495 
2496  std::string tmp_codename(lowerCase(CodeName));
2497 
2498  if (tmp_codename == "rmg")
2499  {
2500  std::cout << "Adding MPC and Chiesa correction to Hamiltonian" << std::endl;
2501  xmlNodePtr pairpotMPC = xmlNewNode(NULL, (const xmlChar*)"pairpot");
2502  xmlNewProp(pairpotMPC, (const xmlChar*)"name", (const xmlChar*)"MPC");
2503  xmlNewProp(pairpotMPC, (const xmlChar*)"type", (const xmlChar*)"MPC");
2504  xmlNewProp(pairpotMPC, (const xmlChar*)"source", (const xmlChar*)"e");
2505  xmlNewProp(pairpotMPC, (const xmlChar*)"target", (const xmlChar*)"e");
2506  xmlNewProp(pairpotMPC, (const xmlChar*)"ecut", (const xmlChar*)"60.0");
2507  xmlNewProp(pairpotMPC, (const xmlChar*)"physical", (const xmlChar*)"false");
2508  xmlAddChild(hamPtr, pairpotMPC);
2509 
2510  xmlNodePtr chiesaPtr = xmlNewNode(NULL, (const xmlChar*)"estimator");
2511  xmlNewProp(chiesaPtr, (const xmlChar*)"name", (const xmlChar*)"KEcorr");
2512  xmlNewProp(chiesaPtr, (const xmlChar*)"type", (const xmlChar*)"chiesa");
2513  xmlNewProp(chiesaPtr, (const xmlChar*)"source", (const xmlChar*)"e");
2514  xmlNewProp(chiesaPtr, (const xmlChar*)"psi", (const xmlChar*)psi_tag.c_str());
2515  xmlAddChild(hamPtr, chiesaPtr);
2516  }
2517  }
2518  return hamPtr;
2519 }
2520 
2522 {
2523  int res = 0;
2524  for (int i = ci_neb; i < ci_nstates; i++)
2525  {
2526  if (i < ci_nea && occ[i] == '2')
2527  {
2528  res++; //excitation into singly occupied alpha states in the reference
2529  }
2530  else
2531  {
2532  if (occ[i] == '1')
2533  res++;
2534  else if (occ[i] == '2')
2535  res += 2;
2536  }
2537  }
2538  return res;
2539 }
2540 
2541 
2542 xmlNodePtr QMCGaussianParserBase::parameter(xmlNodePtr Parent, std::string Mypara, std::string a)
2543 {
2544  xmlNodePtr e = xmlNewTextChild(Parent, NULL, (const xmlChar*)"parameter", (const xmlChar*)a.c_str());
2545  xmlNewProp(e, (const xmlChar*)"name", (const xmlChar*)Mypara.c_str());
2546  return e;
2547 }
2548 
2549 
2550 void QMCGaussianParserBase::PrepareSPOSetsFromH5(xmlNodePtr spoUP, xmlNodePtr spoDN)
2551 {
2553  std::ostringstream up_size, down_size, b_size, occ, nstates_alpha, nstates_beta;
2554  up_size << NumberOfAlpha;
2555  down_size << NumberOfBeta;
2556  b_size << numMO;
2557  nstates_alpha << ci_nstates + ci_nca;
2558  ;
2559  nstates_beta << ci_nstates + ci_ncb;
2560 
2561  //create a spoUp
2562  xmlNewProp(spoUP, (const xmlChar*)"name", (const xmlChar*)"spo-up");
2563  xmlNewProp(spoUP, (const xmlChar*)"size", (const xmlChar*)nstates_alpha.str().c_str());
2564 
2565  //create a spoDN
2566  xmlNewProp(spoDN, (const xmlChar*)"name", (const xmlChar*)"spo-dn");
2567  xmlNewProp(spoDN, (const xmlChar*)"size", (const xmlChar*)nstates_beta.str().c_str());
2568 
2569 
2570  if (DoCusp == true)
2571  {
2572  xmlNewProp(spoUP, (const xmlChar*)"cuspInfo", (const xmlChar*)"../spo-up.cuspInfo.xml");
2573  xmlNewProp(spoDN, (const xmlChar*)"cuspInfo", (const xmlChar*)"../spo-dn.cuspInfo.xml");
2574  }
2575 
2576 
2577  //add occupation UP
2578  xmlNodePtr occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
2579  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
2580  xmlAddChild(spoUP, occ_data);
2581 
2582 
2583  //add coefficients
2584  xmlNodePtr coeff_data = xmlNewNode(NULL, (const xmlChar*)"coefficient");
2585  xmlNewProp(coeff_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
2586  xmlNewProp(coeff_data, (const xmlChar*)"spindataset", (const xmlChar*)"0");
2587  xmlAddChild(spoUP, coeff_data);
2588 
2589 
2590  //add occupation DN
2591  occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation");
2592  xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground");
2593  xmlAddChild(spoDN, occ_data);
2594 
2595  coeff_data = xmlNewNode(NULL, (const xmlChar*)"coefficient");
2596  xmlNewProp(coeff_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str());
2597  if (SpinRestricted)
2598  xmlNewProp(coeff_data, (const xmlChar*)"spindataset", (const xmlChar*)"0");
2599  else
2600  xmlNewProp(coeff_data, (const xmlChar*)"spindataset", (const xmlChar*)"1");
2601  xmlAddChild(spoDN, coeff_data);
2602 }
2604 {
2605  xmlNodePtr multislaterdet = xmlNewNode(NULL, (const xmlChar*)"multideterminant");
2606  if (optDetCoeffs)
2607  xmlNewProp(multislaterdet, (const xmlChar*)"optimize", (const xmlChar*)"yes");
2608  else
2609  xmlNewProp(multislaterdet, (const xmlChar*)"optimize", (const xmlChar*)"no");
2610  xmlNewProp(multislaterdet, (const xmlChar*)"spo_up", (const xmlChar*)"spo-up");
2611  xmlNewProp(multislaterdet, (const xmlChar*)"spo_dn", (const xmlChar*)"spo-dn");
2612  xmlNodePtr detlist = xmlNewNode(NULL, (const xmlChar*)"detlist");
2613  std::ostringstream nstates, cisize, cinca, cincb, cinea, cineb, ci_thr;
2614  cisize << ci_size;
2615  nstates << ci_nstates;
2616  cinca << ci_nca;
2617  cincb << ci_ncb;
2618  cinea << ci_nea;
2619  cineb << ci_neb;
2620  ci_thr << ci_threshold;
2621  xmlNewProp(detlist, (const xmlChar*)"size", (const xmlChar*)cisize.str().c_str());
2622  xmlNewProp(detlist, (const xmlChar*)"type", (const xmlChar*)"DETS");
2623  xmlNewProp(detlist, (const xmlChar*)"nca", (const xmlChar*)cinca.str().c_str());
2624  xmlNewProp(detlist, (const xmlChar*)"ncb", (const xmlChar*)cincb.str().c_str());
2625  xmlNewProp(detlist, (const xmlChar*)"nea", (const xmlChar*)cinea.str().c_str());
2626  xmlNewProp(detlist, (const xmlChar*)"neb", (const xmlChar*)cineb.str().c_str());
2627  xmlNewProp(detlist, (const xmlChar*)"nstates", (const xmlChar*)nstates.str().c_str());
2628  xmlNewProp(detlist, (const xmlChar*)"cutoff", (const xmlChar*)ci_thr.str().c_str());
2629  if (nbexcitedstates >= 1)
2630  {
2631  app_log() << "WARNING!! THE HDF5 Contains CI coefficients for " << nbexcitedstates
2632  << ". By default, the ground state coefficients will be loaded ( ext_level=0). If you want to evaluate "
2633  "an excited for which the coefficients are stored in the HDF5 file, modify the value of ext_level "
2634  "Using [1,"
2635  << nbexcitedstates << "]" << std::endl;
2636  xmlNewProp(detlist, (const xmlChar*)"ext_level", (const xmlChar*)"0");
2637  }
2638  if (!debug)
2639  xmlNewProp(detlist, (const xmlChar*)"href", (const xmlChar*)multih5file.c_str());
2640  if (CIcoeff.size() == 0)
2641  {
2642  std::cerr << " CI configuration list is empty. \n";
2643  exit(101);
2644  }
2645  if (CIcoeff.size() != CIalpha.size() || CIcoeff.size() != CIbeta.size())
2646  {
2647  std::cerr << " Problem with CI configuration lists. \n";
2648  exit(102);
2649  }
2650  int iv = 0;
2651  xmlAddChild(multislaterdet, detlist);
2652  return multislaterdet;
2653 }
std::vector< std::vector< double > > CSFexpansion
void setName(const std::string &aname)
Definition: ParticleSet.h:237
std::vector< value_type > EigVal_beta
xmlNodePtr createNode(bool addlattice)
create particleset node
const std::string & getName() const
return the name
xmlNodePtr createMultiDeterminantSetFromH5()
int addSpecies(const std::string &aname)
When a name species does not exist, add a new species.
Definition: SpeciesSet.cpp:33
void write(T &data, const std::string &aname)
write the data to the group aname and check status runtime error is issued on I/O error ...
Definition: hdf_archive.h:259
bool open(const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
open a file
xmlNodePtr createCenter(int iat, int _off)
xmlNodePtr parameter(xmlNodePtr Parent, std::string Mypara, std::string a)
static std::vector< int > gShellID
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< double > Z
xmlNodePtr createHamiltonian(const std::string &ion_tag, const std::string &psi_tag)
std::vector< double > X
void close()
close all the open groups and file
Definition: hdf_archive.cpp:38
std::vector< double > CIcoeff
std::vector< int > Occ_beta
class to handle hdf file
Definition: hdf_archive.h:51
int first(int igroup) const
return the first index of a group i
Definition: ParticleSet.h:514
void dumpStdInputProd(const std::string &psi_tag, const std::string &ion_tag)
int numberOfExcitationsCSF(std::string &)
int addAttribute(const std::string &aname)
for a new attribute, allocate the data, !More often used to get the index of a species ...
Definition: SpeciesSet.cpp:45
std::vector< std::string > GroupName
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
std::vector< std::vector< std::string > > CSFbeta
int getTotalNum() const
return the number of species
Definition: SpeciesSet.h:55
std::vector< value_type > EigVal_alpha
std::enable_if_t< IsComplex_t< T >::value, bool > IsComplex
std::vector< std::string > CSFocc
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
const SimulationCell simulation_cell
std::vector< int > Occ_alpha
void createShell(int n, int ig, int off_, xmlNodePtr abasis)
std::unique_ptr< xmlNode, void(*)(xmlNodePtr)> gridPtr
std::vector< value_type > gC0
std::vector< double > STwist_Coord
void createShellH5(int n, int ig, int off_, int numelem)
static const int bufferSize
Definition: SimpleParser.h:47
void createSPOSetsH5(xmlNodePtr, xmlNodePtr)
std::string lowerCase(const std::string_view s)
++17
std::vector< value_type > EigVec
xmlNodePtr PrepareDeterminantSetFromHDF5()
ParticlePos R
Position.
Definition: ParticleSet.h:79
std::vector< value_type > gExp
int last(int igroup) const
return the last index of a group i
Definition: ParticleSet.h:517
static std::map< int, std::string > IonName
xmlNodePtr createElectronSet(const std::string &ion_tag)
std::vector< double > Y
std::vector< int > CIexcitLVL
virtual void dumpPBC(const std::string &psi_tag, const std::string &ion_tag)
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
std::vector< std::string > CIalpha
void create(const std::vector< int > &agroup)
create grouped particles
void push(const std::string &gname, bool createit=true)
push a group to the group stack
std::vector< std::pair< int, double > > coeff2csf
xmlNodePtr createMultiDeterminantSetCIHDF5()
virtual void dump(const std::string &psi_tag, const std::string &ion_tag)
bool create(const std::filesystem::path &fname, unsigned flags=H5F_ACC_TRUNC)
create a file
static std::vector< std::string > gShellType
void createCenterH5(int iat, int _off, int numelem)
std::vector< int > gNumber
void PrepareSPOSetsFromH5(xmlNodePtr, xmlNodePtr)
Custom container for set of attributes for a set of species.
Definition: SpeciesSet.h:33
std::vector< std::string > CIbeta
std::vector< value_type > gC1
void createGridNode(int argc, char **argv)
void dumpStdInput(const std::string &psi_tag, const std::string &ion_tag)
static const std::vector< double > gCoreTable
void createSPOSets(xmlNodePtr, xmlNodePtr)
std::vector< std::vector< std::string > > CSFalpha
#define LOGMSG(msg)
Definition: OutputManager.h:82