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

This commit is contained in:
sjplimp 2008-03-17 20:49:18 +00:00
parent 85d81c4207
commit d4f14ea20b
7 changed files with 71 additions and 33 deletions

View File

@ -5,10 +5,10 @@ SHELL = /bin/sh
# System-specific settings
CC = c++
CCFLAGS = -O -I../STUBS -I/sw/include -DFFT_FFTW
CCFLAGS = -O -I../STUBS -DFFT_FFTW
DEPFLAGS = -M
LINK = c++
LINKFLAGS = -O -L/sw/lib
LINKFLAGS = -O
USRLIB = -lfftw ../STUBS/mpi.o
SYSLIB =
SIZE = size

View File

@ -30,6 +30,9 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) :
xvalue = atof(arg[3]);
yvalue = atof(arg[4]);
zvalue = atof(arg[5]);
force_flag = 0;
foriginal[0] = foriginal[1] = foriginal[2] = 0.0;
}
/* ---------------------------------------------------------------------- */
@ -79,8 +82,14 @@ void FixAddForce::post_force(int vflag)
int *mask = atom->mask;
int nlocal = atom->nlocal;
foriginal[0] = foriginal[1] = foriginal[2] = 0.0;
force_flag = 0;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
foriginal[0] += f[i][0];
foriginal[1] += f[i][1];
foriginal[2] += f[i][2];
f[i][0] += xvalue;
f[i][1] += yvalue;
f[i][2] += zvalue;
@ -100,3 +109,18 @@ void FixAddForce::min_post_force(int vflag)
{
post_force(vflag);
}
/* ----------------------------------------------------------------------
return components of total force on fix group before force was changed
------------------------------------------------------------------------- */
double FixAddForce::compute_vector(int n)
{
// only sum across procs one time
if (force_flag == 0) {
MPI_Allreduce(foriginal,foriginal_all,3,MPI_DOUBLE,MPI_SUM,world);
force_flag = 1;
}
return foriginal_all[n];
}

View File

@ -28,9 +28,12 @@ class FixAddForce : public Fix {
void post_force(int);
void post_force_respa(int, int, int);
void min_post_force(int);
double compute_vector(int);
private:
double xvalue,yvalue,zvalue;
double foriginal[3],foriginal_all[3];
int force_flag;
int nlevels_respa;
};

View File

@ -98,33 +98,33 @@ void FixAveForce::post_force(int vflag)
int *mask = atom->mask;
int nlocal = atom->nlocal;
double sum[3];
sum[0] = sum[1] = sum[2] = 0.0;
double foriginal[3];
foriginal[0] = foriginal[1] = foriginal[2] = 0.0;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
sum[0] += f[i][0];
sum[1] += f[i][1];
sum[2] += f[i][2];
foriginal[0] += f[i][0];
foriginal[1] += f[i][1];
foriginal[2] += f[i][2];
}
// average the force on participating atoms
// add in requested amount
double sumall[3];
MPI_Allreduce(sum,sumall,3,MPI_DOUBLE,MPI_SUM,world);
sumall[0] = sumall[0]/ncount + xvalue;
sumall[1] = sumall[1]/ncount + yvalue;
sumall[2] = sumall[2]/ncount + zvalue;
MPI_Allreduce(foriginal,foriginal_all,3,MPI_DOUBLE,MPI_SUM,world);
double fave[3];
fave[0] = foriginal_all[0]/ncount + xvalue;
fave[1] = foriginal_all[1]/ncount + yvalue;
fave[2] = foriginal_all[2]/ncount + zvalue;
// set force of all participating atoms to same value
// only for active dimensions
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
if (xflag) f[i][0] = sumall[0];
if (yflag) f[i][1] = sumall[1];
if (zflag) f[i][2] = sumall[2];
if (xflag) f[i][0] = fave[0];
if (yflag) f[i][1] = fave[1];
if (zflag) f[i][2] = fave[2];
}
}
@ -141,27 +141,27 @@ void FixAveForce::post_force_respa(int vflag, int ilevel, int iloop)
int *mask = atom->mask;
int nlocal = atom->nlocal;
double sum[3];
sum[0] = sum[1] = sum[2] = 0.0;
double foriginal[3];
foriginal[0] = foriginal[1] = foriginal[2] = 0.0;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
sum[0] += f[i][0];
sum[1] += f[i][1];
sum[2] += f[i][2];
foriginal[0] += f[i][0];
foriginal[1] += f[i][1];
foriginal[2] += f[i][2];
}
double sumall[3];
MPI_Allreduce(sum,sumall,3,MPI_DOUBLE,MPI_SUM,world);
sumall[0] = sumall[0]/ncount;
sumall[1] = sumall[1]/ncount;
sumall[2] = sumall[2]/ncount;
MPI_Allreduce(foriginal,foriginal_all,3,MPI_DOUBLE,MPI_SUM,world);
double fave[3];
fave[0] = foriginal_all[0]/ncount;
fave[1] = foriginal_all[1]/ncount;
fave[2] = foriginal_all[2]/ncount;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
if (xflag) f[i][0] = sumall[0];
if (yflag) f[i][1] = sumall[1];
if (zflag) f[i][2] = sumall[2];
if (xflag) f[i][0] = fave[0];
if (yflag) f[i][1] = fave[1];
if (zflag) f[i][2] = fave[2];
}
}
}
@ -172,3 +172,12 @@ void FixAveForce::min_post_force(int vflag)
{
post_force(vflag);
}
/* ----------------------------------------------------------------------
return components of total force on fix group before force was changed
------------------------------------------------------------------------- */
double FixAveForce::compute_vector(int n)
{
return foriginal_all[n];
}

View File

@ -28,10 +28,12 @@ class FixAveForce : public Fix {
void post_force(int);
void post_force_respa(int, int, int);
void min_post_force(int);
double compute_vector(int);
private:
int xflag,yflag,zflag;
double xvalue,yvalue,zvalue;
double foriginal_all[3];
int ncount;
int nlevels_respa;
};

View File

@ -142,7 +142,7 @@ void FixSetForce::min_post_force(int vflag)
}
/* ----------------------------------------------------------------------
return components of total force on fix group before reset
return components of total force on fix group before force was changed
------------------------------------------------------------------------- */
double FixSetForce::compute_vector(int n)

View File

@ -35,14 +35,14 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) :
{
if (narg != 6) error->all("Illegal fix temp/berendsen command");
t_start = atof(arg[3]);
t_stop = atof(arg[4]);
t_period = atof(arg[5]);
// Berendsen thermostat should be applied every step
nevery = 1;
t_start = atof(arg[3]);
t_stop = atof(arg[4]);
t_period = atof(arg[5]);
// error checks
if (t_period <= 0.0) error->all("Fix temp/berendsen period must be > 0.0");