1 |
|
#include <algorithm> |
2 |
< |
#include <cstdlib> |
2 |
> |
#include <stdlib.h> |
3 |
|
#include <iostream> |
4 |
< |
#include <cmath> |
4 |
> |
#include <math.h> |
5 |
|
#include <string> |
6 |
|
#include <sprng.h> |
7 |
– |
|
7 |
|
#include "SimSetup.hpp" |
8 |
|
#include "ReadWrite.hpp" |
9 |
|
#include "parse_me.h" |
21 |
|
#define NVT_ENS 1 |
22 |
|
#define NPTi_ENS 2 |
23 |
|
#define NPTf_ENS 3 |
24 |
< |
#define NPTim_ENS 4 |
26 |
< |
#define NPTfm_ENS 5 |
24 |
> |
#define NPTxyz_ENS 4 |
25 |
|
|
26 |
+ |
|
27 |
|
#define FF_DUFF 0 |
28 |
|
#define FF_LJ 1 |
29 |
|
#define FF_EAM 2 |
31 |
|
using namespace std; |
32 |
|
|
33 |
|
SimSetup::SimSetup(){ |
34 |
+ |
|
35 |
+ |
initSuspend = false; |
36 |
|
isInfoArray = 0; |
37 |
|
nInfo = 1; |
38 |
|
|
55 |
|
info = the_info; |
56 |
|
nInfo = theNinfo; |
57 |
|
isInfoArray = 1; |
58 |
+ |
initSuspend = true; |
59 |
|
} |
60 |
|
|
61 |
|
|
94 |
|
#endif // is_mpi |
95 |
|
|
96 |
|
void SimSetup::createSim(void){ |
95 |
– |
int i, j, k, globalAtomIndex; |
97 |
|
|
98 |
|
// gather all of the information from the Bass file |
99 |
|
|
109 |
|
|
110 |
|
// initialize the system coordinates |
111 |
|
|
112 |
< |
if (!isInfoArray){ |
112 |
> |
if ( !initSuspend ){ |
113 |
|
initSystemCoords(); |
114 |
+ |
|
115 |
+ |
if( !(globals->getUseInitTime()) ) |
116 |
+ |
info[0].currentTime = 0.0; |
117 |
|
} |
118 |
|
|
119 |
|
// make the output filenames |
135 |
|
|
136 |
|
|
137 |
|
void SimSetup::makeMolecules(void){ |
138 |
< |
int k, l; |
138 |
> |
int k; |
139 |
|
int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset; |
140 |
|
molInit molInfo; |
141 |
|
DirectionalAtom* dAtom; |
557 |
|
|
558 |
|
|
559 |
|
void SimSetup::gatherInfo(void){ |
560 |
< |
int i, j, k; |
560 |
> |
int i; |
561 |
|
|
562 |
|
ensembleCase = -1; |
563 |
|
ffCase = -1; |
608 |
|
else if (!strcasecmp(ensemble, "NPTf")){ |
609 |
|
ensembleCase = NPTf_ENS; |
610 |
|
} |
611 |
< |
else if (!strcasecmp(ensemble, "NPTim")){ |
612 |
< |
ensembleCase = NPTim_ENS; |
609 |
< |
} |
610 |
< |
else if (!strcasecmp(ensemble, "NPTfm")){ |
611 |
< |
ensembleCase = NPTfm_ENS; |
611 |
> |
else if (!strcasecmp(ensemble, "NPTxyz")){ |
612 |
> |
ensembleCase = NPTxyz_ENS; |
613 |
|
} |
614 |
|
else{ |
615 |
|
sprintf(painCave.errMsg, |
689 |
|
info[i].thermalTime = globals->getThermalTime(); |
690 |
|
} |
691 |
|
|
692 |
< |
// check for the temperature set flag |
692 |
> |
info[i].resetIntegrator = 0; |
693 |
> |
if( globals->haveResetTime() ){ |
694 |
> |
info[i].resetTime = globals->getResetTime(); |
695 |
> |
info[i].resetIntegrator = 1; |
696 |
> |
} |
697 |
|
|
698 |
+ |
// check for the temperature set flag |
699 |
+ |
|
700 |
|
if (globals->haveTempSet()) |
701 |
|
info[i].setTemp = globals->getTempSet(); |
702 |
|
|
703 |
< |
// get some of the tricky things that may still be in the globals |
703 |
> |
// check for the extended State init |
704 |
|
|
705 |
< |
double boxVector[3]; |
706 |
< |
if (globals->haveBox()){ |
707 |
< |
boxVector[0] = globals->getBox(); |
701 |
< |
boxVector[1] = globals->getBox(); |
702 |
< |
boxVector[2] = globals->getBox(); |
703 |
< |
|
704 |
< |
info[i].setBox(boxVector); |
705 |
< |
} |
706 |
< |
else if (globals->haveDensity()){ |
707 |
< |
double vol; |
708 |
< |
vol = (double) tot_nmol / globals->getDensity(); |
709 |
< |
boxVector[0] = pow(vol, (1.0 / 3.0)); |
710 |
< |
boxVector[1] = boxVector[0]; |
711 |
< |
boxVector[2] = boxVector[0]; |
712 |
< |
|
713 |
< |
info[i].setBox(boxVector); |
714 |
< |
} |
715 |
< |
else{ |
716 |
< |
if (!globals->haveBoxX()){ |
717 |
< |
sprintf(painCave.errMsg, |
718 |
< |
"SimSetup error, no periodic BoxX size given.\n"); |
719 |
< |
painCave.isFatal = 1; |
720 |
< |
simError(); |
721 |
< |
} |
722 |
< |
boxVector[0] = globals->getBoxX(); |
723 |
< |
|
724 |
< |
if (!globals->haveBoxY()){ |
725 |
< |
sprintf(painCave.errMsg, |
726 |
< |
"SimSetup error, no periodic BoxY size given.\n"); |
727 |
< |
painCave.isFatal = 1; |
728 |
< |
simError(); |
729 |
< |
} |
730 |
< |
boxVector[1] = globals->getBoxY(); |
731 |
< |
|
732 |
< |
if (!globals->haveBoxZ()){ |
733 |
< |
sprintf(painCave.errMsg, |
734 |
< |
"SimSetup error, no periodic BoxZ size given.\n"); |
735 |
< |
painCave.isFatal = 1; |
736 |
< |
simError(); |
737 |
< |
} |
738 |
< |
boxVector[2] = globals->getBoxZ(); |
739 |
< |
|
740 |
< |
info[i].setBox(boxVector); |
741 |
< |
} |
705 |
> |
info[i].useInitXSstate = globals->getUseInitXSstate(); |
706 |
> |
info[i].orthoTolerance = globals->getOrthoBoxTolerance(); |
707 |
> |
|
708 |
|
} |
709 |
< |
|
709 |
> |
|
710 |
|
//setup seed for random number generator |
711 |
|
int seedValue; |
712 |
|
|
781 |
|
|
782 |
|
if (!globals->haveECR()){ |
783 |
|
sprintf(painCave.errMsg, |
784 |
< |
"SimSetup Warning: using default value of 1/2 the smallest " |
785 |
< |
"box length for the electrostaticCutoffRadius.\n" |
820 |
< |
"I hope you have a very fast processor!\n"); |
784 |
> |
"SimSetup Warning: using default value of 15.0 angstroms" |
785 |
> |
"box length for the electrostaticCutoffRadius.\n"); |
786 |
|
painCave.isFatal = 0; |
787 |
|
simError(); |
788 |
< |
double smallest; |
824 |
< |
smallest = info[i].boxL[0]; |
825 |
< |
if (info[i].boxL[1] <= smallest) |
826 |
< |
smallest = info[i].boxL[1]; |
827 |
< |
if (info[i].boxL[2] <= smallest) |
828 |
< |
smallest = info[i].boxL[2]; |
829 |
< |
theEcr = 0.5 * smallest; |
788 |
> |
theEcr = 15.0; |
789 |
|
} |
790 |
|
else{ |
791 |
|
theEcr = globals->getECR(); |
803 |
|
theEst = globals->getEST(); |
804 |
|
} |
805 |
|
|
806 |
< |
info[i].setEcr(theEcr, theEst); |
806 |
> |
info[i].setDefaultEcr(theEcr, theEst); |
807 |
|
|
808 |
|
if (!globals->haveDielectric()){ |
809 |
|
sprintf(painCave.errMsg, |
818 |
|
if (usesDipoles){ |
819 |
|
if (!globals->haveECR()){ |
820 |
|
sprintf(painCave.errMsg, |
821 |
< |
"SimSetup Warning: using default value of 1/2 the smallest " |
822 |
< |
"box length for the electrostaticCutoffRadius.\n" |
823 |
< |
"I hope you have a very fast processor!\n"); |
824 |
< |
painCave.isFatal = 0; |
825 |
< |
simError(); |
867 |
< |
double smallest; |
868 |
< |
smallest = info[i].boxL[0]; |
869 |
< |
if (info[i].boxL[1] <= smallest) |
870 |
< |
smallest = info[i].boxL[1]; |
871 |
< |
if (info[i].boxL[2] <= smallest) |
872 |
< |
smallest = info[i].boxL[2]; |
873 |
< |
theEcr = 0.5 * smallest; |
821 |
> |
"SimSetup Warning: using default value of 15.0 angstroms" |
822 |
> |
"box length for the electrostaticCutoffRadius.\n"); |
823 |
> |
painCave.isFatal = 0; |
824 |
> |
simError(); |
825 |
> |
theEcr = 15.0; |
826 |
|
} |
827 |
|
else{ |
828 |
|
theEcr = globals->getECR(); |
829 |
|
} |
830 |
< |
|
830 |
> |
|
831 |
|
if (!globals->haveEST()){ |
832 |
|
sprintf(painCave.errMsg, |
833 |
|
"SimSetup Warning: using default value of 0.05 * the " |
840 |
|
else{ |
841 |
|
theEst = globals->getEST(); |
842 |
|
} |
843 |
< |
|
844 |
< |
info[i].setEcr(theEcr, theEst); |
843 |
> |
|
844 |
> |
info[i].setDefaultEcr(theEcr, theEst); |
845 |
|
} |
846 |
|
} |
847 |
|
} |
896 |
– |
|
848 |
|
#ifdef IS_MPI |
849 |
|
strcpy(checkPointMsg, "post processing checks out"); |
850 |
|
MPIcheckPoint(); |
851 |
|
#endif // is_mpi |
852 |
|
} |
853 |
< |
|
853 |
> |
|
854 |
|
void SimSetup::initSystemCoords(void){ |
855 |
|
int i; |
856 |
|
|
867 |
|
if (worldRank == 0){ |
868 |
|
#endif //is_mpi |
869 |
|
inName = globals->getInitialConfig(); |
919 |
– |
double* tempDouble = new double[1000000]; |
870 |
|
fileInit = new InitializeFromFile(inName); |
871 |
|
#ifdef IS_MPI |
872 |
|
} |
878 |
|
delete fileInit; |
879 |
|
} |
880 |
|
else{ |
881 |
< |
#ifdef IS_MPI |
932 |
< |
|
881 |
> |
|
882 |
|
// no init from bass |
883 |
< |
|
883 |
> |
|
884 |
|
sprintf(painCave.errMsg, |
885 |
< |
"Cannot intialize a parallel simulation without an initial configuration file.\n"); |
886 |
< |
painCave.isFatal; |
885 |
> |
"Cannot intialize a simulation without an initial configuration file.\n"); |
886 |
> |
painCave.isFatal = 1;; |
887 |
|
simError(); |
888 |
< |
|
940 |
< |
#else |
941 |
< |
|
942 |
< |
initFromBass(); |
943 |
< |
|
944 |
< |
|
945 |
< |
#endif |
888 |
> |
|
889 |
|
} |
890 |
|
|
891 |
|
#ifdef IS_MPI |
1103 |
|
} |
1104 |
|
|
1105 |
|
void SimSetup::calcSysValues(void){ |
1106 |
< |
int i, j, k; |
1106 |
> |
int i; |
1107 |
|
|
1108 |
|
int* molMembershipArray; |
1109 |
|
|
1202 |
|
|
1203 |
|
|
1204 |
|
void SimSetup::makeSysArrays(void){ |
1205 |
< |
int i, j, k, l; |
1205 |
> |
|
1206 |
> |
#ifndef IS_MPI |
1207 |
> |
int k, j; |
1208 |
> |
#endif // is_mpi |
1209 |
> |
int i, l; |
1210 |
|
|
1211 |
|
Atom** the_atoms; |
1212 |
|
Molecule* the_molecules; |
1289 |
|
void SimSetup::makeIntegrator(void){ |
1290 |
|
int k; |
1291 |
|
|
1292 |
+ |
NVE<RealIntegrator>* myNVE = NULL; |
1293 |
|
NVT<RealIntegrator>* myNVT = NULL; |
1294 |
< |
NPTi<RealIntegrator>* myNPTi = NULL; |
1295 |
< |
NPTf<RealIntegrator>* myNPTf = NULL; |
1296 |
< |
NPTim<RealIntegrator>* myNPTim = NULL; |
1349 |
< |
NPTfm<RealIntegrator>* myNPTfm = NULL; |
1294 |
> |
NPTi<NPT<RealIntegrator> >* myNPTi = NULL; |
1295 |
> |
NPTf<NPT<RealIntegrator> >* myNPTf = NULL; |
1296 |
> |
NPTxyz<NPT<RealIntegrator> >* myNPTxyz = NULL; |
1297 |
|
|
1298 |
|
for (k = 0; k < nInfo; k++){ |
1299 |
|
switch (ensembleCase){ |
1300 |
|
case NVE_ENS: |
1301 |
|
if (globals->haveZconstraints()){ |
1302 |
|
setupZConstraint(info[k]); |
1303 |
< |
new ZConstraint<NVE<RealIntegrator> >(&(info[k]), the_ff); |
1303 |
> |
myNVE = new ZConstraint<NVE<RealIntegrator> >(&(info[k]), the_ff); |
1304 |
|
} |
1305 |
< |
else |
1306 |
< |
new NVE<RealIntegrator>(&(info[k]), the_ff); |
1305 |
> |
else{ |
1306 |
> |
myNVE = new NVE<RealIntegrator>(&(info[k]), the_ff); |
1307 |
> |
} |
1308 |
> |
|
1309 |
> |
info->the_integrator = myNVE; |
1310 |
|
break; |
1311 |
|
|
1312 |
|
case NVT_ENS: |
1328 |
|
painCave.isFatal = 1; |
1329 |
|
simError(); |
1330 |
|
} |
1331 |
+ |
|
1332 |
+ |
info->the_integrator = myNVT; |
1333 |
|
break; |
1334 |
|
|
1335 |
|
case NPTi_ENS: |
1336 |
|
if (globals->haveZconstraints()){ |
1337 |
|
setupZConstraint(info[k]); |
1338 |
< |
myNPTi = new ZConstraint<NPTi<RealIntegrator> >(&(info[k]), the_ff); |
1338 |
> |
myNPTi = new ZConstraint<NPTi<NPT <RealIntegrator> > >(&(info[k]), the_ff); |
1339 |
|
} |
1340 |
|
else |
1341 |
< |
myNPTi = new NPTi<RealIntegrator>(&(info[k]), the_ff); |
1341 |
> |
myNPTi = new NPTi<NPT<RealIntegrator> >(&(info[k]), the_ff); |
1342 |
|
|
1343 |
|
myNPTi->setTargetTemp(globals->getTargetTemp()); |
1344 |
|
|
1371 |
|
painCave.isFatal = 1; |
1372 |
|
simError(); |
1373 |
|
} |
1374 |
+ |
|
1375 |
+ |
info->the_integrator = myNPTi; |
1376 |
|
break; |
1377 |
|
|
1378 |
|
case NPTf_ENS: |
1379 |
|
if (globals->haveZconstraints()){ |
1380 |
|
setupZConstraint(info[k]); |
1381 |
< |
myNPTf = new ZConstraint<NPTf<RealIntegrator> >(&(info[k]), the_ff); |
1381 |
> |
myNPTf = new ZConstraint<NPTf<NPT <RealIntegrator> > >(&(info[k]), the_ff); |
1382 |
|
} |
1383 |
|
else |
1384 |
< |
myNPTf = new NPTf<RealIntegrator>(&(info[k]), the_ff); |
1384 |
> |
myNPTf = new NPTf<NPT <RealIntegrator> >(&(info[k]), the_ff); |
1385 |
|
|
1386 |
|
myNPTf->setTargetTemp(globals->getTargetTemp()); |
1387 |
|
|
1397 |
|
|
1398 |
|
if (globals->haveTauThermostat()) |
1399 |
|
myNPTf->setTauThermostat(globals->getTauThermostat()); |
1400 |
+ |
|
1401 |
|
else{ |
1402 |
|
sprintf(painCave.errMsg, |
1403 |
|
"SimSetup error: If you use an NPT\n" |
1408 |
|
|
1409 |
|
if (globals->haveTauBarostat()) |
1410 |
|
myNPTf->setTauBarostat(globals->getTauBarostat()); |
1411 |
+ |
|
1412 |
|
else{ |
1413 |
|
sprintf(painCave.errMsg, |
1414 |
|
"SimSetup error: If you use an NPT\n" |
1416 |
|
painCave.isFatal = 1; |
1417 |
|
simError(); |
1418 |
|
} |
1419 |
+ |
|
1420 |
+ |
info->the_integrator = myNPTf; |
1421 |
|
break; |
1422 |
|
|
1423 |
< |
case NPTim_ENS: |
1423 |
> |
case NPTxyz_ENS: |
1424 |
|
if (globals->haveZconstraints()){ |
1425 |
|
setupZConstraint(info[k]); |
1426 |
< |
myNPTim = new ZConstraint<NPTim<RealIntegrator> >(&(info[k]), the_ff); |
1426 |
> |
myNPTxyz = new ZConstraint<NPTxyz<NPT <RealIntegrator> > >(&(info[k]), the_ff); |
1427 |
|
} |
1428 |
|
else |
1429 |
< |
myNPTim = new NPTim<RealIntegrator>(&(info[k]), the_ff); |
1429 |
> |
myNPTxyz = new NPTxyz<NPT <RealIntegrator> >(&(info[k]), the_ff); |
1430 |
|
|
1431 |
< |
myNPTim->setTargetTemp(globals->getTargetTemp()); |
1431 |
> |
myNPTxyz->setTargetTemp(globals->getTargetTemp()); |
1432 |
|
|
1433 |
|
if (globals->haveTargetPressure()) |
1434 |
< |
myNPTim->setTargetPressure(globals->getTargetPressure()); |
1434 |
> |
myNPTxyz->setTargetPressure(globals->getTargetPressure()); |
1435 |
|
else{ |
1436 |
|
sprintf(painCave.errMsg, |
1437 |
|
"SimSetup error: If you use a constant pressure\n" |
1438 |
|
" ensemble, you must set targetPressure in the BASS file.\n"); |
1439 |
|
painCave.isFatal = 1; |
1440 |
|
simError(); |
1441 |
< |
} |
1441 |
> |
} |
1442 |
|
|
1443 |
|
if (globals->haveTauThermostat()) |
1444 |
< |
myNPTim->setTauThermostat(globals->getTauThermostat()); |
1444 |
> |
myNPTxyz->setTauThermostat(globals->getTauThermostat()); |
1445 |
|
else{ |
1446 |
|
sprintf(painCave.errMsg, |
1447 |
|
"SimSetup error: If you use an NPT\n" |
1451 |
|
} |
1452 |
|
|
1453 |
|
if (globals->haveTauBarostat()) |
1454 |
< |
myNPTim->setTauBarostat(globals->getTauBarostat()); |
1454 |
> |
myNPTxyz->setTauBarostat(globals->getTauBarostat()); |
1455 |
|
else{ |
1456 |
|
sprintf(painCave.errMsg, |
1457 |
|
"SimSetup error: If you use an NPT\n" |
1459 |
|
painCave.isFatal = 1; |
1460 |
|
simError(); |
1461 |
|
} |
1504 |
– |
break; |
1462 |
|
|
1463 |
< |
case NPTfm_ENS: |
1507 |
< |
if (globals->haveZconstraints()){ |
1508 |
< |
setupZConstraint(info[k]); |
1509 |
< |
myNPTfm = new ZConstraint<NPTfm<RealIntegrator> >(&(info[k]), the_ff); |
1510 |
< |
} |
1511 |
< |
else |
1512 |
< |
myNPTfm = new NPTfm<RealIntegrator>(&(info[k]), the_ff); |
1513 |
< |
|
1514 |
< |
myNPTfm->setTargetTemp(globals->getTargetTemp()); |
1515 |
< |
|
1516 |
< |
if (globals->haveTargetPressure()) |
1517 |
< |
myNPTfm->setTargetPressure(globals->getTargetPressure()); |
1518 |
< |
else{ |
1519 |
< |
sprintf(painCave.errMsg, |
1520 |
< |
"SimSetup error: If you use a constant pressure\n" |
1521 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1522 |
< |
painCave.isFatal = 1; |
1523 |
< |
simError(); |
1524 |
< |
} |
1525 |
< |
|
1526 |
< |
if (globals->haveTauThermostat()) |
1527 |
< |
myNPTfm->setTauThermostat(globals->getTauThermostat()); |
1528 |
< |
else{ |
1529 |
< |
sprintf(painCave.errMsg, |
1530 |
< |
"SimSetup error: If you use an NPT\n" |
1531 |
< |
" ensemble, you must set tauThermostat.\n"); |
1532 |
< |
painCave.isFatal = 1; |
1533 |
< |
simError(); |
1534 |
< |
} |
1535 |
< |
|
1536 |
< |
if (globals->haveTauBarostat()) |
1537 |
< |
myNPTfm->setTauBarostat(globals->getTauBarostat()); |
1538 |
< |
else{ |
1539 |
< |
sprintf(painCave.errMsg, |
1540 |
< |
"SimSetup error: If you use an NPT\n" |
1541 |
< |
" ensemble, you must set tauBarostat.\n"); |
1542 |
< |
painCave.isFatal = 1; |
1543 |
< |
simError(); |
1544 |
< |
} |
1463 |
> |
info->the_integrator = myNPTxyz; |
1464 |
|
break; |
1465 |
|
|
1466 |
|
default: |
1534 |
|
} |
1535 |
|
theInfo.addProperty(zconsTol); |
1536 |
|
|
1537 |
< |
//set Force Substraction Policy |
1537 |
> |
//set Force Subtraction Policy |
1538 |
|
StringData* zconsForcePolicy = new StringData(); |
1539 |
|
zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID); |
1540 |
|
|
1543 |
|
} |
1544 |
|
else{ |
1545 |
|
sprintf(painCave.errMsg, |
1546 |
< |
"ZConstraint Warning: User does not set force substraction policy, " |
1547 |
< |
"average force substraction policy is used\n"); |
1546 |
> |
"ZConstraint Warning: User does not set force Subtraction policy, " |
1547 |
> |
"PolicyByMass is used\n"); |
1548 |
|
painCave.isFatal = 0; |
1549 |
|
simError(); |
1550 |
< |
zconsForcePolicy->setData("BYNUMBER"); |
1550 |
> |
zconsForcePolicy->setData("BYMASS"); |
1551 |
|
} |
1552 |
|
|
1553 |
|
theInfo.addProperty(zconsForcePolicy); |
1585 |
|
zconsParaData->addItem(tempParaItem); |
1586 |
|
} |
1587 |
|
|
1588 |
+ |
//check the uniqueness of index |
1589 |
+ |
if(!zconsParaData->isIndexUnique()){ |
1590 |
+ |
sprintf(painCave.errMsg, |
1591 |
+ |
"ZConstraint Error: molIndex is not unique\n"); |
1592 |
+ |
painCave.isFatal = 1; |
1593 |
+ |
simError(); |
1594 |
+ |
} |
1595 |
+ |
|
1596 |
|
//sort the parameters by index of molecules |
1597 |
|
zconsParaData->sortByIndex(); |
1598 |
< |
|
1598 |
> |
|
1599 |
|
//push data into siminfo, therefore, we can retrieve later |
1600 |
|
theInfo.addProperty(zconsParaData); |
1601 |
|
} |