Path Integral Quantum Monte Carlo
worm.cpp
Go to the documentation of this file.
1 
7 #include "worm.h"
8 #include "path.h"
9 
10 // ---------------------------------------------------------------------------
11 // ---------------------------------------------------------------------------
12 // WORM CLASS ----------------------------------------------------------------
13 // ---------------------------------------------------------------------------
14 // ---------------------------------------------------------------------------
15 
16 /**************************************************************************/
22 Worm::Worm(int numParticles) {
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 }
42 
43 /**************************************************************************/
47  beads.free();
48 }
49 
50 /**************************************************************************/
53 void Worm::reset() {
54  gap = XXX;
55  length = 0;
56  sep = 0.0;
57  head = XXX;
58  tail = XXX;
59  special1 = XXX;
60  special2 = XXX;
61 }
62 
63 /**************************************************************************/
69 void Worm::update(Path &path, const beadLocator &newHead,
70  const beadLocator &newTail) {
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 }
104 
105 /**************************************************************************/
109 double Worm::factor(const beadState state1, const beadLocator &bead2) const {
110 
111  beadState state2 = getState(bead2);
112 
113  if ((state1 == NONE) && (state2 == NONE))
114  return 1.0;
115  else if ((state1 == HEADTAIL) && (state2 == HEADTAIL))
116  return 0.0;
117  else
118  return 0.5;
119 }
120 
121 /**************************************************************************/
124 bool Worm::foundBead(const Path &path, const beadLocator &beadIndex) {
125  if (isConfigDiagonal)
126  return false;
127  else {
128  beadLocator beadID;
129  beadID = tail;
130  while ( (!all(beadID==beadIndex)) && (!all(beadID==path.next(head))) ) {
131  beadID = path.next(beadID);
132  }
133  return all(beadID==beadIndex);
134  }
135 }
int numTimeSlices()
Get number of time slices.
Definition: constants.h:99
The space-time trajectories.
Definition: path.h:29
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
bool isConfigDiagonal
Stores the diagonality of the configuration.
Definition: worm.h:39
int gap
numTimeSlices - length
Definition: worm.h:38
beadLocator tail
The coordinates of the worm tail.
Definition: worm.h:32
Worm(int)
Constructor.
Definition: worm.cpp:22
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
double maxWormCost
The maximum 'cost' of inserting a worm.
Definition: worm.h:35
void update(Path &, const beadLocator &, const beadLocator &)
We update all worm properties for a new head and tail.
Definition: worm.cpp:69
beadState getState(const beadLocator &) const
Get the state of the supplied bead?
Definition: worm.h:110
bool foundBead(const Path &, const beadLocator &)
Test to see if a supplied bead is located on a worm.
Definition: worm.cpp:124
void resetNumBeadsOn()
Reset the number of active beads.
Definition: worm.h:94
double factor(const beadState, const beadLocator &) const
Compute the value of the potential action trajectory factor.
Definition: worm.cpp:109
void reset()
Reset the worm to a null state.
Definition: worm.cpp:53
~Worm()
Destructor.
Definition: worm.cpp:46
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
beadState
Each bead can have three possible states.
Definition: common.h:129
#define PIMC_ASSERT(X)
Rename assert method.
Definition: common.h:64
#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
Path class definition.
Worm class definition.