[lammps-users] Reverse velocities

Hello,

I am trying to read in a restart file, reverse the velocities (multiply all vx, vy, vz by -1), and then run MD. Is there a simple way to do this? I have tried using a negative timestep and LAMMPS doesn't complain (this gives me different energies and coordinates from just reading in the restart file and running dynamics with a positive timestep). However, I want to make sure that this is a tractable method to run dynamics in the opposite direction from a given restart file.

Thanks very much for your help. Gregg Beckham

hello gregg,

Hello,

I am trying to read in a restart file, reverse the velocities (multiply all vx, vy, vz by -1), and then run MD. Is there a simple way to do this? I have tried using a negative timestep and LAMMPS

probably the best way to do this would be to implement it as an extension
to the velocity command. let us know, if you need help with that.

doesn't complain (this gives me different energies and coordinates from just reading in the restart

i am not sure if everything is implemented in lammps to accommodate this
approach. the best test would be to run with fix nve for only a small number
of steps (a few 100) and then see if you can reverse the trajectory by inverting
the velocities. the two trajectories will occasional diverge because of the
uncontrollable trunction errors from summing up floating point numbers. but
you can reduce them, e.g., by enforcing a neighborlist rebuild in every step.

file and running dynamics with a positive timestep). However, I want to make sure that this is a tractable method to run dynamics in the opposite direction from a given restart file.

as i wrote above. writing a specific command that does exactly what
you want, is the cleanest way to have this feature implemented.

cheers,
   axel.

gregg, steve,

please find attached modified sources to implement a reverse subcommand
for the velocity command in lammps. the change is very straightforward.

please let me know, if there are any problems with it.

cheers,
    axel.

lammps-vel-rev.tar (40 KB)

I enhanced the "set" option in the velocity command
to allow a variable to be used (equal-style or atom-style),
similar to other LAMMPS commands.

This is more general - you can reverse velocities and more.
Try out the 14Jan11 patch with these commands:

variable vx atom -vx
variable vy atom -vy
variable vz atom -vz
velocity all set v_vx v_vy v_vz

If you add them to the end of bench/in.lj and run
another 100 steps, you will un-equilibrate the system
back to (nearly) its starting point.

Steve

Hi Steve, this works perfectly! Thanks so much to both of you for your help!
Cheers, Gregg

I enhanced the "set" option in the velocity command
to allow a variable to be used (equal-style or atom-style),
similar to other LAMMPS commands.

This is more general - you can reverse velocities and more.
Try out the 14Jan11 patch with these commands:

variable vx atom -vx
variable vy atom -vy
variable vz atom -vz
velocity all set v_vx v_vy v_vz

If you add them to the end of bench/in.lj and run
another 100 steps, you will un-equilibrate the system
back to (nearly) its starting point.

Steve