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; |
52 |
– |
|
51 |
|
|
52 |
+ |
orthoTolerance = 1E-6; |
53 |
+ |
useInitXSstate = true; |
54 |
+ |
|
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; |
63 |
|
|
64 |
|
myConfiguration = new SimState(); |
65 |
|
|
66 |
+ |
has_minimizer = false; |
67 |
+ |
the_minimizer =NULL; |
68 |
+ |
|
69 |
|
wrapMeSimInfo( this ); |
70 |
|
} |
71 |
|
|
107 |
|
// [ 2 5 8 ] |
108 |
|
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
109 |
|
|
105 |
– |
|
110 |
|
if( !boxIsInit ) boxIsInit = 1; |
111 |
|
|
112 |
|
for(i=0; i < 3; i++) |
150 |
|
|
151 |
|
void SimInfo::calcHmatInv( void ) { |
152 |
|
|
153 |
+ |
int oldOrtho; |
154 |
|
int i,j; |
155 |
|
double smallDiag; |
156 |
|
double tol; |
158 |
|
|
159 |
|
invertMat3( Hmat, HmatInv ); |
160 |
|
|
156 |
– |
// Check the inverse to make sure it is sane: |
157 |
– |
|
158 |
– |
matMul3( Hmat, HmatInv, sanity ); |
159 |
– |
|
161 |
|
// check to see if Hmat is orthorhombic |
162 |
|
|
163 |
< |
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; |
163 |
> |
oldOrtho = orthoRhombic; |
164 |
|
|
165 |
+ |
smallDiag = fabs(Hmat[0][0]); |
166 |
+ |
if(smallDiag > fabs(Hmat[1][1])) smallDiag = fabs(Hmat[1][1]); |
167 |
+ |
if(smallDiag > fabs(Hmat[2][2])) smallDiag = fabs(Hmat[2][2]); |
168 |
+ |
tol = smallDiag * orthoTolerance; |
169 |
+ |
|
170 |
|
orthoRhombic = 1; |
171 |
|
|
172 |
|
for (i = 0; i < 3; i++ ) { |
173 |
|
for (j = 0 ; j < 3; j++) { |
174 |
|
if (i != j) { |
175 |
|
if (orthoRhombic) { |
176 |
< |
if (Hmat[i][j] >= tol) orthoRhombic = 0; |
176 |
> |
if ( fabs(Hmat[i][j]) >= tol) orthoRhombic = 0; |
177 |
|
} |
178 |
|
} |
179 |
|
} |
180 |
|
} |
181 |
+ |
|
182 |
+ |
if( oldOrtho != orthoRhombic ){ |
183 |
+ |
|
184 |
+ |
if( orthoRhombic ){ |
185 |
+ |
sprintf( painCave.errMsg, |
186 |
+ |
"Hmat is switching from Non-Orthorhombic to Orthorhombic Box.\n" |
187 |
+ |
"\tIf this is a bad thing, change the orthoBoxTolerance\n" |
188 |
+ |
"\tvariable ( currently set to %G ).\n", |
189 |
+ |
orthoTolerance); |
190 |
+ |
simError(); |
191 |
+ |
} |
192 |
+ |
else { |
193 |
+ |
sprintf( painCave.errMsg, |
194 |
+ |
"Hmat is switching from Orthorhombic to Non-Orthorhombic Box.\n" |
195 |
+ |
"\tIf this is a bad thing, change the orthoBoxTolerance\n" |
196 |
+ |
"\tvariable ( currently set to %G ).\n", |
197 |
+ |
orthoTolerance); |
198 |
+ |
simError(); |
199 |
+ |
} |
200 |
+ |
} |
201 |
|
} |
202 |
|
|
203 |
|
double SimInfo::matDet3(double a[3][3]) { |
486 |
|
|
487 |
|
fInfo.dielect = 0.0; |
488 |
|
|
489 |
< |
if( useDipole ){ |
489 |
> |
if( useDipoles ){ |
490 |
|
if( useReactionField )fInfo.dielect = dielectric; |
491 |
|
} |
492 |
|
|
495 |
|
fInfo.SIM_uses_LJ = useLJ; |
496 |
|
fInfo.SIM_uses_sticky = useSticky; |
497 |
|
//fInfo.SIM_uses_sticky = 0; |
498 |
< |
fInfo.SIM_uses_dipoles = useDipole; |
498 |
> |
fInfo.SIM_uses_charges = useCharges; |
499 |
> |
fInfo.SIM_uses_dipoles = useDipoles; |
500 |
|
//fInfo.SIM_uses_dipoles = 0; |
501 |
< |
//fInfo.SIM_uses_RF = useReactionField; |
502 |
< |
fInfo.SIM_uses_RF = 0; |
501 |
> |
fInfo.SIM_uses_RF = useReactionField; |
502 |
> |
//fInfo.SIM_uses_RF = 0; |
503 |
|
fInfo.SIM_uses_GB = useGB; |
504 |
|
fInfo.SIM_uses_EAM = useEAM; |
505 |
|
|
536 |
|
this->ndfTrans = this->getNDFtranslational(); |
537 |
|
} |
538 |
|
|
539 |
+ |
void SimInfo::setDefaultRcut( double theRcut ){ |
540 |
|
|
541 |
< |
void SimInfo::setRcut( double theRcut ){ |
517 |
< |
|
541 |
> |
haveRcut = 1; |
542 |
|
rCut = theRcut; |
519 |
– |
checkCutOffs(); |
520 |
– |
} |
543 |
|
|
544 |
< |
void SimInfo::setDefaultRcut( double theRcut ){ |
523 |
< |
|
524 |
< |
haveOrigRcut = 1; |
525 |
< |
origRcut = theRcut; |
526 |
< |
rCut = theRcut; |
544 |
> |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
545 |
|
|
546 |
|
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
547 |
|
} |
548 |
|
|
531 |
– |
void SimInfo::setEcr( double theEcr ){ |
532 |
– |
|
533 |
– |
ecr = theEcr; |
534 |
– |
checkCutOffs(); |
535 |
– |
} |
536 |
– |
|
549 |
|
void SimInfo::setDefaultEcr( double theEcr ){ |
550 |
|
|
551 |
< |
haveOrigEcr = 1; |
540 |
< |
origEcr = theEcr; |
541 |
< |
|
551 |
> |
haveEcr = 1; |
552 |
|
ecr = theEcr; |
553 |
< |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
554 |
< |
} |
553 |
> |
|
554 |
> |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
555 |
|
|
556 |
< |
void SimInfo::setEcr( double theEcr, double theEst ){ |
547 |
< |
|
548 |
< |
est = theEst; |
549 |
< |
setEcr( theEcr ); |
556 |
> |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
557 |
|
} |
558 |
|
|
559 |
|
void SimInfo::setDefaultEcr( double theEcr, double theEst ){ |
564 |
|
|
565 |
|
|
566 |
|
void SimInfo::checkCutOffs( void ){ |
560 |
– |
|
561 |
– |
int cutChanged = 0; |
567 |
|
|
568 |
|
if( boxIsInit ){ |
569 |
|
|
570 |
|
//we need to check cutOffs against the box |
571 |
< |
|
572 |
< |
//detect the change of rCut |
568 |
< |
if(( maxCutoff > rCut )&&(usePBC)){ |
569 |
< |
if( rCut < origRcut ){ |
570 |
< |
rCut = origRcut; |
571 |
< |
|
572 |
< |
if (rCut > maxCutoff) |
573 |
< |
rCut = maxCutoff; |
574 |
< |
|
575 |
< |
sprintf( painCave.errMsg, |
576 |
< |
"New Box size is setting the long range cutoff radius " |
577 |
< |
"to %lf at time %lf\n", |
578 |
< |
rCut, currentTime ); |
579 |
< |
painCave.isFatal = 0; |
580 |
< |
simError(); |
581 |
< |
} |
582 |
< |
} |
583 |
< |
else if ((rCut > maxCutoff)&&(usePBC)) { |
571 |
> |
|
572 |
> |
if( rCut > maxCutoff ){ |
573 |
|
sprintf( painCave.errMsg, |
574 |
< |
"New Box size is setting the long range cutoff radius " |
575 |
< |
"to %lf at time %lf\n", |
576 |
< |
maxCutoff, currentTime ); |
577 |
< |
painCave.isFatal = 0; |
574 |
> |
"Box size is too small for the long range cutoff radius, " |
575 |
> |
"%G, at time %G\n" |
576 |
> |
"\t[ %G %G %G ]\n" |
577 |
> |
"\t[ %G %G %G ]\n" |
578 |
> |
"\t[ %G %G %G ]\n", |
579 |
> |
rCut, currentTime, |
580 |
> |
Hmat[0][0], Hmat[0][1], Hmat[0][2], |
581 |
> |
Hmat[1][0], Hmat[1][1], Hmat[1][2], |
582 |
> |
Hmat[2][0], Hmat[2][1], Hmat[2][2]); |
583 |
> |
painCave.isFatal = 1; |
584 |
|
simError(); |
590 |
– |
rCut = maxCutoff; |
585 |
|
} |
586 |
< |
|
587 |
< |
|
588 |
< |
//detect the change of ecr |
589 |
< |
if( maxCutoff > ecr ){ |
590 |
< |
if( ecr < origEcr ){ |
591 |
< |
ecr = origEcr; |
592 |
< |
if (ecr > maxCutoff) ecr = maxCutoff; |
593 |
< |
|
594 |
< |
sprintf( painCave.errMsg, |
595 |
< |
"New Box size is setting the electrostaticCutoffRadius " |
596 |
< |
"to %lf at time %lf\n", |
597 |
< |
ecr, currentTime ); |
598 |
< |
painCave.isFatal = 0; |
599 |
< |
simError(); |
586 |
> |
|
587 |
> |
if( haveEcr ){ |
588 |
> |
if( ecr > maxCutoff ){ |
589 |
> |
sprintf( painCave.errMsg, |
590 |
> |
"Box size is too small for the electrostatic cutoff radius, " |
591 |
> |
"%G, at time %G\n" |
592 |
> |
"\t[ %G %G %G ]\n" |
593 |
> |
"\t[ %G %G %G ]\n" |
594 |
> |
"\t[ %G %G %G ]\n", |
595 |
> |
ecr, currentTime, |
596 |
> |
Hmat[0][0], Hmat[0][1], Hmat[0][2], |
597 |
> |
Hmat[1][0], Hmat[1][1], Hmat[1][2], |
598 |
> |
Hmat[2][0], Hmat[2][1], Hmat[2][2]); |
599 |
> |
painCave.isFatal = 1; |
600 |
> |
simError(); |
601 |
|
} |
602 |
|
} |
608 |
– |
else if( ecr > maxCutoff){ |
609 |
– |
sprintf( painCave.errMsg, |
610 |
– |
"New Box size is setting the electrostaticCutoffRadius " |
611 |
– |
"to %lf at time %lf\n", |
612 |
– |
maxCutoff, currentTime ); |
613 |
– |
painCave.isFatal = 0; |
614 |
– |
simError(); |
615 |
– |
ecr = maxCutoff; |
616 |
– |
} |
617 |
– |
|
618 |
– |
if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
619 |
– |
|
620 |
– |
// rlist is the 1.0 plus max( rcut, ecr ) |
621 |
– |
|
622 |
– |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
623 |
– |
|
624 |
– |
if( cutChanged ){ |
625 |
– |
|
626 |
– |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
627 |
– |
} |
628 |
– |
|
629 |
– |
oldEcr = ecr; |
630 |
– |
oldRcut = rCut; |
631 |
– |
|
603 |
|
} else { |
604 |
|
// initialize this stuff before using it, OK? |
605 |
|
sprintf( painCave.errMsg, |
606 |
< |
"Trying to check cutoffs without a box. Be smarter.\n" ); |
606 |
> |
"Trying to check cutoffs without a box.\n" |
607 |
> |
"\tOOPSE should have better programmers than that.\n" ); |
608 |
|
painCave.isFatal = 1; |
609 |
|
simError(); |
610 |
|
} |