QMCPACK
SkParserBase Class Referenceabstract

Base class for Sk parser. More...

+ Inheritance diagram for SkParserBase:
+ Collaboration diagram for SkParserBase:

Public Types

using Grid_t = LinearGrid< RealType >
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 SkParserBase ()
 
virtual ~SkParserBase ()
 
virtual void parse (const std::string &fname)=0
 
void get_grid (Grid_t &xgrid, Grid_t &ygrid, Grid_t &zgrid)
 
void get_sk (std::vector< RealType > &sk, std::vector< RealType > &skerr)
 
std::vector< PosTypeget_grid_raw ()
 
std::vector< RealTypeget_sk_raw ()
 
std::vector< RealTypeget_skerr_raw ()
 
void compute_sk ()
 
void set_grid (const std::vector< PosType > &gridpoints)
 
void set_grid (const std::vector< TinyVector< int, OHMMS_DIM >> &gridpoints)
 
void compute_grid ()
 
bool is_normalized ()
 
bool has_grid ()
 
void setName (std::string in_name)
 

Protected Attributes

bool isParseSuccess
 
bool isGridComputed
 
bool isSkComputed
 
bool hasGrid
 
bool isNormalized
 
Grid_t xgrid
 
Grid_t ygrid
 
Grid_t zgrid
 
std::vector< RealTypeskraw
 
std::vector< RealTypeskerr_raw
 
std::vector< PosTypekgridraw
 
std::vector< RealTypesk
 
std::vector< RealTypeskerr
 
std::vector< PosTypekgrid
 
std::string skname
 

Detailed Description

Base class for Sk parser.

parse is the only pure virtual function that must be overridden holds various information about S(k) and access functions used by qmcfinitesize

Definition at line 19 of file SkParserBase.h.

Member Typedef Documentation

◆ Grid_t

Definition at line 22 of file SkParserBase.h.

Constructor & Destructor Documentation

◆ SkParserBase()

Definition at line 7 of file SkParserBase.cpp.

References SkParserBase::kgrid, SkParserBase::kgridraw, SkParserBase::sk, SkParserBase::skerr, SkParserBase::skerr_raw, and SkParserBase::skraw.

7  : isParseSuccess(false), isGridComputed(false), isSkComputed(false), skname("SkAll")
8 {
9  skraw.resize(0);
10  sk.resize(0);
11  skerr.resize(0);
12  skerr_raw.resize(0);
13  kgridraw.resize(0);
14  kgrid.resize(0);
15 }
std::vector< RealType > skerr_raw
Definition: SkParserBase.h:60
std::vector< PosType > kgridraw
Definition: SkParserBase.h:61
std::vector< RealType > skraw
Definition: SkParserBase.h:59
std::vector< PosType > kgrid
Definition: SkParserBase.h:65
std::vector< RealType > sk
Definition: SkParserBase.h:63
std::vector< RealType > skerr
Definition: SkParserBase.h:64

◆ ~SkParserBase()

virtual ~SkParserBase ( )
inlinevirtual

Definition at line 25 of file SkParserBase.h.

25 {}

Member Function Documentation

◆ compute_grid()

void compute_grid ( )

Definition at line 17 of file SkParserBase.cpp.

References APP_ABORT, qmcplusplus::get_gridinfo_from_posgrid(), SkParserBase::isGridComputed, SkParserBase::isParseSuccess, SkParserBase::kgrid, SkParserBase::kgridraw, LinearGrid< T, CT >::set(), SkParserBase::xgrid, SkParserBase::ygrid, and SkParserBase::zgrid.

Referenced by SkParserBase::compute_sk(), SkParserBase::get_grid(), and SkParserBase::set_grid().

18 {
19  if (!isParseSuccess)
20  APP_ABORT("SkParserBase::compute_grid(..) : Initial parse failed");
21 
22  // cout<<" We're about to get grid info...\n";
23  RealType lx(0), rx(0);
24  RealType ly(0), ry(0);
25  RealType lz(0), rz(0);
26 
27  RealType dx(0), dy(0), dz(0);
28  IndexType Nx(0), Ny(0), Nz(0);
29  get_gridinfo_from_posgrid(kgridraw, 0, lx, rx, dx, Nx);
30  get_gridinfo_from_posgrid(kgridraw, 1, ly, ry, dy, Ny);
31  get_gridinfo_from_posgrid(kgridraw, 2, lz, rz, dz, Nz);
32 
33  // cout<<" Done with grid info...\n";
34  kgrid.resize(Nx * Ny * Nz);
35 
36  xgrid.set(lx, rx, Nx);
37  ygrid.set(ly, ry, Ny);
38  zgrid.set(lz, rz, Nz);
39 
40 
41  isGridComputed = true;
42 }
void set(T ri, T rf, int n) override
Set the grid given the parameters.
std::vector< PosType > kgridraw
Definition: SkParserBase.h:61
std::vector< PosType > kgrid
Definition: SkParserBase.h:65
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
QMCTraits::RealType RealType
void get_gridinfo_from_posgrid(const std::vector< PosType > &posgridlist, const IndexType &axis, RealType &lx, RealType &rx, RealType &dx, IndexType &Nx)
Definition: FSUtilities.cpp:6

◆ compute_sk()

void compute_sk ( )

Definition at line 74 of file SkParserBase.cpp.

References APP_ABORT, SkParserBase::compute_grid(), OneDimGridBase< T, CT >::getIndex(), SkParserBase::isGridComputed, SkParserBase::isParseSuccess, SkParserBase::isSkComputed, SkParserBase::kgrid, SkParserBase::kgridraw, OneDimGridBase< T, CT >::size(), SkParserBase::sk, SkParserBase::skerr, SkParserBase::skerr_raw, SkParserBase::skraw, SkParserBase::xgrid, SkParserBase::ygrid, and SkParserBase::zgrid.

Referenced by SkParserBase::get_sk().

75 {
76  if (!isParseSuccess)
77  APP_ABORT("SkParserBase::compute_sk() : Initial parse failed");
78  // cout<<"In compute_sk()\n";
79 
80  if (kgridraw.size() != skraw.size())
81  APP_ABORT("SkParserBase::compute_sk() : Kgrid and SK not the same size");
82 
83  if (!isGridComputed)
84  compute_grid();
85 
86  IndexType nx(0), ny(0), nz(0);
87  IndexType Nx(0), Ny(0), Nz(0);
88  IndexType newindex(0);
89 
90  Nx = xgrid.size();
91  Ny = ygrid.size();
92  Nz = zgrid.size();
93 
94  sk.resize(Nx * Ny * Nz);
95  skerr.resize(Nx * Ny * Nz);
96 
97  //set k=(0,0,0), S(0)=0, Serr(0)=0
98 
99  nx = xgrid.getIndex(0);
100  ny = ygrid.getIndex(0);
101  nz = zgrid.getIndex(0);
102 
103  newindex = nx * Ny * Nz + ny * Nz + nz;
104 
105  kgrid[newindex] = 0;
106  sk[newindex] = 0.0;
107  skerr[newindex] = 0.0;
108 
109  for (IndexType i = 0; i < kgridraw.size(); i++)
110  {
111  nx = xgrid.getIndex(kgridraw[i][0]);
112  ny = ygrid.getIndex(kgridraw[i][1]);
113  nz = zgrid.getIndex(kgridraw[i][2]);
114 
115  newindex = nx * Ny * Nz + ny * Nz + nz;
116  kgrid[newindex] = kgridraw[i];
117  sk[newindex] = skraw[i];
118  skerr[newindex] = skerr_raw[i];
119  }
120 
121  isSkComputed = true;
122 }
std::vector< RealType > skerr_raw
Definition: SkParserBase.h:60
std::vector< PosType > kgridraw
Definition: SkParserBase.h:61
std::vector< RealType > skraw
Definition: SkParserBase.h:59
std::vector< PosType > kgrid
Definition: SkParserBase.h:65
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
int size() const
returns the size of the grid
std::vector< RealType > sk
Definition: SkParserBase.h:63
std::vector< RealType > skerr
Definition: SkParserBase.h:64

◆ get_grid()

void get_grid ( Grid_t xgrid,
Grid_t ygrid,
Grid_t zgrid 
)

Definition at line 63 of file SkParserBase.cpp.

References SkParserBase::compute_grid(), SkParserBase::isGridComputed, OneDimGridBase< T, CT >::rmax(), OneDimGridBase< T, CT >::rmin(), LinearGrid< T, CT >::set(), OneDimGridBase< T, CT >::size(), SkParserBase::xgrid, SkParserBase::ygrid, and SkParserBase::zgrid.

Referenced by QMCFiniteSize::initialize().

64 {
65  // cout<<"In get_grid(..)\n";
66  if (!isGridComputed)
67  compute_grid();
68  // cout<<"done with compute_grid()\n";
69  xgrid_i.set(xgrid.rmin(), xgrid.rmax(), xgrid.size());
70  ygrid_i.set(ygrid.rmin(), ygrid.rmax(), ygrid.size());
71  zgrid_i.set(zgrid.rmin(), zgrid.rmax(), zgrid.size());
72 }
T rmin() const
return the first grid point
int size() const
returns the size of the grid
T rmax() const
return the last grid point

◆ get_grid_raw()

std::vector<PosType> get_grid_raw ( )
inline

Definition at line 33 of file SkParserBase.h.

References SkParserBase::kgridraw.

33 { return kgridraw; };
std::vector< PosType > kgridraw
Definition: SkParserBase.h:61

◆ get_sk()

void get_sk ( std::vector< RealType > &  sk,
std::vector< RealType > &  skerr 
)

Definition at line 124 of file SkParserBase.cpp.

References SkParserBase::compute_sk(), SkParserBase::isSkComputed, SkParserBase::sk, and SkParserBase::skerr.

Referenced by QMCFiniteSize::execute().

125 {
126  // cout<<"In get_sk(..)\n";
127  if (!isSkComputed)
128  compute_sk();
129 
130  sk_i = sk;
131  skerr_i = skerr;
132 }
std::vector< RealType > sk
Definition: SkParserBase.h:63
std::vector< RealType > skerr
Definition: SkParserBase.h:64

◆ get_sk_raw()

std::vector<RealType> get_sk_raw ( )
inline

Definition at line 34 of file SkParserBase.h.

References SkParserBase::skraw.

Referenced by QMCFiniteSize::execute().

34 { return skraw; };
std::vector< RealType > skraw
Definition: SkParserBase.h:59

◆ get_skerr_raw()

std::vector<RealType> get_skerr_raw ( )
inline

Definition at line 35 of file SkParserBase.h.

References SkParserBase::skerr_raw.

Referenced by QMCFiniteSize::execute().

35 { return skerr_raw; };
std::vector< RealType > skerr_raw
Definition: SkParserBase.h:60

◆ has_grid()

bool has_grid ( )
inline

Definition at line 44 of file SkParserBase.h.

References SkParserBase::hasGrid.

Referenced by QMCFiniteSize::initialize().

44 { return hasGrid; }

◆ is_normalized()

bool is_normalized ( )
inline

Definition at line 43 of file SkParserBase.h.

References SkParserBase::isNormalized.

Referenced by QMCFiniteSize::execute().

43 { return isNormalized; }

◆ parse()

virtual void parse ( const std::string &  fname)
pure virtual

◆ set_grid() [1/2]

void set_grid ( const std::vector< PosType > &  gridpoints)

Definition at line 55 of file SkParserBase.cpp.

References APP_ABORT, SkParserBase::compute_grid(), SkParserBase::kgridraw, and SkParserBase::skraw.

Referenced by QMCFiniteSize::initialize().

56 {
57  if (skraw.size() != kgridraw1.size())
58  APP_ABORT("SkParserBase::set_grid: S(k) and k-grid don't match");
59  kgridraw = kgridraw1;
60  compute_grid();
61 }
std::vector< PosType > kgridraw
Definition: SkParserBase.h:61
std::vector< RealType > skraw
Definition: SkParserBase.h:59
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ set_grid() [2/2]

void set_grid ( const std::vector< TinyVector< int, OHMMS_DIM >> &  gridpoints)

◆ setName()

void setName ( std::string  in_name)
inline

Definition at line 46 of file SkParserBase.h.

References SkParserBase::skname.

46 { skname = in_name; }

Member Data Documentation

◆ hasGrid

bool hasGrid
protected

◆ isGridComputed

bool isGridComputed
protected

◆ isNormalized

bool isNormalized
protected

◆ isParseSuccess

◆ isSkComputed

bool isSkComputed
protected

Definition at line 51 of file SkParserBase.h.

Referenced by SkParserBase::compute_sk(), and SkParserBase::get_sk().

◆ kgrid

◆ kgridraw

◆ sk

◆ skerr

◆ skerr_raw

◆ skname

std::string skname
protected

Definition at line 67 of file SkParserBase.h.

Referenced by SkParserHDF5::parse(), and SkParserBase::setName().

◆ skraw

◆ xgrid

Grid_t xgrid
protected

◆ ygrid

Grid_t ygrid
protected

◆ zgrid

Grid_t zgrid
protected

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