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

A derived class which performs a bisection move, which exactly samples the kinetic action. More...

#include <move.h>

+ Inheritance diagram for BisectionMove:
+ Collaboration diagram for BisectionMove:

Public Member Functions

 BisectionMove (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=ANY)
 Constructor. More...
 
 ~BisectionMove ()
 Destructor.
 
bool attemptMove ()
 Bisection Move : attempt 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 bisection move, which exactly samples the kinetic action.

Definition at line 296 of file move.h.

Constructor & Destructor Documentation

◆ BisectionMove()

BisectionMove::BisectionMove ( Path _path,
ActionBase _actionPtr,
MTRand &  _random,
ensemble  _operateOnConfig = ANY 
)

Constructor.

Initialize the number of levels and all local data structures.

Definition at line 1440 of file move.cpp.

1441  :
1442  MoveBase(_path,_actionPtr,_random,_operateOnConfig) {
1443 
1444  /* Initialize private data to zera */
1446 
1447  /* Initialize the acceptance by level counters */
1448  /* These need to use the *actual* value of b */
1449  numAcceptedLevel.resize(constants()->b()+1);
1450  numAttemptedLevel.resize(constants()->b()+1);
1451  numAcceptedLevel = 0;
1452  numAttemptedLevel = 0;
1453 
1454  /* The number of levels used in bisection */
1455  numLevels = constants()->b();
1456 
1457  /* We setup the original and new positions as well as the include array
1458  * which stores updates to the beads involved in the bisection */
1459  numActiveBeads = ipow(2,numLevels)-1;
1460  include.resize(numActiveBeads);
1461  originalPos.resize(numActiveBeads);
1462  newPos.resize(numActiveBeads);
1463 }
int b()
Get bisection level.
Definition: constants.h:98
uint32 numAttempted
The number of attempted moves.
Definition: move.h:87
Array< dVec, 1 > originalPos
The original particle positions.
Definition: move.h:97
Array< dVec, 1 > newPos
New particle positions.
Definition: move.h:98
MoveBase(Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=ANY, bool _varLength=false)
Move naming conventions:
Definition: move.cpp:60
int numToMove
The number of particles moved.
Definition: move.h:88
uint32 numAccepted
The number of accepted moves.
Definition: move.h:86
Array< uint32, 1 > numAttemptedLevel
The number of moves attempted at each level.
Definition: move.h:95
Array< uint32, 1 > numAcceptedLevel
The number of moves accepted at each level.
Definition: move.h:94
int ipow(int base, int power)
Return the integer value of a number raised to a power.
Definition: common.h:136
ConstantParameters * constants()
Global public access to the constants.
Definition: constants.h:201
+ Here is the call graph for this function:

Member Function Documentation

◆ attemptMove()

bool BisectionMove::attemptMove ( )
virtual

Bisection Move : attempt Move.

Here we actually perform the bisection move, which attempts to make a single large move at the midpoint between two slices, then futher bisects until all particles have been moved. The only adjustable parameter for is the number of levels, which sets the number of particles that we will try to move. The move can be fully rejected at any level, and we then go back and restore the positions of all moved particles.

For a nice description of the algorithm see: C. Chakravarty et al. J. Chem. Phys. 109, 2123 (1998).

Implements MoveBase.

Definition at line 1486 of file move.cpp.

