git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1656 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -37,7 +37,8 @@ using namespace LAMMPS_NS;
|
||||
ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute temp command");
|
||||
if (narg != 3 || narg != 4)
|
||||
error->all("Illegal compute temp/asphere command");
|
||||
|
||||
if (!atom->quat_flag || !atom->angmom_flag)
|
||||
error->all("Compute temp/asphere requires atom attributes quat, angmom");
|
||||
@ -48,6 +49,15 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
extvector = 1;
|
||||
tempflag = 1;
|
||||
|
||||
tempbias = 0;
|
||||
id_bias = NULL;
|
||||
if (narg == 4) {
|
||||
tempbias = 1;
|
||||
int n = strlen(arg[3]) + 1;
|
||||
id_bias = new char[n];
|
||||
strcpy(id_bias,arg[3]);
|
||||
}
|
||||
|
||||
vector = new double[6];
|
||||
inertia =
|
||||
memory->create_2d_double_array(atom->ntypes+1,3,"fix_temp_sphere:inertia");
|
||||
@ -57,6 +67,7 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
ComputeTempAsphere::~ComputeTempAsphere()
|
||||
{
|
||||
delete [] id_bias;
|
||||
delete [] vector;
|
||||
memory->destroy_2d_double_array(inertia);
|
||||
}
|
||||
@ -65,20 +76,25 @@ ComputeTempAsphere::~ComputeTempAsphere()
|
||||
|
||||
void ComputeTempAsphere::init()
|
||||
{
|
||||
if (tempbias) {
|
||||
int i = modify->find_compute(id_bias);
|
||||
if (i < 0) error->all("Could not find compute ID for temperature bias");
|
||||
tbias = modify->compute[i];
|
||||
if (tbias->tempflag == 0)
|
||||
error->all("Bias compute does not calculate temperature");
|
||||
if (tbias->tempbias == 0)
|
||||
error->all("Bias compute does not calculate a velocity bias");
|
||||
if (tbias->igroup != igroup)
|
||||
error->all("Bias compute group does not match compute group");
|
||||
tbias->init();
|
||||
if (strcmp(tbias->style,"temp/region") == 0) tempbias = 2;
|
||||
}
|
||||
|
||||
fix_dof = 0;
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
dof_compute();
|
||||
|
||||
tempbias = 0;
|
||||
tbias = NULL;
|
||||
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];
|
||||
}
|
||||
|
||||
calculate_inertia();
|
||||
}
|
||||
|
||||
@ -89,10 +105,10 @@ void ComputeTempAsphere::dof_compute()
|
||||
double natoms = group->count(igroup);
|
||||
int dimension = domain->dimension;
|
||||
dof = dimension * natoms;
|
||||
if (tbias) dof -= tbias->dof_remove(natoms);
|
||||
dof -= extra_dof + fix_dof;
|
||||
|
||||
// add rotational degrees of freedom
|
||||
if (tempbias == 1) dof -= tbias->dof_remove(-1) * natoms;
|
||||
|
||||
// rotational degrees of freedom
|
||||
// 0 for sphere, 2 for uniaxial, 3 for biaxial
|
||||
|
||||
double **shape = atom->shape;
|
||||
@ -101,27 +117,30 @@ void ComputeTempAsphere::dof_compute()
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
int itype;
|
||||
int rot_dof = 0;
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
if (tempbias == 2 && tbias->dof_remove(i)) continue;
|
||||
itype = type[i];
|
||||
if (dimension == 2) {
|
||||
if (shape[itype][0] == shape[itype][1]) continue;
|
||||
else rot_dof += 1;
|
||||
else count++;
|
||||
} else {
|
||||
if (shape[itype][0] == shape[itype][1] &&
|
||||
shape[itype][1] == shape[itype][2]) continue;
|
||||
else if (shape[itype][0] == shape[itype][1] ||
|
||||
shape[itype][1] == shape[itype][2] ||
|
||||
shape[itype][0] == shape[itype][2]) rot_dof += 2;
|
||||
else rot_dof += 3;
|
||||
shape[itype][0] == shape[itype][2]) count += 2;
|
||||
else count += 3;
|
||||
}
|
||||
}
|
||||
|
||||
int rot_total;
|
||||
MPI_Allreduce(&rot_dof,&rot_total,1,MPI_INT,MPI_SUM,world);
|
||||
dof += rot_total;
|
||||
int count_all;
|
||||
MPI_Allreduce(&count,&count_all,1,MPI_INT,MPI_SUM,world);
|
||||
dof += count_all;
|
||||
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
}
|
||||
@ -132,7 +151,7 @@ double ComputeTempAsphere::compute_scalar()
|
||||
{
|
||||
invoked |= INVOKED_SCALAR;
|
||||
|
||||
if (tbias) {
|
||||
if (tempbias) {
|
||||
if (!(tbias->invoked & INVOKED_SCALAR))
|
||||
double tmp = tbias->compute_scalar();
|
||||
tbias->remove_bias_all();
|
||||
@ -179,10 +198,10 @@ double ComputeTempAsphere::compute_scalar()
|
||||
}
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
if (tempbias) tbias->restore_bias_all();
|
||||
|
||||
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
if (dynamic || tbias) dof_compute();
|
||||
if (dynamic || tempbias == 2) dof_compute();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
@ -195,7 +214,7 @@ void ComputeTempAsphere::compute_vector()
|
||||
|
||||
invoked |= INVOKED_VECTOR;
|
||||
|
||||
if (tbias) {
|
||||
if (tempbias) {
|
||||
if (!(tbias->invoked & INVOKED_VECTOR)) tbias->compute_vector();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
@ -246,7 +265,7 @@ void ComputeTempAsphere::compute_vector()
|
||||
t[5] += inertia[itype][2]*wbody[1]*wbody[2];
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
if (tempbias) tbias->restore_bias_all();
|
||||
|
||||
MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world);
|
||||
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
|
||||
@ -280,15 +299,6 @@ void ComputeTempAsphere::remove_bias(int i, double *v)
|
||||
if (tbias) tbias->remove_bias(i,v);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
remove velocity bias from all atoms to leave thermal velocity
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempAsphere::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
|
||||
@ -298,13 +308,3 @@ void ComputeTempAsphere::restore_bias(int i, double *v)
|
||||
{
|
||||
if (tbias) tbias->restore_bias(i,v);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
add back in velocity bias to all atoms removed by remove_bias_all()
|
||||
assume remove_bias_all() was previously called
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempAsphere::restore_bias_all()
|
||||
{
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
}
|
||||
|
||||
@ -27,15 +27,13 @@ class ComputeTempAsphere : public Compute {
|
||||
void compute_vector();
|
||||
|
||||
void remove_bias(int, double *);
|
||||
void remove_bias_all();
|
||||
void restore_bias(int, double *);
|
||||
void restore_bias_all();
|
||||
|
||||
private:
|
||||
int fix_dof;
|
||||
double tfactor;
|
||||
double **inertia;
|
||||
|
||||
char *id_bias;
|
||||
Compute *tbias; // ptr to additional bias compute
|
||||
|
||||
void dof_compute();
|
||||
|
||||
@ -62,9 +62,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
||||
scalar_flag = vector_flag = peratom_flag = 0;
|
||||
tempflag = pressflag = peflag = 0;
|
||||
pressatomflag = peatomflag = 0;
|
||||
|
||||
tempbias = 0;
|
||||
id_bias = NULL;
|
||||
|
||||
id_pre = NULL;
|
||||
timeflag = 0;
|
||||
@ -90,7 +88,6 @@ Compute::~Compute()
|
||||
{
|
||||
delete [] id;
|
||||
delete [] style;
|
||||
delete [] id_bias;
|
||||
delete [] id_pre;
|
||||
|
||||
memory->sfree(tlist);
|
||||
@ -120,21 +117,6 @@ void Compute::modify_params(int narg, char **arg)
|
||||
else if (strcmp(arg[iarg+1],"yes") == 0) thermoflag = 1;
|
||||
else error->all("Illegal compute_modify command");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"bias") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal compute_modify command");
|
||||
delete [] id_bias;
|
||||
if (strcmp(arg[iarg+1],"NULL") == 0) id_bias = NULL;
|
||||
else {
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
id_bias = new char[n];
|
||||
strcpy(id_bias,arg[iarg+1]);
|
||||
int icompute = modify->find_compute(id_bias);
|
||||
if (icompute < 0) error->all("Could not find compute_modify bias ID");
|
||||
Compute *temperature = modify->compute[icompute];
|
||||
if (temperature->igroup != igroup && comm->me == 0)
|
||||
error->warning("Group for compute_modify bias != compute group");
|
||||
}
|
||||
iarg += 2;
|
||||
} else error->all("Illegal compute_modify command");
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,9 +45,7 @@ class Compute : protected Pointers {
|
||||
int peflag; // 1 if Compute calculates PE (uses Force energies)
|
||||
int peatomflag; // 1 if Compute calculates per-atom PE
|
||||
|
||||
int tempbias; // 0/1 if Compute temp includes
|
||||
// self or extra bias via compute_modify
|
||||
char *id_bias; // ID of extra Compute temp that adds bias
|
||||
int tempbias; // 0/1 if Compute temp includes self/extra bias
|
||||
|
||||
char *id_pre; // ID of pre-compute the Compute may store
|
||||
|
||||
@ -77,7 +75,7 @@ class Compute : protected Pointers {
|
||||
virtual int pack_reverse_comm(int, int, double *) {return 0;}
|
||||
virtual void unpack_reverse_comm(int, int *, double *) {}
|
||||
|
||||
virtual double dof_remove(double &) {return 0.0;}
|
||||
virtual int dof_remove(int) {return 0;}
|
||||
virtual void remove_bias(int, double *) {}
|
||||
virtual void remove_bias_all() {}
|
||||
virtual void restore_bias(int, double *) {}
|
||||
|
||||
@ -38,6 +38,7 @@ ComputeTemp::ComputeTemp(LAMMPS *lmp, int narg, char **arg) :
|
||||
extscalar = 0;
|
||||
extvector = 1;
|
||||
tempflag = 1;
|
||||
tempbias = 0;
|
||||
|
||||
vector = new double[6];
|
||||
}
|
||||
@ -57,15 +58,6 @@ void ComputeTemp::init()
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
dof_compute();
|
||||
|
||||
tempbias = 0;
|
||||
tbias = NULL;
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -74,7 +66,6 @@ void ComputeTemp::dof_compute()
|
||||
{
|
||||
double natoms = group->count(igroup);
|
||||
dof = domain->dimension * natoms;
|
||||
if (tbias) dof -= tbias->dof_remove(natoms);
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0.0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
@ -86,12 +77,6 @@ double ComputeTemp::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 *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
@ -112,10 +97,8 @@ double ComputeTemp::compute_scalar()
|
||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * rmass[i];
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
|
||||
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
if (dynamic || tbias) dof_compute();
|
||||
if (dynamic) dof_compute();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
@ -128,11 +111,6 @@ void ComputeTemp::compute_vector()
|
||||
|
||||
invoked |= INVOKED_VECTOR;
|
||||
|
||||
if (tbias) {
|
||||
if (!(tbias->invoked & INVOKED_VECTOR)) tbias->compute_vector();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
@ -155,46 +133,6 @@ void ComputeTemp::compute_vector()
|
||||
t[5] += massone * v[i][1]*v[i][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 ComputeTemp::remove_bias(int i, double *v)
|
||||
{
|
||||
if (tbias) tbias->remove_bias(i,v);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
remove velocity bias from all atoms to leave thermal velocity
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTemp::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 ComputeTemp::restore_bias(int i, double *v)
|
||||
{
|
||||
if (tbias) tbias->restore_bias(i,v);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
add back in velocity bias to all atoms removed by remove_bias_all()
|
||||
assume remove_bias_all() was previously called
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTemp::restore_bias_all()
|
||||
{
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
}
|
||||
|
||||
@ -26,17 +26,10 @@ class ComputeTemp : public Compute {
|
||||
double compute_scalar();
|
||||
void compute_vector();
|
||||
|
||||
void remove_bias(int, double *);
|
||||
void remove_bias_all();
|
||||
void restore_bias(int, double *);
|
||||
void restore_bias_all();
|
||||
|
||||
private:
|
||||
int fix_dof;
|
||||
double tfactor;
|
||||
|
||||
Compute *tbias; // ptr to additional bias compute
|
||||
|
||||
void dof_compute();
|
||||
};
|
||||
|
||||
|
||||
@ -64,14 +64,8 @@ void ComputeTempCOM::init()
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
dof_compute();
|
||||
masstotal = group->mass(igroup);
|
||||
|
||||
tbias = NULL;
|
||||
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];
|
||||
}
|
||||
masstotal = group->mass(igroup);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -79,8 +73,8 @@ void ComputeTempCOM::init()
|
||||
void ComputeTempCOM::dof_compute()
|
||||
{
|
||||
double natoms = group->count(igroup);
|
||||
dof = domain->dimension * natoms;
|
||||
if (tbias) dof -= tbias->dof_remove(natoms);
|
||||
int nper = domain->dimension;
|
||||
dof = nper * natoms;
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
@ -94,12 +88,6 @@ 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);
|
||||
|
||||
@ -124,10 +112,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 || tbias) dof_compute();
|
||||
if (dynamic) dof_compute();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
@ -141,11 +127,6 @@ 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);
|
||||
|
||||
@ -176,8 +157,6 @@ 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;
|
||||
}
|
||||
@ -188,12 +167,9 @@ void ComputeTempCOM::compute_vector()
|
||||
|
||||
void ComputeTempCOM::remove_bias(int i, double *v)
|
||||
{
|
||||
if (tbias) tbias->remove_bias(i,v);
|
||||
if (atom->mask[i] & groupbit) {
|
||||
v[0] -= vbias[0];
|
||||
v[1] -= vbias[1];
|
||||
v[2] -= vbias[2];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -202,8 +178,6 @@ void ComputeTempCOM::remove_bias(int i, double *v)
|
||||
|
||||
void ComputeTempCOM::remove_bias_all()
|
||||
{
|
||||
if (tbias) tbias->remove_bias_all();
|
||||
|
||||
double **v = atom->v;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -223,12 +197,9 @@ void ComputeTempCOM::remove_bias_all()
|
||||
|
||||
void ComputeTempCOM::restore_bias(int i, double *v)
|
||||
{
|
||||
if (atom->mask[i] & groupbit) {
|
||||
v[0] += vbias[0];
|
||||
v[1] += vbias[1];
|
||||
v[2] += vbias[2];
|
||||
}
|
||||
if (tbias) tbias->restore_bias(i,v);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -248,6 +219,4 @@ void ComputeTempCOM::restore_bias_all()
|
||||
v[i][1] += vbias[1];
|
||||
v[i][2] += vbias[2];
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
}
|
||||
|
||||
@ -34,11 +34,10 @@ class ComputeTempCOM : public Compute {
|
||||
private:
|
||||
int fix_dof;
|
||||
double tfactor,masstotal;
|
||||
|
||||
double vbias[3]; // stored velocity bias for one atom
|
||||
Compute *tbias; // ptr to additional bias compute
|
||||
|
||||
void dof_compute();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -73,13 +73,6 @@ void ComputeTempDeform::init()
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
dof_compute();
|
||||
|
||||
tbias = NULL;
|
||||
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];
|
||||
}
|
||||
|
||||
// check fix deform remap settings
|
||||
|
||||
for (i = 0; i < modify->nfix; i++)
|
||||
@ -99,7 +92,6 @@ void ComputeTempDeform::dof_compute()
|
||||
{
|
||||
double natoms = group->count(igroup);
|
||||
dof = domain->dimension * natoms;
|
||||
if (tbias) dof -= tbias->dof_remove(natoms);
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
@ -113,12 +105,6 @@ double ComputeTempDeform::compute_scalar()
|
||||
|
||||
invoked |= INVOKED_SCALAR;
|
||||
|
||||
if (tbias) {
|
||||
if (!(tbias->invoked & INVOKED_SCALAR))
|
||||
double tmp = tbias->compute_scalar();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
@ -154,10 +140,8 @@ double ComputeTempDeform::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 || tbias) dof_compute();
|
||||
if (dynamic) dof_compute();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
@ -170,11 +154,6 @@ void ComputeTempDeform::compute_vector()
|
||||
|
||||
invoked |= INVOKED_VECTOR;
|
||||
|
||||
if (tbias) {
|
||||
if (!(tbias->invoked & INVOKED_VECTOR)) tbias->compute_vector();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
@ -210,8 +189,6 @@ void ComputeTempDeform::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 (int i = 0; i < 6; i++) vector[i] *= force->mvv2e;
|
||||
}
|
||||
@ -222,9 +199,6 @@ void ComputeTempDeform::compute_vector()
|
||||
|
||||
void ComputeTempDeform::remove_bias(int i, double *v)
|
||||
{
|
||||
if (tbias) tbias->remove_bias(i,v);
|
||||
|
||||
if (atom->mask[i] & groupbit) {
|
||||
double lamda[3];
|
||||
double *h_rate = domain->h_rate;
|
||||
double *h_ratelo = domain->h_ratelo;
|
||||
@ -237,7 +211,6 @@ void ComputeTempDeform::remove_bias(int i, double *v)
|
||||
v[0] -= vbias[0];
|
||||
v[1] -= vbias[1];
|
||||
v[2] -= vbias[2];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -246,8 +219,6 @@ void ComputeTempDeform::remove_bias(int i, double *v)
|
||||
|
||||
void ComputeTempDeform::remove_bias_all()
|
||||
{
|
||||
if (tbias) tbias->remove_bias_all();
|
||||
|
||||
double **v = atom->v;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -283,12 +254,9 @@ void ComputeTempDeform::remove_bias_all()
|
||||
|
||||
void ComputeTempDeform::restore_bias(int i, double *v)
|
||||
{
|
||||
if (atom->mask[i] & groupbit) {
|
||||
v[0] += vbias[0];
|
||||
v[1] += vbias[1];
|
||||
v[2] += vbias[2];
|
||||
}
|
||||
if (tbias) tbias->restore_bias(i,v);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -308,8 +276,6 @@ void ComputeTempDeform::restore_bias_all()
|
||||
v[i][1] += vbiasall[i][1];
|
||||
v[i][2] += vbiasall[i][2];
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -35,11 +35,9 @@ class ComputeTempDeform : public Compute {
|
||||
private:
|
||||
int fix_dof;
|
||||
double tfactor;
|
||||
|
||||
double vbias[3]; // stored velocity bias for one atom
|
||||
double **vbiasall; // stored velocity bias for all atoms
|
||||
int maxbias; // size of vbiasall array
|
||||
Compute *tbias; // ptr to additional bias compute
|
||||
|
||||
void dof_compute();
|
||||
};
|
||||
|
||||
@ -67,13 +67,6 @@ void ComputeTempPartial::init()
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
dof_compute();
|
||||
|
||||
tbias = NULL;
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -81,8 +74,9 @@ void ComputeTempPartial::init()
|
||||
void ComputeTempPartial::dof_compute()
|
||||
{
|
||||
double natoms = group->count(igroup);
|
||||
dof = (xflag+yflag+zflag) * natoms;
|
||||
if (tbias) dof -= tbias->dof_remove(natoms);
|
||||
int nper = xflag+yflag+zflag;
|
||||
if (domain->dimension == 2) nper = xflag+yflag;
|
||||
dof = nper * natoms;
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
@ -90,14 +84,9 @@ void ComputeTempPartial::dof_compute()
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double ComputeTempPartial::dof_remove(double &natoms)
|
||||
int ComputeTempPartial::dof_remove(int i)
|
||||
{
|
||||
double rmdof = 0.0;
|
||||
if (tbias) rmdof = tbias->dof_remove(natoms);
|
||||
int activedim = xflag+yflag+zflag;
|
||||
if (domain->dimension == 2) activedim = xflag+yflag;
|
||||
rmdof += (domain->dimension - activedim) * natoms;
|
||||
return rmdof;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -106,12 +95,6 @@ double ComputeTempPartial::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 *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
@ -133,10 +116,8 @@ double ComputeTempPartial::compute_scalar()
|
||||
zflag*v[i][2]*v[i][2]) * rmass[i];
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
|
||||
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
if (dynamic || tbias) dof_compute();
|
||||
if (dynamic) dof_compute();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
@ -149,11 +130,6 @@ void ComputeTempPartial::compute_vector()
|
||||
|
||||
invoked |= INVOKED_VECTOR;
|
||||
|
||||
if (tbias) {
|
||||
if (!(tbias->invoked & INVOKED_VECTOR)) tbias->compute_vector();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
@ -176,8 +152,6 @@ void ComputeTempPartial::compute_vector()
|
||||
t[5] += massone * yflag*zflag*v[i][1]*v[i][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;
|
||||
}
|
||||
@ -188,9 +162,6 @@ void ComputeTempPartial::compute_vector()
|
||||
|
||||
void ComputeTempPartial::remove_bias(int i, double *v)
|
||||
{
|
||||
if (tbias) tbias->remove_bias(i,v);
|
||||
|
||||
if (atom->mask[i] & groupbit) {
|
||||
if (!xflag) {
|
||||
vbias[0] = v[0];
|
||||
v[0] = 0.0;
|
||||
@ -203,7 +174,6 @@ void ComputeTempPartial::remove_bias(int i, double *v)
|
||||
vbias[2] = v[2];
|
||||
v[2] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -212,8 +182,6 @@ void ComputeTempPartial::remove_bias(int i, double *v)
|
||||
|
||||
void ComputeTempPartial::remove_bias_all()
|
||||
{
|
||||
if (tbias) tbias->remove_bias_all();
|
||||
|
||||
double **v = atom->v;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -249,12 +217,9 @@ void ComputeTempPartial::remove_bias_all()
|
||||
|
||||
void ComputeTempPartial::restore_bias(int i, double *v)
|
||||
{
|
||||
if (atom->mask[i] & groupbit) {
|
||||
v[0] += vbias[0];
|
||||
v[1] += vbias[1];
|
||||
v[2] += vbias[2];
|
||||
}
|
||||
if (tbias) tbias->restore_bias(i,v);
|
||||
if (!xflag) v[0] += vbias[0];
|
||||
if (!yflag) v[1] += vbias[1];
|
||||
if (!zflag) v[2] += vbias[2];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -270,12 +235,10 @@ void ComputeTempPartial::restore_bias_all()
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
v[i][0] += vbiasall[i][0];
|
||||
v[i][1] += vbiasall[i][1];
|
||||
v[i][2] += vbiasall[i][2];
|
||||
if (!xflag) v[i][0] += vbiasall[i][0];
|
||||
if (!yflag) v[i][1] += vbiasall[i][1];
|
||||
if (!zflag) v[i][2] += vbiasall[i][2];
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -26,7 +26,7 @@ class ComputeTempPartial : public Compute {
|
||||
double compute_scalar();
|
||||
void compute_vector();
|
||||
|
||||
double dof_remove(double &);
|
||||
int dof_remove(int);
|
||||
void remove_bias(int, double *);
|
||||
void remove_bias_all();
|
||||
void restore_bias(int, double *);
|
||||
@ -37,11 +37,9 @@ class ComputeTempPartial : public Compute {
|
||||
int xflag,yflag,zflag;
|
||||
int fix_dof;
|
||||
double tfactor;
|
||||
|
||||
double vbias[3]; // stored velocity bias for one atom
|
||||
double **vbiasall; // stored velocity bias for all atoms
|
||||
int maxbias; // size of vbiasall array
|
||||
Compute *tbias; // ptr to additional bias compute
|
||||
|
||||
void dof_compute();
|
||||
};
|
||||
|
||||
@ -131,13 +131,6 @@ void ComputeTempRamp::init()
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
dof_compute();
|
||||
|
||||
tbias = NULL;
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -145,8 +138,8 @@ void ComputeTempRamp::init()
|
||||
void ComputeTempRamp::dof_compute()
|
||||
{
|
||||
double natoms = group->count(igroup);
|
||||
dof = domain->dimension * natoms;
|
||||
if (tbias) dof -= tbias->dof_remove(natoms);
|
||||
int nper = domain->dimension;
|
||||
dof = nper * natoms;
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
@ -160,12 +153,6 @@ double ComputeTempRamp::compute_scalar()
|
||||
|
||||
invoked |= INVOKED_SCALAR;
|
||||
|
||||
if (tbias) {
|
||||
if (!(tbias->invoked & INVOKED_SCALAR))
|
||||
double tmp = tbias->compute_scalar();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
@ -193,10 +180,8 @@ double ComputeTempRamp::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 || tbias) dof_compute();
|
||||
if (dynamic) dof_compute();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
@ -210,11 +195,6 @@ void ComputeTempRamp::compute_vector()
|
||||
|
||||
invoked |= INVOKED_VECTOR;
|
||||
|
||||
if (tbias) {
|
||||
if (!(tbias->invoked & INVOKED_VECTOR)) tbias->compute_vector();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
@ -247,8 +227,6 @@ void ComputeTempRamp::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;
|
||||
}
|
||||
@ -259,16 +237,11 @@ void ComputeTempRamp::compute_vector()
|
||||
|
||||
void ComputeTempRamp::remove_bias(int i, double *v)
|
||||
{
|
||||
if (tbias) tbias->remove_bias(i,v);
|
||||
|
||||
if (atom->mask[i] & groupbit) {
|
||||
double fraction =
|
||||
(atom->x[i][coord_dim] - coord_lo) / (coord_hi - coord_lo);
|
||||
double fraction = (atom->x[i][coord_dim] - coord_lo) / (coord_hi - coord_lo);
|
||||
fraction = MAX(fraction,0.0);
|
||||
fraction = MIN(fraction,1.0);
|
||||
vbias[v_dim] = v_lo + fraction*(v_hi - v_lo);
|
||||
v[v_dim] -= vbias[v_dim];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -277,8 +250,6 @@ void ComputeTempRamp::remove_bias(int i, double *v)
|
||||
|
||||
void ComputeTempRamp::remove_bias_all()
|
||||
{
|
||||
if (tbias) tbias->remove_bias_all();
|
||||
|
||||
double **v = atom->v;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -308,8 +279,7 @@ void ComputeTempRamp::remove_bias_all()
|
||||
|
||||
void ComputeTempRamp::restore_bias(int i, double *v)
|
||||
{
|
||||
if (atom->mask[i] & groupbit) v[v_dim] += vbias[v_dim];
|
||||
if (tbias) tbias->restore_bias(i,v);
|
||||
v[v_dim] += vbias[v_dim];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -326,8 +296,6 @@ void ComputeTempRamp::restore_bias_all()
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
v[i][v_dim] += vbiasall[i][v_dim];
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -39,11 +39,9 @@ class ComputeTempRamp : public Compute {
|
||||
double v_lo,v_hi;
|
||||
int scaleflag,fix_dof;
|
||||
double tfactor,xscale,yscale,zscale;
|
||||
|
||||
double vbias[3]; // stored velocity bias for one atom
|
||||
double **vbiasall; // stored velocity bias for all atoms
|
||||
int maxbias; // size of vbiasall array
|
||||
Compute *tbias; // ptr to additional bias compute
|
||||
|
||||
void dof_compute();
|
||||
};
|
||||
|
||||
@ -61,25 +61,16 @@ ComputeTempRegion::~ComputeTempRegion()
|
||||
|
||||
void ComputeTempRegion::init()
|
||||
{
|
||||
dof = 0;
|
||||
|
||||
tbias = NULL;
|
||||
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];
|
||||
}
|
||||
dof = 0.0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double ComputeTempRegion::dof_remove(double &natoms)
|
||||
int ComputeTempRegion::dof_remove(int i)
|
||||
{
|
||||
double rmdof = 0.0;
|
||||
if (tbias) rmdof = tbias->dof_remove(natoms);
|
||||
natoms -= natoms_region;
|
||||
rmdof += domain->dimension * natoms;
|
||||
return rmdof;
|
||||
double *x = atom->x[i];
|
||||
if (domain->regions[iregion]->match(x[0],x[1],x[2])) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -88,12 +79,6 @@ double ComputeTempRegion::compute_scalar()
|
||||
{
|
||||
invoked |= INVOKED_SCALAR;
|
||||
|
||||
if (tbias) {
|
||||
if (!(tbias->invoked & INVOKED_SCALAR))
|
||||
double tmp = tbias->compute_scalar();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
@ -102,34 +87,30 @@ double ComputeTempRegion::compute_scalar()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
Region *region = domain->regions[iregion];
|
||||
int count = 0;
|
||||
double t = 0.0;
|
||||
|
||||
if (mass) {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit &&
|
||||
domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
|
||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
||||
count++;
|
||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) *
|
||||
mass[type[i]];
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit &&
|
||||
domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
|
||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
||||
count++;
|
||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * rmass[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
|
||||
double tarray[2],tarray_all[2];
|
||||
tarray[0] = count;
|
||||
tarray[1] = t;
|
||||
MPI_Allreduce(tarray,tarray_all,2,MPI_DOUBLE,MPI_SUM,world);
|
||||
natoms_region = tarray_all[0];
|
||||
dof = domain->dimension * natoms_region - extra_dof;
|
||||
dof = domain->dimension * tarray_all[0] - extra_dof;
|
||||
if (dof > 0) scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz);
|
||||
else scalar = 0.0;
|
||||
return scalar;
|
||||
@ -143,11 +124,6 @@ void ComputeTempRegion::compute_vector()
|
||||
|
||||
invoked |= INVOKED_VECTOR;
|
||||
|
||||
if (tbias) {
|
||||
if (!(tbias->invoked & INVOKED_VECTOR)) tbias->compute_vector();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
@ -156,12 +132,12 @@ void ComputeTempRegion::compute_vector()
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
Region *region = domain->regions[iregion];
|
||||
double massone,t[6];
|
||||
for (i = 0; i < 6; i++) t[i] = 0.0;
|
||||
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit &&
|
||||
domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
|
||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
||||
if (mass) massone = mass[type[i]];
|
||||
else massone = rmass[i];
|
||||
t[0] += massone * v[i][0]*v[i][0];
|
||||
@ -172,8 +148,6 @@ void ComputeTempRegion::compute_vector()
|
||||
t[5] += massone * v[i][1]*v[i][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;
|
||||
}
|
||||
@ -184,9 +158,6 @@ void ComputeTempRegion::compute_vector()
|
||||
|
||||
void ComputeTempRegion::remove_bias(int i, double *v)
|
||||
{
|
||||
if (tbias) tbias->remove_bias(i,v);
|
||||
|
||||
if (atom->mask[i] & groupbit) {
|
||||
double *x = atom->x[i];
|
||||
if (domain->regions[iregion]->match(x[0],x[1],x[2]))
|
||||
vbias[0] = vbias[1] = vbias[2] = 0.0;
|
||||
@ -196,7 +167,6 @@ void ComputeTempRegion::remove_bias(int i, double *v)
|
||||
vbias[2] = v[2];
|
||||
v[0] = v[1] = v[2] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -205,8 +175,6 @@ void ComputeTempRegion::remove_bias(int i, double *v)
|
||||
|
||||
void ComputeTempRegion::remove_bias_all()
|
||||
{
|
||||
if (tbias) tbias->remove_bias_all();
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
int *mask = atom->mask;
|
||||
@ -219,9 +187,11 @@ void ComputeTempRegion::remove_bias_all()
|
||||
"compute/temp:vbiasall");
|
||||
}
|
||||
|
||||
Region *region = domain->regions[iregion];
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]))
|
||||
if (region->match(x[i][0],x[i][1],x[i][2]))
|
||||
vbiasall[i][0] = vbiasall[i][1] = vbiasall[i][2] = 0.0;
|
||||
else {
|
||||
vbiasall[i][0] = v[i][0];
|
||||
@ -239,12 +209,9 @@ void ComputeTempRegion::remove_bias_all()
|
||||
|
||||
void ComputeTempRegion::restore_bias(int i, double *v)
|
||||
{
|
||||
if (atom->mask[i] & groupbit) {
|
||||
v[0] += vbias[0];
|
||||
v[1] += vbias[1];
|
||||
v[2] += vbias[2];
|
||||
}
|
||||
if (tbias) tbias->restore_bias(i,v);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -264,8 +231,6 @@ void ComputeTempRegion::restore_bias_all()
|
||||
v[i][1] += vbiasall[i][1];
|
||||
v[i][2] += vbiasall[i][2];
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -26,7 +26,7 @@ class ComputeTempRegion : public Compute {
|
||||
double compute_scalar();
|
||||
void compute_vector();
|
||||
|
||||
double dof_remove(double &);
|
||||
int dof_remove(int);
|
||||
void remove_bias(int, double *);
|
||||
void remove_bias_all();
|
||||
void restore_bias(int, double *);
|
||||
@ -35,12 +35,9 @@ class ComputeTempRegion : public Compute {
|
||||
|
||||
private:
|
||||
int iregion;
|
||||
double natoms_region;
|
||||
|
||||
double vbias[3]; // stored velocity bias for one atom
|
||||
double **vbiasall; // stored velocity bias for all atoms
|
||||
int maxbias; // size of vbiasall array
|
||||
Compute *tbias; // ptr to additional bias compute
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "string.h"
|
||||
#include "compute_temp_sphere.h"
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
@ -33,7 +34,8 @@ using namespace LAMMPS_NS;
|
||||
ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute temp command");
|
||||
if (narg != 3 || narg != 4)
|
||||
error->all("Illegal compute temp/sphere command");
|
||||
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
@ -41,6 +43,15 @@ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
extvector = 1;
|
||||
tempflag = 1;
|
||||
|
||||
tempbias = 0;
|
||||
id_bias = NULL;
|
||||
if (narg == 4) {
|
||||
tempbias = 1;
|
||||
int n = strlen(arg[3]) + 1;
|
||||
id_bias = new char[n];
|
||||
strcpy(id_bias,arg[3]);
|
||||
}
|
||||
|
||||
vector = new double[6];
|
||||
inertia = new double[atom->ntypes+1];
|
||||
}
|
||||
@ -57,20 +68,26 @@ ComputeTempSphere::~ComputeTempSphere()
|
||||
|
||||
void ComputeTempSphere::init()
|
||||
{
|
||||
if (tempbias) {
|
||||
int i = modify->find_compute(id_bias);
|
||||
if (i < 0) error->all("Could not find compute ID for temperature bias");
|
||||
tbias = modify->compute[i];
|
||||
if (tbias->tempflag == 0)
|
||||
error->all("Bias compute does not calculate temperature");
|
||||
if (tbias->tempbias == 0)
|
||||
error->all("Bias compute does not calculate a velocity bias");
|
||||
if (tbias->igroup != igroup)
|
||||
error->all("Bias compute group does not match compute group");
|
||||
tbias->init();
|
||||
if (strcmp(tbias->style,"temp/region") == 0) tempbias = 2;
|
||||
else tempbias = 1;
|
||||
}
|
||||
|
||||
fix_dof = 0;
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
dof_compute();
|
||||
|
||||
tempbias = 0;
|
||||
tbias = NULL;
|
||||
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];
|
||||
}
|
||||
|
||||
if (atom->mass) {
|
||||
double *mass = atom->mass;
|
||||
double **shape = atom->shape;
|
||||
@ -88,9 +105,25 @@ void ComputeTempSphere::init()
|
||||
void ComputeTempSphere::dof_compute()
|
||||
{
|
||||
double natoms = group->count(igroup);
|
||||
if (domain->dimension == 3) dof = 6.0 * natoms;
|
||||
else dof = 3.0 * natoms;
|
||||
if (tbias) dof -= tbias->dof_remove(natoms);
|
||||
int nper = 6;
|
||||
if (domain->dimension == 2) nper = 3;
|
||||
dof = nper * natoms;
|
||||
|
||||
if (tempbias) {
|
||||
if (tempbias == 1) dof -= tbias->dof_remove(-1) * natoms;
|
||||
else {
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
int count = 0;
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
if (tbias->dof_remove(i)) count++;
|
||||
int count_all;
|
||||
MPI_Allreduce(&count,&count_all,1,MPI_INT,MPI_SUM,world);
|
||||
dof -= nper * count_all;
|
||||
}
|
||||
}
|
||||
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
@ -102,7 +135,7 @@ double ComputeTempSphere::compute_scalar()
|
||||
{
|
||||
invoked |= INVOKED_SCALAR;
|
||||
|
||||
if (tbias) {
|
||||
if (tempbias) {
|
||||
if (!(tbias->invoked & INVOKED_SCALAR))
|
||||
double tmp = tbias->compute_scalar();
|
||||
tbias->remove_bias_all();
|
||||
@ -136,10 +169,10 @@ double ComputeTempSphere::compute_scalar()
|
||||
}
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
if (tempbias) tbias->restore_bias_all();
|
||||
|
||||
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
if (dynamic || tbias) dof_compute();
|
||||
if (dynamic || tempbias == 2) dof_compute();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
@ -152,7 +185,7 @@ void ComputeTempSphere::compute_vector()
|
||||
|
||||
invoked |= INVOKED_VECTOR;
|
||||
|
||||
if (tbias) {
|
||||
if (tempbias) {
|
||||
if (!(tbias->invoked & INVOKED_VECTOR)) tbias->compute_vector();
|
||||
tbias->remove_bias_all();
|
||||
}
|
||||
@ -209,7 +242,7 @@ void ComputeTempSphere::compute_vector()
|
||||
}
|
||||
}
|
||||
|
||||
if (tbias) tbias->restore_bias_all();
|
||||
if (tempbias) tbias->restore_bias_all();
|
||||
|
||||
MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world);
|
||||
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
|
||||
@ -221,16 +254,7 @@ void ComputeTempSphere::compute_vector()
|
||||
|
||||
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();
|
||||
tbias->remove_bias(i,v);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -240,16 +264,5 @@ void ComputeTempSphere::remove_bias_all()
|
||||
|
||||
void ComputeTempSphere::restore_bias(int i, double *v)
|
||||
{
|
||||
if (tbias) tbias->restore_bias(i,v);
|
||||
tbias->restore_bias(i,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();
|
||||
}
|
||||
|
||||
|
||||
@ -27,15 +27,13 @@ class ComputeTempSphere : public Compute {
|
||||
void compute_vector();
|
||||
|
||||
void remove_bias(int, double *);
|
||||
void remove_bias_all();
|
||||
void restore_bias(int, double *);
|
||||
void restore_bias_all();
|
||||
|
||||
private:
|
||||
int fix_dof;
|
||||
double tfactor;
|
||||
double *inertia;
|
||||
|
||||
char *id_bias;
|
||||
Compute *tbias; // ptr to additional bias compute
|
||||
|
||||
void dof_compute();
|
||||
|
||||
Reference in New Issue
Block a user