30 |
|
n_dipoles = 0; |
31 |
|
ndf = 0; |
32 |
|
ndfRaw = 0; |
33 |
+ |
nZconstraints = 0; |
34 |
|
the_integrator = NULL; |
35 |
|
setTemp = 0; |
36 |
|
thermalTime = 0.0; |
37 |
+ |
currentTime = 0.0; |
38 |
|
rCut = 0.0; |
39 |
+ |
origRcut = -1.0; |
40 |
+ |
ecr = 0.0; |
41 |
+ |
origEcr = -1.0; |
42 |
+ |
est = 0.0; |
43 |
+ |
oldEcr = 0.0; |
44 |
+ |
oldRcut = 0.0; |
45 |
|
|
46 |
+ |
haveOrigRcut = 0; |
47 |
+ |
haveOrigEcr = 0; |
48 |
+ |
boxIsInit = 0; |
49 |
+ |
|
50 |
+ |
|
51 |
+ |
|
52 |
|
usePBC = 0; |
53 |
|
useLJ = 0; |
54 |
|
useSticky = 0; |
57 |
|
useGB = 0; |
58 |
|
useEAM = 0; |
59 |
|
|
60 |
+ |
myConfiguration = new SimState(); |
61 |
+ |
|
62 |
|
wrapMeSimInfo( this ); |
63 |
|
} |
64 |
|
|
65 |
+ |
|
66 |
+ |
SimInfo::~SimInfo(){ |
67 |
+ |
|
68 |
+ |
delete myConfiguration; |
69 |
+ |
|
70 |
+ |
map<string, GenericData*>::iterator i; |
71 |
+ |
|
72 |
+ |
for(i = properties.begin(); i != properties.end(); i++) |
73 |
+ |
delete (*i).second; |
74 |
+ |
|
75 |
+ |
} |
76 |
+ |
|
77 |
|
void SimInfo::setBox(double newBox[3]) { |
78 |
|
|
79 |
|
int i, j; |
101 |
|
// [ 2 5 8 ] |
102 |
|
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
103 |
|
|
104 |
+ |
|
105 |
+ |
if( !boxIsInit ) boxIsInit = 1; |
106 |
|
|
107 |
|
for(i=0; i < 3; i++) |
108 |
|
for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; |
109 |
|
|
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 |
– |
|
110 |
|
calcBoxL(); |
111 |
|
calcHmatInv(); |
112 |
|
|
117 |
|
} |
118 |
|
} |
119 |
|
|
120 |
< |
setFortranBoxSize(FortranHmat, FortranHmatI, &orthoRhombic); |
120 |
> |
setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); |
121 |
|
|
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 |
– |
} |
122 |
|
} |
123 |
|
|
124 |
|
|
134 |
|
double theBox[3][3]; |
135 |
|
int i, j; |
136 |
|
|
137 |
< |
cerr << "Scaling box by " << scale << "\n"; |
137 |
> |
// cerr << "Scaling box by " << scale << "\n"; |
138 |
|
|
139 |
|
for(i=0; i<3; i++) |
140 |
|
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale; |
144 |
|
} |
145 |
|
|
146 |
|
void SimInfo::calcHmatInv( void ) { |
147 |
< |
|
147 |
> |
|
148 |
> |
int i,j; |
149 |
|
double smallDiag; |
150 |
|
double tol; |
151 |
|
double sanity[3][3]; |
155 |
|
// Check the inverse to make sure it is sane: |
156 |
|
|
157 |
|
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"; |
158 |
|
|
159 |
|
// check to see if Hmat is orthorhombic |
160 |
|
|
247 |
|
outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2; |
248 |
|
outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2; |
249 |
|
} |
250 |
+ |
|
251 |
+ |
void SimInfo::transposeMat3(double in[3][3], double out[3][3]) { |
252 |
+ |
double temp[3][3]; |
253 |
+ |
int i, j; |
254 |
+ |
|
255 |
+ |
for (i = 0; i < 3; i++) { |
256 |
+ |
for (j = 0; j < 3; j++) { |
257 |
+ |
temp[j][i] = in[i][j]; |
258 |
+ |
} |
259 |
+ |
} |
260 |
+ |
for (i = 0; i < 3; i++) { |
261 |
+ |
for (j = 0; j < 3; j++) { |
262 |
+ |
out[i][j] = temp[i][j]; |
263 |
+ |
} |
264 |
+ |
} |
265 |
+ |
} |
266 |
|
|
267 |
+ |
void SimInfo::printMat3(double A[3][3] ){ |
268 |
+ |
|
269 |
+ |
std::cerr |
270 |
+ |
<< "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n" |
271 |
+ |
<< "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n" |
272 |
+ |
<< "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n"; |
273 |
+ |
} |
274 |
+ |
|
275 |
+ |
void SimInfo::printMat9(double A[9] ){ |
276 |
+ |
|
277 |
+ |
std::cerr |
278 |
+ |
<< "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n" |
279 |
+ |
<< "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n" |
280 |
+ |
<< "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n"; |
281 |
+ |
} |
282 |
+ |
|
283 |
|
void SimInfo::calcBoxL( void ){ |
284 |
|
|
285 |
|
double dx, dy, dz, dsq; |
293 |
|
|
294 |
|
dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; |
295 |
|
dsq = dx*dx + dy*dy + dz*dz; |
296 |
< |
boxLx = sqrt( dsq ); |
296 |
> |
boxL[0] = sqrt( dsq ); |
297 |
> |
maxCutoff = 0.5 * boxL[0]; |
298 |
|
|
299 |
|
// boxLy |
300 |
|
|
301 |
|
dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; |
302 |
|
dsq = dx*dx + dy*dy + dz*dz; |
303 |
< |
boxLy = sqrt( dsq ); |
303 |
> |
boxL[1] = sqrt( dsq ); |
304 |
> |
if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1]; |
305 |
|
|
306 |
|
// boxLz |
307 |
|
|
308 |
|
dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; |
309 |
|
dsq = dx*dx + dy*dy + dz*dz; |
310 |
< |
boxLz = sqrt( dsq ); |
310 |
> |
boxL[2] = sqrt( dsq ); |
311 |
> |
if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2]; |
312 |
|
|
313 |
+ |
checkCutOffs(); |
314 |
+ |
|
315 |
|
} |
316 |
|
|
317 |
|
|
365 |
|
ndf = ndf_local; |
366 |
|
#endif |
367 |
|
|
368 |
< |
ndf = ndf - 3; |
368 |
> |
ndf = ndf - 3 - nZconstraints; |
369 |
|
|
370 |
|
return ndf; |
371 |
|
} |
391 |
|
int isError; |
392 |
|
int n_global; |
393 |
|
int* excl; |
394 |
< |
|
382 |
< |
fInfo.rrf = 0.0; |
383 |
< |
fInfo.rt = 0.0; |
394 |
> |
|
395 |
|
fInfo.dielect = 0.0; |
396 |
|
|
386 |
– |
fInfo.rlist = rList; |
387 |
– |
fInfo.rcut = rCut; |
388 |
– |
|
397 |
|
if( useDipole ){ |
390 |
– |
fInfo.rrf = ecr; |
391 |
– |
fInfo.rt = ecr - est; |
398 |
|
if( useReactionField )fInfo.dielect = dielectric; |
399 |
|
} |
400 |
|
|
440 |
|
|
441 |
|
this->ndf = this->getNDF(); |
442 |
|
this->ndfRaw = this->getNDFraw(); |
443 |
+ |
|
444 |
+ |
} |
445 |
+ |
|
446 |
+ |
|
447 |
+ |
void SimInfo::setRcut( double theRcut ){ |
448 |
+ |
|
449 |
+ |
if( !haveOrigRcut ){ |
450 |
+ |
haveOrigRcut = 1; |
451 |
+ |
origRcut = theRcut; |
452 |
+ |
} |
453 |
|
|
454 |
+ |
rCut = theRcut; |
455 |
+ |
checkCutOffs(); |
456 |
|
} |
457 |
|
|
458 |
+ |
void SimInfo::setEcr( double theEcr ){ |
459 |
+ |
|
460 |
+ |
if( !haveOrigEcr ){ |
461 |
+ |
haveOrigEcr = 1; |
462 |
+ |
origEcr = theEcr; |
463 |
+ |
} |
464 |
+ |
|
465 |
+ |
ecr = theEcr; |
466 |
+ |
checkCutOffs(); |
467 |
+ |
} |
468 |
+ |
|
469 |
+ |
void SimInfo::setEcr( double theEcr, double theEst ){ |
470 |
+ |
|
471 |
+ |
est = theEst; |
472 |
+ |
setEcr( theEcr ); |
473 |
+ |
} |
474 |
+ |
|
475 |
+ |
|
476 |
+ |
void SimInfo::checkCutOffs( void ){ |
477 |
+ |
|
478 |
+ |
int cutChanged = 0; |
479 |
+ |
|
480 |
+ |
|
481 |
+ |
|
482 |
+ |
if( boxIsInit ){ |
483 |
+ |
|
484 |
+ |
//we need to check cutOffs against the box |
485 |
+ |
|
486 |
+ |
if(( maxCutoff > rCut )&&(usePBC)){ |
487 |
+ |
if( rCut < origRcut ){ |
488 |
+ |
rCut = origRcut; |
489 |
+ |
if (rCut > maxCutoff) rCut = maxCutoff; |
490 |
+ |
|
491 |
+ |
sprintf( painCave.errMsg, |
492 |
+ |
"New Box size is setting the long range cutoff radius " |
493 |
+ |
"to %lf\n", |
494 |
+ |
rCut ); |
495 |
+ |
painCave.isFatal = 0; |
496 |
+ |
simError(); |
497 |
+ |
} |
498 |
+ |
} |
499 |
+ |
|
500 |
+ |
if( maxCutoff > ecr ){ |
501 |
+ |
if( ecr < origEcr ){ |
502 |
+ |
rCut = origEcr; |
503 |
+ |
if (ecr > maxCutoff) ecr = maxCutoff; |
504 |
+ |
|
505 |
+ |
sprintf( painCave.errMsg, |
506 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
507 |
+ |
"to %lf\n", |
508 |
+ |
ecr ); |
509 |
+ |
painCave.isFatal = 0; |
510 |
+ |
simError(); |
511 |
+ |
} |
512 |
+ |
} |
513 |
+ |
|
514 |
+ |
|
515 |
+ |
if ((rCut > maxCutoff)&&(usePBC)) { |
516 |
+ |
sprintf( painCave.errMsg, |
517 |
+ |
"New Box size is setting the long range cutoff radius " |
518 |
+ |
"to %lf\n", |
519 |
+ |
maxCutoff ); |
520 |
+ |
painCave.isFatal = 0; |
521 |
+ |
simError(); |
522 |
+ |
rCut = maxCutoff; |
523 |
+ |
} |
524 |
+ |
|
525 |
+ |
if( ecr > maxCutoff){ |
526 |
+ |
sprintf( painCave.errMsg, |
527 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
528 |
+ |
"to %lf\n", |
529 |
+ |
maxCutoff ); |
530 |
+ |
painCave.isFatal = 0; |
531 |
+ |
simError(); |
532 |
+ |
ecr = maxCutoff; |
533 |
+ |
} |
534 |
+ |
|
535 |
+ |
|
536 |
+ |
} |
537 |
+ |
|
538 |
+ |
|
539 |
+ |
if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
540 |
+ |
|
541 |
+ |
// rlist is the 1.0 plus max( rcut, ecr ) |
542 |
+ |
|
543 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
544 |
+ |
|
545 |
+ |
if( cutChanged ){ |
546 |
+ |
|
547 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
548 |
+ |
} |
549 |
+ |
|
550 |
+ |
oldEcr = ecr; |
551 |
+ |
oldRcut = rCut; |
552 |
+ |
} |
553 |
+ |
|
554 |
+ |
void SimInfo::addProperty(GenericData* prop){ |
555 |
+ |
|
556 |
+ |
map<string, GenericData*>::iterator result; |
557 |
+ |
result = properties.find(prop->getID()); |
558 |
+ |
|
559 |
+ |
//we can't simply use properties[prop->getID()] = prop, |
560 |
+ |
//it will cause memory leak if we already contain a propery which has the same name of prop |
561 |
+ |
|
562 |
+ |
if(result != properties.end()){ |
563 |
+ |
|
564 |
+ |
delete (*result).second; |
565 |
+ |
(*result).second = prop; |
566 |
+ |
|
567 |
+ |
} |
568 |
+ |
else{ |
569 |
+ |
|
570 |
+ |
properties[prop->getID()] = prop; |
571 |
+ |
|
572 |
+ |
} |
573 |
+ |
|
574 |
+ |
} |
575 |
+ |
|
576 |
+ |
GenericData* SimInfo::getProperty(const string& propName){ |
577 |
+ |
|
578 |
+ |
map<string, GenericData*>::iterator result; |
579 |
+ |
|
580 |
+ |
//string lowerCaseName = (); |
581 |
+ |
|
582 |
+ |
result = properties.find(propName); |
583 |
+ |
|
584 |
+ |
if(result != properties.end()) |
585 |
+ |
return (*result).second; |
586 |
+ |
else |
587 |
+ |
return NULL; |
588 |
+ |
} |
589 |
+ |
|
590 |
+ |
vector<GenericData*> SimInfo::getProperties(){ |
591 |
+ |
|
592 |
+ |
vector<GenericData*> result; |
593 |
+ |
map<string, GenericData*>::iterator i; |
594 |
+ |
|
595 |
+ |
for(i = properties.begin(); i != properties.end(); i++) |
596 |
+ |
result.push_back((*i).second); |
597 |
+ |
|
598 |
+ |
return result; |
599 |
+ |
} |
600 |
+ |
|
601 |
+ |
|