[lammps-users] fix addtorque and compute temp/rotate

Dear Steve and all,

Recently I have been writing:

* a fix that add a set of forces to each atom in a given group such
that the components of the total torque applied on the group (around
its center of mass) are Tx,Ty,Tz, and the group would move as a rigid
body in the absence of other forces. This command can be used to drive
a group of atoms into rotation.

* a computation that calculates the temperature of a group of atoms,
after subtracting out the center-of-mass velocity and angular velocity
of the group. This is useful if the group is expected to have a
non-zero net velocity and/or global rotation motion for some reason.

Please find enclosed the source and doc files. If you which to include
them in the main lammps distribution, could you check the doc pages?
They may need some improvement as english is not my mother tongue...


torque.tgz (7.27 KB)

Dear all,

From time to time, when I try to send a mail to the list, I don't

receive the "post acknowledgment". For instance, this has been the
case for the mail below. So I was just wondering if it did reach the
list anyway, and/or what could be the cause of the problem?


torque.tgz (7.27 KB)

It was received on the list. I’ve never received acknowledgement of it posting to the list.

I’m just curious and will probably find out once it is put into LAMMPS, but does this work with fix rigid, fix rigid/nvt, fix rigid/nve?




It was received on the list. I've never received acknowledgement of it
posting to the list.
I'm just curious and will probably find out once it is put into LAMMPS, but
does this work with fix rigid, fix rigid/nvt, fix rigid/nve?

you can easily test this for yourself. the way lammps is structured and
compiled, additional fixes or computes typically don't need any other
"installation" outside of being copied into the src directory and recompiling


Dear Josh,

As Axel said, one simply has to add fix_addtorque.cpp and
fix_addtorque.h into the src/ directory and recompile to be able to
use it.

This fix should work with fix rigid and co without problem, but I'm
interested by your feedback if you whish to look at this point in

In fact, this fix can be used in combination with fix aveforce or fix
setforce to induce the rigid motion of a given group, but the
philosophy is very different from the fix rigid family. If I
understood correctly, fix rigid computes the total force and torque on
a group, then computes the global translation and rotation velocity of
the group, and then iterate the atom positions accordingly. Here,
using fix aveforce / fix setforce + fix addtorque impose a set of
forces computed to ensure rigid translation and rotation of the
group... (however it will only work if all atoms in the group share
the same mass, because fix aveforce and fix setforce impose the same
force on atoms, not the same acceleration...)

fix 3 solid aveforce 0.0 0.0 0.0
fix 4 solid addtorque 2.0 3.0 5.0

Anyway, please feel free to test this fix further and send me some feedback.


Dear Laurent,

I was simply asking to understand whether or not it was to be used with “fix rigid” or if it could be used as a replacement. I was using “fix rigid” but with a massless site for a 3 point N2 model (3 point charges and 2 atomic sites). I was able to get “fix rigid” to work with this by removing the zero mass checks in LAMMPS, from a suggestion by Steve. This seemed to work and a comparison with DLPOLY for thermodynamic and dynamic properties seemed to be consistent, but I was curious to see if this could be used as another test.

I thought this addition was interesting and was just replying that it had been received on the list, since no one else seemed to have replied to you to tell you this.