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