From 07f42930ff711b09bf46f9641ae964617edf3cad Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Mon, 10 Jul 2023 12:53:02 -0700 Subject: [PATCH] clean up code and comments --- src/compute_property_local.cpp | 3 ++- src/npair_half_bin_newton_tri.cpp | 29 ++++++----------------------- src/npair_half_nsq_newton.cpp | 5 +++++ src/npair_halffull_newton.cpp | 5 +++++ src/nstencil_half_bin_2d_tri.cpp | 12 ++++++++++-- src/nstencil_half_bin_3d_tri.cpp | 8 +++++++- 6 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/compute_property_local.cpp b/src/compute_property_local.cpp index d0523a1bec..92036c4bd2 100644 --- a/src/compute_property_local.cpp +++ b/src/compute_property_local.cpp @@ -405,7 +405,8 @@ int ComputePropertyLocal::count_pairs(int allflag, int forceflag) if (!(mask[j] & groupbit)) continue; // itag = jtag is possible for long cutoffs that include images of self - + // do not need triclinic logic here b/c neighbor list itself is correct + if (newton_pair == 0 && j >= nlocal) { jtag = tag[j]; if (itag > jtag) { diff --git a/src/npair_half_bin_newton_tri.cpp b/src/npair_half_bin_newton_tri.cpp index 17504ac3af..71a15df59e 100644 --- a/src/npair_half_bin_newton_tri.cpp +++ b/src/npair_half_bin_newton_tri.cpp @@ -83,11 +83,12 @@ void NPairHalfBinNewtonTri::build(NeighList *list) } // loop over all atoms in bins in stencil - // pairs for atoms j "below" i are excluded - // below = lower z or (equal z and lower y) or (equal zy and lower x) - // (equal zyx and j <= i) - // latter excludes self-self interaction but allows superposed atoms - + // for triclinic, bin stencil is full in all 3 dims + // must use itag/jtag to eliminate half the I/J interactions + // cannot use I/J coord comparision + // b/c transforming orthog -> lambda -> orthog for ghost atoms + // with an added PBC offset can shift all 3 coords by epsilon + ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { @@ -107,25 +108,9 @@ void NPairHalfBinNewtonTri::build(NeighList *list) } else { if (x[j][0] < xtmp) continue; } - //if (x[j][2] < ztmp) continue; - //if (x[j][2] == ztmp) { - // if (x[j][1] < ytmp) continue; - // if (x[j][1] == ytmp && x[j][0] < xtmp) continue; - // } } } - /* - if (x[j][2] < ztmp) continue; - if (x[j][2] == ztmp) { - if (x[j][1] < ytmp) continue; - if (x[j][1] == ytmp) { - if (x[j][0] < xtmp) continue; - if (x[j][0] == xtmp && j <= i) continue; - } - } - */ - jtype = type[j]; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; @@ -135,8 +120,6 @@ void NPairHalfBinNewtonTri::build(NeighList *list) rsq = delx*delx + dely*dely + delz*delz; if (rsq <= cutneighsq[itype][jtype]) { - //printf("NEIGH i,j %d %d ijtag %d %d dist %g\n", - // i,j,tag[i],tag[j],sqrt(rsq)); if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); diff --git a/src/npair_half_nsq_newton.cpp b/src/npair_half_nsq_newton.cpp index be06393f58..0174a78900 100644 --- a/src/npair_half_nsq_newton.cpp +++ b/src/npair_half_nsq_newton.cpp @@ -89,7 +89,12 @@ void NPairHalfNsqNewton::build(NeighList *list) } // loop over remaining atoms, owned and ghost + // use itag/jtap comparision to eliminate half the interactions // itag = jtag is possible for long cutoffs that include images of self + // for triclinic, must use delta to eliminate half the I/J interactions + // cannot use direct I/J coord comparision as for orthog + // b/c transforming orthog -> lambda -> orthog for ghost atoms + // with an added PBC offset can shift all 3 coords by epsilon for (j = i+1; j < nall; j++) { if (includegroup && !(mask[j] & bitmask)) continue; diff --git a/src/npair_halffull_newton.cpp b/src/npair_halffull_newton.cpp index d1e894943c..af15b27eac 100644 --- a/src/npair_halffull_newton.cpp +++ b/src/npair_halffull_newton.cpp @@ -70,6 +70,11 @@ void NPairHalffullNewton::build(NeighList *list) ztmp = x[i][2]; // loop over full neighbor list + // use i < j < nlocal to eliminate half the local/local interactions + // for triclinic, must use delta to eliminate half the local/ghost interactions + // cannot use direct I/J coord comparision as for orthog + // b/c transforming orthog -> lambda -> orthog for ghost atoms + // with an added PBC offset can shift all 3 coords by epsilon jlist = firstneigh_full[i]; jnum = numneigh_full[i]; diff --git a/src/nstencil_half_bin_2d_tri.cpp b/src/nstencil_half_bin_2d_tri.cpp index 06831730fd..920918fe09 100644 --- a/src/nstencil_half_bin_2d_tri.cpp +++ b/src/nstencil_half_bin_2d_tri.cpp @@ -27,9 +27,17 @@ void NStencilHalfBin2dTri::create() { int i, j; + // for triclinic, need to use full stencil in all dims + // not a half stencil in y + // b/c transforming orthog -> lambda -> orthog for ghost atoms + // with an added PBC offset can shift both coords by epsilon + // thus for an I/J owned/ghost pair, the xy coords + // and bin assignments can be different on I proc vs J proc + nstencil = 0; - for (j = 0; j <= sy; j++) + for (j = -sy; j <= sy; j++) for (i = -sx; i <= sx; i++) - if (bin_distance(i, j, 0) < cutneighmaxsq) stencil[nstencil++] = j * mbinx + i; + if (bin_distance(i, j, 0) < cutneighmaxsq) + stencil[nstencil++] = j * mbinx + i; } diff --git a/src/nstencil_half_bin_3d_tri.cpp b/src/nstencil_half_bin_3d_tri.cpp index f94bfc5e63..d146b92cd1 100644 --- a/src/nstencil_half_bin_3d_tri.cpp +++ b/src/nstencil_half_bin_3d_tri.cpp @@ -27,9 +27,15 @@ void NStencilHalfBin3dTri::create() { int i, j, k; + // for triclinic, need to use full stencil in all dims + // not a half stencil in z + // b/c transforming orthog -> lambda -> orthog for ghost atoms + // with an added PBC offset can shift all 3 coords by epsilon + // thus for an I/J owned/ghost pair, the xyz coords + // and bin assignments can be different on I proc vs J proc + nstencil = 0; - //for (k = 0; k <= sz; k++) for (k = -sz; k <= sz; k++) for (j = -sy; j <= sy; j++) for (i = -sx; i <= sx; i++)