diff --git a/src/compute.cpp b/src/compute.cpp index 026dbe4103..328573d449 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -143,6 +143,21 @@ void Compute::modify_params(int narg, char **arg) } } +/* ---------------------------------------------------------------------- + calculate adjustment in DOF due to fixes +------------------------------------------------------------------------- */ + +void Compute::adjust_dof_fix() +{ + Fix **fix = modify->fix; + int nfix = modify->nfix; + + fix_dof = 0; + for (int i = 0; i < nfix; i++) + if (fix[i]->dof_flag) + fix_dof += fix[i]->dof(igroup); +} + /* ---------------------------------------------------------------------- reset extra_dof to its default value ------------------------------------------------------------------------- */ diff --git a/src/compute.h b/src/compute.h index 281010c1ee..ce0e7dc9e8 100644 --- a/src/compute.h +++ b/src/compute.h @@ -161,6 +161,10 @@ class Compute : protected Pointers { ubuf(int64_t arg) : i(arg) {} ubuf(int arg) : i(arg) {} }; + + // private methods + + void adjust_dof_fix(); }; } diff --git a/src/compute_temp.cpp b/src/compute_temp.cpp index f5f28df80f..4ad653b2f9 100644 --- a/src/compute_temp.cpp +++ b/src/compute_temp.cpp @@ -18,7 +18,6 @@ #include "update.h" #include "force.h" #include "domain.h" -#include "modify.h" #include "comm.h" #include "group.h" #include "error.h" @@ -61,7 +60,7 @@ void ComputeTemp::setup() void ComputeTemp::dof_compute() { - fix_dof = modify->adjust_dof_fix(igroup); + adjust_dof_fix(); double natoms = group->count(igroup); dof = domain->dimension * natoms; dof -= extra_dof + fix_dof; @@ -97,7 +96,7 @@ double ComputeTemp::compute_scalar() MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); if (dynamic) dof_compute(); - if (tfactor == 0.0 && scalar != 0.0) + if (tfactor == 0.0 && atom->natoms != 0) error->all(FLERR,"Temperature compute degrees of freedom < 0"); scalar *= tfactor; return scalar; diff --git a/src/compute_temp_com.cpp b/src/compute_temp_com.cpp index 8d8b3fe1fe..8e0db3595d 100644 --- a/src/compute_temp_com.cpp +++ b/src/compute_temp_com.cpp @@ -20,7 +20,6 @@ #include "force.h" #include "group.h" #include "domain.h" -#include "modify.h" #include "lattice.h" #include "error.h" @@ -70,7 +69,7 @@ void ComputeTempCOM::setup() void ComputeTempCOM::dof_compute() { - fix_dof = modify->adjust_dof_fix(igroup); + adjust_dof_fix(); double natoms = group->count(igroup); int nper = domain->dimension; dof = nper * natoms; @@ -113,7 +112,7 @@ double ComputeTempCOM::compute_scalar() MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); if (dynamic) dof_compute(); - if (tfactor == 0.0 && scalar != 0.0) + if (tfactor == 0.0 && atom->natoms != 0) error->all(FLERR,"Temperature compute degrees of freedom < 0"); scalar *= tfactor; return scalar; diff --git a/src/compute_temp_deform.cpp b/src/compute_temp_deform.cpp index 50b7dd7344..e608ba3cea 100644 --- a/src/compute_temp_deform.cpp +++ b/src/compute_temp_deform.cpp @@ -95,7 +95,7 @@ void ComputeTempDeform::setup() void ComputeTempDeform::dof_compute() { - fix_dof = modify->adjust_dof_fix(igroup); + adjust_dof_fix(); double natoms = group->count(igroup); dof = domain->dimension * natoms; dof -= extra_dof + fix_dof; @@ -148,7 +148,7 @@ double ComputeTempDeform::compute_scalar() MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); if (dynamic) dof_compute(); - if (tfactor == 0.0 && scalar != 0.0) + if (tfactor == 0.0 && atom->natoms != 0) error->all(FLERR,"Temperature compute degrees of freedom < 0"); scalar *= tfactor; return scalar; diff --git a/src/compute_temp_partial.cpp b/src/compute_temp_partial.cpp index 7fdd0c30d0..29525d3e80 100644 --- a/src/compute_temp_partial.cpp +++ b/src/compute_temp_partial.cpp @@ -18,7 +18,6 @@ #include "update.h" #include "force.h" #include "domain.h" -#include "modify.h" #include "group.h" #include "memory.h" #include "error.h" @@ -74,7 +73,7 @@ void ComputeTempPartial::setup() void ComputeTempPartial::dof_compute() { - fix_dof = modify->adjust_dof_fix(igroup); + adjust_dof_fix(); double natoms = group->count(igroup); int nper = xflag+yflag+zflag; dof = nper * natoms; @@ -120,7 +119,7 @@ double ComputeTempPartial::compute_scalar() MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); if (dynamic) dof_compute(); - if (tfactor == 0.0 && scalar != 0.0) + if (tfactor == 0.0 && atom->natoms != 0) error->all(FLERR,"Temperature compute degrees of freedom < 0"); scalar *= tfactor; return scalar; diff --git a/src/compute_temp_profile.cpp b/src/compute_temp_profile.cpp index b6905946ab..2b13dd0927 100644 --- a/src/compute_temp_profile.cpp +++ b/src/compute_temp_profile.cpp @@ -19,7 +19,6 @@ #include "update.h" #include "force.h" #include "group.h" -#include "modify.h" #include "fix.h" #include "domain.h" #include "memory.h" @@ -195,7 +194,7 @@ void ComputeTempProfile::setup() void ComputeTempProfile::dof_compute() { - fix_dof = modify->adjust_dof_fix(igroup); + adjust_dof_fix(); double natoms = group->count(igroup); int nper = domain->dimension; dof = nper * natoms; @@ -243,7 +242,7 @@ double ComputeTempProfile::compute_scalar() MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); if (dynamic) dof_compute(); - if (tfactor == 0.0 && scalar != 0.0) + if (tfactor == 0.0 && atom->natoms != 0) error->all(FLERR,"Temperature compute degrees of freedom < 0"); scalar *= tfactor; return scalar; diff --git a/src/compute_temp_ramp.cpp b/src/compute_temp_ramp.cpp index 04f714ad6f..76b47a39a2 100644 --- a/src/compute_temp_ramp.cpp +++ b/src/compute_temp_ramp.cpp @@ -19,7 +19,6 @@ #include "update.h" #include "force.h" #include "group.h" -#include "modify.h" #include "fix.h" #include "domain.h" #include "lattice.h" @@ -126,7 +125,7 @@ void ComputeTempRamp::setup() void ComputeTempRamp::dof_compute() { - fix_dof = modify->adjust_dof_fix(igroup); + adjust_dof_fix(); double natoms = group->count(igroup); int nper = domain->dimension; dof = nper * natoms; @@ -172,7 +171,7 @@ double ComputeTempRamp::compute_scalar() MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); if (dynamic) dof_compute(); - if (tfactor == 0.0 && scalar != 0.0) + if (tfactor == 0.0 && atom->natoms != 0) error->all(FLERR,"Temperature compute degrees of freedom < 0"); scalar *= tfactor; return scalar; diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index b7ca03837a..70f13d40b0 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -124,7 +124,7 @@ void ComputeTempSphere::dof_compute() { int count,count_all; - fix_dof = modify->adjust_dof_fix(igroup); + adjust_dof_fix(); // 6 or 3 dof for extended/point particles for 3d // 3 or 2 dof for extended/point particles for 2d @@ -252,7 +252,7 @@ double ComputeTempSphere::compute_scalar() MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); if (dynamic || tempbias == 2) dof_compute(); - if (tfactor == 0.0 && scalar != 0.0) + if (tfactor == 0.0 && atom->natoms != 0) error->all(FLERR,"Temperature compute degrees of freedom < 0"); scalar *= tfactor; return scalar; diff --git a/src/modify.cpp b/src/modify.cpp index 80b7b624ff..0745c1c6ca 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -64,7 +64,6 @@ Modify::Modify(LAMMPS *lmp) : Pointers(lmp) end_of_step_every = NULL; - list_dofflag = NULL; list_timeflag = NULL; nfix_restart_global = 0; @@ -136,7 +135,6 @@ Modify::~Modify() delete [] list_min_energy; delete [] end_of_step_every; - delete [] list_dofflag; delete [] list_timeflag; restart_deallocate(); @@ -186,8 +184,6 @@ void Modify::init() list_init(MIN_POST_FORCE,n_min_post_force,list_min_post_force); list_init(MIN_ENERGY,n_min_energy,list_min_energy); - list_init_dofflag(n_dofflag,list_dofflag); - // init each fix // not sure if now needs to come before compute init // used to b/c temperature computes called fix->dof() in their init, @@ -902,20 +898,6 @@ int Modify::check_package(const char *package_fix_name) return 1; } -/* ---------------------------------------------------------------------- - loop over fixes with dof() method - accumulate # of DOFs removed by fixes and return it - called by temperature computes -------------------------------------------------------------------------- */ - -int Modify::adjust_dof_fix(int igroup) -{ - int n = 0; - for (int ifix = 0; ifix < n_dofflag; ifix++) - n += fix[list_dofflag[ifix]]->dof(igroup); - return n; -} - /* ---------------------------------------------------------------------- add a new compute ------------------------------------------------------------------------- */ @@ -1300,27 +1282,6 @@ void Modify::list_init_thermo_energy(int mask, int &n, int *&list) if (fmask[i] & mask && fix[i]->thermo_energy) list[n++] = i; } - -/* ---------------------------------------------------------------------- - create list of fix indices for thermo energy fixes - only added to list if fix has THERMO_ENERGY mask - and its thermo_energy flag was set via fix_modify -------------------------------------------------------------------------- */ - -void Modify::list_init_dofflag(int &n, int *&list) -{ - delete [] list; - - n = 0; - for (int i = 0; i < nfix; i++) - if (fix[i]->dof_flag) n++; - list = new int[n]; - - n = 0; - for (int i = 0; i < nfix; i++) - if (fix[i]->dof_flag) list[n++] = i; -} - /* ---------------------------------------------------------------------- create list of compute indices for computes which store invocation times ------------------------------------------------------------------------- */ diff --git a/src/modify.h b/src/modify.h index fb4a8f5057..be2fe286f8 100644 --- a/src/modify.h +++ b/src/modify.h @@ -88,7 +88,6 @@ class Modify : protected Pointers { void delete_fix(const char *); int find_fix(const char *); int check_package(const char *); - int adjust_dof_fix(int); void add_compute(int, char **, int trysuffix=0); void modify_compute(int, char **); @@ -122,9 +121,6 @@ class Modify : protected Pointers { int *end_of_step_every; - int n_dofflag; // list of fixes with dof() method - int *list_dofflag; - int n_timeflag; // list of computes that store time invocation int *list_timeflag;