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

Create a 2d histogram of particle positions but only store the average. More...

#include <estimator.h>

+ Inheritance diagram for PlaneAverageExternalPotentialEstimator:
+ Collaboration diagram for PlaneAverageExternalPotentialEstimator:

Public Member Functions

 PlaneAverageExternalPotentialEstimator (const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="planeaveVext")
 Constructor. More...
 
 ~PlaneAverageExternalPotentialEstimator ()
 Destructor.
 
string getName () const
 Get the name of the estimator.
 
void output ()
 Output a flat estimator value 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.
 
virtual void sample ()
 Sample the estimator. More...
 
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

Create a 2d histogram of particle positions but only store the average.

Definition at line 362 of file estimator.h.

Constructor & Destructor Documentation

◆ PlaneAverageExternalPotentialEstimator()

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

Constructor.

2-dimensional average external potential.

Definition at line 1191 of file estimator.cpp.

1193  :
1194  EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1195 
1196  /* We choose an odd number to make sure (0,0) is the central
1197  * grid box. */
1198  numLinearGrid = 4*NGRIDSEP+1;
1199  numGrid = numLinearGrid*numLinearGrid;
1200 
1201  /* The spatial discretization */
1202  for (int i = 0; i < NDIM; i++)
1203  dl[i] = path.boxPtr->side[i] / numLinearGrid;
1204 
1205  /* This is a diagonal estimator that gets its own file */
1206  initialize(numGrid);
1207 
1208  /* The header contains information about the grid */
1209  header = str(format("# PIMCID: %s\n") % constants()->id());
1210  header = str(format("# ESTINF: dx = %12.6E dy = %12.6E NGRIDSEP = %d\n")
1211  % dl[0] % dl[1] % numLinearGrid);
1212  header += str(format("#%15s") % "plane external potential");
1213 
1214  side = path.boxPtr->side;
1215 }
dVec side
The linear dimensions of the box.
Definition: container.h:31
string header
The data file header.
Definition: estimator.h:110
EstimatorBase(const Path &_path, ActionBase *_actionPtr, const MTRand &_random, double _maxR, int _frequency=1, string _label="")
Constructor.
Definition: estimator.cpp:103
const Path & path
A constant reference to the paths.
Definition: estimator.h:78
void initialize(int)
Initialize estimator.
Definition: estimator.cpp:201
const Container * boxPtr
A constant reference to the container class.
Definition: path.h:43
#define NDIM
Number of spatial dimnsions.
Definition: common.h:71
#define NGRIDSEP
Spatial separations to be used in each dimension of the particle position grid.
Definition: common.h:93
ConstantParameters * constants()
Global public access to the constants.
Definition: constants.h:201
+ Here is the call graph for this function:

Member Function Documentation

◆ output()

void PlaneAverageExternalPotentialEstimator::output ( )
virtual

Output a flat estimator value to disk.

Instead of keeping the individual binned averages, here we reset the output file and write the current average to disk.

Reimplemented from EstimatorBase.

Definition at line 1261 of file estimator.cpp.

1261  {
1262 
1263  /* Prepare the position file for writing over old data */
1264  communicate()->file(label)->reset();
1265 
1266  (*outFilePtr) << header;
1267  if (endLine)
1268  (*outFilePtr) << endl;
1269 
1270  /* Now write the running average of the estimator to disk */
1271  double Vext = 0.0;
1272  for (int n = 0; n < numEst; n++) {
1273  if (abs(norm(n)) > 0.0)
1274  Vext = estimator(n)/norm(n);
1275  else
1276  Vext = 0.0;
1277  (*outFilePtr) << format("%16.8E\n") % Vext;
1278  }
1279 
1280  communicate()->file(label)->rename();
1281 }
File * file(string type)
Get method returning file object.
Definition: communicator.h:85
Array< double, 1 > estimator
The estimator array.
Definition: estimator.h:90
Array< double, 1 > norm
The normalization factor for each estimator.
Definition: estimator.h:91
bool endLine
Should we output a carriage return?
Definition: estimator.h:107
int numEst
The number of individual quantities measured.
Definition: estimator.h:93
string label
The label used for the output file.
Definition: estimator.h:99
void reset()
Reset a file.
void rename()
Rename a file.
Communicator * communicate()
Global public access to the communcator singleton.
Definition: communicator.h:121
+ Here is the call graph for this function:

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