How to apply torque force through springs?

Dear LAMMPS users,

There are two aligned layers of atoms (the upper and the lower). The upper and lower layers are connected by springs. I want to apply a horizontal rotation to the upper to drive a similar rotation of the lower. However, the existing fix spring and fix smd commands do not seem to be suitable for this case. Because the two commands calculate the spring force based on the distance between the centroid of two groups. In other words, they only apply to linear motion of two groups. During the rotation, the relative position of the centroid remains unchanged although a mismatch between layers will occur. I would like to ask if there is a good solution and I am looking forward to your reply.
Best regards!

How about using fix addtorque or fix move?


How about using fix addtorque or fix move?


In this particular case, that is what I would do.

For other LAMMPS users, if you feel comfortable compiling LAMMPS, you can try using “fix twist”. (It is similar to “fix spring”, but it applies torsional forces. It might be more useful if you want to apply dihedral-like forces to many different quadruplets of atoms in a system.)

There are several videos showing what it does (and a basic usage example) here:

To use this feature the following files into your LAMMPS src/ subdirectory, and re-compile LAMMPS

(As mentioned in the description of the video, you can get similar behavior using “dihedral_style table”. But I suspect that not many users can figure out how to get that to work, so I decided to write a new fix that makes it more clear.)

I have been too lazy to write up documentation for “fix twist”, but if anybody finds it useful I am happy to do this and post a pull request.


I have an new idea. Divide the upper and lower layers into the same groups (upper: A1 A2 A3…;lower: B1 B2 B3…)and each pair is connected separately by a fix spring command (A1-B1 A2-B2 A3-B3…).
Also, the source code you provide is a good reference, although it’s a bit long. I wanted to see if I could understand it.
Thank you for your reply.

在 2020-03-12 08:47:57,“Andrew Jewett” <[email protected]…24…> 写道:

I don’t really understand what you are trying to do here, and specifically what is the physics behind it. It seems to me to be more of an animation than something real.

Please find below a demonstration how to drive a rotation of two layers with a real non-bonded interaction. No need for an additional fix spring or similar to couple the two layers.

You can find a video of it at:

The type 3 atoms are a small percentage randomly placed in the upper half of the upper layer. They are driving the rotation through fix move. The remainder of the system is passive and simply time integrated with fix nve. It is easily visible how the green atoms follow the blue atoms which then will drive the red atoms.

units real
lattice fcc 5.0
atom_style atomic
neighbor 1.0 bin
boundary p p p
region box block -10 10 -10 10 -10 10
create_box 3 box

region upper cylinder z 0.0 0.0 8.0 -4.0 -0.01
region lower cylinder z 0.0 0.0 8.0 0.01 4.0

region inner cylinder z 0.0 0.0 7.5 2.0 4.1 side in
region outer cylinder z 0.0 0.0 1.0 2.0 4.1 side out
region ring intersect 2 inner outer
variable drive atom rmask(ring)*(random(0,1,73577)<0.2)

create_atoms 1 region upper
create_atoms 2 region lower
group drive variable drive
group passive subtract all drive

set group drive type 3

pair_style lj/cut 8.5
pair_coeff * * 0.2379 3.405
mass * 40
timestep 5.0
neigh_modify every 1 delay 1 check yes

thermo 1000
thermo_style custom step temp ke pe etotal

write_dump all image init.jpg type type size 1280 1080 adiam 3.5 ssao yes 54 0.3

minimize 0.0 0.0 100 1000
reset_timestep 0

fix 0 passive nve
fix 1 drive move rotate 0.0 0.0 0.0 0.0 0.0 1.0 200000.0
dump 1 all movie 100 rotate.mp4 type type size 1280 1080 adiam 3.5 ssao yes 1547154 0.3

run 50000