Path Integral Quantum Monte Carlo
Public Member Functions | Static Public Attributes
TimeEstimator Class Reference

An estimator which tracks the ammount of time between bins, summing them into a total at the end. More...

#include <estimator.h>

+ Inheritance diagram for TimeEstimator:
+ Collaboration diagram for TimeEstimator:

Public Member Functions

 TimeEstimator (const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="estimator")
 Constructor. More...
 
void sample ()
 Overload sampling to make sure it is always done, regardless of ensemble.
 
string getName () const
 Get the name of the estimator.
 
void output ()
 Grab the final time and write to disk. More...
 
- Public Member Functions inherited from EstimatorBase
 EstimatorBase (const Path &_path, ActionBase *_actionPtr, const MTRand &_random, double _maxR, int _frequency=1, string _label="")
 Constructor. More...
 
virtual ~EstimatorBase ()
 Destructor.
 
void reset ()
 Reset numAccumulated and the estimator to 0.
 
void restart (const uint32, const uint32)
 Restart the measurment process from a previous state.
 
virtual void outputFlat ()
 Output a flat estimator value to disk. More...
 
virtual void outputFooter ()
 Ouptut the fooder to disk.
 
bool baseSample ()
 Determine the basic sampling condition. More...
 
uint32 getTotNumAccumulated () const
 Get the total number of accumulated measurments.
 
uint32 getNumAccumulated () const
 Get the number of accumulated measurements since the last reset.
 
uint32 getNumSampled () const
 Get the number of samples since the last reset.
 
void prepare ()
 Prepare the estimator for i/o. More...
 
void addEndLine ()
 Add a carriage return to estimator files.
 
void appendLabel (string append)
 Append to default label. More...
 
string getLabel () const
 Get the estimator label.
 

Static Public Attributes

static const string name
 

Additional Inherited Members

- Protected Member Functions inherited from EstimatorBase
void initialize (int)
 Initialize estimator. More...
 
void initialize (vector< string >)
 Initialize estimator. More...
 
- Protected Attributes inherited from EstimatorBase
const Pathpath
 A constant reference to the paths.
 
ActionBaseactionPtr
 A pointer to the action.
 
MTRand random
 
double maxR
 
fstream * outFilePtr
 The output fie.
 
map< string, int > estIndex
 Map estimator labels to indices.
 
Array< double, 1 > estimator
 The estimator array.
 
Array< double, 1 > norm
 The normalization factor for each estimator.
 
int numEst
 The number of individual quantities measured.
 
int frequency
 The frequency at which we accumulate.
 
int startSlice
 Where imaginary time averages begin.
 
int endSlice
 Where imaginary time averages end.
 
int endDiagSlice
 Where imaginary time averages end for diagonal estimiators.
 
vector< double > sliceFactor
 Used to properly incorporate end affects.
 
string label
 The label used for the output file.
 
uint32 numSampled
 The number of times we have sampled.
 
uint32 numAccumulated
 The number of accumulated values.
 
uint32 totNumAccumulated
 The total number of accumulated values.
 
int numBeads0
 The target number of beads for the canonical ensemble.
 
bool diagonal
 Is this a diagonal estimator?
 
bool endLine
 Should we output a carriage return?
 
bool canonical
 Are we in the canonical ensemble?
 
string header
 The data file header.
 

Detailed Description

An estimator which tracks the ammount of time between bins, summing them into a total at the end.

Definition at line 128 of file estimator.h.

Constructor & Destructor Documentation

◆ TimeEstimator()

TimeEstimator::TimeEstimator ( const Path _path,
ActionBase _actionPtr,
const MTRand &  _random,
double  _maxR,
int  _frequency = 1,
string  _label = "estimator" 
)

Constructor.

Used to measure the time between bins

Definition at line 340 of file estimator.cpp.

342  :
343  EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
344 
345  /* Set estimator name and header */
346  header = str(format("%16s%16s") % "us" % "mcsteps");
347  endLine = false;
348  initialize(2);
349 }
string header
The data file header.
Definition: estimator.h:110
bool endLine
Should we output a carriage return?
Definition: estimator.h:107
EstimatorBase(const Path &_path, ActionBase *_actionPtr, const MTRand &_random, double _maxR, int _frequency=1, string _label="")
Constructor.
Definition: estimator.cpp:103
void initialize(int)
Initialize estimator.
Definition: estimator.cpp:201
+ Here is the call graph for this function:

Member Function Documentation

◆ output()

void TimeEstimator::output ( )
virtual

Grab the final time and write to disk.


Reimplemented from EstimatorBase.

Definition at line 376 of file estimator.cpp.

376  {
377  time_end = std::chrono::high_resolution_clock::now();
378  estimator(0) = 0.001*std::chrono::duration_cast<std::chrono::nanoseconds>(
379  time_end - time_begin).count()/numAccumulated;
380  estimator(1) = 1.0*numAccumulated;
381 
382  // close the loop
383  time_begin = time_end;
384 
385  /* Now write the estimator values to disk */
386  for (int n = 0; n < numEst; n++)
387  (*outFilePtr) << format("%16.8E") % estimator(n);
388 
389  if (endLine)
390  (*outFilePtr) << endl;
391 
392  /* Reset all values */
393  reset();
394 }
void reset()
Reset numAccumulated and the estimator to 0.
Definition: estimator.cpp:261
Array< double, 1 > estimator
The estimator array.
Definition: estimator.h:90
int numEst
The number of individual quantities measured.
Definition: estimator.h:93
uint32 numAccumulated
The number of accumulated values.
Definition: estimator.h:102
fstream * outFilePtr
The output fie.
Definition: estimator.h:86
+ Here is the call graph for this function:

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