--- trunk/OOPSE/libmdtools/SimSetup.cpp 2003/11/10 21:50:36 859 +++ trunk/OOPSE/libmdtools/SimSetup.cpp 2004/01/19 18:36:21 962 @@ -29,6 +29,30 @@ using namespace std; #define FF_EAM 2 using namespace std; + +/** + * Check whether dividend is divisble by divisor or not + */ +bool isDivisible(double dividend, double divisor){ + double tolerance = 0.000001; + double quotient; + double diff; + int intQuotient; + + quotient = dividend / divisor; + + if (quotient < 0) + quotient = -quotient; + + intQuotient = int (quotient + tolerance); + + diff = fabs(fabs(dividend) - intQuotient * fabs(divisor)); + + if (diff <= tolerance) + return true; + else + return false; +} SimSetup::SimSetup(){ @@ -667,6 +691,35 @@ void SimSetup::gatherInfo(void){ simError(); } + //check whether sample time, status time, thermal time and reset time are divisble by dt + if (!isDivisible(globals->getSampleTime(), globals->getDt())){ + sprintf(painCave.errMsg, + "Sample time is not divisible by dt \n"); + painCave.isFatal = 0; + simError(); + } + + if (globals->haveStatusTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ + sprintf(painCave.errMsg, + "Status time is not divisible by dt\n"); + painCave.isFatal = 0; + simError(); + } + + if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){ + sprintf(painCave.errMsg, + "Thermal time is not divisible by dt\n"); + painCave.isFatal = 0; + simError(); + } + + if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){ + sprintf(painCave.errMsg, + "Reset time is not divisible by dt\n"); + painCave.isFatal = 0; + simError(); + } + // set the status, sample, and thermal kick times for (i = 0; i < nInfo; i++){