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 |
|
#include "SimSetup.hpp" |
29 |
|
#define FF_EAM 2 |
30 |
|
|
31 |
|
using namespace std; |
32 |
+ |
|
33 |
+ |
/** |
34 |
+ |
* Check whether dividend is divisble by divisor or not |
35 |
+ |
*/ |
36 |
+ |
bool isDivisible(double dividend, double divisor){ |
37 |
+ |
double tolerance = 0.000001; |
38 |
+ |
double quotient; |
39 |
+ |
double diff; |
40 |
+ |
int intQuotient; |
41 |
+ |
|
42 |
+ |
quotient = dividend / divisor; |
43 |
+ |
|
44 |
+ |
if (quotient < 0) |
45 |
+ |
quotient = -quotient; |
46 |
|
|
47 |
+ |
intQuotient = int (quotient + tolerance); |
48 |
+ |
|
49 |
+ |
diff = fabs(fabs(dividend) - intQuotient * fabs(divisor)); |
50 |
+ |
|
51 |
+ |
if (diff <= tolerance) |
52 |
+ |
return true; |
53 |
+ |
else |
54 |
+ |
return false; |
55 |
+ |
} |
56 |
+ |
|
57 |
|
SimSetup::SimSetup(){ |
58 |
|
|
59 |
|
initSuspend = false; |
637 |
|
} |
638 |
|
else{ |
639 |
|
sprintf(painCave.errMsg, |
640 |
< |
"SimSetup Warning. Unrecognized Ensemble -> %s, " |
641 |
< |
"reverting to NVE for this simulation.\n", |
640 |
> |
"SimSetup Warning. Unrecognized Ensemble -> %s \n" |
641 |
> |
"\treverting to NVE for this simulation.\n", |
642 |
|
ensemble); |
643 |
|
painCave.isFatal = 0; |
644 |
|
simError(); |
670 |
|
if (!the_components[i]->haveNMol()){ |
671 |
|
// we have a problem |
672 |
|
sprintf(painCave.errMsg, |
673 |
< |
"SimSetup Error. No global NMol or component NMol" |
674 |
< |
" given. Cannot calculate the number of atoms.\n"); |
673 |
> |
"SimSetup Error. No global NMol or component NMol given.\n" |
674 |
> |
"\tCannot calculate the number of atoms.\n"); |
675 |
|
painCave.isFatal = 1; |
676 |
|
simError(); |
677 |
|
} |
690 |
|
painCave.isFatal = 1; |
691 |
|
simError(); |
692 |
|
} |
693 |
+ |
|
694 |
+ |
//check whether sample time, status time, thermal time and reset time are divisble by dt |
695 |
+ |
if (!isDivisible(globals->getSampleTime(), globals->getDt())){ |
696 |
+ |
sprintf(painCave.errMsg, |
697 |
+ |
"Sample time is not divisible by dt.\n" |
698 |
+ |
"\tThis will result in samples that are not uniformly\n" |
699 |
+ |
"\tdistributed in time. If this is a problem, change\n" |
700 |
+ |
"\tyour sampleTime variable.\n"); |
701 |
+ |
painCave.isFatal = 0; |
702 |
+ |
simError(); |
703 |
+ |
} |
704 |
+ |
|
705 |
+ |
if (globals->haveStatusTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ |
706 |
+ |
sprintf(painCave.errMsg, |
707 |
+ |
"Status time is not divisible by dt.\n" |
708 |
+ |
"\tThis will result in status reports that are not uniformly\n" |
709 |
+ |
"\tdistributed in time. If this is a problem, change \n" |
710 |
+ |
"\tyour statusTime variable.\n"); |
711 |
+ |
painCave.isFatal = 0; |
712 |
+ |
simError(); |
713 |
+ |
} |
714 |
+ |
|
715 |
+ |
if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){ |
716 |
+ |
sprintf(painCave.errMsg, |
717 |
+ |
"Thermal time is not divisible by dt.\n" |
718 |
+ |
"\tThis will result in thermalizations that are not uniformly\n" |
719 |
+ |
"\tdistributed in time. If this is a problem, change \n" |
720 |
+ |
"\tyour thermalTime variable.\n"); |
721 |
+ |
painCave.isFatal = 0; |
722 |
+ |
simError(); |
723 |
+ |
} |
724 |
|
|
725 |
+ |
if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){ |
726 |
+ |
sprintf(painCave.errMsg, |
727 |
+ |
"Reset time is not divisible by dt.\n" |
728 |
+ |
"\tThis will result in integrator resets that are not uniformly\n" |
729 |
+ |
"\tdistributed in time. If this is a problem, change\n" |
730 |
+ |
"\tyour resetTime variable.\n"); |
731 |
+ |
painCave.isFatal = 0; |
732 |
+ |
simError(); |
733 |
+ |
} |
734 |
+ |
|
735 |
|
// set the status, sample, and thermal kick times |
736 |
|
|
737 |
|
for (i = 0; i < nInfo; i++){ |
761 |
|
} |
762 |
|
|
763 |
|
// check for the temperature set flag |
764 |
< |
|
764 |
> |
|
765 |
|
if (globals->haveTempSet()) |
766 |
|
info[i].setTemp = globals->getTempSet(); |
767 |
|
|
768 |
< |
// get some of the tricky things that may still be in the globals |
768 |
> |
// check for the extended State init |
769 |
|
|
770 |
< |
double boxVector[3]; |
771 |
< |
if (globals->haveBox()){ |
772 |
< |
boxVector[0] = globals->getBox(); |
708 |
< |
boxVector[1] = globals->getBox(); |
709 |
< |
boxVector[2] = globals->getBox(); |
710 |
< |
|
711 |
< |
info[i].setBox(boxVector); |
712 |
< |
} |
713 |
< |
else if (globals->haveDensity()){ |
714 |
< |
double vol; |
715 |
< |
vol = (double) tot_nmol / globals->getDensity(); |
716 |
< |
boxVector[0] = pow(vol, (1.0 / 3.0)); |
717 |
< |
boxVector[1] = boxVector[0]; |
718 |
< |
boxVector[2] = boxVector[0]; |
719 |
< |
|
720 |
< |
info[i].setBox(boxVector); |
721 |
< |
} |
722 |
< |
else{ |
723 |
< |
if (!globals->haveBoxX()){ |
724 |
< |
sprintf(painCave.errMsg, |
725 |
< |
"SimSetup error, no periodic BoxX size given.\n"); |
726 |
< |
painCave.isFatal = 1; |
727 |
< |
simError(); |
728 |
< |
} |
729 |
< |
boxVector[0] = globals->getBoxX(); |
730 |
< |
|
731 |
< |
if (!globals->haveBoxY()){ |
732 |
< |
sprintf(painCave.errMsg, |
733 |
< |
"SimSetup error, no periodic BoxY size given.\n"); |
734 |
< |
painCave.isFatal = 1; |
735 |
< |
simError(); |
736 |
< |
} |
737 |
< |
boxVector[1] = globals->getBoxY(); |
738 |
< |
|
739 |
< |
if (!globals->haveBoxZ()){ |
740 |
< |
sprintf(painCave.errMsg, |
741 |
< |
"SimSetup error, no periodic BoxZ size given.\n"); |
742 |
< |
painCave.isFatal = 1; |
743 |
< |
simError(); |
744 |
< |
} |
745 |
< |
boxVector[2] = globals->getBoxZ(); |
746 |
< |
|
747 |
< |
info[i].setBox(boxVector); |
748 |
< |
} |
770 |
> |
info[i].useInitXSstate = globals->getUseInitXSstate(); |
771 |
> |
info[i].orthoTolerance = globals->getOrthoBoxTolerance(); |
772 |
> |
|
773 |
|
} |
774 |
< |
|
774 |
> |
|
775 |
|
//setup seed for random number generator |
776 |
|
int seedValue; |
777 |
|
|
846 |
|
|
847 |
|
if (!globals->haveECR()){ |
848 |
|
sprintf(painCave.errMsg, |
849 |
< |
"SimSetup Warning: using default value of 1/2 the smallest " |
850 |
< |
"box length for the electrostaticCutoffRadius.\n" |
851 |
< |
"I hope you have a very fast processor!\n"); |
849 |
> |
"SimSetup Warning: No value was set for electrostaticCutoffRadius.\n" |
850 |
> |
"\tOOPSE will use a default value of 15.0 angstroms" |
851 |
> |
"\tfor the electrostaticCutoffRadius.\n"); |
852 |
|
painCave.isFatal = 0; |
853 |
|
simError(); |
854 |
< |
double smallest; |
831 |
< |
smallest = info[i].boxL[0]; |
832 |
< |
if (info[i].boxL[1] <= smallest) |
833 |
< |
smallest = info[i].boxL[1]; |
834 |
< |
if (info[i].boxL[2] <= smallest) |
835 |
< |
smallest = info[i].boxL[2]; |
836 |
< |
theEcr = 0.5 * smallest; |
854 |
> |
theEcr = 15.0; |
855 |
|
} |
856 |
|
else{ |
857 |
|
theEcr = globals->getECR(); |
859 |
|
|
860 |
|
if (!globals->haveEST()){ |
861 |
|
sprintf(painCave.errMsg, |
862 |
< |
"SimSetup Warning: using default value of 0.05 * the " |
863 |
< |
"electrostaticCutoffRadius for the electrostaticSkinThickness\n"); |
862 |
> |
"SimSetup Warning: No value was set for electrostaticSkinThickness.\n" |
863 |
> |
"\tOOPSE will use a default value of\n" |
864 |
> |
"\t0.05 * electrostaticCutoffRadius\n" |
865 |
> |
"\tfor the electrostaticSkinThickness\n"); |
866 |
|
painCave.isFatal = 0; |
867 |
|
simError(); |
868 |
|
theEst = 0.05 * theEcr; |
871 |
|
theEst = globals->getEST(); |
872 |
|
} |
873 |
|
|
874 |
< |
info[i].setEcr(theEcr, theEst); |
874 |
> |
info[i].setDefaultEcr(theEcr, theEst); |
875 |
|
|
876 |
|
if (!globals->haveDielectric()){ |
877 |
|
sprintf(painCave.errMsg, |
878 |
< |
"SimSetup Error: You are trying to use Reaction Field without" |
879 |
< |
"setting a dielectric constant!\n"); |
878 |
> |
"SimSetup Error: No Dielectric constant was set.\n" |
879 |
> |
"\tYou are trying to use Reaction Field without" |
880 |
> |
"\tsetting a dielectric constant!\n"); |
881 |
|
painCave.isFatal = 1; |
882 |
|
simError(); |
883 |
|
} |
887 |
|
if (usesDipoles){ |
888 |
|
if (!globals->haveECR()){ |
889 |
|
sprintf(painCave.errMsg, |
890 |
< |
"SimSetup Warning: using default value of 1/2 the smallest " |
891 |
< |
"box length for the electrostaticCutoffRadius.\n" |
892 |
< |
"I hope you have a very fast processor!\n"); |
893 |
< |
painCave.isFatal = 0; |
894 |
< |
simError(); |
895 |
< |
double smallest; |
875 |
< |
smallest = info[i].boxL[0]; |
876 |
< |
if (info[i].boxL[1] <= smallest) |
877 |
< |
smallest = info[i].boxL[1]; |
878 |
< |
if (info[i].boxL[2] <= smallest) |
879 |
< |
smallest = info[i].boxL[2]; |
880 |
< |
theEcr = 0.5 * smallest; |
890 |
> |
"SimSetup Warning: No value was set for electrostaticCutoffRadius.\n" |
891 |
> |
"\tOOPSE will use a default value of 15.0 angstroms" |
892 |
> |
"\tfor the electrostaticCutoffRadius.\n"); |
893 |
> |
painCave.isFatal = 0; |
894 |
> |
simError(); |
895 |
> |
theEcr = 15.0; |
896 |
|
} |
897 |
|
else{ |
898 |
|
theEcr = globals->getECR(); |
899 |
|
} |
900 |
< |
|
900 |
> |
|
901 |
|
if (!globals->haveEST()){ |
902 |
|
sprintf(painCave.errMsg, |
903 |
< |
"SimSetup Warning: using default value of 0.05 * the " |
904 |
< |
"electrostaticCutoffRadius for the " |
905 |
< |
"electrostaticSkinThickness\n"); |
903 |
> |
"SimSetup Warning: No value was set for electrostaticSkinThickness.\n" |
904 |
> |
"\tOOPSE will use a default value of\n" |
905 |
> |
"\t0.05 * electrostaticCutoffRadius\n" |
906 |
> |
"\tfor the electrostaticSkinThickness\n"); |
907 |
|
painCave.isFatal = 0; |
908 |
|
simError(); |
909 |
|
theEst = 0.05 * theEcr; |
911 |
|
else{ |
912 |
|
theEst = globals->getEST(); |
913 |
|
} |
914 |
< |
|
915 |
< |
info[i].setEcr(theEcr, theEst); |
914 |
> |
|
915 |
> |
info[i].setDefaultEcr(theEcr, theEst); |
916 |
|
} |
917 |
|
} |
918 |
|
} |
903 |
– |
|
919 |
|
#ifdef IS_MPI |
920 |
|
strcpy(checkPointMsg, "post processing checks out"); |
921 |
|
MPIcheckPoint(); |
922 |
|
#endif // is_mpi |
923 |
|
} |
924 |
< |
|
924 |
> |
|
925 |
|
void SimSetup::initSystemCoords(void){ |
926 |
|
int i; |
927 |
|
|
949 |
|
delete fileInit; |
950 |
|
} |
951 |
|
else{ |
952 |
< |
#ifdef IS_MPI |
938 |
< |
|
952 |
> |
|
953 |
|
// no init from bass |
954 |
< |
|
954 |
> |
|
955 |
|
sprintf(painCave.errMsg, |
956 |
< |
"Cannot intialize a parallel simulation without an initial configuration file.\n"); |
956 |
> |
"Cannot intialize a simulation without an initial configuration file.\n"); |
957 |
|
painCave.isFatal = 1;; |
958 |
|
simError(); |
959 |
< |
|
946 |
< |
#else |
947 |
< |
|
948 |
< |
initFromBass(); |
949 |
< |
|
950 |
< |
|
951 |
< |
#endif |
959 |
> |
|
960 |
|
} |
961 |
|
|
962 |
|
#ifdef IS_MPI |
1252 |
|
|
1253 |
|
if (local_atoms != info[0].n_atoms){ |
1254 |
|
sprintf(painCave.errMsg, |
1255 |
< |
"SimSetup error: mpiSim's localAtom (%d) and SimSetup's" |
1256 |
< |
" localAtom (%d) are not equal.\n", |
1255 |
> |
"SimSetup error: mpiSim's localAtom (%d) and SimSetup's\n" |
1256 |
> |
"\tlocalAtom (%d) are not equal.\n", |
1257 |
|
info[0].n_atoms, local_atoms); |
1258 |
|
painCave.isFatal = 1; |
1259 |
|
simError(); |
1395 |
|
else{ |
1396 |
|
sprintf(painCave.errMsg, |
1397 |
|
"SimSetup error: If you use the NVT\n" |
1398 |
< |
" ensemble, you must set tauThermostat.\n"); |
1398 |
> |
"\tensemble, you must set tauThermostat.\n"); |
1399 |
|
painCave.isFatal = 1; |
1400 |
|
simError(); |
1401 |
|
} |
1418 |
|
else{ |
1419 |
|
sprintf(painCave.errMsg, |
1420 |
|
"SimSetup error: If you use a constant pressure\n" |
1421 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1421 |
> |
"\tensemble, you must set targetPressure in the BASS file.\n"); |
1422 |
|
painCave.isFatal = 1; |
1423 |
|
simError(); |
1424 |
|
} |
1428 |
|
else{ |
1429 |
|
sprintf(painCave.errMsg, |
1430 |
|
"SimSetup error: If you use an NPT\n" |
1431 |
< |
" ensemble, you must set tauThermostat.\n"); |
1431 |
> |
"\tensemble, you must set tauThermostat.\n"); |
1432 |
|
painCave.isFatal = 1; |
1433 |
|
simError(); |
1434 |
|
} |
1438 |
|
else{ |
1439 |
|
sprintf(painCave.errMsg, |
1440 |
|
"SimSetup error: If you use an NPT\n" |
1441 |
< |
" ensemble, you must set tauBarostat.\n"); |
1441 |
> |
"\tensemble, you must set tauBarostat.\n"); |
1442 |
|
painCave.isFatal = 1; |
1443 |
|
simError(); |
1444 |
|
} |
1461 |
|
else{ |
1462 |
|
sprintf(painCave.errMsg, |
1463 |
|
"SimSetup error: If you use a constant pressure\n" |
1464 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1464 |
> |
"\tensemble, you must set targetPressure in the BASS file.\n"); |
1465 |
|
painCave.isFatal = 1; |
1466 |
|
simError(); |
1467 |
|
} |
1468 |
|
|
1469 |
|
if (globals->haveTauThermostat()) |
1470 |
|
myNPTf->setTauThermostat(globals->getTauThermostat()); |
1471 |
+ |
|
1472 |
|
else{ |
1473 |
|
sprintf(painCave.errMsg, |
1474 |
|
"SimSetup error: If you use an NPT\n" |
1475 |
< |
" ensemble, you must set tauThermostat.\n"); |
1475 |
> |
"\tensemble, you must set tauThermostat.\n"); |
1476 |
|
painCave.isFatal = 1; |
1477 |
|
simError(); |
1478 |
|
} |
1479 |
|
|
1480 |
|
if (globals->haveTauBarostat()) |
1481 |
|
myNPTf->setTauBarostat(globals->getTauBarostat()); |
1482 |
+ |
|
1483 |
|
else{ |
1484 |
|
sprintf(painCave.errMsg, |
1485 |
|
"SimSetup error: If you use an NPT\n" |
1486 |
< |
" ensemble, you must set tauBarostat.\n"); |
1486 |
> |
"\tensemble, you must set tauBarostat.\n"); |
1487 |
|
painCave.isFatal = 1; |
1488 |
|
simError(); |
1489 |
|
} |
1506 |
|
else{ |
1507 |
|
sprintf(painCave.errMsg, |
1508 |
|
"SimSetup error: If you use a constant pressure\n" |
1509 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1509 |
> |
"\tensemble, you must set targetPressure in the BASS file.\n"); |
1510 |
|
painCave.isFatal = 1; |
1511 |
|
simError(); |
1512 |
|
} |
1516 |
|
else{ |
1517 |
|
sprintf(painCave.errMsg, |
1518 |
|
"SimSetup error: If you use an NPT\n" |
1519 |
< |
" ensemble, you must set tauThermostat.\n"); |
1519 |
> |
"\tensemble, you must set tauThermostat.\n"); |
1520 |
|
painCave.isFatal = 1; |
1521 |
|
simError(); |
1522 |
|
} |
1526 |
|
else{ |
1527 |
|
sprintf(painCave.errMsg, |
1528 |
|
"SimSetup error: If you use an NPT\n" |
1529 |
< |
" ensemble, you must set tauBarostat.\n"); |
1529 |
> |
"\tensemble, you must set tauBarostat.\n"); |
1530 |
|
painCave.isFatal = 1; |
1531 |
|
simError(); |
1532 |
|
} |
1579 |
|
} |
1580 |
|
else{ |
1581 |
|
sprintf(painCave.errMsg, |
1582 |
< |
"ZConstraint error: If you use an ZConstraint\n" |
1583 |
< |
" , you must set sample time.\n"); |
1582 |
> |
"ZConstraint error: If you use a ZConstraint,\n" |
1583 |
> |
"\tyou must set zconsTime.\n"); |
1584 |
|
painCave.isFatal = 1; |
1585 |
|
simError(); |
1586 |
|
} |
1595 |
|
else{ |
1596 |
|
double defaultZConsTol = 0.01; |
1597 |
|
sprintf(painCave.errMsg, |
1598 |
< |
"ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n" |
1599 |
< |
" , default value %f is used.\n", |
1598 |
> |
"ZConstraint Warning: Tolerance for z-constraint method is not specified.\n" |
1599 |
> |
"\tOOPSE will use a default value of %f.\n" |
1600 |
> |
"\tTo set the tolerance, use the zconsTol variable.\n", |
1601 |
|
defaultZConsTol); |
1602 |
|
painCave.isFatal = 0; |
1603 |
|
simError(); |
1615 |
|
} |
1616 |
|
else{ |
1617 |
|
sprintf(painCave.errMsg, |
1618 |
< |
"ZConstraint Warning: User does not set force Subtraction policy, " |
1619 |
< |
"PolicyByMass is used\n"); |
1618 |
> |
"ZConstraint Warning: No force subtraction policy was set.\n" |
1619 |
> |
"\tOOPSE will use PolicyByMass.\n" |
1620 |
> |
"\tTo set the policy, use the zconsForcePolicy variable.\n"); |
1621 |
|
painCave.isFatal = 0; |
1622 |
|
simError(); |
1623 |
|
zconsForcePolicy->setData("BYMASS"); |
1661 |
|
//check the uniqueness of index |
1662 |
|
if(!zconsParaData->isIndexUnique()){ |
1663 |
|
sprintf(painCave.errMsg, |
1664 |
< |
"ZConstraint Error: molIndex is not unique\n"); |
1664 |
> |
"ZConstraint Error: molIndex is not unique!\n"); |
1665 |
|
painCave.isFatal = 1; |
1666 |
|
simError(); |
1667 |
|
} |