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

A derived class which performs a swap head move, which mixes up worldlines by reconnecting the worm head and is essential for systems with permutation symmetry (such as bosons). More...

#include <move.h>

+ Inheritance diagram for SwapHeadMove:
+ Collaboration diagram for SwapHeadMove:

Public Member Functions

 SwapHeadMove (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=OFFDIAGONAL)
 Constructor.
 
 ~SwapHeadMove ()
 Destructor.
 
bool attemptMove ()
 Perform a swap head move. More...
 
string getName ()
 return the move name
 
- Public Member Functions inherited from SwapMoveBase
 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.
 
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.
 
void resetTotAccept ()
 Reset the total accepted counter.
 
void resetAccept ()
 Reset the number accepted counter.
 

Static Public Attributes

static const string name
 

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
 
- Protected Member Functions inherited from SwapMoveBase
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
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 inherited from SwapMoveBase
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.
 
- 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 performs a swap head move, which mixes up worldlines by reconnecting the worm head and is essential for systems with permutation symmetry (such as bosons).

Definition at line 591 of file move.h.

Member Function Documentation

◆ attemptMove()

bool SwapHeadMove::attemptMove ( )
virtual

Perform a swap head move.

Attempt to perform a swap move that samples particle permuations due to the indistinguishability of bosons by reattaching the worm head to another worldline..

Implements MoveBase.

Definition at line 3317 of file move.cpp.

3317  {
3318 
3319  success = false;
3320 
3321  /* Only perform a move if we have beads */
3322  if (path.worm.getNumBeadsOn() == 0)
3323  return success;
3324 
3325  /* We first make sure we are in an off-diagonal configuration */
3326  if (!path.worm.isConfigDiagonal) {
3327 
3328  /* Initialize */
3329  pivot = XXX;
3330  swap = XXX;
3331 
3332  /* Now we figure out how many beads will be involved with the swap bisection. */
3333  swapLength = constants()->Mbar();
3334  numLevels = int (ceil(log(1.0*swapLength) / log(2.0)-EPS));
3335 
3336  /* Now form the list of beads which are in the neighbourhood of
3337  * the head, but at the advanced time slice */
3338  int pivotSlice = path.worm.head[0] + swapLength;
3339  if (pivotSlice >= constants()->numTimeSlices())
3340  pivotSlice -= constants()->numTimeSlices();
3341 
3342  /* Update the full interaction list */
3344 
3345  /* We can only try to make a move if we have at least one bead to swap with */
3346  if (path.lookup.fullNumBeads > 0) {
3347 
3348  /* We compute the normalization factors using the head bead */
3349  SigmaHead = getNorm(path.worm.head);
3350 
3351  iVec wind;
3352  wind = 0;
3353  /* Get the pivot bead and winding number sector */
3354  pivot = selectPivotBead(wind);
3355 
3356  /* Now we try to find the swap bead. If we find the worm tail, we immediatly
3357  * exit the move */
3358  beadLocator beadIndex;
3359  beadIndex = pivot;
3360  for (int k = 0; k < swapLength; k++) {
3361  if (all(beadIndex==path.worm.tail))
3362  return false;
3363  beadIndex = path.prev(beadIndex);
3364  }
3365  swap = beadIndex;
3366 
3367  /* We only continue if the swap is not the tail, and the swap and pivot
3368  * grid boxes coincide. */
3369  if ( !all(path.worm.tail==swap) && path.lookup.gridNeighbors(pivot,swap) ) {
3370 
3371  checkMove(0,0.0);
3372 
3373  /* Increment the number of swap moves and the total number of moves */
3374  numAttempted++;
3375  totAttempted++;
3377 
3378  /* Now we create a new list of beads (using the same beadList)
3379  * which contains all beads in neighborhood of the swap bead
3380  * grid box, but at a time slice advanced by Mbar. We only need to
3381  * do this if head and swap are in different grid boxes. */
3384 
3385  /* Get the normalization factor for the new list */
3386  SigmaSwap = getNorm(swap);
3387 
3388  /* We now perform a pre-metropolis step on the selected bead. If this
3389  * is not accepted, it is extremely likely that the potential change
3390  * will not have any effect, so we don't bother with it. */
3391  double PNorm = min(SigmaHead/SigmaSwap,1.0);
3392  if (random.rand() < PNorm) {
3393 
3394  /* Mark the special beads */
3395  path.worm.special1 = swap;
3396  path.worm.special2 = pivot;
3397 
3398  /* Store the original positions */
3399  int k = 0;
3400  beadIndex = swap;
3401  do {
3402  /* Store the original positions */
3403  if (!all(beadIndex==swap) && !all(beadIndex==pivot)) {
3404  originalPos(k) = path(beadIndex);
3405  ++k;
3406  }
3407  beadIndex = path.next(beadIndex);
3408  } while (!all(beadIndex==path.next(pivot)));
3409 
3410  /* now compute the original action for the path to be
3411  * updated */
3413 
3414  /* Because the staging algorithm requires that we move foward
3415  * and backward in imaginary time (for periodic boundary conditions)
3416  * we perform the relinking now, and change back to the original
3417  * linking only if we reject the move */
3418 
3419  /* Store temporary bead locators for all the linkages that
3420  * will be changed */
3421  nextSwap = path.next(swap);
3422 
3423  /* Update the links. Here we exploit the non-constant return reference
3424  * semantics of the next/prev methods */
3425  path.next(path.worm.head) = nextSwap;
3426  path.next(swap) = XXX;
3427  path.prev(nextSwap) = path.worm.head;
3428 
3429  /* Change the former head to a special bead, and assign the new head */
3431  path.worm.head = swap;
3432 
3433  /* Propose a new trajectory */
3434  beadIndex = path.worm.special1;
3435  k = 0;
3436  do {
3437  if (!all(beadIndex==path.worm.special1) && !all(beadIndex==pivot)) {
3438  path.updateBead(beadIndex,
3439  newStagingPosition(path.prev(beadIndex),pivot,swapLength,k,wind));
3440  ++k;
3441  }
3442  beadIndex = path.next(beadIndex);
3443  } while (!all(beadIndex==path.next(pivot)));
3444 
3445  /* Compute the potential action for the updated path */
3447 
3448  if ( random.rand() < exp(-(newAction - oldAction))) {
3449  keepMove();
3450  checkMove(1,newAction-oldAction);
3451  }
3452  else {
3453  undoMove();
3454  checkMove(2,0.0);
3455  }
3456 
3457  } // PNorm
3458 
3459  } // if we didn't find the tail and grid boxes coincide
3460 
3461  } // numListBeads = 0
3462 
3463  } // isConfigDiagonal
3464 
3465  return success;
3466 }
virtual double potentialAction()
The effective potential inter-ACTION for various pass conditions.
Definition: action.h:48
int numTimeSlices()
Get number of time slices.
Definition: constants.h:99
int Mbar()
Get Mbar.
Definition: constants.h:97
int fullNumBeads
The full number of active beads in beadList;.
Definition: lookuptable.h:44
void updateFullInteractionList(const beadLocator &, const int)
Fill up the fullBeadList array with a list of beads in the same grid box as the supplied beadIndex an...
bool gridNeighbors(const beadLocator &, const beadLocator &)
Given two beadIndices, determine if the beads lie in neighboring grid boxes.
bool gridShare(const beadLocator &bead1, const beadLocator &bead2)
Determine if two beads are in the same grid box.
Definition: lookuptable.h:90
uint32 numAttempted
The number of attempted moves.
Definition: move.h:87
Array< dVec, 1 > originalPos
The original particle positions.
Definition: move.h:97
Path & path
A reference to the paths.
Definition: move.h:80
dVec newStagingPosition(const beadLocator &, const beadLocator &, const int, const int)
Returns a new staging position which will exactly sample the kinetic action.
Definition: move.cpp:268
MTRand & random
A reference to the RNG.
Definition: move.h:82
ActionBase * actionPtr
A base pointer to the action.
Definition: move.h:81
double newAction
The new potential action.
Definition: move.h:108
Array< uint32, 1 > numAttemptedLevel
The number of moves attempted at each level.
Definition: move.h:95
bool success
Did we sucessfully perform a move?
Definition: move.h:84
double oldAction
The original potential action.
Definition: move.h:107
static uint32 totAttempted
The total number of moves attempted.
Definition: move.h:92
void updateBead(const beadLocator &, const dVec &)
Update the position of a bead in the worldine configuration.
Definition: path.cpp:182
beadLocator & next(int slice, int ptcl)
Move one link forward in imaginary time.
Definition: path.h:86
Worm worm
Details on the worm.
Definition: path.h:44
beadLocator & prev(int slice, int ptcl)
Move one link backward in imaginary time.
Definition: path.h:95
LookupTable & lookup
A reference to the nearest neighbor lookup table.
Definition: path.h:46
beadLocator pivot
The pivot bead.
Definition: move.h:568
beadLocator selectPivotBead()
Select the pivot bead for a swap move.
Definition: move.cpp:3269
double SigmaSwap
Probability normalization factor.
Definition: move.h:571
double getNorm(const beadLocator &, const int sign=1)
Get the normalization constant for a swap move.
Definition: move.cpp:3141
beadLocator swap
The swap bead.
Definition: move.h:569
int swapLength
The length of worldLine to be moved.
Definition: move.h:562
int numLevels
The number of bisection levels.
Definition: move.h:563
bool isConfigDiagonal
Stores the diagonality of the configuration.
Definition: worm.h:39
beadLocator tail
The coordinates of the worm tail.
Definition: worm.h:32
beadLocator head
The coordinates of the worm head.
Definition: worm.h:31
beadLocator special2
Special bead, used in move updates.
Definition: worm.h:34
int getNumBeadsOn() const
Return the number of active beads.
Definition: worm.h:88
beadLocator special1
Special bead, used in move updates.
Definition: worm.h:33
TinyVector< int, 2 > beadLocator
time-slice,bead-number world line index
Definition: common.h:117
#define EPS
A small number.
Definition: common.h:94
Ttype & min(Ttype &x, Ttype &y)
Minimum of two inputs.
Definition: common.h:142
TinyVector< int, NDIM > iVec
A NDIM-vector of type integer.
Definition: common.h:114
#define XXX
Used to refer to a nonsense beadIndex.
Definition: common.h:98
ConstantParameters * constants()
Global public access to the constants.
Definition: constants.h:201
+ Here is the call graph for this function:

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