| 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 |
|
#include "parallel/ForceMatrixDecomposition.hpp" |
| 43 |
|
#include "math/SquareMatrix3.hpp" |
| 95 |
|
storageLayout_ = sman_->getStorageLayout(); |
| 96 |
|
ff_ = info_->getForceField(); |
| 97 |
|
nLocal_ = snap_->getNumberOfAtoms(); |
| 98 |
< |
|
| 98 |
> |
|
| 99 |
|
nGroups_ = info_->getNLocalCutoffGroups(); |
| 100 |
|
// gather the information for atomtype IDs (atids): |
| 101 |
|
idents = info_->getIdentArray(); |
| 109 |
|
PairList* oneTwo = info_->getOneTwoInteractions(); |
| 110 |
|
PairList* oneThree = info_->getOneThreeInteractions(); |
| 111 |
|
PairList* oneFour = info_->getOneFourInteractions(); |
| 112 |
< |
|
| 112 |
> |
|
| 113 |
> |
if (needVelocities_) |
| 114 |
> |
snap_->cgData.setStorageLayout(DataStorage::dslPosition | |
| 115 |
> |
DataStorage::dslVelocity); |
| 116 |
> |
else |
| 117 |
> |
snap_->cgData.setStorageLayout(DataStorage::dslPosition); |
| 118 |
> |
|
| 119 |
|
#ifdef IS_MPI |
| 120 |
|
|
| 121 |
|
MPI::Intracomm row = rowComm.getComm(); |
| 151 |
|
cgRowData.resize(nGroupsInRow_); |
| 152 |
|
cgRowData.setStorageLayout(DataStorage::dslPosition); |
| 153 |
|
cgColData.resize(nGroupsInCol_); |
| 154 |
< |
cgColData.setStorageLayout(DataStorage::dslPosition); |
| 155 |
< |
|
| 154 |
> |
if (needVelocities_) |
| 155 |
> |
// we only need column velocities if we need them. |
| 156 |
> |
cgColData.setStorageLayout(DataStorage::dslPosition | |
| 157 |
> |
DataStorage::dslVelocity); |
| 158 |
> |
else |
| 159 |
> |
cgColData.setStorageLayout(DataStorage::dslPosition); |
| 160 |
> |
|
| 161 |
|
identsRow.resize(nAtomsInRow_); |
| 162 |
|
identsCol.resize(nAtomsInCol_); |
| 163 |
|
|
| 245 |
|
} |
| 246 |
|
} |
| 247 |
|
|
| 248 |
< |
#endif |
| 237 |
< |
|
| 238 |
< |
// allocate memory for the parallel objects |
| 239 |
< |
atypesLocal.resize(nLocal_); |
| 240 |
< |
|
| 241 |
< |
for (int i = 0; i < nLocal_; i++) |
| 242 |
< |
atypesLocal[i] = ff_->getAtomType(idents[i]); |
| 243 |
< |
|
| 244 |
< |
groupList_.clear(); |
| 245 |
< |
groupList_.resize(nGroups_); |
| 246 |
< |
for (int i = 0; i < nGroups_; i++) { |
| 247 |
< |
int gid = cgLocalToGlobal[i]; |
| 248 |
< |
for (int j = 0; j < nLocal_; j++) { |
| 249 |
< |
int aid = AtomLocalToGlobal[j]; |
| 250 |
< |
if (globalGroupMembership[aid] == gid) { |
| 251 |
< |
groupList_[i].push_back(j); |
| 252 |
< |
} |
| 253 |
< |
} |
| 254 |
< |
} |
| 255 |
< |
|
| 248 |
> |
#else |
| 249 |
|
excludesForAtom.clear(); |
| 250 |
|
excludesForAtom.resize(nLocal_); |
| 251 |
|
toposForAtom.clear(); |
| 278 |
|
} |
| 279 |
|
} |
| 280 |
|
} |
| 281 |
< |
|
| 281 |
> |
#endif |
| 282 |
> |
|
| 283 |
> |
// allocate memory for the parallel objects |
| 284 |
> |
atypesLocal.resize(nLocal_); |
| 285 |
> |
|
| 286 |
> |
for (int i = 0; i < nLocal_; i++) |
| 287 |
> |
atypesLocal[i] = ff_->getAtomType(idents[i]); |
| 288 |
> |
|
| 289 |
> |
groupList_.clear(); |
| 290 |
> |
groupList_.resize(nGroups_); |
| 291 |
> |
for (int i = 0; i < nGroups_; i++) { |
| 292 |
> |
int gid = cgLocalToGlobal[i]; |
| 293 |
> |
for (int j = 0; j < nLocal_; j++) { |
| 294 |
> |
int aid = AtomLocalToGlobal[j]; |
| 295 |
> |
if (globalGroupMembership[aid] == gid) { |
| 296 |
> |
groupList_[i].push_back(j); |
| 297 |
> |
} |
| 298 |
> |
} |
| 299 |
> |
} |
| 300 |
> |
|
| 301 |
> |
|
| 302 |
|
createGtypeCutoffMap(); |
| 303 |
|
|
| 304 |
|
} |
| 536 |
|
atomColData.skippedCharge.end(), 0.0); |
| 537 |
|
} |
| 538 |
|
|
| 539 |
+ |
if (storageLayout_ & DataStorage::dslFlucQForce) { |
| 540 |
+ |
fill(atomRowData.flucQFrc.begin(), |
| 541 |
+ |
atomRowData.flucQFrc.end(), 0.0); |
| 542 |
+ |
fill(atomColData.flucQFrc.begin(), |
| 543 |
+ |
atomColData.flucQFrc.end(), 0.0); |
| 544 |
+ |
} |
| 545 |
+ |
|
| 546 |
+ |
if (storageLayout_ & DataStorage::dslElectricField) { |
| 547 |
+ |
fill(atomRowData.electricField.begin(), |
| 548 |
+ |
atomRowData.electricField.end(), V3Zero); |
| 549 |
+ |
fill(atomColData.electricField.begin(), |
| 550 |
+ |
atomColData.electricField.end(), V3Zero); |
| 551 |
+ |
} |
| 552 |
+ |
|
| 553 |
+ |
if (storageLayout_ & DataStorage::dslFlucQForce) { |
| 554 |
+ |
fill(atomRowData.flucQFrc.begin(), atomRowData.flucQFrc.end(), |
| 555 |
+ |
0.0); |
| 556 |
+ |
fill(atomColData.flucQFrc.begin(), atomColData.flucQFrc.end(), |
| 557 |
+ |
0.0); |
| 558 |
+ |
} |
| 559 |
+ |
|
| 560 |
|
#endif |
| 561 |
|
// even in parallel, we need to zero out the local arrays: |
| 562 |
|
|
| 569 |
|
fill(snap_->atomData.density.begin(), |
| 570 |
|
snap_->atomData.density.end(), 0.0); |
| 571 |
|
} |
| 572 |
+ |
|
| 573 |
|
if (storageLayout_ & DataStorage::dslFunctional) { |
| 574 |
|
fill(snap_->atomData.functional.begin(), |
| 575 |
|
snap_->atomData.functional.end(), 0.0); |
| 576 |
|
} |
| 577 |
+ |
|
| 578 |
|
if (storageLayout_ & DataStorage::dslFunctionalDerivative) { |
| 579 |
|
fill(snap_->atomData.functionalDerivative.begin(), |
| 580 |
|
snap_->atomData.functionalDerivative.end(), 0.0); |
| 581 |
|
} |
| 582 |
+ |
|
| 583 |
|
if (storageLayout_ & DataStorage::dslSkippedCharge) { |
| 584 |
|
fill(snap_->atomData.skippedCharge.begin(), |
| 585 |
|
snap_->atomData.skippedCharge.end(), 0.0); |
| 586 |
|
} |
| 587 |
< |
|
| 587 |
> |
|
| 588 |
> |
if (storageLayout_ & DataStorage::dslElectricField) { |
| 589 |
> |
fill(snap_->atomData.electricField.begin(), |
| 590 |
> |
snap_->atomData.electricField.end(), V3Zero); |
| 591 |
> |
} |
| 592 |
|
} |
| 593 |
|
|
| 594 |
|
|
| 611 |
|
cgPlanVectorColumn->gather(snap_->cgData.position, |
| 612 |
|
cgColData.position); |
| 613 |
|
|
| 614 |
+ |
|
| 615 |
+ |
|
| 616 |
+ |
if (needVelocities_) { |
| 617 |
+ |
// gather up the atomic velocities |
| 618 |
+ |
AtomPlanVectorColumn->gather(snap_->atomData.velocity, |
| 619 |
+ |
atomColData.velocity); |
| 620 |
+ |
|
| 621 |
+ |
cgPlanVectorColumn->gather(snap_->cgData.velocity, |
| 622 |
+ |
cgColData.velocity); |
| 623 |
+ |
} |
| 624 |
+ |
|
| 625 |
|
|
| 626 |
|
// if needed, gather the atomic rotation matrices |
| 627 |
|
if (storageLayout_ & DataStorage::dslAmat) { |
| 639 |
|
atomColData.electroFrame); |
| 640 |
|
} |
| 641 |
|
|
| 642 |
+ |
// if needed, gather the atomic fluctuating charge values |
| 643 |
+ |
if (storageLayout_ & DataStorage::dslFlucQPosition) { |
| 644 |
+ |
AtomPlanRealRow->gather(snap_->atomData.flucQPos, |
| 645 |
+ |
atomRowData.flucQPos); |
| 646 |
+ |
AtomPlanRealColumn->gather(snap_->atomData.flucQPos, |
| 647 |
+ |
atomColData.flucQPos); |
| 648 |
+ |
} |
| 649 |
+ |
|
| 650 |
|
#endif |
| 651 |
|
} |
| 652 |
|
|
| 669 |
|
for (int i = 0; i < n; i++) |
| 670 |
|
snap_->atomData.density[i] += rho_tmp[i]; |
| 671 |
|
} |
| 672 |
+ |
|
| 673 |
+ |
if (storageLayout_ & DataStorage::dslElectricField) { |
| 674 |
+ |
|
| 675 |
+ |
AtomPlanVectorRow->scatter(atomRowData.electricField, |
| 676 |
+ |
snap_->atomData.electricField); |
| 677 |
+ |
|
| 678 |
+ |
int n = snap_->atomData.electricField.size(); |
| 679 |
+ |
vector<Vector3d> field_tmp(n, V3Zero); |
| 680 |
+ |
AtomPlanVectorColumn->scatter(atomColData.electricField, field_tmp); |
| 681 |
+ |
for (int i = 0; i < n; i++) |
| 682 |
+ |
snap_->atomData.electricField[i] += field_tmp[i]; |
| 683 |
+ |
} |
| 684 |
|
#endif |
| 685 |
|
} |
| 686 |
|
|
| 755 |
|
} |
| 756 |
|
|
| 757 |
|
AtomPlanRealColumn->scatter(atomColData.skippedCharge, skch_tmp); |
| 758 |
< |
for (int i = 0; i < ns; i++) |
| 758 |
> |
for (int i = 0; i < ns; i++) |
| 759 |
|
snap_->atomData.skippedCharge[i] += skch_tmp[i]; |
| 760 |
+ |
|
| 761 |
|
} |
| 762 |
|
|
| 763 |
+ |
if (storageLayout_ & DataStorage::dslFlucQForce) { |
| 764 |
+ |
|
| 765 |
+ |
int nq = snap_->atomData.flucQFrc.size(); |
| 766 |
+ |
vector<RealType> fqfrc_tmp(nq, 0.0); |
| 767 |
+ |
|
| 768 |
+ |
AtomPlanRealRow->scatter(atomRowData.flucQFrc, fqfrc_tmp); |
| 769 |
+ |
for (int i = 0; i < nq; i++) { |
| 770 |
+ |
snap_->atomData.flucQFrc[i] += fqfrc_tmp[i]; |
| 771 |
+ |
fqfrc_tmp[i] = 0.0; |
| 772 |
+ |
} |
| 773 |
+ |
|
| 774 |
+ |
AtomPlanRealColumn->scatter(atomColData.flucQFrc, fqfrc_tmp); |
| 775 |
+ |
for (int i = 0; i < nq; i++) |
| 776 |
+ |
snap_->atomData.flucQFrc[i] += fqfrc_tmp[i]; |
| 777 |
+ |
|
| 778 |
+ |
} |
| 779 |
+ |
|
| 780 |
|
nLocal_ = snap_->getNumberOfAtoms(); |
| 781 |
|
|
| 782 |
|
vector<potVec> pot_temp(nLocal_, |
| 788 |
|
|
| 789 |
|
for (int ii = 0; ii < pot_temp.size(); ii++ ) |
| 790 |
|
pairwisePot += pot_temp[ii]; |
| 791 |
< |
|
| 791 |
> |
|
| 792 |
> |
if (storageLayout_ & DataStorage::dslParticlePot) { |
| 793 |
> |
// This is the pairwise contribution to the particle pot. The |
| 794 |
> |
// embedding contribution is added in each of the low level |
| 795 |
> |
// non-bonded routines. In single processor, this is done in |
| 796 |
> |
// unpackInteractionData, not in collectData. |
| 797 |
> |
for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { |
| 798 |
> |
for (int i = 0; i < nLocal_; i++) { |
| 799 |
> |
// factor of two is because the total potential terms are divided |
| 800 |
> |
// by 2 in parallel due to row/ column scatter |
| 801 |
> |
snap_->atomData.particlePot[i] += 2.0 * pot_temp[i](ii); |
| 802 |
> |
} |
| 803 |
> |
} |
| 804 |
> |
} |
| 805 |
> |
|
| 806 |
|
fill(pot_temp.begin(), pot_temp.end(), |
| 807 |
|
Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); |
| 808 |
|
|
| 810 |
|
|
| 811 |
|
for (int ii = 0; ii < pot_temp.size(); ii++ ) |
| 812 |
|
pairwisePot += pot_temp[ii]; |
| 813 |
+ |
|
| 814 |
+ |
if (storageLayout_ & DataStorage::dslParticlePot) { |
| 815 |
+ |
// This is the pairwise contribution to the particle pot. The |
| 816 |
+ |
// embedding contribution is added in each of the low level |
| 817 |
+ |
// non-bonded routines. In single processor, this is done in |
| 818 |
+ |
// unpackInteractionData, not in collectData. |
| 819 |
+ |
for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { |
| 820 |
+ |
for (int i = 0; i < nLocal_; i++) { |
| 821 |
+ |
// factor of two is because the total potential terms are divided |
| 822 |
+ |
// by 2 in parallel due to row/ column scatter |
| 823 |
+ |
snap_->atomData.particlePot[i] += 2.0 * pot_temp[i](ii); |
| 824 |
+ |
} |
| 825 |
+ |
} |
| 826 |
+ |
} |
| 827 |
|
|
| 828 |
+ |
if (storageLayout_ & DataStorage::dslParticlePot) { |
| 829 |
+ |
int npp = snap_->atomData.particlePot.size(); |
| 830 |
+ |
vector<RealType> ppot_temp(npp, 0.0); |
| 831 |
+ |
|
| 832 |
+ |
// This is the direct or embedding contribution to the particle |
| 833 |
+ |
// pot. |
| 834 |
+ |
|
| 835 |
+ |
AtomPlanRealRow->scatter(atomRowData.particlePot, ppot_temp); |
| 836 |
+ |
for (int i = 0; i < npp; i++) { |
| 837 |
+ |
snap_->atomData.particlePot[i] += ppot_temp[i]; |
| 838 |
+ |
} |
| 839 |
+ |
|
| 840 |
+ |
fill(ppot_temp.begin(), ppot_temp.end(), 0.0); |
| 841 |
+ |
|
| 842 |
+ |
AtomPlanRealColumn->scatter(atomColData.particlePot, ppot_temp); |
| 843 |
+ |
for (int i = 0; i < npp; i++) { |
| 844 |
+ |
snap_->atomData.particlePot[i] += ppot_temp[i]; |
| 845 |
+ |
} |
| 846 |
+ |
} |
| 847 |
+ |
|
| 848 |
|
for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { |
| 849 |
|
RealType ploc1 = pairwisePot[ii]; |
| 850 |
|
RealType ploc2 = 0.0; |
| 852 |
|
pairwisePot[ii] = ploc2; |
| 853 |
|
} |
| 854 |
|
|
| 855 |
+ |
for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { |
| 856 |
+ |
RealType ploc1 = embeddingPot[ii]; |
| 857 |
+ |
RealType ploc2 = 0.0; |
| 858 |
+ |
MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM); |
| 859 |
+ |
embeddingPot[ii] = ploc2; |
| 860 |
+ |
} |
| 861 |
+ |
|
| 862 |
+ |
// Here be dragons. |
| 863 |
+ |
MPI::Intracomm col = colComm.getComm(); |
| 864 |
+ |
|
| 865 |
+ |
col.Allreduce(MPI::IN_PLACE, |
| 866 |
+ |
&snap_->frameData.conductiveHeatFlux[0], 3, |
| 867 |
+ |
MPI::REALTYPE, MPI::SUM); |
| 868 |
+ |
|
| 869 |
+ |
|
| 870 |
|
#endif |
| 871 |
|
|
| 872 |
|
} |
| 909 |
|
|
| 910 |
|
snap_->wrapVector(d); |
| 911 |
|
return d; |
| 912 |
+ |
} |
| 913 |
+ |
|
| 914 |
+ |
Vector3d ForceMatrixDecomposition::getGroupVelocityColumn(int cg2){ |
| 915 |
+ |
#ifdef IS_MPI |
| 916 |
+ |
return cgColData.velocity[cg2]; |
| 917 |
+ |
#else |
| 918 |
+ |
return snap_->cgData.velocity[cg2]; |
| 919 |
+ |
#endif |
| 920 |
|
} |
| 921 |
|
|
| 922 |
+ |
Vector3d ForceMatrixDecomposition::getAtomVelocityColumn(int atom2){ |
| 923 |
+ |
#ifdef IS_MPI |
| 924 |
+ |
return atomColData.velocity[atom2]; |
| 925 |
+ |
#else |
| 926 |
+ |
return snap_->atomData.velocity[atom2]; |
| 927 |
+ |
#endif |
| 928 |
+ |
} |
| 929 |
|
|
| 930 |
+ |
|
| 931 |
|
Vector3d ForceMatrixDecomposition::getAtomToGroupVectorRow(int atom1, int cg1){ |
| 932 |
|
|
| 933 |
|
Vector3d d; |
| 995 |
|
*/ |
| 996 |
|
bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2) { |
| 997 |
|
int unique_id_1, unique_id_2; |
| 998 |
< |
|
| 998 |
> |
|
| 999 |
|
#ifdef IS_MPI |
| 1000 |
|
// in MPI, we have to look up the unique IDs for each atom |
| 1001 |
|
unique_id_1 = AtomRowToGlobal[atom1]; |
| 1002 |
|
unique_id_2 = AtomColToGlobal[atom2]; |
| 1003 |
+ |
#else |
| 1004 |
+ |
unique_id_1 = AtomLocalToGlobal[atom1]; |
| 1005 |
+ |
unique_id_2 = AtomLocalToGlobal[atom2]; |
| 1006 |
+ |
#endif |
| 1007 |
|
|
| 835 |
– |
// this situation should only arise in MPI simulations |
| 1008 |
|
if (unique_id_1 == unique_id_2) return true; |
| 1009 |
< |
|
| 1009 |
> |
|
| 1010 |
> |
#ifdef IS_MPI |
| 1011 |
|
// this prevents us from doing the pair on multiple processors |
| 1012 |
|
if (unique_id_1 < unique_id_2) { |
| 1013 |
|
if ((unique_id_1 + unique_id_2) % 2 == 0) return true; |
| 1014 |
|
} else { |
| 1015 |
< |
if ((unique_id_1 + unique_id_2) % 2 == 1) return true; |
| 1015 |
> |
if ((unique_id_1 + unique_id_2) % 2 == 1) return true; |
| 1016 |
|
} |
| 1017 |
|
#endif |
| 1018 |
+ |
|
| 1019 |
|
return false; |
| 1020 |
|
} |
| 1021 |
|
|
| 1029 |
|
* field) must still be handled for these pairs. |
| 1030 |
|
*/ |
| 1031 |
|
bool ForceMatrixDecomposition::excludeAtomPair(int atom1, int atom2) { |
| 1032 |
< |
int unique_id_2; |
| 1033 |
< |
#ifdef IS_MPI |
| 1034 |
< |
// in MPI, we have to look up the unique IDs for the row atom. |
| 861 |
< |
unique_id_2 = AtomColToGlobal[atom2]; |
| 862 |
< |
#else |
| 863 |
< |
// in the normal loop, the atom numbers are unique |
| 864 |
< |
unique_id_2 = atom2; |
| 865 |
< |
#endif |
| 1032 |
> |
|
| 1033 |
> |
// excludesForAtom was constructed to use row/column indices in the MPI |
| 1034 |
> |
// version, and to use local IDs in the non-MPI version: |
| 1035 |
|
|
| 1036 |
|
for (vector<int>::iterator i = excludesForAtom[atom1].begin(); |
| 1037 |
|
i != excludesForAtom[atom1].end(); ++i) { |
| 1038 |
< |
if ( (*i) == unique_id_2 ) return true; |
| 1038 |
> |
if ( (*i) == atom2 ) return true; |
| 1039 |
|
} |
| 1040 |
|
|
| 1041 |
|
return false; |
| 1109 |
|
idat.skippedCharge2 = &(atomColData.skippedCharge[atom2]); |
| 1110 |
|
} |
| 1111 |
|
|
| 1112 |
< |
#else |
| 1112 |
> |
if (storageLayout_ & DataStorage::dslFlucQPosition) { |
| 1113 |
> |
idat.flucQ1 = &(atomRowData.flucQPos[atom1]); |
| 1114 |
> |
idat.flucQ2 = &(atomColData.flucQPos[atom2]); |
| 1115 |
> |
} |
| 1116 |
|
|
| 1117 |
+ |
#else |
| 1118 |
+ |
|
| 1119 |
|
idat.atypes = make_pair( atypesLocal[atom1], atypesLocal[atom2]); |
| 946 |
– |
//idat.atypes = make_pair( ff_->getAtomType(idents[atom1]), |
| 947 |
– |
// ff_->getAtomType(idents[atom2]) ); |
| 1120 |
|
|
| 1121 |
|
if (storageLayout_ & DataStorage::dslAmat) { |
| 1122 |
|
idat.A1 = &(snap_->atomData.aMat[atom1]); |
| 1157 |
|
idat.skippedCharge1 = &(snap_->atomData.skippedCharge[atom1]); |
| 1158 |
|
idat.skippedCharge2 = &(snap_->atomData.skippedCharge[atom2]); |
| 1159 |
|
} |
| 1160 |
+ |
|
| 1161 |
+ |
if (storageLayout_ & DataStorage::dslFlucQPosition) { |
| 1162 |
+ |
idat.flucQ1 = &(snap_->atomData.flucQPos[atom1]); |
| 1163 |
+ |
idat.flucQ2 = &(snap_->atomData.flucQPos[atom2]); |
| 1164 |
+ |
} |
| 1165 |
+ |
|
| 1166 |
|
#endif |
| 1167 |
|
} |
| 1168 |
|
|
| 1169 |
|
|
| 1170 |
|
void ForceMatrixDecomposition::unpackInteractionData(InteractionData &idat, int atom1, int atom2) { |
| 1171 |
|
#ifdef IS_MPI |
| 1172 |
< |
pot_row[atom1] += 0.5 * *(idat.pot); |
| 1173 |
< |
pot_col[atom2] += 0.5 * *(idat.pot); |
| 1172 |
> |
pot_row[atom1] += RealType(0.5) * *(idat.pot); |
| 1173 |
> |
pot_col[atom2] += RealType(0.5) * *(idat.pot); |
| 1174 |
|
|
| 1175 |
|
atomRowData.force[atom1] += *(idat.f1); |
| 1176 |
|
atomColData.force[atom2] -= *(idat.f1); |
| 1177 |
+ |
|
| 1178 |
+ |
if (storageLayout_ & DataStorage::dslFlucQForce) { |
| 1179 |
+ |
atomRowData.flucQFrc[atom1] -= *(idat.dVdFQ1); |
| 1180 |
+ |
atomColData.flucQFrc[atom2] -= *(idat.dVdFQ2); |
| 1181 |
+ |
} |
| 1182 |
+ |
|
| 1183 |
+ |
if (storageLayout_ & DataStorage::dslElectricField) { |
| 1184 |
+ |
atomRowData.electricField[atom1] += *(idat.eField1); |
| 1185 |
+ |
atomColData.electricField[atom2] += *(idat.eField2); |
| 1186 |
+ |
} |
| 1187 |
+ |
|
| 1188 |
|
#else |
| 1189 |
|
pairwisePot += *(idat.pot); |
| 1190 |
|
|
| 1191 |
|
snap_->atomData.force[atom1] += *(idat.f1); |
| 1192 |
|
snap_->atomData.force[atom2] -= *(idat.f1); |
| 1193 |
+ |
|
| 1194 |
+ |
if (idat.doParticlePot) { |
| 1195 |
+ |
// This is the pairwise contribution to the particle pot. The |
| 1196 |
+ |
// embedding contribution is added in each of the low level |
| 1197 |
+ |
// non-bonded routines. In parallel, this calculation is done |
| 1198 |
+ |
// in collectData, not in unpackInteractionData. |
| 1199 |
+ |
snap_->atomData.particlePot[atom1] += *(idat.vpair) * *(idat.sw); |
| 1200 |
+ |
snap_->atomData.particlePot[atom2] += *(idat.vpair) * *(idat.sw); |
| 1201 |
+ |
} |
| 1202 |
+ |
|
| 1203 |
+ |
if (storageLayout_ & DataStorage::dslFlucQForce) { |
| 1204 |
+ |
snap_->atomData.flucQFrc[atom1] -= *(idat.dVdFQ1); |
| 1205 |
+ |
snap_->atomData.flucQFrc[atom2] -= *(idat.dVdFQ2); |
| 1206 |
+ |
} |
| 1207 |
+ |
|
| 1208 |
+ |
if (storageLayout_ & DataStorage::dslElectricField) { |
| 1209 |
+ |
snap_->atomData.electricField[atom1] += *(idat.eField1); |
| 1210 |
+ |
snap_->atomData.electricField[atom2] += *(idat.eField2); |
| 1211 |
+ |
} |
| 1212 |
+ |
|
| 1213 |
|
#endif |
| 1214 |
|
|
| 1215 |
|
} |
| 1394 |
|
} |
| 1395 |
|
} |
| 1396 |
|
#else |
| 1188 |
– |
|
| 1397 |
|
for (vector<int>::iterator j1 = cellList_[m1].begin(); |
| 1398 |
|
j1 != cellList_[m1].end(); ++j1) { |
| 1399 |
|
for (vector<int>::iterator j2 = cellList_[m2].begin(); |
| 1400 |
|
j2 != cellList_[m2].end(); ++j2) { |
| 1401 |
< |
|
| 1401 |
> |
|
| 1402 |
|
// Always do this if we're in different cells or if |
| 1403 |
< |
// we're in the same cell and the global index of the |
| 1404 |
< |
// j2 cutoff group is less than the j1 cutoff group |
| 1405 |
< |
|
| 1406 |
< |
if (m2 != m1 || (*j2) < (*j1)) { |
| 1403 |
> |
// we're in the same cell and the global index of |
| 1404 |
> |
// the j2 cutoff group is greater than or equal to |
| 1405 |
> |
// the j1 cutoff group. Note that Rappaport's code |
| 1406 |
> |
// has a "less than" conditional here, but that |
| 1407 |
> |
// deals with atom-by-atom computation. OpenMD |
| 1408 |
> |
// allows atoms within a single cutoff group to |
| 1409 |
> |
// interact with each other. |
| 1410 |
> |
|
| 1411 |
> |
|
| 1412 |
> |
|
| 1413 |
> |
if (m2 != m1 || (*j2) >= (*j1) ) { |
| 1414 |
> |
|
| 1415 |
|
dr = snap_->cgData.position[(*j2)] - snap_->cgData.position[(*j1)]; |
| 1416 |
|
snap_->wrapVector(dr); |
| 1417 |
|
cuts = getGroupCutoffs( (*j1), (*j2) ); |
| 1430 |
|
// branch to do all cutoff group pairs |
| 1431 |
|
#ifdef IS_MPI |
| 1432 |
|
for (int j1 = 0; j1 < nGroupsInRow_; j1++) { |
| 1433 |
< |
for (int j2 = 0; j2 < nGroupsInCol_; j2++) { |
| 1433 |
> |
for (int j2 = 0; j2 < nGroupsInCol_; j2++) { |
| 1434 |
|
dr = cgColData.position[j2] - cgRowData.position[j1]; |
| 1435 |
|
snap_->wrapVector(dr); |
| 1436 |
|
cuts = getGroupCutoffs( j1, j2 ); |
| 1438 |
|
neighborList.push_back(make_pair(j1, j2)); |
| 1439 |
|
} |
| 1440 |
|
} |
| 1441 |
< |
} |
| 1441 |
> |
} |
| 1442 |
|
#else |
| 1443 |
< |
for (int j1 = 0; j1 < nGroups_ - 1; j1++) { |
| 1444 |
< |
for (int j2 = j1 + 1; j2 < nGroups_; j2++) { |
| 1443 |
> |
// include all groups here. |
| 1444 |
> |
for (int j1 = 0; j1 < nGroups_; j1++) { |
| 1445 |
> |
// include self group interactions j2 == j1 |
| 1446 |
> |
for (int j2 = j1; j2 < nGroups_; j2++) { |
| 1447 |
|
dr = snap_->cgData.position[j2] - snap_->cgData.position[j1]; |
| 1448 |
|
snap_->wrapVector(dr); |
| 1449 |
|
cuts = getGroupCutoffs( j1, j2 ); |
| 1450 |
|
if (dr.lengthSquare() < cuts.third) { |
| 1451 |
|
neighborList.push_back(make_pair(j1, j2)); |
| 1452 |
|
} |
| 1453 |
< |
} |
| 1454 |
< |
} |
| 1453 |
> |
} |
| 1454 |
> |
} |
| 1455 |
|
#endif |
| 1456 |
|
} |
| 1457 |
|
|