26 double _endFactor,
int _period) :
29 externalPtr(_externalPtr),
30 interactionPtr(_interactionPtr),
34 waveFunctionPtr(_waveFunctionPtr),
74 int nR = int(sqrt(dot(psep,psep))/dSep);
125 if ( window || gaussianEnsemble ){
127 int numBeadsP = numBeads + deltaNumBeads;
132 if ( ( numBeadsP > (
numBeads0+beadWindowWidth) )||
133 (numBeadsP < (
numBeads0-beadWindowWidth)) )
137 if (gaussianEnsemble){
140 (2.0*sigmaBeads*sigmaBeads);
142 (2.0*sigmaBeads*sigmaBeads);
166 totK += dot(vel,vel);
168 totK += dot(vel,vel);
191 for (
int n = 0; n < wlLength; n++) {
193 totK += dot(vel, vel);
216 beadIndex = slice,ptcl;
242 beadIndex = startBead;
246 }
while (!all(beadIndex==
path.
next(endBead)));
262 const TinyVector<double,2> & _gradVFactor,
bool _local,
string _name,
263 double _endFactor,
int _period) :
264 ActionBase(_path,_lookup,_externalPtr,_interactionPtr,_waveFunctionPtr,
265 _local,_name,_endFactor,_period),
267 gradVFactor(_gradVFactor)
324 eo = (beadIndex[0] % 2);
337 if ( (beadIndex[0] == 0) || (beadIndex[0] == (
constants()->numTimeSlices()-1)) ) {
343 return (bareU + corU);
358 if ( (beadIndex[0] == 0) || (beadIndex[0]== (
constants()->numTimeSlices()-1)) ) {
374 eo = (beadIndex[0] % 2);
404 beadIndex = startBead;
408 }
while (!all(beadIndex==
path.
next(endBead)));
543 double totVint = 0.0;
549 if ( bead2[1] != bead1[1] ) {
559 return ( totVext + totVint );
575 double totVint = 0.0;
576 double totVext = 0.0;
579 bead1[0] = bead2[0] = slice;
588 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
598 for (bead2[1] = bead1[1]+1; bead2[1] < numParticles; bead2[1]++) {
607 return TinyVector<double,2>(totVext,totVint);
621 double totVint = 0.0;
622 double totVext = 0.0;
628 bead1[0] = bead2[0] = slice;
637 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
642 for (
int i = 0; i <
NDIM-1; i++)
645 if (r1sq < maxR*maxR) {
652 for (bead2[1] = bead1[1]+1; bead2[1] < numParticles; bead2[1]++) {
656 for (
int i = 0; i <
NDIM-1; i++)
660 if (r2sq < maxR*maxR) {
661 int nR = int(abs(sep[2])/dSep);
671 return ( totVext + totVint );
682 double totVint = 0.0;
683 double totVext = 0.0;
703 return ( totVext + totVint );
718 double totVint = 0.0;
719 double totVext = 0.0;
721 iVec gIndex,nngIndex;
722 TinyVector<int,NDIM+1> nnIndex;
723 TinyVector<int,NDIM+2> hI1,hI2;
732 doParticles(bead1[1]) =
false;
747 if (doParticles(bead2[1])) {
755 return ( totVext + totVint );
769 bead2[0] = bead3[0] = bead1[0];
773 dVec Fint1,Fint2,Fint3;
783 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
785 if (!all(bead1==bead2)) {
795 for (bead3[1] = 0; bead3[1] < numParticles; bead3[1]++) {
796 if ( !all(bead3==bead2) && !all(bead3==bead1) ) {
802 totF2 += dot(Fint2,Fint2) + 2.0*dot(Fext2,Fint2) + 2.0*dot(Fint2,Fint3);
808 totF2 += dot(Fext1,Fext1) + 2.0 * dot(Fext1,Fint1) + dot(Fint1,Fint1);
829 bead1[0] = bead2[0] = slice;
834 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
838 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
841 if (!all(bead1==bead2)) {
872 bead1[0] = bead2[0] = slice;
879 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
883 for (
int i = 0; i <
NDIM-1; i++)
886 if (r1sq < maxR*maxR) {
890 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
892 if (!all(bead1==bead2)) {
926 dVec Fint1,Fint2,Fint3;
937 if ( !all(bead1 == bead2) ) {
952 if ( !all(bead3==bead2) && !all(bead3==bead1) ) {
959 totF2 += dot(Fint2,Fint2) + 2.0*dot(Fext2,Fint2) + 2.0*dot(Fint2,Fint3);
965 totF2 += dot(Fext1,Fext1) + 2.0 * dot(Fext1,Fint1) + dot(Fint1,Fint1);
984 bead1[0] = bead2[0] = slice;
989 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
992 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
995 if (!all(bead1==bead2)) {
1028 bead1[0] = bead2[0] = slice;
1030 for (
int a=0; a<
NDIM; a++){
1031 for (
int b=0; b<
NDIM; b++){
1034 for (bead1[1]=0; bead1[1]<numParticles; bead1[1]++){
1037 for (bead2[1]=0; bead2[1]<numParticles; bead2[1]++){
1040 if (!all(bead1==bead2)) {
1043 rmag = sqrt(dot(rDiff,rDiff));
1051 tMat(a,b) += rDiff(a)*rDiff(b)*d2V/(rmag*rmag);
1053 tMat(a,b) -= (rDiff(a)*rDiff(b)/pow(rmag,3))*dV;
1055 tMat(a,b) += (1.0/rmag - rDiff(a)*rDiff(b)/pow(rmag,3))*dV;
1086 bead1[0] = bead2[0] = slice;
1089 double rDotgV = 0.0;
1092 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
1096 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
1099 if (!all(bead1==bead2)) {
1109 rDotgV += dot(gV,
path(bead1));
1133 bead1[0] = bead2[0] = slice;
1135 dVec gVi, gVe, gV, g2V;
1151 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
1159 dVe = sqrt(dot(gVe,gVe));
1166 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
1170 rmag = sqrt(dot(rDiff,rDiff));
1173 if (!all(bead1==bead2)) {
1177 dVi = sqrt(dot(gVi,gVi));
1185 for (
int a=0; a<
NDIM; a++){
1186 for (
int b=0; b<
NDIM; b++){
1187 tMat(a,b) += rDiff(a)*rDiff(b)*d2V/(rmag*rmag)
1188 - rDiff(a)*rDiff(b)*dV/pow(rmag,3);
1190 tMat(a,b) += dV/rmag;
1202 for(
int j=0; j<
NDIM; j++){
1203 for(
int i=0; i<
NDIM; i++){
1204 gVdotT(j) += gV(i)*tMat(j,i);
1207 term2 += dot(gVdotT,
path(bead1));
1235 beadLocator bead1, beadNext, beadPrev, beadNextOld, beadPrevOld;
1236 bead1[0] = bead2[0] = slice;
1238 dVec gVi, gVe, gV, delta;
1239 double rDotgV = 0.0;
1242 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
1249 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
1252 if (!all(bead1==bead2)) {
1264 dVec runTotMore = 0.0;
1265 dVec runTotLess = 0.0;
1268 beadNextOld = bead1;
1269 beadPrevOld = bead1;
1270 for (
int gamma = 0; gamma < virialWindow; gamma++) {
1272 beadNext =
path.
next(bead1, gamma);
1273 beadPrev =
path.
prev(bead1, gamma);
1279 COM += (pos1 + runTotMore) + (pos1 + runTotLess);
1281 beadNextOld = beadNext;
1282 beadPrevOld = beadPrev;
1284 COM /= (2.0*virialWindow);
1291 rDotgV += dot(gV, delta);
1314 beadLocator bead1, beadNext, beadPrev, beadNextOld, beadPrevOld;
1315 bead1[0] = bead2[0] = slice;
1317 dVec gVi, gVe, gV, g2V, delta;
1333 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
1342 dVe = sqrt(dot(gVe,gVe));
1349 for (bead2[1] = 0; bead2[1] < numParticles; bead2[1]++) {
1353 rmag = sqrt(dot(rDiff,rDiff));
1356 if (!all(bead1==bead2)) {
1360 dVi = sqrt(dot(gVi,gVi));
1368 for (
int a=0; a<
NDIM; a++){
1369 for (
int b=0; b<
NDIM; b++){
1370 tMat(a,b) += rDiff(a)*rDiff(b)*d2V/(rmag*rmag)
1371 - rDiff(a)*rDiff(b)*dV/pow(rmag,3);
1373 tMat(a,b) += dV/rmag;
1385 for(
int j=0; j<
NDIM; j++){
1386 for(
int i=0; i<
NDIM; i++){
1387 gVdotT(j) += gV(i)*tMat(j,i);
1393 dVec runTotMore = 0.0;
1394 dVec runTotLess = 0.0;
1397 beadNextOld = bead1;
1398 beadPrevOld = bead1;
1399 for (
int gamma = 0; gamma < virialWindow; gamma++) {
1401 beadNext =
path.
next(bead1, gamma);
1402 beadPrev =
path.
prev(bead1, gamma);
1408 COM += (pos1 + runTotMore) + (pos1 + runTotLess);
1410 beadNextOld = beadNext;
1411 beadPrevOld = beadPrev;
1413 COM /= (2.0*virialWindow);
1418 term2 += dot(gVdotT, delta);
1472 for(
int j=0; j<
NDIM; j++){
1473 for(
int i=0; i<
NDIM; i++){
1474 gU2(i) += gV(j)*tM(i,j);
1495 ActionBase(_path,_lookup,_externalPtr,_interactionPtr,_waveFunctionPtr,
1498 NNbead.resize(
constants()->initialNumParticles(),
false);
1518 totU += sum(
U(slice));
1544 if ( (bead1[0] == 0) || (bead1[0] == (
constants()->numTimeSlices()-1)) )
1560 NNbead[bead2[1]] =
true;
1567 if(!all(bead2==
XXX))
1568 NNbead[bead2[1]] =
true;
1571 bead2[0] = bead1[0];
1573 if(NNbead[bead2[1]]){
1578 NNbead[bead2[1]] =
false;
1582 double totUext =
tau()*totVext/(2.0);
1610 return (totU + totUext);
1621 double totUint = 0.0;
1622 double totUext = 0.0;
1625 bead1[0] = bead2[0] = slice;
1636 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
1641 for (bead2[1] = bead1[1]+1; bead2[1] < numParticles; bead2[1]++) {
1652 return TinyVector<double,2>(totUext,totUint);
1669 bead1[0] = bead2[0] = slice;
1680 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
1685 for (bead2[1] = bead1[1]+1; bead2[1] < numParticles; bead2[1]++) {
1714 bead1[0] = bead2[0] = slice;
1722 for (bead1[1] = 0; bead1[1] < numParticles; bead1[1]++) {
1727 for (bead2[1] = bead1[1]+1; bead2[1] < numParticles; bead2[1]++) {
Action class definitions.
Holds a base class that all action classes will be derived from.
WaveFunctionBase * waveFunctionPtr
A pointer to a trial wave function object.
Array< int, 1 > cylSepHist
A histogram of separations for a cylinder.
virtual double potentialAction()
The effective potential inter-ACTION for various pass conditions.
ActionBase(const Path &, LookupTable &, PotentialBase *, PotentialBase *, WaveFunctionBase *, bool _local=true, string _name="Base", double _endFactor=1.0, int _period=1)
Setup the path data members and canonical re-weighting factors.
double endFactor
Mutiplictive factor of the potential action on ends.
Array< int, 1 > sepHist
A histogram of separations.
int numBeads0
The target number of beads.
PotentialBase * interactionPtr
The interaction potential.
bool canonical
Are we in the canonical ensemble?
LookupTable & lookup
We need a non-constant reference for updates.
double tau()
The local shifted value of tau.
PotentialBase * externalPtr
The external potential.
double ensembleWeight(const int)
The ensemble particle number weighting factor.
double kineticAction()
The full kinetic Action
virtual ~ActionBase()
Empty base constructor.
void updateSepHist(const dVec &)
Update the separation histogram.
int shift
The scaling factor for tau.
const Path & path
A reference to the paths.
double rho0(const dVec &, const dVec &, int)
The free-particle density matrix.
int windowWidth() const
Get window 1/2 width.
int numTimeSlices()
Get number of time slices.
double lambda() const
Get lambda = hbar^2/(2mk_B)
bool window() const
Get window on/off.
double gaussianEnsembleSD() const
Get enesemble weight standard dev.
int virialWindow() const
Get centroid virial window size.
bool canonical() const
Get ensemble.
bool gaussianEnsemble() const
Get enesemble weight on/off.
int initialNumParticles()
Get initial number of particles.
TinyVector< unsigned int, NDIM > periodic
Determines which dimensions have periodic bc.
void putInBC(dVec &r) const
Place a vector in boundary conditions.
dVec side
The linear dimensions of the box.
double potentialAction()
Return the potential action for all time slices and all particles.
double deltadotgradUterm1(const int)
Return the sum over particles at a given time slice of the gradient of the action potential for a sin...
double potentialActionCorrection(const beadLocator &)
Return the potential action correction for a single bead.
virtual ~LocalAction()
Empty base constructor.
double rDOTgradUterm2(int)
Return the sum over particles at a given time slice of the gradient of the action potential for a sin...
double secondderivPotentialActionTau(int)
The second derivative of the potential action wrt tau on all links starting on slice.
dMat tMatrix(const int)
Returns the T-matrix needed to compute gradU.
double gradVSquared(const beadLocator &)
Return the gradient of the full potential squared for a single bead.
double virialKinCorrection(const int)
Returns the value of the virial kinetic energy correction term.
double derivPotentialActionLambda(int)
The derivative of the potential action wrt lambda for all links starting on slice.
double rDOTgradUterm1(int)
Return the sum over particles at a given time slice of the gradient of the action potential for a sin...
TinyVector< double, 2 > VFactor
The even/odd slice potential factor.
dVec gradU(const int)
Returns the value of the gradient of the potential action for all beads at a given time slice.
TinyVector< double, 2 > gradVFactor
The even/odd slice correction factor.
dVec gradientV(const int)
Return the gradient of the full potential for all beads at a single time slice.
LocalAction(const Path &, LookupTable &, PotentialBase *, PotentialBase *, WaveFunctionBase *, const TinyVector< double, 2 > &, const TinyVector< double, 2 > &, bool _local=true, string _name="Local", double _endFactor=1.0, int _period=1)
Setup the path data members and local action factors.
double derivPotentialActionTau(int)
The derivative of the potential action wrt tau on all links starting on slice.
double deltadotgradUterm2(const int)
Return the sum over particles at a given time slice of the gradient of the action potential for a sin...
int eo
Is a slice even or odd?
double barePotentialAction(const beadLocator &)
Return the bare potential action for a single bead indexed with beadIndex.
double V(const beadLocator &)
Returns the total value of the potential energy, including both the external potential,...
double Vnn(const beadLocator &)
Returns the total value of the potential energy, including both the external potential,...
double gradVnnSquared(const beadLocator &)
Return the gradient of the full potential squared for a single bead.
The particle (bead) lookup table.
Array< beadLocator, 1 > beadList
The cutoff dynamic list of interacting beads.
void updateInteractionList(const Path &, const beadLocator &)
Update the NN lookup table and the array of beadLocators containing all beads which 'interact' with t...
Array< dVec, 1 > beadSep
The separation between beads.
int numBeads
The cutoff number of active beads in beadList;.
double derivPotentialActionLambda(int)
The derivative of the potential action wrt lambda on all links starting on slice.
double potentialAction()
Return the potential action for all time slices and all particles.
NonLocalAction(const Path &, LookupTable &, PotentialBase *, PotentialBase *, WaveFunctionBase *, bool _local=false, string _name="Non-local")
Setup the path data members for non-local actions.
TinyVector< double, 2 > U(int)
Return the potential action for all time slices and all particles.
double derivPotentialActionTau(int)
The derivative of the potential action wrt tau on all links starting on slice.
virtual ~NonLocalAction()
Empty constructor.
The space-time trajectories.
dVec getVelocity(const beadLocator &) const
Return the velocity between two time slices of a given particle as a ndim-vector.
dVec getSeparation(const beadLocator &, const beadLocator &) const
Return the separation vector between two particles in the same timeslice.
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.
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.
The base class from which all specific potentials are derived from.
virtual double grad2V(const dVec &)
Grad^2 of the potential.
virtual dVec gradV(const dVec &)
The gradient of the potential.
virtual double dVdlambda(const dVec &, const dVec &)
The derivative of the effective potential with respect to lambda and tau.
virtual double V(const dVec &)
The potential.
Holds a base class that all trial wave function classes will be derived from.
virtual double PsiTrial(const int)
The Constant Trial Wave Function.
int beadOn(int, int) const
Safely get a bead (int indexed)
beadState getState(const beadLocator &) const
Get the state of the supplied bead?
double factor(const beadState, const beadLocator &) const
Compute the value of the potential action trajectory factor.
int getNumBeadsOn() const
Return the number of active beads.
#define NDIM
Number of spatial dimnsions.
TinyMatrix< double, NDIM, NDIM > dMat
A NDIM x NDIM matrix of type double.
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.
beadState
Each bead can have three possible states.
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.
ConstantParameters * constants()
Global public access to the constants.
LookupTable class definition.
All possible potential classes.
Action class definitions.