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

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

#include <move.h>

+ Inheritance diagram for SwapTailMove:
+ Collaboration diagram for SwapTailMove:

Public Member Functions

 SwapTailMove (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=OFFDIAGONAL)
 Constructor.
 
 ~SwapTailMove ()
 Destructor.
 
bool attemptMove ()
 Perform a swap tail 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 tail move, which mixes up worldlines by reconnecting the worm tail and is essential for systems with permutation symmetry (such as our bosons).

Definition at line 619 of file move.h.

Member Function Documentation

◆ attemptMove()

bool SwapTailMove::attemptMove ( )
virtual

Perform a swap tail move.

Try to perform a swap tail move that samples particle permuations due to the indistinguishability of bosons by reattaching the tail to a worldline.

Implements MoveBase.

Definition at line 3554 of file move.cpp.

3554  {
3555 
3556  success = false;
3557 
3558  /* Only perform a move if we have beads */
3559  if (path.worm.getNumBeadsOn() == 0)
3560  return success;
3561 
3562  /* We first make sure we are in an off-diagonal configuration */
3563  if (!path.worm.isConfigDiagonal) {
3564 
3565  /* Initialize */
3566  pivot = XXX;
3567  swap = XXX;
3568 
3569  /* Now we figure out how many beads will be involved with the swap bisection. */
3570  swapLength = constants()->Mbar();
3571  numLevels = int (ceil(log(1.0*swapLength) / log(2.0)-EPS));
3572 
3573  /* Now form the list of beads which are in the neighbourhood of
3574  * the tail, but at the regressed time slice */
3575  int pivotSlice = path.worm.tail[0] - swapLength;
3576  if (pivotSlice < 0)
3577  pivotSlice += constants()->numTimeSlices();
3578 
3580 
3581  /* We can only try to make a move if we have at least one bead to swap with */
3582  if (path.lookup.fullNumBeads > 0) {
3583 
3584  /* We compute the normalization factors using the tail bead */
3585  /* We have a factor of -1 here due to the tail */
3586  SigmaTail = getNorm(path.worm.tail,-1);
3587 
3588  /* Get the pivot bead and winding sector */
3589  iVec wind;
3590  wind = 0;
3591  pivot = selectPivotBead(wind);
3592 
3593  /* Now we try to find the swap bead. If we find the worm head, we immediatly
3594  * exit the move */
3595  beadLocator beadIndex;
3596  beadIndex = pivot;
3597  for (int k = 0; k < swapLength; k++) {
3598  if (all(beadIndex==path.worm.head))
3599  return false;
3600  beadIndex = path.next(beadIndex);
3601  }
3602  swap = beadIndex;
3603 
3604  /* We only continue if we don't find the head, and the pivot and swap grid
3605  * boxes coincide, otherwise we reject the move. */
3606  if ( !all(path.worm.head==swap) && path.lookup.gridNeighbors(pivot,swap) ) {
3607 
3608  checkMove(0,0.0);
3609 
3610  /* Increment the number of swap moves and the total number of moves */
3611  numAttempted++;
3612  totAttempted++;
3614 
3615  /* Now we create a new list of beads (using the same beadList)
3616  * which contains all beads in neighborhood of the swap bead
3617  * grid box, but at a time slice advanced by Mbar. We only
3618  * do this if tail and swap are in different grid boxes. */
3621 
3622  /* Get the normalization factor for the new list */
3623  SigmaSwap = getNorm(swap);
3624 
3625  /* We now perform a pre-metropolis step on the selected bead. If this
3626  * is not accepted, it is extremely unlikely that the potential change
3627  * will have any effect, so we don't bother with it. */
3628  double PNorm = min(SigmaTail/SigmaSwap,1.0);
3629  if (random.rand() < PNorm) {
3630 
3631  /* Mark the swap and pivot as special */
3632  path.worm.special1 = swap;
3633  path.worm.special2 = pivot;
3634 
3635  int k = 0;
3636  oldAction = newAction = 0.0;
3637 
3638  /* Store the old trajectory and compute its action */
3639  beadIndex = pivot;
3640  do {
3641  if (!all(beadIndex==swap) && !all(beadIndex==pivot)) {
3642  originalPos(k) = path(beadIndex);
3643  ++k;
3644  }
3645  beadIndex = path.next(beadIndex);
3646  } while (!all(beadIndex==path.next(swap)));
3647 
3649 
3650  /* Because the staging algorithm requires that we move foward
3651  * and backward in imaginary time (for periodic boundary conditions)
3652  * we perform the relinking now, and change back to the original
3653  * linking only if we reject the move */
3654 
3655  /* Store temporary bead locators for all the linkages that
3656  * will be changed */
3657  prevSwap = path.prev(swap);
3658 
3659  /* Update the links. Here we exploit the non-constant return reference
3660  * semantics of the next/prev methods */
3661  path.prev(path.worm.tail) = prevSwap;
3662  path.prev(swap) = XXX;
3663  path.next(prevSwap) = path.worm.tail;
3664 
3665  /* Change the former tail to a special bead, and assign the new tail */
3667  path.worm.tail = swap;
3668 
3669  /* Propose a new path trajectory and compute its action */
3670  k = 0;
3671  beadIndex = pivot;
3672  do {
3673  if (!all(beadIndex==path.worm.special1) && !all(beadIndex==pivot)) {
3674  path.updateBead(beadIndex,
3675  newStagingPosition(path.prev(beadIndex),path.worm.special1,swapLength,k,wind));
3676  ++k;
3677  }
3678  beadIndex = path.next(beadIndex);
3679  } while (!all(beadIndex==path.next(path.worm.special1)));
3680 
3682 
3683  /* Perform the Metropolis test */
3684  if ( random.rand() < exp(-(newAction - oldAction))) {
3685  keepMove();
3686  checkMove(1,newAction-oldAction);
3687  }
3688  else {
3689  undoMove();
3690  checkMove(2,0.0);
3691  }
3692 
3693  } // PNorm
3694 
3695  } // if we didn't find the tail and the grid boxes coincide
3696 
3697  } // numListBeads = 0
3698 
3699  } // isConfigDiagonal
3700 
3701  return success;
3702 }
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: