# | Line 30 | Line 30 | using namespace std; | |
---|---|---|
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; | |
# | Line 103 | Line 127 | void SimSetup::createSim(void){ | |
127 | ||
128 | sysObjectsCreation(); | |
129 | ||
130 | + | // check on the post processing info |
131 | + | |
132 | + | finalInfoCheck(); |
133 | + | |
134 | // initialize the system coordinates | |
135 | ||
136 | if ( !initSuspend ){ | |
# | Line 111 | Line 139 | void SimSetup::createSim(void){ | |
139 | if( !(globals->getUseInitTime()) ) | |
140 | info[0].currentTime = 0.0; | |
141 | } | |
114 | – | |
115 | – | // check on the post processing info |
116 | – | |
117 | – | finalInfoCheck(); |
142 | ||
143 | // make the output filenames | |
144 | ||
# | Line 665 | Line 689 | void SimSetup::gatherInfo(void){ | |
689 | " Please give nMol in the components.\n"); | |
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 | + | painCave.isFatal = 0; |
699 | + | simError(); |
700 | } | |
701 | + | |
702 | + | if (globals->haveStatusTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ |
703 | + | sprintf(painCave.errMsg, |
704 | + | "Status time is not divisible by dt\n"); |
705 | + | painCave.isFatal = 0; |
706 | + | simError(); |
707 | + | } |
708 | + | |
709 | + | if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){ |
710 | + | sprintf(painCave.errMsg, |
711 | + | "Thermal time is not divisible by dt\n"); |
712 | + | painCave.isFatal = 0; |
713 | + | simError(); |
714 | + | } |
715 | + | |
716 | + | if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){ |
717 | + | sprintf(painCave.errMsg, |
718 | + | "Reset time is not divisible by dt\n"); |
719 | + | painCave.isFatal = 0; |
720 | + | simError(); |
721 | + | } |
722 | ||
723 | // set the status, sample, and thermal kick times | |
724 | ||
# | Line 781 | Line 834 | void SimSetup::finalInfoCheck(void){ | |
834 | ||
835 | if (!globals->haveECR()){ | |
836 | sprintf(painCave.errMsg, | |
837 | < | "SimSetup Warning: using default value of 1/2 the smallest " |
838 | < | "box length for the electrostaticCutoffRadius.\n" |
786 | < | "I hope you have a very fast processor!\n"); |
837 | > | "SimSetup Warning: using default value of 15.0 angstroms" |
838 | > | "box length for the electrostaticCutoffRadius.\n"); |
839 | painCave.isFatal = 0; | |
840 | simError(); | |
841 | < | double smallest; |
790 | < | smallest = info[i].boxL[0]; |
791 | < | if (info[i].boxL[1] <= smallest) |
792 | < | smallest = info[i].boxL[1]; |
793 | < | if (info[i].boxL[2] <= smallest) |
794 | < | smallest = info[i].boxL[2]; |
795 | < | theEcr = 0.5 * smallest; |
841 | > | theEcr = 15.0; |
842 | } | |
843 | else{ | |
844 | theEcr = globals->getECR(); | |
# | Line 825 | Line 871 | void SimSetup::finalInfoCheck(void){ | |
871 | if (usesDipoles){ | |
872 | if (!globals->haveECR()){ | |
873 | sprintf(painCave.errMsg, | |
874 | < | "SimSetup Warning: using default value of 1/2 the smallest " |
875 | < | "box length for the electrostaticCutoffRadius.\n" |
876 | < | "I hope you have a very fast processor!\n"); |
877 | < | painCave.isFatal = 0; |
878 | < | simError(); |
833 | < | double smallest; |
834 | < | smallest = info[i].boxL[0]; |
835 | < | if (info[i].boxL[1] <= smallest) |
836 | < | smallest = info[i].boxL[1]; |
837 | < | if (info[i].boxL[2] <= smallest) |
838 | < | smallest = info[i].boxL[2]; |
839 | < | theEcr = 0.5 * smallest; |
874 | > | "SimSetup Warning: using default value of 15.0 angstroms" |
875 | > | "box length for the electrostaticCutoffRadius.\n"); |
876 | > | painCave.isFatal = 0; |
877 | > | simError(); |
878 | > | theEcr = 15.0; |
879 | } | |
880 | else{ | |
881 | theEcr = globals->getECR(); | |
882 | } | |
883 | < | |
883 | > | |
884 | if (!globals->haveEST()){ | |
885 | sprintf(painCave.errMsg, | |
886 | "SimSetup Warning: using default value of 0.05 * the " | |
# | Line 854 | Line 893 | void SimSetup::finalInfoCheck(void){ | |
893 | else{ | |
894 | theEst = globals->getEST(); | |
895 | } | |
896 | < | |
896 | > | |
897 | info[i].setDefaultEcr(theEcr, theEst); | |
898 | } | |
899 | } | |
861 | – | |
862 | – | if( !initSuspend ) |
863 | – | info[i].checkCutOffs(); |
900 | } | |
865 | – | |
901 | #ifdef IS_MPI | |
902 | strcpy(checkPointMsg, "post processing checks out"); | |
903 | MPIcheckPoint(); | |
904 | #endif // is_mpi | |
905 | } | |
906 | < | |
906 | > | |
907 | void SimSetup::initSystemCoords(void){ | |
908 | int i; | |
909 | ||
# | Line 896 | Line 931 | void SimSetup::initSystemCoords(void){ | |
931 | delete fileInit; | |
932 | } | |
933 | else{ | |
934 | < | #ifdef IS_MPI |
935 | < | |
936 | < | // no init from bass |
902 | < | |
934 | > | |
935 | > | // no init from bass |
936 | > | |
937 | sprintf(painCave.errMsg, | |
938 | < | "Cannot intialize a parallel simulation without an initial configuration file.\n"); |
938 | > | "Cannot intialize a simulation without an initial configuration file.\n"); |
939 | painCave.isFatal = 1;; | |
940 | simError(); | |
941 | < | |
908 | < | #else |
909 | < | |
910 | < | initFromBass(); |
911 | < | |
912 | < | |
913 | < | #endif |
941 | > | |
942 | } | |
943 | ||
944 | #ifdef IS_MPI |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |