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; |
54 |
|
useGB = 0; |
55 |
|
useEAM = 0; |
56 |
|
|
57 |
+ |
myConfiguration = new SimState(); |
58 |
+ |
|
59 |
|
wrapMeSimInfo( this ); |
60 |
|
} |
61 |
|
|
62 |
+ |
|
63 |
+ |
SimInfo::~SimInfo(){ |
64 |
+ |
|
65 |
+ |
delete myConfiguration; |
66 |
+ |
|
67 |
+ |
map<string, GenericData*>::iterator i; |
68 |
+ |
|
69 |
+ |
for(i = properties.begin(); i != properties.end(); i++) |
70 |
+ |
delete (*i).second; |
71 |
+ |
|
72 |
+ |
} |
73 |
+ |
|
74 |
|
void SimInfo::setBox(double newBox[3]) { |
75 |
|
|
76 |
|
int i, j; |
98 |
|
// [ 2 5 8 ] |
99 |
|
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
100 |
|
|
101 |
+ |
|
102 |
+ |
if( !boxIsInit ) boxIsInit = 1; |
103 |
|
|
104 |
|
for(i=0; i < 3; i++) |
105 |
|
for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; |
106 |
|
|
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 |
– |
|
107 |
|
calcBoxL(); |
108 |
|
calcHmatInv(); |
109 |
|
|
116 |
|
|
117 |
|
setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); |
118 |
|
|
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 |
– |
} |
119 |
|
} |
120 |
|
|
121 |
|
|
290 |
|
|
291 |
|
dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; |
292 |
|
dsq = dx*dx + dy*dy + dz*dz; |
293 |
< |
boxLx = sqrt( dsq ); |
293 |
> |
boxL[0] = sqrt( dsq ); |
294 |
> |
maxCutoff = 0.5 * boxL[0]; |
295 |
|
|
296 |
|
// boxLy |
297 |
|
|
298 |
|
dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; |
299 |
|
dsq = dx*dx + dy*dy + dz*dz; |
300 |
< |
boxLy = sqrt( dsq ); |
300 |
> |
boxL[1] = sqrt( dsq ); |
301 |
> |
if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1]; |
302 |
|
|
303 |
|
// boxLz |
304 |
|
|
305 |
|
dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; |
306 |
|
dsq = dx*dx + dy*dy + dz*dz; |
307 |
< |
boxLz = sqrt( dsq ); |
307 |
> |
boxL[2] = sqrt( dsq ); |
308 |
> |
if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2]; |
309 |
|
|
310 |
+ |
checkCutOffs(); |
311 |
+ |
|
312 |
|
} |
313 |
|
|
314 |
|
|
388 |
|
int isError; |
389 |
|
int n_global; |
390 |
|
int* excl; |
391 |
< |
|
409 |
< |
fInfo.rrf = 0.0; |
410 |
< |
fInfo.rt = 0.0; |
391 |
> |
|
392 |
|
fInfo.dielect = 0.0; |
393 |
|
|
413 |
– |
fInfo.rlist = rList; |
414 |
– |
fInfo.rcut = rCut; |
415 |
– |
|
394 |
|
if( useDipole ){ |
417 |
– |
fInfo.rrf = ecr; |
418 |
– |
fInfo.rt = ecr - est; |
395 |
|
if( useReactionField )fInfo.dielect = dielectric; |
396 |
|
} |
397 |
|
|
437 |
|
|
438 |
|
this->ndf = this->getNDF(); |
439 |
|
this->ndfRaw = this->getNDFraw(); |
440 |
+ |
|
441 |
+ |
} |
442 |
+ |
|
443 |
+ |
|
444 |
+ |
void SimInfo::setRcut( double theRcut ){ |
445 |
+ |
|
446 |
+ |
if( !haveOrigRcut ){ |
447 |
+ |
haveOrigRcut = 1; |
448 |
+ |
origRcut = theRcut; |
449 |
+ |
} |
450 |
+ |
|
451 |
+ |
rCut = theRcut; |
452 |
+ |
checkCutOffs(); |
453 |
+ |
} |
454 |
+ |
|
455 |
+ |
void SimInfo::setEcr( double theEcr ){ |
456 |
+ |
|
457 |
+ |
if( !haveOrigEcr ){ |
458 |
+ |
haveOrigEcr = 1; |
459 |
+ |
origEcr = theEcr; |
460 |
+ |
} |
461 |
+ |
|
462 |
+ |
ecr = theEcr; |
463 |
+ |
checkCutOffs(); |
464 |
+ |
} |
465 |
+ |
|
466 |
+ |
void SimInfo::setEcr( double theEcr, double theEst ){ |
467 |
+ |
|
468 |
+ |
est = theEst; |
469 |
+ |
setEcr( theEcr ); |
470 |
+ |
} |
471 |
|
|
472 |
+ |
|
473 |
+ |
void SimInfo::checkCutOffs( void ){ |
474 |
+ |
|
475 |
+ |
int cutChanged = 0; |
476 |
+ |
|
477 |
+ |
|
478 |
+ |
|
479 |
+ |
if( boxIsInit ){ |
480 |
+ |
|
481 |
+ |
//we need to check cutOffs against the box |
482 |
+ |
|
483 |
+ |
if(( maxCutoff > rCut )&&(usePBC)){ |
484 |
+ |
if( rCut < origRcut ){ |
485 |
+ |
rCut = origRcut; |
486 |
+ |
if (rCut > maxCutoff) rCut = maxCutoff; |
487 |
+ |
|
488 |
+ |
sprintf( painCave.errMsg, |
489 |
+ |
"New Box size is setting the long range cutoff radius " |
490 |
+ |
"to %lf\n", |
491 |
+ |
rCut ); |
492 |
+ |
painCave.isFatal = 0; |
493 |
+ |
simError(); |
494 |
+ |
} |
495 |
+ |
} |
496 |
+ |
|
497 |
+ |
if( maxCutoff > ecr ){ |
498 |
+ |
if( ecr < origEcr ){ |
499 |
+ |
rCut = origEcr; |
500 |
+ |
if (ecr > maxCutoff) ecr = maxCutoff; |
501 |
+ |
|
502 |
+ |
sprintf( painCave.errMsg, |
503 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
504 |
+ |
"to %lf\n", |
505 |
+ |
ecr ); |
506 |
+ |
painCave.isFatal = 0; |
507 |
+ |
simError(); |
508 |
+ |
} |
509 |
+ |
} |
510 |
+ |
|
511 |
+ |
|
512 |
+ |
if ((rCut > maxCutoff)&&(usePBC)) { |
513 |
+ |
sprintf( painCave.errMsg, |
514 |
+ |
"New Box size is setting the long range cutoff radius " |
515 |
+ |
"to %lf\n", |
516 |
+ |
maxCutoff ); |
517 |
+ |
painCave.isFatal = 0; |
518 |
+ |
simError(); |
519 |
+ |
rCut = maxCutoff; |
520 |
+ |
} |
521 |
+ |
|
522 |
+ |
if( ecr > maxCutoff){ |
523 |
+ |
sprintf( painCave.errMsg, |
524 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
525 |
+ |
"to %lf\n", |
526 |
+ |
maxCutoff ); |
527 |
+ |
painCave.isFatal = 0; |
528 |
+ |
simError(); |
529 |
+ |
ecr = maxCutoff; |
530 |
+ |
} |
531 |
+ |
|
532 |
+ |
|
533 |
+ |
} |
534 |
+ |
|
535 |
+ |
|
536 |
+ |
if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
537 |
+ |
|
538 |
+ |
// rlist is the 1.0 plus max( rcut, ecr ) |
539 |
+ |
|
540 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
541 |
+ |
|
542 |
+ |
if( cutChanged ){ |
543 |
+ |
|
544 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
545 |
+ |
} |
546 |
+ |
|
547 |
+ |
oldEcr = ecr; |
548 |
+ |
oldRcut = rCut; |
549 |
|
} |
550 |
|
|
551 |
+ |
void SimInfo::addProperty(GenericData* prop){ |
552 |
+ |
|
553 |
+ |
map<string, GenericData*>::iterator result; |
554 |
+ |
result = properties.find(prop->getID()); |
555 |
+ |
|
556 |
+ |
//we can't simply use properties[prop->getID()] = prop, |
557 |
+ |
//it will cause memory leak if we already contain a propery which has the same name of prop |
558 |
+ |
|
559 |
+ |
if(result != properties.end()){ |
560 |
+ |
|
561 |
+ |
delete (*result).second; |
562 |
+ |
(*result).second = prop; |
563 |
+ |
|
564 |
+ |
} |
565 |
+ |
else{ |
566 |
+ |
|
567 |
+ |
properties[prop->getID()] = prop; |
568 |
+ |
|
569 |
+ |
} |
570 |
+ |
|
571 |
+ |
} |
572 |
+ |
|
573 |
+ |
GenericData* SimInfo::getProperty(const string& propName){ |
574 |
+ |
|
575 |
+ |
map<string, GenericData*>::iterator result; |
576 |
+ |
|
577 |
+ |
//string lowerCaseName = (); |
578 |
+ |
|
579 |
+ |
result = properties.find(propName); |
580 |
+ |
|
581 |
+ |
if(result != properties.end()) |
582 |
+ |
return (*result).second; |
583 |
+ |
else |
584 |
+ |
return NULL; |
585 |
+ |
} |
586 |
+ |
|
587 |
+ |
vector<GenericData*> SimInfo::getProperties(){ |
588 |
+ |
|
589 |
+ |
vector<GenericData*> result; |
590 |
+ |
map<string, GenericData*>::iterator i; |
591 |
+ |
|
592 |
+ |
for(i = properties.begin(); i != properties.end(); i++) |
593 |
+ |
result.push_back((*i).second); |
594 |
+ |
|
595 |
+ |
return result; |
596 |
+ |
} |
597 |
+ |
|
598 |
+ |
|