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

A derived class which performs a close move, creating a diagonal world line configuration. More...

#include <move.h>

+ Inheritance diagram for CloseMove:
+ Collaboration diagram for CloseMove:

Public Member Functions

 CloseMove (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=OFFDIAGONAL, bool _varLength=true)
 Constructor.
 
 ~CloseMove ()
 Destructor.
 
bool attemptMove ()
 Perform a close move. More...
 
string getName ()
 return the move name
 
- 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 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 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 close move, creating a diagonal world line configuration.

Definition at line 357 of file move.h.

Member Function Documentation

◆ attemptMove()

bool CloseMove::attemptMove ( )
virtual

Perform a close move.

We attempt to close up the world line configuration if a worm is already present. This consists of both filling in the beadOn array as well as generating new positions for the particle beads. After a successful close, we update the number of particles.

Implements MoveBase.

Definition at line 1881 of file move.cpp.

1881  {
1882 
1883  success = false;
1884 
1885  /* Only perform a move if we have beads */
1886  if (path.worm.getNumBeadsOn() == 0)
1887  return success;
1888 
1889  /* We first make sure we are in an off-diagonal configuration, and that that
1890  * gap is neither too large or too small and that the worm cost is reasonable.
1891  * Otherwise, we simply exit the move */
1892  if ( (path.worm.gap > constants()->Mbar()) || (path.worm.gap == 0)
1893  || path.worm.tooCostly() )
1894  return false;
1895 
1896  checkMove(0,0.0);
1897 
1898  /* Otherwise, proceed with the close move */
1899  numLevels = int (ceil(log(1.0*path.worm.gap) / log(2.0)-EPS));
1900 
1901  /* Increment the number of close moves and the total number of moves */
1902  numAttempted++;
1903  numAttemptedLevel(numLevels)++;
1904  totAttempted++;
1905 
1906  /* Get the head and new 'tail' slices for the worldline length
1907  * to be closed. These beads are left untouched */
1908  headBead = path.worm.head;
1909  tailBead = path.worm.tail;
1910 
1911  /* Sample the winding sector */
1912  double totalrho0;
1913  iVec wind;
1914  wind = sampleWindingSector(headBead,tailBead,path.worm.gap,totalrho0);
1915 
1916  /* Compute the part of the acceptance probability that does not
1917  * depend on the change in potential energy */
1918  double norm = totalrho0 /
1919  (constants()->C() * constants()->Mbar() *
1920  (path.worm.getNumBeadsOn() + path.worm.gap - 1));
1921 
1922  /* We rescale to take into account different attempt probabilities */
1923  norm *= constants()->attemptProb("open")/constants()->attemptProb("close");
1924 
1925  /* Weight for ensemble */
1926  norm *= actionPtr->ensembleWeight(path.worm.gap-1);
1927 
1928  /* The change in the number sector */
1929  double muShift = path.worm.gap*constants()->mu()*constants()->tau();
1930 
1931  /* If we have a local action, perform single slice updates */
1932  if (actionPtr->local) {
1933 
1934  double actionShift = (log(norm) + muShift)/path.worm.gap;
1935 
1936  /* Compute the potential action for the new trajectory, inclucing a piece
1937  * coming from the head and tail. */
1938  beadLocator beadIndex;
1939  beadIndex = path.worm.head;
1940 
1941  deltaAction = actionPtr->barePotentialAction(beadIndex) - 0.5*actionShift;
1942 
1943  /* We perform a metropolis test on the tail bead */
1944  if ( random.rand() >= exp(-deltaAction) ) {
1945  undoMove();
1946  return success;
1947  }
1948 
1949  for (int k = 0; k < (path.worm.gap-1); k++) {
1950  beadIndex = path.addNextBead(beadIndex,
1951  newStagingPosition(beadIndex,path.worm.tail,path.worm.gap,k,wind));
1952  deltaAction = actionPtr->barePotentialAction(beadIndex) - actionShift;
1953 
1954  /* We perform a metropolis test on the single bead */
1955  if ( random.rand() >= exp(-deltaAction) ) {
1956  undoMove();
1957  return success;
1958  }
1959  }
1960  path.next(beadIndex) = path.worm.tail;
1961  path.prev(path.worm.tail) = beadIndex;
1962 
1963  /* If we have made it this far, we compute the total action as well as the
1964  * action correction */
1965  deltaAction = actionPtr->barePotentialAction(path.worm.tail) - 0.5*actionShift;
1966  deltaAction += actionPtr->potentialActionCorrection(path.worm.head,path.worm.tail);
1967 
1968  /* Perform the metropolis test */
1969  if ( random.rand() < (exp(-deltaAction)) ) {
1970  keepMove();
1971  checkMove(1,deltaAction + log(norm) + muShift);
1972  }
1973  else {
1974  undoMove();
1975  checkMove(2,0);
1976  }
1977  }
1978  /* Otherwise, perform a full trajectory update */
1979  else
1980  {
1981  /* Generate a new new trajectory */
1982  beadLocator beadIndex;
1983  beadIndex = path.worm.head;
1984  for (int k = 0; k < (path.worm.gap-1); k++) {
1985  beadIndex = path.addNextBead(beadIndex,
1986  newStagingPosition(beadIndex,path.worm.tail,path.worm.gap,k,wind));
1987  }
1988  path.next(beadIndex) = path.worm.tail;
1989  path.prev(path.worm.tail) = beadIndex;
1990 
1991  /* Compute the action for the new trajectory */
1992  newAction = actionPtr->potentialAction(headBead,tailBead);
1993 
1994  /* Perform the metropolis test */
1995  if ( random.rand() < norm*exp(-newAction + muShift) ) {
1996  keepMove();
1997  checkMove(1,newAction);
1998  }
1999  else {
2000  undoMove();
2001  checkMove(2,0.0);
2002  }
2003  }
2004 
2005  return success;
2006 }
const bool local
Is the action local in imaginary time?
Definition: action.h:103
virtual double potentialAction()
The effective potential inter-ACTION for various pass conditions.
Definition: action.h:48
double ensembleWeight(const int)
The ensemble particle number weighting factor.
Definition: action.cpp:122
double mu() const
Get chemical potential.
Definition: constants.h:43
int Mbar()
Get Mbar.
Definition: constants.h:97
double tau() const
Get imaginary time step.
Definition: constants.h:44
double C() const
Get full worm constant.
Definition: constants.h:50
uint32 numAttempted
The number of attempted moves.
Definition: move.h:87
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
iVec sampleWindingSector(const beadLocator &, const beadLocator &, const int, double &)
Obtain a winding sector for a stage-like move.
Definition: move.cpp:357
MTRand & random
A reference to the RNG.
Definition: move.h:82
double deltaAction
The action difference.
Definition: move.h:109
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
static uint32 totAttempted
The total number of moves attempted.
Definition: move.h:92
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
beadLocator addNextBead(const beadLocator &, const dVec &)
Add a bead at the next time slice.
Definition: path.cpp:194
int gap
numTimeSlices - length
Definition: worm.h:38
beadLocator tail
The coordinates of the worm tail.
Definition: worm.h:32
beadLocator head
The coordinates of the worm head.
Definition: worm.h:31
bool tooCostly()
Return true if the worm is too costly.
Definition: worm.h:68
int getNumBeadsOn() const
Return the number of active beads.
Definition: worm.h:88
TinyVector< int, 2 > beadLocator
time-slice,bead-number world line index
Definition: common.h:117
#define EPS
A small number.
Definition: common.h:94
TinyVector< int, NDIM > iVec
A NDIM-vector of type integer.
Definition: common.h:114
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: