57 |
|
#include "primitives/Torsion.hpp" |
58 |
|
#include "primitives/Inversion.hpp" |
59 |
|
#include "nonbonded/NonBondedInteraction.hpp" |
60 |
< |
#include "perturbations/ElectricField.hpp" |
60 |
> |
#include "perturbations/UniformField.hpp" |
61 |
> |
#include "perturbations/UniformGradient.hpp" |
62 |
|
#include "parallel/ForceMatrixDecomposition.hpp" |
63 |
|
|
64 |
|
#include <cstdio> |
68 |
|
using namespace std; |
69 |
|
namespace OpenMD { |
70 |
|
|
71 |
< |
ForceManager::ForceManager(SimInfo * info) : info_(info), switcher_(NULL), |
72 |
< |
initialized_(false) { |
71 |
> |
ForceManager::ForceManager(SimInfo * info) : initialized_(false), info_(info), |
72 |
> |
switcher_(NULL) { |
73 |
|
forceField_ = info_->getForceField(); |
74 |
|
interactionMan_ = new InteractionManager(); |
75 |
|
fDecomp_ = new ForceMatrixDecomposition(info_, interactionMan_); |
88 |
|
/** |
89 |
|
* setupCutoffs |
90 |
|
* |
91 |
< |
* Sets the values of cutoffRadius, switchingRadius, cutoffMethod, |
91 |
< |
* and cutoffPolicy |
91 |
> |
* Sets the values of cutoffRadius, switchingRadius, and cutoffMethod |
92 |
|
* |
93 |
|
* cutoffRadius : realType |
94 |
|
* If the cutoffRadius was explicitly set, use that value. |
103 |
|
* If cutoffMethod was explicitly set, use that choice. |
104 |
|
* If cutoffMethod was not explicitly set, use SHIFTED_FORCE |
105 |
|
* |
106 |
– |
* cutoffPolicy : (one of MIX, MAX, TRADITIONAL) |
107 |
– |
* If cutoffPolicy was explicitly set, use that choice. |
108 |
– |
* If cutoffPolicy was not explicitly set, use TRADITIONAL |
109 |
– |
* |
106 |
|
* switchingRadius : realType |
107 |
|
* If the cutoffMethod was set to SWITCHED: |
108 |
|
* If the switchingRadius was explicitly set, use that value |
115 |
|
void ForceManager::setupCutoffs() { |
116 |
|
|
117 |
|
Globals* simParams_ = info_->getSimParams(); |
122 |
– |
ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); |
118 |
|
int mdFileVersion; |
119 |
|
rCut_ = 0.0; //Needs a value for a later max() call; |
120 |
|
|
158 |
|
} |
159 |
|
} |
160 |
|
|
161 |
< |
fDecomp_->setUserCutoff(rCut_); |
161 |
> |
fDecomp_->setCutoffRadius(rCut_); |
162 |
|
interactionMan_->setCutoffRadius(rCut_); |
163 |
+ |
rCutSq_ = rCut_ * rCut_; |
164 |
|
|
165 |
|
map<string, CutoffMethod> stringToCutoffMethod; |
166 |
|
stringToCutoffMethod["HARD"] = HARD; |
270 |
|
} |
271 |
|
} |
272 |
|
} |
277 |
– |
|
278 |
– |
map<string, CutoffPolicy> stringToCutoffPolicy; |
279 |
– |
stringToCutoffPolicy["MIX"] = MIX; |
280 |
– |
stringToCutoffPolicy["MAX"] = MAX; |
281 |
– |
stringToCutoffPolicy["TRADITIONAL"] = TRADITIONAL; |
282 |
– |
|
283 |
– |
string cutPolicy; |
284 |
– |
if (forceFieldOptions_.haveCutoffPolicy()){ |
285 |
– |
cutPolicy = forceFieldOptions_.getCutoffPolicy(); |
286 |
– |
}else if (simParams_->haveCutoffPolicy()) { |
287 |
– |
cutPolicy = simParams_->getCutoffPolicy(); |
288 |
– |
} |
289 |
– |
|
290 |
– |
if (!cutPolicy.empty()){ |
291 |
– |
toUpper(cutPolicy); |
292 |
– |
map<string, CutoffPolicy>::iterator i; |
293 |
– |
i = stringToCutoffPolicy.find(cutPolicy); |
294 |
– |
|
295 |
– |
if (i == stringToCutoffPolicy.end()) { |
296 |
– |
sprintf(painCave.errMsg, |
297 |
– |
"ForceManager::setupCutoffs: Could not find chosen cutoffPolicy %s\n" |
298 |
– |
"\tShould be one of: " |
299 |
– |
"MIX, MAX, or TRADITIONAL\n", |
300 |
– |
cutPolicy.c_str()); |
301 |
– |
painCave.isFatal = 1; |
302 |
– |
painCave.severity = OPENMD_ERROR; |
303 |
– |
simError(); |
304 |
– |
} else { |
305 |
– |
cutoffPolicy_ = i->second; |
306 |
– |
} |
307 |
– |
} else { |
308 |
– |
sprintf(painCave.errMsg, |
309 |
– |
"ForceManager::setupCutoffs: No value was set for the cutoffPolicy.\n" |
310 |
– |
"\tOpenMD will use TRADITIONAL.\n"); |
311 |
– |
painCave.isFatal = 0; |
312 |
– |
painCave.severity = OPENMD_INFO; |
313 |
– |
simError(); |
314 |
– |
cutoffPolicy_ = TRADITIONAL; |
315 |
– |
} |
316 |
– |
|
317 |
– |
fDecomp_->setCutoffPolicy(cutoffPolicy_); |
273 |
|
|
274 |
|
// create the switching function object: |
275 |
|
|
349 |
|
switcher_->setSwitch(rSwitch_, rCut_); |
350 |
|
} |
351 |
|
|
397 |
– |
|
398 |
– |
|
399 |
– |
|
352 |
|
void ForceManager::initialize() { |
353 |
|
|
354 |
|
if (!info_->isTopologyDone()) { |
357 |
|
interactionMan_->setSimInfo(info_); |
358 |
|
interactionMan_->initialize(); |
359 |
|
|
360 |
< |
// We want to delay the cutoffs until after the interaction |
361 |
< |
// manager has set up the atom-atom interactions so that we can |
362 |
< |
// query them for suggested cutoff values |
360 |
> |
//! We want to delay the cutoffs until after the interaction |
361 |
> |
//! manager has set up the atom-atom interactions so that we can |
362 |
> |
//! query them for suggested cutoff values |
363 |
|
setupCutoffs(); |
364 |
|
|
365 |
|
info_->prepareTopology(); |
375 |
|
|
376 |
|
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
377 |
|
|
378 |
< |
// Force fields can set options on how to scale van der Waals and |
379 |
< |
// electrostatic interactions for atoms connected via bonds, bends |
380 |
< |
// and torsions in this case the topological distance between |
381 |
< |
// atoms is: |
382 |
< |
// 0 = topologically unconnected |
383 |
< |
// 1 = bonded together |
384 |
< |
// 2 = connected via a bend |
385 |
< |
// 3 = connected via a torsion |
378 |
> |
//! Force fields can set options on how to scale van der Waals and |
379 |
> |
//! electrostatic interactions for atoms connected via bonds, bends |
380 |
> |
//! and torsions in this case the topological distance between |
381 |
> |
//! atoms is: |
382 |
> |
//! 0 = topologically unconnected |
383 |
> |
//! 1 = bonded together |
384 |
> |
//! 2 = connected via a bend |
385 |
> |
//! 3 = connected via a torsion |
386 |
|
|
387 |
|
vdwScale_.reserve(4); |
388 |
|
fill(vdwScale_.begin(), vdwScale_.end(), 0.0); |
400 |
|
electrostaticScale_[2] = fopts.getelectrostatic13scale(); |
401 |
|
electrostaticScale_[3] = fopts.getelectrostatic14scale(); |
402 |
|
|
403 |
< |
if (info_->getSimParams()->haveElectricField()) { |
404 |
< |
ElectricField* eField = new ElectricField(info_); |
403 |
> |
if (info_->getSimParams()->haveUniformField()) { |
404 |
> |
UniformField* eField = new UniformField(info_); |
405 |
|
perturbations_.push_back(eField); |
406 |
|
} |
407 |
< |
|
407 |
> |
if (info_->getSimParams()->haveUniformGradientStrength() || |
408 |
> |
info_->getSimParams()->haveUniformGradientDirection1() || |
409 |
> |
info_->getSimParams()->haveUniformGradientDirection2() ) { |
410 |
> |
UniformGradient* eGrad = new UniformGradient(info_); |
411 |
> |
perturbations_.push_back(eGrad); |
412 |
> |
} |
413 |
> |
|
414 |
|
usePeriodicBoundaryConditions_ = info_->getSimParams()->getUsePeriodicBoundaryConditions(); |
415 |
|
|
416 |
|
fDecomp_->distributeInitialData(); |
626 |
|
DataStorage* config = &(curSnapshot->atomData); |
627 |
|
DataStorage* cgConfig = &(curSnapshot->cgData); |
628 |
|
|
671 |
– |
|
629 |
|
//calculate the center of mass of cutoff group |
630 |
|
|
631 |
|
SimInfo::MoleculeIterator mi; |
632 |
|
Molecule* mol; |
633 |
|
Molecule::CutoffGroupIterator ci; |
634 |
|
CutoffGroup* cg; |
635 |
< |
|
636 |
< |
if(info_->getNCutoffGroups() > 0){ |
635 |
> |
|
636 |
> |
if(info_->getNCutoffGroups() != info_->getNAtoms()){ |
637 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; |
638 |
|
mol = info_->nextMolecule(mi)) { |
639 |
|
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
657 |
|
RealType electroMult, vdwMult; |
658 |
|
RealType vij; |
659 |
|
Vector3d fij, fg, f1; |
703 |
– |
tuple3<RealType, RealType, RealType> cuts; |
704 |
– |
RealType rCut, rCutSq, rListSq; |
660 |
|
bool in_switching_region; |
661 |
|
RealType sw, dswdr, swderiv; |
662 |
|
vector<int> atomListColumn, atomListRow; |
674 |
|
Vector3d eField2(0.0); |
675 |
|
RealType sPot1(0.0); |
676 |
|
RealType sPot2(0.0); |
677 |
+ |
bool newAtom1; |
678 |
|
|
679 |
|
vector<int>::iterator ia, jb; |
680 |
|
|
681 |
|
int loopStart, loopEnd; |
682 |
|
|
683 |
< |
idat.rcut = &rCut; |
683 |
> |
idat.rcut = &rCut_; |
684 |
|
idat.vdwMult = &vdwMult; |
685 |
|
idat.electroMult = &electroMult; |
686 |
|
idat.pot = &workPot; |
697 |
|
idat.f1 = &f1; |
698 |
|
idat.sw = &sw; |
699 |
|
idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false; |
700 |
< |
idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE || cutoffMethod_ == TAYLOR_SHIFTED) ? true : false; |
700 |
> |
idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE || |
701 |
> |
cutoffMethod_ == TAYLOR_SHIFTED) ? true : false; |
702 |
|
idat.doParticlePot = doParticlePot_; |
703 |
|
idat.doElectricField = doElectricField_; |
704 |
|
idat.doSitePotential = doSitePotential_; |
717 |
|
if (update_nlist) { |
718 |
|
if (!usePeriodicBoundaryConditions_) |
719 |
|
Mat3x3d bbox = thermo->getBoundingBox(); |
720 |
< |
fDecomp_->buildNeighborList(neighborList_); |
720 |
> |
fDecomp_->buildNeighborList(neighborList_, point_); |
721 |
|
} |
722 |
|
} |
723 |
|
|
724 |
< |
for (vector<pair<int, int> >::iterator it = neighborList_.begin(); |
768 |
< |
it != neighborList_.end(); ++it) { |
769 |
< |
|
770 |
< |
cg1 = (*it).first; |
771 |
< |
cg2 = (*it).second; |
724 |
> |
for (cg1 = 0; cg1 < int(point_.size()) - 1; cg1++) { |
725 |
|
|
726 |
< |
fDecomp_->getGroupCutoffs(cg1, cg2, rCut, rCutSq, rListSq); |
726 |
> |
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
727 |
> |
newAtom1 = true; |
728 |
> |
|
729 |
> |
for (int m2 = point_[cg1]; m2 < point_[cg1+1]; m2++) { |
730 |
|
|
731 |
< |
d_grp = fDecomp_->getIntergroupVector(cg1, cg2); |
776 |
< |
|
777 |
< |
// already wrapped in the getIntergroupVector call: |
778 |
< |
// curSnapshot->wrapVector(d_grp); |
779 |
< |
rgrpsq = d_grp.lengthSquare(); |
780 |
< |
|
781 |
< |
if (rgrpsq < rCutSq) { |
782 |
< |
if (iLoop == PAIR_LOOP) { |
783 |
< |
vij = 0.0; |
784 |
< |
fij.zero(); |
785 |
< |
eField1.zero(); |
786 |
< |
eField2.zero(); |
787 |
< |
sPot1 = 0.0; |
788 |
< |
sPot2 = 0.0; |
789 |
< |
} |
731 |
> |
cg2 = neighborList_[m2]; |
732 |
|
|
733 |
< |
in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, |
734 |
< |
rgrp); |
735 |
< |
|
736 |
< |
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
737 |
< |
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
738 |
< |
|
739 |
< |
if (doHeatFlux_) |
740 |
< |
gvel2 = fDecomp_->getGroupVelocityColumn(cg2); |
741 |
< |
|
742 |
< |
for (ia = atomListRow.begin(); |
743 |
< |
ia != atomListRow.end(); ++ia) { |
744 |
< |
atom1 = (*ia); |
745 |
< |
|
746 |
< |
for (jb = atomListColumn.begin(); |
747 |
< |
jb != atomListColumn.end(); ++jb) { |
748 |
< |
atom2 = (*jb); |
749 |
< |
|
750 |
< |
if (!fDecomp_->skipAtomPair(atom1, atom2, cg1, cg2)) { |
751 |
< |
|
752 |
< |
vpair = 0.0; |
753 |
< |
workPot = 0.0; |
754 |
< |
exPot = 0.0; |
755 |
< |
f1.zero(); |
756 |
< |
dVdFQ1 = 0.0; |
757 |
< |
dVdFQ2 = 0.0; |
758 |
< |
|
759 |
< |
fDecomp_->fillInteractionData(idat, atom1, atom2); |
760 |
< |
|
761 |
< |
topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); |
762 |
< |
vdwMult = vdwScale_[topoDist]; |
763 |
< |
electroMult = electrostaticScale_[topoDist]; |
764 |
< |
|
765 |
< |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
766 |
< |
idat.d = &d_grp; |
767 |
< |
idat.r2 = &rgrpsq; |
768 |
< |
if (doHeatFlux_) |
769 |
< |
vel2 = gvel2; |
770 |
< |
} else { |
771 |
< |
d = fDecomp_->getInteratomicVector(atom1, atom2); |
772 |
< |
curSnapshot->wrapVector( d ); |
773 |
< |
r2 = d.lengthSquare(); |
774 |
< |
idat.d = &d; |
775 |
< |
idat.r2 = &r2; |
776 |
< |
if (doHeatFlux_) |
777 |
< |
vel2 = fDecomp_->getAtomVelocityColumn(atom2); |
778 |
< |
} |
779 |
< |
|
780 |
< |
r = sqrt( *(idat.r2) ); |
781 |
< |
idat.rij = &r; |
782 |
< |
|
783 |
< |
if (iLoop == PREPAIR_LOOP) { |
784 |
< |
interactionMan_->doPrePair(idat); |
785 |
< |
} else { |
786 |
< |
interactionMan_->doPair(idat); |
787 |
< |
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
788 |
< |
vij += vpair; |
789 |
< |
fij += f1; |
790 |
< |
stressTensor -= outProduct( *(idat.d), f1); |
791 |
< |
if (doHeatFlux_) |
792 |
< |
fDecomp_->addToHeatFlux(*(idat.d) * dot(f1, vel2)); |
733 |
> |
d_grp = fDecomp_->getIntergroupVector(cg1, cg2); |
734 |
> |
|
735 |
> |
// already wrapped in the getIntergroupVector call: |
736 |
> |
// curSnapshot->wrapVector(d_grp); |
737 |
> |
rgrpsq = d_grp.lengthSquare(); |
738 |
> |
|
739 |
> |
if (rgrpsq < rCutSq_) { |
740 |
> |
if (iLoop == PAIR_LOOP) { |
741 |
> |
vij = 0.0; |
742 |
> |
fij.zero(); |
743 |
> |
eField1.zero(); |
744 |
> |
eField2.zero(); |
745 |
> |
sPot1 = 0.0; |
746 |
> |
sPot2 = 0.0; |
747 |
> |
} |
748 |
> |
|
749 |
> |
in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, |
750 |
> |
rgrp); |
751 |
> |
|
752 |
> |
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
753 |
> |
|
754 |
> |
if (doHeatFlux_) |
755 |
> |
gvel2 = fDecomp_->getGroupVelocityColumn(cg2); |
756 |
> |
|
757 |
> |
for (ia = atomListRow.begin(); |
758 |
> |
ia != atomListRow.end(); ++ia) { |
759 |
> |
atom1 = (*ia); |
760 |
> |
|
761 |
> |
for (jb = atomListColumn.begin(); |
762 |
> |
jb != atomListColumn.end(); ++jb) { |
763 |
> |
atom2 = (*jb); |
764 |
> |
|
765 |
> |
if (!fDecomp_->skipAtomPair(atom1, atom2, cg1, cg2)) { |
766 |
> |
|
767 |
> |
vpair = 0.0; |
768 |
> |
workPot = 0.0; |
769 |
> |
exPot = 0.0; |
770 |
> |
f1.zero(); |
771 |
> |
dVdFQ1 = 0.0; |
772 |
> |
dVdFQ2 = 0.0; |
773 |
> |
|
774 |
> |
fDecomp_->fillInteractionData(idat, atom1, atom2, newAtom1); |
775 |
> |
|
776 |
> |
topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); |
777 |
> |
vdwMult = vdwScale_[topoDist]; |
778 |
> |
electroMult = electrostaticScale_[topoDist]; |
779 |
> |
|
780 |
> |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
781 |
> |
idat.d = &d_grp; |
782 |
> |
idat.r2 = &rgrpsq; |
783 |
> |
if (doHeatFlux_) |
784 |
> |
vel2 = gvel2; |
785 |
> |
} else { |
786 |
> |
d = fDecomp_->getInteratomicVector(atom1, atom2); |
787 |
> |
curSnapshot->wrapVector( d ); |
788 |
> |
r2 = d.lengthSquare(); |
789 |
> |
idat.d = &d; |
790 |
> |
idat.r2 = &r2; |
791 |
> |
if (doHeatFlux_) |
792 |
> |
vel2 = fDecomp_->getAtomVelocityColumn(atom2); |
793 |
> |
} |
794 |
> |
|
795 |
> |
r = sqrt( *(idat.r2) ); |
796 |
> |
idat.rij = &r; |
797 |
> |
|
798 |
> |
if (iLoop == PREPAIR_LOOP) { |
799 |
> |
interactionMan_->doPrePair(idat); |
800 |
> |
} else { |
801 |
> |
interactionMan_->doPair(idat); |
802 |
> |
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
803 |
> |
vij += vpair; |
804 |
> |
fij += f1; |
805 |
> |
stressTensor -= outProduct( *(idat.d), f1); |
806 |
> |
if (doHeatFlux_) |
807 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(f1, vel2)); |
808 |
> |
} |
809 |
|
} |
810 |
|
} |
811 |
|
} |
812 |
< |
} |
813 |
< |
|
814 |
< |
if (iLoop == PAIR_LOOP) { |
815 |
< |
if (in_switching_region) { |
816 |
< |
swderiv = vij * dswdr / rgrp; |
817 |
< |
fg = swderiv * d_grp; |
818 |
< |
fij += fg; |
819 |
< |
|
820 |
< |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
821 |
< |
if (!fDecomp_->skipAtomPair(atomListRow[0], |
822 |
< |
atomListColumn[0], |
865 |
< |
cg1, cg2)) { |
812 |
> |
|
813 |
> |
if (iLoop == PAIR_LOOP) { |
814 |
> |
if (in_switching_region) { |
815 |
> |
swderiv = vij * dswdr / rgrp; |
816 |
> |
fg = swderiv * d_grp; |
817 |
> |
fij += fg; |
818 |
> |
|
819 |
> |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
820 |
> |
if (!fDecomp_->skipAtomPair(atomListRow[0], |
821 |
> |
atomListColumn[0], |
822 |
> |
cg1, cg2)) { |
823 |
|
stressTensor -= outProduct( *(idat.d), fg); |
824 |
|
if (doHeatFlux_) |
825 |
|
fDecomp_->addToHeatFlux(*(idat.d) * dot(fg, vel2)); |
826 |
< |
} |
827 |
< |
} |
828 |
< |
|
829 |
< |
for (ia = atomListRow.begin(); |
830 |
< |
ia != atomListRow.end(); ++ia) { |
831 |
< |
atom1 = (*ia); |
832 |
< |
mf = fDecomp_->getMassFactorRow(atom1); |
833 |
< |
// fg is the force on atom ia due to cutoff group's |
834 |
< |
// presence in switching region |
835 |
< |
fg = swderiv * d_grp * mf; |
836 |
< |
fDecomp_->addForceToAtomRow(atom1, fg); |
837 |
< |
if (atomListRow.size() > 1) { |
838 |
< |
if (info_->usesAtomicVirial()) { |
839 |
< |
// find the distance between the atom |
840 |
< |
// and the center of the cutoff group: |
841 |
< |
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
842 |
< |
stressTensor -= outProduct(dag, fg); |
843 |
< |
if (doHeatFlux_) |
844 |
< |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
826 |
> |
} |
827 |
> |
} |
828 |
> |
|
829 |
> |
for (ia = atomListRow.begin(); |
830 |
> |
ia != atomListRow.end(); ++ia) { |
831 |
> |
atom1 = (*ia); |
832 |
> |
mf = fDecomp_->getMassFactorRow(atom1); |
833 |
> |
// fg is the force on atom ia due to cutoff group's |
834 |
> |
// presence in switching region |
835 |
> |
fg = swderiv * d_grp * mf; |
836 |
> |
fDecomp_->addForceToAtomRow(atom1, fg); |
837 |
> |
if (atomListRow.size() > 1) { |
838 |
> |
if (info_->usesAtomicVirial()) { |
839 |
> |
// find the distance between the atom |
840 |
> |
// and the center of the cutoff group: |
841 |
> |
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
842 |
> |
stressTensor -= outProduct(dag, fg); |
843 |
> |
if (doHeatFlux_) |
844 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
845 |
> |
} |
846 |
|
} |
847 |
|
} |
848 |
< |
} |
849 |
< |
for (jb = atomListColumn.begin(); |
850 |
< |
jb != atomListColumn.end(); ++jb) { |
851 |
< |
atom2 = (*jb); |
852 |
< |
mf = fDecomp_->getMassFactorColumn(atom2); |
853 |
< |
// fg is the force on atom jb due to cutoff group's |
854 |
< |
// presence in switching region |
855 |
< |
fg = -swderiv * d_grp * mf; |
856 |
< |
fDecomp_->addForceToAtomColumn(atom2, fg); |
857 |
< |
|
858 |
< |
if (atomListColumn.size() > 1) { |
859 |
< |
if (info_->usesAtomicVirial()) { |
860 |
< |
// find the distance between the atom |
861 |
< |
// and the center of the cutoff group: |
862 |
< |
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
863 |
< |
stressTensor -= outProduct(dag, fg); |
864 |
< |
if (doHeatFlux_) |
865 |
< |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
848 |
> |
for (jb = atomListColumn.begin(); |
849 |
> |
jb != atomListColumn.end(); ++jb) { |
850 |
> |
atom2 = (*jb); |
851 |
> |
mf = fDecomp_->getMassFactorColumn(atom2); |
852 |
> |
// fg is the force on atom jb due to cutoff group's |
853 |
> |
// presence in switching region |
854 |
> |
fg = -swderiv * d_grp * mf; |
855 |
> |
fDecomp_->addForceToAtomColumn(atom2, fg); |
856 |
> |
|
857 |
> |
if (atomListColumn.size() > 1) { |
858 |
> |
if (info_->usesAtomicVirial()) { |
859 |
> |
// find the distance between the atom |
860 |
> |
// and the center of the cutoff group: |
861 |
> |
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
862 |
> |
stressTensor -= outProduct(dag, fg); |
863 |
> |
if (doHeatFlux_) |
864 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
865 |
> |
} |
866 |
|
} |
867 |
|
} |
868 |
|
} |
869 |
+ |
//if (!info_->usesAtomicVirial()) { |
870 |
+ |
// stressTensor -= outProduct(d_grp, fij); |
871 |
+ |
// if (doHeatFlux_) |
872 |
+ |
// fDecomp_->addToHeatFlux( d_grp * dot(fij, vel2)); |
873 |
+ |
//} |
874 |
|
} |
912 |
– |
//if (!info_->usesAtomicVirial()) { |
913 |
– |
// stressTensor -= outProduct(d_grp, fij); |
914 |
– |
// if (doHeatFlux_) |
915 |
– |
// fDecomp_->addToHeatFlux( d_grp * dot(fij, vel2)); |
916 |
– |
//} |
875 |
|
} |
876 |
|
} |
877 |
+ |
newAtom1 = false; |
878 |
|
} |
879 |
< |
|
879 |
> |
|
880 |
|
if (iLoop == PREPAIR_LOOP) { |
881 |
|
if (info_->requiresPrepair()) { |
882 |
< |
|
882 |
> |
|
883 |
|
fDecomp_->collectIntermediateData(); |
884 |
< |
|
884 |
> |
|
885 |
|
for (unsigned int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
886 |
|
fDecomp_->fillSelfData(sdat, atom1); |
887 |
|
interactionMan_->doPreForce(sdat); |
888 |
|
} |
889 |
< |
|
889 |
> |
|
890 |
|
fDecomp_->distributeIntermediateData(); |
891 |
< |
|
891 |
> |
|
892 |
|
} |
893 |
|
} |
894 |
|
} |
917 |
|
curSnapshot->setLongRangePotential(longRangePotential); |
918 |
|
|
919 |
|
curSnapshot->setExcludedPotentials(*(fDecomp_->getExcludedSelfPotential()) + |
920 |
< |
*(fDecomp_->getExcludedPotential())); |
920 |
> |
*(fDecomp_->getExcludedPotential())); |
921 |
|
|
922 |
|
} |
923 |
|
|
953 |
|
|
954 |
|
if (info_->getSimParams()->getUseLongRangeCorrections()) { |
955 |
|
/* |
956 |
< |
RealType vol = curSnapshot->getVolume(); |
957 |
< |
RealType Elrc(0.0); |
958 |
< |
RealType Wlrc(0.0); |
956 |
> |
RealType vol = curSnapshot->getVolume(); |
957 |
> |
RealType Elrc(0.0); |
958 |
> |
RealType Wlrc(0.0); |
959 |
|
|
960 |
< |
set<AtomType*>::iterator i; |
961 |
< |
set<AtomType*>::iterator j; |
960 |
> |
set<AtomType*>::iterator i; |
961 |
> |
set<AtomType*>::iterator j; |
962 |
|
|
963 |
< |
RealType n_i, n_j; |
964 |
< |
RealType rho_i, rho_j; |
965 |
< |
pair<RealType, RealType> LRI; |
963 |
> |
RealType n_i, n_j; |
964 |
> |
RealType rho_i, rho_j; |
965 |
> |
pair<RealType, RealType> LRI; |
966 |
|
|
967 |
< |
for (i = atomTypes_.begin(); i != atomTypes_.end(); ++i) { |
967 |
> |
for (i = atomTypes_.begin(); i != atomTypes_.end(); ++i) { |
968 |
|
n_i = RealType(info_->getGlobalCountOfType(*i)); |
969 |
|
rho_i = n_i / vol; |
970 |
|
for (j = atomTypes_.begin(); j != atomTypes_.end(); ++j) { |
971 |
< |
n_j = RealType(info_->getGlobalCountOfType(*j)); |
972 |
< |
rho_j = n_j / vol; |
971 |
> |
n_j = RealType(info_->getGlobalCountOfType(*j)); |
972 |
> |
rho_j = n_j / vol; |
973 |
|
|
974 |
< |
LRI = interactionMan_->getLongRangeIntegrals( (*i), (*j) ); |
974 |
> |
LRI = interactionMan_->getLongRangeIntegrals( (*i), (*j) ); |
975 |
|
|
976 |
< |
Elrc += n_i * rho_j * LRI.first; |
977 |
< |
Wlrc -= rho_i * rho_j * LRI.second; |
976 |
> |
Elrc += n_i * rho_j * LRI.first; |
977 |
> |
Wlrc -= rho_i * rho_j * LRI.second; |
978 |
|
} |
979 |
< |
} |
980 |
< |
Elrc *= 2.0 * NumericConstant::PI; |
981 |
< |
Wlrc *= 2.0 * NumericConstant::PI; |
979 |
> |
} |
980 |
> |
Elrc *= 2.0 * NumericConstant::PI; |
981 |
> |
Wlrc *= 2.0 * NumericConstant::PI; |
982 |
|
|
983 |
< |
RealType lrp = curSnapshot->getLongRangePotential(); |
984 |
< |
curSnapshot->setLongRangePotential(lrp + Elrc); |
985 |
< |
stressTensor += Wlrc * SquareMatrix3<RealType>::identity(); |
986 |
< |
curSnapshot->setStressTensor(stressTensor); |
983 |
> |
RealType lrp = curSnapshot->getLongRangePotential(); |
984 |
> |
curSnapshot->setLongRangePotential(lrp + Elrc); |
985 |
> |
stressTensor += Wlrc * SquareMatrix3<RealType>::identity(); |
986 |
> |
curSnapshot->setStressTensor(stressTensor); |
987 |
|
*/ |
988 |
|
|
989 |
|
} |