| 75 |
|
/** |
| 76 |
|
* setupCutoffs |
| 77 |
|
* |
| 78 |
< |
* Sets the values of cutoffRadius, cutoffMethod, and cutoffPolicy |
| 78 |
> |
* Sets the values of cutoffRadius, switchingRadius, cutoffMethod, |
| 79 |
> |
* and cutoffPolicy |
| 80 |
|
* |
| 81 |
|
* cutoffRadius : realType |
| 82 |
|
* If the cutoffRadius was explicitly set, use that value. |
| 86 |
|
* simulation for suggested cutoff values (e.g. 2.5 * sigma). |
| 87 |
|
* Use the maximum suggested value that was found. |
| 88 |
|
* |
| 89 |
< |
* cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, SHIFTED_POTENTIAL) |
| 89 |
> |
* cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, |
| 90 |
> |
* or SHIFTED_POTENTIAL) |
| 91 |
|
* If cutoffMethod was explicitly set, use that choice. |
| 92 |
|
* If cutoffMethod was not explicitly set, use SHIFTED_FORCE |
| 93 |
|
* |
| 94 |
|
* cutoffPolicy : (one of MIX, MAX, TRADITIONAL) |
| 95 |
|
* If cutoffPolicy was explicitly set, use that choice. |
| 96 |
|
* If cutoffPolicy was not explicitly set, use TRADITIONAL |
| 97 |
+ |
* |
| 98 |
+ |
* switchingRadius : realType |
| 99 |
+ |
* If the cutoffMethod was set to SWITCHED: |
| 100 |
+ |
* If the switchingRadius was explicitly set, use that value |
| 101 |
+ |
* (but do a sanity check first). |
| 102 |
+ |
* If the switchingRadius was not explicitly set: use 0.85 * |
| 103 |
+ |
* cutoffRadius_ |
| 104 |
+ |
* If the cutoffMethod was not set to SWITCHED: |
| 105 |
+ |
* Set switchingRadius equal to cutoffRadius for safety. |
| 106 |
|
*/ |
| 107 |
|
void ForceManager::setupCutoffs() { |
| 108 |
|
|
| 109 |
|
Globals* simParams_ = info_->getSimParams(); |
| 110 |
|
ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); |
| 111 |
+ |
int mdFileVersion; |
| 112 |
|
|
| 113 |
+ |
if (simParams_->haveMDfileVersion()) |
| 114 |
+ |
mdFileVersion = simParams_->getMDfileVersion(); |
| 115 |
+ |
else |
| 116 |
+ |
mdFileVersion = 0; |
| 117 |
+ |
|
| 118 |
+ |
|
| 119 |
|
if (simParams_->haveCutoffRadius()) { |
| 120 |
|
rCut_ = simParams_->getCutoffRadius(); |
| 121 |
|
} else { |
| 220 |
|
simError(); |
| 221 |
|
cutoffPolicy_ = TRADITIONAL; |
| 222 |
|
} |
| 205 |
– |
fDecomp_->setCutoffPolicy(cutoffPolicy_); |
| 206 |
– |
} |
| 223 |
|
|
| 224 |
< |
/** |
| 225 |
< |
* setupSwitching |
| 210 |
< |
* |
| 211 |
< |
* Sets the values of switchingRadius and |
| 212 |
< |
* If the switchingRadius was explicitly set, use that value (but check it) |
| 213 |
< |
* If the switchingRadius was not explicitly set: use 0.85 * cutoffRadius_ |
| 214 |
< |
*/ |
| 215 |
< |
void ForceManager::setupSwitching() { |
| 216 |
< |
Globals* simParams_ = info_->getSimParams(); |
| 217 |
< |
|
| 224 |
> |
fDecomp_->setCutoffPolicy(cutoffPolicy_); |
| 225 |
> |
|
| 226 |
|
// create the switching function object: |
| 227 |
+ |
|
| 228 |
|
switcher_ = new SwitchingFunction(); |
| 229 |
< |
|
| 230 |
< |
if (simParams_->haveSwitchingRadius()) { |
| 231 |
< |
rSwitch_ = simParams_->getSwitchingRadius(); |
| 232 |
< |
if (rSwitch_ > rCut_) { |
| 229 |
> |
|
| 230 |
> |
if (cutoffMethod_ == SWITCHED) { |
| 231 |
> |
if (simParams_->haveSwitchingRadius()) { |
| 232 |
> |
rSwitch_ = simParams_->getSwitchingRadius(); |
| 233 |
> |
if (rSwitch_ > rCut_) { |
| 234 |
> |
sprintf(painCave.errMsg, |
| 235 |
> |
"ForceManager::setupCutoffs: switchingRadius (%f) is larger " |
| 236 |
> |
"than the cutoffRadius(%f)\n", rSwitch_, rCut_); |
| 237 |
> |
painCave.isFatal = 1; |
| 238 |
> |
painCave.severity = OPENMD_ERROR; |
| 239 |
> |
simError(); |
| 240 |
> |
} |
| 241 |
> |
} else { |
| 242 |
> |
rSwitch_ = 0.85 * rCut_; |
| 243 |
|
sprintf(painCave.errMsg, |
| 244 |
< |
"ForceManager::setupSwitching: switchingRadius (%f) is larger " |
| 245 |
< |
"than the cutoffRadius(%f)\n", rSwitch_, rCut_); |
| 246 |
< |
painCave.isFatal = 1; |
| 247 |
< |
painCave.severity = OPENMD_ERROR; |
| 244 |
> |
"ForceManager::setupCutoffs: No value was set for the switchingRadius.\n" |
| 245 |
> |
"\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n" |
| 246 |
> |
"\tswitchingRadius = %f. for this simulation\n", rSwitch_); |
| 247 |
> |
painCave.isFatal = 0; |
| 248 |
> |
painCave.severity = OPENMD_WARNING; |
| 249 |
|
simError(); |
| 250 |
|
} |
| 251 |
< |
} else { |
| 252 |
< |
rSwitch_ = 0.85 * rCut_; |
| 253 |
< |
sprintf(painCave.errMsg, |
| 254 |
< |
"ForceManager::setupSwitching: No value was set for the switchingRadius.\n" |
| 255 |
< |
"\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n" |
| 256 |
< |
"\tswitchingRadius = %f. for this simulation\n", rSwitch_); |
| 257 |
< |
painCave.isFatal = 0; |
| 258 |
< |
painCave.severity = OPENMD_WARNING; |
| 259 |
< |
simError(); |
| 260 |
< |
} |
| 251 |
> |
} else { |
| 252 |
> |
if (simParams_->haveSwitchingRadius()) { |
| 253 |
> |
map<string, CutoffMethod>::const_iterator it; |
| 254 |
> |
string theMeth; |
| 255 |
> |
for (it = stringToCutoffMethod.begin(); |
| 256 |
> |
it != stringToCutoffMethod.end(); ++it) { |
| 257 |
> |
if (it->second == cutoffMethod_) { |
| 258 |
> |
theMeth = it->first; |
| 259 |
> |
break; |
| 260 |
> |
} |
| 261 |
> |
} |
| 262 |
> |
sprintf(painCave.errMsg, |
| 263 |
> |
"ForceManager::setupCutoffs: the cutoffMethod (%s)\n" |
| 264 |
> |
"\tis not set to SWITCHED, so switchingRadius value\n" |
| 265 |
> |
"\twill be ignored for this simulation\n", theMeth.c_str()); |
| 266 |
> |
painCave.isFatal = 0; |
| 267 |
> |
painCave.severity = OPENMD_WARNING; |
| 268 |
> |
simError(); |
| 269 |
> |
} |
| 270 |
> |
|
| 271 |
> |
rSwitch_ = rCut_; |
| 272 |
> |
} |
| 273 |
|
|
| 274 |
|
// Default to cubic switching function. |
| 275 |
|
sft_ = cubic; |
| 302 |
|
void ForceManager::initialize() { |
| 303 |
|
|
| 304 |
|
if (!info_->isTopologyDone()) { |
| 305 |
+ |
|
| 306 |
|
info_->update(); |
| 307 |
|
interactionMan_->setSimInfo(info_); |
| 308 |
|
interactionMan_->initialize(); |
| 310 |
|
// We want to delay the cutoffs until after the interaction |
| 311 |
|
// manager has set up the atom-atom interactions so that we can |
| 312 |
|
// query them for suggested cutoff values |
| 280 |
– |
|
| 313 |
|
setupCutoffs(); |
| 282 |
– |
setupSwitching(); |
| 314 |
|
|
| 315 |
|
info_->prepareTopology(); |
| 316 |
|
} |
| 317 |
|
|
| 318 |
|
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
| 319 |
|
|
| 320 |
< |
// Force fields can set options on how to scale van der Waals and electrostatic |
| 321 |
< |
// interactions for atoms connected via bonds, bends and torsions |
| 322 |
< |
// in this case the topological distance between atoms is: |
| 320 |
> |
// Force fields can set options on how to scale van der Waals and |
| 321 |
> |
// electrostatic interactions for atoms connected via bonds, bends |
| 322 |
> |
// and torsions in this case the topological distance between |
| 323 |
> |
// atoms is: |
| 324 |
|
// 0 = topologically unconnected |
| 325 |
|
// 1 = bonded together |
| 326 |
|
// 2 = connected via a bend |
| 372 |
|
|
| 373 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; |
| 374 |
|
mol = info_->nextMolecule(mi)) { |
| 375 |
< |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
| 375 |
> |
for(atom = mol->beginAtom(ai); atom != NULL; |
| 376 |
> |
atom = mol->nextAtom(ai)) { |
| 377 |
|
atom->zeroForcesAndTorques(); |
| 378 |
|
} |
| 379 |
< |
|
| 379 |
> |
|
| 380 |
|
//change the positions of atoms which belong to the rigidbodies |
| 381 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
| 382 |
|
rb = mol->nextRigidBody(rbIter)) { |
| 383 |
|
rb->zeroForcesAndTorques(); |
| 384 |
|
} |
| 385 |
< |
|
| 385 |
> |
|
| 386 |
|
if(info_->getNGlobalCutoffGroups() != info_->getNGlobalAtoms()){ |
| 387 |
|
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
| 388 |
|
cg = mol->nextCutoffGroup(ci)) { |
| 391 |
|
} |
| 392 |
|
} |
| 393 |
|
} |
| 394 |
< |
|
| 394 |
> |
|
| 395 |
|
// Zero out the stress tensor |
| 396 |
|
tau *= 0.0; |
| 397 |
|
|
| 445 |
|
dataSet.prev.angle = dataSet.curr.angle = angle; |
| 446 |
|
dataSet.prev.potential = dataSet.curr.potential = currBendPot; |
| 447 |
|
dataSet.deltaV = 0.0; |
| 448 |
< |
bendDataSets.insert(map<Bend*, BendDataSet>::value_type(bend, dataSet)); |
| 448 |
> |
bendDataSets.insert(map<Bend*, BendDataSet>::value_type(bend, |
| 449 |
> |
dataSet)); |
| 450 |
|
}else { |
| 451 |
|
i->second.prev.angle = i->second.curr.angle; |
| 452 |
|
i->second.prev.potential = i->second.curr.potential; |
| 589 |
|
bool update_nlist = fDecomp_->checkNeighborList(); |
| 590 |
|
if (update_nlist) |
| 591 |
|
neighborList = fDecomp_->buildNeighborList(); |
| 592 |
< |
} |
| 593 |
< |
|
| 592 |
> |
} |
| 593 |
> |
|
| 594 |
|
for (vector<pair<int, int> >::iterator it = neighborList.begin(); |
| 595 |
|
it != neighborList.end(); ++it) { |
| 596 |
|
|
| 600 |
|
cuts = fDecomp_->getGroupCutoffs(cg1, cg2); |
| 601 |
|
|
| 602 |
|
d_grp = fDecomp_->getIntergroupVector(cg1, cg2); |
| 603 |
+ |
|
| 604 |
|
curSnapshot->wrapVector(d_grp); |
| 605 |
|
rgrpsq = d_grp.lengthSquare(); |
| 571 |
– |
|
| 606 |
|
rCutSq = cuts.second; |
| 607 |
|
|
| 608 |
|
if (rgrpsq < rCutSq) { |
| 609 |
|
idat.rcut = &cuts.first; |
| 610 |
|
if (iLoop == PAIR_LOOP) { |
| 611 |
< |
vij *= 0.0; |
| 611 |
> |
vij = 0.0; |
| 612 |
|
fij = V3Zero; |
| 613 |
|
} |
| 614 |
|
|
| 617 |
|
|
| 618 |
|
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
| 619 |
|
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
| 620 |
+ |
|
| 621 |
|
|
| 622 |
|
for (vector<int>::iterator ia = atomListRow.begin(); |
| 623 |
|
ia != atomListRow.end(); ++ia) { |
| 626 |
|
for (vector<int>::iterator jb = atomListColumn.begin(); |
| 627 |
|
jb != atomListColumn.end(); ++jb) { |
| 628 |
|
atom2 = (*jb); |
| 629 |
< |
|
| 629 |
> |
|
| 630 |
|
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
| 631 |
|
vpair = 0.0; |
| 632 |
|
workPot = 0.0; |
| 648 |
|
idat.d = &d; |
| 649 |
|
idat.r2 = &r2; |
| 650 |
|
} |
| 651 |
< |
|
| 651 |
> |
|
| 652 |
|
r = sqrt( *(idat.r2) ); |
| 653 |
|
idat.rij = &r; |
| 654 |
|
|
| 657 |
|
} else { |
| 658 |
|
interactionMan_->doPair(idat); |
| 659 |
|
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
| 660 |
+ |
|
| 661 |
|
vij += vpair; |
| 662 |
|
fij += f1; |
| 663 |
|
tau -= outProduct( *(idat.d), f1); |
| 670 |
|
if (in_switching_region) { |
| 671 |
|
swderiv = vij * dswdr / rgrp; |
| 672 |
|
fg = swderiv * d_grp; |
| 637 |
– |
|
| 673 |
|
fij += fg; |
| 674 |
|
|
| 675 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 713 |
|
} |
| 714 |
|
} |
| 715 |
|
} |
| 716 |
< |
//if (!SIM_uses_AtomicVirial) { |
| 716 |
> |
//if (!info_->usesAtomicVirial()) { |
| 717 |
|
// tau -= outProduct(d_grp, fij); |
| 718 |
|
//} |
| 719 |
|
} |
| 721 |
|
} |
| 722 |
|
|
| 723 |
|
if (iLoop == PREPAIR_LOOP) { |
| 724 |
< |
if (info_->requiresPrepair()) { |
| 724 |
> |
if (info_->requiresPrepair()) { |
| 725 |
> |
|
| 726 |
|
fDecomp_->collectIntermediateData(); |
| 727 |
|
|
| 728 |
|
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 729 |
|
fDecomp_->fillSelfData(sdat, atom1); |
| 730 |
|
interactionMan_->doPreForce(sdat); |
| 731 |
|
} |
| 696 |
– |
|
| 697 |
– |
|
| 698 |
– |
fDecomp_->distributeIntermediateData(); |
| 699 |
– |
} |
| 700 |
– |
} |
| 732 |
|
|
| 733 |
< |
} |
| 703 |
< |
|
| 704 |
< |
fDecomp_->collectData(); |
| 705 |
< |
|
| 706 |
< |
if ( info_->requiresSkipCorrection() ) { |
| 707 |
< |
|
| 708 |
< |
for (int atom1 = 0; atom1 < fDecomp_->getNAtomsInRow(); atom1++) { |
| 733 |
> |
fDecomp_->distributeIntermediateData(); |
| 734 |
|
|
| 710 |
– |
vector<int> skipList = fDecomp_->getSkipsForAtom( atom1 ); |
| 711 |
– |
|
| 712 |
– |
for (vector<int>::iterator jb = skipList.begin(); |
| 713 |
– |
jb != skipList.end(); ++jb) { |
| 714 |
– |
|
| 715 |
– |
atom2 = (*jb); |
| 716 |
– |
fDecomp_->fillSkipData(idat, atom1, atom2); |
| 717 |
– |
interactionMan_->doSkipCorrection(idat); |
| 718 |
– |
fDecomp_->unpackSkipData(idat, atom1, atom2); |
| 719 |
– |
|
| 735 |
|
} |
| 736 |
|
} |
| 737 |
|
} |
| 738 |
|
|
| 739 |
+ |
fDecomp_->collectData(); |
| 740 |
+ |
|
| 741 |
|
if (info_->requiresSelfCorrection()) { |
| 742 |
|
|
| 743 |
|
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |