From 7732b4f0c2468912a1825e51ca006e715687f4f7 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 13 Aug 2008 14:39:45 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2051 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/GRANULAR/pair_gran_hertzian.cpp | 1 + src/GRANULAR/pair_gran_history.cpp | 1 + src/KSPACE/pair_lj_cut_coul_long_tip4p.cpp | 3 ++- src/finish.cpp | 9 +++---- src/pair.cpp | 1 + src/pair.h | 1 + src/pair_hybrid.cpp | 31 +++++++++++++--------- 7 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/GRANULAR/pair_gran_hertzian.cpp b/src/GRANULAR/pair_gran_hertzian.cpp index c9107711c2..fc52c19e64 100644 --- a/src/GRANULAR/pair_gran_hertzian.cpp +++ b/src/GRANULAR/pair_gran_hertzian.cpp @@ -32,6 +32,7 @@ using namespace LAMMPS_NS; PairGranHertzian::PairGranHertzian(LAMMPS *lmp) : PairGranHistory(lmp) { + no_virial_compute = 1; history = 1; } diff --git a/src/GRANULAR/pair_gran_history.cpp b/src/GRANULAR/pair_gran_history.cpp index 2f32d4feb1..f0650f3238 100644 --- a/src/GRANULAR/pair_gran_history.cpp +++ b/src/GRANULAR/pair_gran_history.cpp @@ -46,6 +46,7 @@ using namespace LAMMPS_NS; PairGranHistory::PairGranHistory(LAMMPS *lmp) : Pair(lmp) { single_enable = 0; + no_virial_compute = 1; history = 1; fix_history = NULL; } diff --git a/src/KSPACE/pair_lj_cut_coul_long_tip4p.cpp b/src/KSPACE/pair_lj_cut_coul_long_tip4p.cpp index 991dbde655..dc9088d44c 100644 --- a/src/KSPACE/pair_lj_cut_coul_long_tip4p.cpp +++ b/src/KSPACE/pair_lj_cut_coul_long_tip4p.cpp @@ -54,6 +54,7 @@ PairLJCutCoulLongTIP4P::PairLJCutCoulLongTIP4P(LAMMPS *lmp) : PairLJCutCoulLong(lmp) { single_enable = 0; + no_virial_compute = 1; } /* ---------------------------------------------------------------------- */ @@ -75,7 +76,7 @@ void PairLJCutCoulLongTIP4P::compute(int eflag, int vflag) float rsq; int *int_rsq = (int *) &rsq; - // if vflag_global = 2, reset vflag as if vflag_global = 1 + // if global component of incoming vflag = 2, reset vflag as if it were 1 // necessary since TIP4P cannot compute virial as F dot r // due to find_M() finding bonded H atoms which are not near O atom diff --git a/src/finish.cpp b/src/finish.cpp index 269d53b501..9b4c0bdf40 100644 --- a/src/finish.cpp +++ b/src/finish.cpp @@ -256,14 +256,11 @@ void Finish::end(int flag) if (me == 0) { if (screen) { fprintf(screen,"FFT time (%% of Kspce) = %g (%g)\n",time3d,fraction); - fprintf(screen,"FFT Gflps 3d 1d-only = %g %g\n",flop3,flop1); + fprintf(screen,"FFT Gflps 3d (1d only) = %g %g\n",flop3,flop1); } if (logfile) { - fprintf(logfile,"FFT time (%% of Kspce) = %g (%g)\n", - time3d,time3d/time_kspace*100.0); - fprintf(logfile,"FFT Gflps 3d 1d-only = %g %g\n", - nflops/1.0e9/(time3d/4.0/nsteps), - nflops/1.0e9/(time1d/4.0/nsteps)); + fprintf(logfile,"FFT time (%% of Kspce) = %g (%g)\n",time3d,fraction); + fprintf(logfile,"FFT Gflps 3d (1d only) = %g %g\n",flop3,flop1); } } } diff --git a/src/pair.cpp b/src/pair.cpp index 495fdae821..9bb99bea32 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -55,6 +55,7 @@ Pair::Pair(LAMMPS *lmp) : Pointers(lmp) single_enable = 1; respa_enable = 0; one_coeff = 0; + no_virial_compute = 0; // pair_modify settings diff --git a/src/pair.h b/src/pair.h index b50d685c9d..3eae3f4041 100644 --- a/src/pair.h +++ b/src/pair.h @@ -37,6 +37,7 @@ class Pair : protected Pointers { int single_enable; // 1 if single() routine exists int respa_enable; // 1 if inner/middle/outer rRESPA routines int one_coeff; // 1 if allows only one coeff * * call + int no_virial_compute; // 1 if does not invoke virial_compute() int tail_flag; // pair_modify flag for LJ tail correction double etail,ptail; // energy/pressure tail corrections diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 493f6fe376..aa43f2fab5 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -59,12 +59,11 @@ PairHybrid::~PairHybrid() /* ---------------------------------------------------------------------- call each sub-style's compute function accumulate sub-style global/peratom energy/virial in hybrid - for vflag = 1: + for global vflag = 1: each sub-style computes own virial[6] sum sub-style virial[6] to hybrid's virial[6] - for vflag = 2: - call sub-style compute() with vflag % 2 - to prevent sub-style from calling virial_compute() + for global vflag = 2: + call sub-style with adjusted vflag to prevent it calling virial_compute() hybrid calls virial_compute() on final accumulated f ------------------------------------------------------------------------- */ @@ -72,18 +71,22 @@ void PairHybrid::compute(int eflag, int vflag) { int i,j,m,n; + // if no_virial_compute is set and global component of incoming vflag = 2, + // reset vflag as if it were 1 + // necessary since one or more sub-styles cannot compute virial as F dot r + + if (no_virial_compute && vflag % 4 == 2) vflag = 1 + vflag/4 * 4; + if (eflag || vflag) ev_setup(eflag,vflag); else evflag = 0; - // don't allow substyle to invoke virial_compute() - // if vflag has that setting, change vflag passed to substyle - // preserve vflag_atom option in what is passed to substyle + // check if global component of incoming vflag = 2 + // if so, reset vflag passed to substyle as if it were 0 + // necessary so substyle will not invoke virial_compute() int vflag_substyle; - int vflag_global_substyle = vflag % 4; - if (vflag_global_substyle == 2) { - vflag_substyle = vflag/4 * 4; - } else vflag_substyle = vflag; + if (vflag % 4 == 2) vflag_substyle = vflag/4 * 4; + else vflag_substyle = vflag; for (m = 0; m < nstyles; m++) { styles[m]->compute(eflag,vflag_substyle); @@ -92,8 +95,9 @@ void PairHybrid::compute(int eflag, int vflag) eng_vdwl += styles[m]->eng_vdwl; eng_coul += styles[m]->eng_coul; } - if (vflag_global) + if (vflag_global) { for (n = 0; n < 6; n++) virial[n] += styles[m]->virial[n]; + } if (eflag_atom) { n = atom->nlocal; if (force->newton_pair) n += atom->nghost; @@ -238,11 +242,14 @@ void PairHybrid::settings(int narg, char **arg) // single_enable = 0 if any sub-style = 0 // respa_enable = 1 if any sub-style is set + // no_virial_compute = 1 if any sub-style is set for (m = 0; m < nstyles; m++) if (styles[m]->single_enable == 0) single_enable = 0; for (m = 0; m < nstyles; m++) if (styles[m]->respa_enable) respa_enable = 1; + for (m = 0; m < nstyles; m++) + if (styles[m]->no_virial_compute) no_virial_compute = 1; } /* ----------------------------------------------------------------------