#include <QMCConfigIO.h>
Public Member Functions | |
QMCConfigIO () | |
Constructor. | |
~QMCConfigIO () | |
Destructor. | |
QMCConfigIO (int numElectrons) | |
Constructor. | |
void | open (string filename, bool forWriting) |
Returns a string with the name of the file this class is writing/reading. | |
void | close () |
Closes the file and then deletes the reference and sets the pointer to zero. | |
bool | eof () |
Are there more records in the file? | |
string | getFilename () |
Returns a string with the name of the file this class is writing/reading. | |
int | getNumberConfigsWritten () |
void | setPrecision () |
This will set all the precision requirements we want for our output stream. | |
void | writeCorrelatedSamplingConfiguration (Array2D< double > &R, double SCF_Laplacian_PsiRatio, Array2D< double > &SCF_Grad_PsiRatio, double lnJastrow, double PE, double weight) |
This will write the contents of all the arguments sent to this function into the configuration file. | |
void | readCorrelatedSamplingConfiguration (Array2D< double > &R, double &SCF_Laplacian_PsiRatio, Array2D< double > &SCF_Grad_PsiRatio, double &lnJastrow, double &PE, double &weight) |
This will read one set of parameters from the configuration file and store them in the arguments to this function. | |
template<class T> | |
fstream & | operator<< (T rhs) |
Just in case we want to augment our output file. | |
Static Private Attributes | |
static fstream * | config_strm = 0 |
This is a pointer we can use to store our the information for the stream. | |
static string | filename = "" |
The filename we opened the stream with. | |
static bool | areWriting = false |
Are we reading or writing? | |
static int | numElectrons = 0 |
Number of electrons. | |
static int | numWritten = 0 |
Number of configurations written. | |
static int | numRead = 0 |
It has two modes -- text and binary. I was going to add HDF5, but it looks like they're going to be adding a C++ PacketTable class in an upcoming release, so I'll wait until then since that seems like the way to go.
There are a couple advantages to binary output. First, a quick measurement with HMX reveals that binary files are about 50% the size of an equivalent text output. Second, binary output means that the code does not have to convert doubles etc into chars, possibly preserving a little more precision as well as effort. Third, the text output option uses endl frequently. endl flushes the buffer every time, meaning the code has to access the disk quite often. Binary does automatically flush -- we can control when.
some notes: 1) obviously, the binary output cfgs files are only meant to be used by the program within the same run. e.g. they are not portable at all.
2) i played around with gzip on the binary output, and the file size difference was very small. i conclude from this that compression doesn't make any difference.
3) Since there can only ever be one file (per node), all the data members are static.
Definition at line 63 of file QMCConfigIO.h.
QMCConfigIO::QMCConfigIO | ( | ) |
Constructor.
Assigns zero to the fstream pointer.
Definition at line 44 of file QMCConfigIO.cpp.
References areWriting, config_strm, numRead, and numWritten.
QMCConfigIO::~QMCConfigIO | ( | ) |
QMCConfigIO::QMCConfigIO | ( | int | numElectrons | ) |
Constructor.
Assigns zero to the fstream pointer.
since | two of the arrays in the file depend on this, we might as well keep this number in the class. |
Definition at line 65 of file QMCConfigIO.cpp.
References areWriting, config_strm, filename, inBinary, numElectrons, numRead, and numWritten.
void QMCConfigIO::open | ( | string | filename, | |
bool | forWriting | |||
) |
Returns a string with the name of the file this class is writing/reading.
If the file is opened for writing, it is opened in ios_base::trunc mode.
filename | the name of the file to open | |
forWriting | whether this instance of QMCConfig is meant to be reading from or writing to the file. |
Definition at line 88 of file QMCConfigIO.cpp.
References areWriting, close(), config_strm, filename, inBinary, numElectrons, numRead, and numWritten.
Referenced by QMCReadAndEvaluateConfigs::locally_CalculateProperties(), and QMCInput::openConfigFile().
void QMCConfigIO::close | ( | ) |
Closes the file and then deletes the reference and sets the pointer to zero.
Definition at line 508 of file QMCConfigIO.cpp.
References config_strm.
Referenced by QMCReadAndEvaluateConfigs::locally_CalculateProperties(), open(), and ~QMCConfigIO().
bool QMCConfigIO::eof | ( | ) |
Are there more records in the file?
Definition at line 533 of file QMCConfigIO.cpp.
References config_strm, numRead, and numWritten.
Referenced by QMCReadAndEvaluateConfigs::locally_CalculateProperties().
string QMCConfigIO::getFilename | ( | ) |
Returns a string with the name of the file this class is writing/reading.
Definition at line 528 of file QMCConfigIO.cpp.
References filename.
int QMCConfigIO::getNumberConfigsWritten | ( | ) |
void QMCConfigIO::setPrecision | ( | ) |
This will set all the precision requirements we want for our output stream.
Definition at line 553 of file QMCConfigIO.cpp.
References config_strm.
Referenced by writeCorrelatedSamplingConfiguration().
void QMCConfigIO::writeCorrelatedSamplingConfiguration | ( | Array2D< double > & | R, | |
double | SCF_Laplacian_PsiRatio, | |||
Array2D< double > & | SCF_Grad_PsiRatio, | |||
double | lnJastrow, | |||
double | PE, | |||
double | weight | |||
) |
This will write the contents of all the arguments sent to this function into the configuration file.
It will only print numElectrons x 3 elements from the arrays.
R | position vectors for all the electrons | |
SCF_Laplacian_PsiRatio | the calculated "D1" | |
SCF_Grad_PsiRatio | gradient vectors for all the electrons | |
lnJastrow | the result of the Jastrow functions | |
PE | the potential energy for the configuration | |
weight | a weight associated with the configuration |
Definition at line 271 of file QMCConfigIO.cpp.
References areWriting, Array2D< T >::array(), config_strm, Array2D< T >::dim1(), inBinary, numElectrons, numWritten, and setPrecision().
Referenced by QMCWalkerData::writeConfigs().
void QMCConfigIO::readCorrelatedSamplingConfiguration | ( | Array2D< double > & | R, | |
double & | SCF_Laplacian_PsiRatio, | |||
Array2D< double > & | SCF_Grad_PsiRatio, | |||
double & | lnJastrow, | |||
double & | PE, | |||
double & | weight | |||
) |
This will read one set of parameters from the configuration file and store them in the arguments to this function.
R | position vectors for all the electrons | |
SCF_Laplacian_PsiRatio | the calculated "D1" | |
SCF_Grad_PsiRatio | gradient vectors for all the electrons | |
lnJastrow | the result of the Jastrow functions | |
PE | the potential energy for the configuration | |
weight | a weight associated with the configuration |
Definition at line 387 of file QMCConfigIO.cpp.
References areWriting, Array2D< T >::array(), config_strm, Array2D< T >::dim1(), inBinary, numElectrons, and numRead.
Referenced by QMCReadAndEvaluateConfigs::locally_CalculateProperties().
fstream& QMCConfigIO::operator<< | ( | T | rhs | ) | [inline] |
Just in case we want to augment our output file.
.. Anything piped through this function will be printed in text, regardless of whether we're in binary mode.
Definition at line 175 of file QMCConfigIO.h.
References config_strm.
fstream * QMCConfigIO::config_strm = 0 [static, private] |
This is a pointer we can use to store our the information for the stream.
Definition at line 196 of file QMCConfigIO.h.
Referenced by close(), eof(), open(), operator<<(), QMCConfigIO(), readCorrelatedSamplingConfiguration(), setPrecision(), and writeCorrelatedSamplingConfiguration().
string QMCConfigIO::filename = "" [static, private] |
The filename we opened the stream with.
Definition at line 202 of file QMCConfigIO.h.
Referenced by getFilename(), open(), and QMCConfigIO().
bool QMCConfigIO::areWriting = false [static, private] |
Are we reading or writing?
Definition at line 207 of file QMCConfigIO.h.
Referenced by open(), QMCConfigIO(), readCorrelatedSamplingConfiguration(), and writeCorrelatedSamplingConfiguration().
int QMCConfigIO::numElectrons = 0 [static, private] |
Number of electrons.
Definition at line 212 of file QMCConfigIO.h.
Referenced by open(), QMCConfigIO(), readCorrelatedSamplingConfiguration(), and writeCorrelatedSamplingConfiguration().
int QMCConfigIO::numWritten = 0 [static, private] |
Number of configurations written.
Definition at line 217 of file QMCConfigIO.h.
Referenced by eof(), open(), QMCConfigIO(), and writeCorrelatedSamplingConfiguration().
int QMCConfigIO::numRead = 0 [static, private] |
Definition at line 218 of file QMCConfigIO.h.
Referenced by eof(), open(), QMCConfigIO(), and readCorrelatedSamplingConfiguration().