diff --git a/doc/src/pair_yukawa_colloid.txt b/doc/src/pair_yukawa_colloid.txt index 3d5294bbdb524b668b4040e6d42e854ebc740ccd..ecdc1496ab734dcc8f59009de35a8990a6f09905 100644 --- a/doc/src/pair_yukawa_colloid.txt +++ b/doc/src/pair_yukawa_colloid.txt @@ -35,7 +35,7 @@ cutoff. In contrast to "pair_style yukawa"_pair_yukawa.html, this functional form arises from the Coulombic interaction between two colloid particles, screened due to the presence of an electrolyte, see the -book by "Safran"_#Safran for a derivation in the context of DVLO +book by "Safran"_#Safran for a derivation in the context of DLVO theory. "Pair_style yukawa"_pair_yukawa.html is a screened Coulombic potential between two point-charges and uses no such approximation. diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 7e8db7632ccdc7f48448734b3170ec4cb9784fdd..c5b566eef785699559280eabe7bd0a681bef31a0 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -286,9 +286,6 @@ void FixQEq::setup_pre_force(int vflag) if (force->newton_pair == 0) error->all(FLERR,"QEQ with 'newton pair off' not supported"); - // should not be needed - // neighbor->build_one(list); - deallocate_storage(); allocate_storage(); diff --git a/src/USER-DPD/nbin_ssa.cpp b/src/USER-DPD/nbin_ssa.cpp index 73da5e0df3570945cb7a098500243da54f69fca6..f65a397e88d02e29fc81016733073dd8b0940db3 100644 --- a/src/USER-DPD/nbin_ssa.cpp +++ b/src/USER-DPD/nbin_ssa.cpp @@ -76,6 +76,7 @@ void NBinSSA::bin_atoms() if (ssaAIR[i] < 2) continue; // skip ghost atoms not in AIR if (mask[i] & bitmask) { ibin = coord2bin(x[i]); + atom2bin[i] = ibin; bins_ssa[i] = gbinhead_ssa[ibin]; gbinhead_ssa[ibin] = i; } @@ -84,12 +85,14 @@ void NBinSSA::bin_atoms() for (i = nall-1; i >= nlocal; i--) { if (ssaAIR[i] < 2) continue; // skip ghost atoms not in AIR ibin = coord2bin(x[i]); + atom2bin[i] = ibin; bins_ssa[i] = gbinhead_ssa[ibin]; gbinhead_ssa[ibin] = i; } } for (i = nlocal-1; i >= 0; i--) { ibin = coord2bin(x[i]); + atom2bin[i] = ibin; bins_ssa[i] = binhead_ssa[ibin]; binhead_ssa[ibin] = i; } diff --git a/src/USER-DPD/npair_half_bin_newton_ssa.cpp b/src/USER-DPD/npair_half_bin_newton_ssa.cpp index 59acbda301403c5e36e513b03a2df7e4608e90c2..e8e4b20a0ab64a5063de016f1cbeb1644c04e522 100644 --- a/src/USER-DPD/npair_half_bin_newton_ssa.cpp +++ b/src/USER-DPD/npair_half_bin_newton_ssa.cpp @@ -141,7 +141,7 @@ void NPairHalfBinNewtonSSA::build(NeighList *list) } } - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; // loop over all local atoms in other bins in "half" stencil diff --git a/src/USER-OMP/npair_full_bin_ghost_omp.cpp b/src/USER-OMP/npair_full_bin_ghost_omp.cpp index 7f7239fe63c9adbc76214e44f5c8f67d251d1b73..b915aca002a68ee7893aa18269a8128349b97a89 100644 --- a/src/USER-OMP/npair_full_bin_ghost_omp.cpp +++ b/src/USER-OMP/npair_full_bin_ghost_omp.cpp @@ -97,7 +97,7 @@ void NPairFullBinGhostOmp::build(NeighList *list) // no molecular test when i = ghost atom if (i < nlocal) { - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (i == j) continue; diff --git a/src/USER-OMP/npair_full_bin_omp.cpp b/src/USER-OMP/npair_full_bin_omp.cpp index ad9e48784ed2a8cbf1d7198676d3fd9c45750e34..e1f75c06e2a8f36d245cfa7b6589b2628eb6a159 100644 --- a/src/USER-OMP/npair_full_bin_omp.cpp +++ b/src/USER-OMP/npair_full_bin_omp.cpp @@ -90,7 +90,7 @@ void NPairFullBinOmp::build(NeighList *list) // loop over all atoms in surrounding bins in stencil including self // skip i = j - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { diff --git a/src/USER-OMP/npair_full_multi_omp.cpp b/src/USER-OMP/npair_full_multi_omp.cpp index eb0153d63f7e7577df1530e48c61dde05f18a280..9bc196e17a1a39cda046bd1fe6b7327c64dd345c 100644 --- a/src/USER-OMP/npair_full_multi_omp.cpp +++ b/src/USER-OMP/npair_full_multi_omp.cpp @@ -94,7 +94,7 @@ void NPairFullMultiOmp::build(NeighList *list) // skip if i,j neighbor cutoff is less than bin distance // skip i = j - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; s = stencil_multi[itype]; distsq = distsq_multi[itype]; cutsq = cutneighsq[itype]; diff --git a/src/USER-OMP/npair_half_bin_newtoff_ghost_omp.cpp b/src/USER-OMP/npair_half_bin_newtoff_ghost_omp.cpp index e46afebb0d8f6fe285bfc104a44933e8b639b53c..05763c3d689bd37f947c7556d5ef3d53ba69945a 100644 --- a/src/USER-OMP/npair_half_bin_newtoff_ghost_omp.cpp +++ b/src/USER-OMP/npair_half_bin_newtoff_ghost_omp.cpp @@ -103,7 +103,7 @@ void NPairHalfBinNewtoffGhostOmp::build(NeighList *list) // no molecular test when i = ghost atom if (i < nlocal) { - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { diff --git a/src/USER-OMP/npair_half_bin_newtoff_omp.cpp b/src/USER-OMP/npair_half_bin_newtoff_omp.cpp index 99698b1d30c7380b511cb973e2a4dff2d1f1eee8..ff74b54d7d68dd258fc6be84b9b3e4c35852ad53 100644 --- a/src/USER-OMP/npair_half_bin_newtoff_omp.cpp +++ b/src/USER-OMP/npair_half_bin_newtoff_omp.cpp @@ -94,7 +94,7 @@ void NPairHalfBinNewtoffOmp::build(NeighList *list) // stores own/own pairs only once // stores own/ghost pairs on both procs - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { diff --git a/src/USER-OMP/npair_half_bin_newton_omp.cpp b/src/USER-OMP/npair_half_bin_newton_omp.cpp index 33d78fe55a61bbc96960fba41aa363ff19688dde..f7d969ba271a110edf8b83a631a48394ddb0ea63 100644 --- a/src/USER-OMP/npair_half_bin_newton_omp.cpp +++ b/src/USER-OMP/npair_half_bin_newton_omp.cpp @@ -130,7 +130,7 @@ void NPairHalfBinNewtonOmp::build(NeighList *list) // loop over all atoms in other bins in stencil, store every pair - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { jtype = type[j]; diff --git a/src/USER-OMP/npair_half_bin_newton_tri_omp.cpp b/src/USER-OMP/npair_half_bin_newton_tri_omp.cpp index 9eb96122351ec234a026c03d5d79403862662791..c843d623cd44960b8f8ebaaf68142f8896e10acb 100644 --- a/src/USER-OMP/npair_half_bin_newton_tri_omp.cpp +++ b/src/USER-OMP/npair_half_bin_newton_tri_omp.cpp @@ -94,7 +94,7 @@ void NPairHalfBinNewtonTriOmp::build(NeighList *list) // (equal zyx and j <= i) // latter excludes self-self interaction but allows superposed atoms - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (x[j][2] < ztmp) continue; diff --git a/src/USER-OMP/npair_half_multi_newtoff_omp.cpp b/src/USER-OMP/npair_half_multi_newtoff_omp.cpp index 37dc8058573947777affac3003dde019ea5f5f92..705d1b8d9ff1ec53e44c240f6a9ab02b647f2f25 100644 --- a/src/USER-OMP/npair_half_multi_newtoff_omp.cpp +++ b/src/USER-OMP/npair_half_multi_newtoff_omp.cpp @@ -97,7 +97,7 @@ void NPairHalfMultiNewtoffOmp::build(NeighList *list) // stores own/own pairs only once // stores own/ghost pairs on both procs - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; s = stencil_multi[itype]; distsq = distsq_multi[itype]; cutsq = cutneighsq[itype]; diff --git a/src/USER-OMP/npair_half_multi_newton_omp.cpp b/src/USER-OMP/npair_half_multi_newton_omp.cpp index 9719911afa6b575056b3159cef517408b0ed5953..f16dd027a0c26552494726af0b8e53730beffeb9 100644 --- a/src/USER-OMP/npair_half_multi_newton_omp.cpp +++ b/src/USER-OMP/npair_half_multi_newton_omp.cpp @@ -131,7 +131,7 @@ void NPairHalfMultiNewtonOmp::build(NeighList *list) // loop over all atoms in other bins in stencil, store every pair // skip if i,j neighbor cutoff is less than bin distance - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; s = stencil_multi[itype]; distsq = distsq_multi[itype]; cutsq = cutneighsq[itype]; diff --git a/src/USER-OMP/npair_half_multi_newton_tri_omp.cpp b/src/USER-OMP/npair_half_multi_newton_tri_omp.cpp index 717a709386e800b2fbb653975f4137ffdcd735e7..f66cf194e75342add192bcbd984930f0f301efb7 100644 --- a/src/USER-OMP/npair_half_multi_newton_tri_omp.cpp +++ b/src/USER-OMP/npair_half_multi_newton_tri_omp.cpp @@ -99,7 +99,7 @@ void NPairHalfMultiNewtonTriOmp::build(NeighList *list) // (equal zyx and j <= i) // latter excludes self-self interaction but allows superposed atoms - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; s = stencil_multi[itype]; distsq = distsq_multi[itype]; cutsq = cutneighsq[itype]; diff --git a/src/USER-OMP/npair_half_respa_bin_newtoff_omp.cpp b/src/USER-OMP/npair_half_respa_bin_newtoff_omp.cpp index 287f11efa71107572a07cace735c0efe0d582f5d..12780fa4a371171810a4d548da341087fd5574a7 100644 --- a/src/USER-OMP/npair_half_respa_bin_newtoff_omp.cpp +++ b/src/USER-OMP/npair_half_respa_bin_newtoff_omp.cpp @@ -117,7 +117,7 @@ void NPairHalfRespaBinNewtoffOmp::build(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; if (moltemplate) { imol = molindex[i]; iatom = molatom[i]; diff --git a/src/USER-OMP/npair_half_respa_bin_newton_omp.cpp b/src/USER-OMP/npair_half_respa_bin_newton_omp.cpp index 30256bd20da24336006c689604c27a2315029d34..b9a636424262a52df2f61149e0e26b8f3dcb7298 100644 --- a/src/USER-OMP/npair_half_respa_bin_newton_omp.cpp +++ b/src/USER-OMP/npair_half_respa_bin_newton_omp.cpp @@ -176,7 +176,7 @@ void NPairHalfRespaBinNewtonOmp::build(NeighList *list) // loop over all atoms in other bins in stencil, store every pair - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { jtype = type[j]; diff --git a/src/USER-OMP/npair_half_respa_bin_newton_tri_omp.cpp b/src/USER-OMP/npair_half_respa_bin_newton_tri_omp.cpp index 27d02000c5b242ab2f84e3590c55c4ae7cc06115..bc03972d859a4101f1cbcb33ec8a8de7491ea541 100644 --- a/src/USER-OMP/npair_half_respa_bin_newton_tri_omp.cpp +++ b/src/USER-OMP/npair_half_respa_bin_newton_tri_omp.cpp @@ -128,7 +128,7 @@ void NPairHalfRespaBinNewtonTriOmp::build(NeighList *list) // (equal zyx and j <= i) // latter excludes self-self interaction but allows superposed atoms - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (x[j][2] < ztmp) continue; diff --git a/src/USER-OMP/npair_half_size_bin_newtoff_omp.cpp b/src/USER-OMP/npair_half_size_bin_newtoff_omp.cpp index 699d347db5cbae91b1fa45c4bbde6b33e08d7d73..dbb62e96efc9a2f3d800fe0585fd845cd473401b 100644 --- a/src/USER-OMP/npair_half_size_bin_newtoff_omp.cpp +++ b/src/USER-OMP/npair_half_size_bin_newtoff_omp.cpp @@ -113,7 +113,7 @@ void NPairHalfSizeBinNewtoffOmp::build(NeighList *list) ytmp = x[i][1]; ztmp = x[i][2]; radi = radius[i]; - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; // loop over all atoms in surrounding bins in stencil including self // only store pair if i < j diff --git a/src/USER-OMP/npair_half_size_bin_newton_omp.cpp b/src/USER-OMP/npair_half_size_bin_newton_omp.cpp index 0d7e4e68da6ed863eca0f4a41005de8399b478e8..2c26c7952cda571d4133281246bb781891f9b7f4 100644 --- a/src/USER-OMP/npair_half_size_bin_newton_omp.cpp +++ b/src/USER-OMP/npair_half_size_bin_newton_omp.cpp @@ -168,7 +168,7 @@ void NPairHalfSizeBinNewtonOmp::build(NeighList *list) // loop over all atoms in other bins in stencil, store every pair - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (exclude && exclusion(i,j,type[i],type[j],mask,molecule)) continue; diff --git a/src/USER-OMP/npair_half_size_bin_newton_tri_omp.cpp b/src/USER-OMP/npair_half_size_bin_newton_tri_omp.cpp index 7463a6aba6085753b9ba23b30b60cc9c12bbf5fa..bf273f545f425b7b7bd6d660daf8f2c484c74222 100644 --- a/src/USER-OMP/npair_half_size_bin_newton_tri_omp.cpp +++ b/src/USER-OMP/npair_half_size_bin_newton_tri_omp.cpp @@ -84,7 +84,7 @@ void NPairHalfSizeBinNewtonTriOmp::build(NeighList *list) // (equal zyx and j <= i) // latter excludes self-self interaction but allows superposed atoms - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (x[j][2] < ztmp) continue; diff --git a/src/USER-REAXC/fix_qeq_reax.cpp b/src/USER-REAXC/fix_qeq_reax.cpp index 01ecd9d3994fce173ac4dbf9ca6b619314c62b3a..96df03c668a260ce63b87221bd63bac42b88a12c 100644 --- a/src/USER-REAXC/fix_qeq_reax.cpp +++ b/src/USER-REAXC/fix_qeq_reax.cpp @@ -416,9 +416,6 @@ void FixQEqReax::init_taper() void FixQEqReax::setup_pre_force(int vflag) { - // should not be needed - // neighbor->build_one(list); - deallocate_storage(); allocate_storage(); diff --git a/src/USER-REAXC/fix_reaxc_species.cpp b/src/USER-REAXC/fix_reaxc_species.cpp index 672b1e6a568c799218dcbfa705e2bf0d859b3f98..fe74337128088654e3b4e9aa0e265d63504b4c90 100644 --- a/src/USER-REAXC/fix_reaxc_species.cpp +++ b/src/USER-REAXC/fix_reaxc_species.cpp @@ -500,7 +500,7 @@ void FixReaxCSpecies::Output_ReaxC_Bonds(bigint ntimestep, FILE *fp) AtomCoord FixReaxCSpecies::chAnchor(AtomCoord in1, AtomCoord in2) { - if (in1.x < in2.x) + if (in1.x <= in2.x) return in1; return in2; } diff --git a/src/nbin.cpp b/src/nbin.cpp index 6aa37a4c43c6a5382cb398d3a80e18d1b090699d..6bd1ce322f6f93d93a80c50058d598f8abccfcc9 100644 --- a/src/nbin.cpp +++ b/src/nbin.cpp @@ -29,6 +29,7 @@ NBin::NBin(LAMMPS *lmp) : Pointers(lmp) maxbin = maxatom = 0; binhead = NULL; bins = NULL; + atom2bin = NULL; // geometry settings @@ -42,6 +43,7 @@ NBin::~NBin() { memory->destroy(binhead); memory->destroy(bins); + memory->destroy(atom2bin); } /* ---------------------------------------------------------------------- */ @@ -87,12 +89,15 @@ void NBin::bin_atoms_setup(int nall) memory->create(binhead,maxbin,"neigh:binhead"); } - // bins = per-atom vector + // bins and atom2bin = per-atom vectors + // for both local and ghost atoms if (nall > maxatom) { maxatom = nall; memory->destroy(bins); memory->create(bins,maxatom,"neigh:bins"); + memory->destroy(atom2bin); + memory->create(atom2bin,maxatom,"neigh:atom2bin"); } } @@ -148,6 +153,6 @@ bigint NBin::memory_usage() { bigint bytes = 0; bytes += maxbin*sizeof(int); - bytes += maxatom*sizeof(int); + bytes += 2*maxatom*sizeof(int); return bytes; } diff --git a/src/nbin.h b/src/nbin.h index 9871a229d8542aef87caa8718e64ee758f7ff560..30c74ff29558e0d8dca424b52ece331211d126fb 100644 --- a/src/nbin.h +++ b/src/nbin.h @@ -31,10 +31,11 @@ class NBin : protected Pointers { double binsizex,binsizey,binsizez; // bin sizes and inverse sizes double bininvx,bininvy,bininvz; - int *binhead; // index of first atom in each bin - int *bins; // index of next atom in same bin + int *binhead; // index of first atom in each bin + int *bins; // index of next atom in same bin + int *atom2bin; // bin assignment for each atom (local+ghost) - double cutoff_custom; // cutoff set by requestor + double cutoff_custom; // cutoff set by requestor NBin(class LAMMPS *); ~NBin(); diff --git a/src/nbin_standard.cpp b/src/nbin_standard.cpp index 2a72d996a51128082e27f1ac280d84a6853f2321..e6941014f9f60e441bc99831656465f2bb2d7a0e 100644 --- a/src/nbin_standard.cpp +++ b/src/nbin_standard.cpp @@ -211,12 +211,14 @@ void NBinStandard::bin_atoms() for (i = nall-1; i >= nlocal; i--) { if (mask[i] & bitmask) { ibin = coord2bin(x[i]); + atom2bin[i] = ibin; bins[i] = binhead[ibin]; binhead[ibin] = i; } } for (i = atom->nfirst-1; i >= 0; i--) { ibin = coord2bin(x[i]); + atom2bin[i] = ibin; bins[i] = binhead[ibin]; binhead[ibin] = i; } @@ -224,6 +226,7 @@ void NBinStandard::bin_atoms() } else { for (i = nall-1; i >= 0; i--) { ibin = coord2bin(x[i]); + atom2bin[i] = ibin; bins[i] = binhead[ibin]; binhead[ibin] = i; } diff --git a/src/neigh_request.cpp b/src/neigh_request.cpp index 5e77c230773ab13b1b2ecc5c03055e3781dc795e..bb691d00baa8072d97f3d3bbcdbd92ec682864cc 100644 --- a/src/neigh_request.cpp +++ b/src/neigh_request.cpp @@ -50,6 +50,7 @@ NeighRequest::NeighRequest(LAMMPS *lmp) : Pointers(lmp) // default is no Intel-specific neighbor list build // default is no Kokkos neighbor list build // default is no Shardlow Splitting Algorithm (SSA) neighbor list build + // default is no list-specific cutoff // default is no storage of auxiliary floating point values occasional = 0; diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 545c8cf027c7a09d42feab261f9271db2cb7e246..62a9143226333455a55d1c61928a53d44d03dd8a 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -640,6 +640,24 @@ int Neighbor::init_pair() delete [] neigh_stencil; delete [] neigh_pair; + // error check on requests + // do not allow occasional, ghost, bin list + // b/c it still uses variant of coord2bin() in NPair() method + // instead of atom2bin, this could cause error b/c stoms have + // moved out of proc domain by time occasional list is built + // solution would be to use a different NBin variant + // that used Npair::coord2bin(x,ix,iy,iz) (then delete it from NPair) + // and stored the ix,iy,iz values for all atoms (including ghosts) + // at time of binning when neighbor lists are rebuilt, + // similar to what vanilla Nbin::coord2atom() does now in atom2bin + + if (style == BIN) { + for (i = 0; i < nrequest; i++) + if (requests[i]->occasional && requests[i]->ghost) + error->all(FLERR,"Cannot request an occasional binned neighbor list " + "with ghost info"); + } + // morph requests in various ways // purpose is to avoid duplicate or inefficient builds // may add new requests if a needed request to derive from does not exist @@ -1669,7 +1687,6 @@ int Neighbor::choose_stencil(NeighRequest *rq) else if (rq->newton == 1) newtflag = 1; else if (rq->newton == 2) newtflag = 0; - //printf("STENCIL RQ FLAGS: hff %d %d n %d g %d s %d newtflag %d\n", // rq->half,rq->full,rq->newton,rq->ghost,rq->ssa, // newtflag); @@ -2087,7 +2104,7 @@ void Neighbor::build(int topoflag) } // bin atoms for all NBin instances - // not just NBin associated with perpetual lists + // not just NBin associated with perpetual lists, also occasional lists // b/c cannot wait to bin occasional lists in build_one() call // if bin then, atoms may have moved outside of proc domain & bin extent, // leading to errors or even a crash @@ -2193,6 +2210,7 @@ void Neighbor::build_one(class NeighList *mylist, int preflag) // build the list + if (!mylist->copy) mylist->grow(atom->nlocal,atom->nlocal+atom->nghost); np->build_setup(); np->build(mylist); } diff --git a/src/npair.cpp b/src/npair.cpp index 6c3f8ac05e3545ca61b6087c64fa0dbb9a86b1ee..3451cd6eae4dcbdc5fcd442eeadad919f287d550 100644 --- a/src/npair.cpp +++ b/src/npair.cpp @@ -128,6 +128,7 @@ void NPair::copy_bin_info() bininvy = nb->bininvy; bininvz = nb->bininvz; + atom2bin = nb->atom2bin; bins = nb->bins; binhead = nb->binhead; } @@ -198,53 +199,8 @@ int NPair::exclusion(int i, int j, int itype, int jtype, } /* ---------------------------------------------------------------------- - convert atom coords into local bin # - for orthogonal, only ghost atoms will have coord >= bboxhi or coord < bboxlo - take special care to insure ghosts are in correct bins even w/ roundoff - hi ghost atoms = nbin,nbin+1,etc - owned atoms = 0 to nbin-1 - lo ghost atoms = -1,-2,etc - this is necessary so that both procs on either side of PBC - treat a pair of atoms straddling the PBC in a consistent way - for triclinic, doesn't matter since stencil & neigh list built differently -------------------------------------------------------------------------- */ - -int NPair::coord2bin(double *x) -{ - int ix,iy,iz; - - if (!ISFINITE(x[0]) || !ISFINITE(x[1]) || !ISFINITE(x[2])) - error->one(FLERR,"Non-numeric positions - simulation unstable"); - - if (x[0] >= bboxhi[0]) - ix = static_cast<int> ((x[0]-bboxhi[0])*bininvx) + nbinx; - else if (x[0] >= bboxlo[0]) { - ix = static_cast<int> ((x[0]-bboxlo[0])*bininvx); - ix = MIN(ix,nbinx-1); - } else - ix = static_cast<int> ((x[0]-bboxlo[0])*bininvx) - 1; - - if (x[1] >= bboxhi[1]) - iy = static_cast<int> ((x[1]-bboxhi[1])*bininvy) + nbiny; - else if (x[1] >= bboxlo[1]) { - iy = static_cast<int> ((x[1]-bboxlo[1])*bininvy); - iy = MIN(iy,nbiny-1); - } else - iy = static_cast<int> ((x[1]-bboxlo[1])*bininvy) - 1; - - if (x[2] >= bboxhi[2]) - iz = static_cast<int> ((x[2]-bboxhi[2])*bininvz) + nbinz; - else if (x[2] >= bboxlo[2]) { - iz = static_cast<int> ((x[2]-bboxlo[2])*bininvz); - iz = MIN(iz,nbinz-1); - } else - iz = static_cast<int> ((x[2]-bboxlo[2])*bininvz) - 1; - - return (iz-mbinzlo)*mbiny*mbinx + (iy-mbinylo)*mbinx + (ix-mbinxlo); -} - -/* ---------------------------------------------------------------------- - same as coord2bin, but also return ix,iy,iz offsets in each dim + same as coord2bin in Nbin, but also return ix,iy,iz offsets in each dim + used by some of the ghost neighbor lists ------------------------------------------------------------------------- */ int NPair::coord2bin(double *x, int &ix, int &iy, int &iz) diff --git a/src/npair.h b/src/npair.h index 8f2bcb13bc8d26f7fbb15f317b4bee7ec78e648f..4e5e3f5dfd38619db6a76c3f84e230019dfb9d12 100644 --- a/src/npair.h +++ b/src/npair.h @@ -77,7 +77,7 @@ class NPair : protected Pointers { int mbinx,mbiny,mbinz; int mbinxlo,mbinylo,mbinzlo; double bininvx,bininvy,bininvz; - int *bins; + int *atom2bin,*bins; int *binhead; // data from NStencil class diff --git a/src/npair_full_bin.cpp b/src/npair_full_bin.cpp index a29acb67abeb1382860744b8c759e11aa113cc6f..94a6af129cbed7b448d0bab554f6fd433a9483bc 100644 --- a/src/npair_full_bin.cpp +++ b/src/npair_full_bin.cpp @@ -80,7 +80,7 @@ void NPairFullBin::build(NeighList *list) // loop over all atoms in surrounding bins in stencil including self // skip i = j - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { diff --git a/src/npair_full_bin_atomonly.cpp b/src/npair_full_bin_atomonly.cpp index 8d4fc254b525410171dd0ab05660832fdbdad747..db84733f1c584201d8d15c6e0bb01cd0bb8111ee 100644 --- a/src/npair_full_bin_atomonly.cpp +++ b/src/npair_full_bin_atomonly.cpp @@ -64,7 +64,7 @@ void NPairFullBinAtomonly::build(NeighList *list) // loop over all atoms in surrounding bins in stencil including self // skip i = j - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { diff --git a/src/npair_full_bin_ghost.cpp b/src/npair_full_bin_ghost.cpp index 1e258cf5181a49c5c4588d10197fb725377527b1..2edd03cc9e5a48fa91c985613213d1e5f05f8674 100644 --- a/src/npair_full_bin_ghost.cpp +++ b/src/npair_full_bin_ghost.cpp @@ -87,7 +87,7 @@ void NPairFullBinGhost::build(NeighList *list) // no molecular test when i = ghost atom if (i < nlocal) { - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (i == j) continue; diff --git a/src/npair_full_multi.cpp b/src/npair_full_multi.cpp index 628a706e7aa16a3fbd890044248fd5b4bfe426b2..9a2490ac5d18acb07375675da9b4b1e795053abd 100644 --- a/src/npair_full_multi.cpp +++ b/src/npair_full_multi.cpp @@ -83,7 +83,7 @@ void NPairFullMulti::build(NeighList *list) // skip if i,j neighbor cutoff is less than bin distance // skip i = j - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; s = stencil_multi[itype]; distsq = distsq_multi[itype]; cutsq = cutneighsq[itype]; diff --git a/src/npair_half_bin_atomonly_newton.cpp b/src/npair_half_bin_atomonly_newton.cpp index bc425cd22ee5459d2464bf105744e9293dd819b2..6bbef0700a36e681d444217d447c2fc421133952 100644 --- a/src/npair_half_bin_atomonly_newton.cpp +++ b/src/npair_half_bin_atomonly_newton.cpp @@ -90,7 +90,8 @@ void NPairHalfBinAtomonlyNewton::build(NeighList *list) // loop over all atoms in other bins in stencil, store every pair - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; + for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { jtype = type[j]; diff --git a/src/npair_half_bin_newtoff.cpp b/src/npair_half_bin_newtoff.cpp index dd072508a9483b93c66833e78afe545f4b8d898b..4c44741ffed9a19ab258223b7f2d2ea6c5b652b3 100644 --- a/src/npair_half_bin_newtoff.cpp +++ b/src/npair_half_bin_newtoff.cpp @@ -84,7 +84,7 @@ void NPairHalfBinNewtoff::build(NeighList *list) // stores own/own pairs only once // stores own/ghost pairs on both procs - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { diff --git a/src/npair_half_bin_newtoff_ghost.cpp b/src/npair_half_bin_newtoff_ghost.cpp index f486df105a7a12fdf55ef9686c58369ba668751c..72ec15e66a733424d918250f8e52553f5f257be1 100644 --- a/src/npair_half_bin_newtoff_ghost.cpp +++ b/src/npair_half_bin_newtoff_ghost.cpp @@ -92,7 +92,7 @@ void NPairHalfBinNewtoffGhost::build(NeighList *list) // no molecular test when i = ghost atom if (i < nlocal) { - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { diff --git a/src/npair_half_bin_newton.cpp b/src/npair_half_bin_newton.cpp index f1fc203403380147a6237299cc933a186a1a48e7..3a387870e3c48c8104813a5eae8576744c58ff2c 100644 --- a/src/npair_half_bin_newton.cpp +++ b/src/npair_half_bin_newton.cpp @@ -119,7 +119,7 @@ void NPairHalfBinNewton::build(NeighList *list) // loop over all atoms in other bins in stencil, store every pair - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { jtype = type[j]; diff --git a/src/npair_half_bin_newton_tri.cpp b/src/npair_half_bin_newton_tri.cpp index 3ef8c3260e154dab0fe6d06fab1cc2f6772350c0..169e710e0e5e18779d88aa4e039619c620351e1c 100644 --- a/src/npair_half_bin_newton_tri.cpp +++ b/src/npair_half_bin_newton_tri.cpp @@ -84,7 +84,7 @@ void NPairHalfBinNewtonTri::build(NeighList *list) // (equal zyx and j <= i) // latter excludes self-self interaction but allows superposed atoms - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (x[j][2] < ztmp) continue; diff --git a/src/npair_half_multi_newtoff.cpp b/src/npair_half_multi_newtoff.cpp index 11e45d91ffc093f85200eb9579f48f3decbc7d09..07b5c87a6cfb85b6c399597fdac9da27e3ff800b 100644 --- a/src/npair_half_multi_newtoff.cpp +++ b/src/npair_half_multi_newtoff.cpp @@ -87,7 +87,7 @@ void NPairHalfMultiNewtoff::build(NeighList *list) // stores own/own pairs only once // stores own/ghost pairs on both procs - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; s = stencil_multi[itype]; distsq = distsq_multi[itype]; cutsq = cutneighsq[itype]; diff --git a/src/npair_half_multi_newton.cpp b/src/npair_half_multi_newton.cpp index cd3a37821f366c0b58f3567ed0b9826a55b0eba9..3d909793291cae7fedab4eed4420fa09a0c11242 100644 --- a/src/npair_half_multi_newton.cpp +++ b/src/npair_half_multi_newton.cpp @@ -121,7 +121,7 @@ void NPairHalfMultiNewton::build(NeighList *list) // loop over all atoms in other bins in stencil, store every pair // skip if i,j neighbor cutoff is less than bin distance - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; s = stencil_multi[itype]; distsq = distsq_multi[itype]; cutsq = cutneighsq[itype]; diff --git a/src/npair_half_multi_newton_tri.cpp b/src/npair_half_multi_newton_tri.cpp index f9aaeb0414ec7d3ddd07dcced0ecfd49c34a83fa..909c69246b7e9c481ce97576400cbd7481d9f6aa 100644 --- a/src/npair_half_multi_newton_tri.cpp +++ b/src/npair_half_multi_newton_tri.cpp @@ -88,7 +88,7 @@ void NPairHalfMultiNewtonTri::build(NeighList *list) // (equal zyx and j <= i) // latter excludes self-self interaction but allows superposed atoms - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; s = stencil_multi[itype]; distsq = distsq_multi[itype]; cutsq = cutneighsq[itype]; diff --git a/src/npair_half_respa_bin_newtoff.cpp b/src/npair_half_respa_bin_newtoff.cpp index 39f68a289dd49eb577465835de06d2dc73b6e7cc..11246b4af8746f7b008e8872cebcd64cc71a66bd 100644 --- a/src/npair_half_respa_bin_newtoff.cpp +++ b/src/npair_half_respa_bin_newtoff.cpp @@ -101,7 +101,7 @@ void NPairHalfRespaBinNewtoff::build(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; if (moltemplate) { imol = molindex[i]; iatom = molatom[i]; diff --git a/src/npair_half_respa_bin_newton.cpp b/src/npair_half_respa_bin_newton.cpp index 537a72d0c1a2dcef8265414ab61a4eb4c57a933f..db766780360b2fc382eec5a87e9a1c8d5722da9d 100644 --- a/src/npair_half_respa_bin_newton.cpp +++ b/src/npair_half_respa_bin_newton.cpp @@ -160,7 +160,7 @@ void NPairHalfRespaBinNewton::build(NeighList *list) // loop over all atoms in other bins in stencil, store every pair - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { jtype = type[j]; diff --git a/src/npair_half_respa_bin_newton_tri.cpp b/src/npair_half_respa_bin_newton_tri.cpp index 9c5fd39fbe85e4aa07cb8fd50374374e88dcadaf..38621224c49df568fb7ed6b44a8c69ab7e2a6e1b 100644 --- a/src/npair_half_respa_bin_newton_tri.cpp +++ b/src/npair_half_respa_bin_newton_tri.cpp @@ -113,7 +113,7 @@ void NPairHalfRespaBinNewtonTri::build(NeighList *list) // (equal zyx and j <= i) // latter excludes self-self interaction but allows superposed atoms - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (x[j][2] < ztmp) continue; diff --git a/src/npair_half_size_bin_newtoff.cpp b/src/npair_half_size_bin_newtoff.cpp index e98923cd1160e1fe5619cd2ae90aaf7b29cb5afa..571b2484ea425aee53439974d08eb974d0cf2604 100644 --- a/src/npair_half_size_bin_newtoff.cpp +++ b/src/npair_half_size_bin_newtoff.cpp @@ -105,7 +105,7 @@ void NPairHalfSizeBinNewtoff::build(NeighList *list) ytmp = x[i][1]; ztmp = x[i][2]; radi = radius[i]; - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; // loop over all atoms in surrounding bins in stencil including self // only store pair if i < j diff --git a/src/npair_half_size_bin_newton.cpp b/src/npair_half_size_bin_newton.cpp index 2cd0943ac2c287f47ca3018c78ed5798466d501e..a8be3ce691092d7843e03a1147afc9a8ccc79836 100644 --- a/src/npair_half_size_bin_newton.cpp +++ b/src/npair_half_size_bin_newton.cpp @@ -156,7 +156,7 @@ void NPairHalfSizeBinNewton::build(NeighList *list) // loop over all atoms in other bins in stencil, store every pair - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (exclude && exclusion(i,j,type[i],type[j],mask,molecule)) continue; diff --git a/src/npair_half_size_bin_newton_tri.cpp b/src/npair_half_size_bin_newton_tri.cpp index 054487d31f271ed1532beee2bbdaccf01633a3f8..1107f73026240fb75ac1bd1b1d79e239b3ee279d 100644 --- a/src/npair_half_size_bin_newton_tri.cpp +++ b/src/npair_half_size_bin_newton_tri.cpp @@ -112,7 +112,7 @@ void NPairHalfSizeBinNewtonTri::build(NeighList *list) // (equal zyx and j <= i) // latter excludes self-self interaction but allows superposed atoms - ibin = coord2bin(x[i]); + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { if (x[j][2] < ztmp) continue;