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

@ -62,6 +62,13 @@ void ComputeTempSphere::init()
fix_dof += modify->fix[i]->dof(igroup);
recount();
if (id_bias) {
tempbias = 1;
int i = modify->find_compute(id_bias);
if (i < 0) error->all("Could not find compute ID for temperature bias");
tbias = modify->compute[i];
} else tempbias = 0;
if (atom->mass) {
double *mass = atom->mass;
double **shape = atom->shape;
@ -92,6 +99,12 @@ double ComputeTempSphere::compute_scalar()
{
invoked |= INVOKED_SCALAR;
if (tbias) {
if (!(tbias->invoked & INVOKED_SCALAR))
double tmp = tbias->compute_scalar();
tbias->remove_bias_all();
}
double **v = atom->v;
double **omega = atom->omega;
double *mass = atom->mass;
@ -120,6 +133,8 @@ double ComputeTempSphere::compute_scalar()
}
}
if (tbias) tbias->restore_bias_all();
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
if (dynamic) recount();
scalar *= tfactor;
@ -134,6 +149,11 @@ void ComputeTempSphere::compute_vector()
invoked |= INVOKED_VECTOR;
if (tbias) {
if (!(tbias->invoked & INVOKED_VECTOR)) tbias->compute_vector();
tbias->remove_bias_all();
}
double **v = atom->v;
double **omega = atom->omega;
double *mass = atom->mass;
@ -186,6 +206,47 @@ void ComputeTempSphere::compute_vector()
}
}
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 ComputeTempSphere::remove_bias(int i, double *v)
{
if (tbias) tbias->remove_bias(i,v);
}
/* ----------------------------------------------------------------------
remove velocity bias from all atoms to leave thermal velocity
------------------------------------------------------------------------- */
void ComputeTempSphere::remove_bias_all()
{
if (tbias) tbias->remove_bias_all();
}
/* ----------------------------------------------------------------------
add back in velocity bias to atom I removed by remove_bias()
assume remove_bias() was previously called
------------------------------------------------------------------------- */
void ComputeTempSphere::restore_bias(double *v)
{
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 ComputeTempSphere::restore_bias_all()
{
if (tbias) tbias->restore_bias_all();
}