Path Integral Quantum Monte Carlo
Public Member Functions | Data Fields | Friends
Worm Class Reference

Contains information on the worm. More...

#include <worm.h>

Public Member Functions

 Worm (int)
 Constructor. More...
 
 ~Worm ()
 Destructor.
 
int beadOn (int, int) const
 Safely get a bead (int indexed)
 
int beadOn (const beadLocator &) const
 Safely get a bead (beadLocator indexed)
 
beadState getState (const beadLocator &) const
 Get the state of the supplied bead?
 
double factor (const beadState, const beadLocator &) const
 Compute the value of the potential action trajectory factor.
 
double factor (const beadState state1) const
 
void delBead (int, int)
 Safely delete a bead (int indexed)
 
void addBead (int, int)
 Safely add a bead (int indexed)
 
void delBead (const beadLocator &)
 Safely delete a bead (beadLocator indexed)
 
void addBead (const beadLocator &)
 Safely add a bead (beadLocator indexed)
 
void reset ()
 Reset the worm to a null state.
 
void update (Path &, const beadLocator &, const beadLocator &)
 We update all worm properties for a new head and tail. More...
 
bool foundBead (const Path &, const beadLocator &)
 Test to see if a supplied bead is located on a worm.
 
bool tooCostly ()
 Return true if the worm is too costly.
 
bool tooCostly (const dVec &_sep, int _gap)
 Return true if the worm is too costly.
 
const Array< unsigned int, 2 > & getBeads () const
 Return the bead list.
 
int getNumBeadsOn () const
 Return the number of active beads.
 
void incNumBeadsOn ()
 Increment the number of active beads.
 
void decNumBeadsOn ()
 Decrement the number of active beads.
 
void resetNumBeadsOn ()
 Reset the number of active beads.
 

Data Fields

beadLocator head
 The coordinates of the worm head.
 
beadLocator tail
 The coordinates of the worm tail.
 
beadLocator special1
 Special bead, used in move updates.
 
beadLocator special2
 Special bead, used in move updates.
 
double maxWormCost
 The maximum 'cost' of inserting a worm.
 
dVec sep
 The spatial separation between head and tail.
 
int length
 The length of the worm.
 
int gap
 numTimeSlices - length
 
bool isConfigDiagonal
 Stores the diagonality of the configuration.
 

Friends

class Path
 
class PathIntegralMonteCarlo
 

Detailed Description

Contains information on the worm.

In a grand-canonical or worm simulation, one world line may lose its periodicity in imaginary time. This class holds all parameters and methods used to describe worm configurations.

Definition at line 25 of file worm.h.

Constructor & Destructor Documentation

◆ Worm()

Worm::Worm ( int  numParticles)

Constructor.

Initialize the worm object.

Parameters
numParticlesThe number of particles

Definition at line 22 of file worm.cpp.

22  {
23 
24  int numTimeSlices = constants()->numTimeSlices();
25 
26  /* Setup the bead array */
27  beads.resize(numTimeSlices,numParticles);
28  beads = 1;
29 
30  /* Count the initial number of beads */
32 
33  /* The initial configuration is always diagonal */
34  isConfigDiagonal = true;
35 
36  /* Max worm cost [PRE 74, 036701 (2006)] */
37  maxWormCost = 4.0;
38 
39  /* Initialize the properties of the worm */
40  reset();
41 }
int numTimeSlices()
Get number of time slices.
Definition: constants.h:99
bool isConfigDiagonal
Stores the diagonality of the configuration.
Definition: worm.h:39
double maxWormCost
The maximum 'cost' of inserting a worm.
Definition: worm.h:35
void resetNumBeadsOn()
Reset the number of active beads.
Definition: worm.h:94
void reset()
Reset the worm to a null state.
Definition: worm.cpp:53
ConstantParameters * constants()
Global public access to the constants.
Definition: constants.h:201
+ Here is the call graph for this function:

Member Function Documentation

◆ update()

void Worm::update ( Path path,
const beadLocator newHead,
const beadLocator newTail 
)

We update all worm properties for a new head and tail.

Given new head and tail positions, we assign them and compute the gap, length and separation, while turning off all special flags.

Definition at line 69 of file worm.cpp.

70  {
71 
72  /* Assign the new head and tail */
73  head = newHead;
74  tail = newTail;
75 
76  /* Compute the new worm gap. This is defined to be the scalar separation
77  * between the head and tail modulo the number of time slices*/
78  gap = tail[0] - head[0];
79  if (gap < 0)
80  gap += path.numTimeSlices;
81  PIMC_ASSERT(gap>=0);
82 
83  /* Get the new length */
84  beadLocator beadIndex;
85  beadIndex = tail;
86  length = 0;
87  do {
88  ++length;
89  beadIndex = path.next(beadIndex);
90  /* cout << head[0] << " " << head[1] << " " << tail[0] << " " << tail[1] << " " << beadIndex[0] << " " << beadIndex[1] << endl; */
91  } while (!all(beadIndex==head));
92 
93  /* Now we update the head-tail separation */
94  sep = path.getSeparation(tail,head);
95 
96  /* Unlink the head and tail */
97  path.next(head) = XXX;
98  path.prev(tail) = XXX;
99 
100  /* Turn off the special beads */
101  special1 = XXX;
102  special2 = XXX;
103 }
dVec getSeparation(const beadLocator &, const beadLocator &) const
Return the separation vector between two particles in the same timeslice.
Definition: path.h:173
const int numTimeSlices
A local constant copy of the number of time slices.
Definition: path.h:37
beadLocator & next(int slice, int ptcl)
Move one link forward in imaginary time.
Definition: path.h:86
beadLocator & prev(int slice, int ptcl)
Move one link backward in imaginary time.
Definition: path.h:95
int gap
numTimeSlices - length
Definition: worm.h:38
beadLocator tail
The coordinates of the worm tail.
Definition: worm.h:32
dVec sep
The spatial separation between head and tail.
Definition: worm.h:36
beadLocator head
The coordinates of the worm head.
Definition: worm.h:31
beadLocator special2
Special bead, used in move updates.
Definition: worm.h:34
beadLocator special1
Special bead, used in move updates.
Definition: worm.h:33
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 PIMC_ASSERT(X)
Rename assert method.
Definition: common.h:64
#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: