ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/SimSetup.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/SimSetup.cpp (file contents):
Revision 859 by mmeineke, Mon Nov 10 21:50:36 2003 UTC vs.
Revision 962 by tim, Mon Jan 19 18:36:21 2004 UTC

# Line 29 | Line 29 | using namespace std;
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    
# Line 667 | Line 691 | void SimSetup::gatherInfo(void){
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  
725    for (i = 0; i < nInfo; i++){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines