[lammps-users] Output torque on rigid body?

Hi,

I'm trying to figure out how to extract the torque on a rigid body

group rbody type 3
fix 1 rbody rigid single

#variable torqx equal torque(rbody,x)
#variable torqy equal torque(rbody,y)
#variable torqz equal torque(rbody,z)
variable fcmx equal fcm(rbody,x)
variable fcmy equal fcm(rbody,y)
variable fcmz equal fcm(rbody,z)
#fix ex1 rbody print 500 "\{torqx\} {torqy} \{torqz\}" file torque\.dat fix ex2 rbody print 500 "{fcmx} \{fcmy\} {fcmz}" file fcm.dat

This seems to be working OK to print out the forces on the center of mass. I thought I could use the commented lines to get the torque, but it doesn't work, I suppose because group.cpp doesn't compute the torque, only fix_rigid.cpp does that. So, either I need to 1) figure out how to get the torque computed in fix_rigid.cpp to be output by a fix print, or 2) I need to put the torque computation in the group.cpp so that I can print it out along with other group properties. Option 1 is easier, but I can't figure out how to do it, other than hacking in a printf command and recompiling... any help is appreciated!

And Happy New Year to all as well!

Cheers,
Chris.

You're correct that the torque is stored internal
to fix rigid. The fix could store these values
so they can be output like other fixes do, except
there may be 1000 rigid bodies managed by the
fix. So for now you'd have to print it yourself
by instrumenting the fix. You could also write
a compute to calculate torque on a group
of atoms. Not hard to do if you know how
torque is computed ...

Steve

Thanks, I've put in a quick hack to fix_rigid.cpp that prints out the torque from final_integrate(), recompiled and it seems to be doing OK. Not exactly elegant, but it works!

Chris.