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

Comparing trunk/OOPSE/libmdtools/SimInfo.cpp (file contents):
Revision 855 by mmeineke, Thu Nov 6 22:01:37 2003 UTC vs.
Revision 999 by chrisfen, Fri Jan 30 15:01:09 2004 UTC

# Line 20 | Line 20 | inline double roundMe( double x ){
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  
# Line 37 | Line 40 | SimInfo::SimInfo(){
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;
# Line 56 | Line 55 | SimInfo::SimInfo(){
55    usePBC = 0;
56    useLJ = 0;
57    useSticky = 0;
58 <  useDipole = 0;
58 >  useCharges = 0;
59 >  useDipoles = 0;
60    useReactionField = 0;
61    useGB = 0;
62    useEAM = 0;
# Line 104 | Line 104 | void SimInfo::setBoxM( double theBox[3][3] ){
104                           // [ 2 5 8 ]
105    double FortranHmatInv[9]; // the inverted Hmat (for Fortran);
106  
107  
107    if( !boxIsInit ) boxIsInit = 1;
108  
109    for(i=0; i < 3; i++)
# Line 181 | Line 180 | void SimInfo::calcHmatInv( void ) {
180      
181      if( orthoRhombic ){
182        sprintf( painCave.errMsg,
183 <               "Hmat is switching from Non-Orthorhombic to OrthoRhombic\n"
184 <               "       If this is a bad thing, change the orthoBoxTolerance( currently %G ).\n",
183 >               "Hmat is switching from Non-Orthorhombic to Orthorhombic Box.\n"
184 >               "\tIf this is a bad thing, change the orthoBoxTolerance\n"
185 >               "\tvariable ( currently set to %G ).\n",
186                 orthoTolerance);
187        simError();
188      }
189      else {
190        sprintf( painCave.errMsg,
191 <               "Hmat is switching from Orthorhombic to Non-OrthoRhombic\n"
192 <               "       If this is a bad thing, change the orthoBoxTolerance( currently %G ).\n",
191 >               "Hmat is switching from Orthorhombic to Non-Orthorhombic Box.\n"
192 >               "\tIf this is a bad thing, change the orthoBoxTolerance\n"
193 >               "\tvariable ( currently set to %G ).\n",
194                 orthoTolerance);
195        simError();
196      }
# Line 482 | Line 483 | void SimInfo::refreshSim(){
483  
484    fInfo.dielect = 0.0;
485  
486 <  if( useDipole ){
486 >  if( useDipoles ){
487      if( useReactionField )fInfo.dielect = dielectric;
488    }
489  
# Line 491 | Line 492 | void SimInfo::refreshSim(){
492    fInfo.SIM_uses_LJ = useLJ;
493    fInfo.SIM_uses_sticky = useSticky;
494    //fInfo.SIM_uses_sticky = 0;
495 <  fInfo.SIM_uses_dipoles = useDipole;
495 >  fInfo.SIM_uses_charges = useCharges;
496 >  fInfo.SIM_uses_dipoles = useDipoles;
497    //fInfo.SIM_uses_dipoles = 0;
498 <  //fInfo.SIM_uses_RF = useReactionField;
499 <  fInfo.SIM_uses_RF = 0;
498 >  fInfo.SIM_uses_RF = useReactionField;
499 >  //fInfo.SIM_uses_RF = 0;
500    fInfo.SIM_uses_GB = useGB;
501    fInfo.SIM_uses_EAM = useEAM;
502  
# Line 529 | Line 531 | void SimInfo::refreshSim(){
531    this->ndf = this->getNDF();
532    this->ndfRaw = this->getNDFraw();
533    this->ndfTrans = this->getNDFtranslational();
532 }
533
534
535 void SimInfo::setRcut( double theRcut ){
536
537  rCut = theRcut;
538  checkCutOffs();
534   }
535  
536   void SimInfo::setDefaultRcut( double theRcut ){
537  
538 <  haveOrigRcut = 1;
544 <  origRcut = theRcut;
538 >  haveRcut = 1;
539    rCut = theRcut;
540  
541    ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
# Line 549 | Line 543 | void SimInfo::setEcr( double theEcr ){
543    notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
544   }
545  
552 void SimInfo::setEcr( double theEcr ){
553
554  ecr = theEcr;
555  checkCutOffs();
556 }
557
546   void SimInfo::setDefaultEcr( double theEcr ){
547  
548 <  haveOrigEcr = 1;
549 <  origEcr = theEcr;
548 >  haveEcr = 1;
549 >  ecr = theEcr;
550    
551    ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
552  
565  ecr = theEcr;
566
553    notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
554   }
555  
570 void SimInfo::setEcr( double theEcr, double theEst ){
571
572  est = theEst;
573  setEcr( theEcr );
574 }
575
556   void SimInfo::setDefaultEcr( double theEcr, double theEst ){
557  
558    est = theEst;
# Line 581 | Line 561 | void SimInfo::checkCutOffs( void ){
561  
562  
563   void SimInfo::checkCutOffs( void ){
584
585  int cutChanged = 0;
564    
565    if( boxIsInit ){
566      
567      //we need to check cutOffs against the box
568 <
569 <    //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)) {
568 >    
569 >    if( rCut > maxCutoff ){
570        sprintf( painCave.errMsg,
571 <               "New Box size is setting the long range cutoff radius "
572 <               "to %lf at time %lf\n",
573 <               maxCutoff, currentTime );
574 <      painCave.isFatal = 0;
571 >               "Box size is too small for the long range cutoff radius, "
572 >               "%G, at time %G\n"
573 >               "\t[ %G %G %G ]\n"
574 >               "\t[ %G %G %G ]\n"
575 >               "\t[ %G %G %G ]\n",
576 >               rCut, currentTime,
577 >               Hmat[0][0], Hmat[0][1], Hmat[0][2],
578 >               Hmat[1][0], Hmat[1][1], Hmat[1][2],
579 >               Hmat[2][0], Hmat[2][1], Hmat[2][2]);
580 >      painCave.isFatal = 1;
581        simError();
614      rCut = maxCutoff;
582      }
583 <
584 <
585 <    //detect the change of ecr
586 <    if( maxCutoff > ecr ){
587 <      if( ecr < origEcr ){
588 <        ecr = origEcr;
589 <        if (ecr > maxCutoff) ecr = maxCutoff;
590 <  
591 <          sprintf( painCave.errMsg,
592 <                    "New Box size is setting the electrostaticCutoffRadius "
593 <                    "to %lf at time %lf\n",
594 <                    ecr, currentTime );
595 <            painCave.isFatal = 0;
596 <            simError();
583 >    
584 >    if( haveEcr ){
585 >      if( ecr > maxCutoff ){
586 >        sprintf( painCave.errMsg,
587 >                 "Box size is too small for the electrostatic cutoff radius, "
588 >                 "%G, at time %G\n"
589 >                 "\t[ %G %G %G ]\n"
590 >                 "\t[ %G %G %G ]\n"
591 >                 "\t[ %G %G %G ]\n",
592 >                 ecr, currentTime,
593 >                 Hmat[0][0], Hmat[0][1], Hmat[0][2],
594 >                 Hmat[1][0], Hmat[1][1], Hmat[1][2],
595 >                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
596 >        painCave.isFatal = 1;
597 >        simError();
598        }
599      }
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    
600    } else {
601      // initialize this stuff before using it, OK?
602      sprintf( painCave.errMsg,
603 <             "Trying to check cutoffs without a box. Be smarter.\n" );
603 >             "Trying to check cutoffs without a box.\n"
604 >             "\tOOPSE should have better programmers than that.\n" );
605      painCave.isFatal = 1;
606      simError();      
607    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines