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

A derived class which performs an open move, creating a worm with a well defined head and tail. More...

#include <move.h>

+ Inheritance diagram for OpenMove:
+ Collaboration diagram for OpenMove:

Public Member Functions

 OpenMove (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=DIAGONAL, bool _varLength=true)
 Constructor.
 
 ~OpenMove ()
 Destructor.
 
bool attemptMove ()
 Perform an open 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 an open move, creating a worm with a well defined head and tail.

Definition at line 329 of file move.h.

Member Function Documentation

◆ attemptMove()

bool OpenMove::attemptMove ( )
virtual

Perform an open move.

Here we actually attempt to open up the world line configuration with the resulting creation of a worm. We select a particle and then time slice at random, and provided the current configuration is diagonal (worm free) we just remove a portion of the particle's worldline.

actionPtr->rho0(sep,gapLength);

Implements MoveBase.

Definition at line 1680 of file move.cpp.

1680  {
1681 
1682  success = false;
1683 
1684  /* Only perform a move if we have beads */
1685  if (path.worm.getNumBeadsOn() == 0)
1686  return success;
1687 
1688  /* Only do an open move when we have at least one particle */
1689  if (path.getTrueNumParticles()==0)
1690  return false;
1691 
1692  /* Get the length of the proposed gap to open up. We only allow even
1693  * gaps. */
1694  gapLength = 2*(1 + random.randInt(constants()->Mbar()/2-1));
1695  numLevels = int (ceil(log(1.0*gapLength) / log(2.0)-EPS));
1696 
1697  /* Randomly select the head bead, and make sure it is turned on, we only
1698  * allow the head or tail to live on even slices */
1699  /* THIS IS EXTREMELY IMPORTANT FOR DETAILED BALANCE */
1700  headBead[0] = 2*random.randInt(path.numTimeSlices/2-1);
1701  headBead[1] = random.randInt(path.numBeadsAtSlice(headBead[0])-1);
1702 
1703  /* Find the tail bead */
1704  tailBead = path.next(headBead,gapLength);
1705 
1706  /* Get the current winding number of the chosen trajectory */
1707  double totalrho0;
1708  iVec wind;
1709  wind = sampleWindingSector(headBead,tailBead,gapLength,totalrho0);
1710 
1711  /* Determine the separation in this winding sector */
1712  dVec sep;
1713  sep = path(tailBead) - path(headBead) + wind*path.boxPtr->side;
1714 
1715  /* We make sure that the proposed worm is not too costly */
1716  if ( !path.worm.tooCostly(sep,gapLength) )
1717  {
1718 
1719  checkMove(0,0.0);
1720 
1721  /* We use the 'true' number of particles here because we are still diagonal,
1722  * so it corresponds to the number of worldlines*/
1723  double norm = (constants()->C() * constants()->Mbar() * path.worm.getNumBeadsOn())
1724  / totalrho0;
1726 
1727  /* We rescale to take into account different attempt probabilities */
1728  norm *= constants()->attemptProb("close")/constants()->attemptProb("open");
1729 
1730  /* Weight for ensemble */
1731  norm *= actionPtr->ensembleWeight(-gapLength+1);
1732  double muShift = gapLength*constants()->mu()*constants()->tau();
1733 
1734  /* Increment the number of open moves and the total number of moves */
1735  numAttempted++;
1736  totAttempted++;
1737  numAttemptedLevel(numLevels)++;
1738 
1739  /* The temporary head and tail are special beads */
1740  path.worm.special1 = headBead;
1741  path.worm.special2 = tailBead;
1742 
1743  /* If we have a local action, perform a single slice rejection move */
1744  if (actionPtr->local) {
1745 
1746  double actionShift = (-log(norm) + muShift)/gapLength;
1747 
1748  /* We now compute the potential energy of the beads that would be
1749  * removed if the worm is inserted */
1750  deltaAction = 0.0;
1751  double factor = 0.5;
1752 
1753  beadLocator beadIndex;
1754  beadIndex = headBead;
1755  do {
1756  deltaAction = -(actionPtr->barePotentialAction(beadIndex) - factor*actionShift);
1757 
1758  /* We do a single slice Metropolis test and exit the move if we
1759  * wouldn't remove the single bead */
1760  if ( random.rand() >= exp(-deltaAction) ) {
1761  undoMove();
1762  return success;
1763  }
1764 
1765  factor = 1.0;
1766  beadIndex = path.next(beadIndex);
1767  } while (!all(beadIndex==tailBead));
1768 
1769  /* Add the part from the tail */
1770  deltaAction = -(actionPtr->barePotentialAction(tailBead) - 0.5*actionShift);
1771  deltaAction -= actionPtr->potentialActionCorrection(headBead,tailBead);
1772 
1773  /* Now perform the final metropolis acceptance test based on removing a
1774  * chunk of worldline. */
1775  if ( random.rand() < (exp(-deltaAction)) ) {
1776  keepMove();
1777  checkMove(1,deltaAction - gapLength*actionShift);
1778  }
1779  else {
1780  undoMove();
1781  checkMove(2,0.0);
1782  }
1783  }
1784  /* otherwise, perform a full trajctory update */
1785  else {
1786 
1787  /* We now compute the potential energy of the beads that would be
1788  * removed if the worm is inserted */
1789  oldAction = actionPtr->potentialAction(headBead,tailBead);
1790 
1791  /* Now perform the metropolis acceptance test based on removing a chunk of
1792  * worldline. */
1793  if ( random.rand() < norm*exp(oldAction - muShift) ) {
1794  keepMove();
1795  checkMove(1,-oldAction);
1796  }
1797  else {
1798  undoMove();
1799  checkMove(2,0.0);
1800  }
1801  }
1802 
1803  } // too costly
1804 
1805  return success;
1806 }
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
dVec side
The linear dimensions of the box.
Definition: container.h:31
uint32 numAttempted
The number of attempted moves.
Definition: move.h:87
Path & path
A reference to the paths.
Definition: move.h:80
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
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
const int numTimeSlices
A local constant copy of the number of time slices.
Definition: path.h:37
Array< int, 1 > numBeadsAtSlice
The number of active beads at a given time slice.
Definition: path.h:48
beadLocator & next(int slice, int ptcl)
Move one link forward in imaginary time.
Definition: path.h:86
const Container * boxPtr
A constant reference to the container class.
Definition: path.h:43
Worm worm
Details on the worm.
Definition: path.h:44
int getTrueNumParticles() const
The number of active particles.
Definition: path.h:54
beadLocator special2
Special bead, used in move updates.
Definition: worm.h:34
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
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
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
Definition: common.h:111
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: