QMCPACK
SkParserHDF5 Class Reference

Class to handle reading the S(k) directly from stat.h5 file. More...

+ Inheritance diagram for SkParserHDF5:
+ Collaboration diagram for SkParserHDF5:

Public Member Functions

void parse (const std::string &fname) override
 
- Public Member Functions inherited from SkParserBase
 SkParserBase ()
 
virtual ~SkParserBase ()
 
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)
 

Private Attributes

hdf_archive statfile
 

Additional Inherited Members

- Public Types inherited from SkParserBase
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 > >
 
- Protected Attributes inherited from SkParserBase
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

Class to handle reading the S(k) directly from stat.h5 file.

This class parses the kgrid and fluctuation S(k) from skall estimator. In the parse function, it performs a simple equilibration estimate and block average to create the S(k) to use for the corrections

Definition at line 17 of file SkParserHDF5.h.

Member Function Documentation

◆ parse()

void parse ( const std::string &  fname)
overridevirtual

Implements SkParserBase.

Definition at line 7 of file SkParserHDF5.cpp.

References hdf_archive::close(), qmcplusplus::estimateEquilibration(), hdf_archive::getShape(), qmcplusplus::getStats(), SkParserBase::hasGrid, SkParserBase::isNormalized, SkParserBase::isParseSuccess, SkParserBase::kgridraw, hdf_archive::open(), hdf_archive::readSlabReshaped(), SkParserBase::skerr_raw, SkParserBase::skname, SkParserBase::skraw, and SkParserHDF5::statfile.

8 {
9  bool result = statfile.open(fname);
10  if (!result)
11  {
12  std::cout << "SkParserHDF5::parse could not open " << fname << std::endl;
13  exit(1);
14  }
15 
16  //read the kpoints
17  std::vector<int> readShape;
18  statfile.getShape<int>(skname + "/kpoints/value", readShape);
19  assert(readShape[1] == 3);
20  std::array<int, 2> kdims{readShape[0], readShape[1]};
21  std::vector<RealType> ktmp;
22  statfile.readSlabReshaped(ktmp, kdims, skname + "/kpoints/value");
23  for (int ik = 0; ik < readShape[0]; ik++)
24  {
25  PosType k;
26  k[0] = ktmp[3 * ik];
27  k[1] = ktmp[3 * ik + 1];
28  k[2] = ktmp[3 * ik + 2];
29  kgridraw.push_back(k);
30  }
31  int nKpts = kgridraw.size();
32 
33  //read the <rho_-k*rho_k> term
34  statfile.getShape<int>(skname + "/rhok_e_e/value", readShape);
35  assert(readShape[1] == nKpts);
36  std::vector<RealType> rhok_e_tmp;
37  std::array<int, 2> rhok_e_dims{readShape[0], readShape[1]};
38  statfile.readSlabReshaped(rhok_e_tmp, rhok_e_dims, skname + "/rhok_e_e/value");
39  int nBlocks = readShape[0];
40 
41  //read the Im(rho_k) term
42  statfile.getShape<int>(skname + "/rhok_e_i/value", readShape);
43  std::vector<RealType> rhok_i_tmp;
44  std::array<int, 2> rhok_i_dims{readShape[0], readShape[1]};
45  statfile.readSlabReshaped(rhok_i_tmp, rhok_i_dims, skname + "/rhok_e_i/value");
46  assert(readShape[0] == nBlocks);
47  assert(readShape[1] == nKpts);
48 
49  //read the Re(rho_k)
50  statfile.getShape<int>(skname + "/rhok_e_r/value", readShape);
51  std::vector<RealType> rhok_r_tmp;
52  std::array<int, 2> rhok_r_dims{readShape[0], readShape[1]};
53  statfile.readSlabReshaped(rhok_r_tmp, rhok_r_dims, skname + "/rhok_e_r/value");
54  assert(readShape[0] == nBlocks);
55  assert(readShape[1] == nKpts);
56 
57  //For each k, evaluate the flucuating S(k) for all blocks.
58  //Then perform a simple equilibration estimate for this particular S(k) value
59  //Store the average and error after throwing out the equilibration
60  for (int ik = 0; ik < nKpts; ik++)
61  {
62  std::vector<RealType> block_data;
63  for (int ib = 0; ib < nBlocks; ib++)
64  {
65  RealType re, rr, ri;
66  re = rhok_e_tmp[nKpts * ib + ik];
67  rr = rhok_r_tmp[nKpts * ib + ik];
68  ri = rhok_i_tmp[nKpts * ib + ik];
69  block_data.push_back(re - (rr * rr + ri * ri));
70  }
71  int ieq = estimateEquilibration(block_data);
72  RealType avg, err;
73  getStats(block_data, avg, err, ieq);
74  skraw.push_back(avg);
75  skerr_raw.push_back(err);
76  }
77 
78  hasGrid = false;
79  isNormalized = false;
80  isParseSuccess = true;
81 
82  statfile.close();
83 }
std::vector< RealType > skerr_raw
Definition: SkParserBase.h:60
bool open(const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
open a file
std::vector< PosType > kgridraw
Definition: SkParserBase.h:61
std::vector< RealType > skraw
Definition: SkParserBase.h:59
void close()
close all the open groups and file
Definition: hdf_archive.cpp:38
void readSlabReshaped(T &data, const std::array< IT, RANK > &shape, const std::string &aname)
read file dataset with a specific shape into a container and check status
Definition: hdf_archive.h:321
QMCTraits::PosType PosType
bool getShape(const std::string &aname, std::vector< int > &sizes_out)
read the shape of multidimensional filespace from the group aname this function can be used to query ...
Definition: hdf_archive.h:231
QMCTraits::RealType RealType
void getStats(const std::vector< RealType > &vals, RealType &avg, RealType &err, int start)
Simpleaverage and error estimate.
Definition: FSUtilities.cpp:31
int estimateEquilibration(const std::vector< RealType > &vals, RealType frac)
estimate equilibration of block data
Definition: FSUtilities.cpp:50

Member Data Documentation

◆ statfile

hdf_archive statfile
private

Definition at line 23 of file SkParserHDF5.h.

Referenced by SkParserHDF5::parse().


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