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 |
|
/** |
201 |
|
// electrostaticSummationMethod keyword. |
202 |
|
|
203 |
|
if (simParams_->haveElectrostaticSummationMethod()) { |
204 |
< |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
204 |
> |
string myMethod = simParams_->getElectrostaticSummationMethod(); |
205 |
|
toUpper(myMethod); |
206 |
|
|
207 |
|
if (myMethod == "SHIFTED_POTENTIAL") { |
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 |
|
} |
330 |
– |
sprintf(painCave.errMsg, |
331 |
– |
"ForceManager::setupCutoffs: the cutoffMethod (%s)\n" |
332 |
– |
"\tis not set to SWITCHED, so switchingRadius value\n" |
333 |
– |
"\twill be ignored for this simulation\n", theMeth.c_str()); |
334 |
– |
painCave.isFatal = 0; |
335 |
– |
painCave.severity = OPENMD_WARNING; |
336 |
– |
simError(); |
342 |
|
} |
338 |
– |
|
343 |
|
rSwitch_ = rCut_; |
344 |
|
} |
345 |
|
|
388 |
|
setupCutoffs(); |
389 |
|
|
390 |
|
info_->prepareTopology(); |
391 |
+ |
|
392 |
+ |
doParticlePot_ = info_->getSimParams()->getOutputParticlePotential(); |
393 |
+ |
doHeatFlux_ = info_->getSimParams()->getPrintHeatFlux(); |
394 |
+ |
if (doHeatFlux_) doParticlePot_ = true; |
395 |
+ |
|
396 |
|
} |
397 |
|
|
398 |
|
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
473 |
|
} |
474 |
|
|
475 |
|
// Zero out the stress tensor |
476 |
< |
tau *= 0.0; |
477 |
< |
|
476 |
> |
stressTensor *= 0.0; |
477 |
> |
// Zero out the heatFlux |
478 |
> |
fDecomp_->setHeatFlux( V3Zero ); |
479 |
|
} |
480 |
|
|
481 |
|
void ForceManager::shortRangeInteractions() { |
508 |
|
|
509 |
|
for (bond = mol->beginBond(bondIter); bond != NULL; |
510 |
|
bond = mol->nextBond(bondIter)) { |
511 |
< |
bond->calcForce(); |
511 |
> |
bond->calcForce(doParticlePot_); |
512 |
|
bondPotential += bond->getPotential(); |
513 |
|
} |
514 |
|
|
516 |
|
bend = mol->nextBend(bendIter)) { |
517 |
|
|
518 |
|
RealType angle; |
519 |
< |
bend->calcForce(angle); |
519 |
> |
bend->calcForce(angle, doParticlePot_); |
520 |
|
RealType currBendPot = bend->getPotential(); |
521 |
|
|
522 |
|
bendPotential += bend->getPotential(); |
541 |
|
for (torsion = mol->beginTorsion(torsionIter); torsion != NULL; |
542 |
|
torsion = mol->nextTorsion(torsionIter)) { |
543 |
|
RealType angle; |
544 |
< |
torsion->calcForce(angle); |
544 |
> |
torsion->calcForce(angle, doParticlePot_); |
545 |
|
RealType currTorsionPot = torsion->getPotential(); |
546 |
|
torsionPotential += torsion->getPotential(); |
547 |
|
map<Torsion*, TorsionDataSet>::iterator i = torsionDataSets.find(torsion); |
565 |
|
inversion != NULL; |
566 |
|
inversion = mol->nextInversion(inversionIter)) { |
567 |
|
RealType angle; |
568 |
< |
inversion->calcForce(angle); |
568 |
> |
inversion->calcForce(angle, doParticlePot_); |
569 |
|
RealType currInversionPot = inversion->getPotential(); |
570 |
|
inversionPotential += inversion->getPotential(); |
571 |
|
map<Inversion*, InversionDataSet>::iterator i = inversionDataSets.find(inversion); |
598 |
|
|
599 |
|
void ForceManager::longRangeInteractions() { |
600 |
|
|
601 |
+ |
|
602 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
603 |
|
DataStorage* config = &(curSnapshot->atomData); |
604 |
|
DataStorage* cgConfig = &(curSnapshot->cgData); |
622 |
|
// center of mass of the group is the same as position of the atom |
623 |
|
// if cutoff group does not exist |
624 |
|
cgConfig->position = config->position; |
625 |
+ |
cgConfig->velocity = config->velocity; |
626 |
|
} |
627 |
|
|
628 |
|
fDecomp_->zeroWorkArrays(); |
629 |
|
fDecomp_->distributeData(); |
630 |
|
|
631 |
|
int cg1, cg2, atom1, atom2, topoDist; |
632 |
< |
Vector3d d_grp, dag, d; |
632 |
> |
Vector3d d_grp, dag, d, gvel2, vel2; |
633 |
|
RealType rgrpsq, rgrp, r2, r; |
634 |
|
RealType electroMult, vdwMult; |
635 |
|
RealType vij; |
644 |
|
RealType mf; |
645 |
|
RealType lrPot; |
646 |
|
RealType vpair; |
647 |
+ |
RealType dVdFQ1(0.0); |
648 |
+ |
RealType dVdFQ2(0.0); |
649 |
|
potVec longRangePotential(0.0); |
650 |
|
potVec workPot(0.0); |
651 |
+ |
vector<int>::iterator ia, jb; |
652 |
|
|
653 |
|
int loopStart, loopEnd; |
654 |
|
|
657 |
|
idat.pot = &workPot; |
658 |
|
sdat.pot = fDecomp_->getEmbeddingPotential(); |
659 |
|
idat.vpair = &vpair; |
660 |
+ |
idat.dVdFQ1 = &dVdFQ1; |
661 |
+ |
idat.dVdFQ2 = &dVdFQ2; |
662 |
|
idat.f1 = &f1; |
663 |
|
idat.sw = &sw; |
664 |
|
idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false; |
665 |
|
idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE) ? true : false; |
666 |
+ |
idat.doParticlePot = doParticlePot_; |
667 |
+ |
sdat.doParticlePot = doParticlePot_; |
668 |
|
|
669 |
|
loopEnd = PAIR_LOOP; |
670 |
|
if (info_->requiresPrepair() ) { |
708 |
|
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
709 |
|
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
710 |
|
|
711 |
< |
for (vector<int>::iterator ia = atomListRow.begin(); |
711 |
> |
if (doHeatFlux_) |
712 |
> |
gvel2 = fDecomp_->getGroupVelocityColumn(cg2); |
713 |
> |
|
714 |
> |
for (ia = atomListRow.begin(); |
715 |
|
ia != atomListRow.end(); ++ia) { |
716 |
|
atom1 = (*ia); |
717 |
|
|
718 |
< |
for (vector<int>::iterator jb = atomListColumn.begin(); |
718 |
> |
for (jb = atomListColumn.begin(); |
719 |
|
jb != atomListColumn.end(); ++jb) { |
720 |
|
atom2 = (*jb); |
721 |
|
|
723 |
|
vpair = 0.0; |
724 |
|
workPot = 0.0; |
725 |
|
f1 = V3Zero; |
726 |
+ |
dVdFQ1 = 0.0; |
727 |
+ |
dVdFQ2 = 0.0; |
728 |
|
|
729 |
|
fDecomp_->fillInteractionData(idat, atom1, atom2); |
730 |
|
|
735 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
736 |
|
idat.d = &d_grp; |
737 |
|
idat.r2 = &rgrpsq; |
738 |
+ |
if (doHeatFlux_) |
739 |
+ |
vel2 = gvel2; |
740 |
|
} else { |
741 |
|
d = fDecomp_->getInteratomicVector(atom1, atom2); |
742 |
|
curSnapshot->wrapVector( d ); |
743 |
|
r2 = d.lengthSquare(); |
744 |
|
idat.d = &d; |
745 |
|
idat.r2 = &r2; |
746 |
+ |
if (doHeatFlux_) |
747 |
+ |
vel2 = fDecomp_->getAtomVelocityColumn(atom2); |
748 |
|
} |
749 |
|
|
750 |
|
r = sqrt( *(idat.r2) ); |
757 |
|
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
758 |
|
vij += vpair; |
759 |
|
fij += f1; |
760 |
< |
tau -= outProduct( *(idat.d), f1); |
760 |
> |
stressTensor -= outProduct( *(idat.d), f1); |
761 |
> |
if (doHeatFlux_) |
762 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(f1, vel2)); |
763 |
|
} |
764 |
|
} |
765 |
|
} |
772 |
|
fij += fg; |
773 |
|
|
774 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
775 |
< |
tau -= outProduct( *(idat.d), fg); |
775 |
> |
stressTensor -= outProduct( *(idat.d), fg); |
776 |
> |
if (doHeatFlux_) |
777 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(fg, vel2)); |
778 |
> |
|
779 |
|
} |
780 |
|
|
781 |
< |
for (vector<int>::iterator ia = atomListRow.begin(); |
781 |
> |
for (ia = atomListRow.begin(); |
782 |
|
ia != atomListRow.end(); ++ia) { |
783 |
|
atom1 = (*ia); |
784 |
|
mf = fDecomp_->getMassFactorRow(atom1); |
791 |
|
// find the distance between the atom |
792 |
|
// and the center of the cutoff group: |
793 |
|
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
794 |
< |
tau -= outProduct(dag, fg); |
794 |
> |
stressTensor -= outProduct(dag, fg); |
795 |
> |
if (doHeatFlux_) |
796 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
797 |
|
} |
798 |
|
} |
799 |
|
} |
800 |
< |
for (vector<int>::iterator jb = atomListColumn.begin(); |
800 |
> |
for (jb = atomListColumn.begin(); |
801 |
|
jb != atomListColumn.end(); ++jb) { |
802 |
|
atom2 = (*jb); |
803 |
|
mf = fDecomp_->getMassFactorColumn(atom2); |
811 |
|
// find the distance between the atom |
812 |
|
// and the center of the cutoff group: |
813 |
|
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
814 |
< |
tau -= outProduct(dag, fg); |
814 |
> |
stressTensor -= outProduct(dag, fg); |
815 |
> |
if (doHeatFlux_) |
816 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
817 |
|
} |
818 |
|
} |
819 |
|
} |
820 |
|
} |
821 |
|
//if (!info_->usesAtomicVirial()) { |
822 |
< |
// tau -= outProduct(d_grp, fij); |
822 |
> |
// stressTensor -= outProduct(d_grp, fij); |
823 |
> |
// if (doHeatFlux_) |
824 |
> |
// fDecomp_->addToHeatFlux( d_grp * dot(fij, vel2)); |
825 |
|
//} |
826 |
|
} |
827 |
|
} |
859 |
|
|
860 |
|
lrPot = longRangePotential.sum(); |
861 |
|
|
862 |
< |
//store the tau and long range potential |
862 |
> |
//store the stressTensor and long range potential |
863 |
|
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; |
864 |
|
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY]; |
865 |
|
curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_FAMILY]; |
880 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
881 |
|
rb = mol->nextRigidBody(rbIter)) { |
882 |
|
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
883 |
< |
tau += rbTau; |
883 |
> |
stressTensor += rbTau; |
884 |
|
} |
885 |
|
} |
886 |
|
|
887 |
|
#ifdef IS_MPI |
888 |
< |
Mat3x3d tmpTau(tau); |
889 |
< |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
890 |
< |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
888 |
> |
|
889 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, stressTensor.getArrayPointer(), 9, |
890 |
> |
MPI::REALTYPE, MPI::SUM); |
891 |
|
#endif |
892 |
< |
curSnapshot->statData.setTau(tau); |
892 |
> |
curSnapshot->setStressTensor(stressTensor); |
893 |
> |
|
894 |
|
} |
895 |
|
|
896 |
|
} //end namespace OpenMD |