Path Integral Quantum Monte Carlo
action.h
Go to the documentation of this file.
1 
9 #include "constants.h"
10 
11 #ifndef ACTION_H
12 #define ACTION_H
13 
14 class Path;
15 class PotentialBase;
16 class LookupTable;
17 class WaveFunctionBase;
18 
19 // ========================================================================
20 // ActionBase Class
21 // ========================================================================
29 class ActionBase {
30 
31  public:
32  ActionBase (const Path &, LookupTable &, PotentialBase *,
33  PotentialBase *, WaveFunctionBase *, bool _local=true,
34  string _name="Base", double _endFactor=1.0, int _period=1);
35  virtual ~ActionBase();
36 
38  string getActionName () { return name; }
39 
41  double kineticAction ();
43  double kineticAction (const beadLocator &);
45  double kineticAction (const beadLocator &, int wlLength);
46 
48  virtual double potentialAction() {return 0.0;}
49  virtual double potentialAction (const beadLocator &, const beadLocator &);
50  virtual double potentialAction (const beadLocator &) { return 0.0; }
51 
52  /* The bare potential action and its correction */
53  virtual double barePotentialAction (const beadLocator &) { return 0.0; }
54  virtual double potentialActionCorrection (const beadLocator &) {return 0.0; }
55  virtual double potentialActionCorrection (const beadLocator &, const beadLocator &) { return 0.0; }
56 
57  /* Various derivatives of the potential action */
58  virtual double derivPotentialActionTau (int) { return 0.0; }
59  virtual double derivPotentialActionLambda (int) { return 0.0; }
60  virtual double secondderivPotentialActionTau (int) { return 0.0; }
61 
62  /* Various derivatives of the potential action with a cutoff */
63  virtual double derivPotentialActionTau (int,double) { return 0.0; }
64  virtual double derivPotentialActionLambda (int,double) { return 0.0; }
65 
66  /* gradient of the potential action */
67  virtual dVec gradPotentialAction(int) { return 0.0; }
68 
69  /* r \dot gradU -> for virial estimator.
70  * It is necessary to split the terms in order to compute
71  * the specific heat efficiently.*/
72  virtual double rDOTgradUterm1(int) { return 0.0; }
73  virtual double rDOTgradUterm2(int) { return 0.0; }
74 
75  /* (r-R) \dot gradU -> for centroid virial estimator.
76  * It is necessary to split the terms in order to compute
77  * the specific heat efficiently.*/
78  virtual double deltaDOTgradUterm1(int) { return 0.0; }
79  virtual double deltaDOTgradUterm2(int) { return 0.0; }
80 
81  /* return virial kinetic energy estimator term */
82  virtual double virKinCorr(int) { return 0.0; }
83 
84  /* The bare local potential at a single time slice */
85  virtual TinyVector<double,2> potential(int) { return TinyVector<double,2>(0.0); }
86  virtual double potential(int,double) { return 0.0; }
87 
89  void setShift(int _shift) { shift = _shift; }
90 
92  int getShift() { return shift; }
93 
95  double rho0(const dVec&, const dVec&, int);
96  double rho0(const beadLocator&, const beadLocator&, int);
97  double rho0(const dVec&, const int);
98 
100  double ensembleWeight(const int);
101 
103  const bool local;
104 
105  /* The period of the action */
106  const int period;
107 
110 
111  Array <int,1> sepHist;
112  Array <int,1> cylSepHist;
113 
114  protected:
115  string name;
116 
118  const Path &path;
120  double endFactor;
121 
122  int shift;
123 
124  /* These definitions are needed for weighting in the canonical ensemble */
125  bool canonical;
126  int numBeads0;
127  bool window; // Whether or not to force particle numberin to window
128  int windowWidth; // Half width of particle number window
129  bool gaussianEnsemble; // Whether or not to use gaussian ensemble weight
130  double gaussianEnsembleSD; // Standard deviation of guassian ensemble weight
131 
133  double tau() {return shift * constants()->tau();}
134 
135  beadLocator bead2,bead3; // Bead indexers
136  dVec sep,sep2; // The spatial separation between beads.
137  double dSep; // The discretization for the separation histogram
138 
139  /* Update the separation histogram */
140  void updateSepHist(const dVec &);
141 };
142 
143 // ========================================================================
144 // LocalAction Class
145 // ========================================================================
150 class LocalAction : public ActionBase {
151 
152  public:
153  LocalAction (const Path &, LookupTable &, PotentialBase *,
154  PotentialBase *, WaveFunctionBase *, const TinyVector<double,2>&,
155  const TinyVector<double,2>&, bool _local=true, string _name="Local",
156  double _endFactor=1.0, int _period=1);
157  virtual ~LocalAction();
158 
159  /* The potential action */
160  double potentialAction ();
161  double potentialAction (const beadLocator &);
162 
163  /* The bare potential action and its correction */
164  double barePotentialAction (const beadLocator &);
165  double potentialActionCorrection (const beadLocator &);
166  double potentialActionCorrection (const beadLocator &, const beadLocator &);
167 
168  /* Various derivatives of the potential action */
169  double derivPotentialActionTau (int);
170  double derivPotentialActionLambda (int);
171  double secondderivPotentialActionTau (int);
172  double derivPotentialActionTau (int,double);
173  double derivPotentialActionLambda (int,double);
174 
175  /* gradient of the potential action */
176  virtual dVec gradPotentialAction(int slice) { return gradU(slice); }
177 
178  /* R \dot gradU -> for virial estimators */
179  double rDOTgradUterm1(int);
180  double rDOTgradUterm2(int);
181 
182  /* delta \dot gradU -> for centroid virial estimators */
183  virtual double deltaDOTgradUterm1(int slice) { return deltadotgradUterm1(slice); }
184  virtual double deltaDOTgradUterm2(int slice) { return deltadotgradUterm2(slice); }
185 
186  /* Returns virial kinetic energy correction term. */
187  virtual double virKinCorr(int slice) { return virialKinCorrection(slice); }
188 
189  /* The bare local potential at a single time slice */
190  virtual TinyVector<double,2> potential(int slice) { return V(slice); }
191  virtual double potential(int slice, double maxR) { return V(slice,maxR); }
192 
193  protected:
194  int eo;
195 
196  TinyVector <double,2> VFactor;
197  TinyVector <double,2> gradVFactor;
198 
199  /* The full potential for a single bead and all beads at a single
200  * time slice. */
201  double V(const beadLocator&);
202  double V(const int, const double);
203 
204  /* For the potential at a given time slice we separate the interaction
205  * and potential parts */
206  TinyVector <double,2> V(const int);
207 
208  /* The gradient of the potential squared for a single bead and all beads
209  * at a single time slice. */
210  double gradVSquared(const beadLocator&);
211  double gradVSquared(const int);
212  double gradVSquared(const int, const double);
213 
214  /* The full potential with the NN lookup table for a single bead and all
215  * beads at a single time slice. */
216  double Vnn(const beadLocator&);
217  double Vnn(const int);
218 
219  /* The bare potential action for a trajectory */
220  double bareUnn(const beadLocator &, const beadLocator &);
221 
222  /* The gradient of the potential squared for a single bead using the
223  * nearest neighbor lookup table */
224  double gradVnnSquared(const beadLocator&);
225 
226  /* gradient and Laplacian of potential energy */
227  dVec gradientV(const int);
228 
229  /* T-matrix needed for grad((gradV)^2) */
230  dMat tMatrix(const int);
231 
232  /* r \dot gradU -> for virial estimator */
233  double RdotgradUterm1(const int);
234  double RdotgradUterm2(const int);
235 
236  /* delta \dot gradU -> for centroid virial estimator */
237  double deltadotgradUterm1(const int);
238  double deltadotgradUterm2(const int);
239 
240  /* virial kinetic energy term */
241  double virialKinCorrection(const int);
242 
243  /* gradient of potential action */
244  dVec gradU(const int);
245 
246 };
247 
248 // ========================================================================
249 // NonLocalAction Class
250 // ========================================================================
257 class NonLocalAction : public ActionBase {
258 
259  public:
261  PotentialBase *, WaveFunctionBase *, bool _local=false,
262  string _name="Non-local");
263  virtual ~NonLocalAction();
264 
265  /* The potential Action */
266  double potentialAction ();
267  double potentialAction (const beadLocator &);
268 
269  /* Derivatives of the potential action */
270  double derivPotentialActionTau (int);
271  double derivPotentialActionLambda (int);
272 
273  /* The bare local external and interaction potential at a single time slice */
274  virtual TinyVector<double,2> potential(int slice) { return U(slice); }
275 
276  protected:
277  TinyVector<double,2> U(int);
278 
279  private:
280  vector<bool> NNbead; //Records which beads where already visited for NN operation
281 };
282 #endif
Holds a base class that all action classes will be derived from.
Definition: action.h:29
WaveFunctionBase * waveFunctionPtr
A pointer to a trial wave function object.
Definition: action.h:119
const bool local
Is the action local in imaginary time?
Definition: action.h:103
Array< int, 1 > cylSepHist
A histogram of separations for a cylinder.
Definition: action.h:112
string name
The name of the action.
Definition: action.h:115
virtual double potentialAction()
The effective potential inter-ACTION for various pass conditions.
Definition: action.h:48
ActionBase(const Path &, LookupTable &, PotentialBase *, PotentialBase *, WaveFunctionBase *, bool _local=true, string _name="Base", double _endFactor=1.0, int _period=1)
Setup the path data members and canonical re-weighting factors.
Definition: action.cpp:23
double endFactor
Mutiplictive factor of the potential action on ends.
Definition: action.h:120
int getShift()
Get the tau scaling factor.
Definition: action.h:92
string getActionName()
Returns the action name.
Definition: action.h:38
Array< int, 1 > sepHist
A histogram of separations.
Definition: action.h:111
int numBeads0
The target number of beads.
Definition: action.h:126
PotentialBase * interactionPtr
The interaction potential.
Definition: action.h:109
bool canonical
Are we in the canonical ensemble?
Definition: action.h:125
LookupTable & lookup
We need a non-constant reference for updates.
Definition: action.h:117
double tau()
The local shifted value of tau.
Definition: action.h:133
PotentialBase * externalPtr
The external potential.
Definition: action.h:108
double ensembleWeight(const int)
The ensemble particle number weighting factor.
Definition: action.cpp:122
double kineticAction()
The full kinetic Action
Definition: action.cpp:205
virtual ~ActionBase()
Empty base constructor.
Definition: action.cpp:60
void setShift(int _shift)
The public method that sets the tau scaling factor.
Definition: action.h:89
void updateSepHist(const dVec &)
Update the separation histogram.
Definition: action.cpp:71
int shift
The scaling factor for tau.
Definition: action.h:122
const Path & path
A reference to the paths.
Definition: action.h:118
double rho0(const dVec &, const dVec &, int)
The free-particle density matrix.
Definition: action.cpp:83
double tau() const
Get imaginary time step.
Definition: constants.h:44
A base class to be inherited by actions that are local in imaginary time.
Definition: action.h:150
double potentialAction()
Return the potential action for all time slices and all particles.
Definition: action.cpp:289
double deltadotgradUterm1(const int)
Return the sum over particles at a given time slice of the gradient of the action potential for a sin...
Definition: action.cpp:1228
double potentialActionCorrection(const beadLocator &)
Return the potential action correction for a single bead.
Definition: action.cpp:372
virtual ~LocalAction()
Empty base constructor.
Definition: action.cpp:275
double rDOTgradUterm2(int)
Return the sum over particles at a given time slice of the gradient of the action potential for a sin...
Definition: action.cpp:1126
double secondderivPotentialActionTau(int)
The second derivative of the potential action wrt tau on all links starting on slice.
Definition: action.cpp:447
dMat tMatrix(const int)
Returns the T-matrix needed to compute gradU.
Definition: action.cpp:1015
double gradVSquared(const beadLocator &)
Return the gradient of the full potential squared for a single bead.
Definition: action.cpp:762
double virialKinCorrection(const int)
Returns the value of the virial kinetic energy correction term.
Definition: action.cpp:1433
double derivPotentialActionLambda(int)
The derivative of the potential action wrt lambda for all links starting on slice.
Definition: action.cpp:469
double rDOTgradUterm1(int)
Return the sum over particles at a given time slice of the gradient of the action potential for a sin...
Definition: action.cpp:1079
TinyVector< double, 2 > VFactor
The even/odd slice potential factor.
Definition: action.h:196
dVec gradU(const int)
Returns the value of the gradient of the potential action for all beads at a given time slice.
Definition: action.cpp:1458
TinyVector< double, 2 > gradVFactor
The even/odd slice correction factor.
Definition: action.h:197
dVec gradientV(const int)
Return the gradient of the full potential for all beads at a single time slice.
Definition: action.cpp:978
LocalAction(const Path &, LookupTable &, PotentialBase *, PotentialBase *, WaveFunctionBase *, const TinyVector< double, 2 > &, const TinyVector< double, 2 > &, bool _local=true, string _name="Local", double _endFactor=1.0, int _period=1)
Setup the path data members and local action factors.
Definition: action.cpp:259
double derivPotentialActionTau(int)
The derivative of the potential action wrt tau on all links starting on slice.
Definition: action.cpp:422
double deltadotgradUterm2(const int)
Return the sum over particles at a given time slice of the gradient of the action potential for a sin...
Definition: action.cpp:1307
int eo
Is a slice even or odd?
Definition: action.h:194
double barePotentialAction(const beadLocator &)
Return the bare potential action for a single bead indexed with beadIndex.
Definition: action.cpp:352
double V(const beadLocator &)
Returns the total value of the potential energy, including both the external potential,...
Definition: action.cpp:529
double Vnn(const beadLocator &)
Returns the total value of the potential energy, including both the external potential,...
Definition: action.cpp:680
double gradVnnSquared(const beadLocator &)
Return the gradient of the full potential squared for a single bead.
Definition: action.cpp:915
The particle (bead) lookup table.
Definition: lookuptable.h:29
A base class to be inherited by actions that are non-local in imaginary time.
Definition: action.h:257
double derivPotentialActionLambda(int)
The derivative of the potential action wrt lambda on all links starting on slice.
Definition: action.cpp:1709
double potentialAction()
Return the potential action for all time slices and all particles.
Definition: action.cpp:1514
NonLocalAction(const Path &, LookupTable &, PotentialBase *, PotentialBase *, WaveFunctionBase *, bool _local=false, string _name="Non-local")
Setup the path data members for non-local actions.
Definition: action.cpp:1492
TinyVector< double, 2 > U(int)
Return the potential action for all time slices and all particles.
Definition: action.cpp:1619
double derivPotentialActionTau(int)
The derivative of the potential action wrt tau on all links starting on slice.
Definition: action.cpp:1664
virtual ~NonLocalAction()
Empty constructor.
Definition: action.cpp:1504
The space-time trajectories.
Definition: path.h:29
The base class from which all specific potentials are derived from.
Definition: potential.h:32
Holds a base class that all trial wave function classes will be derived from.
Definition: wavefunction.h:26
TinyMatrix< double, NDIM, NDIM > dMat
A NDIM x NDIM matrix of type double.
Definition: common.h:108
TinyVector< int, 2 > beadLocator
time-slice,bead-number world line index
Definition: common.h:117
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
Definition: common.h:111
ConstantParameters class definition.
ConstantParameters * constants()
Global public access to the constants.
Definition: constants.h:201