# | 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; | |
52 | – | |
51 | ||
52 | + | orthoTolerance = 1E-6; |
53 | + | useInitXSstate = true; |
54 | + | |
55 | usePBC = 0; | |
56 | useLJ = 0; | |
57 | useSticky = 0; | |
# | Line 102 | Line 103 | void SimInfo::setBoxM( double theBox[3][3] ){ | |
103 | // [ 2 5 8 ] | |
104 | double FortranHmatInv[9]; // the inverted Hmat (for Fortran); | |
105 | ||
105 | – | |
106 | if( !boxIsInit ) boxIsInit = 1; | |
107 | ||
108 | for(i=0; i < 3; i++) | |
# | Line 161 | Line 161 | void SimInfo::calcHmatInv( void ) { | |
161 | smallDiag = fabs(Hmat[0][0]); | |
162 | if(smallDiag > fabs(Hmat[1][1])) smallDiag = fabs(Hmat[1][1]); | |
163 | if(smallDiag > fabs(Hmat[2][2])) smallDiag = fabs(Hmat[2][2]); | |
164 | < | tol = smallDiag * 1E-6; |
164 | > | tol = smallDiag * orthoTolerance; |
165 | ||
166 | orthoRhombic = 1; | |
167 | ||
# | Line 180 | Line 180 | void SimInfo::calcHmatInv( void ) { | |
180 | if( orthoRhombic ){ | |
181 | sprintf( painCave.errMsg, | |
182 | "Hmat is switching from Non-Orthorhombic to OrthoRhombic\n" | |
183 | < | " If this is a bad thing change the ortho tolerance in SimInfo.\n" ); |
183 | > | " If this is a bad thing, change the orthoBoxTolerance( currently %G ).\n", |
184 | > | orthoTolerance); |
185 | simError(); | |
186 | } | |
187 | else { | |
188 | sprintf( painCave.errMsg, | |
189 | "Hmat is switching from Orthorhombic to Non-OrthoRhombic\n" | |
190 | < | " If this is a bad thing change the ortho tolerance in SimInfo.\n" ); |
190 | > | " If this is a bad thing, change the orthoBoxTolerance( currently %G ).\n", |
191 | > | orthoTolerance); |
192 | simError(); | |
193 | } | |
194 | } | |
# | Line 525 | Line 527 | void SimInfo::refreshSim(){ | |
527 | this->ndf = this->getNDF(); | |
528 | this->ndfRaw = this->getNDFraw(); | |
529 | this->ndfTrans = this->getNDFtranslational(); | |
528 | – | } |
529 | – | |
530 | – | |
531 | – | void SimInfo::setRcut( double theRcut ){ |
532 | – | |
533 | – | rCut = theRcut; |
534 | – | checkCutOffs(); |
530 | } | |
531 | ||
532 | void SimInfo::setDefaultRcut( double theRcut ){ | |
533 | ||
534 | < | haveOrigRcut = 1; |
540 | < | origRcut = theRcut; |
534 | > | haveRcut = 1; |
535 | rCut = theRcut; | |
536 | ||
537 | ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; | |
# | Line 545 | Line 539 | void SimInfo::setDefaultRcut( double theRcut ){ | |
539 | notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | |
540 | } | |
541 | ||
548 | – | void SimInfo::setEcr( double theEcr ){ |
549 | – | |
550 | – | ecr = theEcr; |
551 | – | checkCutOffs(); |
552 | – | } |
553 | – | |
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 | ||
561 | – | ecr = theEcr; |
562 | – | |
549 | notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | |
550 | } | |
551 | ||
566 | – | void SimInfo::setEcr( double theEcr, double theEst ){ |
567 | – | |
568 | – | est = theEst; |
569 | – | setEcr( theEcr ); |
570 | – | } |
571 | – | |
552 | void SimInfo::setDefaultEcr( double theEcr, double theEst ){ | |
553 | ||
554 | est = theEst; | |
# | Line 577 | Line 557 | void SimInfo::checkCutOffs( void ){ | |
557 | ||
558 | ||
559 | void SimInfo::checkCutOffs( void ){ | |
580 | – | |
581 | – | int cutChanged = 0; |
560 | ||
561 | if( boxIsInit ){ | |
562 | ||
563 | //we need to check cutOffs against the box | |
564 | < | |
565 | < | //detect the change of rCut |
588 | < | if(( maxCutoff > rCut )&&(usePBC)){ |
589 | < | if( rCut < origRcut ){ |
590 | < | rCut = origRcut; |
591 | < | |
592 | < | if (rCut > maxCutoff) |
593 | < | rCut = maxCutoff; |
594 | < | |
595 | < | sprintf( painCave.errMsg, |
596 | < | "New Box size is setting the long range cutoff radius " |
597 | < | "to %lf at time %lf\n", |
598 | < | rCut, currentTime ); |
599 | < | painCave.isFatal = 0; |
600 | < | simError(); |
601 | < | } |
602 | < | } |
603 | < | 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(); | |
610 | – | 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, |
621 | < | "New Box size is setting the electrostaticCutoffRadius " |
622 | < | "to %lf at time %lf\n", |
623 | < | ecr, currentTime ); |
624 | < | painCave.isFatal = 0; |
625 | < | 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 | } | |
628 | – | else if( ecr > maxCutoff){ |
629 | – | sprintf( painCave.errMsg, |
630 | – | "New Box size is setting the electrostaticCutoffRadius " |
631 | – | "to %lf at time %lf\n", |
632 | – | maxCutoff, currentTime ); |
633 | – | painCave.isFatal = 0; |
634 | – | simError(); |
635 | – | ecr = maxCutoff; |
636 | – | } |
637 | – | |
638 | – | if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
639 | – | |
640 | – | // rlist is the 1.0 plus max( rcut, ecr ) |
641 | – | |
642 | – | ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
643 | – | |
644 | – | if( cutChanged ){ |
645 | – | notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
646 | – | } |
647 | – | |
648 | – | oldEcr = ecr; |
649 | – | oldRcut = rCut; |
650 | – | |
584 | } else { | |
585 | // initialize this stuff before using it, OK? | |
586 | sprintf( painCave.errMsg, |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |