QMCPACK
NEReferencePoints.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) 2023 QMCPACK developers.
6 //
7 // File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
8 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
9 // Peter W. Doak. doakpw@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File refactored from: QMCHamiltonian/ReferencePoints.cpp
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #include "NEReferencePoints.h"
16 #include "Utilities/string_utils.h"
17 #include "OhmmsData/AttributeSet.h"
19 
20 namespace qmcplusplus
21 {
22 
24  const ParticleSet& pset,
25  RefVector<ParticleSet>& ref_psets)
26  : input_(rp_input)
27 {
28  processParticleSets(pset, ref_psets);
29  for (int i = 0; i < OHMMS_DIM; i++)
30  for (int d = 0; d < OHMMS_DIM; d++)
31  axes(d, i) = pset.getLattice().a(i)[d];
32  Axes crd;
33  // no need to handle error here rp_input will have a valid value for coord_form
34  switch (input_.get_coord_form())
35  {
36  case Coord::CELL:
37  crd = axes;
38  break;
39  case Coord::CARTESIAN:
40  for (int i = 0; i < OHMMS_DIM; i++)
41  for (int d = 0; d < OHMMS_DIM; d++)
42  if (d == i)
43  crd(i, i) = 1.0;
44  else
45  crd(d, i) = 0.0;
46  break;
47  }
48 
49  for (const auto& [key, value] : input_.get_points())
50  points_[key] = dot(crd, value);
51 }
52 
54 {
55  //get axes and origin information from the ParticleSet
56  points_["zero"] = 0 * P.getLattice().a(0);
57  points_["a1"] = P.getLattice().a(0);
58  points_["a2"] = P.getLattice().a(1);
59  points_["a3"] = P.getLattice().a(2);
60  //points_["center"]= .5*(P.getLattice().a(0)+P.getLattice().a(1)+P.Lattice.a(2))
61  //set points_ on face centers
62  points_["f1p"] = points_["zero"] + .5 * points_["a1"];
63  points_["f1m"] = points_["zero"] - .5 * points_["a1"];
64  points_["f2p"] = points_["zero"] + .5 * points_["a2"];
65  points_["f2m"] = points_["zero"] - .5 * points_["a2"];
66  points_["f3p"] = points_["zero"] + .5 * points_["a3"];
67  points_["f3m"] = points_["zero"] - .5 * points_["a3"];
68  //set points_ on cell corners
69  points_["cmmm"] = points_["zero"] + .5 * (-1 * points_["a1"] - points_["a2"] - points_["a3"]);
70  points_["cpmm"] = points_["zero"] + .5 * (points_["a1"] - points_["a2"] - points_["a3"]);
71  points_["cmpm"] = points_["zero"] + .5 * (-1 * points_["a1"] + points_["a2"] - points_["a3"]);
72  points_["cmmp"] = points_["zero"] + .5 * (-1 * points_["a1"] - points_["a2"] + points_["a3"]);
73  points_["cmpp"] = points_["zero"] + .5 * (-1 * points_["a1"] + points_["a2"] + points_["a3"]);
74  points_["cpmp"] = points_["zero"] + .5 * (points_["a1"] - points_["a2"] + points_["a3"]);
75  points_["cppm"] = points_["zero"] + .5 * (points_["a1"] + points_["a2"] - points_["a3"]);
76  points_["cppp"] = points_["zero"] + .5 * (points_["a1"] + points_["a2"] + points_["a3"]);
77  //get points from requested particle sets
78  int cshift = 1;
79  for (ParticleSet& pset : Psets)
80  {
81  for (int p = 0; p < pset.getTotalNum(); p++)
82  {
83  std::stringstream ss;
84  ss << p + cshift;
85  points_[pset.getName() + ss.str()] = pset.R[p];
86  }
87  }
88 }
89 
90 void NEReferencePoints::write_description(std::ostream& os, const std::string& indent) const
91 {
92  os << indent + "reference_points" << std::endl;
93  std::map<std::string, Point>::const_iterator it, end = points_.end();
94  for (it = points_.begin(); it != end; ++it)
95  {
96  os << indent + " " << it->first << ": " << it->second << std::endl;
97  }
98  os << indent + "end reference_points" << std::endl;
99  return;
100 }
101 
103 {
104  file.push(std::string_view("reference_points"));
105  for (auto it = points_.cbegin(); it != points_.cend(); ++it)
106  file.write(const_cast<Point&>(it->second), it->first);
107  file.pop();
108 }
109 
110 std::ostream& operator<<(std::ostream& out, const NEReferencePoints& rhs)
111 {
112  rhs.write_description(out, "");
113  return out;
114 }
115 
116 } // namespace qmcplusplus
This class creates, contains, and writes both user and machine readable referencepoints.
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
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
NEReferencePoints(const ReferencePointsInput &rp_input, const ParticleSet &pset, RefVector< ParticleSet > &ref_psets)
Usual constructor.
void write(hdf_archive &file) const
machine readable output
class to handle hdf file
Definition: hdf_archive.h:51
#define OHMMS_DIM
Definition: config.h:64
Declaration of ObservableHelper and other helper class for observables.
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
void processParticleSets(const ParticleSet &P, RefVector< ParticleSet > &Pref)
std::ostream & operator<<(std::ostream &out, const AntiSymTensor< T, D > &rhs)
void push(const std::string &gname, bool createit=true)
push a group to the group stack
void write_description(std::ostream &os, const std::string &indent) const
writes a human readable representation of the reference points.
std::vector< std::reference_wrapper< T > > RefVector
const auto & getLattice() const
Definition: ParticleSet.h:251
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)