# [lammps-users] torque on a group

Dear all,

Is there a simple way to compute the total torque on a (non-rigid)
group of atoms? In particular, I can't find a variable function, like
fcm(group,dim) that can compute the total force, or a compute like
group/group - once again for the force.

I guess one can get it through compute reduce, something like (for the
torque on the group about its center of mass):

variable Tza atom (x-xcm(group,x))*fy-(y-xcm(group,y)*fx
compute Tz group reduce sum v_Tza

Would that work? And maybe I missed a simpler way...

Best,
Laurent

There isn't a variable function for it, like fcm(), but
it could be added easily enough.

Steve

Dear Steve,

If I understand correctly, this can be done by adding a "function"
Group::torque() to group.cpp, by copying and slightly modifying
Group::angmom for instance. And then adding the corresponding part to
variable.cpp, also doing something quite similar to angmom...

Would that be enough, and not conflict with anything else? There are
already lots of 'torque' in the code...

But I don't like modifying too much lammps because it is always harder
to keep a modified lammps version up-to-date, even using the svn
repository (thanks to Axel by the way, it's extremely useful).

So should I simply use the following input script (would it work?), or
if I make the modifications would you be interested to include them in
the main lammps distribution?

variable Tza atom (x-xcm(group,x))*fy-(y-xcm(group,y)*fx
compute Tz group reduce sum v_Tza

Best,
Laurent

What you describe is the way to do it. I'll add it to
to the main distribution if you do it like the other
group functions called by variable.

This all presumes you want torque around the
center--of-mass point. If you want it around
some arbitrary point, then that would need to
be extra args to the torque() function, which would
require more extensive changes to variable.cpp.

Steve

Dear Steve,

torque on a group around its center of mass to the 10Nov10 version,
and the modified files (doc/variable.html, doc/variable.txt,
src/group.cpp, src/group.h, src/variable.cpp).

Best,
Laurent

patch.torque (13.1 KB)

torque.tgz (44.4 KB)

Laurent - posted this just now as a 27Nov10 patch.

Thanks,
Steve

Great, thank you!

Lately I have also been working on a fix addtorque command, which add
a set of forces to each atom in a group such that: the components of
the total torque applied on the group (around its center of mass) are
Tx,Ty,Tz; 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 (see attached files). I made a few tests and I'm reasonably
convinced that in my situation of interest (lj units, constant torque,
dynamics simulations) it is working correctly. If you are interested
to include it in the main lammps distribution, I can test it a little
bit harder, and other lammps users are welcome to give it a try. So
just tell me...

While doing that, I found two small mistakes in the fix addforce code
and documentation:

* in fix_addforce.cpp: several error messages refer to "fix setforce"
* in the documentation:
<LI>keyword = <I>region</I>
should be
<LI>keyword = <I>region</I> or <I>energy</I>

Nothing serious as you can see...

Best,
Laurent

P.S.: For my purpose I will also have to write a compute temp that
remove the center of mass velocity and the global rotational motion of
the group...

torque.tgz (9.89 KB)

Sure - a fix addtorque command might
be of general interest.

I'll make the changes to fix the doc page
issues you mention.

Thanks,
Steve