[lammps-users] Variable :: Atom Vector & K.E components


I am trying to calculate the three kinetic energy components separately i.e.,

K.E_x = sum over all atoms [(1/2) ux^2]
K.E_y = sum over all atoms [(1/2) uy^2]
K.E_z = sum over all atoms [(1/2) uz^2]

Is there a way to calculate this readily using LAMMPS commands or do I have use some post processing tools to do this?

I think variable command should allow me to do that. The atom vector option in Variable command is documented as

Atom vectors use empty brackets, i.e. they take no argument. They generate one value per atom, so that a reference like x[] means the x-coord of each atom will be used when evaluating the variable.

I don’t understand this properly. Does this mean x[] is average value of quantity ‘x’ over all atoms in the group?

Thanks in advance!


The compute temp command calcs a KE tensor whose diagonal
components are what you list. Access it in thermo output as
c_thermo_temp[N}, where N = 1,2,3. You might have to normalize
appropriately, which can be done with a variable.


From the documentation it is not clear to me about the out come of the following commands.

compute mobile flow temp/partial 0 0 1
thermo_style custom c_thermo_temp[1] c_thermo_temp[2] c_thermo_temp[3]

The values outputted by “c_thermo_temp” command are

  1. per/atom values or global values?
  2. If they are per atom values whether they are normalized by all atoms
    or only atoms (group mobile) that contribute to the temperature via the first command listed.


Everyhing output by thermo is global. Read the thermo
and thermo_modify doc pages for info on normalization. If
thermo normalizes it, it will be normalized by all atoms
in the system.

Read the compute temp doc page for info about what it
produces and whether it is intensive or extensive which
also affects the normalization.