Fix addtorque command

Dear lammps users:

I am trying to apply an orientation dependent torsion for each atom with the command fix addtorque, the relevant piece of code is below.

compute orient all property/atom quati quatj quatk quatw

variable ux atom 2*(c_orient[2]*c_orient[4]+c_orient[1]c_orient[3])
variable uy atom 2
variable uz atom 2

fix magnetic all addtorque v_uy v_ux 0.0

The problem is that generates an error: ‘Variable for fix addtorque is invalid style’ . I think there should be some way that the command accepts variables atom-style

¿What should I change to solve the error?

Any help will really be appreciated. Thank you in advance.


Your thinking is wrong. The documentation explicitly states that the command accepts equal style variables and besides, the description clearly says that that fix adds forces to atoms that correspond to a torque on the entire group; in that context atom style variables make no sense.

Then, how could a different torsion be implemented for each atom?

I am new in lammps. Excuse me if the questions are obvious.


Fix addtorque operates on point particles (usually atoms with atom style atomic, charge, bond, full, etc.). Point particles cannot have a torque. Even if you use a different atom style, fix addtorque will ignore that.

As I already mentioned (and as is prominently stated in the documentation for the command where it explains what it does) the provided torque is applied to the entire group of atoms and that makes it a global and not a per-atom property and thus only equal style variables make sense.