| 20 | 
  | 
  return ( x >= 0 ) ? floor( x + 0.5 ) : ceil( x - 0.5 ); | 
| 21 | 
  | 
} | 
| 22 | 
  | 
           | 
| 23 | 
+ | 
inline double min( double a, double b ){ | 
| 24 | 
+ | 
  return (a < b ) ? a : b; | 
| 25 | 
+ | 
} | 
| 26 | 
  | 
 | 
| 27 | 
  | 
SimInfo* currentInfo; | 
| 28 | 
  | 
 | 
| 40 | 
  | 
  thermalTime = 0.0; | 
| 41 | 
  | 
  currentTime = 0.0; | 
| 42 | 
  | 
  rCut = 0.0; | 
| 40 | 
– | 
  origRcut = -1.0; | 
| 43 | 
  | 
  ecr = 0.0; | 
| 42 | 
– | 
  origEcr = -1.0; | 
| 44 | 
  | 
  est = 0.0; | 
| 44 | 
– | 
  oldEcr = 0.0; | 
| 45 | 
– | 
  oldRcut = 0.0; | 
| 45 | 
  | 
 | 
| 46 | 
< | 
  haveOrigRcut = 0; | 
| 47 | 
< | 
  haveOrigEcr = 0; | 
| 46 | 
> | 
  haveRcut = 0; | 
| 47 | 
> | 
  haveEcr = 0; | 
| 48 | 
  | 
  boxIsInit = 0; | 
| 49 | 
  | 
   | 
| 50 | 
  | 
  resetTime = 1e99; | 
| 103 | 
  | 
                         // [ 2 5 8 ] | 
| 104 | 
  | 
  double FortranHmatInv[9]; // the inverted Hmat (for Fortran); | 
| 105 | 
  | 
 | 
| 107 | 
– | 
   | 
| 106 | 
  | 
  if( !boxIsInit ) boxIsInit = 1; | 
| 107 | 
  | 
 | 
| 108 | 
  | 
  for(i=0; i < 3; i++)  | 
| 527 | 
  | 
  this->ndf = this->getNDF(); | 
| 528 | 
  | 
  this->ndfRaw = this->getNDFraw(); | 
| 529 | 
  | 
  this->ndfTrans = this->getNDFtranslational(); | 
| 532 | 
– | 
} | 
| 533 | 
– | 
 | 
| 534 | 
– | 
 | 
| 535 | 
– | 
void SimInfo::setRcut( double theRcut ){ | 
| 536 | 
– | 
 | 
| 537 | 
– | 
  rCut = theRcut; | 
| 538 | 
– | 
  checkCutOffs(); | 
| 530 | 
  | 
} | 
| 531 | 
  | 
 | 
| 532 | 
  | 
void SimInfo::setDefaultRcut( double theRcut ){ | 
| 533 | 
  | 
 | 
| 534 | 
< | 
  haveOrigRcut = 1; | 
| 544 | 
< | 
  origRcut = theRcut; | 
| 534 | 
> | 
  haveRcut = 1; | 
| 535 | 
  | 
  rCut = theRcut; | 
| 536 | 
  | 
 | 
| 537 | 
  | 
  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; | 
| 539 | 
  | 
  notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | 
| 540 | 
  | 
} | 
| 541 | 
  | 
 | 
| 552 | 
– | 
void SimInfo::setEcr( double theEcr ){ | 
| 553 | 
– | 
 | 
| 554 | 
– | 
  ecr = theEcr; | 
| 555 | 
– | 
  checkCutOffs(); | 
| 556 | 
– | 
} | 
| 557 | 
– | 
 | 
| 542 | 
  | 
void SimInfo::setDefaultEcr( double theEcr ){ | 
| 543 | 
  | 
 | 
| 544 | 
< | 
  haveOrigEcr = 1; | 
| 545 | 
< | 
  origEcr = theEcr; | 
| 544 | 
> | 
  haveEcr = 1; | 
| 545 | 
> | 
  ecr = theEcr; | 
| 546 | 
  | 
   | 
| 547 | 
  | 
  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; | 
| 548 | 
  | 
 | 
| 565 | 
– | 
  ecr = theEcr; | 
| 566 | 
– | 
 | 
| 549 | 
  | 
  notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | 
| 550 | 
  | 
} | 
| 551 | 
  | 
 | 
| 570 | 
– | 
void SimInfo::setEcr( double theEcr, double theEst ){ | 
| 571 | 
– | 
 | 
| 572 | 
– | 
  est = theEst; | 
| 573 | 
– | 
  setEcr( theEcr ); | 
| 574 | 
– | 
} | 
| 575 | 
– | 
 | 
| 552 | 
  | 
void SimInfo::setDefaultEcr( double theEcr, double theEst ){ | 
| 553 | 
  | 
 | 
| 554 | 
  | 
  est = theEst; | 
| 557 | 
  | 
 | 
| 558 | 
  | 
 | 
| 559 | 
  | 
void SimInfo::checkCutOffs( void ){ | 
| 584 | 
– | 
 | 
| 585 | 
– | 
  int cutChanged = 0; | 
| 560 | 
  | 
   | 
| 561 | 
  | 
  if( boxIsInit ){ | 
| 562 | 
  | 
     | 
| 563 | 
  | 
    //we need to check cutOffs against the box | 
| 564 | 
< | 
 | 
| 565 | 
< | 
    //detect the change of rCut | 
| 592 | 
< | 
    if(( maxCutoff > rCut )&&(usePBC)){ | 
| 593 | 
< | 
      if( rCut < origRcut ){ | 
| 594 | 
< | 
        rCut = origRcut; | 
| 595 | 
< | 
         | 
| 596 | 
< | 
        if (rCut > maxCutoff) | 
| 597 | 
< | 
          rCut = maxCutoff; | 
| 598 | 
< | 
   | 
| 599 | 
< | 
          sprintf( painCave.errMsg, | 
| 600 | 
< | 
                    "New Box size is setting the long range cutoff radius " | 
| 601 | 
< | 
                    "to %lf at time %lf\n", | 
| 602 | 
< | 
                    rCut, currentTime ); | 
| 603 | 
< | 
          painCave.isFatal = 0; | 
| 604 | 
< | 
          simError(); | 
| 605 | 
< | 
      } | 
| 606 | 
< | 
    } | 
| 607 | 
< | 
    else if ((rCut > maxCutoff)&&(usePBC)) { | 
| 564 | 
> | 
     | 
| 565 | 
> | 
    if( rCut > maxCutoff ){ | 
| 566 | 
  | 
      sprintf( painCave.errMsg, | 
| 567 | 
< | 
               "New Box size is setting the long range cutoff radius " | 
| 568 | 
< | 
               "to %lf at time %lf\n", | 
| 569 | 
< | 
               maxCutoff, currentTime ); | 
| 570 | 
< | 
      painCave.isFatal = 0; | 
| 567 | 
> | 
               "Box size is too small for the long range cutoff radius, " | 
| 568 | 
> | 
               "%lf, at time %lf\n", | 
| 569 | 
> | 
               rCut, currentTime ); | 
| 570 | 
> | 
      painCave.isFatal = 1; | 
| 571 | 
  | 
      simError(); | 
| 614 | 
– | 
      rCut = maxCutoff; | 
| 572 | 
  | 
    } | 
| 573 | 
< | 
 | 
| 574 | 
< | 
 | 
| 575 | 
< | 
    //detect the change of ecr | 
| 576 | 
< | 
    if( maxCutoff > ecr ){ | 
| 577 | 
< | 
      if( ecr < origEcr ){ | 
| 578 | 
< | 
        ecr = origEcr; | 
| 579 | 
< | 
        if (ecr > maxCutoff) ecr = maxCutoff; | 
| 580 | 
< | 
   | 
| 581 | 
< | 
          sprintf( painCave.errMsg, | 
| 625 | 
< | 
                    "New Box size is setting the electrostaticCutoffRadius " | 
| 626 | 
< | 
                    "to %lf at time %lf\n", | 
| 627 | 
< | 
                    ecr, currentTime ); | 
| 628 | 
< | 
            painCave.isFatal = 0; | 
| 629 | 
< | 
            simError(); | 
| 573 | 
> | 
     | 
| 574 | 
> | 
    if( haveEcr ){ | 
| 575 | 
> | 
      if( ecr > maxCutoff ){ | 
| 576 | 
> | 
        sprintf( painCave.errMsg, | 
| 577 | 
> | 
                 "Box size is too small for the electrostatic cutoff radius, " | 
| 578 | 
> | 
                 "%lf, at time %lf\n", | 
| 579 | 
> | 
                 ecr, currentTime ); | 
| 580 | 
> | 
        painCave.isFatal = 1; | 
| 581 | 
> | 
        simError(); | 
| 582 | 
  | 
      } | 
| 583 | 
  | 
    } | 
| 632 | 
– | 
    else if( ecr > maxCutoff){ | 
| 633 | 
– | 
      sprintf( painCave.errMsg, | 
| 634 | 
– | 
               "New Box size is setting the electrostaticCutoffRadius " | 
| 635 | 
– | 
               "to %lf at time %lf\n", | 
| 636 | 
– | 
               maxCutoff, currentTime  ); | 
| 637 | 
– | 
      painCave.isFatal = 0; | 
| 638 | 
– | 
      simError();       | 
| 639 | 
– | 
      ecr = maxCutoff; | 
| 640 | 
– | 
    } | 
| 641 | 
– | 
 | 
| 642 | 
– | 
    if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; | 
| 643 | 
– | 
     | 
| 644 | 
– | 
    // rlist is the 1.0 plus max( rcut, ecr ) | 
| 645 | 
– | 
     | 
| 646 | 
– | 
    ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; | 
| 647 | 
– | 
     | 
| 648 | 
– | 
    if( cutChanged ){ | 
| 649 | 
– | 
      notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | 
| 650 | 
– | 
    } | 
| 651 | 
– | 
     | 
| 652 | 
– | 
    oldEcr = ecr; | 
| 653 | 
– | 
    oldRcut = rCut; | 
| 654 | 
– | 
     | 
| 584 | 
  | 
  } else { | 
| 585 | 
  | 
    // initialize this stuff before using it, OK? | 
| 586 | 
  | 
    sprintf( painCave.errMsg, |