implement a "reverse" sub-command for velocity.
This commit is contained in:
@ -13,7 +13,7 @@ velocity command :h3
|
||||
velocity group-ID style args keyword value ... :pre
|
||||
|
||||
group-ID = ID of group of atoms whose velocity will be changed :ulb,l
|
||||
style = {create} or {set} or {scale} or {ramp} or {zero} :l
|
||||
style = {create} or {set} or {scale} or {ramp} or {reverse} or {zero} :l
|
||||
{create} args = temp seed
|
||||
temp = temperature value (temperature units)
|
||||
seed = random # seed (positive integer)
|
||||
@ -26,6 +26,7 @@ style = {create} or {set} or {scale} or {ramp} or {zero} :l
|
||||
vlo,vhi = lower and upper velocity value (velocity units)
|
||||
dim = {x} or {y} or {z}
|
||||
clo,chi = lower and upper coordinate bound (distance units)
|
||||
{reverse}
|
||||
{zero} arg = {linear} or {angular}
|
||||
{linear} = zero the linear momentum
|
||||
{angular} = zero the angular momentum :pre
|
||||
@ -47,6 +48,7 @@ velocity all create 300.0 4928459 rot yes dist gaussian
|
||||
velocity border set NULL 4.0 3.0 sum yes units box
|
||||
velocity flow scale 300.0
|
||||
velocity flow ramp vx 0.0 5.0 y 5 25 temp mytemp
|
||||
velocity all reverse
|
||||
velocity all zero linear :pre
|
||||
|
||||
[Description:]
|
||||
@ -77,6 +79,10 @@ outside the coordinate bounds (less than 5 or greater than 25 in this
|
||||
case), are assigned velocities equal to vlo or vhi (0.0 or 5.0 in this
|
||||
case).
|
||||
|
||||
The {reverse} style replaces the velocities of the group of atoms with
|
||||
the negative of the original values. The total kinetic energy is unchanged.
|
||||
No other changes are made to the velocities of the atoms.
|
||||
|
||||
The {zero} style adjusts the velocities of the group of atoms so that
|
||||
the aggregate linear or angular momentum is zero. No other changes
|
||||
are made to the velocities of the atoms.
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
enum{CREATE,SET,SCALE,RAMP,ZERO};
|
||||
enum{CREATE,SET,SCALE,RAMP,REVERSE,ZERO};
|
||||
enum{ALL,LOCAL,GEOM};
|
||||
|
||||
#define WARMUP 100
|
||||
@ -74,6 +74,7 @@ void Velocity::command(int narg, char **arg)
|
||||
else if (strcmp(arg[1],"set") == 0) style = SET;
|
||||
else if (strcmp(arg[1],"scale") == 0) style = SCALE;
|
||||
else if (strcmp(arg[1],"ramp") == 0) style = RAMP;
|
||||
else if (strcmp(arg[1],"reverse") == 0) style = REVERSE;
|
||||
else if (strcmp(arg[1],"zero") == 0) style = ZERO;
|
||||
else error->all("Illegal velocity command");
|
||||
|
||||
@ -121,6 +122,7 @@ void Velocity::command(int narg, char **arg)
|
||||
else if (style == SET) set(narg-2,&arg[2]);
|
||||
else if (style == SCALE) scale(narg-2,&arg[2]);
|
||||
else if (style == RAMP) ramp(narg-2,&arg[2]);
|
||||
else if (style == REVERSE) reverse(narg-2,&arg[2]);
|
||||
else if (style == ZERO) zero(narg-2,&arg[2]);
|
||||
}
|
||||
|
||||
@ -528,6 +530,24 @@ void Velocity::rescale(double t_old, double t_new)
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
reverse velocities, so an MD can run backwards.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Velocity::reverse(int narg, char **arg)
|
||||
{
|
||||
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] = -v[i][0];
|
||||
v[i][1] = -v[i][1];
|
||||
v[i][2] = -v[i][2];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero the linear momentum of a group of atoms by adjusting v by -Vcm
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -39,6 +39,7 @@ class Velocity : protected Pointers {
|
||||
double xscale,yscale,zscale;
|
||||
class Compute *temperature;
|
||||
|
||||
void reverse(int, char **);
|
||||
void set(int, char **);
|
||||
void scale(int, char **);
|
||||
void ramp(int, char **);
|
||||
|
||||
Reference in New Issue
Block a user