28 MTRand &_random, boost::ptr_vector<move_vector> &_movePtrVec,
29 boost::ptr_vector<estimator_vector> &_estimatorPtrVec,
30 const bool _startWithState,
uint32 _binSize) :
33 Npaths(_pathPtrVec.size()),
34 pathPtrVec(_pathPtrVec),
35 path(pathPtrVec.front()),
36 movePtrVec(_movePtrVec),
37 move(movePtrVec.front()),
38 estimatorPtrVec(_estimatorPtrVec),
39 estimator(estimatorPtrVec.front())
42 startWithState = _startWithState;
45 stateStrings.resize(Npaths);
60 numImagTimeSweeps = int(ceil((1.0*
constants()->numTimeSlices()/(1.0*
constants()->Mbar()))));
75 relaxmuMessage =
false;
76 relaxC0Message =
false;
78 equilODMessage =
false;
81 targetDiagFrac = 0.70;
111 double cumDiagProb = 0.0;
112 double cumOffDiagProb = 0.0;
115 for (
auto movePtr = move.begin(); movePtr != move.end(); ++movePtr) {
119 moveName = movePtr->getName();
120 if ((moveName ==
"bisection") || (moveName ==
"staging"))
121 moveName =
"diagonal";
124 if ( (movePtr->operateOnConfig == DIAGONAL) || movePtr->operateOnConfig == ANY ) {
125 cumDiagProb +=
constants()->attemptProb(moveName);
126 attemptDiagProb.push_back(cumDiagProb);
129 attemptDiagProb.push_back(cumDiagProb);
132 if ( (movePtr->operateOnConfig == OFFDIAGONAL) || movePtr->operateOnConfig == ANY) {
133 cumOffDiagProb +=
constants()->attemptProb(moveName);
134 attemptOffDiagProb.push_back(cumOffDiagProb);
137 attemptOffDiagProb.push_back(cumOffDiagProb);
140 moveIndex[moveName] = std::distance(move.begin(), movePtr);
144 attemptDiagProb.back() = 1.0 +
EPS;
145 attemptOffDiagProb.back() = 1.0 +
EPS;
148 if (startWithState ||
constants()->restart())
152 for (
auto &&estPtr : estimatorPtrVec)
153 for (
auto &est : estPtr)
157 for (
auto estimatorPtr = estimator.begin(); estimatorPtr != estimator.end(); ++estimatorPtr)
158 estimatorIndex[estimatorPtr->getName()] = std::distance(estimator.begin(), estimatorPtr);
171 string PathIntegralMonteCarlo::update(
const double x,
const int sweep,
const int pathIdx=0) {
174 string moveName =
"NONE";
178 if (pathPtrVec[pathIdx].worm.isConfigDiagonal)
179 index = std::lower_bound(attemptDiagProb.begin(),attemptDiagProb.end(),x)
180 - attemptDiagProb.begin();
182 index = std::lower_bound(attemptOffDiagProb.begin(),attemptOffDiagProb.end(),x)
183 - attemptOffDiagProb.begin();
186 moveName = movePtrVec[pathIdx].at(index).getName();
187 success = movePtrVec[pathIdx].at(index).attemptMove();
202 double x = random.rand();
206 if (x <
constants()->attemptProb(
"center of mass")) {
209 int index = moveIndex[
"center of mass"];
212 for (
auto & cmove : movePtrVec)
213 cmove.at(index).attemptMove();
217 if ( (move.at(index).getNumAttempted() > 0)
226 else if (CoMRatio < 0.3)
228 else if (CoMRatio < 0.4)
230 else if (CoMRatio > 0.6)
232 else if (CoMRatio > 0.7)
234 else if (CoMRatio > 0.8)
244 else if (x <
constants()->attemptProb(
"center of mass") +
constants()->attemptProb(
"displace")) {
246 int index = moveIndex[
"displace"];
247 for (
auto & cmove : movePtrVec)
248 cmove.at(index).attemptMove();
252 if ( (move.at(index).getNumAttempted() > 0)
257 if (displaceRatio < 0.2)
259 else if (displaceRatio < 0.3)
261 else if (displaceRatio < 0.4)
263 else if (displaceRatio > 0.6)
265 else if (displaceRatio > 0.7)
267 else if (displaceRatio > 0.8)
277 for (
int sweep = 0; sweep < numImagTimeSweeps; sweep++){
278 for (
auto &cmove : movePtrVec)
279 cmove.at(moveIndex[
"diagonal"]).attemptMove();
295 if (!relaxmuMessage) {
296 relaxmuMessage =
true;
297 cout << format(
"[PIMCID: %s] - Relax Chemical Potential.") %
constants()->
id() << endl;
300 double shiftmu = 1.0;
303 for (
int n = 0; n < numUpdates; n++) {
306 double x = random.rand();
308 for(
uint32 p=0; p<Npaths; p++) {
309 mName = update(x,n,p);
315 int curSize = PN.size();
317 PN.resizeAndPreserve(cN+1);
318 for (
int n = curSize; n < cN; n++)
331 int peakN = blitz::maxIndex(PN)[0];
333 int aveN = round(blitz::sum(i*PN)/blitz::sum(PN));
337 cout << format(
"Converged on μ = %8.5f\n\n") %
constants()->
mu();
345 bool peakInWindow = ((peakN >= N0-5) && (peakN <= N0+5));
347 if ((PN(N0) > 0) && (PN(N0+1) > 0) && (PN(N0-1) > 0) && peakInWindow) {
351 else if ((PN(N0) > 0) && (PN(N0+1) > 0) && peakInWindow) {
355 else if ((PN(N0) > 0) && (PN(N0-1) > 0) && peakInWindow) {
361 cout <<
"Reseting μ to previous best value." << endl;
375 int sgn = ((N0-aveN) > 0) - ((N0-aveN) < 0);
380 muFactor /= 1.61803399;
386 cout << format(
"Shifting %5s:%10.2f%10.2f%10d%10d%10d") % method %
387 constants()->
mu() % mu % PN(N0-1) % PN(N0) % PN(N0+1);
415 if (!relaxC0Message) {
416 relaxC0Message =
true;
417 cout << format(
"[PIMCID: %s] - Relax Worm Constant.\n") %
constants()->
id() << endl;
420 for (
int n = 0; n < numUpdates; n++) {
423 double x = random.rand();
425 for(
uint32 p=0; p<Npaths; p++) {
426 mName = update(x,n,p);
440 if ( (diagFrac > (targetDiagFrac-0.05)) && (diagFrac <= (targetDiagFrac+0.05)) ) {
441 cout << format(
"\nConverged on C0 = %8.5f\n\n") %
constants()->
C0();
447 cout << format(
"%4.2f\t%8.5f\t") % diagFrac %
constants()->
C0();
451 diagFracVals.push_back(diagFrac);
457 cout << format(
"%8.5f\t%5d\t%8.6f\n") %
constants()->
C0()
477 double PathIntegralMonteCarlo::linearRegressionC0() {
479 auto num = diagFracVals.size();
480 double diagFrac = diagFracVals.back();
484 sgnDiagFrac = ((targetDiagFrac-diagFrac) > 0) - ((targetDiagFrac-diagFrac) < 0);
486 if (diagFrac < targetDiagFrac) {
489 return 0.4*C0Vals.back();
492 return 1.6*C0Vals.back();
508 double sumX,sumY,sumX2,sumXY,sum1;
510 sum1 = sumX = sumY = sumXY = sumX2 = 0.0;
512 for (
int i = 0; i < num; i++) {
514 sumX2 += C0Vals[i]*C0Vals[i];
515 sumY += diagFracVals[i];
516 sumXY += C0Vals[i]*diagFracVals[i];
520 double denom = sum1*sumX2 - sumX*sumX;
521 double a0 = (sumY*sumX2 - sumX*sumXY)/denom;
522 double a1 = (sum1*sumXY - sumY*sumX)/denom;
524 double C0guess = (targetDiagFrac-a0)/a1;
526 if ((C0guess < 1E4) && ( C0guess > 1E-4) && (a1 < 0.0))
542 if (diagFrac < targetDiagFrac) {
545 return (1.0/1.618)*C0Vals.back();
548 return 1.61803399*C0Vals.back();
567 if (equilFrac < 0.1 && !startWithState) {
570 if (numRemainingSteps == 0)
571 numRemainingSteps = 1;
572 barStepSize = numRemainingSteps/44;
575 cout <<
"[" << std::flush;
581 if ((iStep > 0) && (iStep % barStepSize == 0) && (numBars < 44)) {
582 cout <<
"▇" << std::flush;
586 if (iStep == numRemainingSteps-1) {
587 for (
int nb = numBars; nb < 44; nb++)
588 cout <<
"▇" << std::flush;
589 cout <<
"] \t. Diagonal Pre-Equilibration." << endl << std::flush;
593 else if ((equilFrac < 0.2) && (relaxmu || relaxC0)) {
595 if (!equilODMessage) {
596 equilODMessage =
true;
598 numRemainingSteps = int(0.2*
constants()->numEqSteps())-iStep;
599 barStepSize = numRemainingSteps/44;
606 if ((iStep % barStepSize == 0) && (numBars < 44)) {
607 cout <<
"▇" << std::flush;
611 if (iStep ==
constants()->numEqSteps()/5-1) {
612 for (
int nb = numBars; nb < 44; nb++)
613 cout <<
"▇" << std::flush;
614 cout <<
"] \t. Off-Diagonal Pre-Equilibration." << endl << std::flush;
619 for (
int n = 0; n < numUpdates; n++) {
622 double x = random.rand();
624 for(
uint32 p=0;p<Npaths;p++){
625 mName = update(x,n,p);
631 if (relaxmu && !foundmu)
633 else if (relaxC0 && !foundC0) {
640 cout << format(
"[PIMCID: %s] - Equilibration Stage.") %
constants()->
id() << endl <<
"[";
642 barStepSize = numRemainingSteps/44;
649 if ((iStep % barStepSize == 0) && (numBars < 44)) {
650 cout <<
"▇" << std::flush;
656 for (
int n = 0; n < numUpdates; n++) {
659 double x = random.rand();
661 for(
uint32 p=0;p<Npaths;p++){
662 mName = update(x,n,p);
673 if ((iStep ==
constants()->numEqSteps()-1) && equilMessage){
674 for (
int nb = numBars; nb < 44; nb++)
675 cout <<
"▇" << std::flush;
693 for (
uint32 pIdx=0; pIdx<Npaths; pIdx++) {
696 for (
int n = 0; n < numUpdates ; n++) {
697 moveName = update(random.rand(),n,pIdx);
701 for (
auto& est : estimatorPtrVec[pIdx])
706 if (estimatorPtrVec[pIdx].size() > 0){
707 if (estimatorPtrVec[pIdx].front().getNumAccumulated() >= binSize) {
709 for (
auto& est : estimatorPtrVec[pIdx]) {
711 if (est.getNumAccumulated() >= binSize)
723 if(estimatorPtrVec.size() > Npaths) {
726 for (
auto& est : estimatorPtrVec.back())
731 if (estimatorPtrVec.back().front().getNumAccumulated() >= binSize) {
733 for (
auto& est : estimatorPtrVec.back())
734 if (est.getNumAccumulated() >= binSize)
740 if (estimator.size() == 0)
758 communicate()->
file(
"log")->stream() <<
"---------- Begin Acceptance Data ---------------" << endl;
760 communicate()->
file(
"log")->stream() << format(
"%-29s\t:\t%7.5f\n") %
"Total Rate"
761 % move.front().getTotAcceptanceRatio();
766 for (
auto &cmove : move){
768 moveName = cmove.getName();
771 if (cmove.variableLength) {
773 communicate()->
file(
"log")->stream() << format(
"%-12s Level %-10d\t:\t%7.5f\t(%d/%d)\n")
774 % moveName % n % cmove.getAcceptanceRatioLevel(n)
775 % cmove.numAcceptedLevel(n) % cmove.numAttemptedLevel(n);
778 communicate()->
file(
"log")->stream() << format(
"%-29s\t:\t%7.5f\t(%d/%d)\n") % moveName
779 % cmove.getAcceptanceRatio() % cmove.numAccepted % cmove.numAttempted;
783 communicate()->
file(
"log")->stream() <<
"---------- End Acceptance Data -----------------" << endl;
789 communicate()->
file(
"log")->stream() <<
"---------- Begin Estimator Data ----------------" << endl;
791 for (
auto &cestimator : estimator) {
792 communicate()->
file(
"log")->stream() << format(
"%-33s\t:\t%16d\t%16d\n") % cestimator.getName()
793 % cestimator.getNumSampled() % cestimator.getTotNumAccumulated();
797 communicate()->
file(
"log")->stream() <<
"---------- End Estimator Data ------------------" << endl;
806 stringstream stateStrStrm;
811 for(
uint32 pIdx=0; pIdx<Npaths; pIdx++){
813 stateStrStrm.str(
"");
816 pathPtrVec[pIdx].leftPack();
817 pathPtrVec[pIdx].lookup.updateGrid(path);
820 stateStrStrm << pathPtrVec[pIdx].getNumParticles() << endl;
823 stateStrStrm << format(
"%16d\t%16d\n")
824 % movePtrVec[pIdx].front().totAccepted % movePtrVec[pIdx].front().totAttempted;
828 for (
const auto &cmove : movePtrVec[pIdx])
829 stateStrStrm << format(
"%16d\t%16d\n") % cmove.numAccepted % cmove.numAttempted;
832 for (
const auto &cestimator : estimatorPtrVec[pIdx])
833 stateStrStrm << format(
"%16d\t%16d\n") % cestimator.getTotNumAccumulated()
834 % cestimator.getNumSampled();
837 stateStrStrm << setprecision(16) << pathPtrVec[pIdx].beads << endl;
838 stateStrStrm << pathPtrVec[pIdx].nextLink << endl;
839 stateStrStrm << pathPtrVec[pIdx].prevLink << endl;
842 stateStrStrm << pathPtrVec[pIdx].worm.beads << endl;
845 uint32 randomState[random.SAVE];
846 random.save(randomState);
847 for (
int i = 0; i < random.SAVE; i++)
848 stateStrStrm << randomState[i] <<
" ";
849 stateStrStrm << endl;
852 stateStrings[pIdx] = stateStrStrm.str();
858 string stateFileName;
859 if (
constants()->saveStateFiles() || finalSave) {
861 for(
uint32 pIdx=0; pIdx<Npaths; pIdx++) {
863 stateFileName =
"state";
865 stateFileName += str(format(
"%d") % (pIdx+1));
871 communicate()->
file(stateFileName.c_str())->stream() << stateStrings[pIdx];
882 void PathIntegralMonteCarlo::loadClassicalState(Array <dVec,2> &tempBeads,
883 Array <unsigned int, 2> &tempWormBeads,
int numWorldLines) {
890 for(
uint32 pIdx=0; pIdx<Npaths; pIdx++){
892 for (
int n = 0; n < numWorldLines; n++) {
896 if (tempWormBeads(beadIndex)) {
899 pathPtrVec[pIdx].beads(Range::all(),ptcl) = tempBeads(beadIndex);
900 pathPtrVec[pIdx].worm.beads(Range::all(),ptcl) = 1;
910 void PathIntegralMonteCarlo::loadQuantumState(Array <dVec,2> &tempBeads,
911 Array <beadLocator,2> &tempNextLink, Array <beadLocator,2> &tempPrevLink,
912 int numTimeSlices,
int tempNumWorldLines) {
915 Array <bool, 1> doBead(tempNumWorldLines);
922 for(
uint32 pIdx=0; pIdx<Npaths; pIdx++) {
930 for (
int n = 0; n < tempNumWorldLines; n++) {
938 beadIndex = startBead;
943 newStartBead = slice,ptcl;
947 doBead(beadIndex[1]) =
false;
949 pathPtrVec[pIdx].beads(slice % numTimeSlices,ptcl) = tempBeads(beadIndex);
950 pathPtrVec[pIdx].worm.beads(slice % numTimeSlices,ptcl) = 1;
952 beadIndex = tempNextLink(beadIndex);
957 if ( ((slice % numTimeSlices) == 0) && !all(beadIndex==startBead)) {
958 pathPtrVec[pIdx].nextLink(numTimeSlices-1,ptcl) = 0,ptcl+1;
959 pathPtrVec[pIdx].prevLink(0,ptcl+1) = numTimeSlices-1,ptcl;
962 }
while (!all(beadIndex==startBead));
966 for (
int tslice = (slice % numTimeSlices); tslice < numTimeSlices; tslice++) {
967 pathPtrVec[pIdx].beads(tslice,ptcl) = tempBeads(beadIndex);
968 pathPtrVec[pIdx].worm.beads(tslice,ptcl) = 1;
970 pathPtrVec[pIdx].nextLink(numTimeSlices-1,ptcl) = newStartBead;
971 pathPtrVec[pIdx].prevLink(newStartBead) = numTimeSlices-1,ptcl;
986 void PathIntegralMonteCarlo::loadState() {
990 string fileInitStr =
"init";
992 for(
uint32 pIdx=0; pIdx<Npaths; pIdx++){
995 fileInitStr = str(format(
"init%d") % (pIdx+1));
999 movePtrVec[pIdx].front().resetTotAccept();
1002 for (
auto &cmove : movePtrVec[pIdx])
1003 cmove.resetAccept();
1006 for (
auto &cestimator : estimatorPtrVec[pIdx])
1007 cestimator.restart(0,0);
1011 int numTimeSlices = pathPtrVec[pIdx].numTimeSlices;
1016 while (!
communicate()->file(fileInitStr)->stream().eof()) {
1017 if (
communicate()->file(fileInitStr)->stream().peek() !=
'(')
1018 getline (
communicate()->file(fileInitStr)->stream(), tempString);
1024 pathPtrVec[pIdx].beads.resize(numTimeSlices,numWorldLines);
1025 pathPtrVec[pIdx].nextLink.resize(numTimeSlices,numWorldLines);
1026 pathPtrVec[pIdx].prevLink.resize(numTimeSlices,numWorldLines);
1027 pathPtrVec[pIdx].worm.beads.resize(numTimeSlices,numWorldLines);
1030 Array <dVec,2> tempBeads;
1036 int tempNumTimeSlices = tempBeads.rows();
1038 if (tempNumTimeSlices == numTimeSlices) {
1041 pathPtrVec[pIdx].beads = tempBeads;
1044 communicate()->
file(fileInitStr)->stream() >> pathPtrVec[pIdx].nextLink;
1045 communicate()->
file(fileInitStr)->stream() >> pathPtrVec[pIdx].prevLink;
1048 communicate()->
file(fileInitStr)->stream() >> pathPtrVec[pIdx].worm.beads;
1056 pathPtrVec[pIdx].prevLink[0] = i1-1;
1057 pathPtrVec[pIdx].prevLink[1] = i2;
1058 pathPtrVec[pIdx].nextLink[0] = i1+1;
1059 pathPtrVec[pIdx].nextLink[1] = i2;
1063 pathPtrVec[pIdx].prevLink(0,Range::all())[0] = numTimeSlices-1;
1064 pathPtrVec[pIdx].nextLink(numTimeSlices-1,Range::all())[0] = 0;
1067 pathPtrVec[pIdx].worm.beads = 0;
1070 Array <beadLocator,2> tempNextLink;
1071 Array <beadLocator,2> tempPrevLink;
1072 Array <unsigned int,2> tempWormBeads;
1081 loadClassicalState(tempBeads,tempWormBeads, numWorldLines);
1091 for (
int slice = 0; slice < numTimeSlices; slice++) {
1092 for (
int ptcl = 0; ptcl < numWorldLines; ptcl++) {
1093 beadIndex = slice,ptcl;
1094 if (!pathPtrVec[pIdx].worm.beads(beadIndex)) {
1095 pathPtrVec[pIdx].nextLink(beadIndex) =
XXX;
1096 pathPtrVec[pIdx].prevLink(beadIndex) =
XXX;
1102 tempPrevLink.free();
1103 tempNextLink.free();
1104 tempWormBeads.free();
1111 uint32 randomState[random.SAVE];
1112 for (
int i = 0; i < random.SAVE; i++)
1114 random.load(randomState);
1118 pathPtrVec[pIdx].worm.resetNumBeadsOn();
1123 pathPtrVec[pIdx].numBeadsAtSlice = 0;
1124 for (beadIndex[0] = 0; beadIndex[0] < numTimeSlices; ++beadIndex[0]) {
1125 for (beadIndex[1] = 0; beadIndex[1] < numWorldLines; ++beadIndex[1]) {
1126 pathPtrVec[pIdx].boxPtr->putInside(path(beadIndex));
1127 if (pathPtrVec[pIdx].worm.beadOn(beadIndex))
1128 ++pathPtrVec[pIdx].numBeadsAtSlice(beadIndex[0]);
1133 pathPtrVec[pIdx].worm.isConfigDiagonal =
true;
1134 pathPtrVec[pIdx].worm.reset();
1137 pathPtrVec[pIdx].lookup.resizeList(numWorldLines);
1138 pathPtrVec[pIdx].lookup.updateGrid(path);
1141 pathPtrVec[pIdx].resetBrokenClosedVecs();
1170 Array <beadLocator,1> startBead,endBead;
1171 startBead.resize(numParticles);
1172 endBead.resize(numParticles);
1175 Array <int,1> wlLength(numParticles);
1179 Array <int,2> beadNum(numTimeSlices,numParticles);
1182 int numWorldLines = 0;
1185 Array <bool,2> doBead(numTimeSlices,numParticles);
1191 for (
int n = 0; n < numParticles; n++) {
1194 startBead(nwl) = 0,n;
1197 if (doBead(startBead(nwl))) {
1207 endBead(nwl) = startBead(nwl);
1211 beadIndex = startBead(nwl);
1214 doBead(beadIndex) =
false;
1215 beadNum(beadIndex) = beadNumber;
1218 beadIndex = path.
next(beadIndex);
1219 }
while (!all(beadIndex==endBead(nwl)));
1223 if ((length % numTimeSlices) == 0)
1224 wlLength(nwl) = length/numTimeSlices;
1232 numWorldLines = nwl;
1235 communicate()->
file(
"wl")->stream() << format(
"REMARK [CONFIG %04d]\n") % configNumber;
1240 double scale = 10.0;
1243 for (i = 0; i <
NDIM; i++)
1249 communicate()->
file(
"wl")->stream() << format(
"%7.2f%7.2f%7.2f %-11s%4d\n") % 90.0 % 90.0 % 90.0 %
"P 1" % 1;
1253 for (
int n = 0; n < numWorldLines; n++) {
1254 beadIndex = startBead(n);
1257 if (beadIndex[0] == 0) {
1258 communicate()->
file(
"wl")->stream() << format(
"%-6s%5d %-4s %03d %9s") %
"ATOM"
1259 % beadNum(beadIndex) %
"H0" % wlLength(n) %
" ";
1262 communicate()->
file(
"wl")->stream() << format(
"%-6s%5d %-4s %03d %9s") %
"ATOM"
1263 % beadNum(beadIndex) %
"HE" % wlLength(n) %
" ";
1267 for (i = 0; i <
NDIM; i++) {
1268 communicate()->
file(
"wl")->stream() << format(
"%8.3f") % (scale*path(beadIndex)[i]);
1276 beadIndex = path.
next(beadIndex);
1277 }
while (!all(beadIndex==endBead(n)));
1282 for (
int n = 0; n < numWorldLines; n++) {
1283 beadIndex = startBead(n);
1285 communicate()->
file(
"wl")->stream() << format(
"%-6s%5d") %
"CONECT" % beadNum(beadIndex);
1287 prevIndex = path.
prev(beadIndex);
1288 nextIndex = path.
next(beadIndex);
1296 sep = path(beadIndex) - path(prevIndex);
1298 communicate()->
file(
"wl")->stream() << format(
"%5d") % beadNum(prevIndex);
1304 sep = path(nextIndex) - path(beadIndex);
1306 communicate()->
file(
"wl")->stream() << format(
"%5d") % beadNum(nextIndex);
1310 beadIndex = path.
next(beadIndex);
1311 }
while (!all(beadIndex==endBead(n)));
1327 void PathIntegralMonteCarlo::printWormState() {
1330 Array <beadLocator,1> wormBeads;
1339 <<
" gap " << path.
worm.
gap << endl;
1346 wormBeads(n) = beadIndex;
1347 beadIndex = path.
next(beadIndex);
1363 string histogramDisplay =
"\n";
1366 int start,end,window;
1376 if (end > PN.size()-1)
1381 for (
int n = start; n <= end; n++) {
1382 int numStars = int(PN(n)*factor);
1383 histogramDisplay += str(format(
"%03d|") % n);
1384 for (
int i = 0; i < numStars; i++)
1385 histogramDisplay +=
"▇";
1386 histogramDisplay +=
"\n";
1389 histogramDisplay +=
"\n";
1398 double aveN = (blitz::sum(i*PN)/blitz::sum(PN));
1400 double diffAveN = abs(N0-aveN);
1402 if (diffAveN < bestDiffAveN) {
1403 bestDiffAveN = diffAveN;
1407 inWindow = (sumPN > 0);
1411 return histogramDisplay;
File * file(string type)
Get method returning file object.
void setmu(double _mu)
Set the value of the chemical potential.
double T() const
Get temperature.
double mu() const
Get chemical potential.
void shiftCoMDelta(double frac)
Shift the CoM move size.
void shiftDisplaceDelta(double frac)
Shift the displace move size.
void setC0(double _C0)
Set the value of C0.
string id()
Get simulation UUID.
double C0() const
Get worm factor C0.
int b()
Get bisection level.
double comDelta() const
Get center of mass shift.
uint32 numEqSteps()
Get the number of equilibration steps.
int initialNumParticles()
Get initial number of particles.
double volume
The volume of the container in A^3.
double rcut2
The smallest separation squared.
dVec side
The linear dimensions of the box.
void reset()
Reset a file.
void rename()
Rename a file.
void close()
Close the file.
void outputPDB()
Output the worldline configuration to disk using PDB , suitable for plotting using vmd.
~PathIntegralMonteCarlo()
Destructor.
bool equilStepRelaxC0()
Relax the worm constant C0 until we have found the desired diagonal fraction.
bool equilStepRelaxmu()
Relax the chemical potential to find a target number of particles.
int prevNumCoMAttempted
Number of Center of Mass moves attempted.
int numDisplaceAttempted
Number of equil Displace moves.
int numDisplaceAccepted
Number of equil Displace moves accepted.
void saveState(const int finalSave=0)
Save the state of the simulation to disk, including all path, worm, move and estimator data.
int numConfig
Number of configurations;.
void equilStep(const uint32, const bool, const bool)
Equilibration.
void finalOutput()
Output simulation statistics to disk.
string printHistogram()
Output a histogram to the terminal.
int numStepsAttempted
Number of steps for relaxing C0.
PathIntegralMonteCarlo(boost::ptr_vector< Path > &, MTRand &, boost::ptr_vector< move_vector > &, boost::ptr_vector< estimator_vector > &, const bool, uint32 binSize=100)
Constructor.
int numCoMAttempted
Number of Center of Mass moves.
int numCoMAccepted
Number of equil CoM moves accepted.
int numNAttempted
The number of particle measurements.
void equilStepDiagonal()
Diagonal Equilibration.
int numDiagonal
Number of consecutive diagonal configs.
int numStoredBins
Number of stored estimators.
int numMuAttempted
Number of moves between mu adjustments.
int getNumParticles() const
Get the size of the worldline array.
void printWormConfig(Array< beadLocator, 1 > &)
Used when debugging worm configurations.
const int numTimeSlices
A local constant copy of the number of time slices.
void printLinks(Tstream &)
Output bead-link info, used for debugging.
beadLocator & next(int slice, int ptcl)
Move one link forward in imaginary time.
const Container * boxPtr
A constant reference to the container class.
Worm worm
Details on the worm.
beadLocator & prev(int slice, int ptcl)
Move one link backward in imaginary time.
int getTrueNumParticles() const
The number of active particles.
bool isConfigDiagonal
Stores the diagonality of the configuration.
int gap
numTimeSlices - length
beadLocator tail
The coordinates of the worm tail.
beadLocator head
The coordinates of the worm head.
int beadOn(int, int) const
Safely get a bead (int indexed)
bool foundBead(const Path &, const beadLocator &)
Test to see if a supplied bead is located on a worm.
int getNumBeadsOn() const
Return the number of active beads.
const Array< unsigned int, 2 > & getBeads() const
Return the bead list.
int length
The length of the worm.
Ttype & max(Ttype &x, Ttype &y)
Maximum of two inputs.
#define NDIM
Number of spatial dimnsions.
unsigned long uint32
Unsigned integer type, at least 32 bits.
TinyVector< int, 2 > beadLocator
time-slice,bead-number world line index
#define EPS
A small number.
Ttype & min(Ttype &x, Ttype &y)
Minimum of two inputs.
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
#define XXX
Used to refer to a nonsense beadIndex.
Communicator * communicate()
Global public access to the communcator singleton.
ConstantParameters * constants()
Global public access to the constants.
LookupTable class definition.
PathIntegralMonteCarlo class definition.