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

This commit is contained in:
sjplimp
2008-03-20 14:53:21 +00:00
parent 848aece2b4
commit ebe2ee9bac
28 changed files with 833 additions and 99 deletions

View File

@ -45,7 +45,6 @@ ComputeTempCOM::ComputeTempCOM(LAMMPS *lmp, int narg, char **arg) :
extvector = 1;
tempflag = 1;
tempbias = 1;
vbias[0] = vbias[1] = vbias[2] = 0.0;
vector = new double[6];
}
@ -66,6 +65,12 @@ void ComputeTempCOM::init()
fix_dof += modify->fix[i]->dof(igroup);
recount();
masstotal = group->mass(igroup);
if (id_bias) {
int i = modify->find_compute(id_bias);
if (i < 0) error->all("Could not find compute ID for temperature bias");
tbias = modify->compute[i];
}
}
/* ---------------------------------------------------------------------- */
@ -87,6 +92,12 @@ double ComputeTempCOM::compute_scalar()
invoked |= INVOKED_SCALAR;
if (tbias) {
if (!(tbias->invoked & INVOKED_SCALAR))
double tmp = tbias->compute_scalar();
tbias->remove_bias_all();
}
if (dynamic) masstotal = group->mass(igroup);
group->vcm(igroup,masstotal,vbias);
@ -111,6 +122,8 @@ double ComputeTempCOM::compute_scalar()
vthermal[2]*vthermal[2]) * rmass[i];
}
if (tbias) tbias->restore_bias_all();
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
if (dynamic) recount();
scalar *= tfactor;
@ -126,6 +139,11 @@ void ComputeTempCOM::compute_vector()
invoked |= INVOKED_VECTOR;
if (tbias) {
if (!(tbias->invoked & INVOKED_VECTOR)) tbias->compute_vector();
tbias->remove_bias_all();
}
if (dynamic) masstotal = group->mass(igroup);
group->vcm(igroup,masstotal,vbias);
@ -156,15 +174,74 @@ void ComputeTempCOM::compute_vector()
t[5] += massone * vthermal[1]*vthermal[2];
}
if (tbias) tbias->restore_bias_all();
MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world);
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
}
/* ---------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
remove velocity bias from atom I to leave thermal velocity
------------------------------------------------------------------------- */
void ComputeTempCOM::remove_bias(int i, double *v)
{
v[0] = v[0] - vbias[0];
v[1] = v[1] - vbias[1];
v[2] = v[2] - vbias[2];
if (tbias) tbias->remove_bias(i,v);
v[0] -= vbias[0];
v[1] -= vbias[1];
v[2] -= vbias[2];
}
/* ----------------------------------------------------------------------
remove velocity bias from all atoms to leave thermal velocity
------------------------------------------------------------------------- */
void ComputeTempCOM::remove_bias_all()
{
if (tbias) tbias->remove_bias_all();
double **v = atom->v;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
v[i][0] -= vbias[0];
v[i][1] -= vbias[1];
v[i][2] -= vbias[2];
}
}
/* ----------------------------------------------------------------------
add back in velocity bias to atom I removed by remove_bias()
assume remove_bias() was previously called
------------------------------------------------------------------------- */
void ComputeTempCOM::restore_bias(double *v)
{
v[0] += vbias[0];
v[1] += vbias[1];
v[2] += vbias[2];
if (tbias) tbias->restore_bias(v);
}
/* ----------------------------------------------------------------------
add back in velocity bias to all atoms removed by remove_bias_all()
assume remove_bias_all() was previously called
------------------------------------------------------------------------- */
void ComputeTempCOM::restore_bias_all()
{
double **v = atom->v;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
v[i][0] += vbias[0];
v[i][1] += vbias[1];
v[i][2] += vbias[2];
}
if (tbias) tbias->restore_bias_all();
}