33 |
|
the_integrator = NULL; |
34 |
|
setTemp = 0; |
35 |
|
thermalTime = 0.0; |
36 |
+ |
currentTime = 0.0; |
37 |
|
rCut = 0.0; |
38 |
+ |
ecr = 0.0; |
39 |
+ |
est = 0.0; |
40 |
+ |
oldEcr = 0.0; |
41 |
+ |
oldRcut = 0.0; |
42 |
|
|
43 |
+ |
haveOrigRcut = 0; |
44 |
+ |
haveOrigEcr = 0; |
45 |
+ |
boxIsInit = 0; |
46 |
+ |
|
47 |
+ |
|
48 |
+ |
|
49 |
|
usePBC = 0; |
50 |
|
useLJ = 0; |
51 |
|
useSticky = 0; |
84 |
|
// [ 2 5 8 ] |
85 |
|
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
86 |
|
|
87 |
+ |
|
88 |
+ |
if( !boxIsInit ) boxIsInit = 1; |
89 |
|
|
90 |
|
for(i=0; i < 3; i++) |
91 |
|
for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; |
92 |
|
|
80 |
– |
cerr |
81 |
– |
<< "setting Hmat ->\n" |
82 |
– |
<< "[ " << Hmat[0][0] << ", " << Hmat[0][1] << ", " << Hmat[0][2] << " ]\n" |
83 |
– |
<< "[ " << Hmat[1][0] << ", " << Hmat[1][1] << ", " << Hmat[1][2] << " ]\n" |
84 |
– |
<< "[ " << Hmat[2][0] << ", " << Hmat[2][1] << ", " << Hmat[2][2] << " ]\n"; |
85 |
– |
|
93 |
|
calcBoxL(); |
94 |
|
calcHmatInv(); |
95 |
|
|
100 |
|
} |
101 |
|
} |
102 |
|
|
103 |
< |
setFortranBoxSize(FortranHmat, FortranHmatI, &orthoRhombic); |
103 |
> |
setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); |
104 |
|
|
98 |
– |
smallestBoxL = boxLx; |
99 |
– |
if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
100 |
– |
if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
101 |
– |
|
102 |
– |
maxCutoff = smallestBoxL / 2.0; |
103 |
– |
|
104 |
– |
if (rList > maxCutoff) { |
105 |
– |
sprintf( painCave.errMsg, |
106 |
– |
"New Box size is forcing neighborlist radius down to %lf\n", |
107 |
– |
maxCutoff ); |
108 |
– |
painCave.isFatal = 0; |
109 |
– |
simError(); |
110 |
– |
|
111 |
– |
rList = maxCutoff; |
112 |
– |
|
113 |
– |
sprintf( painCave.errMsg, |
114 |
– |
"New Box size is forcing cutoff radius down to %lf\n", |
115 |
– |
maxCutoff - 1.0 ); |
116 |
– |
painCave.isFatal = 0; |
117 |
– |
simError(); |
118 |
– |
|
119 |
– |
rCut = rList - 1.0; |
120 |
– |
|
121 |
– |
// list radius changed so we have to refresh the simulation structure. |
122 |
– |
refreshSim(); |
123 |
– |
} |
124 |
– |
|
125 |
– |
if (rCut > maxCutoff) { |
126 |
– |
sprintf( painCave.errMsg, |
127 |
– |
"New Box size is forcing cutoff radius down to %lf\n", |
128 |
– |
maxCutoff ); |
129 |
– |
painCave.isFatal = 0; |
130 |
– |
simError(); |
131 |
– |
|
132 |
– |
status = 0; |
133 |
– |
LJ_new_rcut(&rCut, &status); |
134 |
– |
if (status != 0) { |
135 |
– |
sprintf( painCave.errMsg, |
136 |
– |
"Error in recomputing LJ shifts based on new rcut\n"); |
137 |
– |
painCave.isFatal = 1; |
138 |
– |
simError(); |
139 |
– |
} |
140 |
– |
} |
105 |
|
} |
106 |
|
|
107 |
|
|
117 |
|
double theBox[3][3]; |
118 |
|
int i, j; |
119 |
|
|
120 |
< |
cerr << "Scaling box by " << scale << "\n"; |
120 |
> |
// cerr << "Scaling box by " << scale << "\n"; |
121 |
|
|
122 |
|
for(i=0; i<3; i++) |
123 |
|
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale; |
127 |
|
} |
128 |
|
|
129 |
|
void SimInfo::calcHmatInv( void ) { |
130 |
< |
|
130 |
> |
|
131 |
> |
int i,j; |
132 |
|
double smallDiag; |
133 |
|
double tol; |
134 |
|
double sanity[3][3]; |
138 |
|
// Check the inverse to make sure it is sane: |
139 |
|
|
140 |
|
matMul3( Hmat, HmatInv, sanity ); |
176 |
– |
|
177 |
– |
cerr << "sanity => \n" |
178 |
– |
<< sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n" |
179 |
– |
<< sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n" |
180 |
– |
<< sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2] |
181 |
– |
<< "\n"; |
141 |
|
|
142 |
|
// check to see if Hmat is orthorhombic |
143 |
|
|
230 |
|
outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2; |
231 |
|
outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2; |
232 |
|
} |
233 |
+ |
|
234 |
+ |
void SimInfo::transposeMat3(double in[3][3], double out[3][3]) { |
235 |
+ |
double temp[3][3]; |
236 |
+ |
int i, j; |
237 |
+ |
|
238 |
+ |
for (i = 0; i < 3; i++) { |
239 |
+ |
for (j = 0; j < 3; j++) { |
240 |
+ |
temp[j][i] = in[i][j]; |
241 |
+ |
} |
242 |
+ |
} |
243 |
+ |
for (i = 0; i < 3; i++) { |
244 |
+ |
for (j = 0; j < 3; j++) { |
245 |
+ |
out[i][j] = temp[i][j]; |
246 |
+ |
} |
247 |
+ |
} |
248 |
+ |
} |
249 |
|
|
250 |
+ |
void SimInfo::printMat3(double A[3][3] ){ |
251 |
+ |
|
252 |
+ |
std::cerr |
253 |
+ |
<< "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n" |
254 |
+ |
<< "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n" |
255 |
+ |
<< "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n"; |
256 |
+ |
} |
257 |
+ |
|
258 |
+ |
void SimInfo::printMat9(double A[9] ){ |
259 |
+ |
|
260 |
+ |
std::cerr |
261 |
+ |
<< "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n" |
262 |
+ |
<< "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n" |
263 |
+ |
<< "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n"; |
264 |
+ |
} |
265 |
+ |
|
266 |
|
void SimInfo::calcBoxL( void ){ |
267 |
|
|
268 |
|
double dx, dy, dz, dsq; |
276 |
|
|
277 |
|
dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; |
278 |
|
dsq = dx*dx + dy*dy + dz*dz; |
279 |
< |
boxLx = sqrt( dsq ); |
279 |
> |
boxL[0] = sqrt( dsq ); |
280 |
> |
maxCutoff = 0.5 * boxL[0]; |
281 |
|
|
282 |
|
// boxLy |
283 |
|
|
284 |
|
dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; |
285 |
|
dsq = dx*dx + dy*dy + dz*dz; |
286 |
< |
boxLy = sqrt( dsq ); |
286 |
> |
boxL[1] = sqrt( dsq ); |
287 |
> |
if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1]; |
288 |
|
|
289 |
|
// boxLz |
290 |
|
|
291 |
|
dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; |
292 |
|
dsq = dx*dx + dy*dy + dz*dz; |
293 |
< |
boxLz = sqrt( dsq ); |
294 |
< |
|
293 |
> |
boxL[2] = sqrt( dsq ); |
294 |
> |
if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2]; |
295 |
> |
|
296 |
|
} |
297 |
|
|
298 |
|
|
372 |
|
int isError; |
373 |
|
int n_global; |
374 |
|
int* excl; |
375 |
< |
|
382 |
< |
fInfo.rrf = 0.0; |
383 |
< |
fInfo.rt = 0.0; |
375 |
> |
|
376 |
|
fInfo.dielect = 0.0; |
377 |
|
|
386 |
– |
fInfo.rlist = rList; |
387 |
– |
fInfo.rcut = rCut; |
388 |
– |
|
378 |
|
if( useDipole ){ |
390 |
– |
fInfo.rrf = ecr; |
391 |
– |
fInfo.rt = ecr - est; |
379 |
|
if( useReactionField )fInfo.dielect = dielectric; |
380 |
|
} |
381 |
|
|
424 |
|
|
425 |
|
} |
426 |
|
|
427 |
+ |
|
428 |
+ |
void SimInfo::setRcut( double theRcut ){ |
429 |
+ |
|
430 |
+ |
if( !haveOrigRcut ){ |
431 |
+ |
haveOrigRcut = 1; |
432 |
+ |
origRcut = theRcut; |
433 |
+ |
} |
434 |
+ |
|
435 |
+ |
rCut = theRcut; |
436 |
+ |
checkCutOffs(); |
437 |
+ |
} |
438 |
+ |
|
439 |
+ |
void SimInfo::setEcr( double theEcr ){ |
440 |
+ |
|
441 |
+ |
if( !haveOrigEcr ){ |
442 |
+ |
haveOrigEcr = 1; |
443 |
+ |
origEcr = theEcr; |
444 |
+ |
} |
445 |
+ |
|
446 |
+ |
ecr = theEcr; |
447 |
+ |
checkCutOffs(); |
448 |
+ |
} |
449 |
+ |
|
450 |
+ |
void SimInfo::setEcr( double theEcr, double theEst ){ |
451 |
+ |
|
452 |
+ |
est = theEst; |
453 |
+ |
setEcr( theEcr ); |
454 |
+ |
} |
455 |
+ |
|
456 |
+ |
|
457 |
+ |
void SimInfo::checkCutOffs( void ){ |
458 |
+ |
|
459 |
+ |
int cutChanged = 0; |
460 |
+ |
|
461 |
+ |
if( boxIsInit ){ |
462 |
+ |
|
463 |
+ |
//we need to check cutOffs against the box |
464 |
+ |
|
465 |
+ |
if( maxCutoff > rCut ){ |
466 |
+ |
if( rCut < origRcut ){ |
467 |
+ |
rCut = origRcut; |
468 |
+ |
if (rCut > maxCutoff) rCut = maxCutoff; |
469 |
+ |
|
470 |
+ |
sprintf( painCave.errMsg, |
471 |
+ |
"New Box size is setting the long range cutoff radius " |
472 |
+ |
"to %lf\n", |
473 |
+ |
rCut ); |
474 |
+ |
painCave.isFatal = 0; |
475 |
+ |
simError(); |
476 |
+ |
} |
477 |
+ |
} |
478 |
+ |
|
479 |
+ |
if( maxCutoff > ecr ){ |
480 |
+ |
if( ecr < origEcr ){ |
481 |
+ |
rCut = origEcr; |
482 |
+ |
if (ecr > maxCutoff) ecr = maxCutoff; |
483 |
+ |
|
484 |
+ |
sprintf( painCave.errMsg, |
485 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
486 |
+ |
"to %lf\n", |
487 |
+ |
ecr ); |
488 |
+ |
painCave.isFatal = 0; |
489 |
+ |
simError(); |
490 |
+ |
} |
491 |
+ |
} |
492 |
+ |
|
493 |
+ |
|
494 |
+ |
if (rCut > maxCutoff) { |
495 |
+ |
sprintf( painCave.errMsg, |
496 |
+ |
"New Box size is setting the long range cutoff radius " |
497 |
+ |
"to %lf\n", |
498 |
+ |
maxCutoff ); |
499 |
+ |
painCave.isFatal = 0; |
500 |
+ |
simError(); |
501 |
+ |
rCut = maxCutoff; |
502 |
+ |
} |
503 |
+ |
|
504 |
+ |
if( ecr > maxCutoff){ |
505 |
+ |
sprintf( painCave.errMsg, |
506 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
507 |
+ |
"to %lf\n", |
508 |
+ |
maxCutoff ); |
509 |
+ |
painCave.isFatal = 0; |
510 |
+ |
simError(); |
511 |
+ |
ecr = maxCutoff; |
512 |
+ |
} |
513 |
+ |
|
514 |
+ |
|
515 |
+ |
} |
516 |
+ |
|
517 |
+ |
|
518 |
+ |
if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
519 |
+ |
|
520 |
+ |
// rlist is the 1.0 plus max( rcut, ecr ) |
521 |
+ |
|
522 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
523 |
+ |
|
524 |
+ |
if( cutChanged ){ |
525 |
+ |
|
526 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
527 |
+ |
} |
528 |
+ |
|
529 |
+ |
oldEcr = ecr; |
530 |
+ |
oldRcut = rCut; |
531 |
+ |
} |