# | 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 146 | Line 146 | void SimInfo::calcHmatInv( void ) { | |
146 | ||
147 | void SimInfo::calcHmatInv( void ) { | |
148 | ||
149 | + | int oldOrtho; |
150 | int i,j; | |
151 | double smallDiag; | |
152 | double tol; | |
# | Line 153 | Line 154 | void SimInfo::calcHmatInv( void ) { | |
154 | ||
155 | invertMat3( Hmat, HmatInv ); | |
156 | ||
156 | – | // Check the inverse to make sure it is sane: |
157 | – | |
158 | – | matMul3( Hmat, HmatInv, sanity ); |
159 | – | |
157 | // check to see if Hmat is orthorhombic | |
158 | ||
159 | < | smallDiag = Hmat[0][0]; |
163 | < | if(smallDiag > Hmat[1][1]) smallDiag = Hmat[1][1]; |
164 | < | if(smallDiag > Hmat[2][2]) smallDiag = Hmat[2][2]; |
165 | < | tol = smallDiag * 1E-6; |
159 | > | oldOrtho = orthoRhombic; |
160 | ||
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 * orthoTolerance; |
165 | + | |
166 | orthoRhombic = 1; | |
167 | ||
168 | for (i = 0; i < 3; i++ ) { | |
169 | for (j = 0 ; j < 3; j++) { | |
170 | if (i != j) { | |
171 | if (orthoRhombic) { | |
172 | < | if (Hmat[i][j] >= tol) orthoRhombic = 0; |
172 | > | if ( fabs(Hmat[i][j]) >= tol) orthoRhombic = 0; |
173 | } | |
174 | } | |
175 | } | |
176 | } | |
177 | + | |
178 | + | if( oldOrtho != orthoRhombic ){ |
179 | + | |
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 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 orthoBoxTolerance( currently %G ).\n", |
191 | + | orthoTolerance); |
192 | + | simError(); |
193 | + | } |
194 | + | } |
195 | } | |
196 | ||
197 | double SimInfo::matDet3(double a[3][3]) { | |
# | Line 511 | Line 528 | void SimInfo::refreshSim(){ | |
528 | this->ndfRaw = this->getNDFraw(); | |
529 | this->ndfTrans = this->getNDFtranslational(); | |
530 | } | |
514 | – | |
515 | – | |
516 | – | void SimInfo::setRcut( double theRcut ){ |
531 | ||
518 | – | rCut = theRcut; |
519 | – | checkCutOffs(); |
520 | – | } |
521 | – | |
532 | void SimInfo::setDefaultRcut( double theRcut ){ | |
533 | ||
534 | < | haveOrigRcut = 1; |
525 | < | origRcut = theRcut; |
534 | > | haveRcut = 1; |
535 | rCut = theRcut; | |
536 | ||
537 | ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; | |
# | Line 530 | Line 539 | void SimInfo::setDefaultRcut( double theRcut ){ | |
539 | notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | |
540 | } | |
541 | ||
533 | – | void SimInfo::setEcr( double theEcr ){ |
534 | – | |
535 | – | ecr = theEcr; |
536 | – | checkCutOffs(); |
537 | – | } |
538 | – | |
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 | ||
546 | – | ecr = theEcr; |
547 | – | |
549 | notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); | |
550 | } | |
551 | ||
551 | – | void SimInfo::setEcr( double theEcr, double theEst ){ |
552 | – | |
553 | – | est = theEst; |
554 | – | setEcr( theEcr ); |
555 | – | } |
556 | – | |
552 | void SimInfo::setDefaultEcr( double theEcr, double theEst ){ | |
553 | ||
554 | est = theEst; | |
# | Line 562 | Line 557 | void SimInfo::checkCutOffs( void ){ | |
557 | ||
558 | ||
559 | void SimInfo::checkCutOffs( void ){ | |
565 | – | |
566 | – | int cutChanged = 0; |
560 | ||
561 | if( boxIsInit ){ | |
562 | ||
563 | //we need to check cutOffs against the box | |
564 | < | |
565 | < | //detect the change of rCut |
573 | < | if(( maxCutoff > rCut )&&(usePBC)){ |
574 | < | if( rCut < origRcut ){ |
575 | < | rCut = origRcut; |
576 | < | |
577 | < | if (rCut > maxCutoff) |
578 | < | rCut = maxCutoff; |
579 | < | |
580 | < | sprintf( painCave.errMsg, |
581 | < | "New Box size is setting the long range cutoff radius " |
582 | < | "to %lf at time %lf\n", |
583 | < | rCut, currentTime ); |
584 | < | painCave.isFatal = 0; |
585 | < | simError(); |
586 | < | } |
587 | < | } |
588 | < | 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 | > | "%G, at time %G\n" |
569 | > | " [ %G %G %G ]\n" |
570 | > | " [ %G %G %G ]\n" |
571 | > | " [ %G %G %G ]\n", |
572 | > | rCut, currentTime, |
573 | > | Hmat[0][0], Hmat[0][1], Hmat[0][2], |
574 | > | Hmat[1][0], Hmat[1][1], Hmat[1][2], |
575 | > | Hmat[2][0], Hmat[2][1], Hmat[2][2]); |
576 | > | painCave.isFatal = 1; |
577 | simError(); | |
595 | – | rCut = maxCutoff; |
578 | } | |
579 | < | |
580 | < | |
581 | < | //detect the change of ecr |
582 | < | if( maxCutoff > ecr ){ |
583 | < | if( ecr < origEcr ){ |
584 | < | ecr = origEcr; |
585 | < | if (ecr > maxCutoff) ecr = maxCutoff; |
586 | < | |
587 | < | sprintf( painCave.errMsg, |
588 | < | "New Box size is setting the electrostaticCutoffRadius " |
589 | < | "to %lf at time %lf\n", |
590 | < | ecr, currentTime ); |
591 | < | painCave.isFatal = 0; |
592 | < | simError(); |
579 | > | |
580 | > | if( haveEcr ){ |
581 | > | if( ecr > maxCutoff ){ |
582 | > | sprintf( painCave.errMsg, |
583 | > | "Box size is too small for the electrostatic cutoff radius, " |
584 | > | "%G, at time %G\n" |
585 | > | " [ %G %G %G ]\n" |
586 | > | " [ %G %G %G ]\n" |
587 | > | " [ %G %G %G ]\n", |
588 | > | ecr, currentTime, |
589 | > | Hmat[0][0], Hmat[0][1], Hmat[0][2], |
590 | > | Hmat[1][0], Hmat[1][1], Hmat[1][2], |
591 | > | Hmat[2][0], Hmat[2][1], Hmat[2][2]); |
592 | > | painCave.isFatal = 1; |
593 | > | simError(); |
594 | } | |
595 | } | |
613 | – | else if( ecr > maxCutoff){ |
614 | – | sprintf( painCave.errMsg, |
615 | – | "New Box size is setting the electrostaticCutoffRadius " |
616 | – | "to %lf at time %lf\n", |
617 | – | maxCutoff, currentTime ); |
618 | – | painCave.isFatal = 0; |
619 | – | simError(); |
620 | – | ecr = maxCutoff; |
621 | – | } |
622 | – | |
623 | – | if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
624 | – | |
625 | – | // rlist is the 1.0 plus max( rcut, ecr ) |
626 | – | |
627 | – | ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
628 | – | |
629 | – | if( cutChanged ){ |
630 | – | notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
631 | – | } |
632 | – | |
633 | – | oldEcr = ecr; |
634 | – | oldRcut = rCut; |
635 | – | |
596 | } else { | |
597 | // initialize this stuff before using it, OK? | |
598 | sprintf( painCave.errMsg, |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |