36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
> |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
*/ |
42 |
|
|
43 |
|
/** |
87 |
|
* simulation for suggested cutoff values (e.g. 2.5 * sigma). |
88 |
|
* Use the maximum suggested value that was found. |
89 |
|
* |
90 |
< |
* cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, SHIFTED_POTENTIAL) |
90 |
> |
* cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, |
91 |
> |
* or SHIFTED_POTENTIAL) |
92 |
|
* If cutoffMethod was explicitly set, use that choice. |
93 |
|
* If cutoffMethod was not explicitly set, use SHIFTED_FORCE |
94 |
|
* |
109 |
|
|
110 |
|
Globals* simParams_ = info_->getSimParams(); |
111 |
|
ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); |
112 |
+ |
int mdFileVersion; |
113 |
|
|
114 |
+ |
if (simParams_->haveMDfileVersion()) |
115 |
+ |
mdFileVersion = simParams_->getMDfileVersion(); |
116 |
+ |
else |
117 |
+ |
mdFileVersion = 0; |
118 |
+ |
|
119 |
|
if (simParams_->haveCutoffRadius()) { |
120 |
|
rCut_ = simParams_->getCutoffRadius(); |
121 |
|
} else { |
173 |
|
cutoffMethod_ = i->second; |
174 |
|
} |
175 |
|
} else { |
176 |
< |
sprintf(painCave.errMsg, |
177 |
< |
"ForceManager::setupCutoffs: No value was set for the cutoffMethod.\n" |
178 |
< |
"\tOpenMD will use SHIFTED_FORCE.\n"); |
179 |
< |
painCave.isFatal = 0; |
180 |
< |
painCave.severity = OPENMD_INFO; |
181 |
< |
simError(); |
182 |
< |
cutoffMethod_ = SHIFTED_FORCE; |
176 |
> |
if (mdFileVersion > 1) { |
177 |
> |
sprintf(painCave.errMsg, |
178 |
> |
"ForceManager::setupCutoffs: No value was set for the cutoffMethod.\n" |
179 |
> |
"\tOpenMD will use SHIFTED_FORCE.\n"); |
180 |
> |
painCave.isFatal = 0; |
181 |
> |
painCave.severity = OPENMD_INFO; |
182 |
> |
simError(); |
183 |
> |
cutoffMethod_ = SHIFTED_FORCE; |
184 |
> |
} else { |
185 |
> |
// handle the case where the old file version was in play |
186 |
> |
// (there should be no cutoffMethod, so we have to deduce it |
187 |
> |
// from other data). |
188 |
> |
|
189 |
> |
sprintf(painCave.errMsg, |
190 |
> |
"ForceManager::setupCutoffs : DEPRECATED FILE FORMAT!\n" |
191 |
> |
"\tOpenMD found a file which does not set a cutoffMethod.\n" |
192 |
> |
"\tOpenMD will attempt to deduce a cutoffMethod using the\n" |
193 |
> |
"\tbehavior of the older (version 1) code. To remove this\n" |
194 |
> |
"\twarning, add an explicit cutoffMethod and change the top\n" |
195 |
> |
"\tof the file so that it begins with <OpenMD version=2>\n"); |
196 |
> |
painCave.isFatal = 0; |
197 |
> |
painCave.severity = OPENMD_WARNING; |
198 |
> |
simError(); |
199 |
> |
|
200 |
> |
// The old file version tethered the shifting behavior to the |
201 |
> |
// electrostaticSummationMethod keyword. |
202 |
> |
|
203 |
> |
if (simParams_->haveElectrostaticSummationMethod()) { |
204 |
> |
string myMethod = simParams_->getElectrostaticSummationMethod(); |
205 |
> |
toUpper(myMethod); |
206 |
> |
|
207 |
> |
if (myMethod == "SHIFTED_POTENTIAL") { |
208 |
> |
cutoffMethod_ = SHIFTED_POTENTIAL; |
209 |
> |
} else if (myMethod == "SHIFTED_FORCE") { |
210 |
> |
cutoffMethod_ = SHIFTED_FORCE; |
211 |
> |
} |
212 |
> |
|
213 |
> |
if (simParams_->haveSwitchingRadius()) |
214 |
> |
rSwitch_ = simParams_->getSwitchingRadius(); |
215 |
> |
|
216 |
> |
if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") { |
217 |
> |
if (simParams_->haveSwitchingRadius()){ |
218 |
> |
sprintf(painCave.errMsg, |
219 |
> |
"ForceManager::setupCutoffs : DEPRECATED ERROR MESSAGE\n" |
220 |
> |
"\tA value was set for the switchingRadius\n" |
221 |
> |
"\teven though the electrostaticSummationMethod was\n" |
222 |
> |
"\tset to %s\n", myMethod.c_str()); |
223 |
> |
painCave.severity = OPENMD_WARNING; |
224 |
> |
painCave.isFatal = 1; |
225 |
> |
simError(); |
226 |
> |
} |
227 |
> |
} |
228 |
> |
if (abs(rCut_ - rSwitch_) < 0.0001) { |
229 |
> |
if (cutoffMethod_ == SHIFTED_FORCE) { |
230 |
> |
sprintf(painCave.errMsg, |
231 |
> |
"ForceManager::setupCutoffs : DEPRECATED BEHAVIOR\n" |
232 |
> |
"\tcutoffRadius and switchingRadius are set to the\n" |
233 |
> |
"\tsame value. OpenMD will use shifted force\n" |
234 |
> |
"\tpotentials instead of switching functions.\n"); |
235 |
> |
painCave.isFatal = 0; |
236 |
> |
painCave.severity = OPENMD_WARNING; |
237 |
> |
simError(); |
238 |
> |
} else { |
239 |
> |
cutoffMethod_ = SHIFTED_POTENTIAL; |
240 |
> |
sprintf(painCave.errMsg, |
241 |
> |
"ForceManager::setupCutoffs : DEPRECATED BEHAVIOR\n" |
242 |
> |
"\tcutoffRadius and switchingRadius are set to the\n" |
243 |
> |
"\tsame value. OpenMD will use shifted potentials\n" |
244 |
> |
"\tinstead of switching functions.\n"); |
245 |
> |
painCave.isFatal = 0; |
246 |
> |
painCave.severity = OPENMD_WARNING; |
247 |
> |
simError(); |
248 |
> |
} |
249 |
> |
} |
250 |
> |
} |
251 |
> |
} |
252 |
|
} |
253 |
|
|
254 |
|
map<string, CutoffPolicy> stringToCutoffPolicy; |
256 |
|
stringToCutoffPolicy["MAX"] = MAX; |
257 |
|
stringToCutoffPolicy["TRADITIONAL"] = TRADITIONAL; |
258 |
|
|
259 |
< |
std::string cutPolicy; |
259 |
> |
string cutPolicy; |
260 |
|
if (forceFieldOptions_.haveCutoffPolicy()){ |
261 |
|
cutPolicy = forceFieldOptions_.getCutoffPolicy(); |
262 |
|
}else if (simParams_->haveCutoffPolicy()) { |
318 |
|
simError(); |
319 |
|
} |
320 |
|
} else { |
321 |
< |
if (simParams_->haveSwitchingRadius()) { |
322 |
< |
map<string, CutoffMethod>::const_iterator it; |
323 |
< |
string theMeth; |
324 |
< |
for (it = stringToCutoffMethod.begin(); |
325 |
< |
it != stringToCutoffMethod.end(); ++it) { |
326 |
< |
if (it->second == cutoffMethod_) { |
327 |
< |
theMeth = it->first; |
328 |
< |
break; |
321 |
> |
if (mdFileVersion > 1) { |
322 |
> |
// throw an error if we define a switching radius and don't need one. |
323 |
> |
// older file versions should not do this. |
324 |
> |
if (simParams_->haveSwitchingRadius()) { |
325 |
> |
map<string, CutoffMethod>::const_iterator it; |
326 |
> |
string theMeth; |
327 |
> |
for (it = stringToCutoffMethod.begin(); |
328 |
> |
it != stringToCutoffMethod.end(); ++it) { |
329 |
> |
if (it->second == cutoffMethod_) { |
330 |
> |
theMeth = it->first; |
331 |
> |
break; |
332 |
> |
} |
333 |
|
} |
334 |
+ |
sprintf(painCave.errMsg, |
335 |
+ |
"ForceManager::setupCutoffs: the cutoffMethod (%s)\n" |
336 |
+ |
"\tis not set to SWITCHED, so switchingRadius value\n" |
337 |
+ |
"\twill be ignored for this simulation\n", theMeth.c_str()); |
338 |
+ |
painCave.isFatal = 0; |
339 |
+ |
painCave.severity = OPENMD_WARNING; |
340 |
+ |
simError(); |
341 |
|
} |
254 |
– |
sprintf(painCave.errMsg, |
255 |
– |
"ForceManager::setupCutoffs: the cutoffMethod (%s)\n" |
256 |
– |
"\tis not set to SWITCHED, so switchingRadius value\n" |
257 |
– |
"\twill be ignored for this simulation\n", theMeth.c_str()); |
258 |
– |
painCave.isFatal = 0; |
259 |
– |
painCave.severity = OPENMD_WARNING; |
260 |
– |
simError(); |
342 |
|
} |
262 |
– |
|
343 |
|
rSwitch_ = rCut_; |
344 |
|
} |
345 |
|
|
370 |
|
switcher_->setSwitch(rSwitch_, rCut_); |
371 |
|
interactionMan_->setSwitchingRadius(rSwitch_); |
372 |
|
} |
373 |
+ |
|
374 |
+ |
|
375 |
+ |
|
376 |
|
|
377 |
|
void ForceManager::initialize() { |
378 |
|
|
379 |
|
if (!info_->isTopologyDone()) { |
380 |
+ |
|
381 |
|
info_->update(); |
382 |
|
interactionMan_->setSimInfo(info_); |
383 |
|
interactionMan_->initialize(); |
385 |
|
// We want to delay the cutoffs until after the interaction |
386 |
|
// manager has set up the atom-atom interactions so that we can |
387 |
|
// query them for suggested cutoff values |
304 |
– |
|
388 |
|
setupCutoffs(); |
389 |
|
|
390 |
|
info_->prepareTopology(); |
392 |
|
|
393 |
|
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
394 |
|
|
395 |
< |
// Force fields can set options on how to scale van der Waals and electrostatic |
396 |
< |
// interactions for atoms connected via bonds, bends and torsions |
397 |
< |
// in this case the topological distance between atoms is: |
395 |
> |
// Force fields can set options on how to scale van der Waals and |
396 |
> |
// electrostatic interactions for atoms connected via bonds, bends |
397 |
> |
// and torsions in this case the topological distance between |
398 |
> |
// atoms is: |
399 |
|
// 0 = topologically unconnected |
400 |
|
// 1 = bonded together |
401 |
|
// 2 = connected via a bend |
447 |
|
|
448 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; |
449 |
|
mol = info_->nextMolecule(mi)) { |
450 |
< |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
450 |
> |
for(atom = mol->beginAtom(ai); atom != NULL; |
451 |
> |
atom = mol->nextAtom(ai)) { |
452 |
|
atom->zeroForcesAndTorques(); |
453 |
|
} |
454 |
< |
|
454 |
> |
|
455 |
|
//change the positions of atoms which belong to the rigidbodies |
456 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
457 |
|
rb = mol->nextRigidBody(rbIter)) { |
458 |
|
rb->zeroForcesAndTorques(); |
459 |
|
} |
460 |
< |
|
460 |
> |
|
461 |
|
if(info_->getNGlobalCutoffGroups() != info_->getNGlobalAtoms()){ |
462 |
|
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
463 |
|
cg = mol->nextCutoffGroup(ci)) { |
466 |
|
} |
467 |
|
} |
468 |
|
} |
469 |
< |
|
469 |
> |
|
470 |
|
// Zero out the stress tensor |
471 |
|
tau *= 0.0; |
472 |
|
|
520 |
|
dataSet.prev.angle = dataSet.curr.angle = angle; |
521 |
|
dataSet.prev.potential = dataSet.curr.potential = currBendPot; |
522 |
|
dataSet.deltaV = 0.0; |
523 |
< |
bendDataSets.insert(map<Bend*, BendDataSet>::value_type(bend, dataSet)); |
523 |
> |
bendDataSets.insert(map<Bend*, BendDataSet>::value_type(bend, |
524 |
> |
dataSet)); |
525 |
|
}else { |
526 |
|
i->second.prev.angle = i->second.curr.angle; |
527 |
|
i->second.prev.potential = i->second.curr.potential; |
664 |
|
bool update_nlist = fDecomp_->checkNeighborList(); |
665 |
|
if (update_nlist) |
666 |
|
neighborList = fDecomp_->buildNeighborList(); |
667 |
< |
} |
668 |
< |
|
667 |
> |
} |
668 |
> |
|
669 |
|
for (vector<pair<int, int> >::iterator it = neighborList.begin(); |
670 |
|
it != neighborList.end(); ++it) { |
671 |
|
|
675 |
|
cuts = fDecomp_->getGroupCutoffs(cg1, cg2); |
676 |
|
|
677 |
|
d_grp = fDecomp_->getIntergroupVector(cg1, cg2); |
678 |
+ |
|
679 |
|
curSnapshot->wrapVector(d_grp); |
680 |
|
rgrpsq = d_grp.lengthSquare(); |
594 |
– |
|
681 |
|
rCutSq = cuts.second; |
682 |
|
|
683 |
|
if (rgrpsq < rCutSq) { |
689 |
|
|
690 |
|
in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, |
691 |
|
rgrp); |
692 |
< |
|
692 |
> |
|
693 |
|
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
694 |
|
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
695 |
|
|
700 |
|
for (vector<int>::iterator jb = atomListColumn.begin(); |
701 |
|
jb != atomListColumn.end(); ++jb) { |
702 |
|
atom2 = (*jb); |
703 |
< |
|
703 |
> |
|
704 |
|
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
705 |
|
vpair = 0.0; |
706 |
|
workPot = 0.0; |
722 |
|
idat.d = &d; |
723 |
|
idat.r2 = &r2; |
724 |
|
} |
725 |
< |
|
725 |
> |
|
726 |
|
r = sqrt( *(idat.r2) ); |
727 |
|
idat.rij = &r; |
728 |
|
|
757 |
|
// presence in switching region |
758 |
|
fg = swderiv * d_grp * mf; |
759 |
|
fDecomp_->addForceToAtomRow(atom1, fg); |
674 |
– |
|
760 |
|
if (atomListRow.size() > 1) { |
761 |
|
if (info_->usesAtomicVirial()) { |
762 |
|
// find the distance between the atom |
785 |
|
} |
786 |
|
} |
787 |
|
} |
788 |
< |
//if (!SIM_uses_AtomicVirial) { |
788 |
> |
//if (!info_->usesAtomicVirial()) { |
789 |
|
// tau -= outProduct(d_grp, fij); |
790 |
|
//} |
791 |
|
} |
793 |
|
} |
794 |
|
|
795 |
|
if (iLoop == PREPAIR_LOOP) { |
796 |
< |
if (info_->requiresPrepair()) { |
796 |
> |
if (info_->requiresPrepair()) { |
797 |
> |
|
798 |
|
fDecomp_->collectIntermediateData(); |
799 |
|
|
800 |
|
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
801 |
|
fDecomp_->fillSelfData(sdat, atom1); |
802 |
|
interactionMan_->doPreForce(sdat); |
803 |
|
} |
804 |
< |
|
805 |
< |
|
806 |
< |
fDecomp_->distributeIntermediateData(); |
804 |
> |
|
805 |
> |
fDecomp_->distributeIntermediateData(); |
806 |
> |
|
807 |
|
} |
808 |
|
} |
723 |
– |
|
809 |
|
} |
810 |
|
|
811 |
|
fDecomp_->collectData(); |
854 |
|
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
855 |
|
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
856 |
|
#endif |
857 |
< |
curSnapshot->statData.setTau(tau); |
857 |
> |
curSnapshot->setTau(tau); |
858 |
|
} |
859 |
|
|
860 |
|
} //end namespace OpenMD |