QMCPACK
OrbitalImages.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: Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
8 // Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
9 //
10 // File created by: Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #include "OrbitalImages.h"
15 #include "OhmmsData/AttributeSet.h"
17 
18 #include <array>
19 
20 namespace qmcplusplus
21 {
23  : psetpool(PSP), sposet_indices(std::make_shared<std::vector<std::vector<int>>>()), spomap_(spomap)
24 {
25  //keep the electron particle to get the cell later, if necessary
26  Peln = &P;
27 
28  //keep the communicator to select master task for file write
29  comm = mpicomm;
30 }
31 
33  : OperatorBase(other),
34  psetpool(other.psetpool),
35  Peln(other.Peln),
36  Pion(other.Pion),
37  comm(other.comm),
38  format(other.format),
39  value_types(other.value_types),
40  derivatives(other.derivatives),
41  sposet_names(other.sposet_names),
42  sposet_indices(other.sposet_indices),
43  center_grid(other.center_grid),
44  cell(other.cell),
45  corner(other.corner),
46  grid(other.grid),
47  gdims(other.gdims),
48  npoints(other.npoints),
49  batch_size(other.batch_size),
50  spo_vtmp(other.spo_vtmp),
51  spo_gtmp(other.spo_gtmp),
52  spo_ltmp(other.spo_ltmp),
53  batch_values(other.batch_values),
54  batch_gradients(other.batch_gradients),
55  batch_laplacians(other.batch_laplacians),
56  orbital(other.orbital),
57  spomap_(other.spomap_)
58 {
59  for (auto& element : other.sposets)
60  sposets.push_back(element->makeClone());
61 }
62 
63 std::unique_ptr<OperatorBase> OrbitalImages::makeClone(ParticleSet& P, TrialWaveFunction& Psi)
64 {
65  //cloning shouldn't strictly be necessary, but do it right just in case
66  std::unique_ptr<OrbitalImages> clone = std::make_unique<OrbitalImages>(*this);
67  clone->Peln = &P;
68  return clone;
69 }
70 
71 
72 bool OrbitalImages::put(xmlNodePtr cur)
73 {
74  app_log() << "OrbitalImages::put" << std::endl;
75 
76  //set defaults
77  name_ = "OrbitalImages";
78  derivatives = false;
79  center_grid = false;
80  corner = 0.0;
81  batch_size = -1;
82 
83  //read simple attributes
84  std::string write_report = "yes";
85  std::string ion_psname = "ion0";
86  OhmmsAttributeSet attrib;
87  attrib.add(name_, "name");
88  attrib.add(ion_psname, "ions");
89  attrib.add(write_report, "report");
90  attrib.put(cur);
91 
92  //read parameters
93  bool have_grid = false;
94  bool have_center = false;
95  bool have_corner = false;
96  bool have_cell = false;
97 
98  PosType center;
100  std::vector<std::string> valtypes;
101  std::vector<std::string> dertypes;
102  std::string file_format = "xsf";
103  std::string der_str = "no";
104  std::string cg_str = "no";
105 
106  xmlNodePtr element = cur->xmlChildrenNode;
107  std::vector<xmlNodePtr> other_elements;
108  while (element != NULL)
109  {
110  std::string ename((const char*)element->name);
111  if (ename == "parameter")
112  {
113  const std::string name(getXMLAttributeValue(element, "name"));
114  if (name == "sposets")
115  putContent(sposet_names, element);
116  else if (name == "batch_size")
117  putContent(batch_size, element);
118  else if (name == "grid")
119  {
120  have_grid = true;
121  putContent(grid, element);
122  }
123  else if (name == "center_grid")
124  putContent(cg_str, element);
125  else if (name == "corner")
126  {
127  have_corner = true;
128  putContent(corner, element);
129  }
130  else if (name == "center")
131  {
132  have_center = true;
133  putContent(center, element);
134  }
135  else if (name == "cell")
136  {
137  have_cell = true;
138  putContent(axes, element);
139  }
140  else if (name == "value")
141  putContent(valtypes, element);
142  else if (name == "derivatives")
143  putContent(der_str, element);
144  else if (name == "format")
145  putContent(file_format, element);
146  else
147  other_elements.push_back(element);
148  }
149  element = element->next;
150  }
151 
152  derivatives = der_str == "yes";
153  center_grid = cg_str == "yes";
154 
155  //second pass parameter read to get orbital indices
156  // each parameter is named after the corresponding sposet
157  sposet_indices->resize(sposet_names.size());
158  for (int n = 0; n < other_elements.size(); ++n)
159  {
160  xmlNodePtr element = other_elements[n];
161  std::string ename((const char*)element->name);
162  if (ename == "parameter")
163  {
164  const std::string name(getXMLAttributeValue(element, "name"));
165  for (int i = 0; i < sposet_names.size(); ++i)
166  if (name == sposet_names[i])
167  putContent((*sposet_indices)[i], element);
168  }
169  }
170 
171  //check that the value types requested are reasonable
172  for (int i = 0; i < valtypes.size(); ++i)
173  {
174  const std::string& valtype = valtypes[i];
175  if (valtype == "real")
176  value_types.push_back(real_val);
177  else if (valtype == "imag")
178  value_types.push_back(imag_val);
179  else if (valtype == "abs")
180  value_types.push_back(abs_val);
181  else if (valtype == "abs2")
182  value_types.push_back(abs2_val);
183  else
184  {
185  APP_ABORT("OrbitalImages::put value type " + valtype + " is unsupported\n valid options are: value, abs, abs2");
186  }
187  }
188  if (value_types.size() == 0)
189  value_types.push_back(real_val);
190 
191  //check the format
192  if (file_format == "xsf")
193  format = xsf;
194  else
195  {
196  APP_ABORT("OrbitalImages::put file format " + file_format + " is invalid\n valid options are: xsf");
197  }
198 
199  //get the ion particleset
200  if (auto pit = psetpool.find(ion_psname); pit == psetpool.end())
201  {
202  APP_ABORT("OrbitalImages::put ParticleSet " + ion_psname + " does not exist");
203  }
204  else
205  Pion = pit->second.get();
206 
207  app_log() << " getting sposets" << std::endl;
208 
209  // get the sposets for image output
210  if (sposet_names.size() == 0)
211  APP_ABORT("OrbitalImages::put must have at least one sposet");
212  for (int i = 0; i < sposet_names.size(); ++i)
213  {
214  auto spo_it = spomap_.find(sposet_names[i]);
215  if (spo_it == spomap_.end())
216  throw std::runtime_error("OrbitalImages::put sposet " + sposet_names[i] + " does not exist.");
217 
218  sposets.push_back(spo_it->second->makeClone());
219  auto& sposet = sposets.back();
220  auto& sposet_inds = (*sposet_indices)[i];
221  if (sposet_inds.size() == 0)
222  for (int n = 0; n < sposet->size(); ++n)
223  sposet_inds.push_back(n);
224  for (int n = 0; n < sposet_inds.size(); ++n)
225  {
226  int index = sposet_inds[n];
227  if (index < 0 || index > sposet->size())
228  {
229  app_log() << "\nindex for sposet " << sposet_names[i] << " is out of range\nindex must be between 0 and "
230  << sposet->size() - 1 << "\nyou provided: " << index << std::endl;
231  APP_ABORT("OrbitalImages::put sposet index out of range, see message above");
232  }
233  }
234  }
235 
236  //check that the grid and cell are properly defined
237  if (!have_grid)
238  APP_ABORT("OrbitalImages::put must provide grid");
239  if (have_corner && have_center)
240  APP_ABORT("OrbitalImages::put corner and center are provided, this is ambiguous");
241  if (have_cell)
242  {
243  cell.set(axes);
244  if (!have_corner && !have_center)
245  APP_ABORT("OrbitalImages::put must provide corner or center");
246  }
247  else
248  cell = Peln->getLattice();
249 
250  //calculate the cell corner in the case that the cell center is provided
251  if (have_center)
252  corner = center - cell.Center;
253 
254  //get the number of grid points
255  npoints = 1;
256  for (int d = 0; d < DIM; ++d)
257  npoints *= grid[d];
258 
259  //get grid strides in D dimensions
260  gdims[0] = 1;
261  for (int d = 1; d < DIM; ++d)
262  gdims[d] = gdims[d - 1] * grid[d - 1];
263 
264  //write a brief report to the log file
265  if (write_report == "yes")
266  report(" ");
267 
268  app_log() << "end OrbitalImages::put" << std::endl;
269  return true;
270 }
271 
272 
273 void OrbitalImages::report(const std::string& pad)
274 {
275  app_log() << pad << "OrbitalImages report" << std::endl;
276  app_log() << pad << " derivatives = " << derivatives << std::endl;
277  app_log() << pad << " nsposets = " << sposets.size() << " " << sposet_names.size() << " "
278  << sposet_indices->size() << std::endl;
279  for (int i = 0; i < sposet_names.size(); ++i)
280  {
281  std::vector<int>& sposet_inds = (*sposet_indices)[i];
282  SPOSet& sposet = *sposets[i];
283  if (sposet_inds.size() == sposet.size())
284  app_log() << pad << " " << sposet_names[i] << " = all " << sposet.size() << " orbitals" << std::endl;
285  else
286  {
287  app_log() << pad << " " << sposet_names[i] << " =";
288  for (int n = 0; n < sposet_inds.size(); ++n)
289  app_log() << " " << sposet_inds[n];
290  app_log() << std::endl;
291  }
292  }
293  app_log() << pad << " npoints = " << npoints << std::endl;
294  app_log() << pad << " grid = " << grid << std::endl;
295  app_log() << pad << " corner = " << corner << std::endl;
296  app_log() << pad << " center = " << corner + cell.Center << std::endl;
297  app_log() << pad << " center_grid = " << center_grid << std::endl;
298  app_log() << pad << " cell " << std::endl;
299  for (int d = 0; d < DIM; ++d)
300  app_log() << pad << " " << d << " " << cell.Rv[d] << std::endl;
301  app_log() << pad << " end cell " << std::endl;
302  app_log() << pad << "end OrbitalImages report" << std::endl;
303 }
304 
305 
307 {
308  //only the first thread of the master task writes the orbitals
309  if (comm->rank() == 0 && omp_get_thread_num() == 0)
310  {
311  app_log() << std::endl;
312  app_log() << "OrbitalImages::evaluate writing orbital images" << std::endl;
313 
314  //create the grid points by mapping point index into D-dim points
315  app_log() << " generating grid " << grid << std::endl;
316  std::vector<PosType> rpoints;
317  rpoints.resize(npoints);
318  PosType u, du;
319  for (int d = 0; d < DIM; ++d)
320  du[d] += 1.0 / grid[d];
321  for (int p = 0; p < npoints; ++p)
322  {
323  int nrem = p;
324  for (int d = DIM - 1; d > 0; --d)
325  {
326  int ind = nrem / gdims[d];
327  u[d] = ind * du[d];
328  nrem -= ind * gdims[d];
329  }
330  u[0] = nrem * du[0];
331  if (center_grid)
332  u += 0.5 * du;
333  rpoints[p] = cell.toCart(u) + corner;
334  }
335 
336  //evaluate and write the orbitals for each sposet
337  app_log() << " evaluating all orbitals" << std::endl;
338  for (int i = 0; i < sposets.size(); ++i)
339  {
340  //get sposet information
341  const std::string& sposet_name = sposet_names[i];
342  app_log() << " evaluating orbitals in " + sposet_name + " on the grid" << std::endl;
343  std::vector<int>& sposet_inds = (*sposet_indices)[i];
344  SPOSet& sposet = *sposets[i];
345  int nspo = sposet_inds.size();
346 
347  //set the batch size
348  int bsize = batch_size;
349  if (bsize == -1)
350  bsize = nspo;
351 
352  //resize temporary evaluation arrays
353  spo_vtmp.resize(sposet.size());
354  batch_values.resize(npoints, bsize);
355  orbital.resize(npoints);
356  if (derivatives)
357  {
358  spo_gtmp.resize(sposet.size());
359  spo_ltmp.resize(sposet.size());
362  }
363 
364  //loop over orbitals one batch at a time (batch_size orbitals)
365  int bstart = 0;
366  int bend = std::min(bsize, nspo);
367  while (bstart < nspo)
368  {
369  //fill up the temporary storage for a batch of orbitals
370  app_log() << " evaluating orbital batch " << bstart << " to " << bend << " out of " << nspo << std::endl;
371  for (int p = 0; p < npoints; ++p)
372  {
373  P.makeMove(0, rpoints[p] - P.R[0]);
374  if (!derivatives)
375  {
376  sposet.evaluateValue(P, 0, spo_vtmp); //note that ALL orbitals are evaluated each time
377  for (int b = bstart, ib = 0; b < bend; ++b, ++ib)
378  batch_values(p, ib) = spo_vtmp[sposet_inds[b]];
379  }
380  else
381  {
382  sposet.evaluateVGL(P, 0, spo_vtmp, spo_gtmp, spo_ltmp);
383  for (int b = bstart, ib = 0; b < bend; ++b, ++ib)
384  batch_values(p, ib) = spo_vtmp[sposet_inds[b]];
385  for (int b = bstart, ib = 0; b < bend; ++b, ++ib)
386  batch_gradients(p, ib) = spo_gtmp[sposet_inds[b]];
387  for (int b = bstart, ib = 0; b < bend; ++b, ++ib)
388  batch_laplacians(p, ib) = spo_ltmp[sposet_inds[b]];
389  }
390  P.rejectMove(0);
391  }
392  //write out the batch one orbital at a time for each value type requested
393  app_log() << " writing all orbitals in the batch" << std::endl;
394  for (int b = bstart, ib = 0; b < bend; ++b, ++ib)
395  {
396  //transfer strided orbital info into contiguous array
397  for (int p = 0; p < npoints; ++p)
398  orbital[p] = batch_values(p, ib);
399  //write one file for each value type (real, imag, etc) selected
400  for (int iv = 0; iv < value_types.size(); ++iv)
401  write_orbital(sposet_name, sposet_inds[b], orbital, value_types[iv]);
402  }
403  if (derivatives)
404  {
405  for (int b = bstart, ib = 0; b < bend; ++b, ++ib)
406  {
407  for (int d = 0; d < DIM; ++d)
408  {
409  for (int p = 0; p < npoints; ++p)
410  orbital[p] = batch_gradients(p, ib)[d];
411  for (int iv = 0; iv < value_types.size(); ++iv)
412  write_orbital(sposet_name, sposet_inds[b], orbital, value_types[iv], gradient_d, d);
413  }
414  }
415  for (int b = bstart, ib = 0; b < bend; ++b, ++ib)
416  {
417  for (int p = 0; p < npoints; ++p)
418  orbital[p] = batch_laplacians(p, ib);
419  for (int iv = 0; iv < value_types.size(); ++iv)
420  write_orbital(sposet_name, sposet_inds[b], orbital, value_types[iv], laplacian_d);
421  }
422  }
423  bstart = bend;
424  bend += bsize;
425  bend = std::min(bend, nspo);
426  }
427  }
428 
429  app_log() << "OrbitalImages::evaluate orbital images written successfully, exiting.\n" << std::endl;
430  APP_ABORT(" Not a fatal error, just exiting.");
431  }
432 
433  //make sure no other process runs off
434  comm->barrier();
435 
436  return 0.0;
437 }
438 
439 
440 void OrbitalImages::write_orbital(const std::string& sponame,
441  int index,
442  std::vector<ValueType>& orb,
444  derivative_types_enum derivative_type,
445  int dimension)
446 {
447  //only xsf format is supported for now
448  if (format == xsf)
449  write_orbital_xsf(sponame, index, orb, value_type, derivative_type, dimension);
450 }
451 
452 
453 void OrbitalImages::write_orbital_xsf(const std::string& sponame,
454  int index,
455  std::vector<ValueType>& orb,
457  derivative_types_enum derivative_type,
458  int dimension)
459 {
460  using Units::A;
461  using Units::B;
462  using Units::convert;
463 
464  //generate file name
465  std::array<char, 100> filename;
466  int file_len{0};
467  if (derivative_type == value_d)
468  {
469  if (value_type == real_val)
470  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d.xsf", sponame.c_str(), index);
471  else if (value_type == imag_val)
472  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_imag.xsf", sponame.c_str(), index);
473  else if (value_type == abs_val)
474  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_abs.xsf", sponame.c_str(), index);
475  else if (value_type == abs2_val)
476  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_abs2.xsf", sponame.c_str(), index);
477  }
478  else if (derivative_type == gradient_d)
479  {
480  if (value_type == real_val)
481  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_grad%1d.xsf", sponame.c_str(), index,
482  dimension);
483  else if (value_type == imag_val)
484  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_grad%1d_imag.xsf", sponame.c_str(),
485  index, dimension);
486  else if (value_type == abs_val)
487  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_grad%1d_abs.xsf", sponame.c_str(),
488  index, dimension);
489  else if (value_type == abs2_val)
490  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_grad%1d_abs2.xsf", sponame.c_str(),
491  index, dimension);
492  }
493  else if (derivative_type == laplacian_d)
494  {
495  if (value_type == real_val)
496  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_lap.xsf", sponame.c_str(), index);
497  else if (value_type == imag_val)
498  file_len =
499  std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_lap_imag.xsf", sponame.c_str(), index);
500  else if (value_type == abs_val)
501  file_len = std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_lap_abs.xsf", sponame.c_str(), index);
502  else if (value_type == abs2_val)
503  file_len =
504  std::snprintf(filename.data(), filename.size(), "%s_orbital_%04d_lap_abs2.xsf", sponame.c_str(), index);
505  }
506  if (file_len < 0)
507  throw std::runtime_error("Error generating filename");
508  std::string output_name(filename.data(), file_len);
509  app_log() << " writing file: " << output_name << std::endl;
510 
511  //get the cell containing the ion positions
512  // assume the evaluation cell if any boundaries are open
513  ParticleSet& Pc = *Pion;
514  const Lattice_t& Lbox = Peln->getLattice().SuperCellEnum == SUPERCELL_BULK ? Peln->getLattice() : cell;
515 
516  //open the file
517  std::ofstream file;
518  file.open(output_name, std::ios::out | std::ios::trunc);
519  if (!file.is_open())
520  APP_ABORT("OrbitalImages::write_orbital\n failed to open file for output: " + output_name);
521 
522  //set the precision & number of columns
523  file.precision(6);
524  file << std::scientific;
525  int columns = 5;
526 
527  //get the number of atoms
528  int natoms = Pc.getTotalNum();
529 
530  //write the cell, atomic positions, and orbital to the file in xsf format
531  file << " CRYSTAL" << std::endl;
532  file << " PRIMVEC" << std::endl;
533  for (int i = 0; i < DIM; ++i)
534  {
535  file << " ";
536  for (int d = 0; d < DIM; ++d)
537  file << " " << convert(Lbox.Rv[i][d], B, A);
538  file << std::endl;
539  }
540  file << " PRIMCOORD" << std::endl;
541  file << " " << natoms << " 1" << std::endl;
542  for (int i = 0; i < natoms; ++i)
543  {
544  file << " " << Pc.species_from_index(i);
545  for (int d = 0; d < DIM; ++d)
546  file << " " << convert(Pc.R[i][d], B, A);
547  file << std::endl;
548  }
549  file << " BEGIN_BLOCK_DATAGRID_3D" << std::endl;
550  file << " orbital " << index << std::endl;
551  file << " DATAGRID_3D_ORBITAL" << std::endl;
552  file << " ";
553  for (int d = 0; d < DIM; ++d)
554  file << " " << grid[d];
555  file << std::endl;
556  file << " ";
557  for (int d = 0; d < DIM; ++d)
558  file << " " << convert(corner[d], B, A);
559  file << std::endl;
560  for (int i = 0; i < DIM; ++i)
561  {
562  file << " ";
563  for (int d = 0; d < DIM; ++d)
564  file << " " << convert(cell.Rv[i][d], B, A);
565  file << std::endl;
566  }
567  file << " ";
568  if (value_type == real_val) // real part
569  for (int p = 0; p < npoints; ++p)
570  {
571  file << " " << real(orb[p]);
572  if ((p + 1) % columns == 0)
573  file << std::endl << " ";
574  }
575  else if (value_type == imag_val) // imag part
576  for (int p = 0; p < npoints; ++p)
577  {
578  file << " " << imag(orb[p]);
579  if ((p + 1) % columns == 0)
580  file << std::endl << " ";
581  }
582  else if (value_type == abs_val) // modulus
583  for (int p = 0; p < npoints; ++p)
584  {
585  file << " " << std::abs(orb[p]);
586  if ((p + 1) % columns == 0)
587  file << std::endl << " ";
588  }
589  else if (value_type == abs2_val) // modulus^2
590  for (int p = 0; p < npoints; ++p)
591  {
592  file << " " << std::abs(orb[p]) * std::abs(orb[p]);
593  if ((p + 1) % columns == 0)
594  file << std::endl << " ";
595  }
596  file << std::endl;
597  file << " END_DATAGRID_3D" << std::endl;
598  file << " END_BLOCK_DATAGRID_3D" << std::endl;
599 }
600 
601 } // namespace qmcplusplus
void set(const Tensor< TT, D > &lat)
set the lattice vector from the command-line options
base class for Single-particle orbital sets
Definition: SPOSet.h:46
a class that defines a supercell in D-dimensional Euclean space.
OrbitalImages(ParticleSet &P, const PSPool &PSP, Communicate *mpicomm, const SPOMap &spomap)
SingleParticlePos Center
Center of the cell sum(Rv[i])/2.
formats_enum format
file format selection
void barrier() const
Array< GradType, 2 > batch_gradients
temporary array to hold gradients of a batch of orbitals at all grid points
bool center_grid
evaluate points at grid cell centers instead of edges
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
int rank() const
return the rank
Definition: Communicate.h:116
TinyVector< int, DIM > grid
number of grid points in each direction (cell axis)
Array< ValueType, 2 > batch_values
temporary array to hold values of a batch of orbitals at all grid points
derivative_types_enum
derivative types
const PSPool & psetpool
at put() ion particleset is obtained from ParticleSetPool
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
size_t getTotalNum() const
Definition: ParticleSet.h:493
void convert(const PL &lat, const PV &pin, PV &pout)
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::vector< std::string > sposet_names
names of sposets to evaluate
std::vector< std::unique_ptr< SPOSet > > sposets
sposets obtained by name from SPOMap
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
int size() const
return the size of the orbital set Ye: this needs to be replaced by getOrbitalSetSize(); ...
Definition: SPOSet.h:75
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
T min(T a, T b)
std::map< std::string, const std::unique_ptr< ParticleSet > > PSPool
Array< ValueType, 2 > batch_laplacians
temporary array to hold laplacians of a batch of orbitals at all grid points
TinyVector< SingleParticlePos, D > Rv
Real-space unit vectors.
Wrapping information on parallelism.
Definition: Communicate.h:68
void write_orbital(const std::string &sponame, int index, std::vector< ValueType > &orb, value_types_enum value_type, derivative_types_enum derivative_type=value_d, int dimension=0)
write a single orbital to file
virtual void evaluateValue(const ParticleSet &P, int iat, ValueVector &psi)=0
evaluate the values of this single-particle orbital set
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
std::string name_
name of this object
Definition: OperatorBase.h:527
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
ParticleSet * Pion
ion particleset
real convert(real value, units units_in, units units_out)
PosType corner
location of cell corner, positions in the cell are corner+uvec*cell
void write_orbital_xsf(const std::string &sponame, int index, std::vector< ValueType > &orb, value_types_enum value_type, derivative_types_enum derivative_type=value_d, int dimension=0)
write a single orbital to an xsf file
ValueVector spo_ltmp
temporary vector to hold laplacians of all orbitals at a single point
Lattice_t cell
cell bounding the evaluation grid, default is simulation cell
void report(const std::string &pad)
write brief report of configuration data
std::vector< ValueType > orbital
temporary array to hold values of a single orbital at all grid points
GradVector spo_gtmp
temporary vector to hold gradients of all orbitals at a single point
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
void rejectMove(Index_t iat)
reject a proposed move in regular mode
const std::shared_ptr< std::vector< std::vector< int > > > sposet_indices
indices of orbitals within each sposet to evaluate
virtual void evaluateVGL(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi)=0
evaluate the values, gradients and laplacians of this single-particle orbital set ...
std::vector< value_types_enum > value_types
orbital value selections
int batch_size
number of orbitals to store in memory at a time (batch_size*npoints)
"Estimator" to produce files for orbital plotting.
ParticlePos R
Position.
Definition: ParticleSet.h:79
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::string getXMLAttributeValue(const xmlNodePtr cur, const std::string_view name)
get the value string for attribute name if name is unfound in cur you get an empty string back this i...
int npoints
total number of grid points
bool putContent(T &a, xmlNodePtr cur)
replaces a&#39;s value with the first "element" in the "string" returned by XMLNodeString{cur}.
Definition: libxmldefs.h:88
An abstract class for Local Energy operators.
Definition: OperatorBase.h:59
FullPrecRealType Return_t
type of return value of evaluate
Definition: OperatorBase.h:64
SPOSet::SPOMap SPOMap
const SPOMap & spomap_
reference to the sposet_builder_factory
Class to represent a many-body trial wave function.
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
const auto & getLattice() const
Definition: ParticleSet.h:251
Communicate * comm
mpi communicator
const std::string & species_from_index(int i)
get species name of particle i
Definition: ParticleSet.h:491
ParticleSet * Peln
electron particleset
ValueVector spo_vtmp
temporary vector to hold values of all orbitals at a single point
SingleParticlePos toCart(const TinyVector< T1, D > &c) const
Convert a unit vector to a cartesian vector.
double B(double x, int k, int i, const std::vector< double > &t)
TinyVector< int, DIM > gdims
stride to generate grid in arbitrary dimensions
bool get(std::ostream &os) const override
dummy. For satisfying OhmmsElementBase.
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42
std::unique_ptr< OperatorBase > makeClone(ParticleSet &P, TrialWaveFunction &psi) final
QMCTraits::FullPrecRealType value_type
value_types_enum
options for orbital value to write
Return_t evaluate(ParticleSet &P) override
hijack estimator evaluate to evaluate and write all orbitals
bool derivatives
write out derivatives in addition to values
bool put(xmlNodePtr cur) override
read xml input