forked from lijiext/lammps
more changes to fix rigid and fix poems
This commit is contained in:
parent
c9d41178d8
commit
0c53afbfcf
|
@ -267,6 +267,10 @@ FixPOEMS::FixPOEMS(LAMMPS *lmp, int narg, char **arg) :
|
|||
|
||||
poems = new Workspace;
|
||||
|
||||
// compute per body forces and torques inside final_integrate() by default
|
||||
|
||||
earlyflag = 0;
|
||||
|
||||
// print statistics
|
||||
|
||||
int nsum = 0;
|
||||
|
@ -281,10 +285,6 @@ FixPOEMS::FixPOEMS(LAMMPS *lmp, int narg, char **arg) :
|
|||
fprintf(logfile,"%d clusters, %d bodies, %d joints, %d atoms\n",
|
||||
ncluster,nbody,njoint,nsum);
|
||||
}
|
||||
|
||||
// compute per body forces and torques inside final_integrate() by default
|
||||
|
||||
earlyflag = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
@ -335,25 +335,6 @@ FixPOEMS::~FixPOEMS()
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int FixPOEMS::modify_param(int narg, char **arg)
|
||||
{
|
||||
if (strcmp(arg[0],"bodyforces") == 0) {
|
||||
if (narg < 2)
|
||||
error->all(FLERR,"Illegal fix_modify command");
|
||||
if (strcmp(arg[1],"early") == 0)
|
||||
earlyflag = 1;
|
||||
else if (strcmp(arg[1],"late") == 0)
|
||||
earlyflag = 0;
|
||||
else
|
||||
error->all(FLERR,"Illegal fix_modify command");
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int FixPOEMS::setmask()
|
||||
{
|
||||
int mask = 0;
|
||||
|
@ -374,19 +355,25 @@ void FixPOEMS::init()
|
|||
int i,ibody;
|
||||
|
||||
// warn if more than one POEMS fix
|
||||
// if earlyflag, warn if any post-force fixes come after POEMS fix
|
||||
|
||||
int count = 0;
|
||||
int myindex, myposition;
|
||||
for (i = 0; i < modify->nfix; i++)
|
||||
if (strcmp(modify->fix[i]->style,"poems") == 0) {
|
||||
count++;
|
||||
if (strcmp(modify->fix[i]->id,this->id) == 0) {
|
||||
myindex = i;
|
||||
myposition = count;
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (strcmp(modify->fix[i]->style,"poems") == 0) count++;
|
||||
if (count > 1 && comm->me == 0) error->warning(FLERR,"More than one fix poems");
|
||||
|
||||
if (earlyflag) {
|
||||
int pflag = 0;
|
||||
for (i = 0; i < modify->nfix; i++) {
|
||||
if (strcmp(modify->fix[i]->style,"poems") == 0) pflag = 1;
|
||||
if (pflag && (modify->fmask[i] & POST_FORCE) &&
|
||||
!modify->fix[i]->rigid_flag) {
|
||||
char str[128];
|
||||
sprintf(str,"Fix %d alters forces after fix poems",modify->fix[i]->id);
|
||||
error->warning(FLERR,str);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > 1 && myposition == 1 && comm->me == 0)
|
||||
error->warning(FLERR,"More than one fix poems");
|
||||
|
||||
// error if npt,nph fix comes before rigid fix
|
||||
|
||||
|
@ -400,29 +387,6 @@ void FixPOEMS::init()
|
|||
error->all(FLERR,"POEMS fix must come before NPT/NPH fix");
|
||||
}
|
||||
|
||||
// warn if fix poems preceeds non-rigid fixes with post-force tasks
|
||||
// when computing body forces and torques in post_force() instead of final_integrate()
|
||||
|
||||
if (earlyflag) {
|
||||
int has_post_force[modify->nfix - myindex];
|
||||
count = 0;
|
||||
for (i = myindex + 1; i < modify->nfix; i++)
|
||||
if ( (modify->fmask[i] & POST_FORCE) && (!modify->fix[i]->rigid_flag) )
|
||||
has_post_force[count++] = i;
|
||||
if (count) {
|
||||
FILE *p[2] = {screen, logfile};
|
||||
for (int j = 0; j < 2; j++)
|
||||
if (p[j]) {
|
||||
fprintf(p[j],"WARNING: fix %s %s",id,style);
|
||||
fprintf(p[j]," will add up forces before they are handled by:\n");
|
||||
for (int k = 0; k < count; k++) {
|
||||
Fix *fix = modify->fix[has_post_force[k]];
|
||||
fprintf(p[j]," => fix %s %s\n",fix->id,fix->style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// timestep info
|
||||
|
||||
dtv = update->dt;
|
||||
|
@ -781,6 +745,13 @@ void FixPOEMS::initial_integrate(int vflag)
|
|||
set_xv();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPOEMS::post_force(int vflag)
|
||||
{
|
||||
if (earlyflag) compute_forces_and_torques();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute fcm,torque on each rigid body
|
||||
only count joint atoms in 1st body
|
||||
|
@ -837,13 +808,6 @@ void FixPOEMS::compute_forces_and_torques()
|
|||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPOEMS::post_force(int vflag)
|
||||
{
|
||||
if (earlyflag) compute_forces_and_torques();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
update vcm,omega by last 1/2 step
|
||||
set v of body atoms accordingly
|
||||
|
@ -1678,6 +1642,21 @@ int FixPOEMS::unpack_exchange(int nlocal, double *buf)
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int FixPOEMS::modify_param(int narg, char **arg)
|
||||
{
|
||||
if (strcmp(arg[0],"bodyforces") == 0) {
|
||||
if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
|
||||
if (strcmp(arg[1],"early") == 0) earlyflag = 1;
|
||||
else if (strcmp(arg[1],"late") == 0) earlyflag = 0;
|
||||
else error->all(FLERR,"Illegal fix_modify command");
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPOEMS::reset_dt()
|
||||
{
|
||||
dtv = update->dt;
|
||||
|
|
|
@ -28,7 +28,6 @@ class FixPOEMS : public Fix {
|
|||
public:
|
||||
FixPOEMS(class LAMMPS *, int narg, char **arg);
|
||||
~FixPOEMS();
|
||||
int modify_param(int, char **);
|
||||
int setmask();
|
||||
void init();
|
||||
void setup(int);
|
||||
|
@ -48,6 +47,7 @@ class FixPOEMS : public Fix {
|
|||
void pre_neighbor();
|
||||
int dof(int);
|
||||
void deform(int);
|
||||
int modify_param(int, char **);
|
||||
void reset_dt();
|
||||
|
||||
private:
|
||||
|
@ -56,7 +56,6 @@ class FixPOEMS : public Fix {
|
|||
double *step_respa;
|
||||
int nlevels_respa;
|
||||
double total_ke;
|
||||
|
||||
int earlyflag; // 1 if forces and torques are computed at post_force()
|
||||
|
||||
// atom assignment to rigid bodies
|
||||
|
|
|
@ -694,7 +694,7 @@ int FixRigid::setmask()
|
|||
int mask = 0;
|
||||
mask |= INITIAL_INTEGRATE;
|
||||
mask |= FINAL_INTEGRATE;
|
||||
if (langflag || earlyflag) mask |= POST_FORCE;
|
||||
if (langflag) mask |= POST_FORCE;
|
||||
mask |= PRE_NEIGHBOR;
|
||||
mask |= INITIAL_INTEGRATE_RESPA;
|
||||
mask |= FINAL_INTEGRATE_RESPA;
|
||||
|
@ -2638,6 +2638,17 @@ int FixRigid::modify_param(int narg, char **arg)
|
|||
if (strcmp(arg[1],"early") == 0) earlyflag = 1;
|
||||
else if (strcmp(arg[1],"late") == 0) earlyflag = 0;
|
||||
else error->all(FLERR,"Illegal fix_modify command");
|
||||
|
||||
// reset fix mask
|
||||
// must do here and not in init,
|
||||
// since modify.cpp::init() uses fix masks before calling fix::init()
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (strcmp(modify->fix[i]->id,id) == 0) {
|
||||
if (earlyflag) modify->fmask[i] |= POST_FORCE;
|
||||
else if (!langflag) modify->fmask[i] &= ~POST_FORCE;
|
||||
break;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -540,7 +540,7 @@ int FixRigidSmall::setmask()
|
|||
int mask = 0;
|
||||
mask |= INITIAL_INTEGRATE;
|
||||
mask |= FINAL_INTEGRATE;
|
||||
if (langflag || earlyflag) mask |= POST_FORCE;
|
||||
if (langflag) mask |= POST_FORCE;
|
||||
mask |= PRE_NEIGHBOR;
|
||||
mask |= INITIAL_INTEGRATE_RESPA;
|
||||
mask |= FINAL_INTEGRATE_RESPA;
|
||||
|
@ -3428,6 +3428,18 @@ int FixRigidSmall::modify_param(int narg, char **arg)
|
|||
if (strcmp(arg[1],"early") == 0) earlyflag = 1;
|
||||
else if (strcmp(arg[1],"late") == 0) earlyflag = 0;
|
||||
else error->all(FLERR,"Illegal fix_modify command");
|
||||
|
||||
// reset fix mask
|
||||
// must do here and not in init,
|
||||
// since modify.cpp::init() uses fix masks before calling fix::init()
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (strcmp(modify->fix[i]->id,id) == 0) {
|
||||
if (earlyflag) modify->fmask[i] |= POST_FORCE;
|
||||
else if (!langflag) modify->fmask[i] &= ~POST_FORCE;
|
||||
break;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue