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

A derived class which performs an insert move, creating an off-diagonal world line configuration with a single worm. More...

#include <move.h>

+ Inheritance diagram for InsertMove:
+ Collaboration diagram for InsertMove:

Public Member Functions

 InsertMove (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=DIAGONAL, bool _varLength=true)
 Constructor.
 
 ~InsertMove ()
 Destructor.
 
bool attemptMove ()
 Perform an insert 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 insert move, creating an off-diagonal world line configuration with a single worm.

Definition at line 385 of file move.h.

Member Function Documentation

◆ attemptMove()

bool InsertMove::attemptMove ( )
virtual

Perform an insert move.

Attempt to insert a worm, which acts like a new worldline without periodic boundary conditions. It is only possible if we are already in a diagonal configuration. We have to be careful to properly grow our bead and link arrays. The actual number of particles doesn't increase, just the number of active worldlines.

Implements MoveBase.

Definition at line 2081 of file move.cpp.

2081  {
2082 
2083  /* Get the length of the proposed worm to insert */
2084  wormLength = 2*(1 + random.randInt(constants()->Mbar()/2-1));
2085  numLevels = int(ceil(log(1.0*wormLength) / log(2.0)-EPS));
2086 
2087  checkMove(0,0.0);
2088 
2089  /* Increment the number of insert moves and the total number of moves */
2090  numAttempted++;
2091  totAttempted++;
2092  numAttemptedLevel(numLevels)++;
2093 
2094  /* Move normalization factor */
2095  double norm = constants()->C() * constants()->Mbar() * path.numTimeSlices
2096  * path.boxPtr->volume;
2097  double muShift = wormLength*constants()->tau()*constants()->mu();
2098 
2099  /* We rescale to take into account different attempt probabilities */
2100  norm *= constants()->attemptProb("remove") / constants()->attemptProb("insert");
2101 
2102  /* Weight for ensemble */
2103  norm *= actionPtr->ensembleWeight(wormLength);
2104 
2105  /* If we are trying to insert a worm when it is not possible due to a
2106  * canonical constraint don't perform the update */
2107  if (norm < DBL_EPS)
2108  return false;
2109 
2110  /* We pick a random tail slice, and add a new bead */
2111  int slice = 2*(random.randInt(constants()->numTimeSlices()/2-1));
2112 
2113  /* Choose a random position inside the box for the proposed tail */
2114  tailBead = path.addBead(slice,path.boxPtr->randPosition(random));
2115  path.worm.special2 = tailBead;
2116 
2117  /* If we have a local action, perform a single slice rejection move */
2118  if (actionPtr->local) {
2119 
2120  double actionShift = (log(norm) + muShift)/wormLength;
2121 
2122  /* Generate the action for the proposed worm */
2123  beadLocator beadIndex;
2124  beadIndex = tailBead;
2125  deltaAction = actionPtr->barePotentialAction(beadIndex) - 0.5*actionShift;
2126 
2127  /* We perform a metropolis test on the tail bead */
2128  if ( random.rand() >= exp(-deltaAction) ) {
2129  undoMove();
2130  return success;
2131  }
2132 
2133  /* Now go through the non head/tail beads */
2134  for (int k = 1; k < wormLength; k++) {
2135 
2136  beadIndex = path.addNextBead(beadIndex,newFreeParticlePosition(beadIndex));
2137  deltaAction = actionPtr->barePotentialAction(beadIndex) - actionShift;
2138 
2139  /* We perform a metropolis test on the single bead */
2140  if ( random.rand() >= exp(-deltaAction) ) {
2141  undoMove();
2142  return success;
2143  }
2144  }
2145  headBead = path.addNextBead(beadIndex,newFreeParticlePosition(beadIndex));
2146  path.worm.special1 = headBead;
2147 
2148  /* If we have made it this far, we compute the total action as well as the
2149  * action correction */
2150  deltaAction = actionPtr->barePotentialAction(headBead) - 0.5*actionShift;
2151  deltaAction += actionPtr->potentialActionCorrection(tailBead,headBead);
2152 
2153  /* Perform a final Metropolis test for inserting the full worm*/
2154  if ( random.rand() < (exp(-deltaAction)) ) {
2155  keepMove();
2156  checkMove(1,deltaAction + actionShift*wormLength);
2157  }
2158  else {
2159  undoMove();
2160  checkMove(2,0.0);
2161  }
2162  }
2163  /* Otherwise, perform a full trajectory move */
2164  else {
2165 
2166  /* Generate the path for the proposed worm, setting the new head as special */
2167  beadLocator beadIndex;
2168  beadIndex = tailBead;
2169  for (int k = 0; k < wormLength; k++)
2170  beadIndex = path.addNextBead(beadIndex,newFreeParticlePosition(beadIndex));
2171  headBead = beadIndex;
2172  path.worm.special1 = headBead;
2173 
2174  /* Compute the new path action */
2175  newAction = actionPtr->potentialAction(tailBead,headBead);
2176 
2177  /* Perform the metropolis test */
2178  if ( random.rand() < norm*exp(-newAction + muShift) ) {
2179  keepMove();
2180  checkMove(1,newAction);
2181  }
2182  else {
2183  undoMove();
2184  checkMove(2,0.0);
2185  }
2186  }
2187 
2188  return success;
2189 }
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
virtual dVec randPosition(MTRand &) const =0
Random position inside a box.
double volume
The volume of the container in A^3.
Definition: container.h:35
uint32 numAttempted
The number of attempted moves.
Definition: move.h:87
Path & path
A reference to the paths.
Definition: move.h:80
dVec newFreeParticlePosition(const beadLocator &)
Generates a new position, which exactly samples the free particle density matrix.
Definition: move.cpp:448
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
const int numTimeSlices
A local constant copy of the number of time slices.
Definition: path.h:37
beadLocator addBead(const int, const dVec &)
Add a bead to the worldline configuration at a given slice.
Definition: path.cpp:250
const Container * boxPtr
A constant reference to the container class.
Definition: path.h:43
Worm worm
Details on the worm.
Definition: path.h:44
beadLocator addNextBead(const beadLocator &, const dVec &)
Add a bead at the next time slice.
Definition: path.cpp:194
beadLocator special2
Special bead, used in move updates.
Definition: worm.h:34
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
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: