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

The space-time trajectories. More...

#include <path.h>

+ Collaboration diagram for Path:

Public Member Functions

 Path (const Container *, LookupTable &, int, const Array< dVec, 1 > &, int numberBroken=0)
 Constructor. More...
 
 ~Path ()
 Destructor. More...
 
int getNumParticles () const
 Get the size of the worldline array.
 
int getTrueNumParticles () const
 The number of active particles.
 
const dVecoperator() (int slice, int ptcl) const
 Operator Overloading to skip having to specifically grab .beads

 
dVecoperator() (int slice, int ptcl)
 Operator Overloading to skip having to specifically grab .beads

 
const dVecoperator() (const beadLocator &beadIndex) const
 Operator Overloading to skip having to specifically grab .beads

 
dVecoperator() (const beadLocator &beadIndex)
 Operator Overloading to skip having to specifically grab .beads

 
dVec getVelocity (const beadLocator &) const
 Return the velocity between two time slices of a given particle as a ndim-vector.
 
dVec getSeparation (const beadLocator &, const beadLocator &) const
 Return the separation vector between two particles in the same timeslice.
 
template<class Tstream >
void printLinks (Tstream &)
 Output bead-link info, used for debugging.
 
void outputConfig (int) const
 Output the world-line configurations in a generic format. More...
 
beadLocatornext (int slice, int ptcl)
 Move one link forward in imaginary time.
 
const beadLocatornext (int slice, int ptcl) const
 Move one link forward in imaginary time.
 
beadLocatornext (const beadLocator &beadIndex)
 Move one link forward in imaginary time.
 
const beadLocatornext (const beadLocator &beadIndex) const
 Move one link forward in imaginary time.
 
beadLocatorprev (int slice, int ptcl)
 Move one link backward in imaginary time.
 
const beadLocatorprev (int slice, int ptcl) const
 Move one link backward in imaginary time.
 
beadLocatorprev (const beadLocator &beadIndex)
 Move one link backward in imaginary time.
 
const beadLocatorprev (const beadLocator &beadIndex) const
 Move one link backward in imaginary time.
 
beadLocator next (int, int, int) const
 Move an integer number of links forward in imaginary time.
 
beadLocator next (const beadLocator &, int) const
 Move an integer number of links forward in imaginary time.
 
beadLocator prev (int, int, int) const
 Move an integer number of links backward in imaginary time.
 
beadLocator prev (const beadLocator &, int) const
 Move an integer number of links backward in imaginary time.
 
beadLocator addBead (const int, const dVec &)
 Add a bead to the worldline configuration at a given slice. More...
 
beadLocator addNextBead (const beadLocator &, const dVec &)
 Add a bead at the next time slice. More...
 
beadLocator addPrevBead (const beadLocator &, const dVec &)
 Add a bead at the previous time slice. More...
 
void delBead (const beadLocator &)
 Remove a bead from the world-line configuration. More...
 
beadLocator delBeadGetNext (const beadLocator &)
 Delete a bead and move forwards. More...
 
beadLocator delBeadGetPrev (const beadLocator &)
 Delete a bead and move backwards. More...
 
void breakLink (const beadLocator &)
 Break the link to right of bead. More...
 
void makeLink (const beadLocator &, const beadLocator &)
 Make a link between beads.
 
void removeCenterLink (const beadLocator &)
 Break the link to right of bead t center slice AND update lists. More...
 
void addCenterLink (const beadLocator &, const beadLocator &)
 Make a link between beads at center slice AND update lists. More...
 
bool isBroken (const beadLocator &) const
 Checks to see if worldline is broken. More...
 
double breakFactor (const beadLocator &, const beadLocator &) const
 Returns factor for broken worldines. More...
 
bool inSubregionA (const beadLocator &) const
 Checks to see if bead is in subregion A/B at break slice + 1. More...
 
bool inSubregionB (const beadLocator &) const
 Check if bead is in subregion B.
 
bool checkSubregionLinks () const
 Check if only subregion worldlines are broken, for debugging. More...
 
void updateBead (const beadLocator &, const dVec &)
 Update the position of a bead in the worldine configuration. More...
 
void printWormConfig (Array< beadLocator, 1 > &)
 Used when debugging worm configurations. More...
 
void leftPack ()
 Initialize any loaded state by left packing the array. More...
 
void resetBrokenClosedVecs ()
 Reset broken/closed worldline vectors. More...
 

Data Fields

const int numTimeSlices
 A local constant copy of the number of time slices.
 
int breakSlice
 The location of the break in the path (0=>no break)
 
vector< int > brokenWorldlinesL
 A list of particles with broken worldlines on left of break.
 
vector< int > brokenWorldlinesR
 A list of particles with broken worldlines on right of break.
 
vector< int > closedWorldlines
 A list of particles with closed worldlines on left of break.
 
const ContainerboxPtr
 A constant reference to the container class.
 
Worm worm
 Details on the worm.
 
LookupTablelookup
 A reference to the nearest neighbor lookup table.
 
Array< int, 1 > numBeadsAtSlice
 The number of active beads at a given time slice.
 

Friends

class PathIntegralMonteCarlo
 

Detailed Description

The space-time trajectories.

Holds the actual particle wordlines, consisting of a fixed number of time slices for each particle with periodic boundary conditions in imaginary time.

Definition at line 29 of file path.h.

Constructor & Destructor Documentation

◆ Path()

Path::Path ( const Container _boxPtr,
LookupTable _lookup,
int  _numTimeSlices,
const Array< dVec, 1 > &  initialPos,
int  numberBroken = 0 
)

Constructor.

We initialize the all the data structures in path given a random initial configuration (classical) depending on the type of potential.

Parameters
_boxPtrThe pointer to the simulation cell
_lookupThe nearest neighbor lookup table
_numTimeSlicesThe number of imaginary time slices
initialPosThe initial configuration of particles

Definition at line 28 of file path.cpp.

29  :
30  numTimeSlices(_numTimeSlices),
31  boxPtr(_boxPtr),
32  worm(initialPos.size()),
33  lookup(_lookup)
34 {
35 
36  /* Get the initial number of particles */
37  int numParticles = initialPos.size();
38 
39  /* Construct and initialize the array of beads */
40  beads.resize(numTimeSlices,numParticles);
41  beads = 0.0;
42 
43  /* Copy the initial condition at all time slices (a classical initial condition)*/
44  for (int n = 0; n < numParticles; n++) {
45  for (int i = 0; i < NDIM; i++)
46  beads(Range::all(),n)[i] = initialPos(n)[i];
47  }
48 
49  /* Construct and initialize the prevLink and nextLink arrays */
50  prevLink.resize(numTimeSlices,getNumParticles());
51  nextLink.resize(numTimeSlices,getNumParticles());
52  firstIndex i1;
53  secondIndex i2;
54  prevLink[0] = i1-1;
55  prevLink[1] = i2;
56  nextLink[0] = i1+1;
57  nextLink[1] = i2;
58 
59  if (PIGS) {
60  /* Here we implement the fixed boundary conditions in imaginary time. */
61  prevLink(0,Range::all()) = XXX;
62  nextLink(numTimeSlices-1,Range::all()) = XXX;
63 
64  /* Here we break worldlines at the center of the path if requested*/
65  breakSlice = 0;
66  if (numberBroken > 0){
67  breakSlice = (numTimeSlices-1)/2;
68  for (int n=0; n<numberBroken; n++){
69  nextLink(breakSlice,n) = XXX;
70  prevLink(breakSlice+1,n) = XXX;
71  brokenWorldlinesL.push_back(n);
72  brokenWorldlinesR.push_back(n);
73  }
74  for (int n=numberBroken; n<getNumParticles(); n++)
75  closedWorldlines.push_back(n);
76  }else if(constants()->spatialSubregionOn()){
77  breakSlice = (numTimeSlices-1)/2;
78  beadLocator beadIndex;
79  beadIndex[0] =breakSlice+1;
80  for( int n=0; n<getNumParticles(); n++){
81  beadIndex[1] = n;
82  if (inSubregionA(beadIndex)){
83  nextLink(breakSlice,n) = XXX;
84  prevLink(breakSlice+1,n) = XXX;
85  brokenWorldlinesL.push_back(n);
86  brokenWorldlinesR.push_back(n);
87  }else{
88  closedWorldlines.push_back(n);
89  }
90  }
91  }else{
92  for (int n=0; n<getNumParticles(); n++)
93  closedWorldlines.push_back(n);
94  }
95  }
96  else {
97  breakSlice = 0;
98  /* Here we implement periodic boundary conditions in imaginary time */
99  prevLink(0,Range::all())[0] = numTimeSlices-1;
100  nextLink(numTimeSlices-1,Range::all())[0] = 0;
101  }
102 
103  /* Initialize the number of active beads at each slice */
106 
107  /* Initialize the lookup table */
109  lookup.updateGrid(*this);
110 }
void updateGrid(const Path &)
We update the full nearest neighbor grid by filling up all data arrays at all time slices.
void resizeList(int _numParticles)
Resize the bead and grid lists.
Definition: lookuptable.h:78
bool inSubregionA(const beadLocator &) const
Checks to see if bead is in subregion A/B at break slice + 1.
Definition: path.cpp:518
int getNumParticles() const
Get the size of the worldline array.
Definition: path.h:51
vector< int > closedWorldlines
A list of particles with closed worldlines on left of break.
Definition: path.h:41
vector< int > brokenWorldlinesR
A list of particles with broken worldlines on right of break.
Definition: path.h:40
vector< int > brokenWorldlinesL
A list of particles with broken worldlines on left of break.
Definition: path.h:39
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
const Container * boxPtr
A constant reference to the container class.
Definition: path.h:43
Worm worm
Details on the worm.
Definition: path.h:44
LookupTable & lookup
A reference to the nearest neighbor lookup table.
Definition: path.h:46
#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
#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:

◆ ~Path()

Path::~Path ( )

Destructor.

Kill all blitz arrays

Definition at line 117 of file path.cpp.

117  {
118  beads.free();
119  prevLink.free();
120  nextLink.free();
121  numBeadsAtSlice.free();
122 }

Member Function Documentation

◆ addBead()

beadLocator Path::addBead ( const int  slice,
const dVec pos 
)

Add a bead to the worldline configuration at a given slice.

We add a single bead to our configuration by searching for a free position at the end of the wordline array. If no such position exists, all data structures are resized to accomidate the new bead;

Parameters
sliceThe time slice where the new bead will be added.
posThe new spatial position of the bead
Returns
a beadLocator for the new bead

Definition at line 250 of file path.cpp.

250  {
251 
252  int numWorldLines = getNumParticles();
253 
254  lastBeadIndex[0] = slice;
255  lastBeadIndex[1] = numBeadsAtSlice(slice);
256 
257  /* Here we check and see if we have enough free-space to add a bead. If
258  * not we have to grow all our data structures */
259  if (lastBeadIndex[1] == numWorldLines) {
260 
261  /* Resize and initialize the main data array which holds all worldline
262  * configurations */
263  beads.resizeAndPreserve(numTimeSlices,numWorldLines + 1);
264  beads(Range::all(),numWorldLines) = 0.0;
265 
266  /* Resize and initialize the worm bead arrays which tells us
267  * whether or not we have a bead present */
268  worm.beads.resizeAndPreserve(numTimeSlices,numWorldLines + 1);
269  worm.beads(Range::all(),numWorldLines) = 0;
270 
271  /* Resize and initialize the previous and next link arrays */
272  prevLink.resizeAndPreserve(numTimeSlices,numWorldLines + 1);
273  nextLink.resizeAndPreserve(numTimeSlices,numWorldLines + 1);
274  prevLink(Range::all(),numWorldLines) = XXX;
275  nextLink(Range::all(),numWorldLines) = XXX;
276 
277  /* Resize the lookup table */
278  lookup.resizeList(numWorldLines + 1);
279  }
280 
281  PIMC_ASSERT(!worm.beadOn(lastBeadIndex));
282 
283  /* Add and increment the number of beads */
284  worm.addBead(lastBeadIndex);
286 
287  /* Update the number of beads at the time slice */
288  ++numBeadsAtSlice(slice);
289 
290  /* Initialize the connections */
291  next(lastBeadIndex) = XXX;
292  prev(lastBeadIndex) = XXX;
293 
294  /* Update the actual path and lookup table */
295  beads(lastBeadIndex) = pos;
296  lookup.addBead(lastBeadIndex,pos);
297 
298  /* Return the added bead */
299  return lastBeadIndex;
300 }
void addBead(const beadLocator &, const dVec &)
Add a single bead to the NN grid and position pos.
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 beadOn(int, int) const
Safely get a bead (int indexed)
Definition: worm.h:148
void incNumBeadsOn()
Increment the number of active beads.
Definition: worm.h:90
void addBead(int, int)
Safely add a bead (int indexed)
Definition: worm.h:135
#define PIMC_ASSERT(X)
Rename assert method.
Definition: common.h:64
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addCenterLink()

void Path::addCenterLink ( const beadLocator beadIndexL,
const beadLocator beadIndexR 
)

Make a link between beads at center slice AND update lists.

Make a link between beads AND update lists.

Definition at line 441 of file path.cpp.

441  {
442 
443  /* Make new link */
444  makeLink(beadIndexL,beadIndexR);
445 
446  /* Update lists */
447  vector<int>::iterator itr;
448  itr = find(brokenWorldlinesL.begin(), brokenWorldlinesL.end(), beadIndexL[1]);
449  brokenWorldlinesL.erase(itr);
450  itr = find(brokenWorldlinesR.begin(), brokenWorldlinesR.end(), beadIndexR[1]);
451  brokenWorldlinesR.erase(itr);
452  closedWorldlines.push_back(beadIndexL[1]);
453 }
void makeLink(const beadLocator &, const beadLocator &)
Make a link between beads.
Definition: path.cpp:415
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addNextBead()

beadLocator Path::addNextBead ( const beadLocator prevIndex,
const dVec pos 
)

Add a bead at the next time slice.

We add a single bead to our configuration at one advanced time slice from the supplied bead.

Returns
next(prevIndex)

Definition at line 194 of file path.cpp.

194  {
195 
196  beadLocator beadIndex;
197 
198  /* We make sure that the next bead doesn't already exist */
199  PIMC_ASSERT(all(next(prevIndex)==XXX));
200 
201  /* The bead doesn't exist, so add it */
202  int slice = prevIndex[0] + 1;
203  if (slice >= numTimeSlices)
204  slice -= numTimeSlices;
205 
206  beadIndex = addBead(slice,pos);
207 
208  next(prevIndex) = beadIndex;
209  prev(beadIndex) = prevIndex;
210 
211  return beadIndex;
212 }
beadLocator addBead(const int, const dVec &)
Add a bead to the worldline configuration at a given slice.
Definition: path.cpp:250
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addPrevBead()

beadLocator Path::addPrevBead ( const beadLocator nextIndex,
const dVec pos 
)

Add a bead at the previous time slice.

We add a single bead to our configuration at one previous time slice from the supplied bead.

Returns
prev(nextIndex)

Definition at line 221 of file path.cpp.

221  {
222 
223  /* We make sure that the previous bead doesn't already exist */
224  PIMC_ASSERT(all(prev(nextIndex)==XXX));
225 
226  /* The bead doesn't exist, so add it */
227  int slice = nextIndex[0] - 1;
228  if (slice < 0)
229  slice += numTimeSlices;
230 
231  beadLocator beadIndex;
232  beadIndex = addBead(slice,pos);
233 
234  prev(nextIndex) = beadIndex;
235  next(beadIndex) = nextIndex;
236 
237  return beadIndex;
238 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ breakFactor()

double Path::breakFactor ( const beadLocator beadIndex1,
const beadLocator beadIndex2 
) const

Returns factor for broken worldines.

Return a constatnt factor for worldine breaks.

Definition at line 502 of file path.cpp.

503  {
504  double factor = 1.0;
505 
506  /*if ( PIGS ){
507  if ( (breakSlice > 0) && (beadIndex1[0] == (breakSlice+1)) ){
508  if ( isBroken(beadIndex1) || isBroken(beadIndex2) )
509  factor = 0.5;
510  }
511  }*/
512  return factor;
513 }

◆ breakLink()

void Path::breakLink ( const beadLocator beadIndexL)

Break the link to right of bead.

Break a link to right of bead.

Definition at line 406 of file path.cpp.

406  {
407  beadLocator beadIndexR = next(beadIndexL);
408  nextLink(beadIndexL[0],beadIndexL[1]) = XXX;
409  prevLink(beadIndexR[0],beadIndexR[1]) = XXX;
410 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkSubregionLinks()

bool Path::checkSubregionLinks ( ) const

Check if only subregion worldlines are broken, for debugging.

Check if bead is in subregion B.

Definition at line 545 of file path.cpp.

545  {
546  bool foundError = false;
547  beadLocator beadIndex;
548 
549  beadIndex[0] = breakSlice+1;
550  for(int n=0; n<getNumParticles(); n++){
551  beadIndex[1] = n;
552  if( inSubregionA(beadIndex)){
553  foundError = (all(prev(beadIndex)!= XXX));
554  }else if( inSubregionB(beadIndex) ){
555  foundError = (all(prev(beadIndex)== XXX));
556  }else{
557  foundError=true;
558  }
559  if(foundError){
560  cout << beadIndex[1] << '\t' << beads(beadIndex) << 't' <<
561  inSubregionA(beadIndex) << '\t' << inSubregionB(beadIndex) << endl;
562  break;
563  }
564  }
565  return foundError;
566 }
bool inSubregionB(const beadLocator &) const
Check if bead is in subregion B.
Definition: path.cpp:533
+ Here is the call graph for this function:

◆ delBead()

void Path::delBead ( const beadLocator beadIndex)

Remove a bead from the world-line configuration.

We delete a single bead from our configuration and update the emptyWorldLine array. At the same point, we must update the nearest neighbor lookup table.

Definition at line 344 of file path.cpp.

344  {
345 
346  /* Delete the bead from the lookup table */
347  lookup.delBead(beadIndex);
348 
349  /* Reduce the number of beads at this time slice by one. */
350  --numBeadsAtSlice(beadIndex[0]);
351 
352  /* Get the coordinates of the last bead */
353  lastBeadIndex[0] = beadIndex[0];
354  lastBeadIndex[1] = numBeadsAtSlice(beadIndex[0]);
355 
356  /* unlink */
357  if (!all(next(beadIndex)==XXX))
358  prev(next(beadIndex)) = XXX;
359  if (!all(prev(beadIndex)==XXX))
360  next(prev(beadIndex)) = XXX;
361 
362  /* If we are not already the largest bead label, perform the value
363  * and linkage swap. */
364  if (beadIndex[1] < numBeadsAtSlice(beadIndex[0])) {
365 
366  /* Copy over the position, updating the lookup table */
367  lookup.delBead(lastBeadIndex);
368  lookup.addBead(beadIndex,beads(lastBeadIndex));
369  beads(beadIndex) = beads(lastBeadIndex);
370 
371  /* Swap the next/prev links */
372  prev(beadIndex) = prev(lastBeadIndex);
373  next(beadIndex) = next(lastBeadIndex);
374 
375  if (!all(next(lastBeadIndex)==XXX))
376  prev(next(lastBeadIndex)) = beadIndex;
377  if (!all(prev(lastBeadIndex)==XXX))
378  next(prev(lastBeadIndex)) = beadIndex;
379 
380  /* We have to make sure that the worm is updated correctly if the swapped bead
381  * is either a head or tail */
382  if (all(worm.head==lastBeadIndex))
383  worm.head = beadIndex;
384  if (all(worm.tail==lastBeadIndex))
385  worm.tail = beadIndex;
386  if (all(worm.special1==lastBeadIndex))
387  worm.special1 = beadIndex;
388  if (all(worm.special2==lastBeadIndex))
389  worm.special2 = beadIndex;
390  }
391 
392  /* Unlink */
393  next(lastBeadIndex) = XXX;
394  prev(lastBeadIndex) = XXX;
395 
396  /* delete from the beads array */
397  worm.delBead(lastBeadIndex);
398 
399  /* decrement the number of beads */
401 }
void delBead(const beadLocator &)
Remove a single bead from the NN grid.
beadLocator tail
The coordinates of the worm tail.
Definition: worm.h:32
beadLocator head
The coordinates of the worm head.
Definition: worm.h:31
beadLocator special2
Special bead, used in move updates.
Definition: worm.h:34
void delBead(int, int)
Safely delete a bead (int indexed)
Definition: worm.h:122
void decNumBeadsOn()
Decrement the number of active beads.
Definition: worm.h:92
beadLocator special1
Special bead, used in move updates.
Definition: worm.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delBeadGetNext()

beadLocator Path::delBeadGetNext ( const beadLocator beadIndex)

Delete a bead and move forwards.

Delete a single bead and return the index of the next bead in imaginary time.

Definition at line 326 of file path.cpp.

326  {
327 
328  /* Store the next index */
329  beadLocator nextBead;
330  nextBead = next(beadIndex);
331 
332  /* Remove the bead, and return the next index */
333  delBead(beadIndex);
334  return nextBead;
335 }
void delBead(const beadLocator &)
Remove a bead from the world-line configuration.
Definition: path.cpp:344
+ Here is the call graph for this function:

◆ delBeadGetPrev()

beadLocator Path::delBeadGetPrev ( const beadLocator beadIndex)

Delete a bead and move backwards.

Delete a single bead and return the index of the preivous bead in imaginary time.

Definition at line 309 of file path.cpp.

309  {
310 
311  /* Store the previous index */
312  beadLocator prevBead;
313  prevBead = prev(beadIndex);
314 
315  /* Remove the bead, and return the previous index */
316  delBead(beadIndex);
317  return prevBead;
318 }
+ Here is the call graph for this function:

◆ inSubregionA()

bool Path::inSubregionA ( const beadLocator beadIndex) const

Checks to see if bead is in subregion A/B at break slice + 1.

Check if bead is in subregion A.

Definition at line 518 of file path.cpp.

518  {
519  bool inA = false;
520  if( constants()->spatialSubregionOn() ){
521  if ( (beadIndex[0]==breakSlice+1)&&
522  //(abs(beads(beadIndex)[0]) < constants()->spatialSubregion()) )
523  ( beads(beadIndex)[0] < constants()->spatialSubregion() ) )
524  inA = true;
525  }
526  //cout << beadIndex[0] << '\t' << inA << '\t' << beads(beadIndex) << endl;
527  return inA;
528 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBroken()

bool Path::isBroken ( const beadLocator beadIndex) const

Checks to see if worldline is broken.

Check to see if worldline is broken at beadIndex.

Definition at line 492 of file path.cpp.

492  {
493  bool broken = false;
494  if ( all(prev(beadIndex)==XXX) || all(next(beadIndex)==XXX) )
495  broken = true;
496  return broken;
497 }
+ Here is the call graph for this function:

◆ leftPack()

void Path::leftPack ( )

Initialize any loaded state by left packing the array.

Go through all data arrays, and make sure the active beads are packed at the beginning (LHS) of the array.

Definition at line 130 of file path.cpp.

130  {
131 
132  beadLocator bead1,bead2;
133 
134  /* We go through each slice, and make sure the data arrays are left packed */
135  for (bead1[0] = 0; bead1[0] < numTimeSlices; bead1[0]++) {
136  for (bead1[1] = 0; bead1[1] < beads.extent(secondDim); bead1[1]++) {
137  if (!worm.beadOn(bead1)) {
138  bead2 = bead1;
139 
140  /* Find an active bead to the right of the inactive bead */
141  bool foundBead = false;
142  for (bead2[1] = bead1[1] + 1; bead2[1] < beads.extent(secondDim); bead2[1]++) {
143  if (worm.beadOn(bead2)) {
144  foundBead = true;
145  break;
146  }
147  } //bead2
148 
149  /* If we have found one, perform the swap */
150  if (foundBead) {
151 
152  /* Copy the position back */
153  beads(bead1) = beads(bead2);
154 
155  /* Swap the active bead indicators */
156  worm.addBead(bead1);
157  worm.delBead(bead2);
158 
159  /* Update the links */
160  next(bead1) = next(bead2);
161  prev(bead1) = prev(bead2);
162  next(prev(bead2)) = bead1;
163  prev(next(bead2)) = bead1;
164 
165  /* Zero out the old links */
166  next(bead2) = XXX;
167  prev(bead2) = XXX;
168 
169  } // foundBead
170 
171  } // bead1On
172  } //bead11
173  } //bead10
174 }
+ Here is the call graph for this function:

◆ outputConfig()

void Path::outputConfig ( int  configNumber) const

Output the world-line configurations in a generic format.

Output the worldline configuration to disk using a format suitable for plotting.

Definition at line 576 of file path.cpp.

576  {
577 
578  int numParticles = getNumParticles();
579  /* Output format for PIGS and PIMC are different */
580 #if PIGS
581  /* We go through each particle/worldline */
582  beadLocator beadIndex;
583 
584  /* Output the header */
585  communicate()->file("wl")->stream() << format("# START_CONFIG %06d\n") % configNumber;
586 
587  /* Output the unit cell information. It is always cubic. Everything is scaled by
588  * an overall factor for better visualization. */
589 
590  /* We output the bead block */
591  for (int n = 0; n < numParticles; n++) {
592  for (int m = 0; m < numTimeSlices; m++) {
593  beadIndex = m,n;
594 
595  communicate()->file("wl")->stream() << format("%8d %8d %8d") % beadIndex[0]
596  % beadIndex[1] % 1;
597 
598  /* Output the coordinates in 3D */
599  int i;
600  for (i = 0; i < NDIM; i++) {
601  communicate()->file("wl")->stream() << format("%16.3E") % (beads(beadIndex)[i]);
602  }
603  while (i < 3) {
604  communicate()->file("wl")->stream() << format("%16.3E") % 0.0;
605  i++;
606  }
607 
608  /* Output the bead indices of the connecting beads */
609  communicate()->file("wl")->stream() << format("%8d %8d %8d %8d\n") % prev(beadIndex)[0]
610  % prev(beadIndex)[1] % next(beadIndex)[0] % next(beadIndex)[1];
611 
612  /* Advance the bead index */
613  beadIndex = next(beadIndex);
614  }
615  }
616  communicate()->file("wl")->stream() << format("# END_CONFIG %06d\n") % configNumber;
617 
618  /* Flush the file stream */
619  communicate()->file("wl")->stream().flush();
620 #else
621  /* We go through all beads, and find the start and end bead for each
622  * worldline, adding them to an array */
623  Array <beadLocator,1> startBead,endBead;
624  startBead.resize(numParticles);
625  endBead.resize(numParticles);
626 
627  /* We sort the output by the number of beads in a worldline */
628  Array <int,1> wlLength(numParticles);
629  wlLength = 0;
630 
631  int numWorldLines = 0;
632 
633  /* Get the list of beads that are active in the simulation */
634  Array <bool,2> doBead(numTimeSlices,numParticles);
635  doBead = cast<bool>(worm.getBeads());
636 
637  /* We go through each particle/worldline */
638  int nwl = 0;
639  beadLocator beadIndex;
640 
641  /* If we are off-diagonal, we start with the worm */
642  if (!worm.isConfigDiagonal) {
643  startBead(nwl) = worm.tail;
644  endBead(nwl) = XXX;
645 
646  /* Mark the beads as touched and increment the number of worldlines */
647  beadIndex = startBead(nwl);
648  do {
649  doBead(beadIndex) = false;
650  beadIndex = next(beadIndex);
651  } while (!all(beadIndex==endBead(nwl)));
652 
653  /* We label a worm with a XXX */
654  wlLength(nwl) = XXX;
655 
656  nwl++;
657  } // off-diagonal
658 
659  /* Now go through eacheach worldline, and figure out how many particles
660  * are involved in the permuation cycle */
661  beadLocator testStart;
662  for (int n = 0; n < numParticles; n++) {
663 
664  /* The initial bead to be moved */
665  testStart = 0,n;
666 
667  /* We make sure we don't try to touch the same worldline twice */
668  if (doBead(testStart)) {
669 
670  startBead(nwl) = testStart;
671 
672  /* Otherwise, we loop around until we find the initial bead */
673  endBead(nwl) = startBead(nwl);
674 
675  /* Mark the beads as touched and increment the number of worldlines */
676  beadIndex = startBead(nwl);
677  int length = 1;
678  do {
679  doBead(beadIndex) = false;
680  length++;
681  beadIndex = next(beadIndex);
682  } while (!all(beadIndex==endBead(nwl)));
683 
684  /* We label each trajectory by the number of particles it contains. */
685  wlLength(nwl) = int(length/numTimeSlices)-1;
686 
687  nwl++;
688  } // touchBeads
689 
690  } // n
691 
692  numWorldLines = nwl;
693 
694  /* Output the header */
695  communicate()->file("wl")->stream() << format("# START_CONFIG %06d\n") % configNumber;
696 
697  /* Output the unit cell information. It is always cubic. Everything is scaled by
698  * an overall factor for better visualization. */
699 
700  /* We output the bead block */
701  for (int n = 0; n < numWorldLines; n++) {
702  beadIndex = startBead(n);
703  do {
704  communicate()->file("wl")->stream() << format("%8d %8d %8d") %
705  beadIndex[0] % beadIndex[1] % wlLength(n);
706 
707  /* Output the coordinates in 3D */
708  int i;
709  for (i = 0; i < NDIM; i++) {
710  communicate()->file("wl")->stream() << format("%16.3E") % (beads(beadIndex)[i]);
711  }
712  while (i < 3) {
713  communicate()->file("wl")->stream() << format("%16.3E") % 0.0;
714  i++;
715  }
716 
717  /* Output the bead indices of the connecting beads */
718  communicate()->file("wl")->stream() << format("%8d %8d %8d %8d\n") % prev(beadIndex)[0]
719  % prev(beadIndex)[1] % next(beadIndex)[0] % next(beadIndex)[1];
720 
721  /* Advance the bead index */
722  beadIndex = next(beadIndex);
723  } while (!all(beadIndex==endBead(n)));
724  }
725  communicate()->file("wl")->stream() << format("# END_CONFIG %06d\n") % configNumber;
726 
727  /* Flush the file stream */
728  communicate()->file("wl")->stream().flush();
729 
730  /* Free up memory */
731  startBead.free();
732  endBead.free();
733  wlLength.free();
734  doBead.free();
735 #endif
736 }
File * file(string type)
Get method returning file object.
Definition: communicator.h:85
bool isConfigDiagonal
Stores the diagonality of the configuration.
Definition: worm.h:39
const Array< unsigned int, 2 > & getBeads() const
Return the bead list.
Definition: worm.h:84
Communicator * communicate()
Global public access to the communcator singleton.
Definition: communicator.h:121
+ Here is the call graph for this function:

◆ printWormConfig()

void Path::printWormConfig ( Array< beadLocator, 1 > &  wormBeads)

Used when debugging worm configurations.

We print out the current link and bead configuration to visualize a worm.

Definition at line 743 of file path.cpp.

743  {
744 
745  int numWorldLines = getNumParticles();
746 
747  /* A shortform for the output file */
748  fstream *outFilePtr;
749  outFilePtr = &(communicate()->file("debug")->stream());
750 
751  for (int m = numTimeSlices-1; m >= 0; m--) {
752  /* First print out the beads */
753  for (int n = 0; n < numWorldLines; n++) {
754  beadLocator beadIndex;
755  beadIndex = m,n;
756  if (all(beadIndex==worm.head)) {
757  if (worm.beadOn(beadIndex))
758  (*outFilePtr) << "^";
759  else
760  (*outFilePtr) << "z";
761  }
762 
763  else if (all(beadIndex==worm.tail)) {
764  if (worm.beadOn(beadIndex))
765  (*outFilePtr) << "v";
766  else
767  (*outFilePtr) << "y";
768  }
769  else
770  {
771  if (worm.beadOn(beadIndex))
772  (*outFilePtr) << "*";
773  else
774  (*outFilePtr) << " ";
775  }
776  } // for n
777 
778  (*outFilePtr) << "\t";
779  /* Now print out the links */
780  for (int n = 0; n < numWorldLines; n++) {
781  beadLocator beadIndex;
782  beadIndex = m,n;
783  if (all(next(beadIndex)==XXX))
784  (*outFilePtr) << " ";
785  else
786  (*outFilePtr) << "|";
787  } // for n
788 
789  (*outFilePtr) << "\t";
790  /* Finally, if we are off-diagonal, print out the worm */
791  if (!worm.isConfigDiagonal) {
792  for (int n = 0; n < numWorldLines; n++) {
793  beadLocator beadIndex;
794  beadIndex = m,n;
795  bool foundWormBead = false;
796  string beadOut;
797  for (int k = 0; k < wormBeads.extent(firstDim); k++) {
798 
799  if (all(beadIndex==wormBeads(k))) {
800  foundWormBead = true;
801  if ((k > 0) && (k < (wormBeads.extent(firstDim)-1))) {
802  if ( (wormBeads(k+1)[1] > wormBeads(k)[1]) ||
803  (wormBeads(k-1)[1] < wormBeads(k)[1]) )
804  beadOut = "/";
805  else if ( (wormBeads(k+1)[1] < wormBeads(k)[1]) ||
806  (wormBeads(k-1)[1] > wormBeads(k)[1]) )
807  beadOut = "\\";
808  else
809  beadOut = "|";
810  }
811  break;
812  }
813  }
814 
815  if (foundWormBead) {
816  if (all(beadIndex==worm.head))
817  (*outFilePtr) << "^";
818  else if (all(beadIndex==worm.tail))
819  (*outFilePtr) << "v";
820  else
821  (*outFilePtr) << beadOut;
822  }
823  else {
824  if (worm.beadOn(beadIndex))
825  (*outFilePtr) << "~";
826  else
827  (*outFilePtr) << " ";
828  }
829  } // for n
830 
831  } // isConfigDiagonal
832  (*outFilePtr) << endl;
833 
834  } // for int m
835  (*outFilePtr) << endl;
836 }
+ Here is the call graph for this function:

◆ removeCenterLink()

void Path::removeCenterLink ( const beadLocator beadIndexL)

Break the link to right of bead t center slice AND update lists.

Break a link to right of bead AND update lists.

Definition at line 423 of file path.cpp.

423  {
424  /* Get linked bead */
425  beadLocator beadIndexR = next(beadIndexL);
426 
427  /* Break link */
428  breakLink(beadIndexL);
429 
430  /* Update lists */
431  vector<int>::iterator itr;
432  itr = find(closedWorldlines.begin(), closedWorldlines.end(), beadIndexL[1]);
433  closedWorldlines.erase(itr);
434  brokenWorldlinesL.push_back(beadIndexL[1]);
435  brokenWorldlinesR.push_back(beadIndexR[1]);
436 }
void breakLink(const beadLocator &)
Break the link to right of bead.
Definition: path.cpp:406
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetBrokenClosedVecs()

void Path::resetBrokenClosedVecs ( )

Reset broken/closed worldline vectors.

Reset broken bead lists.

Definition at line 459 of file path.cpp.

459  {
460 
461  if ( PIGS && (breakSlice > 0) ){
462 
463  beadLocator beadIndex;
464 
465  /* Clear vectors */
466  brokenWorldlinesL.clear();
467  brokenWorldlinesR.clear();
468  closedWorldlines.clear();
469 
470  /* Set brokenWorldlinesL and closedWorldlines by checking breakSlice */
471  beadIndex[0] = breakSlice;
472  for (int ptcl = 0; ptcl < numBeadsAtSlice(beadIndex[0]); ptcl++) {
473  beadIndex[1] = ptcl;
474  if( all(next(beadIndex) == XXX))
475  brokenWorldlinesL.push_back(ptcl);
476  else
477  closedWorldlines.push_back(ptcl);
478  }
479  /* Set brokenWorldlinesR by checking breakSlice+1 */
480  beadIndex[0] = breakSlice+1;
481  for (int ptcl = 0; ptcl < numBeadsAtSlice(beadIndex[0]); ptcl++) {
482  beadIndex[1] = ptcl;
483  if( all(prev(beadIndex) == XXX))
484  brokenWorldlinesR.push_back(ptcl);
485  }
486  }
487 };

◆ updateBead()

void Path::updateBead ( const beadLocator beadIndex,
const dVec pos 
)

Update the position of a bead in the worldine configuration.

Given a beadIndex and spatial position, we assign the new bead location and update its position in the lookup table.

Definition at line 182 of file path.cpp.

182  {
183  lookup.updateBead(beadIndex,pos);
184  beads(beadIndex) = pos;
185 }
void updateBead(const beadLocator &, const dVec &)
Update the NN grid with a new bead position.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: