From bb48c5ccdc0bed7fd6f89c8af72ead5c073caea2 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 18 Jun 2012 23:49:36 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8312 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/domain.cpp | 28 +++++++++++++--------------- src/domain.h | 2 +- src/min.cpp | 4 ++++ src/respa.cpp | 3 +++ src/verlet.cpp | 3 +++ 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/domain.cpp b/src/domain.cpp index 472da91734..c5a4b72d2b 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -98,12 +98,6 @@ Domain::~Domain() void Domain::init() { - // check for too small a periodic box for molecular system - - if (atom->molecular && box_too_small()) - error->all(FLERR,"Bond/angle/dihedral extent must be < " - "half of periodic box dimension"); - // set box_change if box dimensions/shape ever changes // due to shrink-wrapping, fixes that change volume (npt, vol/rescale, etc) @@ -525,16 +519,16 @@ void Domain::pbc() /* ---------------------------------------------------------------------- check that no pair of atoms in a bonded interaction are further apart than half a periodic box length - return 1 if any pair is, else 0 ------------------------------------------------------------------------- */ -int Domain::box_too_small() +void Domain::box_too_small_check() { int i,j,k; - // only need to check if some dimension is periodic + // only need to check if system is molecluar and some dimension is periodic - if (!xperiodic && !yperiodic && (dimension == 2 || !zperiodic)) return 0; + if (!atom->molecular) return; + if (!xperiodic && !yperiodic && (dimension == 2 || !zperiodic)) return; // maxbondall = longest current bond length // NOTE: if box is tiny (less than 2 * bond-length), @@ -552,7 +546,7 @@ int Domain::box_too_small() for (i = 0; i < nlocal; i++) for (j = 0; j < num_bond[i]; j++) { k = atom->map(bond_atom[i][j]); - if (k < 0) error->one(FLERR,"Bond atom missing in box size check"); + if (k == -1) error->one(FLERR,"Bond atom missing in box size check"); delx = x[i][0] - x[k][0]; dely = x[i][1] - x[k][1]; delz = x[i][2] - x[k][2]; @@ -576,10 +570,14 @@ int Domain::box_too_small() // else when use minimg() in bond/angle/dihdral compute, // could calculate incorrect distance between 2 atoms - if (xperiodic && maxdelta > xprd_half) return 1; - if (yperiodic && maxdelta > yprd_half) return 1; - if (dimension == 3 && zperiodic && maxdelta > zprd_half) return 1; - return 0; + int flag = 0; + if (xperiodic && maxdelta > xprd_half) flag = 1; + if (yperiodic && maxdelta > yprd_half) flag = 1; + if (dimension == 3 && zperiodic && maxdelta > zprd_half) flag = 1; + + if (flag) + error->all(FLERR, + "Bond/angle/dihedral extent > half of periodic box length"); } /* ---------------------------------------------------------------------- diff --git a/src/domain.h b/src/domain.h index 58303527c0..517fc565b6 100644 --- a/src/domain.h +++ b/src/domain.h @@ -93,7 +93,7 @@ class Domain : protected Pointers { virtual void set_local_box(); virtual void reset_box(); virtual void pbc(); - int box_too_small(); + void box_too_small_check(); int minimum_image_check(double, double, double); void minimum_image(double &, double &, double &); void minimum_image(double *); diff --git a/src/min.cpp b/src/min.cpp index 629a895449..cc51460b99 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -234,6 +234,7 @@ void Min::setup() if (atom->sortfreq > 0) atom->sort(); comm->borders(); if (triclinic) domain->lamda2x(atom->nlocal+atom->nghost); + domain->box_too_small_check(); neighbor->build(); neighbor->ncalls = 0; @@ -319,6 +320,7 @@ void Min::setup_minimal(int flag) comm->exchange(); comm->borders(); if (triclinic) domain->lamda2x(atom->nlocal+atom->nghost); + domain->box_too_small_check(); neighbor->build(); neighbor->ncalls = 0; } @@ -432,6 +434,8 @@ void Min::cleanup() // delete fix at end of run, so its atom arrays won't persist modify->delete_fix("MINIMIZE"); + + domain->box_too_small_check(); } /* ---------------------------------------------------------------------- diff --git a/src/respa.cpp b/src/respa.cpp index fec5b10e89..a91037b8d1 100644 --- a/src/respa.cpp +++ b/src/respa.cpp @@ -363,6 +363,7 @@ void Respa::setup() if (atom->sortfreq > 0) atom->sort(); comm->borders(); if (triclinic) domain->lamda2x(atom->nlocal+atom->nghost); + domain->box_too_small_check(); neighbor->build(); neighbor->ncalls = 0; @@ -427,6 +428,7 @@ void Respa::setup_minimal(int flag) comm->exchange(); comm->borders(); if (triclinic) domain->lamda2x(atom->nlocal+atom->nghost); + domain->box_too_small_check(); neighbor->build(); neighbor->ncalls = 0; } @@ -501,6 +503,7 @@ void Respa::cleanup() { modify->post_run(); modify->delete_fix("RESPA"); + domain->box_too_small_check(); } /* ---------------------------------------------------------------------- */ diff --git a/src/verlet.cpp b/src/verlet.cpp index 20bc2d6112..ad8263d9a8 100644 --- a/src/verlet.cpp +++ b/src/verlet.cpp @@ -111,6 +111,7 @@ void Verlet::setup() if (atom->sortfreq > 0) atom->sort(); comm->borders(); if (triclinic) domain->lamda2x(atom->nlocal+atom->nghost); + domain->box_too_small_check(); neighbor->build(); neighbor->ncalls = 0; @@ -167,6 +168,7 @@ void Verlet::setup_minimal(int flag) comm->exchange(); comm->borders(); if (triclinic) domain->lamda2x(atom->nlocal+atom->nghost); + domain->box_too_small_check(); neighbor->build(); neighbor->ncalls = 0; } @@ -309,6 +311,7 @@ void Verlet::run(int n) void Verlet::cleanup() { modify->post_run(); + domain->box_too_small_check(); } /* ----------------------------------------------------------------------