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

A derived class which performs a remove move, creating a diagonal world line configuration by destroying a single worm. More...

#include <move.h>

+ Inheritance diagram for RemoveMove:
+ Collaboration diagram for RemoveMove:

Public Member Functions

 RemoveMove (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=OFFDIAGONAL, bool _varLength=true)
 Constructor.
 
 ~RemoveMove ()
 Destructor.
 
bool attemptMove ()
 Perform a remove 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 remove move, creating a diagonal world line configuration by destroying a single worm.

Definition at line 413 of file move.h.

Member Function Documentation

◆ attemptMove()

bool RemoveMove::attemptMove ( )
virtual

Perform a remove move.

Attempt to remove a worm thus restoring a diagonal configuration. It is only possible if we are already have an off-diagonal configuration.
We have to be careful to properly shrink our bead and link arrays. Again the number of true particles doesn't change here, just the number of active worldlines.

Implements MoveBase.

Definition at line 2266 of file move.cpp.

2266  {
2267 
2268  /* We first make sure we are in an off-diagonal configuration, and the worm isn't
2269  * too short or long */
2270  if ( (path.worm.length > constants()->Mbar()) || (path.worm.length < 1))
2271  return false;
2272 
2273  numLevels = int(ceil(log(1.0*path.worm.length) / log(2.0)-EPS));
2274 
2275  checkMove(0,0.0);
2276 
2277  /* Increment the number of insert moves and the total number of moves */
2278  numAttempted++;
2279  numAttemptedLevel(numLevels)++;
2280  totAttempted++;
2281 
2282  /* The normalization constant and action shift due to the chemical potential */
2283  double norm = 1.0 / (constants()->C() * constants()->Mbar() * path.numTimeSlices
2284  * path.boxPtr->volume);
2285  double muShift = path.worm.length * constants()->mu() * constants()->tau();
2286 
2287  /* We rescale to take into account different attempt probabilities */
2288  norm *= constants()->attemptProb("insert") / constants()->attemptProb("remove");
2289 
2290  /* Weight for ensemble */
2292 
2293  /* If we are trying to remove a worm when it is not possible due to a
2294  * canonical constraint don't perform the update */
2295  if (norm < DBL_EPS)
2296  return false;
2297 
2298  /* If we have a local action, perform a single slice rejection move */
2299  if (actionPtr->local) {
2300 
2301  double actionShift = (-log(norm) + muShift)/path.worm.length;
2302  deltaAction = 0.0;
2303 
2304  /* First do the head */
2305  beadLocator beadIndex;
2306  beadIndex = path.worm.head;
2307  double factor = 0.5;
2308  do {
2309  deltaAction = -(actionPtr->barePotentialAction(beadIndex) - factor*actionShift);
2310 
2311  /* We do a single slice Metropolis test and exit the move if we
2312  * wouldn't remove the single bead */
2313  if ( random.rand() >= exp(-deltaAction) ) {
2314  undoMove();
2315  return success;
2316  }
2317 
2318  factor = 1.0;
2319  beadIndex = path.prev(beadIndex);
2320  } while (!all(beadIndex==path.worm.tail));
2321 
2322  /* Add the part from the tail */
2323  deltaAction = -(actionPtr->barePotentialAction(path.worm.tail) - 0.5*actionShift);
2324  deltaAction -= actionPtr->potentialActionCorrection(path.worm.tail,path.worm.head);
2325 
2326  /* Perform final metropolis test */
2327  if ( random.rand() < (exp(-deltaAction)) ) {
2328  keepMove();
2329  checkMove(1,deltaAction + log(norm) - muShift);
2330  }
2331  else {
2332  undoMove();
2333  checkMove(2,0.0);
2334  }
2335  }
2336  /* otherwise, perform a full trajectory update */
2337  else {
2338  /* Compute the potential action of the path */
2340 
2341  /* Perform the metropolis test */
2342  if ( random.rand() < norm*exp(oldAction - muShift) ) {
2343  keepMove();
2344  checkMove(1,-oldAction);
2345  }
2346 
2347  else {
2348  undoMove();
2349  checkMove(2,0.0);
2350  }
2351  }
2352 
2353  return success;
2354 }
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
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
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
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 & prev(int slice, int ptcl)
Move one link backward in imaginary time.
Definition: path.h:95
beadLocator tail
The coordinates of the worm tail.
Definition: worm.h:32
beadLocator head
The coordinates of the worm head.
Definition: worm.h:31
int length
The length of the worm.
Definition: worm.h:37
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: