1 |
< |
#include <cstdlib> |
2 |
< |
#include <cstring> |
3 |
< |
#include <cmath> |
1 |
> |
#include <stdlib.h> |
2 |
> |
#include <string.h> |
3 |
> |
#include <math.h> |
4 |
|
|
5 |
|
#include <iostream> |
6 |
|
using namespace std; |
37 |
|
thermalTime = 0.0; |
38 |
|
currentTime = 0.0; |
39 |
|
rCut = 0.0; |
40 |
– |
origRcut = -1.0; |
40 |
|
ecr = 0.0; |
42 |
– |
origEcr = -1.0; |
41 |
|
est = 0.0; |
44 |
– |
oldEcr = 0.0; |
45 |
– |
oldRcut = 0.0; |
42 |
|
|
43 |
< |
haveOrigRcut = 0; |
44 |
< |
haveOrigEcr = 0; |
43 |
> |
haveRcut = 0; |
44 |
> |
haveEcr = 0; |
45 |
|
boxIsInit = 0; |
46 |
|
|
47 |
|
resetTime = 1e99; |
52 |
– |
|
48 |
|
|
49 |
+ |
orthoTolerance = 1E-6; |
50 |
+ |
useInitXSstate = true; |
51 |
+ |
|
52 |
|
usePBC = 0; |
53 |
|
useLJ = 0; |
54 |
|
useSticky = 0; |
100 |
|
// [ 2 5 8 ] |
101 |
|
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
102 |
|
|
105 |
– |
|
103 |
|
if( !boxIsInit ) boxIsInit = 1; |
104 |
|
|
105 |
|
for(i=0; i < 3; i++) |
143 |
|
|
144 |
|
void SimInfo::calcHmatInv( void ) { |
145 |
|
|
146 |
+ |
int oldOrtho; |
147 |
|
int i,j; |
148 |
|
double smallDiag; |
149 |
|
double tol; |
151 |
|
|
152 |
|
invertMat3( Hmat, HmatInv ); |
153 |
|
|
156 |
– |
// Check the inverse to make sure it is sane: |
157 |
– |
|
158 |
– |
matMul3( Hmat, HmatInv, sanity ); |
159 |
– |
|
154 |
|
// check to see if Hmat is orthorhombic |
155 |
|
|
156 |
< |
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; |
156 |
> |
oldOrtho = orthoRhombic; |
157 |
|
|
158 |
+ |
smallDiag = fabs(Hmat[0][0]); |
159 |
+ |
if(smallDiag > fabs(Hmat[1][1])) smallDiag = fabs(Hmat[1][1]); |
160 |
+ |
if(smallDiag > fabs(Hmat[2][2])) smallDiag = fabs(Hmat[2][2]); |
161 |
+ |
tol = smallDiag * orthoTolerance; |
162 |
+ |
|
163 |
|
orthoRhombic = 1; |
164 |
|
|
165 |
|
for (i = 0; i < 3; i++ ) { |
166 |
|
for (j = 0 ; j < 3; j++) { |
167 |
|
if (i != j) { |
168 |
|
if (orthoRhombic) { |
169 |
< |
if (Hmat[i][j] >= tol) orthoRhombic = 0; |
169 |
> |
if ( fabs(Hmat[i][j]) >= tol) orthoRhombic = 0; |
170 |
|
} |
171 |
|
} |
172 |
|
} |
173 |
|
} |
174 |
+ |
|
175 |
+ |
if( oldOrtho != orthoRhombic ){ |
176 |
+ |
|
177 |
+ |
if( orthoRhombic ){ |
178 |
+ |
sprintf( painCave.errMsg, |
179 |
+ |
"Hmat is switching from Non-Orthorhombic to OrthoRhombic\n" |
180 |
+ |
" If this is a bad thing, change the orthoBoxTolerance( currently %G ).\n", |
181 |
+ |
orthoTolerance); |
182 |
+ |
simError(); |
183 |
+ |
} |
184 |
+ |
else { |
185 |
+ |
sprintf( painCave.errMsg, |
186 |
+ |
"Hmat is switching from Orthorhombic to Non-OrthoRhombic\n" |
187 |
+ |
" If this is a bad thing, change the orthoBoxTolerance( currently %G ).\n", |
188 |
+ |
orthoTolerance); |
189 |
+ |
simError(); |
190 |
+ |
} |
191 |
+ |
} |
192 |
|
} |
193 |
|
|
194 |
|
double SimInfo::matDet3(double a[3][3]) { |
526 |
|
this->ndfTrans = this->getNDFtranslational(); |
527 |
|
} |
528 |
|
|
529 |
+ |
void SimInfo::setDefaultRcut( double theRcut ){ |
530 |
|
|
531 |
< |
void SimInfo::setRcut( double theRcut ){ |
531 |
> |
haveRcut = 1; |
532 |
> |
rCut = theRcut; |
533 |
|
|
534 |
< |
if( !haveOrigRcut ){ |
519 |
< |
haveOrigRcut = 1; |
520 |
< |
origRcut = theRcut; |
521 |
< |
} |
534 |
> |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
535 |
|
|
536 |
< |
rCut = theRcut; |
524 |
< |
checkCutOffs(); |
536 |
> |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
537 |
|
} |
538 |
|
|
539 |
< |
void SimInfo::setEcr( double theEcr ){ |
539 |
> |
void SimInfo::setDefaultEcr( double theEcr ){ |
540 |
> |
|
541 |
> |
haveEcr = 1; |
542 |
> |
|
543 |
> |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
544 |
|
|
529 |
– |
if( !haveOrigEcr ){ |
530 |
– |
haveOrigEcr = 1; |
531 |
– |
origEcr = theEcr; |
532 |
– |
} |
533 |
– |
|
545 |
|
ecr = theEcr; |
546 |
< |
checkCutOffs(); |
546 |
> |
|
547 |
> |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
548 |
|
} |
549 |
|
|
550 |
< |
void SimInfo::setEcr( double theEcr, double theEst ){ |
550 |
> |
void SimInfo::setDefaultEcr( double theEcr, double theEst ){ |
551 |
|
|
552 |
|
est = theEst; |
553 |
< |
setEcr( theEcr ); |
553 |
> |
setDefaultEcr( theEcr ); |
554 |
|
} |
555 |
|
|
556 |
|
|
557 |
|
void SimInfo::checkCutOffs( void ){ |
546 |
– |
|
547 |
– |
int cutChanged = 0; |
558 |
|
|
559 |
|
if( boxIsInit ){ |
560 |
|
|
561 |
|
//we need to check cutOffs against the box |
562 |
< |
|
563 |
< |
//detect the change of rCut |
554 |
< |
if(( maxCutoff > rCut )&&(usePBC)){ |
555 |
< |
if( rCut < origRcut ){ |
556 |
< |
rCut = origRcut; |
557 |
< |
|
558 |
< |
if (rCut > maxCutoff) |
559 |
< |
rCut = maxCutoff; |
560 |
< |
|
561 |
< |
sprintf( painCave.errMsg, |
562 |
< |
"New Box size is setting the long range cutoff radius " |
563 |
< |
"to %lf at time %lf\n", |
564 |
< |
rCut, currentTime ); |
565 |
< |
painCave.isFatal = 0; |
566 |
< |
simError(); |
567 |
< |
} |
568 |
< |
} |
569 |
< |
else if ((rCut > maxCutoff)&&(usePBC)) { |
562 |
> |
|
563 |
> |
if( rCut > maxCutoff ){ |
564 |
|
sprintf( painCave.errMsg, |
565 |
< |
"New Box size is setting the long range cutoff radius " |
566 |
< |
"to %lf at time %lf\n", |
567 |
< |
maxCutoff, currentTime ); |
568 |
< |
painCave.isFatal = 0; |
565 |
> |
"Box size is too small for the long range cutoff radius, " |
566 |
> |
"%lf, at time %lf\n", |
567 |
> |
rCut, currentTime ); |
568 |
> |
painCave.isFatal = 1; |
569 |
|
simError(); |
576 |
– |
rCut = maxCutoff; |
570 |
|
} |
571 |
< |
|
572 |
< |
|
573 |
< |
//detect the change of ecr |
574 |
< |
if( maxCutoff > ecr ){ |
575 |
< |
if( ecr < origEcr ){ |
576 |
< |
ecr = origEcr; |
577 |
< |
if (ecr > maxCutoff) ecr = maxCutoff; |
578 |
< |
|
579 |
< |
sprintf( painCave.errMsg, |
587 |
< |
"New Box size is setting the electrostaticCutoffRadius " |
588 |
< |
"to %lf at time %lf\n", |
589 |
< |
ecr, currentTime ); |
590 |
< |
painCave.isFatal = 0; |
591 |
< |
simError(); |
571 |
> |
|
572 |
> |
if( haveEcr ){ |
573 |
> |
if( ecr > maxCutoff ){ |
574 |
> |
sprintf( painCave.errMsg, |
575 |
> |
"Box size is too small for the electrostatic cutoff radius, " |
576 |
> |
"%lf, at time %lf\n", |
577 |
> |
ecr, currentTime ); |
578 |
> |
painCave.isFatal = 1; |
579 |
> |
simError(); |
580 |
|
} |
581 |
|
} |
594 |
– |
else if( ecr > maxCutoff){ |
595 |
– |
sprintf( painCave.errMsg, |
596 |
– |
"New Box size is setting the electrostaticCutoffRadius " |
597 |
– |
"to %lf at time %lf\n", |
598 |
– |
maxCutoff, currentTime ); |
599 |
– |
painCave.isFatal = 0; |
600 |
– |
simError(); |
601 |
– |
ecr = maxCutoff; |
602 |
– |
} |
603 |
– |
|
604 |
– |
if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
605 |
– |
|
606 |
– |
// rlist is the 1.0 plus max( rcut, ecr ) |
607 |
– |
|
608 |
– |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
609 |
– |
|
610 |
– |
if( cutChanged ){ |
611 |
– |
|
612 |
– |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
613 |
– |
} |
614 |
– |
|
615 |
– |
oldEcr = ecr; |
616 |
– |
oldRcut = rCut; |
617 |
– |
|
582 |
|
} else { |
583 |
|
// initialize this stuff before using it, OK? |
584 |
|
sprintf( painCave.errMsg, |