git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13344 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2015-03-31 18:47:58 +00:00
parent cfc5c8b277
commit 269bff4b14
11 changed files with 33 additions and 62 deletions

View File

@ -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
------------------------------------------------------------------------- */

View File

@ -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();
};
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
------------------------------------------------------------------------- */

View File

@ -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;