From c318361d2fbae5522ea9ed1177fc75b60002e232 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 1 Jul 2009 20:28:37 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2937 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/ASPHERE/compute_temp_asphere.cpp | 12 +++++++-- src/compute.cpp | 9 +++++-- src/compute.h | 6 ++--- src/compute_pressure.cpp | 32 ++++++++++++++++------ src/compute_pressure.h | 2 ++ src/compute_temp_sphere.cpp | 12 +++++++-- src/fix_box_relax.cpp | 6 ++--- src/fix_indent.cpp | 40 +++++++++++++++++++--------- src/fix_indent.h | 2 +- src/fix_nph.cpp | 6 ++--- src/fix_npt.cpp | 6 ++--- src/fix_press_berendsen.cpp | 9 +++---- src/style_user_ackland.h | 20 -------------- src/style_user_ewaldn.h | 30 --------------------- src/thermo.cpp | 6 ++--- 15 files changed, 97 insertions(+), 101 deletions(-) diff --git a/src/ASPHERE/compute_temp_asphere.cpp b/src/ASPHERE/compute_temp_asphere.cpp index cc67215c20..eee3709e5f 100755 --- a/src/ASPHERE/compute_temp_asphere.cpp +++ b/src/ASPHERE/compute_temp_asphere.cpp @@ -31,6 +31,8 @@ using namespace LAMMPS_NS; +enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM}; + /* ---------------------------------------------------------------------- */ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) : @@ -159,7 +161,10 @@ double ComputeTempAsphere::compute_scalar() invoked_scalar = update->ntimestep; if (tempbias) { - if (tbias->invoked_scalar != update->ntimestep) tbias->compute_scalar(); + if (!(tbias->invoked_flag & INVOKED_SCALAR)) { + tbias->compute_scalar(); + tbias->invoked_flag |= INVOKED_SCALAR; + } tbias->remove_bias_all(); } @@ -216,7 +221,10 @@ void ComputeTempAsphere::compute_vector() invoked_vector = update->ntimestep; if (tempbias) { - if (tbias->invoked_vector != update->ntimestep) tbias->compute_vector(); + if (!(tbias->invoked_flag & INVOKED_VECTOR)) { + tbias->compute_vector(); + tbias->invoked_flag |= INVOKED_VECTOR; + } tbias->remove_bias_all(); } diff --git a/src/compute.cpp b/src/compute.cpp index 4cd76b95d3..57fa4e9298 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -64,7 +64,6 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) pressatomflag = peatomflag = 0; tempbias = 0; - id_pre = NULL; timeflag = 0; comm_forward = comm_reverse = 0; @@ -87,7 +86,6 @@ Compute::~Compute() { delete [] id; delete [] style; - delete [] id_pre; memory->sfree(tlist); } @@ -129,6 +127,13 @@ void Compute::reset_extra_dof() extra_dof = domain->dimension; } +/* ---------------------------------------------------------------------- */ + +void Compute::reset_extra_compute(char *) +{ + error->all("Compute does not allow an extra compute to be reset"); +} + /* ---------------------------------------------------------------------- add ntimestep to list of timesteps the compute will be called on do not add if already in list diff --git a/src/compute.h b/src/compute.h index cc4a24fb17..effcc9462a 100644 --- a/src/compute.h +++ b/src/compute.h @@ -47,14 +47,12 @@ class Compute : protected Pointers { int tempbias; // 0/1 if Compute temp includes self/extra bias - char *id_pre; // ID of pre-compute the Compute may store - int timeflag; // 1 if Compute stores list of timesteps it's called on int ntime; // # of entries in time list int maxtime; // max # of entries time list can hold int *tlist; // time list of steps the Compute is called on - int invoked_flag; // 1 if invoked or accessed this step, 0 if not + int invoked_flag; // non-zero if invoked or accessed this step, 0 if not int invoked_scalar; // last timestep on which compute_scalar() was invoked int invoked_vector; // ditto for compute_vector() int invoked_peratom; // ditto for compute_peratom() @@ -86,6 +84,8 @@ class Compute : protected Pointers { virtual void restore_bias(int, double *) {} virtual void restore_bias_all() {} + virtual void reset_extra_compute(char *); + void addstep(int); int matchstep(int); void clearstep(); diff --git a/src/compute_pressure.cpp b/src/compute_pressure.cpp index 2e9d4157ab..e4e2f47ffb 100644 --- a/src/compute_pressure.cpp +++ b/src/compute_pressure.cpp @@ -31,6 +31,8 @@ using namespace LAMMPS_NS; +enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM}; + /* ---------------------------------------------------------------------- */ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) : @@ -50,10 +52,10 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) : // insure it is valid for temperature computation int n = strlen(arg[3]) + 1; - id_pre = new char[n]; - strcpy(id_pre,arg[3]); + id_temp = new char[n]; + strcpy(id_temp,arg[3]); - int icompute = modify->find_compute(id_pre); + int icompute = modify->find_compute(id_temp); if (icompute < 0) error->all("Could not find compute pressure temp ID"); if (modify->compute[icompute]->tempflag == 0) error->all("Compute pressure temp ID does not compute temperature"); @@ -98,6 +100,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) : ComputePressure::~ComputePressure() { + delete [] id_temp; delete [] vector; delete [] vptr; } @@ -113,7 +116,7 @@ void ComputePressure::init() // set temperature compute, must be done in init() // fixes could have changed or compute_modify could have changed it - int icompute = modify->find_compute(id_pre); + int icompute = modify->find_compute(id_temp); if (icompute < 0) error->all("Could not find compute pressure temp ID"); temperature = modify->compute[icompute]; @@ -169,9 +172,10 @@ double ComputePressure::compute_scalar() double t; if (keflag) { - if (temperature->invoked_scalar == update->ntimestep) - t = temperature->scalar; - else t = temperature->compute_scalar(); + if (!(temperature->invoked_flag & INVOKED_SCALAR)) { + t = temperature->compute_scalar(); + temperature->invoked_flag |= INVOKED_SCALAR; + } else t = temperature->scalar; } if (dimension == 3) { @@ -210,8 +214,10 @@ void ComputePressure::compute_vector() double *ke_tensor; if (keflag) { - if (temperature->invoked_vector != update->ntimestep) + if (!(temperature->invoked_flag & INVOKED_VECTOR)) { temperature->compute_vector(); + temperature->invoked_flag |= INVOKED_VECTOR; + } ke_tensor = temperature->vector; } @@ -269,3 +275,13 @@ void ComputePressure::virial_compute(int n, int ndiag) if (force->pair && force->pair->tail_flag) for (i = 0; i < ndiag; i++) virial[i] += force->pair->ptail * inv_volume; } + +/* ---------------------------------------------------------------------- */ + +void ComputePressure::reset_extra_compute(char *id_new) +{ + delete [] id_temp; + int n = strlen(id_new) + 1; + id_temp = new char[n]; + strcpy(id_temp,id_new); +} diff --git a/src/compute_pressure.h b/src/compute_pressure.h index adf6ec226a..c48fd30ac9 100644 --- a/src/compute_pressure.h +++ b/src/compute_pressure.h @@ -25,6 +25,7 @@ class ComputePressure : public Compute { void init(); double compute_scalar(); void compute_vector(); + void reset_extra_compute(char *); private: double boltz,nktv2p,inv_volume; @@ -32,6 +33,7 @@ class ComputePressure : public Compute { double **vptr; double *kspace_virial; Compute *temperature; + char *id_temp; double virial[6]; int keflag,pairflag,bondflag,angleflag,dihedralflag,improperflag; int fixflag,kspaceflag; diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index f0de81127f..73eeeed722 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -26,6 +26,8 @@ using namespace LAMMPS_NS; +enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM}; + #define INERTIA 0.4 // moment of inertia for sphere /* ---------------------------------------------------------------------- */ @@ -240,7 +242,10 @@ double ComputeTempSphere::compute_scalar() invoked_scalar = update->ntimestep; if (tempbias) { - if (tbias->invoked_scalar != update->ntimestep) tbias->compute_scalar(); + if (!(tbias->invoked_flag & INVOKED_SCALAR)) { + tbias->compute_scalar(); + tbias->invoked_flag |= INVOKED_SCALAR; + } tbias->remove_bias_all(); } @@ -324,7 +329,10 @@ void ComputeTempSphere::compute_vector() invoked_vector = update->ntimestep; if (tempbias) { - if (tbias->invoked_vector != update->ntimestep) tbias->compute_vector(); + if (!(tbias->invoked_flag & INVOKED_VECTOR)) { + tbias->compute_vector(); + tbias->invoked_flag |= INVOKED_VECTOR; + } tbias->remove_bias_all(); } diff --git a/src/fix_box_relax.cpp b/src/fix_box_relax.cpp index 9d8bc4b380..0ae65fa808 100644 --- a/src/fix_box_relax.cpp +++ b/src/fix_box_relax.cpp @@ -466,13 +466,11 @@ int FixBoxRelax::modify_param(int narg, char **arg) if (temperature->igroup != 0 && comm->me == 0) error->warning("Temperature for fix modify is not for group all"); - // reset id_pre of pressure to new temp ID + // reset id_temp of pressure to new temp ID icompute = modify->find_compute(id_press); if (icompute < 0) error->all("Pressure ID for fix modify does not exist"); - delete [] modify->compute[icompute]->id_pre; - modify->compute[icompute]->id_pre = new char[n]; - strcpy(modify->compute[icompute]->id_pre,id_temp); + modify->compute[icompute]->reset_extra_compute(id_temp); return 2; diff --git a/src/fix_indent.cpp b/src/fix_indent.cpp index fd45bd60d2..7e4eeee9c7 100644 --- a/src/fix_indent.cpp +++ b/src/fix_indent.cpp @@ -30,6 +30,7 @@ using namespace LAMMPS_NS; enum{NONE,SPHERE,CYLINDER,PLANE}; +enum{INSIDE,OUTSIDE}; /* ---------------------------------------------------------------------- */ @@ -48,14 +49,6 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) : k = atof(arg[3]); - // set defaults - - istyle = NONE; - vx = vy = vz = 0.0; - radflag = 0; - r0_start = 0.0; - scaleflag = 1; - // read options from end of input line options(narg-4,&arg[4]); @@ -198,9 +191,14 @@ void FixIndent::post_force(int vflag) dely = x[i][1] - y1; delz = x[i][2] - z1; r = sqrt(delx*delx + dely*dely + delz*delz); - dr = r - r0; + if (side == OUTSIDE) { + dr = r - r0; + fmag = k*dr*dr; + } else { + dr = r0 - r; + fmag = -k*dr*dr; + } if (dr >= 0.0) continue; - fmag = k*dr*dr; fx = delx*fmag/r; fy = dely*fmag/r; fz = delz*fmag/r; @@ -255,9 +253,14 @@ void FixIndent::post_force(int vflag) delz = 0; } r = sqrt(delx*delx + dely*dely + delz*delz); - dr = r - r0; + if (side == OUTSIDE) { + dr = r - r0; + fmag = k*dr*dr; + } else { + dr = r0 - r; + fmag = -k*dr*dr; + } if (dr >= 0.0) continue; - fmag = k*dr*dr; fx = delx*fmag/r; fy = dely*fmag/r; fz = delz*fmag/r; @@ -353,6 +356,13 @@ void FixIndent::options(int narg, char **arg) { if (narg < 0) error->all("Illegal fix indent command"); + istyle = NONE; + vx = vy = vz = 0.0; + radflag = 0; + r0_start = 0.0; + scaleflag = 1; + side = OUTSIDE; + int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"sphere") == 0) { @@ -403,6 +413,12 @@ void FixIndent::options(int narg, char **arg) else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1; else error->all("Illegal fix indent command"); iarg += 2; + } else if (strcmp(arg[iarg],"side") == 0) { + if (iarg+2 > narg) error->all("Illegal fix indent command"); + if (strcmp(arg[iarg+1],"in") == 0) side = INSIDE; + else if (strcmp(arg[iarg+1],"out") == 0) side = OUTSIDE; + else error->all("Illegal fix indent command"); + iarg += 2; } else error->all("Illegal fix indent command"); } } diff --git a/src/fix_indent.h b/src/fix_indent.h index 3b580cbf9d..f4579e1ea2 100644 --- a/src/fix_indent.h +++ b/src/fix_indent.h @@ -32,7 +32,7 @@ class FixIndent : public Fix { double compute_vector(int); private: - int istyle,scaleflag,radflag,thermo_flag,eflag_enable; + int istyle,scaleflag,radflag,thermo_flag,eflag_enable,side; double k,k3; double x0,y0,z0,r0_stop,r0_start,planepos; int indenter_flag,planeside; diff --git a/src/fix_nph.cpp b/src/fix_nph.cpp index cfebecc6fe..df8317aab0 100644 --- a/src/fix_nph.cpp +++ b/src/fix_nph.cpp @@ -816,13 +816,11 @@ int FixNPH::modify_param(int narg, char **arg) if (temperature->igroup != 0 && comm->me == 0) error->warning("Temperature for NPH is not for group all"); - // reset id_pre of pressure to new temp ID + // reset id_temp of pressure to new temp ID icompute = modify->find_compute(id_press); if (icompute < 0) error->all("Press ID for fix npt does not exist"); - delete [] modify->compute[icompute]->id_pre; - modify->compute[icompute]->id_pre = new char[n]; - strcpy(modify->compute[icompute]->id_pre,id_temp); + modify->compute[icompute]->reset_extra_compute(id_temp); return 2; diff --git a/src/fix_npt.cpp b/src/fix_npt.cpp index c01437238b..ccafd4d8af 100644 --- a/src/fix_npt.cpp +++ b/src/fix_npt.cpp @@ -957,13 +957,11 @@ int FixNPT::modify_param(int narg, char **arg) if (temperature->igroup != 0 && comm->me == 0) error->warning("Temperature for fix modify is not for group all"); - // reset id_pre of pressure to new temp ID + // reset id_temp of pressure to new temp ID icompute = modify->find_compute(id_press); if (icompute < 0) error->all("Pressure ID for fix modify does not exist"); - delete [] modify->compute[icompute]->id_pre; - modify->compute[icompute]->id_pre = new char[n]; - strcpy(modify->compute[icompute]->id_pre,id_temp); + modify->compute[icompute]->reset_extra_compute(id_temp); return 2; diff --git a/src/fix_press_berendsen.cpp b/src/fix_press_berendsen.cpp index 1fba592461..dfac528192 100644 --- a/src/fix_press_berendsen.cpp +++ b/src/fix_press_berendsen.cpp @@ -438,13 +438,12 @@ int FixPressBerendsen::modify_param(int narg, char **arg) if (temperature->igroup != 0 && comm->me == 0) error->warning("Temperature for NPT is not for group all"); - // reset id_pre of pressure to new temp ID + // reset id_temp of pressure to new temp ID icompute = modify->find_compute(id_press); - if (icompute < 0) error->all("Press ID for fix press/berendsen does not exist"); - delete [] modify->compute[icompute]->id_pre; - modify->compute[icompute]->id_pre = new char[n]; - strcpy(modify->compute[icompute]->id_pre,id_temp); + if (icompute < 0) + error->all("Press ID for fix press/berendsen does not exist"); + modify->compute[icompute]->reset_extra_compute(id_temp); return 2; diff --git a/src/style_user_ackland.h b/src/style_user_ackland.h index 6e7483a9f7..e69de29bb2 100644 --- a/src/style_user_ackland.h +++ b/src/style_user_ackland.h @@ -1,20 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef ComputeInclude -#include "compute_ackland_atom.h" -#endif - -#ifdef ComputeClass -ComputeStyle(ackland/atom,ComputeAcklandAtom) -#endif diff --git a/src/style_user_ewaldn.h b/src/style_user_ewaldn.h index 3eafa50744..e69de29bb2 100644 --- a/src/style_user_ewaldn.h +++ b/src/style_user_ewaldn.h @@ -1,30 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef KSpaceInclude -#include "ewald_n.h" -#endif - -#ifdef KSpaceClass -KSpaceStyle(ewald/n,EwaldN) -#endif - -#ifdef PairInclude -#include "pair_buck_coul.h" -#include "pair_lj_coul.h" -#endif - -#ifdef PairClass -PairStyle(buck/coul,PairBuckCoul) -PairStyle(lj/coul,PairLJCoul) -#endif diff --git a/src/thermo.cpp b/src/thermo.cpp index 5fa7ea598c..e6ff2920dc 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -380,7 +380,7 @@ void Thermo::modify_params(int narg, char **arg) if (temperature->igroup != 0 && comm->me == 0) error->warning("Temperature for thermo pressure is not for group all"); - // reset id_pre of pressure to new temp ID + // reset id_temp of pressure to new temp ID // either pressure currently being used by thermo or "thermo_press" if (index_press_scalar >= 0) { @@ -391,9 +391,7 @@ void Thermo::modify_params(int narg, char **arg) if (icompute < 0) error->all("Press ID for thermo does not exist"); } else icompute = modify->find_compute((char *) "thermo_press"); - delete [] modify->compute[icompute]->id_pre; - modify->compute[icompute]->id_pre = new char[n]; - strcpy(modify->compute[icompute]->id_pre,arg[iarg+1]); + modify->compute[icompute]->reset_extra_compute(arg[iarg+1]); iarg += 2;