From 460976db717ea0353574c76f8ef587120fca1a79 Mon Sep 17 00:00:00 2001 From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa> Date: Wed, 19 Jan 2011 16:49:59 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5567 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/force.cpp | 1 - src/neighbor.cpp | 29 ++++++++++++++++++++++++----- src/neighbor.h | 6 ++++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/force.cpp b/src/force.cpp index f70d67413e..7b890302e3 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -105,7 +105,6 @@ void Force::init() if (kspace) kspace->init(); // kspace must come before pair if (pair) pair->init(); // so g_ewald is defined - if (bond) bond->init(); if (angle) angle->init(); if (dihedral) dihedral->init(); if (improper) improper->init(); diff --git a/src/neighbor.cpp b/src/neighbor.cpp index eed5a92203..1b6cbccad5 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -208,7 +208,11 @@ void Neighbor::init() // cutneigh = force cutoff + skin if cutforce > 0, else cutneigh = 0 triggersq = 0.25*skin*skin; - + shrinkcheck = 0; + if (domain->box_change && (domain->xperiodic || domain->yperiodic || + (dimension == 3 && domain->zperiodic))) + shrinkcheck = 1; + n = atom->ntypes; if (cutneighsq == NULL) { cutneighsq = memory->create_2d_double_array(n+1,n+1,"neigh:cutneighsq"); @@ -996,11 +1000,23 @@ int Neighbor::decide() } else return 0; } -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + if any atom moved trigger distance (half of neighbor skin) return 1 + shrink trigger distance if periodic box dimension has decreased +------------------------------------------------------------------------- */ int Neighbor::check_distance() { - double delx,dely,delz,rsq; + double delx,dely,delz,rsq,deltasq; + + if (shrinkcheck) { + double delta = 0.0; + if (domain->xperiodic) delta = MIN(delta,domain->xprd-xprdhold); + if (domain->yperiodic) delta = MIN(delta,domain->yprd-yprdhold); + if (domain->zperiodic) delta = MIN(delta,domain->zprd-zprdhold); + delta = 0.5*skin - delta; + deltasq = delta*delta; + } else deltasq = triggersq; double **x = atom->x; int nlocal = atom->nlocal; @@ -1012,7 +1028,7 @@ int Neighbor::check_distance() dely = x[i][1] - xhold[i][1]; delz = x[i][2] - xhold[i][2]; rsq = delx*delx + dely*dely + delz*delz; - if (rsq > triggersq) flag = 1; + if (rsq > deltasq) flag = 1; } int flagall; @@ -1033,7 +1049,7 @@ void Neighbor::build() ago = 0; ncalls++; - // store current atom positions if needed + // store current atom positions and box size if needed if (dist_check) { double **x = atom->x; @@ -1049,6 +1065,9 @@ void Neighbor::build() xhold[i][1] = x[i][1]; xhold[i][2] = x[i][2]; } + xprdhold = domain->xprd; + yprdhold = domain->yprd; + zprdhold = domain->zprd; } // if necessary, extend atom arrays in pairwise lists diff --git a/src/neighbor.h b/src/neighbor.h index fcf7600a05..3185e6563c 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -91,8 +91,10 @@ class Neighbor : protected Pointers { double triggersq; // trigger = build when atom moves this dist - double **xhold; // atom coords at last neighbor build - int maxhold; // size of xhold array + double **xhold; // atom coords at last neighbor build + int maxhold; // size of xhold array + double xprdhold,yprdhold,zprdhold; // box size at last neighbor build + int shrinkcheck; int nbinx,nbiny,nbinz; // # of global bins int *bins; // ptr to next atom in each bin -- GitLab