| 110 |
|
Globals* simParams_ = info_->getSimParams(); |
| 111 |
|
ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); |
| 112 |
|
int mdFileVersion; |
| 113 |
+ |
rCut_ = 0.0; //Needs a value for a later max() call; |
| 114 |
|
|
| 115 |
|
if (simParams_->haveMDfileVersion()) |
| 116 |
|
mdFileVersion = simParams_->getMDfileVersion(); |
| 391 |
|
info_->prepareTopology(); |
| 392 |
|
|
| 393 |
|
doParticlePot_ = info_->getSimParams()->getOutputParticlePotential(); |
| 394 |
+ |
doHeatFlux_ = info_->getSimParams()->getPrintHeatFlux(); |
| 395 |
+ |
if (doHeatFlux_) doParticlePot_ = true; |
| 396 |
|
|
| 397 |
|
} |
| 398 |
|
|
| 474 |
|
} |
| 475 |
|
|
| 476 |
|
// Zero out the stress tensor |
| 477 |
< |
tau *= 0.0; |
| 478 |
< |
|
| 477 |
> |
stressTensor *= 0.0; |
| 478 |
> |
// Zero out the heatFlux |
| 479 |
> |
fDecomp_->setHeatFlux( Vector3d(0.0) ); |
| 480 |
|
} |
| 481 |
|
|
| 482 |
|
void ForceManager::shortRangeInteractions() { |
| 599 |
|
|
| 600 |
|
void ForceManager::longRangeInteractions() { |
| 601 |
|
|
| 602 |
+ |
|
| 603 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 604 |
|
DataStorage* config = &(curSnapshot->atomData); |
| 605 |
|
DataStorage* cgConfig = &(curSnapshot->cgData); |
| 623 |
|
// center of mass of the group is the same as position of the atom |
| 624 |
|
// if cutoff group does not exist |
| 625 |
|
cgConfig->position = config->position; |
| 626 |
+ |
cgConfig->velocity = config->velocity; |
| 627 |
|
} |
| 628 |
|
|
| 629 |
|
fDecomp_->zeroWorkArrays(); |
| 630 |
|
fDecomp_->distributeData(); |
| 631 |
|
|
| 632 |
|
int cg1, cg2, atom1, atom2, topoDist; |
| 633 |
< |
Vector3d d_grp, dag, d; |
| 633 |
> |
Vector3d d_grp, dag, d, gvel2, vel2; |
| 634 |
|
RealType rgrpsq, rgrp, r2, r; |
| 635 |
|
RealType electroMult, vdwMult; |
| 636 |
|
RealType vij; |
| 645 |
|
RealType mf; |
| 646 |
|
RealType lrPot; |
| 647 |
|
RealType vpair; |
| 648 |
+ |
RealType dVdFQ1(0.0); |
| 649 |
+ |
RealType dVdFQ2(0.0); |
| 650 |
|
potVec longRangePotential(0.0); |
| 651 |
|
potVec workPot(0.0); |
| 652 |
|
vector<int>::iterator ia, jb; |
| 658 |
|
idat.pot = &workPot; |
| 659 |
|
sdat.pot = fDecomp_->getEmbeddingPotential(); |
| 660 |
|
idat.vpair = &vpair; |
| 661 |
+ |
idat.dVdFQ1 = &dVdFQ1; |
| 662 |
+ |
idat.dVdFQ2 = &dVdFQ2; |
| 663 |
|
idat.f1 = &f1; |
| 664 |
|
idat.sw = &sw; |
| 665 |
|
idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false; |
| 673 |
|
} else { |
| 674 |
|
loopStart = PAIR_LOOP; |
| 675 |
|
} |
| 666 |
– |
|
| 676 |
|
for (int iLoop = loopStart; iLoop <= loopEnd; iLoop++) { |
| 677 |
|
|
| 678 |
|
if (iLoop == loopStart) { |
| 704 |
|
|
| 705 |
|
in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, |
| 706 |
|
rgrp); |
| 707 |
< |
|
| 707 |
> |
|
| 708 |
|
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
| 709 |
|
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
| 710 |
|
|
| 711 |
+ |
if (doHeatFlux_) |
| 712 |
+ |
gvel2 = fDecomp_->getGroupVelocityColumn(cg2); |
| 713 |
+ |
|
| 714 |
|
for (ia = atomListRow.begin(); |
| 715 |
|
ia != atomListRow.end(); ++ia) { |
| 716 |
|
atom1 = (*ia); |
| 717 |
< |
|
| 717 |
> |
|
| 718 |
|
for (jb = atomListColumn.begin(); |
| 719 |
|
jb != atomListColumn.end(); ++jb) { |
| 720 |
|
atom2 = (*jb); |
| 721 |
|
|
| 722 |
< |
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
| 722 |
> |
if (!fDecomp_->skipAtomPair(atom1, atom2, cg1, cg2)) { |
| 723 |
> |
|
| 724 |
|
vpair = 0.0; |
| 725 |
|
workPot = 0.0; |
| 726 |
|
f1 = V3Zero; |
| 727 |
+ |
dVdFQ1 = 0.0; |
| 728 |
+ |
dVdFQ2 = 0.0; |
| 729 |
|
|
| 730 |
|
fDecomp_->fillInteractionData(idat, atom1, atom2); |
| 731 |
< |
|
| 731 |
> |
|
| 732 |
|
topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); |
| 733 |
|
vdwMult = vdwScale_[topoDist]; |
| 734 |
|
electroMult = electrostaticScale_[topoDist]; |
| 736 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 737 |
|
idat.d = &d_grp; |
| 738 |
|
idat.r2 = &rgrpsq; |
| 739 |
+ |
if (doHeatFlux_) |
| 740 |
+ |
vel2 = gvel2; |
| 741 |
|
} else { |
| 742 |
|
d = fDecomp_->getInteratomicVector(atom1, atom2); |
| 743 |
|
curSnapshot->wrapVector( d ); |
| 744 |
|
r2 = d.lengthSquare(); |
| 745 |
|
idat.d = &d; |
| 746 |
|
idat.r2 = &r2; |
| 747 |
+ |
if (doHeatFlux_) |
| 748 |
+ |
vel2 = fDecomp_->getAtomVelocityColumn(atom2); |
| 749 |
|
} |
| 750 |
|
|
| 751 |
|
r = sqrt( *(idat.r2) ); |
| 758 |
|
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
| 759 |
|
vij += vpair; |
| 760 |
|
fij += f1; |
| 761 |
< |
tau -= outProduct( *(idat.d), f1); |
| 761 |
> |
stressTensor -= outProduct( *(idat.d), f1); |
| 762 |
> |
if (doHeatFlux_) |
| 763 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(f1, vel2)); |
| 764 |
|
} |
| 765 |
|
} |
| 766 |
|
} |
| 773 |
|
fij += fg; |
| 774 |
|
|
| 775 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 776 |
< |
tau -= outProduct( *(idat.d), fg); |
| 776 |
> |
stressTensor -= outProduct( *(idat.d), fg); |
| 777 |
> |
if (doHeatFlux_) |
| 778 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(fg, vel2)); |
| 779 |
> |
|
| 780 |
|
} |
| 781 |
|
|
| 782 |
|
for (ia = atomListRow.begin(); |
| 792 |
|
// find the distance between the atom |
| 793 |
|
// and the center of the cutoff group: |
| 794 |
|
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
| 795 |
< |
tau -= outProduct(dag, fg); |
| 795 |
> |
stressTensor -= outProduct(dag, fg); |
| 796 |
> |
if (doHeatFlux_) |
| 797 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
| 798 |
|
} |
| 799 |
|
} |
| 800 |
|
} |
| 812 |
|
// find the distance between the atom |
| 813 |
|
// and the center of the cutoff group: |
| 814 |
|
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
| 815 |
< |
tau -= outProduct(dag, fg); |
| 815 |
> |
stressTensor -= outProduct(dag, fg); |
| 816 |
> |
if (doHeatFlux_) |
| 817 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
| 818 |
|
} |
| 819 |
|
} |
| 820 |
|
} |
| 821 |
|
} |
| 822 |
|
//if (!info_->usesAtomicVirial()) { |
| 823 |
< |
// tau -= outProduct(d_grp, fij); |
| 823 |
> |
// stressTensor -= outProduct(d_grp, fij); |
| 824 |
> |
// if (doHeatFlux_) |
| 825 |
> |
// fDecomp_->addToHeatFlux( d_grp * dot(fij, vel2)); |
| 826 |
|
//} |
| 827 |
|
} |
| 828 |
|
} |
| 844 |
|
} |
| 845 |
|
} |
| 846 |
|
|
| 847 |
+ |
// collects pairwise information |
| 848 |
|
fDecomp_->collectData(); |
| 849 |
|
|
| 850 |
|
if (info_->requiresSelfCorrection()) { |
| 851 |
< |
|
| 821 |
< |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 851 |
> |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 852 |
|
fDecomp_->fillSelfData(sdat, atom1); |
| 853 |
|
interactionMan_->doSelfCorrection(sdat); |
| 854 |
|
} |
| 825 |
– |
|
| 855 |
|
} |
| 856 |
|
|
| 857 |
+ |
// collects single-atom information |
| 858 |
+ |
fDecomp_->collectSelfData(); |
| 859 |
+ |
|
| 860 |
|
longRangePotential = *(fDecomp_->getEmbeddingPotential()) + |
| 861 |
|
*(fDecomp_->getPairwisePotential()); |
| 862 |
|
|
| 863 |
|
lrPot = longRangePotential.sum(); |
| 864 |
|
|
| 865 |
< |
//store the tau and long range potential |
| 865 |
> |
//store the stressTensor and long range potential |
| 866 |
|
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; |
| 867 |
|
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY]; |
| 868 |
|
curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_FAMILY]; |
| 883 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
| 884 |
|
rb = mol->nextRigidBody(rbIter)) { |
| 885 |
|
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
| 886 |
< |
tau += rbTau; |
| 886 |
> |
stressTensor += rbTau; |
| 887 |
|
} |
| 888 |
|
} |
| 889 |
|
|
| 890 |
|
#ifdef IS_MPI |
| 891 |
< |
Mat3x3d tmpTau(tau); |
| 892 |
< |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
| 861 |
< |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
| 891 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, stressTensor.getArrayPointer(), 9, |
| 892 |
> |
MPI::REALTYPE, MPI::SUM); |
| 893 |
|
#endif |
| 894 |
< |
curSnapshot->setTau(tau); |
| 894 |
> |
curSnapshot->setStressTensor(stressTensor); |
| 895 |
> |
|
| 896 |
|
} |
| 897 |
|
|
| 898 |
|
} //end namespace OpenMD |