20 #define REGISTER_ESTIMATOR(NAME,TYPE) \
21 const string TYPE::name = NAME;\
22 bool reg ## TYPE = estimatorFactory()->Register<TYPE>(TYPE::name);
82 const string SwapEstimator::name =
"pigs multi swap";
85 const string EntPartEstimator::name =
"pigs multi entanglement of particles";
104 const MTRand &_random,
double _maxR,
int _frequency,
string _label) :
106 actionPtr(_actionPtr),
109 frequency(_frequency),
113 totNumAccumulated(0),
218 for(
size_t i = 0; i < estLabel.size(); ++i)
222 estLabel.front() = str(format(
"#%15s") % estLabel.front());
224 for (
const auto&
label : estLabel)
253 (*outFilePtr) << endl;
289 for (
int n = 0; n <
numEst; n++)
293 (*outFilePtr) << endl;
312 (*outFilePtr) << endl;
315 for (
int n = 0; n <
numEst; n++)
341 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
342 int _frequency,
string _label) :
343 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
346 header = str(format(
"%16s%16s") %
"us" %
"mcsteps");
368 void TimeEstimator::accumulate() {
370 time_begin = std::chrono::high_resolution_clock::now();
377 time_end = std::chrono::high_resolution_clock::now();
378 estimator(0) = 0.001*std::chrono::duration_cast<std::chrono::nanoseconds>(
383 time_begin = time_end;
386 for (
int n = 0; n <
numEst; n++)
390 (*outFilePtr) << endl;
410 const MTRand &_random,
double _maxR,
int _frequency,
string _label) :
411 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
414 initialize({
"K",
"V",
"V_ext",
"V_int",
"E",
"E_mu",
"K/N",
"V/N",
"E/N"});
430 void EnergyEstimator::accumulate() {
434 TinyVector<double,2> totVop(0.0);
458 beadIndex = slice,ptcl;
460 totK -= dot(vel,vel);
479 t2 /= 1.0*numTimeSlices;
482 totVop /= (numTimeSlices/
actionPtr->period);
485 totK += (classicalKinetic + t1);
486 totV = t2 - t1 + tailV;
502 if (numParticles > 0) {
524 const MTRand &_random,
double _maxR,
int _frequency,
string _label) :
525 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
529 header = str(format(
"#%15s%16s%16s%16s%16s%16s%16s%16s%16s%16s%16s%16s%16s%16s%16s%16s%16s%16s%16s")
530 %
"K_op" %
"K_cv" %
"V_op" %
"V_cv" %
"E" %
"E_mu" %
"K_op/N" %
"K_cv/N" %
"V_op/N"
531 %
" V_cv/N" %
"E/N" %
"EEcv*Beta^2"%
"Ecv*Beta" %
"dEdB" %
"CvCov1"
532 %
"CvCov2" %
"CvCov3" %
"E_th" %
"P");
558 void VirialEnergyEstimator::accumulate() {
570 double virKinTerm = 0.0;
585 double T1 = 0.5 *
NDIM * numParticles / (1.0*virialWindow*
constants()->
tau());
590 double exchangeNorm = 1.0/(4.0*virialWindow*pow(
constants()->tau(),2)
594 double Pressure =
NDIM*numParticles;
600 for (
int slice = 0; slice < numTimeSlices; slice++) {
607 for (
int gamma = 1; gamma <= virialWindow; gamma++) {
610 beadNextOld = beadNext;
612 T2 -= dot(vel1,vel2);
615 thermE -= dot(vel2,vel2);
629 for (
int slice = 0; slice < numTimeSlices; slice++) {
631 T3 +=
actionPtr->deltaDOTgradUterm1(slice);
632 T4 +=
actionPtr->deltaDOTgradUterm2(slice);
633 T5 +=
actionPtr->derivPotentialActionTau(slice);
634 virKinTerm +=
actionPtr->virKinCorr(slice);
636 totVop += sum(
actionPtr->potential(slice));
642 P3 *= (1.0/(2.0*numTimeSlices));
648 totVop /= (0.5 * numTimeSlices);
653 T5 /= (1.0*numTimeSlices);
654 virKinTerm /= (0.5*beta);
659 thermE += thermTerm1;
664 totEcv = T1 + T2 + T3 + T4 + T5 + tailV;
667 Kcv = T1 + T2 + T3 + T4 + virKinTerm;
671 double dEdB = (-1.0*T1 - 2.0*T2 + 2.0*T4)/
constants()->
tau();
673 for (
int slice = 0; slice<numTimeSlices; slice++){
674 dEdB +=
actionPtr->secondderivPotentialActionTau(slice)/(1.0*numTimeSlices);
676 dEdB *= beta*beta/(1.0*numTimeSlices);
685 estimator(6) += (totEcv - totVop)/(1.0*numParticles);
687 estimator(8) += totVop/(1.0*numParticles);
688 estimator(9) += (totEcv - Kcv)/(1.0*numParticles);
689 estimator(10) += totEcv/(1.0*numParticles);
692 estimator(11) += totEcv*thermE*beta*beta;
695 estimator(14) += totEcv*thermE*beta*beta*totEcv*beta;
697 estimator(16) += totEcv*thermE*beta*beta*dEdB;
720 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
721 int _frequency,
string _label) :
722 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
725 header = str(format(
"%16s%16s%16s") %
"N" %
"N^2" %
"density");
739 void NumberParticlesEstimator::accumulate() {
742 estimator(1) += 1.0*numParticles*numParticles;
760 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
761 int _frequency,
string _label) :
762 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
766 startParticleNumber =
max(
constants()->initialNumParticles()-particleShift,0);
767 if (startParticleNumber == 0)
768 endParticleNumber = 2*particleShift;
771 maxNumParticles = endParticleNumber - startParticleNumber + 1;
774 if ((
constants()->initialNumParticles() - particleShift) < 0)
780 header = str(format(
"#%15d") % startParticleNumber);
781 for (
int n = startParticleNumber+1; n <= endParticleNumber; n++)
782 header.append(str(format(
"%16d") % n));
794 void NumberDistributionEstimator::accumulate() {
799 if (index >= 0 && index < maxNumParticles)
817 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
818 int _frequency,
string _label) :
819 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
825 diffLabels = {
"dx",
"dy",
"dz"};
829 for (
int i = 0; i <
NDIM; i++)
832 header += str(format(
"#%15s") %
"density");
835 for (
int n = 0; n <
numEst; n++)
850 void ParticlePositionEstimator::accumulate() {
856 beadIndex = slice,ptcl;
879 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
880 int _frequency,
string _label) :
881 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
884 header = str(format(
"#%15s%16s") %
"film dens" %
"bulk dens");
903 void BipartitionDensityEstimator::accumulate() {
907 for (
int i = 0; i <
NDIM; i++)
912 double excZ = excLens(1);
915 double bulkVol ((lside[2]-2.0*excZ)*lside[0]*lside[1]);
916 double filmArea (lside[0]*2.0*excZ);
926 beadIndex = slice,ptcl;
928 pos =
path(beadIndex);
931 else if (pos[2] < -excZ)
938 estimator(0) += 1.0*filmNum/(1.0*filmArea);
939 estimator(1) += 1.0*bulkNum/(1.0*bulkVol);
956 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
957 int _frequency,
string _label) :
958 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
971 header = str(format(
"# ESTINF: dz = %12.6E NGRIDSEP = %d\n") % dz % numGrid);
972 header += str(format(
"#%15.6E") % (-0.5*side[
NDIM-1]));
973 for (
int n = 1; n < numGrid; n++)
974 header.append(str(format(
"%16.6E") % (n*dz - 0.5*side[
NDIM-1])));
977 for (
int i = 0; i <
NDIM-1; i++)
994 void LinearParticlePositionEstimator::accumulate() {
1002 beadIndex = slice,ptcl;
1003 pos =
path(beadIndex);
1006 index =
static_cast<int>(abs(pos[
NDIM-1] + 0.5*side[
NDIM-1] -
EPS ) / (dz +
EPS));
1009 if (index < numGrid)
1030 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
1031 int _frequency,
string _label) :
1032 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1038 numGrid = numLinearGrid*numLinearGrid;
1041 for (
int i = 0; i <
NDIM; i++)
1048 header = str(format(
"# ESTINF: dx = %12.6E dy = %12.6E NGRIDSEP = %d\n")
1049 % dl[0] % dl[1] % numLinearGrid);
1050 header += str(format(
"#%15.3E") % 0.0);
1051 for (
int n = 1; n < numGrid; n++)
1052 header.append(str(format(
"%16.3E") % (1.0*n)));
1056 for (
int i = 0; i <
NDIM-1; i++)
1074 void PlaneParticlePositionEstimator::accumulate() {
1081 beadIndex = slice,ptcl;
1082 pos =
path(beadIndex);
1085 for (
int i = 0; i <
NDIM-1; i++) {
1087 for (
int j = i+1; j <
NDIM-1; j++)
1088 scale *= numLinearGrid;
1089 index += scale*
static_cast<int>(abs(pos[i] + 0.5*side[i] -
EPS ) / (dl[i] +
EPS));
1093 if (index < numGrid)
1113 const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
1114 double _maxR,
int _frequency,
string _label) :
1115 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1120 numGrid = numLinearGrid*numLinearGrid;
1123 for (
int i = 0; i <
NDIM; i++)
1131 header = str(format(
"# ESTINF: dx = %12.6E dy = %12.6E NGRIDSEP = %d\n")
1132 % dl[0] % dl[1] % numLinearGrid);
1133 header += str(format(
"#%15s") %
"plane density");
1137 for (
int i = 0; i <
NDIM-1; i++)
1154 void PlaneParticleAveragePositionEstimator::accumulate() {
1161 beadIndex = slice,ptcl;
1162 pos =
path(beadIndex);
1165 for (
int i = 0; i <
NDIM-1; i++) {
1167 for (
int j = i+1; j <
NDIM-1; j++)
1168 scale *= numLinearGrid;
1169 index += scale*
static_cast<int>(abs(pos[i] + 0.5*side[i] -
EPS ) / (dl[i] +
EPS));
1173 if (index < numGrid)
1192 const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
1193 double _maxR,
int _frequency,
string _label) :
1194 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1199 numGrid = numLinearGrid*numLinearGrid;
1202 for (
int i = 0; i <
NDIM; i++)
1210 header = str(format(
"# ESTINF: dx = %12.6E dy = %12.6E NGRIDSEP = %d\n")
1211 % dl[0] % dl[1] % numLinearGrid);
1212 header += str(format(
"#%15s") %
"plane external potential");
1227 void PlaneAverageExternalPotentialEstimator::accumulate() {
1234 beadIndex = slice,ptcl;
1235 pos =
path(beadIndex);
1239 for (
int i = 0; i <
NDIM-1; i++) {
1241 for (
int j = i+1; j <
NDIM-1; j++)
1242 scale *= numLinearGrid;
1243 index += scale*
static_cast<int>(abs(pos[i] + 0.5*side[i] -
EPS ) / (dl[i] +
EPS));
1247 if (index < numGrid) {
1268 (*outFilePtr) << endl;
1272 for (
int n = 0; n <
numEst; n++) {
1273 if (abs(
norm(n)) > 0.0)
1277 (*outFilePtr) << format(
"%16.8E\n") % Vext;
1298 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
1299 int _frequency,
string _label) :
1300 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1309 header = str(format(
"#%15s%16s%16s%16s") %
"rho_s/rho" %
"W^2(x)" %
"W^2(y)" %
"W^2(z)");
1310 for (
int w = -windMax; w <= windMax; w++)
1311 header += str(format(
"%11sP(%+1d)") %
" " % w);
1312 header += str(format(
"%16s") %
"Area_rho_s");
1334 void SuperfluidFractionEstimator::accumulate() {
1337 double locW2oN = 0.0;
1347 for (
int slice = 0; slice < numTimeSlices; slice++) {
1351 beadIndex = slice,ptcl;
1356 pos1 =
path(beadIndex);
1358 Az += pos1[0]*pos2[1]-pos2[0]*pos1[1];
1359 I += pos1[0]*pos2[0] + pos1[1]*pos2[1];
1379 for (i = 0; i <
NDIM; i++)
1381 for (
int j = i; j < 3; j++)
1386 for (
int p = -windMax; p <= windMax; p++) {
1387 if (abs(W[
NDIM-1]-1.0*p) < 0.2)
1411 (
const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
1412 int _frequency,
string _label) :
1413 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1425 header = str(format(
"#%15.3E") % 0.0);
1426 for (
int n = 1; n < numGrid; n++)
1427 header.append(str(format(
"%16.3E") % (1.0*n)));
1432 locWz.resize(numGrid);
1450 void PlaneWindingSuperfluidDensityEstimator::accumulate() {
1461 for (
int slice = 0; slice < numTimeSlices; slice++) {
1464 beadIndex = slice,ptcl;
1465 pos1 =
path(beadIndex);
1468 int i =
static_cast<int>(abs(pos1[0] + 0.5*side[0] -
EPS ) / (dx +
EPS));
1469 int j =
static_cast<int>(abs(pos1[1] + 0.5*side[1] -
EPS ) / (dy +
EPS));
1478 locWz(k) += vel[
NDIM-1];
1500 (
const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
1501 int _frequency,
string _label) :
1502 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1514 header = str(format(
"#%15.3E") % 0.0);
1515 for (
int n = 1; n < numGrid; n++)
1516 header.append(str(format(
"%16.3E") % (1.0*n)));
1521 locAz.resize(numGrid);
1539 void PlaneAreaSuperfluidDensityEstimator::accumulate() {
1549 for (
int slice = 0; slice < numTimeSlices; slice++) {
1552 beadIndex = slice,ptcl;
1553 pos1 =
path(beadIndex);
1556 int i =
static_cast<int>(abs(pos1[0] + 0.5*side[0] -
EPS ) / (dx +
EPS));
1557 int j =
static_cast<int>(abs(pos1[1] + 0.5*side[1] -
EPS ) / (dy +
EPS));
1561 rp2 = pos1[0]*pos1[0] + pos1[1]*pos1[1];
1566 tAz = pos1[0]*pos2[1] - pos2[0]*pos1[1];
1573 locAz(k) += tAz/rp2;
1595 (
const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
1596 int _frequency,
string _label) :
1597 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1608 header = str(format(
"#%15.3E") % 0.0);
1609 for (
int n = 1; n < numGrid; n++)
1610 header.append(str(format(
"%16.3E") % ((n)*dR)));
1613 for (
int n = 0; n < numGrid; n++)
1617 locWz.resize(numGrid);
1633 void RadialWindingSuperfluidDensityEstimator::accumulate() {
1644 for (
int slice = 0; slice < numTimeSlices; slice++) {
1647 beadIndex = slice,ptcl;
1648 pos1 =
path(beadIndex);
1651 int k = int(sqrt(pos1[0]*pos1[0]+pos1[1]*pos1[1])/dR);
1659 locWz(k) += vel[
NDIM-1];
1681 (
const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
1682 int _frequency,
string _label) :
1683 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1694 header = str(format(
"#%15.3E") % 0.0);
1695 for (
int n = 1; n < numGrid; n++)
1696 header.append(str(format(
"%16.3E") % ((n)*dR)));
1699 for (
int n = 0; n < numGrid; n++)
1703 locAz.resize(numGrid);
1719 void RadialAreaSuperfluidDensityEstimator::accumulate() {
1729 for (
int slice = 0; slice < numTimeSlices; slice++) {
1732 beadIndex = slice,ptcl;
1733 pos1 =
path(beadIndex);
1735 rp2 = pos1[0]*pos1[0] + pos1[1]*pos1[1];
1737 int k = int(sqrt(rp2)/dR);
1740 tAz = pos1[0]*pos2[1] - pos2[0]*pos1[1];
1747 locAz(k) += tAz/rp2;
1769 (
const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
1770 int _frequency,
string _label):
1771 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1781 header += str(format(
"#%15s%16s%16s") %
"W:rho_s" %
"A:rho_s" %
"A^2");
1786 for (
int n = 0; n < numGrid; n++) {
1789 norm(n+numGrid) = C/dV;
1790 norm(n+2*numGrid) = C/dV;
1794 locWz.resize(numGrid);
1797 locAz.resize(numGrid);
1800 locA2.resize(numGrid);
1825 (*outFilePtr) << endl;
1828 for (
int n = 0; n < numGrid; n++) {
1829 for (
int i = 0; i < int(
numEst/numGrid); i++)
1832 (*outFilePtr) << endl;
1845 void LocalSuperfluidDensityEstimator::accumulate() {
1859 for (
int slice = 0; slice < numTimeSlices; slice++) {
1862 beadIndex = slice,ptcl;
1863 pos1 =
path(beadIndex);
1869 rp2 = pos1[0]*pos2[0] + pos1[1]*pos2[1];
1870 if (abs(rp2) < dR*dR)
1878 locWz(n) += vel[
NDIM-1];
1881 tAz = pos1[0]*pos2[1] - pos2[0]*pos1[1];
1888 locAz(n) += tAz/rp2;
1916 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
1917 int _frequency,
string _label) :
1918 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1922 header = str(format(
"%16s") %
"diagonal");
1936 void DiagonalFractionEstimator::accumulate() {
1969 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
1970 int _frequency,
string _label) :
1971 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
1978 header = str(format(
"#%15s%16s%16s%16s%16s") %
"rel-worm-len" %
1979 "rel-worm-gap" %
"worm-cost" %
"head-tail-sep" %
"particles");
1991 void WormPropertiesEstimator::accumulate() {
2016 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
2017 int _frequency,
string _label) :
2018 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
2029 header = str(format(
"#%15d") % 1);
2030 for (
int n = 2; n <= maxNumCycles; n++)
2031 header.append(str(format(
"%16d") % n));
2048 void PermutationCycleEstimator::accumulate() {
2059 if (numParticles > 0)
2060 cycleNorm = 1.0 / (1.0*numParticles);
2066 doBead.resize(numWorldlines);
2070 for (
int n = 0; n < numWorldlines; n++) {
2079 beadIndex = startBead;
2088 if (beadIndex[0]==0)
2089 doBead(beadIndex[1]) =
false;
2092 }
while (!all(beadIndex==startBead));
2096 if ((cycleNum > 0) && (cycleNum <= maxNumCycles))
2097 estimator(cycleNum-1) += 1.0*cycleNum*cycleNorm;
2118 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
2119 int _frequency,
string _label) :
2120 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label) {
2175 void LocalPermutationEstimator::accumulate() {
2185 doBead.resize(numWorldlines);
2189 for (
int n = 0; n < numWorldlines; n++) {
2198 beadIndex = startBead;
2207 if (beadIndex[0]==0)
2208 doBead(beadIndex[1]) =
false;
2211 }
while (!all(beadIndex==startBead));
2220 if ((cycleNum > 0) && (cycleNum <= maxNumCycles)){
2222 numBeadInGrid(nn) += 1;
2226 }
while (!all(beadIndex==startBead));
2232 for (
int i(0); i<int(
estimator.size()); i++){
2233 if ((
estimator(i) > 0) && (numBeadInGrid(i) > 0)){
2239 numBeadInGrid.resize(0);
2257 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
2258 int _frequency,
string _label) :
2259 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label),
2273 header = str(format(
"#%15.3E") % 0.0);
2275 header.append(str(format(
"%16.3E") % (n*dR)));
2278 norm = 1.0 / (1.0*numReps);
2302 ( (lpath.
worm.
tail[0] % 2) == 0) ) {
2322 inline dVec OneBodyDensityMatrixEstimator::getRandomVector(
const double r) {
2326 if (random.rand() < 0.5)
2331 double theta = 2.0*M_PI*random.rand();
2332 rVec[0] = r*cos(theta);
2333 rVec[1] = r*sin(theta);
2336 double theta = 2.0*M_PI*random.rand();
2337 double phi = M_PI*random.rand();
2338 rVec[0] = r*cos(theta)*sin(phi);
2339 rVec[1] = r*sin(theta)*sin(phi);
2340 rVec[2] = r*cos(phi);
2343 if (random.rand() < 0.5)
2362 dVec OneBodyDensityMatrixEstimator::newStagingPosition(
const beadLocator &neighborIndex,
2363 const beadLocator &endIndex,
const int stageLength,
const int k) {
2366 double f1 = 1.0 * (stageLength - k - 1);
2367 double f2 = 1.0 / (1.0*(stageLength - k));
2368 double sqrtLambdaKTau = sqrt2LambdaTau * sqrt(f1 * f2);
2372 neighborPos = lpath(neighborIndex);
2373 newRanPos = lpath(endIndex) - neighborPos;
2376 newRanPos += neighborPos;
2379 for (
int i = 0; i <
NDIM; i++)
2380 newRanPos[i] = random.randNorm(newRanPos[i],sqrtLambdaKTau);
2395 void OneBodyDensityMatrixEstimator::accumulate() {
2397 oldTailPos = lpath(lpath.
worm.
tail);
2406 for (
int k = 0; k < (lpath.
worm.
gap-1); k++)
2413 for (
int p = 0; p < numReps; p++) {
2417 for (
int n = 0; n <
NOBDMSEP; n++) {
2423 newTailPos = oldTailPos + getRandomVector(n*dR);
2438 if (!all(beadIndex==lpath.
worm.
head) && !all(beadIndex==lpath.
worm.
tail)) {
2446 beadIndex = lpath.
next(beadIndex);
2447 }
while (!all(beadIndex==lpath.
next(lpath.
worm.
tail)));
2449 double expAction = exp(-newAction + oldAction + muShift);
2454 if (random.randExc() < rho0Norm*expAction)
2467 while (!all(beadIndex==lpath.
worm.
tail)) {
2480 (*outFilePtr) << format(
"# accepted: %16.8E attempted: %16.8E ratio: %16.4E\n")
2481 % (1.0*numAccepted) % (1.0*numAttempted) % (1.0*numAccepted/(1.0*numAttempted));
2498 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
2499 int _frequency,
string _label) :
2500 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
2509 header = str(format(
"#%15.3E") % 0.0);
2510 for (
int n = 1; n <
NPCFSEP; n++)
2511 header.append(str(format(
"%16.3E") % ((n)*dR)));
2526 for (
int n = 0; n <
NPCFSEP; n++)
2530 TinyVector<double,3> gNorm;
2532 gNorm[1] = 1.0/(M_PI);
2533 gNorm[2] = 3.0/(2.0*M_PI);
2535 for (
int n = 0; n <
NPCFSEP; n++) {
2536 dV = pow((n+1)*dR,
NDIM)-pow(n*dR,
NDIM);
2554 void PairCorrelationEstimator::accumulate() {
2556 double lnorm = 1.0*(numParticles-1)/(1.0*numParticles);
2557 if (numParticles > 1) {
2578 const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
2579 double _maxR,
int _frequency,
string _label) :
2580 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
2585 for (
int n = 0; n < numq; n++)
2596 header = str(format(
"#%15.6E") % 0.0);
2597 for (
int n = 1; n < numq; n++)
2598 header.append(str(format(
"%16.6E") % q(n)));
2616 void StaticStructureFactorEstimator::accumulate() {
2628 for (
int nq = 0; nq < numq; nq++) {
2632 for (
int slice = 0; slice < numTimeSlices; slice++) {
2634 bead1[0] = bead2[0] = slice;
2639 double lq1 = dot(lq,pos1);
2644 double lq2 = dot(lq,pos2);
2646 sf(nq) += cos(lq1)*cos(lq2) + sin(lq1)*sin(lq2);
2669 const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
2670 double _maxR,
int _frequency,
string _label) :
2671 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
2678 Array <double, 1> qMag(numq);
2680 qMag = 0.761,1.75,1.81;
2683 numqVecs.resize(numq);
2691 for (
int nq = 0; nq < numq; nq++)
2693 double cq = qMag(nq);
2694 vector <dVec> qvecs;
2697 int maxNumQ =
ipow(2*maxComp + 1,
NDIM);
2700 for (
int n = 0; n < maxNumQ; n++) {
2701 for (
int i = 0; i <
NDIM; i++) {
2703 for (
int j = i+1; j <
NDIM; j++)
2704 scale *= (2*maxComp + 1);
2705 qi[i] = (n/scale) % (2*maxComp + 1);
2708 qi[i] -= (qi[i] > maxComp)*(2*maxComp + 1);
2713 if (abs(dot(qd,qd)-cq*cq) < eps) {
2714 qvecs.push_back(qd);
2720 if (qvecs.size() < 1) {
2721 cerr <<
"\nERROR: Intermediate Scattering function: "
2722 <<
"No valid q-vectors were added to the list for measurment."
2723 << endl <<
"Action: modify q-magintudes." << endl;
2731 for (
int nq = 0; nq < numq; nq++)
2732 qMag(nq) = sqrt(dot(q[nq][0],q[nq][0]));
2736 isf.resize(numq*numTimeSlices);
2743 header = str(format(
"#%15.6E") % qMag(0));
2744 for (
int n = 1; n < numq; n++)
2745 header.append(str(format(
"%16.6E") % qMag(n)));
2749 header.append(str(format(
"#%15.6E") % 0.0));
2750 for (
int n = 1; n < numTimeSlices; n++)
2753 for (
int nq = 1; nq < numq; nq++) {
2754 for (
int n = 0; n < numTimeSlices; n++)
2759 norm = 1.0/numTimeSlices;
2774 void IntermediateScatteringFunctionEstimator::accumulate() {
2784 for (
int nq = 0; nq < numq; nq++) {
2787 for (
const auto &cqvec : q[nq]) {
2790 for (bead1[0] = 0; bead1[0] < numTimeSlices; bead1[0]++) {
2793 for (
int tausep = 0; tausep < numTimeSlices; tausep++){
2795 bead2[0] = (bead1[0] + tausep) % numTimeSlices;
2800 double lq1 = dot(cqvec,pos1);
2805 double lq2 = dot(cqvec,pos2);
2807 isf(nq*numTimeSlices + tausep) += (cos(lq1)*cos(lq2) + sin(lq1)*sin(lq2))/numqVecs(nq);
2830 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
2831 int _frequency,
string _label) :
2832 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
2841 header = str(format(
"#%15.3E") % 0.0);
2842 for (
int n = 1; n <
NRADSEP; n++)
2843 header.append(str(format(
"%16.3E") % ((n)*dR)));
2846 for (
int n = 0; n <
NRADSEP; n++)
2847 norm(n) /= (M_PI*(2*n+1)*dR*dR);
2859 void RadialDensityEstimator::accumulate() {
2866 beadIndex = slice,ptcl;
2867 pos =
path(beadIndex);
2869 for (
int i = 0; i <
NDIM-1; i++)
2870 rsq += pos[i]*pos[i];
2871 int k = int(sqrt(rsq)/dR);
2888 return (r[0]*r[0] + r[1]*r[1] < maxR*maxR);
2901 if (
include(path(0,ptcl),maxR))
2920 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
2921 int _frequency,
string _label) :
2922 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
2932 header = str(format(
"#%15s%16s%16s%16s%16s%16s%16s")
2933 %
"K" %
"V" %
"E" %
"E_mu" %
"K/N" %
"V/N" %
"E/N");
2949 void CylinderEnergyEstimator::accumulate() {
2962 double classicalKinetic = (0.5 *
NDIM /
constants()->
tau()) * numParticles;
2970 for (
int slice = 0; slice < numTimeSlices; slice++) {
2972 beadIndex = slice,ptcl;
2975 totK -= dot(vel,vel);
2988 for (
int slice = 0; slice < numTimeSlices; slice++) {
2990 t1 +=
actionPtr->derivPotentialActionLambda(slice,maxR);
2991 t2 +=
actionPtr->derivPotentialActionTau(slice,maxR);
2993 totV +=
actionPtr->potential(slice,maxR);
2998 t2 /= 1.0*numTimeSlices;
2999 totV /= (0.5 * numTimeSlices);
3002 totK += (classicalKinetic + t1);
3007 if (numParticles > 0) {
3014 estimator(4) += totK/(1.0*numParticles);
3015 estimator(5) += totV/(1.0*numParticles);
3016 estimator(6) += (totK + totV)/(1.0*numParticles);
3033 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3034 int _frequency,
string _label) :
3035 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3042 header = str(format(
"%16s%16s%16s") %
"N" %
"N^2" %
"density");
3054 void CylinderNumberParticlesEstimator::accumulate() {
3057 estimator(1) += 1.0*numParticles*numParticles;
3075 (
const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3076 int _frequency,
string _label) :
3077 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3081 maxNumParticles = 200;
3085 header = str(format(
"#%15d") % 0);
3086 for (
int n = 1; n < maxNumParticles; n++)
3087 header.append(str(format(
"%16d") % n));
3099 void CylinderNumberDistributionEstimator::accumulate() {
3103 if (index >= 0 && index < maxNumParticles)
3120 (
const Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3121 int _frequency,
string _label) :
3122 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3134 header = str(format(
"#%15.3E") % 0.0);
3135 for (
int n = 1; n <
NRADSEP; n++)
3136 header.append(str(format(
"%16.3E") % (n*dz)));
3151 void CylinderLinearDensityEstimator::accumulate() {
3158 beadIndex = slice,ptcl;
3159 pos =
path(beadIndex);
3164 int k = int((0.5*Lz + pos[
NDIM-1])/dz);
3187 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3188 int _frequency,
string _label) :
3189 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3200 header = str(format(
"#%15s%16s%16s%16s") %
"rho_s/rho" %
"W^2(x)" %
"W^2(y)" %
"W^2(z)");
3201 for (
int w = -windMax; w <= windMax; w++)
3202 header += str(format(
"%11sP(%+1d)") %
" " % w);
3221 void CylinderSuperfluidFractionEstimator::accumulate() {
3223 double locW2oN = 0.0;
3238 doBead.resize(numWorldlines);
3242 bool includeWorldline =
true;
3245 for (
int n = 0; n < numWorldlines; n++) {
3254 beadIndex = startBead;
3258 includeWorldline =
true;
3262 if (beadIndex[0]==0)
3263 doBead(beadIndex[1]) =
false;
3271 includeWorldline =
false;
3274 }
while (!all(beadIndex==startBead));
3276 if (includeWorldline)
3287 if (numParticles > 0)
3288 locW2oN = dot(W,W)/(1.0*numParticles);
3301 for (i = 0; i <
NDIM; i++)
3303 for (
int j = i; j < 3; j++)
3308 for (
int p = -windMax; p <= windMax; p++) {
3309 if (abs(W[
NDIM-1]-1.0*p) < 0.2)
3330 (
Path &_path,
ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3331 int _frequency,
string _label) :
3332 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label),
3345 header = str(format(
"#%15.3E") % 0.0);
3347 header.append(str(format(
"%16.3E") % (n*dR)));
3350 norm = 1.0 / (1.0*numReps);
3372 ( (lpath.
worm.
tail[0] % 2) == 0) ) {
3391 inline dVec CylinderOneBodyDensityMatrixEstimator::getRandomVector(
const double r) {
3394 if (random.rand() < 0.5)
3412 dVec CylinderOneBodyDensityMatrixEstimator::newStagingPosition(
const beadLocator &neighborIndex,
3413 const beadLocator &endIndex,
const int stageLength,
const int k) {
3416 double f1 = 1.0 * (stageLength - k - 1);
3417 double f2 = 1.0 / (1.0*(stageLength - k));
3418 double sqrtLambdaKTau = sqrt2LambdaTau * sqrt(f1 * f2);
3422 neighborPos = lpath(neighborIndex);
3423 newRanPos = lpath(endIndex) - neighborPos;
3426 newRanPos += neighborPos;
3429 for (
int i = 0; i <
NDIM; i++)
3430 newRanPos[i] = random.randNorm(newRanPos[i],sqrtLambdaKTau);
3445 void CylinderOneBodyDensityMatrixEstimator::accumulate() {
3447 oldTailPos = lpath(lpath.
worm.
tail);
3456 for (
int k = 0; k < (lpath.
worm.
gap-1); k++)
3463 for (
int p = 0; p < numReps; p++) {
3467 for (
int n = 0; n <
NOBDMSEP; n++) {
3473 newTailPos = oldTailPos + getRandomVector(n*dR);
3488 if (!all(beadIndex==lpath.
worm.
head) && !all(beadIndex==lpath.
worm.
tail)) {
3496 beadIndex = lpath.
next(beadIndex);
3497 }
while (!all(beadIndex==lpath.
next(lpath.
worm.
tail)));
3499 double expAction = exp(-newAction + oldAction + muShift);
3503 if (random.randExc() < expAction)
3516 while (!all(beadIndex==lpath.
worm.
tail)) {
3537 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3538 int _frequency,
string _label) :
3539 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3548 header = str(format(
"#%15.3E") % 0.0);
3549 for (
int n = 1; n <
NPCFSEP; n++)
3550 header.append(str(format(
"%16.3E") % ((n)*dR)));
3568 void CylinderPairCorrelationEstimator::accumulate() {
3572 lnorm /= 1.0*(N1D-1)/(1.0*N1D);
3606 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3607 int _frequency,
string _label) :
3608 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3620 header = str(format(
"#%15.3E") % 0.0);
3621 for (
int n = 1; n <
NRADSEP; n++)
3622 header.append(str(format(
"%16.3E") % ((n)*dz)));
3634 void CylinderLinearPotentialEstimator::accumulate() {
3644 for (
int n = 0; n <
NRADSEP; n++) {
3646 r1[
NDIM-1] = -0.5*Lz + n*dz;
3670 totV /= 1.0*numBeads;
3693 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
int _frequency,
string _label) :
3694 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3704 header = str(format(
"#%15.3E") % 0.0);
3705 for (
int n = 1; n <
NRADSEP; n++)
3706 header.append(str(format(
"%16.3E") % ((n)*dR)));
3719 void CylinderRadialPotentialEstimator::accumulate() {
3728 for (
int n = 0; n <
NRADSEP; n++) {
3732 double theta = 2.0*M_PI*random.rand();
3733 r1[0] = n*dR*cos(theta);
3734 r1[1] = n*dR*sin(theta);
3744 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
3768 void CylinderRadialPotentialEstimator::accumulate1() {
3778 found1 = found2 =
false;
3784 bead1[0] = bead2[0] = slice;
3789 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
3792 rad1 = r1[0]*r1[0] + r1[1]*r1[1];
3793 found1 = (rad1 < maxR*maxR);
3804 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
3807 rad2 = r2[0]*r2[0] + r2[1]*r2[1];
3808 found2 = (rad2 < maxR*maxR);
3818 nR = int(sqrt(rad1)/dR);
3825 radPot /= (1.0*numFound1);
3845 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3846 int _frequency,
string _label) :
3847 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3853 header = str(format(
"#%15f") % 0.0 );
3868 void PotentialEnergyEstimator::accumulate() {
3891 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3892 int _frequency,
string _label) :
3893 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3915 void KineticEnergyEstimator::accumulate() {
3925 double classicalKinetic = (0.5 *
NDIM /
constants()->
tau()) * numParticles;
3929 for (
int slice = 0; slice < (numTimeSlices-1); slice+=2) {
3931 for (
int eo = 0; eo < 2; eo++){
3933 beadIndex = slice+eo,ptcl;
3943 for (
int eo = 0; eo < 2; eo++){
3944 t1 +=
actionPtr->derivPotentialActionLambda(slice+eo);
3950 K += (classicalKinetic + t1);
3968 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
3969 int _frequency,
string _label) :
3970 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
3993 void TotalEnergyEstimator::accumulate() {
4003 double classicalKinetic = (0.5 *
NDIM /
constants()->
tau()) * numParticles;
4007 for (
int slice = 0; slice < (numTimeSlices-1); slice++) {
4010 beadIndex = slice,ptcl;
4018 K += (classicalKinetic);
4020 double dUdtau =
actionPtr->derivPotentialActionTau(slice);
4038 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
4039 int _frequency,
string _label):
4040 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
4062 void ThermoPotentialEnergyEstimator::accumulate() {
4066 for (
int slice = 0; slice < (numTimeSlices-1); slice++) {
4067 double dUdtau =
actionPtr->derivPotentialActionTau(slice);
4068 double dUdlam =
actionPtr->derivPotentialActionLambda(slice);
4085 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
4086 int _frequency,
string _label) :
4087 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
4094 header = str(format(
"#%15d") % 0);
4096 header.append(str(format(
"%16d") % n));
4109 void PositionEstimator::accumulate() {
4116 for (beadIndex[1] = 0; beadIndex[1] <
4118 x +=
path(beadIndex)[0];
4135 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
4136 int _frequency,
string _label) :
4137 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
4144 header = str(format(
"#%15d") % 0);
4145 header.append(str(format(
"%16d") % 0));
4147 header.append(str(format(
"%16d") % n));
4148 header.append(str(format(
"%16d") % n));
4162 void ParticleResolvedPositionEstimator::accumulate() {
4171 x =
path(beadIndex)[0];
4172 if ( beadIndex[1] <
constants()->initialNumParticles()){
4192 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
4193 int _frequency,
string _label) :
4194 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
4201 header = str(format(
"#%15d") % 1);
4203 header.append(str(format(
"%16d") % n));
4216 void ParticleCorrelationEstimator::accumulate() {
4222 beadIndex[0] = beadIndex0[0];
4250 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
4251 int _frequency,
string _label) :
4252 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
4259 header = str(format(
"#%15d") % 0);
4261 header.append(str(format(
"%16d") % n));
4274 void VelocityEstimator::accumulate() {
4288 estimator(beadIndex[0]) += sqrt(dot(vel,vel));
4305 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
4306 int _frequency,
string _label) :
4307 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label)
4314 header = str(format(
"#%15s") %
"Z");
4315 header.append(str(format(
"%16s") %
"pA"));
4316 header.append(str(format(
"%16s") %
"pB"));
4329 void SubregionOccupationEstimator::accumulate() {
4332 double rho0Mid,Z,pA,pB;
4353 cout <<
"Error!! Invalid configuration for SubregionOccupatoin!!" << endl;
4377 ActionBase *_actionPtr,
const MTRand &_random,
double _maxR,
4378 int _frequency,
string _label) :
4379 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label),
4393 header = str(format(
"#%15.3E") % 0.0);
4395 header.append(str(format(
"%16.3E") % (n*dR)));
4398 norm = 1.0 / (1.0*numReps);
4443 inline dVec PIGSOneBodyDensityMatrixEstimator::getRandomVector(
const double r) {
4447 if (random.rand() < 0.5)
4452 double theta = 2.0*M_PI*random.rand();
4453 rVec[0] = r*cos(theta);
4454 rVec[1] = r*sin(theta);
4457 double theta = 2.0*M_PI*random.rand();
4458 double phi = acos(2*random.rand() - 1.0);
4459 rVec[0] = r*sin(theta)*cos(phi);
4460 rVec[1] = r*sin(theta)*sin(phi);
4461 rVec[2] = r*cos(phi);
4464 if (random.rand() < 0.5)
4481 void PIGSOneBodyDensityMatrixEstimator::accumulate() {
4489 oldTailPos = lpath(beadIndexR);
4503 for (
int n = 0; n <
NOBDMSEP; n++) {
4509 newTailPos = oldTailPos + getRandomVector(n*dR);
4527 double expAction = exp(-0.5*newAction + 0.5*oldAction);
4533 if (random.randExc() < rho0*expAction)
4552 (*outFilePtr) << format(
"# accepted: %16.8E attempted: %16.8E ratio: %16.4E\n")
4553 % (1.0*numAccepted) % (1.0*numAttempted) % (1.0*numAccepted/(1.0*numAttempted));
4568 int _frequency,
string _label) :
4569 EstimatorBase(_path,_actionPtr,_random,_maxR,_frequency,_label), path2(_path2)
4590 ActionBase *_actionPtr2,
const MTRand &_random,
double _maxR,
4591 int _frequency,
string _label) :
4592 DoubledEstimator(_path,_path2,_actionPtr,_actionPtr2,_random,_maxR,_frequency,_label),
4593 lpath(_path),lpath2(_path2),
4594 actionPtr(_actionPtr),
4595 actionPtr2(_actionPtr2)
4599 header = str(format(
"#%15s%16s%16s") %
"Z" %
"S" %
"ZS");
4612 void SwapEstimator::accumulate() {
4622 void SwapEstimator::accumulateOpen() {
4626 beadLocator beadIndexL,beadIndexR,beadIndexL2,beadIndexR2;
4638 oldTailPos[i] = lpath(beadIndexR);
4642 oldTailPos2[i] = lpath2(beadIndexR2);
4646 double oldPotAction,oldPotAction2;
4647 double rho0Dir, rho0Dir2;
4656 oldPotAction2 = 0.0;
4667 for(
uint32 i=0; i<permutation.size(); i++)
4679 for(
uint32 i=0; i<permutation.size(); i++){
4682 rho0perm *= actionPtr->
rho0(beadIndexL,beadIndexR,1);
4684 rho0Dir += rho0perm;
4686 }
while (next_permutation(permutation.begin(),permutation.end()));
4687 rho0Dir *= 1.0/((double)Nperm);
4692 for(
uint32 i=0; i<permutation.size(); i++)
4703 for(
uint32 i=0; i<permutation.size(); i++){
4706 rho0perm *= actionPtr2->
rho0(beadIndexL2,beadIndexR2,1);
4708 rho0Dir2 += rho0perm;
4710 }
while (next_permutation(permutation.begin(),permutation.end()));
4711 rho0Dir2 *= 1.0/((double)Nperm);
4723 for(
uint32 i=0; i<oldTailPos2.size(); i++){
4727 for(
uint32 i=0; i<oldTailPos.size(); i++){
4729 lpath2.
updateBead(beadIndexR2,oldTailPos[i]);
4734 for(
uint32 i=0; i<permutation.size(); i++)
4737 double rho0Swap = 0.0;
4742 for(
uint32 i=0; i<permutation.size(); i++){
4745 rho0perm *= actionPtr->
rho0(beadIndexL,beadIndexR,1);
4747 rho0Swap += rho0perm;
4749 }
while (next_permutation(permutation.begin(),permutation.end()));
4750 rho0Swap*= 1.0/((double)Nperm);
4753 for(
uint32 i=0; i<permutation.size(); i++)
4756 double rho0Swap2 = 0.0;
4761 for(
uint32 i=0; i<permutation.size(); i++){
4764 rho0perm *= actionPtr2->
rho0(beadIndexL2,beadIndexR2,1);
4766 rho0Swap2 += rho0perm;
4768 }
while (next_permutation(permutation.begin(),permutation.end()));
4769 rho0Swap2*= 1.0/((double)Nperm);
4774 double newPotAction = 0.0;
4779 double newPotAction2 = 0.0;
4786 for(
uint32 i=0; i<oldTailPos.size(); i++){
4790 for(
uint32 i=0; i<oldTailPos2.size(); i++){
4792 lpath2.
updateBead(beadIndexR2,oldTailPos2[i]);
4794 S = rho0Swap*rho0Swap2*exp(-(0.5)*(newPotAction+newPotAction2)+(0.5)*(oldPotAction+oldPotAction2));
4795 Z = rho0Dir*rho0Dir2;
4799 Z = rho0Dir*rho0Dir2;
4815 void SwapEstimator::accumulateClosed() {
4822 beadLocator beadIndexL,beadIndexR,beadIndexL2,beadIndexR2;
4823 beadIndexL[0] = swapSlice;
4824 beadIndexR[0] = swapSlice+1;
4825 beadIndexL2[0] = swapSlice;
4826 beadIndexR2[0] = swapSlice+1;
4830 for (
int brokenBeadIndex1=0; brokenBeadIndex1<lpath.
getNumParticles(); brokenBeadIndex1++){
4832 beadIndexL[1] = brokenBeadIndex1;
4833 beadIndexR[1] = brokenBeadIndex1;
4836 dVec oldTailPos = lpath(beadIndexR);
4840 double rho0Dir = actionPtr->
rho0(beadIndexL,beadIndexR,1);
4842 for (
int brokenBeadIndex2=0; brokenBeadIndex2<lpath2.
getNumParticles(); brokenBeadIndex2++){
4844 beadIndexL2[1] = brokenBeadIndex2;
4845 beadIndexR2[1] = brokenBeadIndex2;
4848 dVec oldTailPos2 = lpath2(beadIndexR2);
4852 double rho0Dir2 = actionPtr2->
rho0(beadIndexL2,beadIndexR2,1);
4859 double rho0Swap = actionPtr->
rho0(beadIndexL,beadIndexR,1);
4860 double rho0Swap2 = actionPtr2->
rho0(beadIndexL2,beadIndexR2,1);
4870 S += (rho0Swap*rho0Swap2/(rho0Dir*rho0Dir2))*exp(-(0.5)*(newPotAction+newPotAction2)+(0.5)*(oldPotAction+oldPotAction2));
4891 const MTRand &_random,
double _maxR,
4892 int _frequency,
string _label) :
4893 DoubledEstimator(_path,_path2,_actionPtr, _actionPtr2,_random,_maxR,_frequency,_label),
4894 lpath(_path),lpath2(_path2),
4895 actionPtr(_actionPtr),
4896 actionPtr2(_actionPtr2)
4898 stringstream headerSS;
4901 header = str(format(
"#%15s") %
"Z" );
4904 headerSS <<
'Z' << n;
4905 header.append(str(format(
"%16s") % headerSS.str().c_str()));
4907 headerSS <<
'S' << n;
4908 header.append(str(format(
"%16s") % headerSS.str().c_str()));
4922 void EntPartEstimator::accumulate() {
4925 bool nMatch =
false;
4928 beadLocator beadIndexL,beadIndexR,beadIndexL2,beadIndexR2;
4940 oldTailPos[i] = lpath(beadIndexR);
4944 oldTailPos2[i] = lpath2(beadIndexR2);
4948 double oldPotAction,oldPotAction2;
4949 double rho0Dir, rho0Dir2;
4958 oldPotAction2 = 0.0;
4969 for(
uint32 i=0; i<permutation.size(); i++)
4981 for(
uint32 i=0; i<permutation.size(); i++){
4984 rho0perm *= actionPtr->
rho0(beadIndexL,beadIndexR,1);
4986 rho0Dir += rho0perm;
4988 }
while (next_permutation(permutation.begin(),permutation.end()));
4989 rho0Dir *= 1.0/((double)Nperm);
4994 for(
uint32 i=0; i<permutation.size(); i++)
5005 for(
uint32 i=0; i<permutation.size(); i++){
5009 rho0perm *= actionPtr2->
rho0(beadIndexL2,beadIndexR2,1);
5011 rho0Dir2 += rho0perm;
5013 }
while (next_permutation(permutation.begin(),permutation.end()));
5014 rho0Dir2 *= 1.0/((double)Nperm);
5026 for(
uint32 i=0; i<oldTailPos2.size(); i++){
5030 for(
uint32 i=0; i<oldTailPos.size(); i++){
5032 lpath2.
updateBead(beadIndexR2,oldTailPos[i]);
5037 for(
uint32 i=0; i<permutation.size(); i++)
5040 double rho0Swap = 0.0;
5045 for(
uint32 i=0; i<permutation.size(); i++){
5048 rho0perm *= actionPtr->
rho0(beadIndexL,beadIndexR,1);
5050 rho0Swap += rho0perm;
5052 }
while (next_permutation(permutation.begin(),permutation.end()));
5053 rho0Swap*= 1.0/((double)Nperm);
5056 for(
uint32 i=0; i<permutation.size(); i++)
5059 double rho0Swap2 = 0.0;
5064 for(
uint32 i=0; i<permutation.size(); i++){
5067 rho0perm *= actionPtr2->
rho0(beadIndexL2,beadIndexR2,1);
5069 rho0Swap2 += rho0perm;
5071 }
while (next_permutation(permutation.begin(),permutation.end()));
5072 rho0Swap2*= 1.0/((double)Nperm);
5077 double newPotAction = 0.0;
5082 double newPotAction2 = 0.0;
5089 for(
uint32 i=0; i<oldTailPos.size(); i++){
5093 for(
uint32 i=0; i<oldTailPos2.size(); i++){
5095 lpath2.
updateBead(beadIndexR2,oldTailPos2[i]);
5097 S = rho0Swap*rho0Swap2*exp(-(0.5)*(newPotAction+newPotAction2)+(0.5)*(oldPotAction+oldPotAction2));
5098 Z = rho0Dir*rho0Dir2;
5101 if( nBin <
constants()->initialNumParticles() )
5106 Z = rho0Dir*rho0Dir2;
Action class definitions.
Holds a base class that all action classes will be derived from.
const bool local
Is the action local in imaginary time?
Array< int, 1 > cylSepHist
A histogram of separations for a cylinder.
virtual double potentialAction()
The effective potential inter-ACTION for various pass conditions.
Array< int, 1 > sepHist
A histogram of separations.
PotentialBase * interactionPtr
The interaction potential.
PotentialBase * externalPtr
The external potential.
double rho0(const dVec &, const dVec &, int)
The free-particle density matrix.
Compute density inside film and in bulk separately for Excluded volume potentials.
~BipartitionDensityEstimator()
Destructor.
BipartitionDensityEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="bipart_dens")
Constructor.
File * file(string type)
Get method returning file object.
int numTimeSlices()
Get number of time slices.
double T() const
Get temperature.
double mu() const
Get chemical potential.
double lambda() const
Get lambda = hbar^2/(2mk_B)
double V() const
Get cell volume.
int virialWindow() const
Get centroid virial window size.
double tau() const
Get imaginary time step.
double fourLambdaTauInv() const
Get (4lambda/tau)^{-1}.
bool canonical() const
Get ensemble.
int initialNumParticles()
Get initial number of particles.
bool restart() const
Get restart state.
dVec gridSize
The grid size in each dimension.
double volume
The volume of the container in A^3.
int numGrid
The number of grid boxes for the position grid.
dVec sideInv
The inverse box dimensions.
TinyVector< unsigned int, NDIM > periodic
Determines which dimensions have periodic bc.
virtual double gridBoxVolume(const int) const =0
The physical size of a NDIM-dimensional grid box.
string name
The name of the container.
void putInBC(dVec &r) const
Place a vector in boundary conditions.
virtual int gridIndex(const dVec &) const =0
Map a position into a grid index.
virtual void putInside(dVec &) const =0
Place a vector inside the simulation cell.
dVec side
The linear dimensions of the box.
Computes the total energy via the thermodynamic estimator.
CylinderEnergyEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="cyl_estimator")
Constructor.
~CylinderEnergyEstimator()
Destructor.
Computes the density as a function of distance along the cylinder axis.
CylinderLinearDensityEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="cyl_linedensity")
Constructor.
~CylinderLinearDensityEstimator()
Destructor.
Compute the effective linear potential along the axis of the cylinder.
~CylinderLinearPotentialEstimator()
Destructor.
CylinderLinearPotentialEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="cyl_linepotential")
Constructor.
Computes the probability distribution function for the number of particles.
~CylinderNumberDistributionEstimator()
Destructor.
CylinderNumberDistributionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="cyl_number")
Constructor.
Computes the average number of particles, as well as density.
~CylinderNumberParticlesEstimator()
Destructor.
CylinderNumberParticlesEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="cyl_estimator")
Constructor.
Compute the one body density matrix n(r) which can be used to find the momentum distribution function...
~CylinderOneBodyDensityMatrixEstimator()
Destructor.
CylinderOneBodyDensityMatrixEstimator(Path &, ActionBase *, const MTRand &, double, int _frequency=20, string _label="cyl_obdm")
Constructor.
void sample()
Sample the OBDM.
Compute the two-body pair-correlation function, g(r) ~ <rho(r)rho(0)>.
~CylinderPairCorrelationEstimator()
Destructor.
void sample()
Sample the estimator.
CylinderPairCorrelationEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="cyl_pair")
Constructor.
Compute the effective radial potential in a cylinder.
CylinderRadialPotentialEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="cyl_potential")
Constructor.
~CylinderRadialPotentialEstimator()
Destructor.
Compute the superfluid fraction, as well as the winding number probability distribution.
~CylinderSuperfluidFractionEstimator()
Destructor.
CylinderSuperfluidFractionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="cyl_super")
Constructor.
Compute the fraction of time we spend in the diagonal ensemble.
void sample()
Overload sampling to make sure it is always done, regardless of ensemble.
~DiagonalFractionEstimator()
Destructor.
DiagonalFractionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="estimator")
Constructor.
Base class for estimators that use two paths.
~DoubledEstimator()
Destructor.
DoubledEstimator(const Path &, const Path &, ActionBase *, ActionBase *, const MTRand &, double, int _frequency=1, string _label="")
Constructor.
Computes the total energy via the thermodynamic estimator.
EnergyEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="estimator")
Constructor.
~EnergyEstimator()
Destructor.
Computes the Swap Estimator between two paths.
EntPartEstimator(Path &, Path &, ActionBase *, ActionBase *, const MTRand &, double, int _frequency=1, string _label="entpart")
Constructor.
~EntPartEstimator()
Destructor.
The base class that all estimator classes will be derived from.
virtual void outputFlat()
Output a flat estimator value to disk.
int endSlice
Where imaginary time averages end.
bool diagonal
Is this a diagonal estimator?
void reset()
Reset numAccumulated and the estimator to 0.
Array< double, 1 > estimator
The estimator array.
ActionBase * actionPtr
A pointer to the action.
virtual ~EstimatorBase()
Destructor.
Array< double, 1 > norm
The normalization factor for each estimator.
bool canonical
Are we in the canonical ensemble?
int endDiagSlice
Where imaginary time averages end for diagonal estimiators.
virtual void output()
Output the estimator value to disk.
vector< double > sliceFactor
Used to properly incorporate end affects.
void restart(const uint32, const uint32)
Restart the measurment process from a previous state.
void prepare()
Prepare the estimator for i/o.
string header
The data file header.
bool endLine
Should we output a carriage return?
int numEst
The number of individual quantities measured.
int startSlice
Where imaginary time averages begin.
int frequency
The frequency at which we accumulate.
void appendLabel(string append)
Append to default label.
map< string, int > estIndex
Map estimator labels to indices.
uint32 totNumAccumulated
The total number of accumulated values.
virtual void sample()
Sample the estimator.
EstimatorBase(const Path &_path, ActionBase *_actionPtr, const MTRand &_random, double _maxR, int _frequency=1, string _label="")
Constructor.
uint32 numSampled
The number of times we have sampled.
virtual void accumulate()
Accumulate the estimator.
uint32 numAccumulated
The number of accumulated values.
bool baseSample()
Determine the basic sampling condition.
const Path & path
A constant reference to the paths.
int numBeads0
The target number of beads for the canonical ensemble.
fstream * outFilePtr
The output fie.
void initialize(int)
Initialize estimator.
string label
The label used for the output file.
void reset()
Reset a file.
void rename()
Rename a file.
bool exists()
did the file exist before opening?
Computes the total energy using a mixed estimator.
KineticEnergyEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="kinetic")
Constructor.
~KineticEnergyEstimator()
Destructor.
Create a 1d histogram of particle positions in the z-direction.
~LinearParticlePositionEstimator()
Destructor.
LinearParticlePositionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="lineardensity")
Constructor.
Particle permutation number density histogram.
LocalPermutationEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="locperm")
Constructor.
~LocalPermutationEstimator()
Destructor.
Compute the local superfluid density.
LocalSuperfluidDensityEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="locsuper")
Constructor.
~LocalSuperfluidDensityEstimator()
Destructor.
void output()
overload the output
Computes the probability distribution function for the number of particles.
~NumberDistributionEstimator()
Destructor.
NumberDistributionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="number")
Constructor.
Computes the average number of particles, as well as density.
NumberParticlesEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="estimator")
Constructor.
~NumberParticlesEstimator()
Destructor.
Compute the one body density matrix n(r) which can be used to find the momentum distribution function...
void outputFooter()
For the one body density matrix estimator, we would like to output the acceptance information for the...
OneBodyDensityMatrixEstimator(Path &, ActionBase *, const MTRand &, double, int _frequency=20, string _label="obdm")
Constructor.
~OneBodyDensityMatrixEstimator()
Destructor.
void sample()
Sample the OBDM.
Compute the one body density matrix n(r) which can be used to find the momentum distribution function...
void outputFooter()
For the one body density matrix estimator, we would like to output the acceptance information for the...
~PIGSOneBodyDensityMatrixEstimator()
Destructor.
PIGSOneBodyDensityMatrixEstimator(Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="obdm")
Constructor.
void sample()
Sample the OBDM.
Compute the two-body pair-correlation function, g(r) ~ <rho(r)rho(0)>.
PairCorrelationEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="pair")
Constructor.
~PairCorrelationEstimator()
Destructor.
Computes the average position of each particle in 1D at the center time slice.
~ParticleCorrelationEstimator()
Destructor.
ParticleCorrelationEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="prcorrelation")
Constructor.
Create histogram of particle positions.
ParticlePositionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="position")
Constructor.
~ParticlePositionEstimator()
Destructor.
Computes the average position of each particle in 1D at the center time slice.
ParticleResolvedPositionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="prposition")
Constructor.
~ParticleResolvedPositionEstimator()
Destructor.
The space-time trajectories.
bool inSubregionA(const beadLocator &) const
Checks to see if bead is in subregion A/B at break slice + 1.
int getNumParticles() const
Get the size of the worldline array.
beadLocator delBeadGetNext(const beadLocator &)
Delete a bead and move forwards.
dVec getVelocity(const beadLocator &) const
Return the velocity between two time slices of a given particle as a ndim-vector.
vector< int > brokenWorldlinesR
A list of particles with broken worldlines on right of break.
dVec getSeparation(const beadLocator &, const beadLocator &) const
Return the separation vector between two particles in the same timeslice.
vector< int > brokenWorldlinesL
A list of particles with broken worldlines on left of break.
const int numTimeSlices
A local constant copy of the number of time slices.
Array< int, 1 > numBeadsAtSlice
The number of active beads at a given time slice.
int breakSlice
The location of the break in the path (0=>no break)
bool inSubregionB(const beadLocator &) const
Check if bead is in subregion B.
void updateBead(const beadLocator &, const dVec &)
Update the position of a bead in the worldine configuration.
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.
beadLocator addNextBead(const beadLocator &, const dVec &)
Add a bead at the next time slice.
int getTrueNumParticles() const
The number of active particles.
Computes the particle permutation cycle probability distribution.
~PermutationCycleEstimator()
Destructor.
PermutationCycleEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="pcycle")
Constructor.
Compute the radially averaged local superfluid density.
~PlaneAreaSuperfluidDensityEstimator()
Destructor.
PlaneAreaSuperfluidDensityEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="planearea")
Constructor.
Create a 2d histogram of particle positions but only store the average.
PlaneAverageExternalPotentialEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="planeaveVext")
Constructor.
void output()
Output a flat estimator value to disk.
~PlaneAverageExternalPotentialEstimator()
Destructor.
Create a 2d histogram of particle positions but only store the average.
~PlaneParticleAveragePositionEstimator()
Destructor.
PlaneParticleAveragePositionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="planeavedensity")
Constructor.
Create a 2d histogram of particle positions.
PlaneParticlePositionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="planedensity")
Constructor.
~PlaneParticlePositionEstimator()
Destructor.
Compute the radially averaged local superfluid density.
PlaneWindingSuperfluidDensityEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="planewind")
Constructor.
~PlaneWindingSuperfluidDensityEstimator()
Destructor.
Computes the average value of the position in 1D.
~PositionEstimator()
Destructor.
PositionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="position")
Constructor.
double tailV
Tail correction factor.
virtual Array< double, 1 > getExcLen()
Array to hold data elements.
virtual double V(const dVec &)
The potential.
Computes the potential energy along the worldline.
PotentialEnergyEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="potential")
Constructor.
~PotentialEnergyEstimator()
Destructor.
Compute the radially averaged local superfluid density.
RadialAreaSuperfluidDensityEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="radarea")
Constructor.
~RadialAreaSuperfluidDensityEstimator()
Destructor.
Compute the density as a function of position in the radial direction.
~RadialDensityEstimator()
Destructor.
RadialDensityEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="radial")
Constructor.
Compute the radially averaged local superfluid density.
~RadialWindingSuperfluidDensityEstimator()
Destructor.
RadialWindingSuperfluidDensityEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="radwind")
Constructor.
Compute the static structure factor S(q)
StaticStructureFactorEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="ssf")
Constructor.
~StaticStructureFactorEstimator()
Destructor.
Computes the imaginary time resolved "velocity" for the first particle .
~SubregionOccupationEstimator()
Destructor.
SubregionOccupationEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="subregionocc")
Constructor.
Compute the superfluid fraction, as well as the winding number probability distribution.
SuperfluidFractionEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="super")
Constructor.
~SuperfluidFractionEstimator()
Destructor.
Computes the Swap Estimator between two paths.
SwapEstimator(Path &, Path &, ActionBase *, ActionBase *, const MTRand &, double, int _frequency=1, string _label="swap")
Constructor.
~SwapEstimator()
Destructor.
Computes the total energy using a mixed estimator.
~ThermoPotentialEnergyEstimator()
Destructor.
ThermoPotentialEnergyEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="thpotential")
Constructor.
An estimator which tracks the ammount of time between bins, summing them into a total at the end.
void sample()
Overload sampling to make sure it is always done, regardless of ensemble.
TimeEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="estimator")
Constructor.
void output()
Grab the final time and write to disk.
Computes the total energy using a mixed estimator.
~TotalEnergyEstimator()
Destructor.
TotalEnergyEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="energy")
Constructor.
Computes the imaginary time resolved "velocity" for the first particle .
~VelocityEstimator()
Destructor.
VelocityEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="velocity")
Constructor.
Computes the total energy via the thermodynamic estimator.
VirialEnergyEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="virial")
Constructor.
~VirialEnergyEstimator()
Destructor.
Compute various properties related to the worm in the simulation.
WormPropertiesEstimator(const Path &, ActionBase *, const MTRand &, double, int _frequency=1, string _label="worm")
Constructor.
~WormPropertiesEstimator()
Destructor.
bool isConfigDiagonal
Stores the diagonality of the configuration.
int gap
numTimeSlices - length
beadLocator tail
The coordinates of the worm tail.
dVec sep
The spatial separation between head and tail.
beadLocator head
The coordinates of the worm head.
int getNumBeadsOn() const
Return the number of active beads.
int length
The length of the worm.
Ttype & max(Ttype &x, Ttype &y)
Maximum of two inputs.
#define NOBDMSEP
Spatial separations to be used in the one body density matrix.
#define NDIM
Number of spatial dimnsions.
int ipow(int base, int power)
Return the integer value of a number raised to a power.
unsigned long uint32
Unsigned integer type, at least 32 bits.
#define NRADSEP
Spatial separations to be used in the radial density.
TinyVector< int, 2 > beadLocator
time-slice,bead-number world line index
#define EPS
A small number.
#define NPCFSEP
Spatial separations to be used in the pair correlation function.
#define NGRIDSEP
Spatial separations to be used in each dimension of the particle position grid.
Ttype & min(Ttype &x, Ttype &y)
Minimum of two inputs.
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
TinyVector< int, NDIM > iVec
A NDIM-vector of type integer.
#define XXX
Used to refer to a nonsense beadIndex.
Class definitions for all file input/output.
Communicator * communicate()
Global public access to the communcator singleton.
ConstantParameters * constants()
Global public access to the constants.
REGISTER_ESTIMATOR("energy", EnergyEstimator)
Estimator naming conventions:
EstimatorFactory estimatorFactory
Setup the estimator factory.
int num1DParticles(const Path &path, double maxR)
Count the number of particles inside a given radius.
bool include(const dVec &r, double maxR)
Determine if a position is inside the cutoff radius.
MultiEstimatorFactory multiEstimatorFactory
Setup the estimator factory for multi path estimators.
Estimator class definitions.
Factory class definitions.
All possible potential classes.