diff --git a/src/ASPHERE/compute_temp_asphere.cpp b/src/ASPHERE/compute_temp_asphere.cpp index 26e625ee69..edcff5dc69 100755 --- a/src/ASPHERE/compute_temp_asphere.cpp +++ b/src/ASPHERE/compute_temp_asphere.cpp @@ -56,14 +56,16 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"bias") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal compute temp/asphere command"); + if (iarg+2 > narg) + error->all(FLERR,"Illegal compute temp/asphere command"); tempbias = 1; int n = strlen(arg[iarg+1]) + 1; id_bias = new char[n]; strcpy(id_bias,arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"dof") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal compute temp/asphere command"); + if (iarg+2 > narg) + error->all(FLERR,"Illegal compute temp/asphere command"); if (strcmp(arg[iarg+1],"rotate") == 0) mode = ROTATE; else if (strcmp(arg[iarg+1],"all") == 0) mode = ALL; else error->all(FLERR,"Illegal compute temp/asphere command"); @@ -106,7 +108,8 @@ void ComputeTempAsphere::init() if (tempbias) { int i = modify->find_compute(id_bias); - if (i < 0) error->all(FLERR,"Could not find compute ID for temperature bias"); + if (i < 0) + error->all(FLERR,"Could not find compute ID for temperature bias"); tbias = modify->compute[i]; if (tbias->tempflag == 0) error->all(FLERR,"Bias compute does not calculate temperature"); @@ -118,7 +121,12 @@ void ComputeTempAsphere::init() if (strcmp(tbias->style,"temp/region") == 0) tempbias = 2; else tempbias = 1; } +} +/* ---------------------------------------------------------------------- */ + +void ComputeTempAsphere::setup() +{ fix_dof = 0; for (int i = 0; i < modify->nfix; i++) fix_dof += modify->fix[i]->dof(igroup); diff --git a/src/ASPHERE/compute_temp_asphere.h b/src/ASPHERE/compute_temp_asphere.h index ee7e73b435..544d811355 100755 --- a/src/ASPHERE/compute_temp_asphere.h +++ b/src/ASPHERE/compute_temp_asphere.h @@ -29,6 +29,7 @@ class ComputeTempAsphere : public Compute { ComputeTempAsphere(class LAMMPS *, int, char **); ~ComputeTempAsphere(); void init(); + void setup(); double compute_scalar(); void compute_vector(); diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index d54cd05ba3..dae552da37 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -1131,12 +1131,13 @@ void FixRigid::pre_neighbor() } /* ---------------------------------------------------------------------- - count # of degrees-of-freedom removed by rigid bodies for atoms in igroup + count # of DOF removed by rigid bodies for atoms in igroup + return total count of DOF ------------------------------------------------------------------------- */ -int FixRigid::dof(int igroup) +int FixRigid::dof(int tgroup) { - int groupbit = group->bitmask[igroup]; + int tgroupbit = group->bitmask[tgroup]; // nall = # of point particles in each rigid body // mall = # of finite-size particles in each rigid body @@ -1151,7 +1152,7 @@ int FixRigid::dof(int igroup) ncount[ibody] = mcount[ibody] = 0; for (int i = 0; i < nlocal; i++) - if (body[i] >= 0 && mask[i] & groupbit) { + if (body[i] >= 0 && mask[i] & tgroupbit) { if (extended && eflags[i]) mcount[body[i]]++; else ncount[body[i]]++; } diff --git a/src/compute.h b/src/compute.h index 3c770d8fb4..e7cb31bae1 100644 --- a/src/compute.h +++ b/src/compute.h @@ -90,6 +90,7 @@ class Compute : protected Pointers { virtual void init() = 0; virtual void init_list(int, class NeighList *) {} + virtual void setup() {} virtual double compute_scalar() {return 0.0;} virtual void compute_vector() {} virtual void compute_array() {} diff --git a/src/compute_temp.cpp b/src/compute_temp.cpp index 0ce6b285ff..f58c2fadf0 100644 --- a/src/compute_temp.cpp +++ b/src/compute_temp.cpp @@ -50,7 +50,7 @@ ComputeTemp::~ComputeTemp() /* ---------------------------------------------------------------------- */ -void ComputeTemp::init() +void ComputeTemp::setup() { fix_dof = 0; for (int i = 0; i < modify->nfix; i++) diff --git a/src/compute_temp.h b/src/compute_temp.h index 79533e9764..ccd35f119a 100644 --- a/src/compute_temp.h +++ b/src/compute_temp.h @@ -28,7 +28,8 @@ class ComputeTemp : public Compute { public: ComputeTemp(class LAMMPS *, int, char **); virtual ~ComputeTemp(); - void init(); + void init() {} + void setup(); double compute_scalar(); void compute_vector(); diff --git a/src/compute_temp_com.cpp b/src/compute_temp_com.cpp index ef51d122d4..2d2537f11e 100644 --- a/src/compute_temp_com.cpp +++ b/src/compute_temp_com.cpp @@ -54,13 +54,18 @@ ComputeTempCOM::~ComputeTempCOM() /* ---------------------------------------------------------------------- */ void ComputeTempCOM::init() +{ + masstotal = group->mass(igroup); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeTempCOM::setup() { fix_dof = 0; for (int i = 0; i < modify->nfix; i++) fix_dof += modify->fix[i]->dof(igroup); dof_compute(); - - masstotal = group->mass(igroup); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_temp_com.h b/src/compute_temp_com.h index f940ba22f5..f59a267d36 100644 --- a/src/compute_temp_com.h +++ b/src/compute_temp_com.h @@ -29,6 +29,7 @@ class ComputeTempCOM : public Compute { ComputeTempCOM(class LAMMPS *, int, char **); ~ComputeTempCOM(); void init(); + void setup(); double compute_scalar(); void compute_vector(); diff --git a/src/compute_temp_deform.cpp b/src/compute_temp_deform.cpp index 611cbdd3be..536bdfbb9a 100644 --- a/src/compute_temp_deform.cpp +++ b/src/compute_temp_deform.cpp @@ -67,11 +67,6 @@ void ComputeTempDeform::init() { int i; - fix_dof = 0; - for (i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); - dof_compute(); - // check fix deform remap settings for (i = 0; i < modify->nfix; i++) @@ -89,6 +84,16 @@ void ComputeTempDeform::init() /* ---------------------------------------------------------------------- */ +void ComputeTempDeform::setup() +{ + fix_dof = 0; + for (int i = 0; i < modify->nfix; i++) + fix_dof += modify->fix[i]->dof(igroup); + dof_compute(); +} + +/* ---------------------------------------------------------------------- */ + void ComputeTempDeform::dof_compute() { double natoms = group->count(igroup); diff --git a/src/compute_temp_deform.h b/src/compute_temp_deform.h index 3400ed6db4..92052d986f 100644 --- a/src/compute_temp_deform.h +++ b/src/compute_temp_deform.h @@ -29,6 +29,7 @@ class ComputeTempDeform : public Compute { ComputeTempDeform(class LAMMPS *, int, char **); virtual ~ComputeTempDeform(); void init(); + void setup(); virtual double compute_scalar(); virtual void compute_vector(); diff --git a/src/compute_temp_partial.cpp b/src/compute_temp_partial.cpp index dbc81bfe0d..99181a56b1 100644 --- a/src/compute_temp_partial.cpp +++ b/src/compute_temp_partial.cpp @@ -61,7 +61,7 @@ ComputeTempPartial::~ComputeTempPartial() /* ---------------------------------------------------------------------- */ -void ComputeTempPartial::init() +void ComputeTempPartial::setup() { fix_dof = 0; for (int i = 0; i < modify->nfix; i++) diff --git a/src/compute_temp_partial.h b/src/compute_temp_partial.h index 97ac60541e..a6178e4ae3 100644 --- a/src/compute_temp_partial.h +++ b/src/compute_temp_partial.h @@ -28,7 +28,8 @@ class ComputeTempPartial : public Compute { public: ComputeTempPartial(class LAMMPS *, int, char **); virtual ~ComputeTempPartial(); - void init(); + void init() {} + void setup(); double compute_scalar(); void compute_vector(); diff --git a/src/compute_temp_profile.cpp b/src/compute_temp_profile.cpp index 6e0470020c..eaf73d5ba8 100644 --- a/src/compute_temp_profile.cpp +++ b/src/compute_temp_profile.cpp @@ -187,6 +187,16 @@ void ComputeTempProfile::init() /* ---------------------------------------------------------------------- */ +void ComputeTempProfile::setup() +{ + fix_dof = 0; + for (int i = 0; i < modify->nfix; i++) + fix_dof += modify->fix[i]->dof(igroup); + dof_compute(); +} + +/* ---------------------------------------------------------------------- */ + void ComputeTempProfile::dof_compute() { double natoms = group->count(igroup); diff --git a/src/compute_temp_profile.h b/src/compute_temp_profile.h index 9aec072da1..aad7a1f2c4 100644 --- a/src/compute_temp_profile.h +++ b/src/compute_temp_profile.h @@ -29,6 +29,7 @@ class ComputeTempProfile : public Compute { ComputeTempProfile(class LAMMPS *, int, char **); ~ComputeTempProfile(); void init(); + void setup(); double compute_scalar(); void compute_vector(); void compute_array(); diff --git a/src/compute_temp_ramp.cpp b/src/compute_temp_ramp.cpp index 4bd073d642..b96467da6d 100644 --- a/src/compute_temp_ramp.cpp +++ b/src/compute_temp_ramp.cpp @@ -118,7 +118,7 @@ ComputeTempRamp::~ComputeTempRamp() /* ---------------------------------------------------------------------- */ -void ComputeTempRamp::init() +void ComputeTempRamp::setup() { fix_dof = 0; for (int i = 0; i < modify->nfix; i++) diff --git a/src/compute_temp_ramp.h b/src/compute_temp_ramp.h index b470011dd7..7e0a8663c8 100644 --- a/src/compute_temp_ramp.h +++ b/src/compute_temp_ramp.h @@ -28,7 +28,8 @@ class ComputeTempRamp : public Compute { public: ComputeTempRamp(class LAMMPS *, int, char **); ~ComputeTempRamp(); - void init(); + void init() {} + void setup(); double compute_scalar(); void compute_vector(); diff --git a/src/compute_temp_region.cpp b/src/compute_temp_region.cpp index 69f5f3909e..c89c0a10ae 100644 --- a/src/compute_temp_region.cpp +++ b/src/compute_temp_region.cpp @@ -69,7 +69,12 @@ void ComputeTempRegion::init() iregion = domain->find_region(idregion); if (iregion == -1) error->all(FLERR,"Region ID for compute temp/region does not exist"); +} +/* ---------------------------------------------------------------------- */ + +void ComputeTempRegion::setup() +{ dof = 0.0; } diff --git a/src/compute_temp_region.h b/src/compute_temp_region.h index ce1df7a041..d7808fb0bd 100644 --- a/src/compute_temp_region.h +++ b/src/compute_temp_region.h @@ -29,6 +29,7 @@ class ComputeTempRegion : public Compute { ComputeTempRegion(class LAMMPS *, int, char **); virtual ~ComputeTempRegion(); void init(); + void setup(); virtual double compute_scalar(); virtual void compute_vector(); diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index 2c4b4c420d..6a376f20fc 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -102,7 +102,12 @@ void ComputeTempSphere::init() if (strcmp(tbias->style,"temp/region") == 0) tempbias = 2; else tempbias = 1; } +} +/* ---------------------------------------------------------------------- */ + +void ComputeTempSphere::setup() +{ fix_dof = 0; for (int i = 0; i < modify->nfix; i++) fix_dof += modify->fix[i]->dof(igroup); diff --git a/src/compute_temp_sphere.h b/src/compute_temp_sphere.h index 3b5916f278..7d4f34b8f4 100644 --- a/src/compute_temp_sphere.h +++ b/src/compute_temp_sphere.h @@ -29,6 +29,7 @@ class ComputeTempSphere : public Compute { ComputeTempSphere(class LAMMPS *, int, char **); ~ComputeTempSphere(); void init(); + void setup(); double compute_scalar(); void compute_vector(); diff --git a/src/modify.cpp b/src/modify.cpp index 10e7478f05..47b382116d 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -221,7 +221,7 @@ void Modify::init() } /* ---------------------------------------------------------------------- - setup for run, calls setup() of all fixes + setup for run, calls setup() of all fixes and computes called from Verlet, RESPA, Min ------------------------------------------------------------------------- */ @@ -231,6 +231,11 @@ void Modify::setup(int vflag) for (int i = 0; i < nfix; i++) fix[i]->setup(vflag); else if (update->whichflag == 2) for (int i = 0; i < nfix; i++) fix[i]->min_setup(vflag); + + // call computes after fixes + // fix rigid dof() can't be called by temperature computes at init + + for (int i = 0; i < ncompute; i++) compute[i]->setup(); } /* ----------------------------------------------------------------------