Add springs to each atom of a group

Hi all,
Recently I’m studying the friction properties of bilayer graphene, I want to add independent springs to each atom of the top layer graphene and moving these springs with a constant velocity in LAMMPS, this protocol is widely used in nanotribology. (e.g., see M. M. van Wijk, et al. Superlubric to stick-slip sliding of incommensurate graphene flakes on graphite. Phys Rev B. 2013, 88: 235423.)
However, I found it’s not trivial to do it in LAMMPS. The present fix styles in LAMMPS such as fix spring and fix smd are designed to add single spring to the COM of a group. Although fix spring/self can add independent springs to each atom, these spring cannot be moved like that in fix smd. Thus, I’m wondering if there is an easy way to do this kind of simulation in LAMMPS or I need to implement this protocol myself. If it is the latter case, is there any point I need pay special attention to? Any input is grateful.
Thank you in advance!



I think you can use fix addforce where you specify a specific force per atom which can be a variable where you use the initial position plus some function-dependent displacement as r_0 for the spring. Something along these lines

# Due to periodic boundary conditions, we need to use the unwrapped coordinates

compute unwrapped all property/atom xu yu zu

# Store initial position of the atoms

fix initial_position all store/state 0 x y z

# Spring constant

variable k equal 1.0

# Customized time-dependent, per-atom spring r_0

variable x0 atom f_initial_position[1]+time

variable y0 atom f_initial_position[2]

variable z0 atom f_initial_position[3]

# Force components using the above

variable fx atom (c_unwrapped[1]-v_x0)*v_k

variable fy atom (c_unwrapped[2]-v_y0)*v_k

variable fz atom (c_unwrapped[3]-v_z0)*v_k

fix addforce all addforce v_fx v_fy v_fz

There might be a simpler way, but this at least works (I think) :slight_smile:


It might also be possible to modify fix spring self to accept per-atom variables. You could then encode the position as a function of time. In effect it will achieve Anders’ solution but might be a bit cleaner looking.

Ahh that is much better haha!