13 #include <boost/math/special_functions/ellint_1.hpp>
14 #include <boost/math/special_functions/ellint_2.hpp>
42 const int numParticles) {
45 Array<dVec,1> initialPos(numParticles);
49 double initSide = pow((1.0*numParticles/boxPtr->
volume),-1.0/(1.0*
NDIM));
53 int totNumGridBoxes = 1;
57 for (
int i = 0; i <
NDIM; i++) {
58 numNNGrid[i] =
static_cast<int>(ceil((boxPtr->
side[i] / initSide) -
EPS));
65 sizeNNGrid[i] = boxPtr->
side[i] / (1.0 * numNNGrid[i]);
68 totNumGridBoxes *= numNNGrid[i];
74 for (
int n = 0; n < totNumGridBoxes; n++) {
77 for (
int i = 0; i <
NDIM; i++) {
79 for (
int j = i+1; j <
NDIM; j++)
80 scale *= numNNGrid[j];
81 gridIndex[i] = (n/scale) % numNNGrid[i];
84 for (
int i = 0; i <
NDIM; i++)
85 pos[i] = (gridIndex[i]+0.5)*sizeNNGrid[i] - 0.5*boxPtr->
side[i];
109 for (
double d = 0; d < maxSep; d+= (maxSep/1.0E6)) {
112 << format(
"%16.12E\t%16.12E\n") % d %
V(sep);
121 double delta = sep2-sep1;
137 Array<double,1> excLens(0);
227 const TinyVector<double,2> &extVal,
const double r) {
238 double xi = rdr - 1.0*k;
239 double vkm1 = VTable(k-1);
240 double vk = VTable(k);
241 double vkp1 = VTable(k+1);
243 double T1 = vkm1 + (vk - vkm1) * xi;
244 double T2 = vk + (vkp1 - vk) * (xi - 1.0);
246 return (T1 + 0.5 * (T2 - T1) * xi);
256 const TinyVector<double,2> &extVal,
const double r) {
314 omega2 = _omega*_omega;
333 const int numParticles) {
336 Array<dVec,1> initialPos(numParticles);
339 for (
int n = 0; n < numParticles; n++) {
340 for (
int i = 0; i <
NDIM; i++)
341 initialPos(n)[i] = 0.1*boxPtr->
side[i]*(-1.0 + 2.0*random.rand());
365 w = 6.35077 / (radius*radius*
constants()->
m());
390 norm = _g/sqrt(2.0*_sigma*_sigma*M_PI);
391 inv2sigma2 = 1.0/(2.0*_sigma*_sigma);
418 norm = 2.0 * c * a / M_PI;
500 fixedParticles.resize(500);
503 numFixedParticles = 0;
505 while (!
communicate()->file(
"fixed")->stream().eof()) {
506 if (
communicate()->file(
"fixed")->stream().peek() ==
'#') {
511 for (
int i = 0; i <
NDIM; i++)
518 if (numFixedParticles >=
int(fixedParticles.size()))
519 fixedParticles.resizeAndPreserve(numFixedParticles);
523 fixedParticles(n) = pos;
530 fixedParticles.resizeAndPreserve(numFixedParticles);
534 lookupPtr =
new LookupTable(_boxPtr,1,numFixedParticles);
540 fixedBeadsInGrid =
XXX;
541 numFixedBeadsInGrid = 0;
559 fixedParticles.free();
560 fixedBeadsInGrid.free();
561 numFixedBeadsInGrid.free();
578 for (
int n = 0; n < numFixedBeadsInGrid(gridNumber); n++) {
579 sep = fixedParticles(fixedBeadsInGrid(gridNumber,n)) - pos;
581 if (dot(sep,sep) < rc2)
603 for (
int n = 0; n < numFixedBeadsInGrid(gridNumber); n++) {
604 sep = fixedParticles(fixedBeadsInGrid(gridNumber,n)) - pos;
606 if (dot(sep,sep) < rc2)
607 totGradV += aziz.
gradV(sep);
621 const int numParticles) {
624 Array<dVec,1> initialPos(1);
627 int locNumParticles = 0;
634 while (!
communicate()->file(
"fixed")->stream().eof()) {
635 if (
communicate()->file(
"fixed")->stream().peek() ==
'#') {
640 for (
int i = 0; i <
NDIM; i++)
647 initialPos.resizeAndPreserve(locNumParticles);
689 fixedParticles.resize(500);
692 numFixedParticles = 0;
694 while (!
communicate()->file(
"fixed")->stream().eof()) {
695 if (
communicate()->file(
"fixed")->stream().peek() ==
'#') {
699 for (
int i = 0; i <
NDIM; i++)
702 if (numFixedParticles >=
int(fixedParticles.size()))
703 fixedParticles.resizeAndPreserve(numFixedParticles);
704 fixedParticles(n) = pos;
709 fixedParticles.resizeAndPreserve(numFixedParticles);
732 fixedParticles.free();
747 if (r[
NDIM-1] < (-0.5*Lz + 1.5) )
750 else if (r[
NDIM-1] > 0.0)
757 for (
int i = 0; i < numFixedParticles; i++) {
758 sep[0] = fixedParticles(i)[0] - r[0];
759 sep[1] = fixedParticles(i)[1] - r[1];
761 sep[2] = fixedParticles(i)[2] - r[2];
762 x = sqrt(dot(sep,sep));
765 v += pow(sor,12)-pow(sor,6);
768 return 4.0*epsilon*v;
801 const double sigmaPlated_,
const double epsilonPlated_,
const double densityPlated_) :
809 densityPlated = densityPlated_;
810 epsilonPlated = epsilonPlated_;
811 sigmaPlated = sigmaPlated_;
839 extV = valueV(0.0),valueV(Ri);
840 extdVdr = valuedVdr(0.0),valuedVdr(Ri);
855 double PlatedLJCylinderPotential::V_(
const double r,
const double R,
856 const double sig,
const double eps,
const double dens)
858 double x = (r - (r>=R)*
EPS) / R;
864 double f1 = 1.0 / (1.0 - x2);
865 double sigoR3 = pow(sig/R,3.0);
866 double sigoR9 = sigoR3*sigoR3*sigoR3;
868 double Kx2 = boost::math::ellint_1(x);
869 double Ex2 = boost::math::ellint_2(x);
871 double v9 = (1.0*pow(f1,9.0)/(240.0)) * (
872 (1091.0 + 11156*x2 + 16434*x4 + 4052*x6 + 35*x8)*Ex2 -
873 8.0*(1.0 - x2)*(1.0 + 7*x2)*(97.0 + 134*x2 + 25*x4)*Kx2);
874 double v3 = 2.0*pow(f1,3.0) * ((7.0 + x2)*Ex2 - 4.0*(1.0-x2)*Kx2);
876 return ((M_PI*eps*sig*sig*sig*dens/3.0)*(sigoR9*v9 - sigoR3*v3));
884 double PlatedLJCylinderPotential::dVdr_(
const double r,
const double R,
885 const double sig,
const double eps,
const double dens)
887 double x = (r - (r>=R)*
EPS) / R;
891 return (1.28121E8/pow(R,11.0) - 102245.0/pow(R,5.0))*x;
897 double f1 = 1.0 / (1.0 - x2);
898 double sigoR3 = pow(sig/R,3.0);
899 double sigoR9 = sigoR3*sigoR3*sigoR3;
901 double Kx2 = boost::math::ellint_1(x);
902 double Ex2 = boost::math::ellint_2(x);
904 double dv9dx =(3.0*pow(f1,10.0)/(80.0*x)) *
905 ( (1.0 + x2)*(35.0 + 5108*x2 + 22482*x4 + 5108*x6 + 35*x8)*Ex2 -
906 (1.0 - x2)*(35.0 + 3428*x2 + 15234*x4 + 12356*x6 +1715*x8)*Kx2 );
907 double dv3dx = (6.0*pow(f1,4.0)/x) *
908 ( (1.0 + 14*x2 + x4)*Ex2 - (1.0 + 6*x2 - 7*x4)*Kx2 );
909 return ((M_PI*eps*sig*sig*sig*dens/(3.0*R))*(sigoR9*dv9dx - sigoR3*dv3dx));
917 double PlatedLJCylinderPotential::valueV(
const double r) {
919 return V_(r,Ri,sigmaPlated,epsilonPlated,densityPlated) -
920 V_(r,Ro,sigmaPlated,epsilonPlated,densityPlated) +
921 V_(r,Ro,sigma,epsilon,density);
929 double PlatedLJCylinderPotential::valuedVdr(
const double r) {
930 return dVdr_(r,Ri,sigmaPlated,epsilonPlated,densityPlated) -
931 dVdr_(r,Ro,sigmaPlated,epsilonPlated,densityPlated) +
932 dVdr_(r,Ro,sigma,epsilon,density);
939 double PlatedLJCylinderPotential::valued2Vdr2(
const double r) {
949 const int numParticles) {
952 Array<dVec,1> initialPos(numParticles);
959 lside[0] = lside[1] = sqrt(2.0)*(Ri-sigmaPlated);
963 double initSide = pow((1.0*numParticles/product(lside)),-1.0/(1.0*
NDIM));
967 int totNumGridBoxes = 1;
971 for (
int i = 0; i <
NDIM; i++) {
972 numNNGrid[i] =
static_cast<int>(ceil((lside[i] / initSide) -
EPS));
975 if (numNNGrid[i] < 1)
979 sizeNNGrid[i] = lside[i] / (1.0 * numNNGrid[i]);
982 totNumGridBoxes *= numNNGrid[i];
988 for (
int n = 0; n < totNumGridBoxes; n++) {
991 for (
int i = 0; i <
NDIM; i++) {
993 for (
int j = i+1; j <
NDIM; j++)
994 scale *= numNNGrid[j];
995 gridIndex[i] = (n/scale) % numNNGrid[i];
998 for (
int i = 0; i <
NDIM; i++)
999 pos[i] = (gridIndex[i]+0.5)*sizeNNGrid[i] - 0.5*lside[i];
1003 if (n < numParticles)
1004 initialPos(n) = pos;
1070 extV = valueV(0.0),valueV(R);
1071 extdVdr = valuedVdr(0.0),valuedVdr(R);
1086 double LJCylinderPotential::valueV(
const double r) {
1096 double f1 = 1.0 / (1.0 - x2);
1097 double sigoR3 = pow(sigma/R,3.0);
1098 double sigoR9 = sigoR3*sigoR3*sigoR3;
1100 double Kx2 = boost::math::ellint_1(x);
1101 double Ex2 = boost::math::ellint_2(x);
1103 double v9 = (1.0*pow(f1,9.0)/(240.0)) * (
1104 (1091.0 + 11156*x2 + 16434*x4 + 4052*x6 + 35*x8)*Ex2 -
1105 8.0*(1.0 - x2)*(1.0 + 7*x2)*(97.0 + 134*x2 + 25*x4)*Kx2);
1106 double v3 = 2.0*pow(f1,3.0) * ((7.0 + x2)*Ex2 - 4.0*(1.0-x2)*Kx2);
1108 return ((M_PI*epsilon*sigma*sigma*sigma*density/3.0)*(sigoR9*v9 - sigoR3*v3));
1116 double LJCylinderPotential::valuedVdr(
const double r) {
1125 return (1.28121E8/pow(R,11.0) - 102245.0/pow(R,5.0))*x;
1131 double f1 = 1.0 / (1.0 - x2);
1132 double sigoR3 = pow(sigma/R,3.0);
1133 double sigoR9 = sigoR3*sigoR3*sigoR3;
1135 double Kx2 = boost::math::ellint_1(x);
1136 double Ex2 = boost::math::ellint_2(x);
1138 double dv9dx =(3.0*pow(f1,10.0)/(80.0*x)) *
1139 ( (1.0 + x2)*(35.0 + 5108*x2 + 22482*x4 + 5108*x6 + 35*x8)*Ex2 -
1140 (1.0 - x2)*(35.0 + 3428*x2 + 15234*x4 + 12356*x6 +1715*x8)*Kx2 );
1141 double dv3dx = (6.0*pow(f1,4.0)/x) *
1142 ( (1.0 + 14*x2 + x4)*Ex2 - (1.0 + 6*x2 - 7*x4)*Kx2 );
1143 return ((M_PI*epsilon*sigma*sigma*sigma*density/(3.0*R))*(sigoR9*dv9dx - sigoR3*dv3dx));
1152 double LJCylinderPotential::valued2Vdr2(
const double r) {
1170 double f1 = 1.0 / (1.0 - x2);
1171 double sigoR3 = pow(sigma/R,3.0);
1172 double sigoR9 = sigoR3*sigoR3*sigoR3;
1174 double Kx2 = boost::math::ellint_1(x);
1175 double Ex2 = boost::math::ellint_2(x);
1177 double d2v9dx2 = (2.0/240)*pow(f1,11)*((1925.0*x10 + 319451.0*x8 + 2079074.0*x6 + 2711942.0*x4
1178 + 764873.0*x2 + 20975.0)*Ex2
1179 - (729400.0*x10 + 430024.0*x8 + 344752.0*x6 + 767248.0*x4 + 386200.0*x2 + 12712.0)*Kx2);
1180 double d2v3dx2 = 8.0*pow(f1,5)*((11.0 + 80.0*x2 + 5.0*x4)*Ex2 + 4.0*(5.0*x4 - 4.0*x2 - 1.0)*Kx2);
1182 return ((M_PI*epsilon*sigma*sigma*sigma*density/(3.0*R*R))*(sigoR9*d2v9dx2 - sigoR3*d2v3dx2));
1192 const int numParticles) {
1195 Array<dVec,1> initialPos(numParticles);
1202 lside[0] = lside[1] = sqrt(2.0)*(R-sigma);
1206 double initSide = pow((1.0*numParticles/product(lside)),-1.0/(1.0*
NDIM));
1210 int totNumGridBoxes = 1;
1214 for (
int i = 0; i <
NDIM; i++) {
1215 numNNGrid[i] =
static_cast<int>(ceil((lside[i] / initSide) -
EPS));
1218 if (numNNGrid[i] < 1)
1222 sizeNNGrid[i] = lside[i] / (1.0 * numNNGrid[i]);
1225 totNumGridBoxes *= numNNGrid[i];
1231 for (
int n = 0; n < totNumGridBoxes; n++) {
1234 for (
int i = 0; i <
NDIM; i++) {
1236 for (
int j = i+1; j <
NDIM; j++)
1237 scale *= numNNGrid[j];
1238 gridIndex[i] = (n/scale) % numNNGrid[i];
1241 for (
int i = 0; i <
NDIM; i++)
1242 pos[i] = (gridIndex[i]+0.5)*sizeNNGrid[i] - 0.5*lside[i];
1246 if (n < numParticles)
1247 initialPos(n) = pos;
1274 const double deltaRadius,
const double deltaWidth) :
PotentialBase()
1286 invd = 1.0/deltaWidth;
1287 R0 = 1.0/tanh(0.5*L*invd);
1317 for (
int i = 0; i <
NDIM-1; i++)
1320 double Rz = Rtanh(r[
NDIM-1]);
1331 double f1 = 1.0 / (1.0 - x2);
1332 double sigoR3 = pow(sigma/Rz,3.0);
1333 double sigoR9 = sigoR3*sigoR3*sigoR3;
1335 double Kx2 = boost::math::ellint_1(x);
1336 double Ex2 = boost::math::ellint_2(x);
1338 double v9 = (1.0*pow(f1,9.0)/(240.0)) * (
1339 (1091.0 + 11156*x2 + 16434*x4 + 4052*x6 + 35*x8)*Ex2 -
1340 8.0*(1.0 - x2)*(1.0 + 7*x2)*(97.0 + 134*x2 + 25*x4)*Kx2);
1341 double v3 = 2.0*pow(f1,3.0) * ((7.0 + x2)*Ex2 - 4.0*(1.0-x2)*Kx2);
1343 return ((M_PI*epsilon*sigma*sigma*sigma*density/3.0)*(sigoR9*v9 - sigoR3*v3));
1355 MTRand &random,
const int numParticles) {
1358 Array<dVec,1> initialPos(numParticles);
1365 lside[0] = lside[1] = sqrt(2.0)*(R-dR-sigma);
1372 double initSide = pow((1.0*numParticles/product(lside)),-1.0/(1.0*
NDIM));
1376 int totNumGridBoxes = 1;
1380 for (
int i = 0; i <
NDIM; i++) {
1381 numNNGrid[i] =
static_cast<int>(ceil((lside[i] / initSide) -
EPS));
1384 if (numNNGrid[i] < 1)
1388 sizeNNGrid[i] = lside[i] / (1.0 * numNNGrid[i]);
1391 totNumGridBoxes *= numNNGrid[i];
1397 for (
int n = 0; n < totNumGridBoxes; n++) {
1400 for (
int i = 0; i <
NDIM; i++) {
1402 for (
int j = i+1; j <
NDIM; j++)
1403 scale *= numNNGrid[j];
1404 gridIndex[i] = (n/scale) % numNNGrid[i];
1407 for (
int i = 0; i <
NDIM; i++)
1408 pos[i] = (gridIndex[i]+0.5)*sizeNNGrid[i] - 0.5*lside[i];
1412 if (n < numParticles)
1413 initialPos(n) = pos;
1430 MTRand &random,
const int numParticles) {
1433 Array<dVec,1> initialPos(numParticles);
1443 for (
int n = 0; n < numParticles; n++) {
1446 pos[
NDIM-1] = L*(-0.5 + random.rand());
1449 double theta = 2.0*M_PI*random.rand();
1450 double r = (Rtanh(pos[
NDIM-1]) - sigma)*sqrt(random.rand());
1452 pos[0] = r*cos(theta);
1453 pos[1] = r*sin(theta);
1457 initialPos(n) = pos;
1494 double L = _boxPtr->
maxSep;
1501 double rmoL = rm / L;
1502 double rm3 = rm*rm*rm;
1503 double t1 = A*exp(-alpha*L/(2.0*rm))*rm*(8.0*rm*rm + 4.0*L*rm * alpha + L*L*alpha*alpha)
1504 / (4.0*alpha*alpha*alpha);
1505 double t2 = 8.0*C6*pow(rmoL,3.0)/3.0;
1506 double t3 = 32.0*C8*pow(rmoL,5.0)/5.0;
1507 double t4 = 128.0*C10*pow(rmoL,7.0)/7.0;
1509 tailV = 2.0*M_PI*epsilon*(t1 - rm3*(t2+t3+t4));
1524 double AzizPotential::valueV(
const double r) {
1527 double Urep = A * exp(-alpha*x);
1534 return (epsilon * Urep);
1536 double ix2 = 1.0 / (x * x);
1537 double ix6 = ix2 * ix2 * ix2;
1538 double ix8 = ix6 * ix2;
1539 double ix10 = ix8 * ix2;
1540 double Uatt = -( C6*ix6 + C8*ix8 + C10*ix10 ) * F(x);
1541 return ( epsilon * (Urep + Uatt) );
1550 double AzizPotential::valuedVdr(
const double r) {
1553 double T1 = -A * alpha * exp(-alpha*x);
1561 return ( ( epsilon / rm ) * T1 );
1564 double ix = 1.0 / x;
1566 double ix6 = ix2 * ix2 * ix2;
1567 double ix7 = ix6 * ix;
1568 double ix8 = ix6 * ix2;
1569 double ix9 = ix8 * ix;
1570 double ix10 = ix8 * ix2;
1571 double ix11 = ix10 * ix;
1572 double T2 = ( 6.0*C6*ix7 + 8.0*C8*ix9 + 10.0*C10*ix11 ) * F(x);
1573 double T3 = -( C6*ix6 + C8*ix8 + C10*ix10 ) * dF(x);
1574 return ( ( epsilon / rm ) * (T1 + T2 + T3) );
1583 double AzizPotential::valued2Vdr2(
const double r) {
1586 double T1 = A * alpha * alpha * exp(-alpha*x);
1594 return ( ( epsilon / rm ) * T1 );
1597 double ix = 1.0 / x;
1599 double ix6 = ix2 * ix2 * ix2;
1600 double ix7 = ix6 * ix;
1601 double ix8 = ix6 * ix2;
1602 double ix9 = ix8 * ix;
1603 double ix10 = ix8 * ix2;
1604 double ix11 = ix10 * ix;
1605 double ix12 = ix11 * ix;
1606 double T2 = - ( 42.0*C6*ix8 + 72.0*C8*ix10 + 110.0*C10*ix12 ) * F(x);
1607 double T3 = 2.0*( 6.0*C6*ix7 + 8.0*C8*ix9 + 10.0*C10*ix11 ) * dF(x);
1608 double T4 = - ( C6*ix6 + C8*ix8 + C10*ix10 ) * d2F(x);
1609 return ( ( epsilon / (rm*rm) ) * (T1 + T2 + T3 + T4) );
1629 rm = 2.9262186279335958;
1636 double L = _boxPtr->
maxSep;
1702 double SzalewiczPotential::valueV(
const double _r) {
1703 double r = _r * 1.8897261254578281;
1710 double t1 = exp(-a*r);
1712 for (
int i = 0; i < 3; i++){
1713 t1m += Pn[i]*pow(r,i);
1717 double t2 = exp(-b*r);
1719 for (
int i = 0; i < 2; i++){
1720 t2m += Qn[i]*pow(r,i);
1727 for (
int i = 0; i < 17; i++){
1728 t3 += fn(eta*r,i)*Cn[i]/pow(r,i);
1732 for (
int i = 0; i < 17; i++){
1733 t3 += fn2(eta*r,i)*Cn[i]/pow(r,i);
1736 return (t1 + t2 - t3)*315774.65;
1745 double SzalewiczPotential::valuedVdr(
const double _r) {
1746 double r = _r * 1.8897261254578281;
1753 double t1 = exp(-a*r);
1755 for (
int i = 0; i < 3; i++){
1756 t1m += Pn[i]*pow(r,i);
1758 t1 *= ((Pn[1]+(2*r*Pn[2]))-(a*t1m));
1760 double t2 = exp(-b*r);
1762 for (
int i = 0; i < 2; i++){
1763 t2m += Qn[i]*pow(r,i);
1773 for (
int i = 0; i < 16; i++){
1774 t3 += (i+1)*fn(eta*r,i+1)*Cn[i+1]/pow(r,(i+2));
1777 for (
int i = 0; i < 17; i++){
1778 t4 += eta*dfn(eta*r,i)*Cn[i]/pow(r,i);
1784 for (
int i = 0; i < 16; i++){
1785 t3 += (i+1)*fn2(eta*r,i+1)*Cn[i+1]/pow(r,(i+2));
1788 for (
int i = 0; i < 17; i++){
1789 t4 += eta*dfn(eta*r,i)*Cn[i]/pow(r,i);
1792 return (t1 + t2 + t3 - t4)*315774.65;
1801 double SzalewiczPotential::valued2Vdr2(
const double _r) {
1802 double r = _r * 1.8897261254578281;
1809 double t1 = exp(-a*r);
1811 for (
int i = 0; i < 3; i++){
1812 t1m += Pn[i]*pow(r,i);
1814 t1 *= (2*Pn[2]-(2*a*(Pn[1]+(2*r*Pn[2])))+(a*a*t1m));
1816 double t2 = exp(-b*r);
1818 for (
int i = 0; i < 2; i++){
1819 t2m += Qn[i]*pow(r,i);
1821 t2 *= (b*b*t2m) - (2*b*Qn[1]);
1827 for (
int i = 0; i < 15; i++){
1828 t3 += (i+1)*(i+2)*fn2(eta*r,i+1)*Cn[i+1]/pow(r,(i+3));
1831 for (
int i = 0; i < 16; i++){
1832 t4 += 2*(i+1)*eta*dfn(eta*r,i+1)*Cn[i+1]/pow(r,(i+2));
1835 for (
int i = 0; i < 17; i++){
1836 t5 += eta*eta*d2fn(eta*r,i)*Cn[i]/pow(r,i);
1839 return (t1 + t2 - t3 + t4 - t5)*315774.65;
1855 excZ(0.5*_boxPtr->side[2]-_az),
1856 excY(0.5*_boxPtr->side[1]-_ay),
1875 MTRand &random,
const int numParticles) {
1879 lside[0] = boxPtr->
side[0];
1880 lside[1] = boxPtr->
side[1];
1884 double volTot = product(lside);
1887 double density = (1.0*numParticles/volTot);
1890 double volExc = lside[0]*(2.0*excY)*(2.0*excZ);
1893 int correctNum = int(numParticles-density*volExc);
1896 Array<dVec,1> initialPos(correctNum);
1899 double initSide = pow((1.0*correctNum/(volTot-volExc)),-1.0/(1.0*
NDIM));
1904 int totNumGridBoxes1 = 1;
1905 int totNumGridBoxes2 = 1;
1912 double V1 = (lside[1]-2.0*excY)*(2.0*excZ)*lside[0];
1913 double V2 = (lside[2]-2.0*excZ)*lside[1]*lside[0];
1915 double fracV1 = V1/(V1+V2);
1917 int numIn1 = int(correctNum*fracV1);
1918 int numIn2 = (correctNum-numIn1);
1922 numNNGrid1[0] =
static_cast<int>(ceil((1.0*lside[0]/initSide)-
EPS));
1923 if (numNNGrid1[0] < 1)
1925 sizeNNGrid1[0] = 1.0*lside[0]/(1.0*numNNGrid1[0]);
1926 totNumGridBoxes1 *= numNNGrid1[0];
1928 numNNGrid1[1] =
static_cast<int>(ceil(((lside[1]-2.0*excY)/initSide)-
EPS));
1929 if (numNNGrid1[1] < 1)
1931 sizeNNGrid1[1] = (lside[1]-2.0*excY)/(1.0*numNNGrid1[1]);
1932 totNumGridBoxes1 *= numNNGrid1[1];
1934 numNNGrid1[2] =
static_cast<int>(ceil(((2.0*excZ)/initSide)-
EPS));
1935 if (numNNGrid1[2] < 1)
1937 sizeNNGrid1[2] = (2.0*excZ)/(1.0*numNNGrid1[2]);
1938 totNumGridBoxes1 *= numNNGrid1[2];
1942 numNNGrid2[0] =
static_cast<int>(ceil((1.0*lside[0]/initSide)-
EPS));
1943 if (numNNGrid2[0] < 1)
1945 sizeNNGrid2[0] = 1.0*lside[0]/(1.0*numNNGrid2[0]);
1946 totNumGridBoxes2 *= numNNGrid2[0];
1948 numNNGrid2[1] =
static_cast<int>(ceil((1.0*lside[1]/initSide)-
EPS));
1949 if (numNNGrid2[1] < 1)
1951 sizeNNGrid2[1] = 1.0*lside[1]/(1.0*numNNGrid2[1]);
1952 totNumGridBoxes2 *= numNNGrid2[1];
1954 numNNGrid2[2] =
static_cast<int>(ceil(((lside[2]-2.0*excZ)/initSide)-
EPS));
1955 if (numNNGrid2[2] < 1)
1957 sizeNNGrid2[2] = (lside[2]-2.0*excZ)/(1.0*numNNGrid2[2]);
1958 totNumGridBoxes2 *= numNNGrid2[2];
1964 for (
int n = 0; n < totNumGridBoxes1; n++) {
1967 for (
int i = 0; i <
NDIM; i++) {
1969 for (
int j = i+1; j <
NDIM; j++)
1970 scale *= numNNGrid1[j];
1971 gridIndex1[i] = (n/scale) % numNNGrid1[i];
1974 pos1[0] = (gridIndex1[0]+0.5)*sizeNNGrid1[0] + +0.5*lside[0] + 2.0*
EPS;
1975 pos1[1] = (gridIndex1[1]+0.5)*sizeNNGrid1[1] + excY + 2.0*
EPS;
1976 pos1[2] = (gridIndex1[2]+0.5)*sizeNNGrid1[2] - excZ + 2.0*
EPS;
1978 if ((pos1[1]<-excY || pos1[1]>excY) || (pos1[2]<-excZ || pos1[2]>excZ))
1982 initialPos(n) = pos1;
1992 for (
int n = 0; n < totNumGridBoxes2; n++) {
1995 for (
int i = 0; i <
NDIM; i++) {
1997 for (
int j = i+1; j <
NDIM; j++)
1998 scale *= numNNGrid2[j];
1999 gridIndex2[i] = (n/scale) % numNNGrid2[i];
2002 pos2[0] = (gridIndex2[0]+0.5)*sizeNNGrid2[0] + 0.5*lside[0] + 2.0*
EPS;
2003 pos2[1] = (gridIndex2[1]+0.5)*sizeNNGrid2[1] + 0.5*lside[1] + 2.0*
EPS;
2004 pos2[2] = (gridIndex2[2]+0.5)*sizeNNGrid2[2] + excZ + 2.0*
EPS;
2006 if ((pos2[1]<-excY || pos2[1]>excY) || (pos2[2]<-excZ || pos2[2]>excZ))
2010 initialPos(n+numIn1) = pos2;
2019 OF.open(
"./OUTPUT/initialConfig.dat");
2020 OF<<
"# Cartesian Coordinates of initial Positions (X-Y-Z)"<<endl;
2021 OF<<
"# "<<lside[0]<<
"\t"<<lside[1]<<
"\t"<<lside[2]<<endl;
2022 OF<<
"# "<< excY <<
"\t"<< excZ <<endl;
2023 for (
int i=0; i< int(initialPos.size()); i++)
2024 OF<<initialPos(i)(0)<<
"\t"<<initialPos(i)(1)<<
"\t"<<initialPos(i)(2)<<endl;
2035 Array<double, 1> excLens(2);
2080 double r1 = sqrt(dot(sep1,sep1));
2081 double r2 = sqrt(dot(sep2,sep2));
2083 if ((r1 <= a ) || (r2 <= a))
2086 double cosTheta = dot(sep1,sep2)/(r1*r2);
2088 double t1 = -(r1*r2 + a*a - a*(r1 + r2)) * (1.0 + cosTheta);
2091 double t2 = (a*(r1+r2) - a*a)/(r1*r2);
2092 double t3 = 1.0 - t2*exp(t1);
2111 double r1 = sqrt(dot(sep1,sep1));
2112 double r2 = sqrt(dot(sep2,sep2));
2114 double cosTheta = dot(sep1,sep2)/(r1*r2);
2116 double t1 = -(r1*r2 + a*a - a*(r1 + r2)) * (1.0 + cosTheta);
2119 double t2 = (a*(r1+r2) - a*a)/(r1*r2);
2120 double t3 = 1.0 - t2*exp(t1);
2143 double r1 = sqrt(dot(sep1,sep1));
2144 double r2 = sqrt(dot(sep2,sep2));
2146 double cosTheta = dot(sep1,sep2)/(r1*r2);
2148 double t1 = -(r1*r2 + a*a - a*(r1 + r2)) * (1.0 + cosTheta);
2151 double t2 = (a*(r1+r2) - a*a)/(r1*r2);
2152 double t3 = 1.0 - t2*exp(t1);
2154 double t4 = (1.0/t3)*(t2*exp(t1))*(t1/
constants()->
tau());
2180 xiSqOver2 = (0.5)*xi*xi;
2181 xiSqrtPIOver2 = sqrt(M_PI/2.0)*xi;
2198 double Delta1DPotential::Wint(
double yt,
double dxt) {
2200 double W,erfVal,expVal;
2204 erfVal = erfc( (xi+yt)/sqrt(2.0) );
2205 expVal = exp( xiSqOver2 + (0.5)*dxt*dxt + xi*yt );
2206 W = 1.0 - xiSqrtPIOver2*expVal*erfVal;
2210 expVal = exp((-0.5)*(yt*yt-dxt*dxt));
2211 W = 1.0 - (xi/(xi+yt))*expVal;
2223 double Delta1DPotential::dWdxi(
double yt,
double dxt) {
2225 double dW,erfVal,expVal,expVal2;
2227 expVal = exp( (0.5)*(dxt*dxt-yt*yt) );
2231 erfVal = erfc( (xi+yt)/sqrt(2.0) );
2232 expVal2 = exp( (0.5)*(xi+yt)*(xi+yt) );
2233 dW = (-1.0)*xi*expVal*( sqrt(0.5*M_PI)*(xi +yt + (1.0/xi) )*expVal2*erfVal - 1.0 );
2236 dW = (-1.0)*xi*expVal*( (xi + yt + (1.0/xi) )/( xi + yt ) - 1.0 );
2247 double Delta1DPotential::dWdyt(
double yt,
double dxt) {
2249 double dW,erfVal,expVal,expVal2;
2251 expVal = exp( (0.5)*(dxt*dxt-yt*yt) );
2255 erfVal = erfc( (xi+yt)/sqrt(2.0) );
2256 expVal2 = exp( (0.5)*(xi+yt)*(xi+yt) );
2257 dW = xi*expVal*( 1 - sqrt(0.5*M_PI)*xi*expVal2*erfVal );
2260 dW = xi*expVal*( 1 - xi/(xi+yt) );
2271 double Delta1DPotential::dWddxt(
double yt,
double dxt) {
2273 double dW,erfVal,expVal;
2275 if (xi + yt < erfCO)
2277 erfVal = erfc( (xi+yt)/sqrt(2.0) );
2278 expVal = exp( (0.5)*( dxt*dxt + xi*( xi + 2.0*yt)) );
2279 dW = (-1.0)*sqrt(0.5*M_PI)*xi*dxt*expVal*erfVal;
2283 expVal = exp( (0.5)*(dxt*dxt-yt*yt) );
2284 dW = (-1.0)*dxt*expVal*( xi/( xi + yt ) );
2303 double yt = (abs(sep1[0])+abs(sep2[0]))/l0;
2305 double W = Wint(yt,dxt);
2307 return (-1.0)*log(W);
2323 double yt = (abs(sep1[0])+abs(sep2[0]))/l0;
2325 double W = Wint(yt,dxt);
2326 double dWdy = dWdyt(yt,dxt);
2327 double dWddx = dWddxt(yt,dxt);
2328 double dWdx = dWdxi(yt,dxt);
2330 double dWdl = ((-1.0)/(2.0*
constants()->
lambda()))*(yt*dWdy + dxt*dWddx+ xi*dWdx );
2332 return ((-1.0)/W)*dWdl;
2348 double yt = (abs(sep1[0])+abs(sep2[0]))/l0;
2350 double W = Wint(yt,dxt);
2352 * ( (-1.0)*yt*dWdyt(yt,dxt) - dxt*dWddxt(yt,dxt) + xi*dWdxi(yt,dxt) );
2354 return ((-1.0)/W)*dWdt;
2393 double r1 = sqrt(dot(sep1,sep1));
2394 double r2 = sqrt(dot(sep2,sep2));
2401 if ( (r1 <= a ) || (r2 <= a) )
2412 return (-log(1.0 - exp(t1)));
2429 double r1 = sqrt(dot(sep1,sep1));
2430 double r2 = sqrt(dot(sep2,sep2));
2454 double r1 = sqrt(dot(sep1,sep1));
2455 double r2 = sqrt(dot(sep2,sep2));
2474 #include <boost/math/special_functions/bessel.hpp>
2477 double strain = _strain;
2478 double poisson = _poisson;
2489 a1x = sqrt(3.0)*a0*0.5*(1.0-strain*poisson);
2490 a1y = 3.0*a0*0.5*(1+strain);
2495 g1x = 2*M_PI/(sqrt(3.0)*a0*(1.0-strain*poisson));
2496 g1y = 2*M_PI/(3.0*a0*(1+strain));
2501 b1x = sqrt(3.0)*a0*0.5*(1.0-strain*poisson);
2502 b1y = 0.5*a0*(1.0 + strain);
2504 b2y = a0*(1+strain);
2507 A = fabs((a1x*a2y) - (a1y*a2x));
2528 double z = r[2] + Lzo2;
2543 double prefactor = 0.;
2545 double v = (4.*M_PI/A)*epsilon*sigma*sigma*( ((2./5.)*pow((sigma/z),10)) - pow((sigma/z),4) );
2547 for (
double m = -1; m < 1+1; m++) {
2548 for (
double n = -1; n < 1+1; n++) {
2549 if ((m != 0) || (n != 0)){
2550 g = sqrt(pow((m*g1x + n*g2x),2.) + pow((m*g1y + n*g2y),2.));
2551 gdotb1 = ((m*g1x + n*g2x)*(b1x+x)) + ((m*g1y + n*g2y)*(b1y+y));
2552 gdotb2 = ((m*g1x + n*g2x)*(b2x+x)) + ((m*g1y + n*g2y)*(b2y+y));
2553 k5term = pow((g*sigma*sigma/2./z),5.)*boost::math::cyl_bessel_k(5., g*z)/30.;
2554 k2term = 2.*pow((g*sigma*sigma/2./z),2.)*boost::math::cyl_bessel_k(2., g*z);
2555 prefactor = epsilon*sigma*sigma*2.*M_PI/A;
2557 v_g = prefactor*(k5term-k2term);
2558 v += (cos(gdotb1)+cos(gdotb2))*v_g;
2572 const int numParticles) {
2575 Array<dVec,1> initialPos(numParticles);
2577 double initSideCube = 1.0*numParticles;
2579 for (
int i = 0; i <
NDIM - 1; i++) {
2580 initSideCube /= boxPtr->
side[i];
2583 initSideCube /= ((boxPtr->
side[
NDIM-1] / 2.0) - 6.0);
2586 double initSide = pow((initSideCube),-1.0/(1.0*
NDIM));
2590 int totNumGridBoxes = 1;
2594 for (
int i = 0; i <
NDIM - 1; i++) {
2595 numNNGrid[i] =
static_cast<int>(ceil((boxPtr->
side[i] / initSide) -
EPS));
2598 if (numNNGrid[i] < 1)
2602 sizeNNGrid[i] = boxPtr->
side[i] / (1.0 * numNNGrid[i]);
2605 totNumGridBoxes *= numNNGrid[i];
2608 numNNGrid[
NDIM-1] =
static_cast<int>(ceil(((boxPtr->
side[
NDIM-1] - 12.0) / (2.0 * initSide)) -
EPS));
2611 if (numNNGrid[
NDIM-1] < 1)
2612 numNNGrid[
NDIM-1] = 1;
2615 sizeNNGrid[
NDIM-1] = (boxPtr->
side[
NDIM-1] - 12.0) / (2.0 * numNNGrid[
NDIM-1]);
2618 totNumGridBoxes *= numNNGrid[
NDIM-1];
2623 for (
int n = 0; n < totNumGridBoxes; n++) {
2626 for (
int i = 0; i <
NDIM; i++) {
2628 for (
int j = i+1; j <
NDIM; j++)
2629 scale *= numNNGrid[j];
2630 gridIndex[i] = (n/scale) % numNNGrid[i];
2633 for (
int i = 0; i <
NDIM - 1; i++)
2634 pos[i] = (gridIndex[i]+0.5)*sizeNNGrid[i] - 0.5*boxPtr->
side[i];
2636 pos[
NDIM - 1] = (gridIndex[
NDIM - 1]+0.5)*sizeNNGrid[
NDIM - 1] + 3.0;
2640 if (n < numParticles)
2641 initialPos(n) = pos;
2657 #include <boost/math/special_functions/bessel.hpp>
2661 double strain = _strain;
2662 double poisson = _poisson;
2676 invWallWidth = 20.0;
2679 tableLength = int((zmax - zmin)/dr);
2685 a1x = sqrt(3.0)*a0*0.5*(1-strain*poisson);
2686 a1y = 3.0*a0*0.5*(1+strain);
2691 g1x = 2*M_PI/(sqrt(3.0)*a0*(1-strain*poisson));
2692 g1y = 2*M_PI/(3.0*a0*(1+strain));
2697 b1x = sqrt(3.0)*a0*0.5*(1.0-strain*poisson);
2698 b1y = 0.5*a0*(1.0 + strain);
2700 b2y = a0*(1.0 + strain);
2703 A = fabs((a1x*a2y) - (a1y*a2x));
2706 double prefactor = epsilon*sigma*sigma*2.*M_PI/A;
2707 double k5term = 0.0;
2708 double k2term = 0.0;
2750 set<double> uniquegMag;
2753 uniquegMag.insert(0.0);
2754 for (
int m = -gnum; m <= gnum; m++) {
2755 for (
int n = 1; n <= gnum; n++) {
2756 g = sqrt(pow((m*g1x + n*g2x),2) + pow((m*g1y + n*g2y),2));
2757 uniquegMag.insert(g);
2760 for (
int m=1; m <= gnum; m++) {
2761 g = sqrt(pow(m*g1x,2) + pow(m*g1y,2));
2762 uniquegMag.insert(g);
2766 std::vector<double> gMag(uniquegMag.begin(), uniquegMag.end());
2767 sort(gMag.begin(),gMag.end());
2770 gMagID.resize(2*(gnum+1)*gnum+1);
2774 for (
int m = -gnum; m <= gnum; m++) {
2775 for (
int n = 1; n <= gnum; n++) {
2776 g = sqrt(pow((m*g1x + n*g2x),2) + pow((m*g1y + n*g2y),2));
2777 gMagID(ig) = distance(gMag.begin(), find(gMag.begin(), gMag.end(),g));
2781 for (
int m=1; m <= gnum; m++){
2782 g = sqrt(pow(m*g1x,2) + pow(m*g1y,2));
2783 gMagID(ig) = distance(gMag.begin(), find(gMag.begin(), gMag.end(),g));
2788 vg.resize(gMag.size(), tableLength);
2791 for (
auto cg : gMag) {
2792 for (
int iz = 0; iz < tableLength; iz++) {
2795 vg(ig,iz) = q*prefactor*( ((2./5.)*pow((sigma/z),10)) - pow((sigma/z),4) );
2797 k5term = pow((cg*sigma*sigma/2./z),5)*boost::math::cyl_bessel_k(5, cg*z)/30.;
2798 k2term = 2.*pow((cg*sigma*sigma/2./z),2)*boost::math::cyl_bessel_k(2, cg*z);
2799 vg(ig,iz) = prefactor*(k5term-k2term);
2855 double z = r[2]+(Lzo2);
2860 double VWall = V_zmin/(1.0+exp(-invWallWidth*(z-zWall)));
2862 int zindex = int((z-zmin)/dr);
2863 if (zindex >= tableLength)
2864 return q*(epsilon*sigma*sigma*2.*M_PI/A)*( ((2./5.)*pow((sigma/z),10)) - pow((sigma/z),4) );
2866 double x1 = r[0]+b1x;
2867 double x2 = r[0]+b2x;
2868 double y1 = r[1]+b1y;
2869 double y2 = r[1]+b2y;
2872 double v = vg(0,zindex);
2875 for (
int m = -gnum; m <= gnum; m++) {
2878 for (
int n = 1; n <= gnum; n++) {
2879 v += 2.0*(cos((mx + n*g2x)*x1 + (my + n*g2y)*y1) +
2880 cos((mx + n*g2x)*x2 + (my + n*g2y)*y2)) * vg(gMagID(ig),zindex);
2885 for (
int m=1; m <= gnum; m++){
2888 v += 2.0*(cos(mx*x1 + my*y1) + cos(mx*x2 + my*y2)) * vg(gMagID(ig),zindex);
2949 const int numParticles) {
2951 Array<dVec,1> initialPos(numParticles);
2954 int Nlayer = round(boxPtr->
side[0]*boxPtr->
side[1]/a1x/a1y/4);
2955 int numX = round(boxPtr->
side[0]/a1x/2);
2956 int numY = round(boxPtr->
side[1]/a1y/2);
2957 double gridX = boxPtr->
side[0]/numX;
2958 double gridY = boxPtr->
side[1]/numY;
2960 if (3*Nlayer < numParticles){
2961 gridSize = numParticles - 3*Nlayer;
2963 int numInLayers = numParticles - gridSize;
2967 for (
int i = 0; i < numInLayers; i++){
2968 layerNum = i/Nlayer;
2969 iShifted = i - (layerNum*Nlayer);
2970 pos[0] = ((iShifted % numX) + 0.5)*gridX - (boxPtr->
side[0]/2);
2971 pos[1] = ((iShifted / numX) + 0.5)*gridY - (boxPtr->
side[1]/2);
2972 pos[
NDIM-1] = ((layerNum+1)*3.0)-(boxPtr->
side[
NDIM-1]/2);
2974 initialPos(i) = pos;
2977 int initCubePart = ceil(pow(1.0*gridSize,1.0/(1.0*
NDIM)));
2979 for (
int i = 0; i <
NDIM - 1; i++) {
2980 initSide[i] = boxPtr->
side[i]/initCubePart;
2983 initSide[
NDIM-1] = (boxPtr->
side[
NDIM-1] - 12.0)/initCubePart;
2985 for (
int n = 0; n < gridSize; n++) {
2986 pos[0] = (((n % initCubePart) + 0.5) * initSide[0]) - (boxPtr->
side[0]/2);
2987 pos[1] = (((n / initCubePart) + 0.5) * initSide[1]) - (boxPtr->
side[1]/2);
2988 pos[
NDIM-1] = (((n / initCubePart / initCubePart) + 0.5) * initSide[
NDIM-1]) - (boxPtr->
side[
NDIM-1]/2) + 12.0;
2990 initialPos(n + numInLayers) = pos;
3008 static auto const aflags = boost::archive::no_header | boost::archive::no_tracking;
3016 invWallWidth = 20.0;
3021 std::ifstream ifs(graphenelut3d_file_prefix + std::string(
"serialized.dat"));
3022 boost::archive::binary_iarchive ia(ifs,aflags);
3024 ia >> V3d >> gradV3d_x >> gradV3d_y >> gradV3d_z >> grad2V3d >> LUTinfo;
3035 cell_length_a = LUTinfo( 7 );
3036 cell_length_b = LUTinfo( 8 );
3037 zmin = LUTinfo( 9 );
3038 zmax = LUTinfo( 10 );
3039 V_zmin = LUTinfo( 11 );
3063 double z = r[2]+Lzo2;
3070 double VWall = V_zmin/(1.0+exp(-invWallWidth*(z-zWall)));
3073 _r[2] += Lzo2 - zmin;
3075 cartesian_to_uc(_r, A11, A12, A21, A22);
3076 put_in_uc(_r, cell_length_a, cell_length_b);
3077 double _V = trilinear_interpolation(V3d, _r, dx, dy, dz);
3093 if (r[2] + Lzo2 < zmin){
3097 _r[2] += Lzo2 - zmin;
3099 cartesian_to_uc(_r, A11, A12, A21, A22);
3100 put_in_uc(_r, cell_length_a, cell_length_b);
3101 double _gradV_x = trilinear_interpolation(gradV3d_x, _r, dx, dy, dz);
3102 double _gradV_y = trilinear_interpolation(gradV3d_y, _r, dx, dy, dz);
3103 double _gradV_z = trilinear_interpolation(gradV3d_z, _r, dx, dy, dz);
3107 _gradV(0) = _gradV_x;
3108 _gradV(1) = _gradV_y;
3109 _gradV(2) = _gradV_z;
3121 double _grad2V = 0.0;
3122 if (r[2] + Lzo2 < zmin){
3126 _r[2] += Lzo2 - zmin;
3128 cartesian_to_uc(_r, A11, A12, A21, A22);
3129 put_in_uc(_r, cell_length_a, cell_length_b);
3130 _grad2V = trilinear_interpolation(grad2V3d, _r, dx, dy, dz);
3141 const int numParticles) {
3146 Array<dVec,1> initialPos(numParticles);
3150 double initSide = pow((1.0*numParticles/boxPtr->
volume),-1.0/(1.0*
NDIM));
3154 int totNumGridBoxes = 1;
3158 for (
int i = 0; i <
NDIM; i++) {
3159 numNNGrid[i] =
static_cast<int>(ceil((boxPtr->
side[i] / initSide) -
EPS));
3162 if (numNNGrid[i] < 1)
3166 sizeNNGrid[i] = boxPtr->
side[i] / (1.0 * numNNGrid[i]);
3169 if (i ==
NDIM - 1) {
3170 sizeNNGrid[i] = (zWall - zmin) / (1.0 * numNNGrid[i]);
3174 totNumGridBoxes *= numNNGrid[i];
3180 for (
int n = 0; n < totNumGridBoxes; n++) {
3183 for (
int i = 0; i <
NDIM; i++) {
3185 for (
int j = i+1; j <
NDIM; j++)
3186 scale *= numNNGrid[j];
3187 gridIndex[i] = (n/scale) % numNNGrid[i];
3191 for (
int i = 0; i <
NDIM; i++)
3192 pos[i] = (gridIndex[i]+0.5)*sizeNNGrid[i] - 0.5*boxPtr->
side[i];
3193 pos[
NDIM-1] += zmin;
3197 if (n < numParticles)
3198 initialPos(n) = pos;
3223 const int numParticles) {
3226 Array<dVec,1> initialPos(numParticles);
3230 side_ = boxPtr->
side;
3233 for (
int i = 0; i <
NDIM-1; i++)
3234 initialPos(0)[i] = side_[i]*(-0.5 + random.rand());
3235 initialPos(0)[
NDIM-1] = -0.5*side_[
NDIM-1]+zmin + (zWall-zmin)*random.rand();
3237 double hardCoreRadius = 1.00;
3240 int numInserted = 1;
3241 int numAttempts = 0;
3242 int maxNumAttempts =
ipow(10,6);
3245 while ((numInserted < numParticles) && (numAttempts < maxNumAttempts)) {
3249 for (
int i = 0; i <
NDIM-1; i++)
3250 trialPos[i] = side_[i]*(-0.5 + random.rand());
3251 trialPos[
NDIM-1] = -0.5*side_[
NDIM-1]+zmin + (zWall-zmin)*random.rand();
3255 bool acceptParticle =
true;
3256 for (
int n = 0; n < numInserted; n++) {
3257 sep = trialPos - initialPos(n);
3259 rsep = sqrt(dot(sep,sep));
3260 if (rsep < 2*hardCoreRadius) {
3261 acceptParticle =
false;
3266 if (acceptParticle) {
3267 initialPos(numInserted) = trialPos;
3273 if (numAttempts == maxNumAttempts) {
3274 cerr <<
"Could not construct a valid initial configuration." << endl;
3303 const double _strain,
const double _poisson_ratio,
3304 const double _carbon_carbon_distance,
const double _sigma,
3305 const double _epsilon,
const Container *_boxPtr
3308 static auto const aflags = boost::archive::no_header | boost::archive::no_tracking;
3316 double strain = _strain;
3319 double sigma = _sigma;
3320 double epsilon = _epsilon;
3334 auto [ V3d, gradV3d_x, gradV3d_y, gradV3d_z, grad2V3d, xy_x, xy_y, LUTinfo ] =
3335 get_V3D_all(strain,sigma,epsilon,xres,yres,zres,zmax);
3337 string graphenelut3d_file_prefix = str( format(
"graphene_%.2f_%.2f_%d_%d_%d_") %
3338 strain % zmax % xres % yres % zres );
3341 std::ofstream ofs(graphenelut3d_file_prefix +
"serialized.dat");
3345 boost::archive::binary_oarchive oa(ofs,aflags);
3347 oa << V3d << gradV3d_x << gradV3d_y << gradV3d_z << grad2V3d << LUTinfo;
3352 double GrapheneLUT3DPotentialGenerate::Vz_64(
3353 double z,
double sigma,
double prefactor,
int atoms_in_basis ) {
3354 return atoms_in_basis*Vz_64(z,sigma,prefactor);
3357 double GrapheneLUT3DPotentialGenerate::Vz_64(
3358 double z,
double sigma,
double prefactor ) {
3359 return prefactor*Vz_64(z,sigma);
3362 double GrapheneLUT3DPotentialGenerate::Vz_64(
double z,
double sigma ) {
3363 return (pow(sigma,4)*(2*pow(sigma,6) - 5*pow(z,6)))/(5*pow(z,10));
3366 double GrapheneLUT3DPotentialGenerate::gradVz_x_64(
3367 double z,
double sigma,
double prefactor,
int atoms_in_basis ) {
3371 double GrapheneLUT3DPotentialGenerate::gradVz_x_64(
3372 double z,
double sigma,
double prefactor ) {
3376 double GrapheneLUT3DPotentialGenerate::gradVz_x_64(
double z,
double sigma ) {
3380 double GrapheneLUT3DPotentialGenerate::gradVz_y_64(
3381 double z,
double sigma,
double prefactor,
int atoms_in_basis ) {
3385 double GrapheneLUT3DPotentialGenerate::gradVz_y_64(
3386 double z,
double sigma,
double prefactor ) {
3390 double GrapheneLUT3DPotentialGenerate::gradVz_y_64(
double z,
double sigma ) {
3394 double GrapheneLUT3DPotentialGenerate::gradVz_z_64(
3395 double z,
double sigma,
double prefactor,
int atoms_in_basis ) {
3396 return atoms_in_basis*gradVz_z_64(z,sigma,prefactor);
3399 double GrapheneLUT3DPotentialGenerate::gradVz_z_64(
3400 double z,
double sigma,
double prefactor ) {
3401 return prefactor*gradVz_z_64(z,sigma);
3404 double GrapheneLUT3DPotentialGenerate::gradVz_z_64(
double z,
double sigma ) {
3405 return (4*pow(sigma,4)*(-pow(sigma,6) + pow(z,6)))/pow(z,11);
3408 double GrapheneLUT3DPotentialGenerate::grad2Vz_64(
3409 double z,
double sigma,
double prefactor,
int atoms_in_basis ) {
3410 return atoms_in_basis*grad2Vz_64(z,sigma,prefactor);
3413 double GrapheneLUT3DPotentialGenerate::grad2Vz_64(
3414 double z,
double sigma,
double prefactor ) {
3415 return prefactor*grad2Vz_64(z,sigma);
3418 double GrapheneLUT3DPotentialGenerate::grad2Vz_64(
double z,
double sigma ) {
3419 return (4*pow(sigma,4)*(11*pow(sigma,6) - 5*pow(z,6)))/pow(z,12);
3422 double GrapheneLUT3DPotentialGenerate::Vg_64(
3423 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3424 double g_j,
double b_i,
double b_j,
double prefactor ) {
3425 return prefactor*Vg_64(x, y, z, sigma, g, g_i, g_j, b_i, b_j);
3428 double GrapheneLUT3DPotentialGenerate::Vg_64(
3429 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3430 double g_j,
double b_i,
double b_j ) {
3431 return (pow(g,2)*pow(sigma,4)*(-480*pow(z,3)*boost::math::cyl_bessel_k(2, g*z) +
3432 pow(g,3)*pow(sigma,6)*boost::math::cyl_bessel_k(5, g*z))*cos(g_i*(b_i + x) +
3433 g_j*(b_j + y)))/(960*pow(z,5));
3436 double GrapheneLUT3DPotentialGenerate::gradVg_x_64(
3437 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3438 double g_j,
double b_i,
double b_j,
double prefactor ) {
3439 return prefactor*gradVg_x_64(x, y, z, sigma, g, g_i, g_j, b_i, b_j);
3442 double GrapheneLUT3DPotentialGenerate::gradVg_x_64(
3443 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3444 double g_j,
double b_i,
double b_j ) {
3445 return -(pow(g,2)*g_i*pow(sigma,4)*(-480*pow(z,3)*boost::math::cyl_bessel_k(2, g*z) +
3446 pow(g,3)*pow(sigma,6)*boost::math::cyl_bessel_k(5, g*z))*sin(g_i*(b_i + x) +
3447 g_j*(b_j + y)))/(960*pow(z,5));
3450 double GrapheneLUT3DPotentialGenerate::gradVg_y_64(
3451 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3452 double g_j,
double b_i,
double b_j,
double prefactor ) {
3453 return prefactor*gradVg_y_64(x, y, z, sigma, g, g_i, g_j, b_i, b_j);
3456 double GrapheneLUT3DPotentialGenerate::gradVg_y_64(
3457 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3458 double g_j,
double b_i,
double b_j ) {
3459 return -(pow(g,2)*g_j*pow(sigma,4)*(-480*pow(z,3)*boost::math::cyl_bessel_k(2, g*z) +
3460 pow(g,3)*pow(sigma,6)*boost::math::cyl_bessel_k(5, g*z))*sin(g_i*(b_i + x) +
3461 g_j*(b_j + y)))/(960*pow(z,5));
3464 double GrapheneLUT3DPotentialGenerate::gradVg_z_64(
3465 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3466 double g_j,
double b_i,
double b_j,
double prefactor ) {
3467 return prefactor*gradVg_z_64(x, y, z, sigma, g, g_i, g_j, b_i, b_j);
3470 double GrapheneLUT3DPotentialGenerate::gradVg_z_64(
3471 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3472 double g_j,
double b_i,
double b_j ) {
3473 return -(pow(g,3)*pow(sigma,4)*(10*(pow(g,2)*pow(sigma,6)*z - 48*pow(z,5))*boost::math::cyl_bessel_k(3, g*z) +
3474 g*pow(sigma,6)*(80 + pow(g*z,2))*boost::math::cyl_bessel_k(4, g*z))*cos(g_i*(b_i + x) +
3475 g_j*(b_j + y)))/(960*pow(z,7));
3478 double GrapheneLUT3DPotentialGenerate::grad2Vg_64(
3479 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3480 double g_j,
double b_i,
double b_j,
double prefactor ) {
3481 return prefactor*grad2Vg_64(x, y, z, sigma, g, g_i, g_j, b_i, b_j);
3484 double GrapheneLUT3DPotentialGenerate::grad2Vg_64(
3485 double x,
double y,
double z,
double sigma,
double g,
double g_i,
3486 double g_j,
double b_i,
double b_j) {
3487 return (pow(g,2)*pow(sigma,4)*(-120*g*pow(z,6)*(g*z*boost::math::cyl_bessel_k(0, g*z) +
3488 8*boost::math::cyl_bessel_k(1, g*z)) + z*(19*pow(g,4)*pow(sigma,6)*pow(z,2) +
3489 480*pow(z,4)*(-6 + (pow(g_i,2) + pow(g_j,2))*pow(z,2)) -
3490 8*pow(g,2)*(45*pow(z,6) + pow(sigma,6)*(-110 + (pow(g_i,2) +
3491 pow(g_j,2))*pow(z,2))))*boost::math::cyl_bessel_k(2, g*z) +
3492 g*(-1680*pow(z,6) + pow(sigma,6)*(5280 + pow(z,2)*(-48*(pow(g_i,2) +
3493 pow(g_j,2)) + pow(g,4)*pow(z,2) + pow(g,2)*(224 -
3494 (pow(g_i,2) + pow(g_j,2))*pow(z,2)))))*boost::math::cyl_bessel_k(3, g*z))*cos(g_i*(b_i + x) +
3495 g_j*(b_j + y)))/(960*pow(z,9));
3498 double GrapheneLUT3DPotentialGenerate::V_64(
3499 double x,
double y,
double z,
double sigma,
double epsilon,
3500 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3501 TinyVector<double,2> g_m, TinyVector<double,2> g_n, Array<int,1> g_i_array,
3502 Array<int,1> g_j_array, Array<double,1> g_magnitude_array ) {
3504 bool flag_1 =
false;
3505 bool flag_2 =
false;
3506 bool flag_3 =
false;
3507 TinyVector <double,2> g;
3508 double pf = 2*M_PI*epsilon*pow(sigma,2)/area_lattice;
3510 _V += 2*Vz_64(z, sigma);
3511 double _V_old = 0.0;
3515 for (
int k = 1; k < 2*k_max; k++) {
3518 g = (g_i * g_m) + (g_j * g_n);
3519 g_magnitude = g_magnitude_array(k);
3520 _V += Vg_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_1[0], b_1[1]);
3521 _V += Vg_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_2[0], b_2[1]);
3523 if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_1)) {
3527 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_2)) {
3531 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_3)) {
3535 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && flag_1 && flag_2 && flag_3) {
3539 else if ((k >= k_max) && (g_magnitude != g_magnitude_array(k+1))) {
3550 double GrapheneLUT3DPotentialGenerate::gradV_x_64(
3551 double x,
double y,
double z,
double sigma,
double epsilon,
3552 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3553 TinyVector<double,2> g_m, TinyVector<double,2> g_n, Array<int,1> g_i_array,
3554 Array<int,1> g_j_array, Array<double,1> g_magnitude_array ) {
3556 bool flag_1 =
false;
3557 bool flag_2 =
false;
3558 bool flag_3 =
false;
3559 TinyVector <double,2> g;
3560 double pf = 2*M_PI*epsilon*pow(sigma,2)/area_lattice;
3562 _V += 2*gradVz_x_64(z, sigma);
3563 double _V_old = 0.0;
3567 for (
int k = 1; k < 2*k_max; k++) {
3570 g = (g_i * g_m) + (g_j * g_n);
3571 g_magnitude = g_magnitude_array(k);
3572 _V += gradVg_x_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_1[0], b_1[1]);
3573 _V += gradVg_x_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_2[0], b_2[1]);
3575 if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_1)) {
3579 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_2)) {
3583 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_3)) {
3587 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && flag_1 && flag_2 && flag_3) {
3591 else if ((k >= k_max) && (g_magnitude != g_magnitude_array(k+1))) {
3602 double GrapheneLUT3DPotentialGenerate::gradV_y_64(
3603 double x,
double y,
double z,
double sigma,
double epsilon,
3604 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3605 TinyVector<double,2> g_m, TinyVector<double,2> g_n, Array<int,1> g_i_array,
3606 Array<int,1> g_j_array, Array<double,1> g_magnitude_array ) {
3608 bool flag_1 =
false;
3609 bool flag_2 =
false;
3610 bool flag_3 =
false;
3611 TinyVector <double,2> g;
3612 double pf = 2*M_PI*epsilon*pow(sigma,2)/area_lattice;
3614 _V += 2*gradVz_y_64(z, sigma);
3615 double _V_old = 0.0;
3619 for (
int k = 1; k < 2*k_max; k++) {
3622 g = (g_i * g_m) + (g_j * g_n);
3623 g_magnitude = g_magnitude_array(k);
3624 _V += gradVg_y_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_1[0], b_1[1]);
3625 _V += gradVg_y_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_2[0], b_2[1]);
3627 if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_1)) {
3631 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_2)) {
3635 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_3)) {
3639 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && flag_1 && flag_2 && flag_3) {
3643 else if ((k >= k_max) && (g_magnitude != g_magnitude_array(k+1))) {
3654 double GrapheneLUT3DPotentialGenerate::gradV_z_64(
3655 double x,
double y,
double z,
double sigma,
double epsilon,
3656 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3657 TinyVector<double,2> g_m, TinyVector<double,2> g_n, Array<int,1> g_i_array,
3658 Array<int,1> g_j_array, Array<double,1> g_magnitude_array ) {
3660 bool flag_1 =
false;
3661 bool flag_2 =
false;
3662 bool flag_3 =
false;
3663 TinyVector <double,2> g;
3664 double pf = 2*M_PI*epsilon*pow(sigma,2)/area_lattice;
3666 _V += 2*gradVz_z_64(z, sigma);
3667 double _V_old = 0.0;
3671 for (
int k = 1; k < 2*k_max; k++) {
3674 g = (g_i * g_m) + (g_j * g_n);
3675 g_magnitude = g_magnitude_array(k);
3676 _V += gradVg_z_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_1[0], b_1[1]);
3677 _V += gradVg_z_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_2[0], b_2[1]);
3679 if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_1)) {
3683 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_2)) {
3687 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_3)) {
3691 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && flag_1 && flag_2 && flag_3) {
3695 else if ((k >= k_max) && (g_magnitude != g_magnitude_array(k+1))) {
3706 double GrapheneLUT3DPotentialGenerate::grad2V_64(
3707 double x,
double y,
double z,
double sigma,
double epsilon,
3708 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3709 TinyVector<double,2> g_m, TinyVector<double,2> g_n, Array<int,1> g_i_array,
3710 Array<int,1> g_j_array, Array<double,1> g_magnitude_array ) {
3712 bool flag_1 =
false;
3713 bool flag_2 =
false;
3714 bool flag_3 =
false;
3715 TinyVector <double,2> g;
3716 double pf = 2*M_PI*epsilon*pow(sigma,2)/area_lattice;
3718 _V += 2*grad2Vz_64(z, sigma);
3719 double _V_old = 0.0;
3723 for (
int k = 1; k < 2*k_max; k++) {
3726 g = (g_i * g_m) + (g_j * g_n);
3727 g_magnitude = g_magnitude_array(k);
3728 _V += grad2Vg_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_1[0], b_1[1]);
3729 _V += grad2Vg_64(x, y, z, sigma, g_magnitude, g[0], g[1], b_2[0], b_2[1]);
3731 if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_1)) {
3735 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_2)) {
3739 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && (!flag_3)) {
3743 else if ((_V == _V_old) && (g_magnitude != g_magnitude_array(k+1)) && flag_1 && flag_2 && flag_3) {
3747 else if ((k >= k_max) && (g_magnitude != g_magnitude_array(k+1))) {
3758 std::tuple< TinyVector<double,2>, TinyVector<double,2>, TinyVector<double,2>,
3759 TinyVector<double,2>, TinyVector<double,2>, TinyVector<double,2>
3760 > GrapheneLUT3DPotentialGenerate::get_graphene_vectors() {
3761 return get_graphene_vectors(0.00);
3764 std::tuple< TinyVector<double,2>, TinyVector<double,2>, TinyVector<double,2>,
3765 TinyVector<double,2>, TinyVector<double,2>, TinyVector<double,2>
3766 > GrapheneLUT3DPotentialGenerate::get_graphene_vectors(
double strain ) {
3767 return get_graphene_vectors(strain, 1.42, 0.165);
3770 std::tuple< TinyVector<double,2>, TinyVector<double,2>, TinyVector<double,2>,
3771 TinyVector<double,2>, TinyVector<double,2>, TinyVector<double,2>
3772 > GrapheneLUT3DPotentialGenerate::get_graphene_vectors(
3773 double strain,
double carbon_carbon_distance,
double poisson_ratio) {
3774 Array<double,2> R_strain(2,2);
3775 R_strain = -strain*poisson_ratio, 0,
3778 TinyVector <double,2> A_m_strain0( (carbon_carbon_distance/2)*sqrt(3) , (carbon_carbon_distance/2)*3 );
3779 TinyVector <double,2> A_m( (carbon_carbon_distance/2)*sqrt(3)*(1 - strain*poisson_ratio) ,
3780 (carbon_carbon_distance/2)*3*(1 + strain) );
3782 TinyVector <double,2> A_n_strain0( -(carbon_carbon_distance/2)*sqrt(3) , (carbon_carbon_distance/2)*3 );
3783 TinyVector <double,2> A_n( -(carbon_carbon_distance/2)*sqrt(3)*(1 - strain*poisson_ratio) ,
3784 (carbon_carbon_distance/2)*3*(1 + strain) );
3787 TinyVector <double,2> A_m_60_strain0( carbon_carbon_distance*sqrt(3) , 0 );
3788 TinyVector <double,2> A_m_60 = A_m_60_strain0;
3789 A_m_60(0) += R_strain(0,0)*A_m_60_strain0(0) + R_strain(0,1)*A_m_60_strain0(1);
3790 A_m_60(1) += R_strain(1,0)*A_m_60_strain0(0) + R_strain(1,1)*A_m_60_strain0(1);
3792 TinyVector <double,2> A_n_60_strain0( (carbon_carbon_distance/2)*sqrt(3) , (carbon_carbon_distance/2)*3 );
3793 TinyVector <double,2> A_n_60 = A_n_60_strain0;
3794 A_n_60(0) += R_strain(0,0)*A_n_60_strain0(0) + R_strain(0,1)*A_n_60_strain0(1);
3795 A_n_60(1) += R_strain(1,0)*A_n_60_strain0(0) + R_strain(1,1)*A_n_60_strain0(1);
3799 TinyVector <double,2> b_1( 0, carbon_carbon_distance*(1 + strain) );
3800 TinyVector <double,2> b_2( 0, carbon_carbon_distance*2*(1 + strain) );
3803 TinyVector <double,2> g_m( 3/(1 - strain*poisson_ratio) , sqrt(3)/(1 + strain) );
3804 g_m *= (2*M_PI/3/carbon_carbon_distance);
3805 TinyVector <double,2> g_n( -g_m[0] , g_m[1] );
3807 TinyVector <double,2> g_m_60( sqrt(3)/(1 - strain*poisson_ratio), -1/(1 + strain) );
3808 g_m_60 *= (2*M_PI/3/carbon_carbon_distance);
3809 TinyVector <double,2> g_n_60( 0 , 1/(1 + strain) );
3810 g_n_60 *= (4*M_PI/3/carbon_carbon_distance);
3812 return { A_m_60, A_n_60, b_1, b_2, g_m_60, g_n_60 };
3815 std::tuple< TinyVector<double,2>, TinyVector<double,2>, TinyVector<double,2>,
3816 TinyVector<double,2>, TinyVector<double,2>, TinyVector<double,2>
3817 > GrapheneLUT3DPotentialGenerate::get_graphene_vectors_old(
3818 double strain,
double carbon_carbon_distance,
double poisson_ratio) {
3819 TinyVector <double,2> A_m_old( sqrt(3)*(4 + strain - 3*strain*poisson_ratio) ,
3820 3*(4 + 3*strain - strain*poisson_ratio) );
3821 A_m_old *= (carbon_carbon_distance/8);
3822 TinyVector <double,2> A_n_old( sqrt(3)*(-4 - strain + 3*strain*poisson_ratio),
3823 3*(4 + 3*strain - strain*poisson_ratio) );
3824 A_n_old *= (carbon_carbon_distance/8);
3827 TinyVector <double,2> b_1( 0 , carbon_carbon_distance*(1 + strain) );
3828 TinyVector <double,2> b_2( 0 , carbon_carbon_distance*2*(1 + strain) );
3831 TinyVector <double,2> g_m_old( sqrt(3)*(4 + 3*strain - strain*poisson_ratio)/((4 + strain - 3*strain*poisson_ratio)*(4 + 3*strain - strain*poisson_ratio)),
3832 (4 + strain - 3*strain*poisson_ratio)/((4 + strain - 3*strain*poisson_ratio)*(4 + 3*strain - strain*poisson_ratio)) );
3833 g_m_old *= (8*M_PI/3/carbon_carbon_distance);
3834 TinyVector <double,2> g_n_old( -g_m_old[0], g_m_old[1] );
3836 return { A_m_old, A_n_old, b_1, b_2, g_m_old, g_n_old };
3839 std::tuple< Array<int,1>, Array<int,1>, Array<double,1> >
3840 GrapheneLUT3DPotentialGenerate::get_g_magnitudes(
3841 TinyVector<double,2> g_m, TinyVector<double,2> g_n ) {
3842 int number_of_g_i = 200;
3843 int number_of_g_j = 200;
3845 int size_of_arrays = pow(number_of_g_i + number_of_g_j + 1,2);
3846 Array<double,1> g_magnitude_array(size_of_arrays);
3847 Array<int,1> g_i_array(size_of_arrays);
3848 Array<int,1> g_j_array(size_of_arrays);
3850 TinyVector<double,2> g;
3852 for (
int g_i = -number_of_g_i; g_i < number_of_g_i + 1; g_i++) {
3853 for (
int g_j = -number_of_g_j; g_j < number_of_g_j + 1; g_j++){
3854 g = (g_i * g_m) + (g_j * g_n);
3855 g_magnitude_array(k) = sqrt(dot(g,g));
3861 int sort_indeces[size_of_arrays];
3862 for (
int i = 0; i < size_of_arrays; i++) {
3863 sort_indeces[i] = i;
3868 std::stable_sort( sort_indeces, sort_indeces + size_of_arrays,
3869 [&g_magnitude_array] (
int i,
int j) {
return g_magnitude_array(i) < g_magnitude_array(j);});
3876 Array<double,1> g_magnitude_array2(size_of_arrays);
3877 Array<int,1> g_i_array2(size_of_arrays);
3878 Array<int,1> g_j_array2(size_of_arrays);
3880 for (
int i = 0; i < size_of_arrays; i++) {
3881 int p = sort_indeces[i];
3883 g_magnitude_array2(i) = g_magnitude_array(p);
3884 g_i_array2(i) = g_i_array(p);
3885 g_j_array2(i) = g_j_array(p);
3887 return std::make_tuple(g_i_array2, g_j_array2, g_magnitude_array2);
3891 void GrapheneLUT3DPotentialGenerate::calculate_V3D_64(
3892 Array<double,3> V3D, Array<double,2> xy_x, Array<double,2> xy_y,
3893 Array<double,1> z_range,
double sigma,
double epsilon,
3894 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3895 TinyVector<double,2> g_m, TinyVector<double,2> g_n,
3896 Array<int,1> g_i_array, Array<int,1> g_j_array,
3897 Array<double,1> g_magnitude_array ) {
3901 for (
int k = 0; k < V3D.shape()[2]; k++) {
3903 for (
int j = 0; j < V3D.shape()[1]; j++) {
3904 for (
int i = 0; i < V3D.shape()[0]; i++) {
3907 V3D(i,j,k) = V_64(x,y,z,sigma,epsilon,area_lattice,b_1,b_2,g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
3913 void GrapheneLUT3DPotentialGenerate::calculate_gradV3D_x_64(
3914 Array<double,3> V3D, Array<double,2> xy_x, Array<double,2> xy_y,
3915 Array<double,1> z_range,
double sigma,
double epsilon,
3916 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3917 TinyVector<double,2> g_m, TinyVector<double,2> g_n,
3918 Array<int,1> g_i_array, Array<int,1> g_j_array,
3919 Array<double,1> g_magnitude_array ) {
3923 for (
int k = 0; k < V3D.shape()[2]; k++) {
3925 for (
int j = 0; j < V3D.shape()[1]; j++) {
3926 for (
int i = 0; i < V3D.shape()[0]; i++) {
3929 V3D(i,j,k) = gradV_x_64(x,y,z,sigma,epsilon,area_lattice,b_1,b_2,g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
3935 void GrapheneLUT3DPotentialGenerate::calculate_gradV3D_y_64(
3936 Array<double,3> V3D, Array<double,2> xy_x, Array<double,2> xy_y,
3937 Array<double,1> z_range,
double sigma,
double epsilon,
3938 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3939 TinyVector<double,2> g_m, TinyVector<double,2> g_n,
3940 Array<int,1> g_i_array, Array<int,1> g_j_array,
3941 Array<double,1> g_magnitude_array ) {
3945 for (
int k = 0; k < V3D.shape()[2]; k++) {
3947 for (
int j = 0; j < V3D.shape()[1]; j++) {
3948 for (
int i = 0; i < V3D.shape()[0]; i++) {
3951 V3D(i,j,k) = gradV_y_64(x,y,z,sigma,epsilon,area_lattice,b_1,b_2,g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
3957 void GrapheneLUT3DPotentialGenerate::calculate_gradV3D_z_64(
3958 Array<double,3> V3D, Array<double,2> xy_x, Array<double,2> xy_y,
3959 Array<double,1> z_range,
double sigma,
double epsilon,
3960 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3961 TinyVector<double,2> g_m, TinyVector<double,2> g_n,
3962 Array<int,1> g_i_array, Array<int,1> g_j_array,
3963 Array<double,1> g_magnitude_array ) {
3967 for (
int k = 0; k < V3D.shape()[2]; k++) {
3969 for (
int j = 0; j < V3D.shape()[1]; j++) {
3970 for (
int i = 0; i < V3D.shape()[0]; i++) {
3973 V3D(i,j,k) = gradV_z_64(x,y,z,sigma,epsilon,area_lattice,b_1,b_2,g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
3979 void GrapheneLUT3DPotentialGenerate::calculate_grad2V3D_64(
3980 Array<double,3> V3D, Array<double,2> xy_x, Array<double,2> xy_y,
3981 Array<double,1> z_range,
double sigma,
double epsilon,
3982 double area_lattice, TinyVector<double,2> b_1, TinyVector<double,2> b_2,
3983 TinyVector<double,2> g_m, TinyVector<double,2> g_n,
3984 Array<int,1> g_i_array, Array<int,1> g_j_array,
3985 Array<double,1> g_magnitude_array ) {
3989 for (
int k = 0; k < V3D.shape()[2]; k++) {
3991 for (
int j = 0; j < V3D.shape()[1]; j++) {
3992 for (
int i = 0; i < V3D.shape()[0]; i++) {
3995 V3D(i,j,k) = grad2V_64(x,y,z,sigma,epsilon,area_lattice,b_1,b_2,g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
4001 std::pair<double, double> GrapheneLUT3DPotentialGenerate::get_z_min_V_min(
double x,
double y,
4002 double sigma,
double epsilon,
double area_lattice,
4003 TinyVector<double,2> b_1, TinyVector<double,2> b_2,
4004 TinyVector<double,2> g_m, TinyVector<double,2> g_n,
4005 Array<int,1> g_i_array, Array<int,1> g_j_array,
4006 Array<double,1> g_magnitude_array ) {
4008 double z_min_limit = 1.0;
4009 double z_max_limit = 5.0;
4010 const int double_bits = std::numeric_limits<double>::digits/2;
4012 std::pair<double, double> r = boost::math::tools::brent_find_minima(
4013 std::bind( &GrapheneLUT3DPotentialGenerate::V_64,
this, x, y, std::placeholders::_1, sigma, epsilon,
4014 area_lattice, b_1, b_2, g_m, g_n, g_i_array, g_j_array,
4015 g_magnitude_array ),
4016 z_min_limit, z_max_limit, double_bits);
4021 std::pair<double, double> GrapheneLUT3DPotentialGenerate::get_z_V_to_find(
4022 double sigma,
double epsilon,
double area_lattice,
4023 TinyVector<double,2> b_1, TinyVector<double,2> b_2,
4024 TinyVector<double,2> g_m, TinyVector<double,2> g_n,
4025 Array<int,1> g_i_array, Array<int,1> g_j_array,
4026 Array<double,1> g_magnitude_array ) {
4027 double V_to_find = 10000.0;
4028 TinyVector<double,2> center_of_hexagon(0.0, 0.0);
4029 TinyVector<double,2> above_A_site(b_1[0],b_1[1]);
4030 double x = center_of_hexagon(0);
4031 double y = center_of_hexagon(1);
4033 auto [_z_min, _V_min] = get_z_min_V_min(x,y,sigma,epsilon,area_lattice,b_1,b_2,g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
4035 double z_min_limit = 0.0;
4036 double z_max_limit = _z_min;
4037 const int double_bits = std::numeric_limits<double>::digits/2;
4040 auto _f_V_64 = std::bind( &GrapheneLUT3DPotentialGenerate::V_64,
this, x, y, std::placeholders::_1, sigma, epsilon,
4041 area_lattice, b_1, b_2, g_m, g_n, g_i_array, g_j_array,
4042 g_magnitude_array );
4043 auto _g_lambda = [&_f_V_64](
double _z,
double _V) {
return fabs(_f_V_64(_z) - _V); };
4044 auto _g_bind = std::bind(_g_lambda, std::placeholders::_1, V_to_find);
4045 std::pair<double, double> r = boost::math::tools::brent_find_minima(
4046 _g_bind, z_min_limit, z_max_limit, double_bits);
4048 double _z_V_to_find = r.first;
4049 double _found_V = V_64(above_A_site(0), above_A_site(1), _z_V_to_find,
4050 sigma,epsilon,area_lattice,b_1,b_2,g_m,g_n,g_i_array,g_j_array,
4053 return { _z_V_to_find, _found_V };
4056 Array<double,3> GrapheneLUT3DPotentialGenerate::get_V3D(
4057 double strain,
double sigma,
double epsilon,
int x_res,
int y_res,
4058 int z_res,
double z_min,
double z_max ) {
4059 auto [A_m, A_n, b_1, b_2, g_m, g_n] = get_graphene_vectors(strain);
4060 auto [g_i_array, g_j_array, g_magnitude_array] = get_g_magnitudes(g_m,g_n);
4062 double cell_length_a = calculate_magnitude(A_m);
4063 double cell_length_b = calculate_magnitude(A_n);
4065 double cell_angle_gamma= calculate_angle(A_m,A_n);
4067 double area_lattice = cell_length_a * cell_length_b * sin(cell_angle_gamma);
4069 Array<double,1> uc_x_range(x_res);
4070 double uc_x_min = 0.0;
4071 double uc_x_max = cell_length_a;
4072 double delta_uc_x = (uc_x_max - uc_x_min) / (x_res - 1);
4074 for (
int i=0; i < x_res - 1; ++i) {
4075 uc_x_range(i) = uc_x_min + (delta_uc_x * i);
4077 uc_x_range(x_res - 1) = uc_x_max;
4081 Array<double,1> uc_y_range(y_res);
4082 double uc_y_min = 0.0;
4083 double uc_y_max = cell_length_b;
4084 double delta_uc_y = (uc_y_max - uc_y_min) / (y_res - 1);
4086 for (
int i=0; i < y_res - 1; ++i) {
4087 uc_y_range(i) = uc_y_min + (delta_uc_y * i);
4089 uc_y_range(y_res - 1) = uc_y_max;
4093 Array<double,2> uc_xy_x(x_res,y_res);
4095 Array<double,2> uc_xy_y(x_res,y_res);
4098 for (
int i=0; i < x_res; ++i) {
4099 for(
int j=0; j < y_res; ++j) {
4100 uc_xy_x(i,j) = uc_x_range(i);
4101 uc_xy_y(i,j) = uc_y_range(j);
4106 Array<double,2> B(2,2);
4107 B = 1, cos(cell_angle_gamma),
4108 0, sin(cell_angle_gamma);
4112 Array<double,2> A(2,2);
4116 A = 1, -1/tan(cell_angle_gamma),
4117 0, 1/sin(cell_angle_gamma);
4120 Array<double,2> xy_x(x_res,y_res);
4121 Array<double,2> xy_y(x_res,y_res);
4123 for (
int i=0; i < x_res; ++i) {
4124 for(
int j=0; j < y_res; ++j) {
4128 xy_x(i,j) = B(0,0)*uc_x_range(i) + B(0,1)*uc_y_range(j);
4129 xy_y(i,j) = B(1,0)*uc_x_range(i) + B(1,1)*uc_y_range(j);
4134 Array<double,1> z_range(z_res);
4135 double delta_z = (z_max - z_min) / (z_res - 1);
4137 for (
int i=0; i < z_res - 1; ++i) {
4138 z_range(i) = z_min + (delta_z * i);
4140 z_range(z_res - 1) = z_max;
4144 Array<double,3> _V3D(x_res,y_res,z_res);
4146 calculate_V3D_64(_V3D,xy_x,xy_y,z_range,sigma,epsilon,area_lattice,b_1,b_2,
4147 g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
4151 std::pair<Array<double,3> , Array<double,1>> GrapheneLUT3DPotentialGenerate::get_V3D(
4152 double strain,
double sigma,
double epsilon,
int x_res,
int y_res,
4153 int z_res,
double z_max ) {
4154 auto [A_m, A_n, b_1, b_2, g_m, g_n] = get_graphene_vectors(strain);
4155 auto [g_i_array, g_j_array, g_magnitude_array] = get_g_magnitudes(g_m,g_n);
4157 double cell_length_a = calculate_magnitude(A_m);
4158 double cell_length_b = calculate_magnitude(A_n);
4160 double cell_angle_gamma= calculate_angle(A_m,A_n);
4162 double area_lattice = cell_length_a * cell_length_b * sin(cell_angle_gamma);
4164 Array<double,1> uc_x_range(x_res);
4165 double uc_x_min = 0.0;
4166 double uc_x_max = cell_length_a;
4167 double delta_uc_x = (uc_x_max - uc_x_min) / (x_res - 1);
4169 for (
int i=0; i < x_res - 1; ++i) {
4170 uc_x_range(i) = uc_x_min + (delta_uc_x * i);
4172 uc_x_range(x_res - 1) = uc_x_max;
4174 double uc_dx = uc_x_range(1) - uc_x_range(0);
4176 Array<double,1> uc_y_range(y_res);
4177 double uc_y_min = 0.0;
4178 double uc_y_max = cell_length_b;
4179 double delta_uc_y = (uc_y_max - uc_y_min) / (y_res - 1);
4181 for (
int i=0; i < y_res - 1; ++i) {
4182 uc_y_range(i) = uc_y_min + (delta_uc_y * i);
4184 uc_y_range(y_res - 1) = uc_y_max;
4186 double uc_dy = uc_y_range(1) - uc_y_range(0);
4188 Array<double,2> uc_xy_x(x_res,y_res);
4190 Array<double,2> uc_xy_y(x_res,y_res);
4193 for (
int i=0; i < x_res; ++i) {
4194 for(
int j=0; j < y_res; ++j) {
4195 uc_xy_x(i,j) = uc_x_range(i);
4196 uc_xy_y(i,j) = uc_y_range(j);
4201 Array<double,2> B(2,2);
4202 B = 1, cos(cell_angle_gamma),
4203 0, sin(cell_angle_gamma);
4207 Array<double,2> A(2,2);
4211 A = 1, -1/tan(cell_angle_gamma),
4212 0, 1/sin(cell_angle_gamma);
4215 Array<double,2> xy_x(x_res,y_res);
4216 Array<double,2> xy_y(x_res,y_res);
4218 for (
int i=0; i < x_res; ++i) {
4219 for(
int j=0; j < y_res; ++j) {
4223 xy_x(i,j) = B(0,0)*uc_x_range(i) + B(0,1)*uc_y_range(j);
4224 xy_y(i,j) = B(1,0)*uc_x_range(i) + B(1,1)*uc_y_range(j);
4228 auto [z_min, V_z_min] = get_z_V_to_find(sigma,epsilon,area_lattice,b_1,b_2,g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
4230 Array<double,1> z_range(z_res);
4231 double delta_z = (z_max - z_min) / (z_res - 1);
4233 for (
int i=0; i < z_res - 1; ++i) {
4234 z_range(i) = z_min + (delta_z * i);
4236 z_range(z_res - 1) = z_max;
4238 double dz = z_range(1) - z_range(0);
4240 Array<double,3> _V3D(x_res,y_res,z_res);
4242 calculate_V3D_64(_V3D,xy_x,xy_y,z_range,sigma,epsilon,area_lattice,b_1,b_2,
4243 g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
4245 Array<double,1> _LUTinfo(12);
4246 _LUTinfo = A(0,0), A(0,1), A(1,0), A(1,1), uc_dx, uc_dy, dz, cell_length_a,
4247 cell_length_b, z_min, z_max, V_z_min;
4249 return { _V3D, _LUTinfo };
4252 std::tuple< Array<double,3>, Array<double,3>, Array<double,3>, Array<double,3>,
4253 Array<double,3>, Array<double,2>, Array<double,2>, Array<double,1>
4254 > GrapheneLUT3DPotentialGenerate::get_V3D_all(
4255 double strain,
double sigma,
double epsilon,
int x_res,
int y_res,
4256 int z_res,
double z_max ) {
4258 auto [A_m, A_n, b_1, b_2, g_m, g_n] = get_graphene_vectors(strain);
4259 auto [g_i_array, g_j_array, g_magnitude_array] = get_g_magnitudes(g_m,g_n);
4261 double cell_length_a = calculate_magnitude(A_m);
4262 double cell_length_b = calculate_magnitude(A_n);
4264 double cell_angle_gamma= calculate_angle(A_m,A_n);
4266 double area_lattice = cell_length_a * cell_length_b * sin(cell_angle_gamma);
4268 Array<double,1> uc_x_range(x_res);
4269 double uc_x_min = 0.0;
4270 double uc_x_max = cell_length_a;
4271 double delta_uc_x = (uc_x_max - uc_x_min) / (x_res - 1);
4273 for (
int i=0; i < x_res - 1; ++i) {
4274 uc_x_range(i) = uc_x_min + (delta_uc_x * i);
4276 uc_x_range(x_res - 1) = uc_x_max;
4278 double uc_dx = uc_x_range(1) - uc_x_range(0);
4280 Array<double,1> uc_y_range(y_res);
4281 double uc_y_min = 0.0;
4282 double uc_y_max = cell_length_b;
4283 double delta_uc_y = (uc_y_max - uc_y_min) / (y_res - 1);
4285 for (
int i=0; i < y_res - 1; ++i) {
4286 uc_y_range(i) = uc_y_min + (delta_uc_y * i);
4288 uc_y_range(y_res - 1) = uc_y_max;
4290 double uc_dy = uc_y_range(1) - uc_y_range(0);
4292 Array<double,2> uc_xy_x(x_res,y_res);
4294 Array<double,2> uc_xy_y(x_res,y_res);
4297 for (
int i=0; i < x_res; ++i) {
4298 for(
int j=0; j < y_res; ++j) {
4299 uc_xy_x(i,j) = uc_x_range(i);
4300 uc_xy_y(i,j) = uc_y_range(j);
4305 Array<double,2> B(2,2);
4306 B = 1, cos(cell_angle_gamma),
4307 0, sin(cell_angle_gamma);
4311 Array<double,2> A(2,2);
4315 A = 1, -1/tan(cell_angle_gamma),
4316 0, 1/sin(cell_angle_gamma);
4319 Array<double,2> xy_x(x_res,y_res);
4320 Array<double,2> xy_y(x_res,y_res);
4322 for (
int i=0; i < x_res; ++i) {
4323 for(
int j=0; j < y_res; ++j) {
4327 xy_x(i,j) = B(0,0)*uc_x_range(i) + B(0,1)*uc_y_range(j);
4328 xy_y(i,j) = B(1,0)*uc_x_range(i) + B(1,1)*uc_y_range(j);
4332 auto [z_min, V_z_min] = get_z_V_to_find(sigma,epsilon,area_lattice,b_1,b_2,g_m,g_n,g_i_array,g_j_array,g_magnitude_array);
4334 Array<double,1> z_range(z_res);
4335 double delta_z = (z_max - z_min) / (z_res - 1);
4337 for (
int i=0; i < z_res - 1; ++i) {
4338 z_range(i) = z_min + (delta_z * i);
4340 z_range(z_res - 1) = z_max;
4342 double dz = z_range(1) - z_range(0);
4344 Array<double,3> _V3D(x_res,y_res,z_res);
4345 Array<double,3> _gradV3D_x(x_res,y_res,z_res);
4346 Array<double,3> _gradV3D_y(x_res,y_res,z_res);
4347 Array<double,3> _gradV3D_z(x_res,y_res,z_res);
4348 Array<double,3> _grad2V3D(x_res,y_res,z_res);
4355 calculate_V3D_64( _V3D, xy_x, xy_y, z_range, sigma, epsilon, area_lattice,
4356 b_1, b_2, g_m, g_n, g_i_array, g_j_array, g_magnitude_array );
4357 calculate_gradV3D_x_64( _gradV3D_x, xy_x, xy_y, z_range, sigma, epsilon,
4358 area_lattice, b_1, b_2, g_m, g_n, g_i_array, g_j_array,
4359 g_magnitude_array );
4360 calculate_gradV3D_y_64( _gradV3D_y, xy_x, xy_y, z_range, sigma, epsilon,
4361 area_lattice, b_1, b_2, g_m, g_n, g_i_array, g_j_array,
4362 g_magnitude_array );
4363 calculate_gradV3D_z_64( _gradV3D_z, xy_x, xy_y, z_range, sigma, epsilon,
4364 area_lattice, b_1, b_2, g_m, g_n, g_i_array, g_j_array,
4365 g_magnitude_array );
4366 calculate_grad2V3D_64( _grad2V3D, xy_x, xy_y, z_range, sigma, epsilon,
4367 area_lattice, b_1, b_2, g_m, g_n, g_i_array, g_j_array,
4368 g_magnitude_array );
4369 Array<double,1> _LUTinfo(12);
4370 _LUTinfo = A(0,0), A(0,1), A(1,0), A(1,1), uc_dx, uc_dy, dz, cell_length_a,
4371 cell_length_b, z_min, z_max, V_z_min;
4372 return { _V3D, _gradV3D_x, _gradV3D_y, _gradV3D_z, _grad2V3D, xy_x, xy_y,
4394 static auto const aflags = boost::archive::no_header | boost::archive::no_tracking;
4398 std::ifstream ifs_V3d(graphenelut3d_file_prefix +
"V3d.txt");
4400 boost::archive::text_iarchive ia_V3d(ifs_V3d,aflags);
4408 std::ifstream ifs_gradV3d_x(graphenelut3d_file_prefix +
"gradV3d_x.txt");
4410 boost::archive::text_iarchive ia_gradV3d_x(ifs_gradV3d_x,aflags);
4412 ia_gradV3d_x >> gradV3d_x;
4418 std::ifstream ifs_gradV3d_y(graphenelut3d_file_prefix +
"gradV3d_y.txt");
4420 boost::archive::text_iarchive ia_gradV3d_y(ifs_gradV3d_y,aflags);
4422 ia_gradV3d_y >> gradV3d_y;
4428 std::ifstream ifs_gradV3d_z(graphenelut3d_file_prefix +
"gradV3d_z.txt");
4430 boost::archive::text_iarchive ia_gradV3d_z(ifs_gradV3d_z,aflags);
4432 ia_gradV3d_z >> gradV3d_z;
4438 std::ifstream ifs_grad2V3d(graphenelut3d_file_prefix +
"grad2V3d.txt");
4440 boost::archive::text_iarchive ia_grad2V3d(ifs_grad2V3d,aflags);
4442 ia_grad2V3d >> grad2V3d;
4448 std::ifstream ifs_LUTinfo(graphenelut3d_file_prefix +
"LUTinfo.txt");
4450 boost::archive::text_iarchive ia_LUTinfo(ifs_LUTinfo,aflags);
4452 ia_LUTinfo >> LUTinfo;
4457 std::ofstream ofs(graphenelut3d_file_prefix +
"serialized.dat");
4460 boost::archive::binary_oarchive oa(ofs,aflags);
4462 oa << V3d << gradV3d_x << gradV3d_y << gradV3d_z << grad2V3d << LUTinfo;
4466 std::cout <<
"Finished converting binary file " <<
4467 graphenelut3d_file_prefix +
"serialized.txt" <<
" to binary file " <<
4468 graphenelut3d_file_prefix +
"serialized.dat" <<
", exiting." <<
4495 static auto const aflags = boost::archive::no_header | boost::archive::no_tracking;
4499 std::ifstream ifs(graphenelut3d_file_prefix +
"serialized.dat");
4500 boost::archive::binary_iarchive ia(ifs,aflags);
4502 ia >> V3d >> gradV3d_x >> gradV3d_y >> gradV3d_z >> grad2V3d >> LUTinfo;
4507 std::ofstream ofs_V3d(graphenelut3d_file_prefix +
"V3d.txt");
4510 boost::archive::text_oarchive oa_V3d(ofs_V3d,aflags);
4517 std::ofstream ofs_gradV3d_x(graphenelut3d_file_prefix +
"gradV3d_x.txt");
4520 boost::archive::text_oarchive oa_gradV3d_x(ofs_gradV3d_x,aflags);
4522 oa_gradV3d_x << gradV3d_x;
4527 std::ofstream ofs_gradV3d_y(graphenelut3d_file_prefix +
"gradV3d_y.txt");
4530 boost::archive::text_oarchive oa_gradV3d_y(ofs_gradV3d_y,aflags);
4532 oa_gradV3d_y << gradV3d_y;
4537 std::ofstream ofs_gradV3d_z(graphenelut3d_file_prefix +
"gradV3d_z.txt");
4540 boost::archive::text_oarchive oa_gradV3d_z(ofs_gradV3d_z,aflags);
4542 oa_gradV3d_z << gradV3d_z;
4547 std::ofstream ofs_grad2V3d(graphenelut3d_file_prefix +
"grad2V3d.txt");
4550 boost::archive::text_oarchive oa_grad2V3d(ofs_grad2V3d,aflags);
4552 oa_grad2V3d << grad2V3d;
4557 std::ofstream ofs_LUTinfo(graphenelut3d_file_prefix +
"LUTinfo.txt");
4560 boost::archive::text_oarchive oa_LUTinfo(ofs_LUTinfo,aflags);
4562 oa_LUTinfo << LUTinfo;
4566 std::cout <<
"Finished converting binary file " <<
4567 graphenelut3d_file_prefix +
"serialized.dat" <<
" to text files " <<
4568 graphenelut3d_file_prefix +
"<V3d|gradV3d_x|gradV3d_y|gradV3d_z|grad2V3d|LUTinfo>.txt" <<
", exiting." <<
~AzizPotential()
Destructor.
dVec gradV(const dVec &)
Return the gradient of aziz potential for separation r using a lookup table.
AzizPotential(const Container *)
Constructor.
double V(const dVec &)
Return the aziz potential for separation r using a lookup table.
File * file(string type)
Get method returning file object.
double m() const
Get mass.
double lambda() const
Get lambda = hbar^2/(2mk_B)
double rc2() const
Get potential cutoff squared.
double L() const
Get maximum side length.
double tau() const
Get imaginary time step.
The base class which holds details on the generalized box that our system will be simulated inside of...
double volume
The volume of the container in A^3.
void putInBC(dVec &r) const
Place a vector in boundary conditions.
virtual void putInside(dVec &) const =0
Place a vector inside the simulation cell.
dVec side
The linear dimensions of the box.
double maxSep
The maximum possible separation for 2 beads on the same timeslice.
~Delta1DPotential()
Destructor.
double dVdlambda(const dVec &, const dVec &)
The derivative of the effective potential with respect to lambda.
double dVdtau(const dVec &, const dVec &)
The derivative of the effective potential with respect to tau.
virtual double V(const dVec &r)
The classical potential.
Delta1DPotential(double)
Constructor.
DeltaPotential(double, double)
Constructor.
~DeltaPotential()
Destructor.
DipolePotential()
Constructor.
~DipolePotential()
Destructor.
dVec gradV(const dVec &r)
The gradient of the total potential coming from the interaction of a particle with all fixed particle...
double V(const dVec &r)
The total potential coming from the interaction of a particle with all fixed particles.
~FixedAzizPotential()
Destructor.
FixedAzizPotential(const Container *)
Constructor.
Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Initial configuration corresponding to FixedAziz potential.
FixedPositionLJPotential(const double, const double, const Container *)
Constructor.
~FixedPositionLJPotential()
Destructor.
double V(const dVec &r)
Return the value of the van der Waals' interaction between a graphene sheet and a helium adatom at a ...
FreePotential()
Constructor.
~FreePotential()
Destructor.
Array< double, 1 > getExcLen()
get the exclusion lengths ay and az
Gasparini_1_Potential(double, double, const Container *)
Constructor.
Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Initial configuration corresponding to FixedAziz potential.
~Gasparini_1_Potential()
Destructor.
~GrapheneLUT3DPotentialGenerate()
Destructor.
GrapheneLUT3DPotentialGenerate(const double, const double, const double, const double, const double, const Container *)
Constructor.
~GrapheneLUT3DPotentialToBinary()
Destructor.
GrapheneLUT3DPotentialToBinary(const string, const Container *)
Constructor.
GrapheneLUT3DPotentialToText(const string, const Container *)
Constructor.
~GrapheneLUT3DPotentialToText()
Destructor.
Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Initial configuration corresponding to graphene-helium vdW potential.
dVec gradV(const dVec &)
Return the gradient of the van der Waals' interaction between a graphene sheet and a helium adatom at...
double V(const dVec &)
Return the value of the van der Waals' interaction between a graphene sheet and a helium adatom at a ...
double grad2V(const dVec &)
Return the gradient of the van der Waals' interaction between a graphene sheet and a helium adatom at...
~GrapheneLUT3DPotential()
Destructor.
GrapheneLUT3DPotential(const string, const Container *)
Constructor.
Array< dVec, 1 > initialConfig1(const Container *, MTRand &, const int)
Return an initial particle configuration.
dVec gradV(const dVec &r)
Return the gradient of the van der Waals' interaction between a graphene sheet and a helium adatom at...
Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Initial configuration corresponding to graphene-helium vdW potential.
GrapheneLUTPotential(const double, const double, const double, const double, const double, const Container *)
Constructor.
double V(const dVec &r)
Return the value of the van der Waals' interaction between a graphene sheet and a helium adatom at a ...
~GrapheneLUTPotential()
Destructor.
GraphenePotential(const double, const double, const double, const double, const double)
Constructor.
double V(const dVec &r)
Return the value of the van der Waals' interaction between a graphene sheet and a helium adatom at a ...
~GraphenePotential()
Destructor.
Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Initial configuration corresponding to graphene-helium vdW potential.
~HardCylinderPotential()
Destructor.
HardCylinderPotential(const double)
Constructor.
HardRodPotential(double)
Constructor.
double dVdlambda(const dVec &, const dVec &)
The derivative of the effective potential with respect to lambda.
~HardRodPotential()
Destructor.
virtual double V(const dVec &r)
The classical potential.
double dVdtau(const dVec &, const dVec &)
The derivative of the effective potential with respect to tau.
virtual double V(const dVec &r)
The classical potential.
double dVdlambda(const dVec &, const dVec &)
The derivative of the effective potential with respect to lambda.
~HardSpherePotential()
Destructor.
HardSpherePotential(double)
Constructor.
double dVdtau(const dVec &, const dVec &)
The derivative of the effective potential with respect to tau.
HarmonicCylinderPotential(const double)
Constructor.
~HarmonicCylinderPotential()
Destructor.
Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Initial configuration corresponding to Harmonic potential.
~HarmonicPotential()
Destructor.
LJCylinderPotential(const double)
Constructor.
~LJCylinderPotential()
Destructor.
Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Initial configuration corresponding to the LJ cylinder potential.
LJHourGlassPotential(const double, const double, const double)
Constructor.
Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Initial configuration corresponding to the LJ cylinder potential.
double V(const dVec &)
The integrated LJ hour glass potential.
Array< dVec, 1 > initialConfig1(const Container *, MTRand &, const int)
Return a set of initial positions inside the hourglass.
~LJHourGlassPotential()
Destructor.
The particle (bead) lookup table.
int fullNumBeads
The full number of active beads in beadList;.
int getTotNumGridBoxes()
Return the total number of grid boxes.
void updateGrid(const Path &)
We update the full nearest neighbor grid by filling up all data arrays at all time slices.
void updateFullInteractionList(const beadLocator &, const int)
Fill up the fullBeadList array with a list of beads in the same grid box as the supplied beadIndex an...
Array< beadLocator, 1 > fullBeadList
The full dynamic list of interacting beads.
const Container * boxPtr
The simulation cell.
int gridNumber(const dVec &)
Given a particle position, return the grid number for the nearest neighbor lookup table.
~LorentzianPotential()
Destructor.
LorentzianPotential(double, double)
Constructor.
PlatedLJCylinderPotential(const double, const double, const double, const double, const double)
Constructor.
~PlatedLJCylinderPotential()
Destructor.
Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Initial configuration corresponding to the LJ cylinder potential.
The base class from which all specific potentials are derived from.
double deltaSeparation(double sep1, double sep2) const
Return the minimum image difference for 1D separations.
PotentialBase()
Constructor.
virtual Array< dVec, 1 > initialConfig(const Container *, MTRand &, const int)
Default Initial configuration of particles.
virtual ~PotentialBase()
Destructor.
double tailV
Tail correction factor.
void output(const double)
A debug method that output's the potential to a supplied separation.
virtual Array< double, 1 > getExcLen()
Array to hold data elements.
virtual double V(const dVec &)
The potential.
~SingleWellPotential()
Destructor.
SingleWellPotential()
Constructor.
~SutherlandPotential()
Destructor.
SutherlandPotential(double)
Constructor.
~SzalewiczPotential()
Destructor.
SzalewiczPotential(const Container *)
Constructor.
Pre-tabulated potential for complicated functions.
Array< double, 1 > lookupd2Vdr2
A lookup table for d2Vint/dr2.
TabulatedPotential()
Constructor.
int tableLength
The number of elements in the lookup table.
TinyVector< double, 2 > extdVdr
Extremal value of dV/dr.
virtual ~TabulatedPotential()
Destructor.
virtual double valuedVdr(const double)=0
The functional value of dV/dr.
TinyVector< double, 2 > extV
Extremal value of V.
void initLookupTable(const double, const double)
Given a discretization factor and the system size, create and fill the lookup tables for the potentia...
Array< double, 1 > lookupdVdr
A lookup table for dVint/dr.
virtual double valued2Vdr2(const double)=0
The functional value of d2V/dr2.
virtual double valueV(const double)=0
The functional value of V.
virtual double direct(const Array< double, 1 > &, const TinyVector< double, 2 > &, const double)
Use a direct lookup for the potential table.
virtual double newtonGregory(const Array< double, 1 > &, const TinyVector< double, 2 > &, const double)
Use the Newton-Gregory forward difference method to do a 2-point lookup on the potential table.
TinyVector< double, 2 > extd2Vdr2
Extremal value of d2V/dr2.
Array< double, 1 > lookupV
A potential lookup table.
double dr
The discretization for the lookup table.
#define NDIM
Number of spatial dimnsions.
int ipow(int base, int power)
Return the integer value of a number raised to a power.
#define EPS
A small number.
#define LBIG
The log of a big number.
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
#define PIMC_ASSERT(X)
Rename assert method.
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.
LookupTable class definition.
All possible potential classes.