Path Integral Quantum Monte Carlo
Public Member Functions | Protected Member Functions | Protected Attributes
SwapMoveBase Class Reference

A derived class which forms the base of a swap head and swap tail move class. More...

#include <move.h>

+ Inheritance diagram for SwapMoveBase:
+ Collaboration diagram for SwapMoveBase:

Public Member Functions

 SwapMoveBase (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=OFFDIAGONAL)
 Constructor.
 
 ~SwapMoveBase ()
 Destructor.
 
- Public Member Functions inherited from MoveBase
 MoveBase (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=ANY, bool _varLength=false)
 Move naming conventions: More...
 
virtual ~MoveBase ()
 Destructor.
 
virtual string getName ()
 return the move name
 
double getAcceptanceRatio ()
 Get the acceptance ratio.
 
double getTotAcceptanceRatio ()
 Get the total acceptance ratio.
 
double getAcceptanceRatioLevel (int n)
 Get the acceptance ratio by level.
 
int getNumAttempted ()
 Get the number of moves attempted.
 
int getNumAccepted ()
 Get the number of moves accepted.
 
int getNumAttemptedLevel (int n)
 Get the number of moves attempted by level.
 
int getNumAcceptedLevel (int n)
 Get the number of moves accepted by level.
 
virtual bool attemptMove ()=0
 Attempt the move (will be overloaded).
 
void resetTotAccept ()
 Reset the total accepted counter.
 
void resetAccept ()
 Reset the number accepted counter.
 

Protected Member Functions

double getNorm (const beadLocator &, const int sign=1)
 Get the normalization constant for a swap move. More...
 
beadLocator selectPivotBead ()
 Select the pivot bead for a swap move. More...
 
beadLocator selectPivotBead (iVec &)
 ‍*************************************************************************‍//‍** More...
 
- Protected Member Functions inherited from MoveBase
virtual void keepMove ()
 Keep the move. More...
 
virtual void undoMove ()=0
 undo the move
 
dVec newStagingPosition (const beadLocator &, const beadLocator &, const int, const int)
 Returns a new staging position which will exactly sample the kinetic action. More...
 
dVec newStagingPosition (const beadLocator &, const beadLocator &, const int, const int, iVec &)
 Returns a new staging position which will exactly sample the kinetic action in different winding sectors. More...
 
iVec sampleWindingSector (const beadLocator &, const beadLocator &, const int, double &)
 Obtain a winding sector for a stage-like move. More...
 
iVec getWindingNumber (const beadLocator &, const beadLocator &)
 Find the winding number for a path between two beads. More...
 
dVec newFreeParticlePosition (const beadLocator &)
 Generates a new position, which exactly samples the free particle density matrix. More...
 
dVec newBisectionPosition (const beadLocator &, const int)
 Returns a new bisection position which will exactly sample the kinetic action. More...
 
void printMoveState (string)
 
void checkMove (int, double)
 

Protected Attributes

int swapLength
 The length of worldLine to be moved.
 
int numLevels
 The number of bisection levels.
 
unsigned int sizeCDF
 The size of the cumulative distribution function.
 
vector< double > cumulant
 The cumulant array used in selecting a pivot.
 
beadLocator pivot
 The pivot bead.
 
beadLocator swap
 The swap bead.
 
double SigmaSwap
 Probability normalization factor.
 
- Protected Attributes inherited from MoveBase
Pathpath
 A reference to the paths.
 
ActionBaseactionPtr
 A base pointer to the action.
 
MTRand & random
 A reference to the RNG.
 
bool success
 Did we sucessfully perform a move?
 
uint32 numAccepted
 The number of accepted moves.
 
uint32 numAttempted
 The number of attempted moves.
 
int numToMove
 The number of particles moved.
 
int numLevels
 
Array< uint32, 1 > numAcceptedLevel
 The number of moves accepted at each level.
 
Array< uint32, 1 > numAttemptedLevel
 The number of moves attempted at each level.
 
Array< dVec, 1 > originalPos
 The original particle positions.
 
Array< dVec, 1 > newPos
 New particle positions.
 
vector< iVecwinding
 The winding vectors

 
vector< int > windingSector
 Used to index different winding sectors.
 
vector< double > cumrho0
 Used for tower-sampling winding sectors.
 
int maxWind
 The largest winding number.
 
int numWind
 The total number of winding vectors.
 
double oldAction
 The original potential action.
 
double newAction
 The new potential action.
 
double deltaAction
 The action difference.
 
double sqrt2LambdaTau
 sqrt(2 * Lambda * tau)
 
double sqrtLambdaTau
 sqrt(Lambda * tau)
 
beadLocator nBeadIndex
 Neighbor bead index.
 
dVec neighborPos
 Staging neighbor position.
 
dVec newRanPos
 Staing random position.
 
double newK
 
double oldK
 The old and new kinetic action.
 
double newV
 
double oldV
 The old and new potential action.
 

Additional Inherited Members

- Data Fields inherited from MoveBase
ensemble operateOnConfig
 What configurations do we operate on?
 
bool variableLength
 Does the move have a variable length?
 
string name1
 
- Static Protected Attributes inherited from MoveBase
static uint32 totAccepted = 0
 The total number of moves accepted.
 
static uint32 totAttempted = 0
 The total number of moves attempted.
 

Detailed Description

A derived class which forms the base of a swap head and swap tail move class.

Definition at line 554 of file move.h.

Member Function Documentation

◆ getNorm()

double SwapMoveBase::getNorm ( const beadLocator beadIndex,
const int  sign = 1 
)
protected

Get the normalization constant for a swap move.

We compute the normalization constant used in both the pivot selection probability as well as the overall acceptance probabilty.

See also
Eq. (2.23) of PRE 74, 036701 (2006).
Parameters
signcorrects for always measuring distances forward in imaginary time

Definition at line 3141 of file move.cpp.

3141  {
3142 
3143  double Sigma = 0.0;
3144  double crho0;
3145  dVec sep;
3146  int index = 0;
3147 
3149 
3150  /* Check if we need to resisize our cumulative distribution funciton */
3151  if (cumulant.size() < sizeCDF)
3152  cumulant.assign(sizeCDF,0.0);
3153 
3154  /* For each particle, we find the free particle weight for all winding
3155  * sectors. We start with W = 0. */
3156 
3157  /* We sum up the free particle density matrices for each bead
3158  * in the list */
3159  sep = path(path.lookup.fullBeadList(0)) - path(beadIndex);
3160  Sigma = actionPtr->rho0(sep,swapLength);
3161  cumulant.at(index) = Sigma;
3162  ++index;
3163  for (int n = 1; n < path.lookup.fullNumBeads; n++) {
3164  sep = path(path.lookup.fullBeadList(n)) - path(beadIndex);
3165  crho0 = actionPtr->rho0(sep,swapLength);
3166  Sigma += crho0;
3167  cumulant.at(index) = cumulant.at(index-1) + crho0;
3168  ++index;
3169  }
3170 
3171  /* Now we repeat for all winding sectors */
3172  for (int w = 1; w < numWind; w++) {
3173 
3174  /* Go through every particle in the lookup table. */
3175  for (int n = 0; n < path.lookup.fullNumBeads; n++) {
3176  sep = path(path.lookup.fullBeadList(n)) - path(beadIndex)
3177  + sign*winding.at(w)*path.boxPtr->side;
3178  crho0 = actionPtr->rho0(sep,swapLength);
3179  Sigma += crho0;
3180  cumulant.at(index) = cumulant.at(index-1) + crho0;
3181  ++index;
3182  }
3183  }
3184 
3185  /* Normalize the cumulant */
3186  for (unsigned int n = 0; n < sizeCDF; n++)
3187  cumulant.at(n) /= Sigma;
3188 
3189  return Sigma;
3190 }
double rho0(const dVec &, const dVec &, int)
The free-particle density matrix.
Definition: action.cpp:83
dVec side
The linear dimensions of the box.
Definition: container.h:31
int fullNumBeads
The full number of active beads in beadList;.
Definition: lookuptable.h:44
Array< beadLocator, 1 > fullBeadList
The full dynamic list of interacting beads.
Definition: lookuptable.h:41
vector< iVec > winding
The winding vectors
Definition: move.h:100
Path & path
A reference to the paths.
Definition: move.h:80
int numWind
The total number of winding vectors.
Definition: move.h:105
ActionBase * actionPtr
A base pointer to the action.
Definition: move.h:81
const Container * boxPtr
A constant reference to the container class.
Definition: path.h:43
LookupTable & lookup
A reference to the nearest neighbor lookup table.
Definition: path.h:46
vector< double > cumulant
The cumulant array used in selecting a pivot.
Definition: move.h:566
unsigned int sizeCDF
The size of the cumulative distribution function.
Definition: move.h:564
int swapLength
The length of worldLine to be moved.
Definition: move.h:562
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
Definition: common.h:111
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ selectPivotBead() [1/2]

beadLocator SwapMoveBase::selectPivotBead ( )
protected

Select the pivot bead for a swap move.

Here we select a pivot bead from a list with the probability given by Eq. (2.22) of PRE 74, 036701 (2006). We use the trick in Ceperly's lecture notes where we evaluate the cumulative distribution function then generate a uniform random variable and find where it lies in the ordered CDF list.

Definition at line 3269 of file move.cpp.

3269  {
3270 
3271  /* Generate a uniform deviate, and figure out where it fits in our cumulant
3272  * array using a binary search. This is basic tower sampling */
3273  int index = std::lower_bound(cumulant.begin(),cumulant.end(),random.rand())
3274  - cumulant.begin();
3275 
3276  /* Copy over the pivot bead and return it */
3277  beadLocator pivotBead;
3278  pivotBead = path.lookup.fullBeadList(index);
3279 
3280  return pivotBead;
3281 }
MTRand & random
A reference to the RNG.
Definition: move.h:82
TinyVector< int, 2 > beadLocator
time-slice,bead-number world line index
Definition: common.h:117
+ Here is the caller graph for this function:

◆ selectPivotBead() [2/2]

beadLocator SwapMoveBase::selectPivotBead ( iVec wind)
protected

‍*************************************************************************‍//‍**

Select the pivot bead for a swap move.

Here we select a pivot bead from a list with the probability given by Eq. (2.22) of PRE 74, 036701 (2006). We use the trick in Ceperly's lecture notes where we evaluate the cumulative distribution function then generate a uniform random variable and find where it lies in the ordered CDF list.

Parameters
windthe chosen winding number sector.

Definition at line 3233 of file move.cpp.

3233  {
3234 
3235  /* Generate a uniform deviate, and figure out where it fits in our cumulant
3236  * array using a binary search. This is basic tower sampling */
3237 
3238  double x = random.rand();
3239 
3240  int index = std::lower_bound(cumulant.begin(),cumulant.begin()+sizeCDF, x) - cumulant.begin();
3241  /* We need to determine the pivot index and winding sector */
3242 
3243  /* row index */
3244  int w = (index/path.lookup.fullNumBeads) % numWind;
3245 
3246  /* column index */
3247  int p = index % path.lookup.fullNumBeads;
3248 
3249  /* Copy over the pivot bead and return it */
3250  beadLocator pivotBead;
3251  pivotBead = path.lookup.fullBeadList(p);
3252 
3253  /* Get the winding number */
3254  wind = winding.at(w);
3255 
3256 
3257  return pivotBead;
3258 }

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