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

A derived class which performs a simple displacement of the center of mass of the entire wordline for a particle. More...

#include <move.h>

+ Inheritance diagram for CenterOfMassMove:
+ Collaboration diagram for CenterOfMassMove:

Public Member Functions

 CenterOfMassMove (Path &, ActionBase *, MTRand &, ensemble _operateOnConfig=ANY)
 Constructor.
 
 ~CenterOfMassMove ()
 Destructor.
 
bool attemptMove ()
 Performs a Center of Mass 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
virtual void keepMove ()
 Keep the move. More...
 
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 simple displacement of the center of mass of the entire wordline for a particle.

Definition at line 247 of file move.h.

Member Function Documentation

◆ attemptMove()

bool CenterOfMassMove::attemptMove ( )
virtual

Performs a Center of Mass move.

For each active particle, we move the center of mass of its wordline by a fixed random amount.

Implements MoveBase.

Definition at line 1126 of file move.cpp.

1126  {
1127 
1128  success = false;
1129 
1130  /* Only perform a move if we have beads */
1131  if (path.worm.getNumBeadsOn() == 0)
1132  return success;
1133 
1134  int startSlice = 0;
1135  /* If there are broken wordlines, choose between starting and ending bead*/
1136  if( (path.breakSlice > 0) && (random.rand() < 0.5) )
1137  startSlice = path.numTimeSlices-1;
1138 
1139  /* We don't bother performing a center of mass move, unless we have at
1140  * least one bead on startSlice */
1141  if (path.numBeadsAtSlice(startSlice) == 0)
1142  return false;
1143 
1144  checkMove(0,0.0);
1145 
1146  /* The initial bead */
1147  beadLocator firstBead;
1148  firstBead = startSlice,random.randInt(path.numBeadsAtSlice(startSlice)-1);
1149 
1150  bool startSubregionA,startSubregionB,endSubregionA,endSubregionB;
1151 
1152  /* Now we traverse the path backwards, until we find 1 of two
1153  * possibilities, either we reach a null bead, or we wrap around */
1154  startBead = firstBead;
1155  if (!all(path.prev(startBead)==XXX)) {
1156  do {
1157  startBead = path.prev(startBead);
1158  } while (!all(path.prev(startBead)==firstBead) && !all(path.prev(startBead)==XXX));
1159  }
1160 
1161  /* Get a closed worldline */
1162  if (all(path.prev(startBead)==firstBead)) {
1163  startBead = firstBead;
1164  endBead = path.prev(startBead);
1165  }
1166  /* Otherwise, find the end bead */
1167  else {
1168  endBead = firstBead;
1169  if (!all(path.next(endBead)==XXX)) {
1170  do {
1171  endBead = path.next(endBead);
1172  } while(!all(path.next(endBead)==XXX));
1173  }
1174  }
1175 
1176  int wlLength = 0;
1177  beadLocator beadIndex;
1178 
1179  /* Make sure the worldline to be moved is shorter than the number of time
1180  * slices */
1181  beadIndex = startBead;
1182  do {
1183  ++wlLength;
1184  beadIndex = path.next(beadIndex);
1185  } while (!all(beadIndex==path.next(endBead)));
1186 
1187  if (wlLength > constants()->numTimeSlices())
1188  return false;
1189 
1190  /* Increment the number of center of mass moves and the total number
1191  * of moves */
1192  numAttempted++;
1193  totAttempted++;
1194 
1195  /* The random shift that will be applied to the center of mass*/
1196  for (int i = 0; i < NDIM; i++)
1197  originalPos(0)[i] = constants()->comDelta()*(-0.5 + random.rand());
1198 
1199  /* Here we test to see if any beads are placed outside the box (if we
1200  * don't have periodic boundary conditions). If that is the case,
1201  * we don't continue */
1202  dVec pos;
1203  if (int(sum(path.boxPtr->periodic)) != NDIM) {
1204  beadIndex = startBead;
1205  do {
1206  pos = path(beadIndex) + originalPos(0);
1207  path.boxPtr->putInBC(pos);
1208  for (int i = 0; i < NDIM; i++) {
1209  if ((pos[i] < -0.5*path.boxPtr->side[i]) || (pos[i] >= 0.5*path.boxPtr->side[i]))
1210  return false;
1211  }
1212  beadIndex = path.next(beadIndex);
1213  } while (!all(beadIndex==path.next(endBead)));
1214  }
1215 
1216  /* Determine the old potential action of the path */
1217  oldAction = actionPtr->potentialAction(startBead,endBead);
1218 
1219  /* Go through the worldline and update the position of all the beads */
1220  beadIndex = startBead;
1221  startSubregionA = false;
1222  startSubregionB = false;
1223  endSubregionA = false;
1224  endSubregionB = false;
1225  do {
1226  /* Check if bead is in subregion A or B */
1227  if ((constants()->spatialSubregionOn())&&(!(startSubregionA||startSubregionB))){
1228  startSubregionA = path.inSubregionA(beadIndex);
1229  startSubregionB = path.inSubregionB(beadIndex);
1230  }
1231  pos = path(beadIndex) + originalPos(0);
1232  path.boxPtr->putInBC(pos);
1233  path.updateBead(beadIndex,pos);
1234  if ((constants()->spatialSubregionOn())&&(!(endSubregionA||endSubregionB))){
1235  endSubregionA = path.inSubregionA(beadIndex);
1236  endSubregionB = path.inSubregionB(beadIndex);
1237  }
1238  beadIndex = path.next(beadIndex);
1239  } while (!all(beadIndex==path.next(endBead)));
1240 
1241  if ( (startSubregionA && endSubregionB)|| (startSubregionB && endSubregionA) ){
1242  undoMove();
1243  checkMove(2,0.0);
1244  } else{
1245  /* Get the new potential action of the path */
1246  newAction = actionPtr->potentialAction(startBead,endBead);
1247 
1248  /* The metropolis acceptance step */
1249  if (random.rand() < exp(-(newAction - oldAction))) {
1250  keepMove();
1251  checkMove(1,newAction-oldAction);
1252  }
1253  else {
1254  undoMove();
1255  checkMove(2,0.0);
1256  }
1257  }
1258 
1259  return success;
1260 }
virtual double potentialAction()
The effective potential inter-ACTION for various pass conditions.
Definition: action.h:48
double comDelta() const
Get center of mass shift.
Definition: constants.h:53
TinyVector< unsigned int, NDIM > periodic
Determines which dimensions have periodic bc.
Definition: container.h:29
void putInBC(dVec &r) const
Place a vector in boundary conditions.
Definition: container.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
Array< dVec, 1 > originalPos
The original particle positions.
Definition: move.h:97
Path & path
A reference to the paths.
Definition: move.h:80
MTRand & random
A reference to the RNG.
Definition: move.h:82
ActionBase * actionPtr
A base pointer to the action.
Definition: move.h:81
virtual void keepMove()
Keep the move.
Definition: move.cpp:248
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
bool inSubregionA(const beadLocator &) const
Checks to see if bead is in subregion A/B at break slice + 1.
Definition: path.cpp:518
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
int breakSlice
The location of the break in the path (0=>no break)
Definition: path.h:38
bool inSubregionB(const beadLocator &) const
Check if bead is in subregion B.
Definition: path.cpp:533
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
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
int getNumBeadsOn() const
Return the number of active beads.
Definition: worm.h:88
#define NDIM
Number of spatial dimnsions.
Definition: common.h:71
TinyVector< int, 2 > beadLocator
time-slice,bead-number world line index
Definition: common.h:117
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
Definition: common.h:111
#define XXX
Used to refer to a nonsense beadIndex.
Definition: common.h:98
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: