Path Integral Quantum Monte Carlo
path.cpp
Go to the documentation of this file.
1 
8 #include "path.h"
9 #include "lookuptable.h"
10 #include "communicator.h"
11 
12 // ---------------------------------------------------------------------------
13 // ---------------------------------------------------------------------------
14 // PATH CLASS ----------------------------------------------------------------
15 // ---------------------------------------------------------------------------
16 // ---------------------------------------------------------------------------
17 
18 /*************************************************************************/
28 Path::Path(const Container * _boxPtr, LookupTable &_lookup, int _numTimeSlices,
29  const Array<dVec,1> &initialPos,int numberBroken) :
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 }
111 
112 /*************************************************************************/
118  beads.free();
119  prevLink.free();
120  nextLink.free();
121  numBeadsAtSlice.free();
122 }
123 
124 /*************************************************************************/
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 }
175 
176 /**************************************************************************/
182 void Path::updateBead(const beadLocator &beadIndex, const dVec &pos) {
183  lookup.updateBead(beadIndex,pos);
184  beads(beadIndex) = pos;
185 }
186 
187 /**************************************************************************/
194 beadLocator Path::addNextBead(const beadLocator &prevIndex, const dVec &pos) {
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 }
213 
214 /**************************************************************************/
221 beadLocator Path::addPrevBead(const beadLocator &nextIndex, const dVec &pos) {
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 }
239 
240 /**************************************************************************/
250 beadLocator Path::addBead(const int slice, const dVec &pos) {
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 }
301 
302 
303 /**************************************************************************/
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 }
319 
320 /**************************************************************************/
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 }
336 
337 /**************************************************************************/
344 void Path::delBead(const beadLocator &beadIndex) {
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 }
402 
403 /**************************************************************************/
406 void Path::breakLink(const beadLocator &beadIndexL) {
407  beadLocator beadIndexR = next(beadIndexL);
408  nextLink(beadIndexL[0],beadIndexL[1]) = XXX;
409  prevLink(beadIndexR[0],beadIndexR[1]) = XXX;
410 }
411 
412 /**************************************************************************/
415 void Path::makeLink(const beadLocator &beadIndexL,const beadLocator &beadIndexR) {
416  nextLink(beadIndexL[0],beadIndexL[1]) = beadIndexR;
417  prevLink(beadIndexR[0],beadIndexR[1]) = beadIndexL;
418 }
419 
420 /**************************************************************************/
423 void Path::removeCenterLink(const beadLocator &beadIndexL) {
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 }
437 
438 /**************************************************************************/
441 void Path::addCenterLink(const beadLocator &beadIndexL,const beadLocator &beadIndexR) {
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 }
454 
455 /**************************************************************************/
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 };
488 
489 /**************************************************************************/
492 bool Path::isBroken(const beadLocator &beadIndex) const{
493  bool broken = false;
494  if ( all(prev(beadIndex)==XXX) || all(next(beadIndex)==XXX) )
495  broken = true;
496  return broken;
497 }
498 
499 /**************************************************************************/
502 double Path::breakFactor(const beadLocator &beadIndex1,
503  const beadLocator &beadIndex2) const{
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 }
514 
515 /**************************************************************************/
518 bool Path::inSubregionA(const beadLocator &beadIndex) const{
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 }
529 
530 /**************************************************************************/
533 bool Path::inSubregionB(const beadLocator &beadIndex) const{
534  bool inB = false;
535  if( constants()->spatialSubregionOn() ){
536  if ( (beadIndex[0]==breakSlice+1)&&(!inSubregionA(beadIndex)) )
537  inB = true;
538  }
539  return inB;
540 }
541 
542 /**************************************************************************/
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 }
567 
568 
569 /**************************************************************************/
575 #include "communicator.h"
576 void Path::outputConfig(int configNumber) const {
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 }
737 
738 /**************************************************************************/
743 void Path::printWormConfig(Array <beadLocator,1> &wormBeads) {
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 }
File * file(string type)
Get method returning file object.
Definition: communicator.h:85
The base class which holds details on the generalized box that our system will be simulated inside of...
Definition: container.h:24
The particle (bead) lookup table.
Definition: lookuptable.h:29
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
void addBead(const beadLocator &, const dVec &)
Add a single bead to the NN grid and position pos.
void updateBead(const beadLocator &, const dVec &)
Update the NN grid with a new bead position.
void delBead(const beadLocator &)
Remove a single bead from the NN grid.
bool inSubregionA(const beadLocator &) const
Checks to see if bead is in subregion A/B at break slice + 1.
Definition: path.cpp:518
~Path()
Destructor.
Definition: path.cpp:117
int getNumParticles() const
Get the size of the worldline array.
Definition: path.h:51
beadLocator delBeadGetNext(const beadLocator &)
Delete a bead and move forwards.
Definition: path.cpp:326
Path(const Container *, LookupTable &, int, const Array< dVec, 1 > &, int numberBroken=0)
Constructor.
Definition: path.cpp:28
void resetBrokenClosedVecs()
Reset broken/closed worldline vectors.
Definition: path.cpp:459
void leftPack()
Initialize any loaded state by left packing the array.
Definition: path.cpp:130
beadLocator delBeadGetPrev(const beadLocator &)
Delete a bead and move backwards.
Definition: path.cpp:309
void outputConfig(int) const
Output the world-line configurations in a generic format.
Definition: path.cpp:576
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
bool checkSubregionLinks() const
Check if only subregion worldlines are broken, for debugging.
Definition: path.cpp:545
void delBead(const beadLocator &)
Remove a bead from the world-line configuration.
Definition: path.cpp:344
void printWormConfig(Array< beadLocator, 1 > &)
Used when debugging worm configurations.
Definition: path.cpp:743
bool isBroken(const beadLocator &) const
Checks to see if worldline is broken.
Definition: path.cpp:492
void makeLink(const beadLocator &, const beadLocator &)
Make a link between beads.
Definition: path.cpp:415
vector< int > brokenWorldlinesL
A list of particles with broken worldlines on left of break.
Definition: path.h:39
void removeCenterLink(const beadLocator &)
Break the link to right of bead t center slice AND update lists.
Definition: path.cpp:423
double breakFactor(const beadLocator &, const beadLocator &) const
Returns factor for broken worldines.
Definition: path.cpp:502
const int numTimeSlices
A local constant copy of the number of time slices.
Definition: path.h:37
beadLocator addPrevBead(const beadLocator &, const dVec &)
Add a bead at the previous time slice.
Definition: path.cpp:221
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
beadLocator addBead(const int, const dVec &)
Add a bead to the worldline configuration at a given slice.
Definition: path.cpp:250
void addCenterLink(const beadLocator &, const beadLocator &)
Make a link between beads at center slice AND update lists.
Definition: path.cpp:441
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
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 addNextBead(const beadLocator &, const dVec &)
Add a bead at the next time slice.
Definition: path.cpp:194
LookupTable & lookup
A reference to the nearest neighbor lookup table.
Definition: path.h:46
void breakLink(const beadLocator &)
Break the link to right of bead.
Definition: path.cpp:406
bool isConfigDiagonal
Stores the diagonality of the configuration.
Definition: worm.h:39
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
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 decNumBeadsOn()
Decrement the number of active beads.
Definition: worm.h:92
const Array< unsigned int, 2 > & getBeads() const
Return the bead list.
Definition: worm.h:84
void addBead(int, int)
Safely add a bead (int indexed)
Definition: worm.h:135
beadLocator special1
Special bead, used in move updates.
Definition: worm.h:33
#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 PIMC_ASSERT(X)
Rename assert method.
Definition: common.h:64
#define XXX
Used to refer to a nonsense beadIndex.
Definition: common.h:98
Class definitions for all file input/output.
Communicator * communicate()
Global public access to the communcator singleton.
Definition: communicator.h:121
ConstantParameters * constants()
Global public access to the constants.
Definition: constants.h:201
LookupTable class definition.
Path class definition.