| 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; |
| 49 |
|
boxIsInit = 0; |
| 50 |
|
|
| 51 |
|
resetTime = 1e99; |
| 52 |
– |
|
| 52 |
|
|
| 53 |
+ |
orthoTolerance = 1E-6; |
| 54 |
+ |
useInitXSstate = true; |
| 55 |
+ |
|
| 56 |
|
usePBC = 0; |
| 57 |
|
useLJ = 0; |
| 58 |
|
useSticky = 0; |
| 148 |
|
|
| 149 |
|
void SimInfo::calcHmatInv( void ) { |
| 150 |
|
|
| 151 |
+ |
int oldOrtho; |
| 152 |
|
int i,j; |
| 153 |
|
double smallDiag; |
| 154 |
|
double tol; |
| 156 |
|
|
| 157 |
|
invertMat3( Hmat, HmatInv ); |
| 158 |
|
|
| 156 |
– |
// Check the inverse to make sure it is sane: |
| 157 |
– |
|
| 158 |
– |
matMul3( Hmat, HmatInv, sanity ); |
| 159 |
– |
|
| 159 |
|
// check to see if Hmat is orthorhombic |
| 160 |
|
|
| 161 |
< |
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; |
| 161 |
> |
oldOrtho = orthoRhombic; |
| 162 |
|
|
| 163 |
+ |
smallDiag = fabs(Hmat[0][0]); |
| 164 |
+ |
if(smallDiag > fabs(Hmat[1][1])) smallDiag = fabs(Hmat[1][1]); |
| 165 |
+ |
if(smallDiag > fabs(Hmat[2][2])) smallDiag = fabs(Hmat[2][2]); |
| 166 |
+ |
tol = smallDiag * orthoTolerance; |
| 167 |
+ |
|
| 168 |
|
orthoRhombic = 1; |
| 169 |
|
|
| 170 |
|
for (i = 0; i < 3; i++ ) { |
| 171 |
|
for (j = 0 ; j < 3; j++) { |
| 172 |
|
if (i != j) { |
| 173 |
|
if (orthoRhombic) { |
| 174 |
< |
if (Hmat[i][j] >= tol) orthoRhombic = 0; |
| 174 |
> |
if ( fabs(Hmat[i][j]) >= tol) orthoRhombic = 0; |
| 175 |
|
} |
| 176 |
|
} |
| 177 |
|
} |
| 178 |
|
} |
| 179 |
+ |
|
| 180 |
+ |
if( oldOrtho != orthoRhombic ){ |
| 181 |
+ |
|
| 182 |
+ |
if( orthoRhombic ){ |
| 183 |
+ |
sprintf( painCave.errMsg, |
| 184 |
+ |
"Hmat is switching from Non-Orthorhombic to OrthoRhombic\n" |
| 185 |
+ |
" If this is a bad thing, change the orthoBoxTolerance( currently %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", |
| 193 |
+ |
orthoTolerance); |
| 194 |
+ |
simError(); |
| 195 |
+ |
} |
| 196 |
+ |
} |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
double SimInfo::matDet3(double a[3][3]) { |
| 534 |
|
|
| 535 |
|
void SimInfo::setRcut( double theRcut ){ |
| 536 |
|
|
| 518 |
– |
if( !haveOrigRcut ){ |
| 519 |
– |
haveOrigRcut = 1; |
| 520 |
– |
origRcut = theRcut; |
| 521 |
– |
} |
| 522 |
– |
|
| 537 |
|
rCut = theRcut; |
| 538 |
|
checkCutOffs(); |
| 539 |
|
} |
| 540 |
|
|
| 541 |
< |
void SimInfo::setEcr( double theEcr ){ |
| 541 |
> |
void SimInfo::setDefaultRcut( double theRcut ){ |
| 542 |
|
|
| 543 |
< |
if( !haveOrigEcr ){ |
| 544 |
< |
haveOrigEcr = 1; |
| 545 |
< |
origEcr = theEcr; |
| 532 |
< |
} |
| 543 |
> |
haveOrigRcut = 1; |
| 544 |
> |
origRcut = theRcut; |
| 545 |
> |
rCut = theRcut; |
| 546 |
|
|
| 547 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
| 548 |
+ |
|
| 549 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
| 550 |
+ |
} |
| 551 |
+ |
|
| 552 |
+ |
void SimInfo::setEcr( double theEcr ){ |
| 553 |
+ |
|
| 554 |
|
ecr = theEcr; |
| 555 |
|
checkCutOffs(); |
| 556 |
|
} |
| 557 |
|
|
| 558 |
+ |
void SimInfo::setDefaultEcr( double theEcr ){ |
| 559 |
+ |
|
| 560 |
+ |
haveOrigEcr = 1; |
| 561 |
+ |
origEcr = theEcr; |
| 562 |
+ |
|
| 563 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
| 564 |
+ |
|
| 565 |
+ |
ecr = theEcr; |
| 566 |
+ |
|
| 567 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
| 568 |
+ |
} |
| 569 |
+ |
|
| 570 |
|
void SimInfo::setEcr( double theEcr, double theEst ){ |
| 571 |
|
|
| 572 |
|
est = theEst; |
| 573 |
|
setEcr( theEcr ); |
| 574 |
|
} |
| 575 |
|
|
| 576 |
+ |
void SimInfo::setDefaultEcr( double theEcr, double theEst ){ |
| 577 |
|
|
| 578 |
+ |
est = theEst; |
| 579 |
+ |
setDefaultEcr( theEcr ); |
| 580 |
+ |
} |
| 581 |
+ |
|
| 582 |
+ |
|
| 583 |
|
void SimInfo::checkCutOffs( void ){ |
| 584 |
|
|
| 585 |
|
int cutChanged = 0; |
| 646 |
|
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
| 647 |
|
|
| 648 |
|
if( cutChanged ){ |
| 611 |
– |
|
| 649 |
|
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
| 650 |
|
} |
| 651 |
|
|