Path Integral Quantum Monte Carlo
pimc.h
Go to the documentation of this file.
1 
9 #ifndef PIMC_H
10 #define PIMC_H
11 
12 #include "common.h"
13 #include "communicator.h"
14 #include "estimator.h"
15 
16 class Path;
17 class LookupTable;
18 class MoveBase;
19 class EstimatorBase;
20 
22 typedef boost::ptr_vector<EstimatorBase> estimator_vector;
23 
25 typedef boost::ptr_vector<MoveBase> move_vector;
26 
27 // ========================================================================
28 // PathIntegralMonteCarlo Class
29 // ========================================================================
38  public:
39  PathIntegralMonteCarlo (boost::ptr_vector<Path> &,MTRand &, boost::ptr_vector<move_vector> &,
40  boost::ptr_vector<estimator_vector> &, const bool, uint32 binSize=100);
42 
43 
44  /* The equilibration relaxation */
45  void equilStepDiagonal();
46 
47  bool equilStepRelaxmu();
48  bool equilStepRelaxC0();
49 
50  void equilStep(const uint32, const bool, const bool);
51 
52  /* The actual monte carlo step */
53  void step();
54 
55  /* Output results of the simulation */
56  void finalOutput();
57 
58  /* Save the PIMC state to disk */
59  void saveState(const int finalSave = 0);
60 
61  /* Output the world-line configurations in the protein databank format */
62  void outputPDB();
63 
66  int numConfig;
75 
76  void printWormState();
77  string printHistogram();
78 
79  private:
80  MTRand &random; // The global random number generator
81 
82  int configNumber; // The output configuration number
83  int numImagTimeSweeps; // Partitioning used for updates
84  int numSteps; // The number of steps performed during equilibration
85  int numUpdates; // The maximum number of updates per step.
86  uint32 binSize; // The maximum number measurements per bin.
87  int numParticles; // The number of particles
88 
89  int N0;
90  bool foundmu;
91  bool foundC0;
92  double muFactor;
93  double bestmu;
94  int bestPN;
95  double bestDiffAveN;
96  bool inWindow;
97 
98  int sgnAveN;
99 
100  Array<int,1> PN;
101  bool relaxmuMessage;
102  bool relaxC0Message;
103  bool equilMessage;
104  bool equilODMessage;
105  vector <double> C0Vals;
106  vector <double> diagFracVals;
107 
108  double targetDiagFrac;
109  int sgnDiagFrac;
110  double shiftC0;
111  int barStepSize;
112  int numRemainingSteps;
113  int numBars;
114 
115  uint32 Npaths; // Number of paths
116 
117  vector<string> stateStrings; // A vector of state strings from the last bin
118 
119  bool startWithState; // Are we starting from a saved state
120  bool success; // Track move success/failure
121 
122  boost::ptr_vector<Path> &pathPtrVec; // The vector of all paths
123  Path &path; // A reference to the first path in the path vector
124 
125  boost::ptr_vector<move_vector> &movePtrVec; // Vector of all move_vectors
126  move_vector &move; // A reference to the first move_vector
127 
128  boost::ptr_vector<estimator_vector> &estimatorPtrVec; // Vector of estimators for
129  // each path followed by multipath
130  estimator_vector &estimator; // A reference to the first estimator_vector
131 
132  vector <double> attemptDiagProb; // The cumulative diagonal attempt Probabilities
133  vector <double> attemptOffDiagProb; // The cumulative off-diagonal attempt Probabilities
134 
135  map <string,int> moveIndex; // A map to keep track of move names and indices
136  map <string,int> estimatorIndex; // A map to keep track of estimator names and indices
137 
138  /* Output estimators to disk */
139  void output();
140 
141  /* perform an iterative linear regrssion for C0 calculation */
142  double linearRegressionC0();
143 
144  /* Load the PIMC state from disk */
145  void loadState();
146 
147  /* Load classical or quantum initial states */
148  void loadClassicalState(Array <dVec,2>&, Array <unsigned int, 2>&, int);
149  void loadQuantumState(Array <dVec,2>&, Array <beadLocator,2>&, Array<beadLocator,2>&, int, int);
150 
151  /* Shuffle the offDiag move list, returning it in moves*/
152  void shuffleMoves();
153 
154  /* Perform a Metropolis update */
155  string update(const double,const int,const int);
156 
157 };
158 
159 #endif
160 
The base class that all estimator classes will be derived from.
Definition: estimator.h:28
The particle (bead) lookup table.
Definition: lookuptable.h:29
The base class that all moves will be derived from.
Definition: move.h:30
The main driver class for the entire path integral monte carlo program.
Definition: pimc.h:37
void outputPDB()
Output the worldline configuration to disk using PDB , suitable for plotting using vmd.
Definition: pimc.cpp:1161
~PathIntegralMonteCarlo()
Destructor.
Definition: pimc.cpp:164
bool equilStepRelaxC0()
Relax the worm constant C0 until we have found the desired diagonal fraction.
Definition: pimc.cpp:412
bool equilStepRelaxmu()
Relax the chemical potential to find a target number of particles.
Definition: pimc.cpp:292
int prevNumCoMAttempted
Number of Center of Mass moves attempted.
Definition: pimc.h:68
int numDisplaceAttempted
Number of equil Displace moves.
Definition: pimc.h:70
int numDisplaceAccepted
Number of equil Displace moves accepted.
Definition: pimc.h:71
void saveState(const int finalSave=0)
Save the state of the simulation to disk, including all path, worm, move and estimator data.
Definition: pimc.cpp:804
int numConfig
Number of configurations;.
Definition: pimc.h:66
void equilStep(const uint32, const bool, const bool)
Equilibration.
Definition: pimc.cpp:561
void finalOutput()
Output simulation statistics to disk.
Definition: pimc.cpp:752
void step()
PIMC step.
Definition: pimc.cpp:688
string printHistogram()
Output a histogram to the terminal.
Definition: pimc.cpp:1361
int numStepsAttempted
Number of steps for relaxing C0.
Definition: pimc.h:74
PathIntegralMonteCarlo(boost::ptr_vector< Path > &, MTRand &, boost::ptr_vector< move_vector > &, boost::ptr_vector< estimator_vector > &, const bool, uint32 binSize=100)
Constructor.
Definition: pimc.cpp:27
int numCoMAttempted
Number of Center of Mass moves.
Definition: pimc.h:67
int numCoMAccepted
Number of equil CoM moves accepted.
Definition: pimc.h:69
int numNAttempted
The number of particle measurements.
Definition: pimc.h:73
void equilStepDiagonal()
Diagonal Equilibration.
Definition: pimc.cpp:198
int numDiagonal
Number of consecutive diagonal configs.
Definition: pimc.h:65
int numStoredBins
Number of stored estimators.
Definition: pimc.h:64
int numMuAttempted
Number of moves between mu adjustments.
Definition: pimc.h:72
The space-time trajectories.
Definition: path.h:29
Global common header with shared dependencies and methods.
unsigned long uint32
Unsigned integer type, at least 32 bits.
Definition: common.h:105
Class definitions for all file input/output.
Estimator class definitions.
boost::ptr_vector< EstimatorBase > estimator_vector
A vector containing measurable estimators.
Definition: pimc.h:19
boost::ptr_vector< MoveBase > move_vector
A vector containing Monte Carlo updates.
Definition: pimc.h:25