fix distance

Check if this works for you or not:
http://lammps.sandia.gov/doc/fix_shake.html