QMCConfigIO Class Reference

This class is meant to handle all of the file I/O for configuration files, which can easily get up to several gigabytes for longer runs on larger molecules. More...

#include <QMCConfigIO.h>

List of all members.

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


Detailed Description

This class is meant to handle all of the file I/O for configuration files, which can easily get up to several gigabytes for longer runs on larger molecules.

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.


Constructor & Destructor Documentation

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 (  ) 

Destructor.

Calls close().

Definition at line 60 of file QMCConfigIO.cpp.

References close().

QMCConfigIO::QMCConfigIO ( int  numElectrons  ) 

Constructor.

Assigns zero to the fstream pointer.

Parameters:
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.


Member Function Documentation

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.

Parameters:
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.

Returns:
The name of the file.

Definition at line 528 of file QMCConfigIO.cpp.

References filename.

int QMCConfigIO::getNumberConfigsWritten (  ) 

Returns:
The number of configurations we wrote into the file.

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.

Parameters:
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.

Parameters:
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().

template<class T>
fstream& QMCConfigIO::operator<< ( 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.


Member Data Documentation

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().


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

Generated on Sat Jul 5 16:14:03 2008 for QMcBeaver by  doxygen 1.5.6