35 |
|
* |
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). |
38 |
> |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
39 |
|
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
|
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
*/ |
44 |
|
* @file ForceManager.cpp |
45 |
|
* @author tlin |
46 |
|
* @date 11/09/2004 |
47 |
– |
* @time 10:39am |
47 |
|
* @version 1.0 |
48 |
|
*/ |
49 |
|
|
57 |
|
#include "primitives/Torsion.hpp" |
58 |
|
#include "primitives/Inversion.hpp" |
59 |
|
#include "nonbonded/NonBondedInteraction.hpp" |
60 |
+ |
#include "perturbations/ElectricField.hpp" |
61 |
|
#include "parallel/ForceMatrixDecomposition.hpp" |
62 |
|
|
63 |
|
#include <cstdio> |
71 |
|
forceField_ = info_->getForceField(); |
72 |
|
interactionMan_ = new InteractionManager(); |
73 |
|
fDecomp_ = new ForceMatrixDecomposition(info_, interactionMan_); |
74 |
+ |
thermo = new Thermo(info_); |
75 |
|
} |
76 |
|
|
77 |
|
/** |
111 |
|
Globals* simParams_ = info_->getSimParams(); |
112 |
|
ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); |
113 |
|
int mdFileVersion; |
114 |
+ |
rCut_ = 0.0; //Needs a value for a later max() call; |
115 |
|
|
116 |
|
if (simParams_->haveMDfileVersion()) |
117 |
|
mdFileVersion = simParams_->getMDfileVersion(); |
118 |
|
else |
119 |
|
mdFileVersion = 0; |
120 |
|
|
121 |
+ |
// We need the list of simulated atom types to figure out cutoffs |
122 |
+ |
// as well as long range corrections. |
123 |
+ |
|
124 |
+ |
set<AtomType*>::iterator i; |
125 |
+ |
set<AtomType*> atomTypes_; |
126 |
+ |
atomTypes_ = info_->getSimulatedAtomTypes(); |
127 |
+ |
|
128 |
|
if (simParams_->haveCutoffRadius()) { |
129 |
|
rCut_ = simParams_->getCutoffRadius(); |
130 |
|
} else { |
139 |
|
rCut_ = 12.0; |
140 |
|
} else { |
141 |
|
RealType thisCut; |
142 |
< |
set<AtomType*>::iterator i; |
134 |
< |
set<AtomType*> atomTypes; |
135 |
< |
atomTypes = info_->getSimulatedAtomTypes(); |
136 |
< |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
142 |
> |
for (i = atomTypes_.begin(); i != atomTypes_.end(); ++i) { |
143 |
|
thisCut = interactionMan_->getSuggestedCutoffRadius((*i)); |
144 |
|
rCut_ = max(thisCut, rCut_); |
145 |
|
} |
207 |
|
// electrostaticSummationMethod keyword. |
208 |
|
|
209 |
|
if (simParams_->haveElectrostaticSummationMethod()) { |
210 |
< |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
210 |
> |
string myMethod = simParams_->getElectrostaticSummationMethod(); |
211 |
|
toUpper(myMethod); |
212 |
|
|
213 |
|
if (myMethod == "SHIFTED_POTENTIAL") { |
262 |
|
stringToCutoffPolicy["MAX"] = MAX; |
263 |
|
stringToCutoffPolicy["TRADITIONAL"] = TRADITIONAL; |
264 |
|
|
265 |
< |
std::string cutPolicy; |
265 |
> |
string cutPolicy; |
266 |
|
if (forceFieldOptions_.haveCutoffPolicy()){ |
267 |
|
cutPolicy = forceFieldOptions_.getCutoffPolicy(); |
268 |
|
}else if (simParams_->haveCutoffPolicy()) { |
374 |
|
} |
375 |
|
switcher_->setSwitchType(sft_); |
376 |
|
switcher_->setSwitch(rSwitch_, rCut_); |
371 |
– |
interactionMan_->setSwitchingRadius(rSwitch_); |
377 |
|
} |
378 |
|
|
379 |
|
|
393 |
|
setupCutoffs(); |
394 |
|
|
395 |
|
info_->prepareTopology(); |
396 |
+ |
|
397 |
+ |
doParticlePot_ = info_->getSimParams()->getOutputParticlePotential(); |
398 |
+ |
doHeatFlux_ = info_->getSimParams()->getPrintHeatFlux(); |
399 |
+ |
if (doHeatFlux_) doParticlePot_ = true; |
400 |
+ |
|
401 |
+ |
doElectricField_ = info_->getSimParams()->getOutputElectricField(); |
402 |
+ |
|
403 |
|
} |
404 |
|
|
405 |
|
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
429 |
|
electrostaticScale_[2] = fopts.getelectrostatic13scale(); |
430 |
|
electrostaticScale_[3] = fopts.getelectrostatic14scale(); |
431 |
|
|
432 |
< |
fDecomp_->distributeInitialData(); |
433 |
< |
|
434 |
< |
initialized_ = true; |
432 |
> |
if (info_->getSimParams()->haveElectricField()) { |
433 |
> |
ElectricField* eField = new ElectricField(info_); |
434 |
> |
perturbations_.push_back(eField); |
435 |
> |
} |
436 |
|
|
437 |
+ |
usePeriodicBoundaryConditions_ = info_->getSimParams()->getUsePeriodicBoundaryConditions(); |
438 |
+ |
|
439 |
+ |
fDecomp_->distributeInitialData(); |
440 |
+ |
|
441 |
+ |
initialized_ = true; |
442 |
+ |
|
443 |
|
} |
444 |
< |
|
444 |
> |
|
445 |
|
void ForceManager::calcForces() { |
446 |
|
|
447 |
|
if (!initialized_) initialize(); |
448 |
< |
|
448 |
> |
|
449 |
|
preCalculation(); |
450 |
|
shortRangeInteractions(); |
451 |
|
longRangeInteractions(); |
462 |
|
Molecule::CutoffGroupIterator ci; |
463 |
|
CutoffGroup* cg; |
464 |
|
|
465 |
< |
// forces are zeroed here, before any are accumulated. |
465 |
> |
// forces and potentials are zeroed here, before any are |
466 |
> |
// accumulated. |
467 |
|
|
468 |
+ |
Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot(); |
469 |
+ |
|
470 |
+ |
snap->setBondPotential(0.0); |
471 |
+ |
snap->setBendPotential(0.0); |
472 |
+ |
snap->setTorsionPotential(0.0); |
473 |
+ |
snap->setInversionPotential(0.0); |
474 |
+ |
|
475 |
+ |
potVec zeroPot(0.0); |
476 |
+ |
snap->setLongRangePotential(zeroPot); |
477 |
+ |
snap->setExcludedPotentials(zeroPot); |
478 |
+ |
|
479 |
+ |
snap->setRestraintPotential(0.0); |
480 |
+ |
snap->setRawPotential(0.0); |
481 |
+ |
|
482 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; |
483 |
|
mol = info_->nextMolecule(mi)) { |
484 |
|
for(atom = mol->beginAtom(ai); atom != NULL; |
502 |
|
} |
503 |
|
|
504 |
|
// Zero out the stress tensor |
505 |
< |
tau *= 0.0; |
506 |
< |
|
505 |
> |
stressTensor *= 0.0; |
506 |
> |
// Zero out the heatFlux |
507 |
> |
fDecomp_->setHeatFlux( Vector3d(0.0) ); |
508 |
|
} |
509 |
|
|
510 |
|
void ForceManager::shortRangeInteractions() { |
537 |
|
|
538 |
|
for (bond = mol->beginBond(bondIter); bond != NULL; |
539 |
|
bond = mol->nextBond(bondIter)) { |
540 |
< |
bond->calcForce(); |
540 |
> |
bond->calcForce(doParticlePot_); |
541 |
|
bondPotential += bond->getPotential(); |
542 |
|
} |
543 |
|
|
545 |
|
bend = mol->nextBend(bendIter)) { |
546 |
|
|
547 |
|
RealType angle; |
548 |
< |
bend->calcForce(angle); |
548 |
> |
bend->calcForce(angle, doParticlePot_); |
549 |
|
RealType currBendPot = bend->getPotential(); |
550 |
|
|
551 |
|
bendPotential += bend->getPotential(); |
570 |
|
for (torsion = mol->beginTorsion(torsionIter); torsion != NULL; |
571 |
|
torsion = mol->nextTorsion(torsionIter)) { |
572 |
|
RealType angle; |
573 |
< |
torsion->calcForce(angle); |
573 |
> |
torsion->calcForce(angle, doParticlePot_); |
574 |
|
RealType currTorsionPot = torsion->getPotential(); |
575 |
|
torsionPotential += torsion->getPotential(); |
576 |
|
map<Torsion*, TorsionDataSet>::iterator i = torsionDataSets.find(torsion); |
594 |
|
inversion != NULL; |
595 |
|
inversion = mol->nextInversion(inversionIter)) { |
596 |
|
RealType angle; |
597 |
< |
inversion->calcForce(angle); |
597 |
> |
inversion->calcForce(angle, doParticlePot_); |
598 |
|
RealType currInversionPot = inversion->getPotential(); |
599 |
|
inversionPotential += inversion->getPotential(); |
600 |
|
map<Inversion*, InversionDataSet>::iterator i = inversionDataSets.find(inversion); |
614 |
|
} |
615 |
|
} |
616 |
|
} |
617 |
< |
|
618 |
< |
RealType shortRangePotential = bondPotential + bendPotential + |
619 |
< |
torsionPotential + inversionPotential; |
617 |
> |
|
618 |
> |
#ifdef IS_MPI |
619 |
> |
// Collect from all nodes. This should eventually be moved into a |
620 |
> |
// SystemDecomposition, but this is a better place than in |
621 |
> |
// Thermo to do the collection. |
622 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &bondPotential, 1, MPI::REALTYPE, |
623 |
> |
MPI::SUM); |
624 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &bendPotential, 1, MPI::REALTYPE, |
625 |
> |
MPI::SUM); |
626 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &torsionPotential, 1, |
627 |
> |
MPI::REALTYPE, MPI::SUM); |
628 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &inversionPotential, 1, |
629 |
> |
MPI::REALTYPE, MPI::SUM); |
630 |
> |
#endif |
631 |
> |
|
632 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
633 |
< |
curSnapshot->statData[Stats::SHORT_RANGE_POTENTIAL] = shortRangePotential; |
634 |
< |
curSnapshot->statData[Stats::BOND_POTENTIAL] = bondPotential; |
635 |
< |
curSnapshot->statData[Stats::BEND_POTENTIAL] = bendPotential; |
636 |
< |
curSnapshot->statData[Stats::DIHEDRAL_POTENTIAL] = torsionPotential; |
637 |
< |
curSnapshot->statData[Stats::INVERSION_POTENTIAL] = inversionPotential; |
633 |
> |
|
634 |
> |
curSnapshot->setBondPotential(bondPotential); |
635 |
> |
curSnapshot->setBendPotential(bendPotential); |
636 |
> |
curSnapshot->setTorsionPotential(torsionPotential); |
637 |
> |
curSnapshot->setInversionPotential(inversionPotential); |
638 |
> |
|
639 |
> |
// RealType shortRangePotential = bondPotential + bendPotential + |
640 |
> |
// torsionPotential + inversionPotential; |
641 |
> |
|
642 |
> |
// curSnapshot->setShortRangePotential(shortRangePotential); |
643 |
|
} |
644 |
|
|
645 |
|
void ForceManager::longRangeInteractions() { |
646 |
|
|
647 |
+ |
|
648 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
649 |
|
DataStorage* config = &(curSnapshot->atomData); |
650 |
|
DataStorage* cgConfig = &(curSnapshot->cgData); |
668 |
|
// center of mass of the group is the same as position of the atom |
669 |
|
// if cutoff group does not exist |
670 |
|
cgConfig->position = config->position; |
671 |
+ |
cgConfig->velocity = config->velocity; |
672 |
|
} |
673 |
|
|
674 |
|
fDecomp_->zeroWorkArrays(); |
675 |
|
fDecomp_->distributeData(); |
676 |
|
|
677 |
|
int cg1, cg2, atom1, atom2, topoDist; |
678 |
< |
Vector3d d_grp, dag, d; |
678 |
> |
Vector3d d_grp, dag, d, gvel2, vel2; |
679 |
|
RealType rgrpsq, rgrp, r2, r; |
680 |
|
RealType electroMult, vdwMult; |
681 |
|
RealType vij; |
688 |
|
InteractionData idat; |
689 |
|
SelfData sdat; |
690 |
|
RealType mf; |
637 |
– |
RealType lrPot; |
691 |
|
RealType vpair; |
692 |
+ |
RealType dVdFQ1(0.0); |
693 |
+ |
RealType dVdFQ2(0.0); |
694 |
|
potVec longRangePotential(0.0); |
695 |
|
potVec workPot(0.0); |
696 |
+ |
potVec exPot(0.0); |
697 |
+ |
Vector3d eField1(0.0); |
698 |
+ |
Vector3d eField2(0.0); |
699 |
+ |
vector<int>::iterator ia, jb; |
700 |
|
|
701 |
|
int loopStart, loopEnd; |
702 |
|
|
703 |
|
idat.vdwMult = &vdwMult; |
704 |
|
idat.electroMult = &electroMult; |
705 |
|
idat.pot = &workPot; |
706 |
+ |
idat.excludedPot = &exPot; |
707 |
|
sdat.pot = fDecomp_->getEmbeddingPotential(); |
708 |
+ |
sdat.excludedPot = fDecomp_->getExcludedSelfPotential(); |
709 |
|
idat.vpair = &vpair; |
710 |
+ |
idat.dVdFQ1 = &dVdFQ1; |
711 |
+ |
idat.dVdFQ2 = &dVdFQ2; |
712 |
+ |
idat.eField1 = &eField1; |
713 |
+ |
idat.eField2 = &eField2; |
714 |
|
idat.f1 = &f1; |
715 |
|
idat.sw = &sw; |
716 |
|
idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false; |
717 |
|
idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE) ? true : false; |
718 |
+ |
idat.doParticlePot = doParticlePot_; |
719 |
+ |
idat.doElectricField = doElectricField_; |
720 |
+ |
sdat.doParticlePot = doParticlePot_; |
721 |
|
|
722 |
|
loopEnd = PAIR_LOOP; |
723 |
|
if (info_->requiresPrepair() ) { |
725 |
|
} else { |
726 |
|
loopStart = PAIR_LOOP; |
727 |
|
} |
660 |
– |
|
728 |
|
for (int iLoop = loopStart; iLoop <= loopEnd; iLoop++) { |
729 |
|
|
730 |
|
if (iLoop == loopStart) { |
731 |
|
bool update_nlist = fDecomp_->checkNeighborList(); |
732 |
< |
if (update_nlist) |
732 |
> |
if (update_nlist) { |
733 |
> |
if (!usePeriodicBoundaryConditions_) |
734 |
> |
Mat3x3d bbox = thermo->getBoundingBox(); |
735 |
|
neighborList = fDecomp_->buildNeighborList(); |
736 |
< |
} |
736 |
> |
} |
737 |
> |
} |
738 |
|
|
739 |
|
for (vector<pair<int, int> >::iterator it = neighborList.begin(); |
740 |
|
it != neighborList.end(); ++it) { |
755 |
|
if (iLoop == PAIR_LOOP) { |
756 |
|
vij = 0.0; |
757 |
|
fij = V3Zero; |
758 |
+ |
eField1 = V3Zero; |
759 |
+ |
eField2 = V3Zero; |
760 |
|
} |
761 |
|
|
762 |
|
in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, |
763 |
|
rgrp); |
764 |
< |
|
764 |
> |
|
765 |
|
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
766 |
|
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
767 |
|
|
768 |
< |
for (vector<int>::iterator ia = atomListRow.begin(); |
768 |
> |
if (doHeatFlux_) |
769 |
> |
gvel2 = fDecomp_->getGroupVelocityColumn(cg2); |
770 |
> |
|
771 |
> |
for (ia = atomListRow.begin(); |
772 |
|
ia != atomListRow.end(); ++ia) { |
773 |
|
atom1 = (*ia); |
774 |
< |
|
775 |
< |
for (vector<int>::iterator jb = atomListColumn.begin(); |
774 |
> |
|
775 |
> |
for (jb = atomListColumn.begin(); |
776 |
|
jb != atomListColumn.end(); ++jb) { |
777 |
|
atom2 = (*jb); |
778 |
|
|
779 |
< |
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
779 |
> |
if (!fDecomp_->skipAtomPair(atom1, atom2, cg1, cg2)) { |
780 |
> |
|
781 |
|
vpair = 0.0; |
782 |
|
workPot = 0.0; |
783 |
+ |
exPot = 0.0; |
784 |
|
f1 = V3Zero; |
785 |
+ |
dVdFQ1 = 0.0; |
786 |
+ |
dVdFQ2 = 0.0; |
787 |
|
|
788 |
|
fDecomp_->fillInteractionData(idat, atom1, atom2); |
789 |
< |
|
789 |
> |
|
790 |
|
topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); |
791 |
|
vdwMult = vdwScale_[topoDist]; |
792 |
|
electroMult = electrostaticScale_[topoDist]; |
794 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
795 |
|
idat.d = &d_grp; |
796 |
|
idat.r2 = &rgrpsq; |
797 |
+ |
if (doHeatFlux_) |
798 |
+ |
vel2 = gvel2; |
799 |
|
} else { |
800 |
|
d = fDecomp_->getInteratomicVector(atom1, atom2); |
801 |
|
curSnapshot->wrapVector( d ); |
802 |
|
r2 = d.lengthSquare(); |
803 |
|
idat.d = &d; |
804 |
|
idat.r2 = &r2; |
805 |
+ |
if (doHeatFlux_) |
806 |
+ |
vel2 = fDecomp_->getAtomVelocityColumn(atom2); |
807 |
|
} |
808 |
|
|
809 |
|
r = sqrt( *(idat.r2) ); |
816 |
|
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
817 |
|
vij += vpair; |
818 |
|
fij += f1; |
819 |
< |
tau -= outProduct( *(idat.d), f1); |
819 |
> |
stressTensor -= outProduct( *(idat.d), f1); |
820 |
> |
if (doHeatFlux_) |
821 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(f1, vel2)); |
822 |
|
} |
823 |
|
} |
824 |
|
} |
831 |
|
fij += fg; |
832 |
|
|
833 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
834 |
< |
tau -= outProduct( *(idat.d), fg); |
834 |
> |
if (!fDecomp_->skipAtomPair(atomListRow[0], |
835 |
> |
atomListColumn[0], |
836 |
> |
cg1, cg2)) { |
837 |
> |
stressTensor -= outProduct( *(idat.d), fg); |
838 |
> |
if (doHeatFlux_) |
839 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(fg, vel2)); |
840 |
> |
} |
841 |
|
} |
842 |
|
|
843 |
< |
for (vector<int>::iterator ia = atomListRow.begin(); |
843 |
> |
for (ia = atomListRow.begin(); |
844 |
|
ia != atomListRow.end(); ++ia) { |
845 |
|
atom1 = (*ia); |
846 |
|
mf = fDecomp_->getMassFactorRow(atom1); |
853 |
|
// find the distance between the atom |
854 |
|
// and the center of the cutoff group: |
855 |
|
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
856 |
< |
tau -= outProduct(dag, fg); |
856 |
> |
stressTensor -= outProduct(dag, fg); |
857 |
> |
if (doHeatFlux_) |
858 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
859 |
|
} |
860 |
|
} |
861 |
|
} |
862 |
< |
for (vector<int>::iterator jb = atomListColumn.begin(); |
862 |
> |
for (jb = atomListColumn.begin(); |
863 |
|
jb != atomListColumn.end(); ++jb) { |
864 |
|
atom2 = (*jb); |
865 |
|
mf = fDecomp_->getMassFactorColumn(atom2); |
873 |
|
// find the distance between the atom |
874 |
|
// and the center of the cutoff group: |
875 |
|
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
876 |
< |
tau -= outProduct(dag, fg); |
876 |
> |
stressTensor -= outProduct(dag, fg); |
877 |
> |
if (doHeatFlux_) |
878 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
879 |
|
} |
880 |
|
} |
881 |
|
} |
882 |
|
} |
883 |
|
//if (!info_->usesAtomicVirial()) { |
884 |
< |
// tau -= outProduct(d_grp, fij); |
884 |
> |
// stressTensor -= outProduct(d_grp, fij); |
885 |
> |
// if (doHeatFlux_) |
886 |
> |
// fDecomp_->addToHeatFlux( d_grp * dot(fij, vel2)); |
887 |
|
//} |
888 |
|
} |
889 |
|
} |
894 |
|
|
895 |
|
fDecomp_->collectIntermediateData(); |
896 |
|
|
897 |
< |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
897 |
> |
for (unsigned int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
898 |
|
fDecomp_->fillSelfData(sdat, atom1); |
899 |
|
interactionMan_->doPreForce(sdat); |
900 |
|
} |
905 |
|
} |
906 |
|
} |
907 |
|
|
908 |
+ |
// collects pairwise information |
909 |
|
fDecomp_->collectData(); |
910 |
|
|
911 |
|
if (info_->requiresSelfCorrection()) { |
912 |
< |
|
815 |
< |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
912 |
> |
for (unsigned int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
913 |
|
fDecomp_->fillSelfData(sdat, atom1); |
914 |
|
interactionMan_->doSelfCorrection(sdat); |
915 |
|
} |
819 |
– |
|
916 |
|
} |
917 |
|
|
918 |
+ |
// collects single-atom information |
919 |
+ |
fDecomp_->collectSelfData(); |
920 |
+ |
|
921 |
|
longRangePotential = *(fDecomp_->getEmbeddingPotential()) + |
922 |
|
*(fDecomp_->getPairwisePotential()); |
923 |
|
|
924 |
< |
lrPot = longRangePotential.sum(); |
924 |
> |
curSnapshot->setLongRangePotential(longRangePotential); |
925 |
> |
|
926 |
> |
curSnapshot->setExcludedPotentials(*(fDecomp_->getExcludedSelfPotential()) + |
927 |
> |
*(fDecomp_->getExcludedPotential())); |
928 |
|
|
827 |
– |
//store the tau and long range potential |
828 |
– |
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; |
829 |
– |
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY]; |
830 |
– |
curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_FAMILY]; |
929 |
|
} |
930 |
|
|
931 |
|
|
932 |
|
void ForceManager::postCalculation() { |
933 |
+ |
|
934 |
+ |
vector<Perturbation*>::iterator pi; |
935 |
+ |
for (pi = perturbations_.begin(); pi != perturbations_.end(); ++pi) { |
936 |
+ |
(*pi)->applyPerturbation(); |
937 |
+ |
} |
938 |
+ |
|
939 |
|
SimInfo::MoleculeIterator mi; |
940 |
|
Molecule* mol; |
941 |
|
Molecule::RigidBodyIterator rbIter; |
942 |
|
RigidBody* rb; |
943 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
944 |
< |
|
944 |
> |
|
945 |
|
// collect the atomic forces onto rigid bodies |
946 |
|
|
947 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; |
949 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
950 |
|
rb = mol->nextRigidBody(rbIter)) { |
951 |
|
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
952 |
< |
tau += rbTau; |
952 |
> |
stressTensor += rbTau; |
953 |
|
} |
954 |
|
} |
955 |
|
|
956 |
|
#ifdef IS_MPI |
957 |
< |
Mat3x3d tmpTau(tau); |
958 |
< |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
855 |
< |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
957 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, stressTensor.getArrayPointer(), 9, |
958 |
> |
MPI::REALTYPE, MPI::SUM); |
959 |
|
#endif |
960 |
< |
curSnapshot->statData.setTau(tau); |
961 |
< |
} |
960 |
> |
curSnapshot->setStressTensor(stressTensor); |
961 |
> |
|
962 |
> |
if (info_->getSimParams()->getUseLongRangeCorrections()) { |
963 |
> |
/* |
964 |
> |
RealType vol = curSnapshot->getVolume(); |
965 |
> |
RealType Elrc(0.0); |
966 |
> |
RealType Wlrc(0.0); |
967 |
|
|
968 |
< |
} //end namespace OpenMD |
968 |
> |
set<AtomType*>::iterator i; |
969 |
> |
set<AtomType*>::iterator j; |
970 |
> |
|
971 |
> |
RealType n_i, n_j; |
972 |
> |
RealType rho_i, rho_j; |
973 |
> |
pair<RealType, RealType> LRI; |
974 |
> |
|
975 |
> |
for (i = atomTypes_.begin(); i != atomTypes_.end(); ++i) { |
976 |
> |
n_i = RealType(info_->getGlobalCountOfType(*i)); |
977 |
> |
rho_i = n_i / vol; |
978 |
> |
for (j = atomTypes_.begin(); j != atomTypes_.end(); ++j) { |
979 |
> |
n_j = RealType(info_->getGlobalCountOfType(*j)); |
980 |
> |
rho_j = n_j / vol; |
981 |
> |
|
982 |
> |
LRI = interactionMan_->getLongRangeIntegrals( (*i), (*j) ); |
983 |
> |
|
984 |
> |
Elrc += n_i * rho_j * LRI.first; |
985 |
> |
Wlrc -= rho_i * rho_j * LRI.second; |
986 |
> |
} |
987 |
> |
} |
988 |
> |
Elrc *= 2.0 * NumericConstant::PI; |
989 |
> |
Wlrc *= 2.0 * NumericConstant::PI; |
990 |
> |
|
991 |
> |
RealType lrp = curSnapshot->getLongRangePotential(); |
992 |
> |
curSnapshot->setLongRangePotential(lrp + Elrc); |
993 |
> |
stressTensor += Wlrc * SquareMatrix3<RealType>::identity(); |
994 |
> |
curSnapshot->setStressTensor(stressTensor); |
995 |
> |
*/ |
996 |
> |
|
997 |
> |
} |
998 |
> |
} |
999 |
> |
} |