| 42 |
|
thermalTime = 0.0; |
| 43 |
|
currentTime = 0.0; |
| 44 |
|
rCut = 0.0; |
| 45 |
< |
ecr = 0.0; |
| 46 |
< |
est = 0.0; |
| 45 |
> |
rSw = 0.0; |
| 46 |
|
|
| 47 |
|
haveRcut = 0; |
| 48 |
< |
haveEcr = 0; |
| 48 |
> |
haveRsw = 0; |
| 49 |
|
boxIsInit = 0; |
| 50 |
|
|
| 51 |
|
resetTime = 1e99; |
| 62 |
|
useReactionField = 0; |
| 63 |
|
useGB = 0; |
| 64 |
|
useEAM = 0; |
| 65 |
< |
useMolecularCutoffs = 0; |
| 65 |
> |
useThermInt = 0; |
| 66 |
|
|
| 67 |
+ |
haveCutoffGroups = false; |
| 68 |
+ |
|
| 69 |
|
excludes = Exclude::Instance(); |
| 70 |
|
|
| 71 |
|
myConfiguration = new SimState(); |
| 445 |
|
excl = excludes->getFortranArray(); |
| 446 |
|
|
| 447 |
|
#ifdef IS_MPI |
| 448 |
< |
n_global = mpiSim->getTotAtoms(); |
| 448 |
> |
n_global = mpiSim->getNAtomsGlobal(); |
| 449 |
|
#else |
| 450 |
|
n_global = n_atoms; |
| 451 |
|
#endif |
| 453 |
|
isError = 0; |
| 454 |
|
|
| 455 |
|
getFortranGroupArray(this, mfact, ngroup, groupList, groupStart); |
| 456 |
< |
|
| 456 |
> |
//it may not be a good idea to pass the address of first element in vector |
| 457 |
> |
//since c++ standard does not require vector to be stored continuously in meomory |
| 458 |
> |
//Most of the compilers will organize the memory of vector continuously |
| 459 |
|
setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl, |
| 460 |
|
&nGlobalExcludes, globalExcludes, molMembershipArray, |
| 461 |
|
&mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError); |
| 483 |
|
|
| 484 |
|
haveRcut = 1; |
| 485 |
|
rCut = theRcut; |
| 486 |
+ |
rList = rCut + 1.0; |
| 487 |
|
|
| 488 |
< |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
| 485 |
< |
|
| 486 |
< |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
| 488 |
> |
notifyFortranCutOffs( &rCut, &rSw, &rList ); |
| 489 |
|
} |
| 490 |
|
|
| 491 |
< |
void SimInfo::setDefaultEcr( double theEcr ){ |
| 491 |
> |
void SimInfo::setDefaultRcut( double theRcut, double theRsw ){ |
| 492 |
|
|
| 493 |
< |
haveEcr = 1; |
| 494 |
< |
ecr = theEcr; |
| 493 |
< |
|
| 494 |
< |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
| 495 |
< |
|
| 496 |
< |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
| 493 |
> |
rSw = theRsw; |
| 494 |
> |
setDefaultRcut( theRcut ); |
| 495 |
|
} |
| 496 |
|
|
| 499 |
– |
void SimInfo::setDefaultEcr( double theEcr, double theEst ){ |
| 497 |
|
|
| 501 |
– |
est = theEst; |
| 502 |
– |
setDefaultEcr( theEcr ); |
| 503 |
– |
} |
| 504 |
– |
|
| 505 |
– |
|
| 498 |
|
void SimInfo::checkCutOffs( void ){ |
| 499 |
|
|
| 500 |
|
if( boxIsInit ){ |
| 503 |
|
|
| 504 |
|
if( rCut > maxCutoff ){ |
| 505 |
|
sprintf( painCave.errMsg, |
| 506 |
< |
"LJrcut is too large for the current periodic box.\n" |
| 507 |
< |
"\tCurrent Value of LJrcut = %G at time %G\n " |
| 506 |
> |
"cutoffRadius is too large for the current periodic box.\n" |
| 507 |
> |
"\tCurrent Value of cutoffRadius = %G at time %G\n " |
| 508 |
|
"\tThis is larger than half of at least one of the\n" |
| 509 |
|
"\tperiodic box vectors. Right now, the Box matrix is:\n" |
| 510 |
|
"\n" |
| 517 |
|
Hmat[2][0], Hmat[2][1], Hmat[2][2]); |
| 518 |
|
painCave.isFatal = 1; |
| 519 |
|
simError(); |
| 520 |
< |
} |
| 529 |
< |
|
| 530 |
< |
if( haveEcr ){ |
| 531 |
< |
if( ecr > maxCutoff ){ |
| 532 |
< |
sprintf( painCave.errMsg, |
| 533 |
< |
"electrostaticCutoffRadius is too large for the current\n" |
| 534 |
< |
"\tperiodic box.\n\n" |
| 535 |
< |
"\tCurrent Value of ECR = %G at time %G\n " |
| 536 |
< |
"\tThis is larger than half of at least one of the\n" |
| 537 |
< |
"\tperiodic box vectors. Right now, the Box matrix is:\n" |
| 538 |
< |
"\n" |
| 539 |
< |
"\t[ %G %G %G ]\n" |
| 540 |
< |
"\t[ %G %G %G ]\n" |
| 541 |
< |
"\t[ %G %G %G ]\n", |
| 542 |
< |
ecr, currentTime, |
| 543 |
< |
Hmat[0][0], Hmat[0][1], Hmat[0][2], |
| 544 |
< |
Hmat[1][0], Hmat[1][1], Hmat[1][2], |
| 545 |
< |
Hmat[2][0], Hmat[2][1], Hmat[2][2]); |
| 546 |
< |
painCave.isFatal = 1; |
| 547 |
< |
simError(); |
| 548 |
< |
} |
| 549 |
< |
} |
| 520 |
> |
} |
| 521 |
|
} else { |
| 522 |
|
// initialize this stuff before using it, OK? |
| 523 |
|
sprintf( painCave.errMsg, |
| 568 |
|
|
| 569 |
|
void getFortranGroupArray(SimInfo* info, vector<double>& mfact, int& ngroup, |
| 570 |
|
vector<int>& groupList, vector<int>& groupStart){ |
| 571 |
< |
Molecule* mol; |
| 571 |
> |
Molecule* myMols; |
| 572 |
|
Atom** myAtoms; |
| 573 |
|
int numAtom; |
| 574 |
|
int curIndex; |
| 575 |
|
double mtot; |
| 576 |
< |
|
| 576 |
> |
int numMol; |
| 577 |
> |
int numCutoffGroups; |
| 578 |
> |
CutoffGroup* myCutoffGroup; |
| 579 |
> |
vector<CutoffGroup*>::iterator iterCutoff; |
| 580 |
> |
Atom* cutoffAtom; |
| 581 |
> |
vector<Atom*>::iterator iterAtom; |
| 582 |
> |
int atomIndex; |
| 583 |
> |
double totalMass; |
| 584 |
> |
|
| 585 |
|
mfact.clear(); |
| 586 |
|
groupList.clear(); |
| 587 |
|
groupStart.clear(); |
| 588 |
|
|
| 589 |
|
//Be careful, fortran array begin at 1 |
| 590 |
|
curIndex = 1; |
| 591 |
< |
|
| 592 |
< |
if(info->useMolecularCutoffs){ |
| 593 |
< |
|
| 594 |
< |
#ifdef IS_MPI |
| 595 |
< |
ngroup = mpiSim->getMyNMol(); |
| 596 |
< |
#else |
| 597 |
< |
ngroup = info->n_mol; |
| 619 |
< |
#endif |
| 620 |
< |
|
| 621 |
< |
for(int i = 0; i < ngroup; i ++){ |
| 622 |
< |
mol = &(info->molecules[i]); |
| 623 |
< |
numAtom = mol->getNAtoms(); |
| 624 |
< |
myAtoms = mol->getMyAtoms(); |
| 625 |
< |
mtot = 0.0; |
| 591 |
> |
|
| 592 |
> |
myMols = info->molecules; |
| 593 |
> |
numMol = info->n_mol; |
| 594 |
> |
for(int i = 0; i < numMol; i++){ |
| 595 |
> |
numCutoffGroups = myMols[i].getNCutoffGroups(); |
| 596 |
> |
for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff); myCutoffGroup != NULL; |
| 597 |
> |
myCutoffGroup =myMols[i].nextCutoffGroup(iterCutoff)){ |
| 598 |
|
|
| 599 |
< |
for(int j=0; j < numAtom; j++) |
| 628 |
< |
mtot += myAtoms[j]->getMass(); |
| 599 |
> |
totalMass = myCutoffGroup->getMass(); |
| 600 |
|
|
| 601 |
< |
for(int j=0; j < numAtom; j++){ |
| 602 |
< |
|
| 603 |
< |
// We want the local Index: |
| 604 |
< |
groupList.push_back(myAtoms[j]->getIndex() + 1); |
| 605 |
< |
mfact.push_back(myAtoms[j]->getMass() / mtot); |
| 635 |
< |
|
| 636 |
< |
} |
| 637 |
< |
|
| 638 |
< |
groupStart.push_back(curIndex); |
| 639 |
< |
curIndex += numAtom; |
| 640 |
< |
|
| 641 |
< |
} //end for(int i =0 ; i < ngroup; i++) |
| 642 |
< |
} |
| 643 |
< |
else{ |
| 644 |
< |
//using atomic cutoff, every single atom is just a group |
| 645 |
< |
|
| 646 |
< |
#ifdef IS_MPI |
| 647 |
< |
ngroup = mpiSim->getMyNlocal(); |
| 601 |
> |
for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom); cutoffAtom != NULL; |
| 602 |
> |
cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){ |
| 603 |
> |
mfact.push_back(cutoffAtom->getMass()/totalMass); |
| 604 |
> |
#ifdef IS_MPI |
| 605 |
> |
groupList.push_back(cutoffAtom->getGlobalIndex() + 1); |
| 606 |
|
#else |
| 607 |
< |
ngroup = info->n_atoms; |
| 607 |
> |
groupList.push_back(cutoffAtom->getIndex() + 1); |
| 608 |
|
#endif |
| 609 |
< |
|
| 610 |
< |
for(int i =0 ; i < ngroup; i++){ |
| 611 |
< |
groupStart.push_back(curIndex++); |
| 612 |
< |
groupList.push_back((info->atoms[i])->getIndex() + 1); |
| 613 |
< |
mfact.push_back(1.0); |
| 614 |
< |
|
| 615 |
< |
}//end for(int i =0 ; i < ngroup; i++) |
| 616 |
< |
|
| 617 |
< |
}//end if (info->useMolecularCutoffs) |
| 618 |
< |
|
| 609 |
> |
} |
| 610 |
> |
|
| 611 |
> |
groupStart.push_back(curIndex); |
| 612 |
> |
curIndex += myCutoffGroup->getNumAtom(); |
| 613 |
> |
|
| 614 |
> |
}//end for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff)) |
| 615 |
> |
|
| 616 |
> |
}//end for(int i = 0; i < numMol; i++) |
| 617 |
> |
|
| 618 |
> |
|
| 619 |
> |
//The last cutoff group need more element to indicate the end of the cutoff |
| 620 |
> |
ngroup = groupStart.size(); |
| 621 |
|
} |