1486  {
1487 
1488  success = false;
1489 
1490  /* Only perform a move if we have beads */
1491  if (path.worm.getNumBeadsOn() == 0)
1492  return success;
1493 
1494  /* We cannot perform this move at present when using a pair product action */
1495  if (constants()->actionType() == "pair_product")
1496  return false;
1497 
1498  /* Do we perform varialble length bisection updates? */
1499  if (constants()->varUpdates()) {
1500  numLevels = 1+random.randInt(constants()->b()-1);
1501  numActiveBeads = ipow(2,numLevels)-1;
1502  }
1503 
1504  /* Only do bisections when we have at least one particle */
1505  if (path.getTrueNumParticles()==0)
1506  return false;
1507 
1508  /* Randomly select the start bead of the bisection */
1509  startBead[0] = random.randInt(path.numTimeSlices-1);
1510 
1511  /* We need to worry about the possibility of an empty slice for small
1512  * numbers of particles. */
1513  if (path.numBeadsAtSlice(startBead[0]) == 0)
1514  return false;
1515  startBead[1] = random.randInt(path.numBeadsAtSlice(startBead[0])-1);
1516 
1517  /* Now we have to make sure that we are moving an active trajectory,
1518  * otherwise we exit immediatly */
1519  beadLocator beadIndex;
1520  beadIndex = startBead;
1521  for (int k = 0; k < (numActiveBeads+1); k++) {
1522  if (!path.worm.beadOn(beadIndex) || all(path.next(beadIndex)==XXX))
1523  return false;
1524  beadIndex = path.next(beadIndex);
1525  }
1526  endBead = beadIndex;
1527 
1528  checkMove(0,0.0);
1529 
1530  /* Increment the number of displacement moves and the total number
1531  * of moves */
1532  numAttempted++;
1533  totAttempted++;
1534  numAttemptedLevel(numLevels)++;
1535  include = true;
1536 
1537  /* Now we perform the actual bisection down to level 1 */
1538  oldDeltaAction = 0.0;
1539  for (level = numLevels; level > 0; level--) {
1540 
1541  /* Compute the distance between time slices and set the tau
1542  * shift for the action */
1543  shift = ipow(2,level-1);
1544  actionPtr->setShift(shift);
1545 
1546  /* Reset the actions for this level*/
1547  oldAction = newAction = 0.0;
1548 
1549  beadIndex = path.next(startBead,shift);
1550  int k = 1;
1551  do {
1552  int n = k*shift-1;
1553 
1554  if (include(n)) {
1555  originalPos(n) = path(beadIndex);
1556  oldAction += actionPtr->potentialAction(beadIndex);
1557 
1558  /* Generate the new position and compute the action */
1559  newPos(n) = newBisectionPosition(beadIndex,shift);
1560  path.updateBead(beadIndex,newPos(n));
1561  newAction += actionPtr->potentialAction(beadIndex);
1562 
1563  /* Set the include bit */
1564  include(n) = false;
1565  }
1566  /* At level 1 we need to compute the full action */
1567  else if (level==1) {
1568  newAction += actionPtr->potentialAction(beadIndex);
1569  path.updateBead(beadIndex,originalPos(n));
1570  oldAction += actionPtr->potentialAction(beadIndex);
1571  path.updateBead(beadIndex,newPos(n));
1572  }
1573 
1574  ++k;
1575  beadIndex = path.next(beadIndex,shift);
1576  } while (!all(beadIndex==endBead));
1577 
1578  /* Record the total action difference at this level */
1580 
1581  /* Now we do the metropolis step, if we accept the move, we
1582  * keep going to the next level, however, if we reject it,
1583  * we return all slices that have already been moved back
1584  * to their original positions and break out of the level
1585  * loop. */
1586 
1587  /* The actual Metropolis test */
1588  if (random.rand() < exp(-deltaAction + oldDeltaAction)) {
1589  if (level == 1) {
1590  keepMove();
1591  checkMove(1,deltaAction);
1592  }
1593  }
1594  else {
1595  undoMove();
1596  checkMove(2,0.0);
1597  break;
1598  }
1599 
1600  oldDeltaAction = deltaAction;
1601 
1602  } // end over level
1603 
1604  return success;
1605 }
virtual double potentialAction()
The effective potential inter-ACTION for various pass conditions.
Definition: action.h:48
void setShift(int _shift)
The public method that sets the tau scaling factor.
Definition: action.h:89
Path & path
A reference to the paths.
Definition: move.h:80
dVec newBisectionPosition(const beadLocator &, const int)
Returns a new bisection position which will exactly sample the kinetic action.
Definition: move.cpp:469
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
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
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
int getTrueNumParticles() const
The number of active particles.
Definition: path.h:54
int beadOn(int, int) const
Safely get a bead (int indexed)
Definition: worm.h:148
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 XXX
Used to refer to a nonsense beadIndex.
Definition: common.h:98
+ Here is the call graph for this function:

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