QMCPACK
SpinDensityInput Class Reference

Native representation for Spin Density Estimators inputs. More...

+ Collaboration diagram for SpinDensityInput:

Classes

struct  DerivedParameters
 

Public Types

using Real = QMCTraits::RealType
 
using POLT = PtclOnLatticeTraits
 
using Lattice = POLT::ParticleLayout
 
using PosType = QMCTraits::PosType
 
using Consumer = SpinDensityNew
 

Public Member Functions

 SpinDensityInput (xmlNodePtr node)
 
 SpinDensityInput (const SpinDensityInput &)=default
 default copy constructor This is required due to SDI being part of a variant used as a vector element. More...
 
Lattice get_cell () const
 
PosType get_corner () const
 
TinyVector< int, DIMget_grid () const
 
int get_npoints () const
 
bool get_write_report () const
 
bool get_save_memory () const
 
DerivedParameters calculateDerivedParameters (const Lattice &lattice) const
 Derived parameters of SpinDensity. More...
 

Static Public Attributes

static constexpr int DIM = QMCTraits::DIM
 

Private Member Functions

void readXML (xmlNodePtr cur)
 

Private Attributes

std::string myName_
 name of this Estimator More...
 
Lattice cell_
 
PosType corner_
 
PosType dr_
 
PosType center_
 
TinyVector< int, DIMgrid_
 
int npoints_
 
bool write_report_
 
bool save_memory_
 
bool have_dr_ = false
 these are necessary for calculateDerivedParameters More...
 
bool have_grid_ = false
 
bool have_center_ = false
 
bool have_corner_ = false
 
bool have_cell_ = false
 

Detailed Description

Native representation for Spin Density Estimators inputs.

This class servers three purposes all related to properly handling and verifying the spin density input.

  1. An immutable representation of actual user input
  2. Parse the xml node of SpinDensityNew input.
  3. Hold the logic of calculating derived parameters.

Definition at line 32 of file SpinDensityInput.h.


Class Documentation

◆ qmcplusplus::SpinDensityInput::DerivedParameters

struct qmcplusplus::SpinDensityInput::DerivedParameters

Definition at line 55 of file SpinDensityInput.h.

+ Collaboration diagram for SpinDensityInput::DerivedParameters:
Class Members
PosType corner
TinyVector< int, DIM > gdims
TinyVector< int, DIM > grid
size_t npoints

Member Typedef Documentation

◆ Consumer

Definition at line 39 of file SpinDensityInput.h.

◆ Lattice

Definition at line 37 of file SpinDensityInput.h.

◆ POLT

Definition at line 36 of file SpinDensityInput.h.

◆ PosType

Definition at line 38 of file SpinDensityInput.h.

◆ Real

Definition at line 35 of file SpinDensityInput.h.

Constructor & Destructor Documentation

◆ SpinDensityInput() [1/2]

SpinDensityInput ( xmlNodePtr  node)

Definition at line 21 of file SpinDensityInput.cpp.

References qmcplusplus::node, and SpinDensityInput::readXML().

22 {
23  readXML(node);
24 }
if(!okay) throw std xmlNodePtr node

◆ SpinDensityInput() [2/2]

SpinDensityInput ( const SpinDensityInput )
default

default copy constructor This is required due to SDI being part of a variant used as a vector element.

Member Function Documentation

◆ calculateDerivedParameters()

SpinDensityInput::DerivedParameters calculateDerivedParameters ( const Lattice lattice) const

Derived parameters of SpinDensity.

These require the cell the SpinDensity is evaluated over, the caller (SpinDensityNew) either gets this from the input and passes it back or passes in the cell from the relevant ParticleSet.

Definition at line 110 of file SpinDensityInput.cpp.

References qmcplusplus::ceil(), SpinDensityInput::center_, SpinDensityInput::corner_, SpinDensityInput::DIM, qmcplusplus::dot(), SpinDensityInput::dr_, SpinDensityInput::grid_, SpinDensityInput::have_center_, SpinDensityInput::have_corner_, SpinDensityInput::have_dr_, SpinDensityInput::have_grid_, qmcplusplus::lattice, and qmcplusplus::sqrt().

Referenced by SpinDensityNew::SpinDensityNew(), and qmcplusplus::TEST_CASE().

111 {
112  PosType corner = 0.0;
113  if (have_center_)
114  corner = center_ - lattice.Center;
115  else if (have_corner_)
116  corner = corner_;
117 
119  if (have_dr_)
120  for (int d = 0; d < DIM; ++d)
121  grid[d] = (int)std::ceil(std::sqrt(dot(lattice.Rv[d], lattice.Rv[d])) / dr_[d]);
122  else if (have_grid_)
123  grid = grid_;
124 
125  size_t npoints = 1;
126  for (int d = 0; d < DIM; ++d)
127  npoints *= grid[d];
128 
129  TinyVector<int, DIM> gdims;
130  gdims[0] = npoints / grid[0];
131  for (int d = 1; d < DIM; ++d)
132  gdims[d] = gdims[d - 1] / grid[d];
133 
134  return {corner, grid, gdims, npoints};
135 }
QMCTraits::PosType PosType
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
MakeReturn< UnaryNode< FnCeil, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t ceil(const Vector< T1, C1 > &l)
bool have_dr_
these are necessary for calculateDerivedParameters
TinyVector< int, DIM > grid_
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)

◆ get_cell()

Lattice get_cell ( ) const
inline

◆ get_corner()

PosType get_corner ( ) const
inline

Definition at line 49 of file SpinDensityInput.h.

References SpinDensityInput::corner_.

49 { return corner_; }

◆ get_grid()

TinyVector<int, DIM> get_grid ( ) const
inline

Definition at line 50 of file SpinDensityInput.h.

References SpinDensityInput::grid_.

50 { return grid_; }
TinyVector< int, DIM > grid_

◆ get_npoints()

int get_npoints ( ) const
inline

Definition at line 51 of file SpinDensityInput.h.

References SpinDensityInput::npoints_.

◆ get_save_memory()

bool get_save_memory ( ) const
inline

◆ get_write_report()

bool get_write_report ( ) const
inline

◆ readXML()

void readXML ( xmlNodePtr  cur)
private

Definition at line 26 of file SpinDensityInput.cpp.

References OhmmsAttributeSet::add(), SpinDensityInput::cell_, SpinDensityInput::center_, SpinDensityInput::corner_, SpinDensityInput::dr_, getXMLAttributeValue(), SpinDensityInput::grid_, SpinDensityInput::have_cell_, SpinDensityInput::have_center_, SpinDensityInput::have_corner_, SpinDensityInput::have_dr_, SpinDensityInput::have_grid_, SpinDensityInput::myName_, OhmmsAttributeSet::put(), putContent(), SpinDensityInput::save_memory_, CrystalLattice< T, D >::set(), and SpinDensityInput::write_report_.

Referenced by SpinDensityInput::SpinDensityInput().

27 {
28  std::string write_report;
29  std::string save_memory;
30  OhmmsAttributeSet attrib;
31  attrib.add(myName_, "name");
32  attrib.add(write_report, "report");
33  attrib.add(save_memory, "save_memory");
34  attrib.put(cur);
35 
36  Tensor<Real, DIM> axes;
37 
38  int test_moves = 0;
39 
40  xmlNodePtr element = cur->xmlChildrenNode;
41  while (element != NULL)
42  {
43  std::string ename((const char*)element->name);
44  if (ename == "parameter")
45  {
46  const std::string name(getXMLAttributeValue(element, "name"));
47  if (name == "dr")
48  {
49  have_dr_ = true;
50  putContent(dr_, element);
51  }
52  else if (name == "grid")
53  {
54  have_grid_ = true;
55  putContent(grid_, element);
56  }
57  else if (name == "corner")
58  {
59  have_corner_ = true;
60  putContent(corner_, element);
61  }
62  else if (name == "center")
63  {
64  have_center_ = true;
65  putContent(center_, element);
66  }
67  else if (name == "cell")
68  {
69  have_cell_ = true;
70  putContent(axes, element);
71  }
72  else if (name == "test_moves")
73  putContent(test_moves, element);
74  }
75  element = element->next;
76  }
77 
78  if (have_dr_ && have_grid_)
79  throw UniformCommunicateError("SpinDensity input dr and grid are provided, this is ambiguous");
80  else if (!have_dr_ && !have_grid_)
81  throw UniformCommunicateError("SpinDensity input must provide dr or grid");
82 
84  throw UniformCommunicateError("SpinDensity input corner and center are provided, this is ambiguous");
85 
86  if (have_cell_)
87  {
88  cell_.set(axes);
89  if (!have_corner_ && !have_center_)
90  throw UniformCommunicateError("SpinDensity input must provide corner or center with explicitly defined cell");
91  }
92 
93  if (write_report == "yes")
94  write_report_ = true;
95  else
96  write_report_ = false;
97 
98  if (save_memory == "yes")
99  save_memory_ = true;
100  else
101  save_memory_ = false;
102 
103  // weird legacy stuff
104  // if (write_report == "yes")
105  // report(" ");
106  // if (test_moves > 0)
107  // test(test_moves, *Ptmp);
108 }
void set(const Tensor< TT, D > &lat)
set the lattice vector from the command-line options
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::string myName_
name of this Estimator
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
bool have_dr_
these are necessary for calculateDerivedParameters
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...
TinyVector< int, DIM > grid_
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
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

Member Data Documentation

◆ cell_

Lattice cell_
private

Definition at line 78 of file SpinDensityInput.h.

Referenced by SpinDensityInput::get_cell(), and SpinDensityInput::readXML().

◆ center_

PosType center_
private

◆ corner_

◆ DIM

constexpr int DIM = QMCTraits::DIM
static

Definition at line 40 of file SpinDensityInput.h.

Referenced by SpinDensityInput::calculateDerivedParameters().

◆ dr_

◆ grid_

◆ have_cell_

bool have_cell_ = false
private

Definition at line 95 of file SpinDensityInput.h.

Referenced by SpinDensityInput::readXML().

◆ have_center_

bool have_center_ = false
private

◆ have_corner_

bool have_corner_ = false
private

◆ have_dr_

bool have_dr_ = false
private

these are necessary for calculateDerivedParameters

If we are going to later write out a canonical input for this input then they are needed as well.

Definition at line 91 of file SpinDensityInput.h.

Referenced by SpinDensityInput::calculateDerivedParameters(), and SpinDensityInput::readXML().

◆ have_grid_

bool have_grid_ = false
private

◆ myName_

std::string myName_
private

name of this Estimator

Definition at line 76 of file SpinDensityInput.h.

Referenced by SpinDensityInput::readXML().

◆ npoints_

int npoints_
private

Definition at line 83 of file SpinDensityInput.h.

Referenced by SpinDensityInput::get_npoints().

◆ save_memory_

bool save_memory_
private

◆ write_report_

bool write_report_
private

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