46 #if(CMK_CCS_AVAILABLE && CMK_WEB_MODE)
47 extern "C" void CApplicationDepositNode0Data(
char *);
52 #define cbrt(x) pow(x,(double)(1.0/3.0))
56 #define MIN_DEBUG_LEVEL 3
60 #define XXXBIGREAL 1.0e32
75 const char *myname,
int outputfreq)
76 : nslabs(numslabs), freq(outputfreq) {
77 name = strdup(myname);
78 nelements = 3*nslabs * numpartitions;
81 average =
new BigReal[nelements];
95 double inv_volume = 1.0 / lattice.
volume();
97 int arraysize = 3*nslabs;
98 for (i=0; i<nelements; i++) {
101 total[i % arraysize] += val;
104 if (!(step % freq)) {
108 iout <<
"PPROFILE" << name <<
": " << step <<
" ";
109 if (step == firsttimestep) {
111 for (i=0; i<nelements; i++)
112 iout << reduction->
item(i)*scalefac*inv_volume <<
" ";
116 for (i=0; i<nelements; i++)
117 iout << average[i]*scalefac <<
" ";
121 memset(average, 0, nelements*
sizeof(
BigReal));
129 computeChecksum(0), marginViolations(0), pairlistWarnings(0),
134 firstCTime(CmiTimer()),
136 firstWTime(CmiWallTimer()),
165 int npairs = (ntypes * (ntypes+1))/2;
171 nslabs, npairs,
"BONDED", freq);
173 nslabs, npairs,
"NONBONDED", freq);
176 nslabs, ntypes,
"INTERNAL", freq);
180 nslabs, npairs,
"NONBONDED", freq);
202 #define AVGXY(T) T.xy = T.yx = 0; T.xx = T.yy = 0.5 * ( T.xx + T.yy );\
203 T.xz = T.zx = T.yz = T.zy = 0.5 * ( T.xz + T.yz );
220 for (
int i=0;i < n;i++) {
271 DebugM(4,
"Starting thread in controller on this=" <<
this <<
"\n");
272 thread = CthCreate((CthVoidFn)&(threadRun),(
void*)(
this),
CTRL_STK_SZ);
273 CthSetStrategyDefault(thread);
274 #if CMK_BLUEGENE_CHARM
287 switch ( scriptTask ) {
321 NAMD_die(
"Unable to revert, checkpoint was never called!");
349 NAMD_die(
"Unable to load checkpoint, requested key was never stored.");
366 NAMD_die(
"Unable to swap checkpoint, requested key was never stored.");
383 NAMD_die(
"Unable to free checkpoint, requested key was never stored.");
404 NAMD_bug(
"Unknown task in Controller::algorithm");
423 if (sig == SIGINT) gotsigint = 1;
454 if ( zeroMomentum && dofull && ! (step %
slowFreq) )
462 traceUserEvent(eventEndOfTimeStep);
463 sprintf(traceNote,
"s:%d", step);
464 traceUserSuppliedNote(traceNote);
476 for ( ++step ; step <= numberOfSteps; ++step )
488 if ( zeroMomentum && dofull && ! (step %
slowFreq) )
502 traceUserEvent(eventEndOfTimeStep);
503 sprintf(traceNote,
"s:%d", step);
504 traceUserSuppliedNote(traceNote);
530 #ifdef MEASURE_NAMD_WITH_PAPI
532 int bstep =
simParams->papiMeasureStartStep;
533 int estep = bstep +
simParams->numPapiMeasureSteps;
535 papiMeasureBarrier(1, step);
538 papiMeasureBarrier(0, step);
554 printMinimizeEnergies(step); \
555 outputExtendedSystem(step); \
556 rebalanceLoad(step); \
557 if ( step == numberOfSteps ) return; \
561 if ( step == numberOfSteps ) { \
562 if ( minVerbose ) { iout << "LINE MINIMIZER: RETURNING TO " << mid.x << " FROM " << last.x << "\n" << endi; } \
563 if ( newDir || (mid.x-last.x) ) { \
564 broadcast->minimizeCoefficient.publish(minSeq++,mid.x-last.x); \
566 broadcast->minimizeCoefficient.publish(minSeq++,0.); \
567 broadcast->minimizeCoefficient.publish(minSeq++,0.); \
568 min_reduction->require(); \
569 broadcast->minimizeCoefficient.publish(minSeq++,0.); \
571 enqueueCollections(step); \
573 } else if ( (X)-last.x ) { \
574 broadcast->minimizeCoefficient.publish(minSeq++,(X)-last.x); \
577 enqueueCollections(step); \
579 last.u = min_energy; \
580 last.dudx = -1. * min_f_dot_v; \
581 last.noGradient = min_huge_count; \
582 if ( minVerbose ) { \
583 iout << "LINE MINIMIZER: POSITION " << last.x << " ENERGY " << last.u << " GRADIENT " << last.dudx; \
584 if ( last.noGradient ) iout << " HUGECOUNT " << last.noGradient; \
585 iout << "\n" << endi; \
602 const BigReal goldenRatio = 0.5 * ( sqrt(5.0) - 1.0 );
609 int old_min_huge_count = 2000000000;
610 int steps_at_same_min_huge_count = 0;
611 for (
int i_slow = 0;
min_huge_count && i_slow < 100; ++i_slow ) {
613 if ( ++steps_at_same_min_huge_count > 10 )
break;
616 steps_at_same_min_huge_count = 0;
626 iout <<
"MINIMIZER STARTING CONJUGATE GRADIENT ALGORITHM\n" <<
endi;
629 int errorFactor = 10;
648 iout <<
"LINE MINIMIZER: POSITION " << last.
x <<
" ENERGY " << last.
u <<
" GRADIENT " << last.
dudx;
653 iout <<
"LINE MINIMIZER REDUCING GRADIENT FROM " <<
654 fabs(min_f_dot_v) <<
" TO " << tol <<
"\n" <<
endi;
660 while ( last.
u < mid.
u ) {
661 if ( last.
dudx < mid.
dudx * (5.5 - x/maxstep)/5. ) {
662 x = 6 * maxstep;
break;
664 lo = mid; mid = last;
666 if ( x > 5.5 * maxstep )
break;
669 if ( x > 5.5 * maxstep ) {
670 iout <<
"MINIMIZER RESTARTING CONJUGATE GRADIENT ALGORITHM DUE TO POOR PROGRESS\n" <<
endi;
680 #define PRINT_BRACKET \
681 iout << "LINE MINIMIZER BRACKET: DX " \
682 << (mid.x-lo.x) << " " << (hi.x-mid.x) << \
683 " DU " << (mid.u-lo.u) << " " << (hi.u-mid.u) << " DUDX " << \
684 lo.dudx << " " << mid.dudx << " " << hi.dudx << " \n" << endi;
688 for ( itcnt = 10; itcnt > 0; --itcnt ) {
692 if ( ( mid.
x - lo.
x ) > ( hi.
x - mid.
x ) ) {
693 x = (1.0 - goldenRatio) * lo.
x + goldenRatio * mid.
x;
695 if ( last.
u <= mid.
u ) {
696 hi = mid; mid = last;
701 x = (1.0 - goldenRatio) * hi.
x + goldenRatio * mid.
x;
703 if ( last.
u <= mid.
u ) {
704 lo = mid; mid = last;
710 if ( mid.
dudx > 0. ) {
711 BigReal altxhi = 0.1 * lo.
x + 0.9 * mid.
x;
712 BigReal altxlo = 0.9 * lo.
x + 0.1 * mid.
x;
713 x = mid.
dudx*(mid.
x*mid.
x-lo.
x*lo.
x) + 2*mid.
x*(lo.
u-mid.
u);
715 if ( xdiv ) x /= xdiv;
else x = last.
x;
716 if ( x > altxhi ) x = altxhi;
717 if ( x < altxlo ) x = altxlo;
718 if ( x-last.
x == 0 )
break;
720 if ( last.
u <= mid.
u ) {
721 hi = mid; mid = last;
723 if ( lo.
dudx < 0. && last.
dudx > 0. ) progress = 0;
727 BigReal altxlo = 0.1 * hi.
x + 0.9 * mid.
x;
728 BigReal altxhi = 0.9 * hi.
x + 0.1 * mid.
x;
729 x = mid.
dudx*(mid.
x*mid.
x-hi.
x*hi.
x) + 2*mid.
x*(hi.
u-mid.
u);
731 if ( xdiv ) x /= xdiv;
else x = last.
x;
732 if ( x < altxlo ) x = altxlo;
733 if ( x > altxhi ) x = altxhi;
734 if ( x-last.
x == 0 )
break;
736 if ( last.
u <= mid.
u ) {
737 lo = mid; mid = last;
739 if ( hi.
dudx > 0. && last.
dudx < 0. ) progress = 0;
749 if ( fabs(last.
dudx) < tol )
break;
750 if ( lo.
x != mid.
x && (lo.
u-mid.
u) < tol * (mid.
x-lo.
x) )
break;
751 if ( mid.
x != hi.
x && (hi.
u-mid.
u) < tol * (hi.
x-mid.
x) )
break;
756 c = ( c > 1.5 ? 1.5 : c );
757 if ( atStart ) { c = 0; --atStart; }
760 if ( errorFactor < 100 ) errorFactor += 10;
763 iout <<
"MINIMIZER RESTARTING CONJUGATE GRADIENT ALGORITHM\n" <<
endi;
783 BigReal NGfac = 1.0/sqrt(3.0*NG + 1.0);
794 BigReal velScale = exp(-s*NGfac*(1.0 + 1.0/NG)*multigratorXiT);
800 if (callNumber == 1) {
831 calcPressure(step, 0, virial_normal, virial_nbond, virial_slow,
832 intVirial_normal, intVirial_nbond, intVirial_slow,
833 extForce_normal, extForce_nbond, extForce_slow);
834 if (callNumber == 2) {
864 for (
int i=n-1;i >= 0;i--) {
868 }
else if (i == n-1) {
900 for (
int i=0;i < n;i++) {
904 }
else if (i == n-1) {
938 BigReal W = (3.0*NG + 1.0)*kT0*tauV*tauV;
966 #define LIMIT_SCALING(VAR,MIN,MAX,FLAG) {\
967 if ( VAR < (MIN) ) { VAR = (MIN); FLAG = 1; } \
968 if ( VAR > (MAX) ) { VAR = (MAX); FLAG = 1; } }
976 " cell rescaling factor limited.\n" <<
endi;
999 #ifdef DEBUG_PRESSURE
1000 iout <<
iINFO <<
"entering langevinPiston1, strain rate: " << strainRate <<
"\n";
1006 BigReal f1 = exp( -0.5 * dt_long * gamma );
1007 BigReal f2 = sqrt( ( 1. - f1*f1 ) * kT / mass );
1023 #ifdef DEBUG_PRESSURE
1024 iout <<
iINFO <<
"applying langevin, strain rate: " << strainRate <<
"\n";
1038 strainRate += ( 0.5 * dt * cellDims *
state->lattice.
volume() / mass ) *
1048 #ifdef DEBUG_PRESSURE
1049 iout <<
iINFO <<
"integrating half step, strain rate: " << strainRate <<
"\n";
1058 factor.
xx = exp( dt_long * strainRate.xx );
1059 factor.
yy = exp( dt_long * strainRate.yy );
1061 factor.
xx = factor.
yy = 1;
1063 factor.
zz = exp( dt_long * strainRate.zz );
1066 #ifdef DEBUG_PRESSURE
1067 iout <<
iINFO <<
"rescaling by: " << factor <<
"\n";
1077 factor.
xx = exp( dt_long * strainRate.xx );
1078 factor.
yy = exp( dt_long * strainRate.yy );
1080 factor.
xx = factor.
yy = 1;
1082 factor.
zz = exp( dt_long * strainRate.zz );
1088 #ifdef DEBUG_PRESSURE
1100 factor.
xx = factor.
yy = 1;
1112 #ifdef DEBUG_PRESSURE
1113 iout <<
iINFO <<
"correcting strain rate for nbond, ";
1115 strainRate -= ( 0.5 * dt * cellDims *
state->lattice.
volume() / mass ) *
1117 #ifdef DEBUG_PRESSURE
1118 iout <<
"strain rate: " << strainRate <<
"\n";
1123 #ifdef DEBUG_PRESSURE
1124 iout <<
iINFO <<
"correcting strain rate for slow, ";
1126 strainRate -= ( 0.5 * dt * cellDims *
state->lattice.
volume() / mass ) *
1128 #ifdef DEBUG_PRESSURE
1129 iout <<
"strain rate: " << strainRate <<
"\n";
1157 #ifdef DEBUG_PRESSURE
1158 iout <<
iINFO <<
"correcting strain rate for nbond, ";
1160 strainRate += ( 0.5 * dt * cellDims *
state->lattice.
volume() / mass ) *
1162 #ifdef DEBUG_PRESSURE
1163 iout <<
"strain rate: " << strainRate <<
"\n";
1168 #ifdef DEBUG_PRESSURE
1169 iout <<
iINFO <<
"correcting strain rate for slow, ";
1171 strainRate += ( 0.5 * dt * cellDims *
state->lattice.
volume() / mass ) *
1173 #ifdef DEBUG_PRESSURE
1174 iout <<
"strain rate: " << strainRate <<
"\n";
1188 strainRate += ( 0.5 * dt * cellDims *
state->lattice.
volume() / mass ) *
1192 #ifdef DEBUG_PRESSURE
1193 iout <<
iINFO <<
"integrating half step, strain rate: " << strainRate <<
"\n";
1196 if ( ! ( step % slowFreq ) )
1199 BigReal f1 = exp( -0.5 * dt_long * gamma );
1200 BigReal f2 = sqrt( ( 1. - f1*f1 ) * kT / mass );
1215 #ifdef DEBUG_PRESSURE
1216 iout <<
iINFO <<
"applying langevin, strain rate: " << strainRate <<
"\n";
1220 #ifdef DEBUG_PRESSURE
1221 iout <<
iINFO <<
"exiting langevinPiston2, strain rate: " << strainRate <<
"\n";
1236 if ( rescaleFreq > 0 ) {
1245 BigReal factor = sqrt(rescaleTemp/avgTemp);
1263 if ( momentum.
length2() == 0. )
1264 iout <<
iERROR <<
"Momentum is exactly zero; probably a bug.\n" <<
endi;
1266 NAMD_die(
"Total mass is zero in Controller::correctMomentum");
1268 momentum *= (-1./mass);
1283 iout <<
"FEP: RESETTING FOR NEW FEP WINDOW "
1284 <<
"LAMBDA SET TO " << alchLambda <<
" LAMBDA2 " << alchLambda2;
1285 if ( alchLambdaIDWS >= 0. ) {
1286 iout <<
" LAMBDA_IDWS " << alchLambdaIDWS;
1288 iout <<
"\nFEP: WINDOW TO HAVE " << alchEquilSteps
1289 <<
" STEPS OF EQUILIBRATION PRIOR TO FEP DATA COLLECTION.\n"
1290 <<
"FEP: USING CONSTANT TEMPERATURE OF " << alchTemp
1291 <<
" K FOR FEP CALCULATION\n" <<
endi;
1300 iout <<
"TI: RESETTING FOR NEW WINDOW "
1301 <<
"LAMBDA SET TO " << alchLambda
1302 <<
"\nTI: WINDOW TO HAVE " << alchEquilSteps
1303 <<
" STEPS OF EQUILIBRATION PRIOR TO TI DATA COLLECTION.\n" <<
endi;
1311 if ( ( reassignFreq > 0 ) && ! ( step % reassignFreq ) ) {
1318 if ( newTemp < simParams->reassignHold )
1321 iout <<
"REASSIGNING VELOCITIES AT STEP " << step
1322 <<
" TO " << newTemp <<
" KELVIN.\n" <<
endi;
1366 double coefficient = 1;
1390 static char tmp_string[50];
1391 static char format_string[50];
1392 const double maxnum = 99999999999.9999;
1393 if ( X > maxnum ) X = maxnum;
1394 if ( X < -maxnum ) X = -maxnum;
1396 int whole = (decimal <= 4 ? 14 : 10 + decimal);
1397 sprintf(format_string,
" %%%d.%df", whole, decimal);
1398 sprintf(tmp_string, format_string, X);
1402 static char *
FORMAT(
const char *
X,
int decimal = 4)
1404 static char tmp_string[50];
1405 static char format_string[50];
1407 int width = (decimal <= 4 ? 14 : 10 + decimal);
1408 sprintf(format_string,
" %%%ds", width);
1409 sprintf(tmp_string, format_string, X);
1415 static char tmp_string[21];
1416 sprintf(tmp_string,
"ENERGY: %7d",X);
1457 int numFixedGroups = ( numFixedAtoms ? molecule->
numFixedGroups : 0 );
1460 if ( numFixedGroups ) numGroupDegFreedom -= 3 * numFixedGroups;
1464 numGroupDegFreedom -= 3;
1471 int numFixedRigidBonds =
1476 numDegFreedom -= ( numRigidBonds - numFixedRigidBonds - numLonepairs);
1491 BigReal groupTempHalfstep = 2.0 * groupKineticEnergyHalfstep
1493 BigReal groupTempCentered = 2.0 * groupKineticEnergyCentered
1566 virial_normal, virial_nbond, virial_slow,
1567 intVirial_normal, intVirial_nbond, intVirial_slow,
1568 extForce_normal, extForce_nbond, extForce_slow);
1570 #ifdef DEBUG_PRESSURE
1599 const Tensor& virial_normal_in,
const Tensor& virial_nbond_in,
const Tensor& virial_slow_in,
1600 const Tensor& intVirial_normal,
const Tensor& intVirial_nbond,
const Tensor& intVirial_slow,
1601 const Vector& extForce_normal,
const Vector& extForce_nbond,
const Vector& extForce_slow) {
1603 Tensor virial_normal = virial_normal_in;
1604 Tensor virial_nbond = virial_nbond_in;
1605 Tensor virial_slow = virial_slow_in;
1619 virial_normal -=
outer(extForce_normal,extPosition);
1620 virial_nbond -=
outer(extForce_nbond,extPosition);
1621 virial_slow -=
outer(extForce_slow,extPosition);
1623 if ( (volume=lattice.
volume()) != 0. )
1627 #ifdef MEM_OPT_VERSION
1628 NAMD_bug(
"LJcorrection not supported in memory optimized build.");
1646 if ( minimize || ! ( step %
nbondFreq ) )
1652 if ( minimize || ! ( step %
slowFreq ) )
1695 #define AVGXY(T) T.xy = T.yx = 0; T.xx = T.yy = 0.5 * ( T.xx + T.yy );\
1696 T.xz = T.zx = T.yz = T.zy = 0.5 * ( T.xz + T.yz );
1723 else if(testV < *Vmin){
1728 delta = testV - *Vavg;
1730 *M2 += delta * (testV - (*Vavg));
1732 *sigmaV = sqrt(*M2/n);
1740 *k0 = (1-sigma0/sigmaV) * (Vmax-Vmin) / (Vavg-Vmin);
1748 *E = Vmin + (Vmax-Vmin)/(*k0);
1754 *k0 = (sigma0 / sigmaV) * (Vmax-Vmin) / (Vmax-Vavg);
1761 *k = *k0 / (Vmax - Vmin);
1771 *vir += vir_orig * (*factor);
1772 *dV += (*factor) * VE/2.;
1781 (
int step_n,
char type,
int V_n,
BigReal Vmax,
BigReal Vmin,
BigReal Vavg,
BigReal sigmaV,
BigReal M2,
BigReal E,
BigReal k,
bool write_topic,
bool lasttime){
1783 char timestepstr[20];
1787 const char *bsuffix;
1789 if(lasttime ||
simParams->restartFrequency == 0){
1798 baselen = strlen(filename);
1799 restart_name =
new char[baselen+26];
1801 strcpy(restart_name, filename);
1802 if (
simParams->restartSave && !lasttime) {
1803 sprintf(timestepstr,
".%d",step_n);
1804 strcat(restart_name, timestepstr);
1807 strcat(restart_name,
".gamd");
1812 rest = fopen(restart_name,
"w");
1814 fprintf(rest,
"# NAMD accelMDG restart file\n"
1815 "# D/T Vn Vmax Vmin Vavg sigmaV M2 E k\n"
1816 "%c %d %.17lg %.17lg %.17lg %.17lg %.17le %.17lg %.17lg\n",
1817 type, V_n-1, Vmax, Vmin, Vavg, sigmaV, M2, E, k);
1819 iout <<
"GAUSSIAN ACCELERATED MD RESTART DATA WRITTEN TO " << restart_name <<
"\n" <<
endi;
1822 iout <<
iWARN <<
"Cannot write accelMDG restart file\n" <<
endi;
1825 rest = fopen(restart_name,
"a");
1827 fprintf(rest,
"%c %d %.17lg %.17lg %.17lg %.17lg %.17le %.17lg %.17lg\n",
1828 type, V_n-1, Vmax, Vmin, Vavg, sigmaV, M2, E, k);
1832 iout <<
iWARN <<
"Cannot write accelMDG restart file\n" <<
endi;
1835 delete[] restart_name;
1869 static BigReal VmaxP, VminP, VavgP, M2P=0, sigmaVP;
1870 static BigReal VmaxD, VminD, VavgD, M2D=0, sigmaVD;
1873 static int V_n = 1, iEusedD, iEusedP;
1874 static char warnD, warnP;
1875 static int restfreq;
1894 BigReal amd_ljEnergy_Corr = 0.;
1911 volume = lattice.
volume();
1955 potentialEnergy = bondEnergy + angleEnergy + dihedralEnergy +
1956 improperEnergy + amd_electEnergy + amd_electEnergySlow + amd_ljEnergy +
1957 crosstermEnergy + boundaryEnergy + miscEnergy +
1958 amd_goTotalEnergy + amd_groLJEnergy + amd_groGaussEnergy;
1963 if(step == firststep) {
1965 warnD = warnP =
'\0';
1971 int dihe_n=0, tot_n=0;
1977 while(fgets(line, 256, rest)){
1979 dihe_n = sscanf(line+1,
" %d %la %la %la %la %la %la %la",
1980 &V_n, &VmaxD, &VminD, &VavgD, &sigmaVD, &M2D, &ED, &kD);
1982 else if(line[0] ==
'T'){
1983 tot_n = sscanf(line+1,
" %d %la %la %la %la %la %la %la",
1984 &V_n, &VmaxP, &VminP, &VavgP, &sigmaVP, &M2P, &EP, &kP);
1995 NAMD_die(
"Invalid dihedral potential energy format in accelMDG restart file");
1996 k0D = kD * (VmaxD - VminD);
1997 iout <<
"GAUSSIAN ACCELERATED MD READ FROM RESTART FILE: DIHED"
1998 <<
" Vmax " << VmaxD <<
" Vmin " << VminD
1999 <<
" Vavg " << VavgD <<
" sigmaV " << sigmaVD
2000 <<
" E " << ED <<
" k " << kD
2007 NAMD_die(
"Invalid total potential energy format in accelMDG restart file");
2008 k0P = kP * (VmaxP - VminP);
2009 iout <<
"GAUSSIAN ACCELERATED MD READ FROM RESTART FILE: TOTAL"
2010 <<
" Vmax " << VmaxP <<
" Vmin " << VminP
2011 <<
" Vavg " << VavgP <<
" sigmaV " << sigmaVP
2012 <<
" E " << EP <<
" k " << kP
2016 iEusedD = (ED == VmaxD) ? 1 : 2;
2017 iEusedP = (EP == VmaxP) ? 1 : 2;
2025 testV = dihedralEnergy + crosstermEnergy;
2028 if(step > firststep && step % restfreq == 0)
2029 write_accelMDG_rest_file(step,
'D', V_n, VmaxD, VminD, VavgD, sigmaVD, M2D, ED, kD,
2034 write_accelMDG_rest_file(step,
'D', V_n, VmaxD, VminD, VavgD, sigmaVD, M2D, ED, kD,
2038 write_accelMDG_rest_file(step,
'D', V_n, VmaxD, VminD, VavgD, sigmaVD, M2D, ED, kD,
2046 VmaxD = VminD = VavgD = testV;
2050 else if(step == ntcmdprep && ntcmdprep != 0){
2052 VmaxD = VminD = VavgD = testV;
2054 iout <<
"GAUSSIAN ACCELERATED MD: RESET DIHEDRAL POTENTIAL STATISTICS\n" <<
endi;
2057 else if(ntave > 0 && step % ntave == 0){
2059 if(testV > VmaxD) VmaxD = testV;
2060 if(testV < VminD) VminD = testV;
2064 iout <<
"GAUSSIAN ACCELERATED MD: RESET DIHEDRAL POTENTIAL AVG AND STD\n" <<
endi;
2069 &VmaxD, &VminD, &VavgD, &M2D, &sigmaVD) ;
2072 if(step == ntcmd - 1){
2074 VmaxD, VminD, VavgD, sigmaVD, &k0D, &kD, &ED, &iEusedD, &warnD);
2078 else if(step < nteb){
2080 &dV, &factor_dihe, &vir);
2085 VmaxD = VminD = VavgD = testV;
2087 iout <<
"GAUSSIAN ACCELERATED MD: RESET DIHEDRAL POTENTIAL STATISTICS\n" <<
endi;
2090 else if(ntave > 0 && step % ntave == 0){
2092 if(testV > VmaxD) VmaxD = testV;
2093 if(testV < VminD) VminD = testV;
2097 iout <<
"GAUSSIAN ACCELERATED MD: RESET DIHEDRAL POTENTIAL AVG AND STD\n" <<
endi;
2101 &VmaxD, &VminD, &VavgD, &M2D, &sigmaVD) ;
2104 if(step >= ntebprep)
2105 if((ntave > 0 && step % ntave == 0) || ntave <= 0)
2107 VmaxD, VminD, VavgD, sigmaVD, &k0D, &kD, &ED, &iEusedD, &warnD);
2112 &dV, &factor_dihe, &vir);
2118 Tensor vir_tot = vir_normal + vir_nbond + vir_slow;
2119 testV = potentialEnergy;
2121 testV -= dihedralEnergy + crosstermEnergy;
2122 vir_tot -= vir_dihe;
2126 if(step > firststep && step % restfreq == 0)
2127 write_accelMDG_rest_file(step,
'T', V_n, VmaxP, VminP, VavgP, sigmaVP, M2P, EP, kP,
2132 write_accelMDG_rest_file(step,
'T', V_n, VmaxP, VminP, VavgP, sigmaVP, M2P, EP, kP,
2136 write_accelMDG_rest_file(step,
'T', V_n, VmaxP, VminP, VavgP, sigmaVP, M2P, EP, kP,
2144 VmaxP = VminP = VavgP = testV;
2148 else if(step == ntcmdprep && ntcmdprep != 0){
2150 VmaxP = VminP = VavgP = testV;
2152 iout <<
"GAUSSIAN ACCELERATED MD: RESET TOTAL POTENTIAL STATISTICS\n" <<
endi;
2155 else if(ntave > 0 && step % ntave == 0){
2157 if(testV > VmaxP) VmaxP = testV;
2158 if(testV < VminP) VminP = testV;
2162 iout <<
"GAUSSIAN ACCELERATED MD: RESET TOTAL POTENTIAL AVG AND STD\n" <<
endi;
2167 &VmaxP, &VminP, &VavgP, &M2P, &sigmaVP);
2169 if(step == ntcmd - 1){
2171 VmaxP, VminP, VavgP, sigmaVP, &k0P, &kP, &EP, &iEusedP, &warnP);
2175 else if(step < nteb){
2177 &dV, &factor_tot, &vir);
2182 VmaxP = VminP = VavgP = testV;
2184 iout <<
"GAUSSIAN ACCELERATED MD: RESET TOTAL POTENTIAL STATISTICS\n" <<
endi;
2187 else if(ntave > 0 && step % ntave == 0){
2189 if(testV > VmaxP) VmaxP = testV;
2190 if(testV < VminP) VminP = testV;
2194 iout <<
"GAUSSIAN ACCELERATED MD: RESET TOTAL POTENTIAL AVG AND STD\n" <<
endi;
2198 &VmaxP, &VminP, &VavgP, &M2P, &sigmaVP);
2201 if(step >= ntebprep)
2202 if((ntave > 0 && step % ntave == 0) || ntave <= 0)
2204 VmaxP, VminP, VavgP, sigmaVP, &k0P, &kP, &EP, &iEusedP, &warnP);
2209 &dV, &factor_tot, &vir);
2216 if((ntcmdprep > 0 && step == ntcmdprep) ||
2217 (step < nteb && ntave > 0 && step % ntave == 0) ||
2230 testV = dihedralEnergy + crosstermEnergy;
2231 if ( testV < accelMDE ) {
2232 factor_dihe = accelMDalpha/(accelMDalpha + accelMDE - testV);
2233 factor_dihe *= factor_dihe;
2234 vir = vir_dihe * (factor_dihe - 1.0);
2235 dV = (accelMDE - testV)*(accelMDE - testV)/(accelMDalpha + accelMDE - testV);
2241 testV = dihedralEnergy + crosstermEnergy;
2242 if ( testV < accelMDE ) {
2243 factor_dihe = accelMDalpha/(accelMDalpha + accelMDE - testV);
2244 factor_dihe *= factor_dihe;
2245 vir = vir_dihe * (factor_dihe - 1.0) ;
2246 dV = (accelMDE - testV)*(accelMDE - testV)/(accelMDalpha + accelMDE - testV);
2249 testV = potentialEnergy - dihedralEnergy - crosstermEnergy;
2250 if ( testV < accelMDTE ) {
2251 factor_tot = accelMDTalpha/(accelMDTalpha + accelMDTE - testV);
2252 factor_tot *= factor_tot;
2253 vir += (vir_normal - vir_dihe + vir_nbond + vir_slow) * (factor_tot - 1.0);
2254 dV += (accelMDTE - testV)*(accelMDTE - testV)/(accelMDTalpha + accelMDTE - testV);
2260 testV = potentialEnergy;
2261 if ( testV < accelMDE ) {
2262 factor_tot = accelMDalpha/(accelMDalpha + accelMDE - testV);
2263 factor_tot *= factor_tot;
2264 vir = (vir_normal + vir_nbond + vir_slow) * (factor_tot - 1.0);
2265 dV = (accelMDE - testV)*(accelMDE - testV)/(accelMDalpha + accelMDE - testV);
2271 accelMDfactor[0]=factor_dihe;
2272 accelMDfactor[1]=factor_tot;
2278 if ( factor_tot < 0.001 ) {
2279 iout <<
iWARN <<
"accelMD is using a very high boost potential, simulation may become unstable!"
2283 if ( ! (step % accelMDOutFreq) ) {
2287 iout <<
"ACCELERATED MD: STEP " << step
2290 <<
" BOND " << bondEnergy
2291 <<
" ANGLE " << angleEnergy
2292 <<
" DIHED " << dihedralEnergy+crosstermEnergy
2293 <<
" IMPRP " << improperEnergy
2294 <<
" ELECT " << amd_electEnergy+amd_electEnergySlow
2295 <<
" VDW " << amd_ljEnergy
2296 <<
" POTENTIAL " << potentialEnergy;
2297 if(amd_ljEnergy_Corr)
2298 iout <<
" LJcorr " << amd_ljEnergy_Corr;
2302 iout <<
"GAUSSIAN ACCELERATED MD: DIHED iE " << iEusedD
2303 <<
" Vmax " << VmaxD <<
" Vmin " << VminD
2304 <<
" Vavg " << VavgD <<
" sigmaV " << sigmaVD
2305 <<
" E " << ED <<
" k0 " << k0D <<
" k " << kD
2308 iout <<
"GAUSSIAN ACCELERATED MD: DIHED !!! WARNING: k0 > 1, "
2309 <<
"SWITCHED TO iE = 1 MODE !!!\n" <<
endi;
2311 iout <<
"GAUSSIAN ACCELERATED MD: DIHED !!! WARNING: k0 <= 0, "
2312 <<
"SWITCHED TO iE = 1 MODE !!!\n" <<
endi;
2314 iout <<
"GAUSSIAN ACCELERATED MD: TOTAL iE " << iEusedP
2315 <<
" Vmax " << VmaxP <<
" Vmin " << VminP
2316 <<
" Vavg " << VavgP <<
" sigmaV " << sigmaVP
2317 <<
" E " << EP <<
" k0 " << k0P <<
" k " << kP
2320 iout <<
"GAUSSIAN ACCELERATED MD: TOTAL !!! WARNING: k0 > 1, "
2321 <<
"SWITCHED TO iE = 1 MODE !!!\n" <<
endi;
2323 iout <<
"GAUSSIAN ACCELERATED MD: TOTAL !!! WARNING: k0 <= 0, "
2324 <<
"SWITCHED TO iE = 1 MODE !!!\n" <<
endi;
2325 warnD = warnP =
'\0';
2335 if ( volume != 0. ) {
2336 p_normal = vir_normal/volume;
2337 p_nbond = vir_nbond/volume;
2338 p_slow = vir_slow/volume;
2341 iout <<
" accelMD Scaling Factor: " << accelMDfactor <<
"\n"
2342 <<
" accelMD PNORMAL " << trace(p_normal)*
PRESSUREFACTOR/3. <<
"\n"
2343 <<
" accelMD PNBOND " << trace(p_nbond)*
PRESSUREFACTOR/3. <<
"\n"
2353 iout <<
iINFO <<
"INITIALISING ADAPTIVE TEMPERING\n" <<
endi;
2358 iout <<
iINFO <<
"READING ADAPTIVE TEMPERING RESTART FILE\n" <<
endi;
2360 if (adaptTempRead) {
2365 adaptTempRead >> readInt;
2373 if (adaptTempBetaMin > adaptTempBetaMax){
2398 adaptTempRead.close();
2400 else NAMD_die(
"Could not open ADAPTIVE TEMPERING restart file.\n");
2440 iout <<
iINFO <<
"ADAPTIVE TEMPERING: ADAPTIVE BIN AVERAGING PARAMETER: " <<
adaptTempCg <<
"\n";
2441 iout <<
iINFO <<
"ADAPTIVE TEMPERING: SCALING CONSTANT FOR LANGEVIN TEMPERATURE UPDATES: " <<
adaptTempDt <<
"\n";
2447 NAMD_die(
"Error opening restart file");
2454 iout <<
"ADAPTEMP: WRITING RESTART FILE AT STEP " << step <<
"\n" <<
endi;
2486 if ( minimize || (step < simParams->adaptTempFirstStep ) ||
2496 <<
" adaptTempBeta: " << adaptTempBeta
2515 potEnergyVariance -= potEnergyAverage*potEnergyAverage;
2528 BigReal deltaBeta = 0.04*adaptTempBeta;
2534 if ( adaptTempBetaMax-adaptTempBeta < deltaBeta ) deltaBeta = adaptTempBetaMax-adaptTempBeta;
2535 betaMinus = adaptTempBeta - deltaBeta;
2536 betaPlus = adaptTempBeta + deltaBeta;
2537 BigReal betaMinus2 = betaMinus*betaMinus;
2538 BigReal betaPlus2 = betaPlus*betaPlus;
2539 nMinus = (int)floor((betaMinus-adaptTempBetaMin)/
adaptTempDBeta);
2556 DeltaE2AveSum += DeltaE2Ave;
2560 A0 += (adaptTempBetaMin+0.5*
adaptTempDBeta-betaMinus)*DeltaE2AveSum;
2565 A0 /= (betaNp1-betaMinus);
2571 DeltaE2Ave = adaptTempPotEnergyVar[j];
2572 DeltaE2AveSum += DeltaE2Ave;
2576 A1 += (adaptTempBetaMin+0.5*
adaptTempDBeta-betaPlus)*DeltaE2AveSum;
2578 if ( nPlus < adaptTempBins ) {
2581 A1 -= 0.5*betaj*adaptTempPotEnergyVar[nPlus];
2583 A1 /= (betaPlus-betaNp1);
2592 if (DeltaE2Ave != 0) {
2593 aplus = (A0-A2)/(A0-A1);
2603 potEnergyAve0 /= (betaNp1-betaMinus);
2605 if ( nPlus < adaptTempBins ) {
2608 potEnergyAve1 /= (betaPlus-betaNp1);
2609 potEnergyAverage = aminus*potEnergyAve0;
2610 potEnergyAverage += aplus*potEnergyAve1;
2613 iout <<
"ADAPTEMP DEBUG:" <<
"\n"
2616 <<
" adaptTempBeta: " << adaptTempBeta <<
"\n"
2618 <<
" betaMin: " << adaptTempBetaMin <<
"\n"
2619 <<
" betaMax: " << adaptTempBetaMax <<
"\n"
2620 <<
" gammaAve: " << gammaAve <<
"\n"
2621 <<
" deltaBeta: " << deltaBeta <<
"\n"
2622 <<
" betaMinus: " << betaMinus <<
"\n"
2623 <<
" betaPlus: " << betaPlus <<
"\n"
2624 <<
" nMinus: " << nMinus <<
"\n"
2625 <<
" nPlus: " << nPlus <<
"\n"
2626 <<
" A0: " << A0 <<
"\n"
2627 <<
" A1: " << A1 <<
"\n"
2628 <<
" A2: " << A2 <<
"\n"
2629 <<
" a+: " << aplus <<
"\n"
2630 <<
" a-: " << aminus <<
"\n"
2636 iout <<
"ADAPTEMP DEBUG:" <<
"\n"
2639 <<
" adaptTempBeta: " << adaptTempBeta <<
"\n"
2642 <<
" betaMax: " << adaptTempBetaMax <<
"\n"
2643 <<
" gammaAve: " << gammaAve <<
"\n"
2644 <<
" deltaBeta: N/A\n"
2645 <<
" betaMinus: N/A\n"
2646 <<
" betaPlus: N/A\n"
2686 else if ( dT < 1./adaptTempBetaMax ) {
2705 if (adaptTempTdiff > 0) {
2717 iout <<
"ADAPTEMP: " << step <<
" FRAC " << Frac <<
"\n";
2720 iout <<
"ADAPTEMP: Updating adaptTempDt to ";
2733 if (adaptTempTdiff > 0) {
2745 iout <<
"ADAPTEMP: " << step <<
" FRAC " << Frac <<
"\n";
2748 iout <<
"ADAPTEMP: Updating adaptTempDt to ";
2763 if ( ! (step % adaptTempOutFreq) ) {
2764 iout <<
"ADAPTEMP: STEP " << step
2766 <<
" ENERGY " << std::setprecision(10) << potentialEnergy
2767 <<
" ENERGYAVG " << std::setprecision(10) << potEnergyAverage
2768 <<
" ENERGYVAR " << std::setprecision(10) << potEnergyVariance;
2784 if ( ((
int)checksum) != molecule->
numAtoms ) {
2785 sprintf(errmsg,
"Bad global atom count! (%d vs %d)\n",
2786 (
int)checksum, molecule->
numAtoms);
2793 computesPartitioned = 0;
2794 }
else if ( (
int)checksum >
computeChecksum && ! computesPartitioned ) {
2795 computesPartitioned = 1;
2797 NAMD_bug(
"Bad global compute count!\n");
2803 if ( checksum_b && (((
int)checksum) != molecule->
numCalcBonds) ) {
2804 sprintf(errmsg,
"Bad global bond count! (%d vs %d)\n",
2806 if ( forgiving && (((
int)checksum) < molecule->
numCalcBonds) )
2812 if ( checksum_b && (((
int)checksum) != molecule->
numCalcAngles) ) {
2813 sprintf(errmsg,
"Bad global angle count! (%d vs %d)\n",
2815 if ( forgiving && (((
int)checksum) < molecule->
numCalcAngles) )
2822 sprintf(errmsg,
"Bad global dihedral count! (%d vs %d)\n",
2831 sprintf(errmsg,
"Bad global improper count! (%d vs %d)\n",
2839 if ( checksum_b && (((
int)checksum) != molecule->
numCalcTholes) ) {
2840 sprintf(errmsg,
"Bad global Thole count! (%d vs %d)\n",
2842 if ( forgiving && (((
int)checksum) < molecule->
numCalcTholes) )
2848 if ( checksum_b && (((
int)checksum) != molecule->
numCalcAnisos) ) {
2849 sprintf(errmsg,
"Bad global Aniso count! (%d vs %d)\n",
2851 if ( forgiving && (((
int)checksum) < molecule->
numCalcAnisos) )
2858 sprintf(errmsg,
"Bad global crossterm count! (%d vs %d)\n",
2869 iout <<
iWARN <<
"High global exclusion count ("
2870 << ((
int64)checksum) <<
" vs "
2872 <<
iWARN <<
"This warning is not unusual during minimization.\n"
2873 <<
iWARN <<
"Decreasing pairlistdist or cutoff that is too close to periodic cell size may avoid this.\n" <<
endi;
2876 sprintf(errmsg,
"High global exclusion count! (%lld vs %lld) System unstable or pairlistdist or cutoff too close to periodic cell size.\n",
2885 iout <<
iWARN <<
"Low global exclusion count! ("
2889 <<
iWARN <<
"This warning is not unusual during minimization.\n"
2890 <<
iWARN <<
"Increasing pairlistdist or cutoff may avoid this.\n";
2892 iout <<
" System unstable or pairlistdist or cutoff too small.\n";
2897 sprintf(errmsg,
"Low global exclusion count! (%lld vs %lld) System unstable or pairlistdist or cutoff too small.\n",
2903 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2908 iout <<
iWARN <<
"High global CUDA exclusion count ("
2909 << ((
int64)checksum) <<
" vs "
2911 <<
iWARN <<
"This warning is not unusual during minimization.\n"
2912 <<
iWARN <<
"Decreasing pairlistdist or cutoff that is too close to periodic cell size may avoid this.\n" <<
endi;
2915 sprintf(errmsg,
"High global CUDA exclusion count! (%lld vs %lld) System unstable or pairlistdist or cutoff too close to periodic cell size.\n",
2924 iout <<
iWARN <<
"Low global CUDA exclusion count! ("
2928 <<
iWARN <<
"This warning is not unusual during minimization.\n"
2929 <<
iWARN <<
"Increasing pairlistdist or cutoff may avoid this.\n";
2931 iout <<
" System unstable or pairlistdist or cutoff too small.\n";
2936 sprintf(errmsg,
"Low global CUDA exclusion count! (%lld vs %lld) System unstable or pairlistdist or cutoff too small.\n",
2945 iout <<
iERROR <<
"Margin is too small for " << ((int)checksum) <<
2946 " atoms during timestep " << step <<
".\n" <<
iERROR <<
2947 "Incorrect nonbonded forces and energies may be calculated!\n" <<
endi;
2954 "Pairlistdist is too small for " << ((int)checksum) <<
2955 " computes during timestep " << step <<
".\n" <<
endi;
2962 iout <<
iWARN <<
"Stray PME grid charges ignored!\n" <<
endi;
2963 else NAMD_bug(
"Stray PME grid charges detected!\n");
2971 const double endWTime = CmiWallTimer() - firstWTime;
2972 const double endCTime = CmiTimer() - firstCTime;
2975 if ( (((
int)endWTime)>>6) != (((
int)startWTime)>>6 ) )
fflush_count = 2;
2977 const double elapsedW =
2979 const double elapsedC =
2982 const double remainingW = elapsedW * (
simParams->
N - step);
2983 const double remainingW_hours = remainingW / 3600;
2985 startWTime = endWTime;
2986 startCTime = endCTime;
2988 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2991 iout <<
iWARN <<
"Energy evaluation is expensive, increase outputEnergies to improve performance.\n" <<
endi;
2995 CmiPrintf(
"TIMING: %d CPU: %g, %g/step Wall: %g, %g/step"
2996 ", %g hours remaining, %f MB of memory in use.\n",
2997 step, endCTime, elapsedC, endWTime, elapsedW,
3069 if ( minimize || ! ( step %
nbondFreq ) )
3096 if ( minimize || ! ( step %
slowFreq ) )
3110 #ifdef MEM_OPT_VERSION
3111 NAMD_bug(
"LJcorrection not supported in memory optimized build.");
3117 if (simParameters->
alchOn) {
3144 angularMomentum.
x =
reduction->
item(REDUCTION_ANGULAR_MOMENTUM_X);
3145 angularMomentum.
y =
reduction->
item(REDUCTION_ANGULAR_MOMENTUM_Y);
3146 angularMomentum.
z =
reduction->
item(REDUCTION_ANGULAR_MOMENTUM_Z);
3149 potentialEnergy = (bondEnergy + angleEnergy + dihedralEnergy
3151 + crosstermEnergy + boundaryEnergy + miscEnergy +
goTotalEnergy
3157 if ( !(step%slowFreq) ) {
3170 if (step <= simParameters->firstTimestep &&
3178 iout <<
"MOMENTUM: " << step
3179 <<
" P: " << momentum
3180 <<
" L: " << angularMomentum
3189 iout <<
"PRESSURE: " << step <<
" "
3191 <<
"GPRESSURE: " << step <<
" "
3195 <<
"GPRESSAVG: " << step <<
" "
3199 groupPressure_tavg = 0;
3210 memset(total, 0, arraysize*
sizeof(
BigReal));
3219 if (!(step % freq)) {
3223 iout <<
"PRESSUREPROFILE: " << step <<
" ";
3224 if (step == first) {
3226 for (
int i=0; i<arraysize; i++) {
3227 iout << total[i] * scalefac <<
" ";
3232 for (
int i=0; i<arraysize; i++)
3247 if ( benchPhase > 0 && benchPhase < 10 ) {
3248 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
3250 iout <<
iWARN <<
"Energy evaluation is expensive, increase outputEnergies to improve performance.\n";
3254 if ( benchPhase < 4 )
iout <<
"Initial time: ";
3255 else iout <<
"Benchmark time: ";
3256 iout << CkNumPes() <<
" CPUs ";
3261 BigReal days = 1.0 / (24.0 * 60.0 * 60.0);
3262 BigReal daysPerNano = wallPerStep * days / ns;
3263 iout << wallPerStep <<
" s/step " << daysPerNano <<
" days/ns ";
3267 startBenchTime = CmiWallTimer();
3274 Vector pairVDWForce, pairElectForce;
3287 #define CALLBACKDATA(LABEL,VALUE) \
3288 labels << (LABEL) << " "; values << (VALUE) << " ";
3289 #define CALLBACKLIST(LABEL,VALUE) \
3290 labels << (LABEL) << " "; values << "{" << (VALUE) << "} ";
3292 std::ostringstream labels,
values;
3295 values.precision(16);
3297 values << std::setprecision(16);
3320 labels <<
"PERIODIC "; values <<
"{" << lattice.
a_p() <<
" "
3321 << lattice.
b_p() <<
" " << lattice.
c_p() <<
"} ";
3333 if (simParameters->
alchOn) {
3347 CALLBACKLIST(
"BOND2", bondEnergy + angleEnergy + dihedralEnergy +
3354 labels <<
'\0'; values <<
'\0';
3355 state->callback_labelstring = labels.str();
3356 state->callback_valuestring = values.str();
3373 " steps.\n" <<
endi;
3383 if ( ! minimize && step % simParameters->
outputEnergies )
return;
3386 if (simParameters->
IMDon && !(step % simParameters->
IMDfreq)) {
3388 energies.
tstep = step;
3391 energies.
Epot = potentialEnergy;
3394 energies.
Ebond = bondEnergy;
3395 energies.
Eangle = angleEnergy;
3396 energies.
Edihe = dihedralEnergy + crosstermEnergy;
3397 energies.
Eimpr = improperEnergy;
3403 " margin violations detected since previous energy output.\n" <<
endi;
3408 if ( (step % (10 * (minimize?1:simParameters->
outputEnergies) ) ) == 0 )
3410 iout <<
"ETITLE: TS";
3429 if ( volume != 0. ) {
3465 if (simParameters->
alchOn) {
3467 iout <<
"\nTITITLE: TS";
3481 iout <<
"\nFEPTITLE: TS";
3494 iout <<
"QMETITLE: TS";
3509 iout <<
FORMAT(dihedralEnergy+crosstermEnergy, precision);
3564 if (simParameters->
alchOn) {
3585 iout <<
FORMAT(bondEnergy + angleEnergy + dihedralEnergy
3597 #if(CMK_CCS_AVAILABLE && CMK_WEB_MODE)
3600 (
int)(potentialEnergy),
3602 CApplicationDepositNode0Data(webout);
3606 iout <<
"PAIR INTERACTION:";
3607 iout <<
" STEP: " << step;
3608 iout <<
" VDW_FORCE: ";
3612 iout <<
" ELECT_FORCE: ";
3632 file <<
"#$LABELS step";
3633 if ( lattice.
a_p() ) file <<
" a_x a_y a_z";
3634 if ( lattice.
b_p() ) file <<
" b_x b_y b_z";
3635 if ( lattice.
c_p() ) file <<
" c_x c_y c_z";
3636 file <<
" o_x o_y o_z";
3638 file <<
" s_x s_y s_z s_u s_v s_w";
3647 if ( lattice.
a_p() ) file <<
" " << lattice.
a().
x <<
" " << lattice.
a().
y <<
" " << lattice.
a().
z;
3648 if ( lattice.
b_p() ) file <<
" " << lattice.
b().
x <<
" " << lattice.
b().
y <<
" " << lattice.
b().
z;
3649 if ( lattice.
c_p() ) file <<
" " << lattice.
c().
x <<
" " << lattice.
c().
y <<
" " << lattice.
c().
z;
3654 file <<
" " << strainRate.
x;
3655 file <<
" " << strainRate.
y;
3656 file <<
" " << strainRate.
z;
3657 file <<
" " << strainRate2.
x;
3658 file <<
" " << strainRate2.
y;
3659 file <<
" " << strainRate2.
z;
3683 if (alchEnsembleAvg && (stepInRun == 0 || stepInRun == alchEquilSteps)) {
3701 if (stepInRun == 0) {
3705 iout <<
"OPENING FEP ENERGY OUTPUT FILE\n" <<
endi;
3706 if(alchEnsembleAvg){
3709 <<
"vdW dE dE_avg Temp dG\n"
3711 <<
" l l+dl E(l+dl)-E(l)" << std::endl;
3717 <<
" l l+dl E(l+dl)-E(l)" << std::endl;
3721 fepFile <<
"#NEW FEP WINDOW: "
3722 <<
"LAMBDA SET TO " << alchLambda <<
" LAMBDA2 "
3730 if ((alchEquilSteps) && (stepInRun == alchEquilSteps)) {
3731 fepFile <<
"#" << alchEquilSteps <<
" STEPS OF EQUILIBRATION AT "
3733 <<
"#STARTING COLLECTION OF ENSEMBLE AVERAGE" << std::endl;
3739 if (alchEnsembleAvg && (step ==
simParams->
N)) {
3741 fepFile <<
"#Free energy change for lambda window [ " << alchLambda
3743 <<
" ; net change until now is " <<
fepSum << std::endl;
3756 if (stepInRun == 0 || stepInRun == alchEquilSteps) {
3778 if (stepInRun == 0 || stepInRun == alchEquilSteps
3802 if (stepInRun == 0) {
3812 iout <<
"OPENING TI ENERGY OUTPUT FILE\n" <<
endi;
3813 tiFile <<
"#TITITLE: TS";
3828 if (alchLambdaFreq > 0) {
3835 if (alchLambdaFreq > 0) {
3836 tiFile <<
"#ALCHEMICAL SWITCHING ACTIVE "
3838 <<
"\n#LAMBDA SCHEDULE: "
3840 <<
" Freq: " << alchLambdaFreq;
3850 tiFile <<
"#NEW TI WINDOW: "
3851 <<
"LAMBDA " << alchLambda
3852 <<
"\n#PARTITION 1 SCALING: BOND " << bond_lambda_1
3853 <<
" VDW " << vdw_lambda_1 <<
" ELEC " << elec_lambda_1
3854 <<
"\n#PARTITION 2 SCALING: BOND " << bond_lambda_2
3855 <<
" VDW " << vdw_lambda_2 <<
" ELEC " << elec_lambda_2;
3861 if ((alchEquilSteps) && (stepInRun == alchEquilSteps)) {
3862 tiFile <<
"#" << alchEquilSteps <<
" STEPS OF EQUILIBRATION AT "
3864 <<
"#STARTING COLLECTION OF ENSEMBLE AVERAGE" << std::endl;
3898 (elec_lambda_12 - elec_lambda_1)*
3902 (elec_lambda_22 - elec_lambda_2)*
3931 if(alchEnsembleAvg){
3936 if(alchEnsembleAvg){
3979 iout <<
"OPENING EXTENDED SYSTEM TRAJECTORY FILE\n" <<
endi;
3983 if ( errno == EINTR ) {
3984 CkPrintf(
"Warning: Interrupted system call opening XST trajectory file, retrying.\n");
3993 xstFile <<
"# NAMD extended system trajectory file" << std::endl;
4006 iout <<
"WRITING EXTENDED SYSTEM TO RESTART FILE AT STEP "
4007 << step <<
"\n" <<
endi;
4009 const char *bsuffix =
".old";
4012 char timestepstr[20];
4013 sprintf(timestepstr,
".%d",step);
4014 strcat(fname, timestepstr);
4017 strcat(fname,
".xsc");
4021 if ( errno == EINTR ) {
4022 CkPrintf(
"Warning: Interrupted system call opening XSC restart file, retrying.\n");
4024 xscFile.
open(fname);
4028 sprintf(err_msg,
"Error opening XSC restart file %s",fname);
4031 xscFile <<
"# NAMD extended system configuration restart file" << std::endl;
4036 sprintf(err_msg,
"Error writing XSC restart file %s",fname);
4048 iout <<
"WRITING EXTENDED SYSTEM TO OUTPUT FILE AT STEP "
4049 << realstep <<
"\n" <<
endi;
4050 static char fname[140];
4052 strcat(fname,
".xsc");
4056 if ( errno == EINTR ) {
4057 CkPrintf(
"Warning: Interrupted system call opening XSC output file, retrying.\n");
4059 xscFile.
open(fname);
4063 sprintf(err_msg,
"Error opening XSC output file %s",fname);
4066 xscFile <<
"# NAMD extended system configuration output file" << std::endl;
4071 sprintf(err_msg,
"Error writing XSC output file %s",fname);
4080 iout <<
"CLOSING EXTENDED SYSTEM TRAJECTORY FILE\n" <<
endi;
4097 NAMD_die(
"Unable to load checkpoint, requested key was never stored.");
4103 NAMD_die(
"Unable to swap checkpoint, requested key was never stored.");
4109 NAMD_die(
"Unable to free checkpoint, requested key was never stored.");
4122 CkpvAccess(_qd)->process();
4132 startBenchTime -= CmiWallTimer();
4135 startBenchTime += CmiWallTimer();
4143 broadcast->cycleBarrier.publish(step,1);
4144 CkPrintf(
"Cycle time at sync Wall: %f CPU %f\n",
4145 CmiWallTimer()-firstWTime,CmiTimer()-firstCTime);
4151 CkPrintf(
"Cycle time at trace sync (begin) Wall at step %d: %f CPU %f\n", step, CmiWallTimer()-firstWTime,CmiTimer()-firstCTime);
4152 CProxy_Node nd(CkpvAccess(BOCclass_group).node);
4153 nd.traceBarrier(turnOnTrace, step);
4159 CkPrintf(
"Cycle time at trace sync (end) Wall at step %d: %f CPU %f\n", step, CmiWallTimer()-firstWTime,CmiTimer()-firstCTime);
4163 #ifdef MEASURE_NAMD_WITH_PAPI
4164 void Controller::papiMeasureBarrier(
int turnOnMeasure,
int step){
4165 CkPrintf(
"Cycle time at PAPI measurement sync (begin) Wall at step %d: %f CPU %f\n", step, CmiWallTimer()-firstWTime,CmiTimer()-firstCTime);
4166 CProxy_Node nd(CkpvAccess(BOCclass_group).node);
4167 nd.papiMeasureBarrier(turnOnMeasure, step);
4171 void Controller::resumeAfterPapiMeasureBarrier(
int step){
4172 broadcast->papiMeasureBarrier.publish(step,1);
4173 CkPrintf(
"Cycle time at PAPI measurement sync (end) Wall at step %d: %f CPU %f\n", step, CmiWallTimer()-firstWTime,CmiTimer()-firstCTime);
Vector gaussian_vector(void)
Bool accelMDGresetVaftercmd
BigReal berendsenPressureCompressibility
void enqueueCollections(int)
Tensor controlPressure_slow
char scriptStringArg1[128]
BigReal berendsenPressureRelaxationTime
std::ostream & iINFO(std::ostream &s)
#define CALLBACKDATA(LABEL, VALUE)
void recvCheckpointReq(const char *key, int task, checkpoint &cp)
void cycleBarrier(int, int)
void rescaleVelocities(int)
void rescaleaccelMD(int step, int minimize=0)
static int velocityNeeded(int)
void write_accelMDG_rest_file(int step_n, char type, int V_n, BigReal Vmax, BigReal Vmin, BigReal Vavg, BigReal sigmaV, BigReal M2, BigReal E, BigReal k, bool write_topic, bool lasttime)
BigReal getLambdaDelta(void)
void compareChecksums(int, int=0)
Tensor groupPressure_nbond
void NAMD_err(const char *err_msg)
std::map< std::string, checkpoint * > checkpoints
BigReal langevinPistonTemp
SimpleBroadcastObject< int > traceBarrier
void calcPressure(int step, int minimize, const Tensor &virial_normal_in, const Tensor &virial_nbond_in, const Tensor &virial_slow_in, const Tensor &intVirial_normal, const Tensor &intVirial_nbond, const Tensor &intVirial_slow, const Vector &extForce_normal, const Vector &extForce_nbond, const Vector &extForce_slow)
static Tensor diagonal(const Vector &v1)
static int coordinateNeeded(int)
void adaptTempWriteRestart(int step)
static __global__ void(const patch_pair *patch_pairs, const atom *atoms, const atom_param *atom_params, const int *vdw_types, unsigned int *plist, float4 *tmpforces, float4 *slow_tmpforces, float4 *forces, float4 *slow_forces, float *tmpvirials, float *slow_tmpvirials, float *virials, float *slow_virials, unsigned int *global_counters, int *force_ready_queue, const unsigned int *overflow_exclusions, const int npatches, const int block_begin, const int total_block_count, int *block_order, exclmask *exclmasks, const int lj_table_size, const float3 lata, const float3 latb, const float3 latc, const float cutoff2, const float plcutoff2, const int doSlow)
SimpleBroadcastObject< Vector > momentumCorrection
ScriptTcl * getScript(void)
virtual void algorithm(void)
static PatchMap * Object()
void calc_accelMDG_mean_std(BigReal testV, int step_n, BigReal *Vmax, BigReal *Vmin, BigReal *Vavg, BigReal *M2, BigReal *sigmaV)
void adaptTempInit(int step)
char adaptTempInFile[NAMD_FILENAME_BUFFER_SIZE]
PressureProfileReduction(int rtag, int numslabs, int numpartitions, const char *myname, int outputfreq)
SimParameters * simParameters
void printMinimizeEnergies(int)
BigReal multigratorPressureTarget
int accelMDGEquiPrepSteps
double stochRescaleCoefficient()
BigReal surfaceTensionTarget
void writeExtendedSystemLabels(ofstream_namd &file)
void enqueueVelocities(int seq)
std::vector< BigReal > multigratorOmega
std::ostream & endi(std::ostream &s)
BigReal sum_of_squared_gaussians(int64_t num_gaussians)
Return the sum of i.i.d. squared Gaussians.
BigReal electEnergySlow_f
std::vector< BigReal > multigratorNuT
int berendsenPressureFreq
std::ostream & iWARN(std::ostream &s)
SubmitReduction * willSubmit(int setID, int size=-1)
if(ComputeNonbondedUtil::goMethod==2)
SimpleBroadcastObject< BigReal > adaptTemperature
Tensor groupPressure_tavg
Bool langevinPistonBarrier
BigReal * adaptTempPotEnergyAveNum
static ReductionMgr * Object(void)
#define GET_TENSOR(O, R, A)
int num_fixed_atoms() const
BigReal recent_dEdl_bond_2
void enqueuePositions(int seq, Lattice &lattice)
SimpleBroadcastObject< BigReal > tcoupleCoefficient
void outputPatchComputeMaps(const char *filename, int tag)
static int forceNeeded(int)
~PressureProfileReduction()
void swap(Array< T > &s, Array< T > &t)
void split(int iStream, int numStreams)
RequireReduction * amd_reduction
char outputFilename[NAMD_FILENAME_BUFFER_SIZE]
void multigratorTemperature(int step, int callNumber)
int64_t num_deg_freedom(int isInitialReport=0) const
void gather_energies(IMDEnergies *energies)
SimpleBroadcastObject< BigReal > stochRescaleCoefficient
void langevinPiston1(int)
void outputTiEnergy(int step)
static char * FEPTITLE2(int X)
Tensor langevinPiston_strainRate
BigReal langevinPistonDecay
std::vector< BigReal > multigratorNu
BigReal adaptTempDTavenum
Lattice checkpoint_lattice
PressureProfileReduction * ppint
void rescale(Tensor factor)
ofstream_namd adaptTempRestartFile
BigReal berendsenPressureTarget