# temperature and kinetic energy

Hi everybody

I have some questions about how LAMMPS calculates temperature and kinetic energy.

First, the section of kinetic energy of the termo style says that ‘The kinetic energy of the system ke is inferred from the temperature of the system’. How LAMMPS calculates this temperature?. It doesn’t seem to be the temperature from the the compute temp section, because the manual mentions that ‘The temperature is calculated by the formula KE = dim/2 N k T, where KE = total kinetic energy of the group of atoms (sum of 1/2 m v^2)’.

Second, how is made the calculation of temperature for the compute temp/asphere command? The manual only states that includes a ‘contribution from both their translational and rotational kinetic energy’.

I’m making these questions because I have a single ellipsoid doing brownian motion (fix langevin with fix nve/asphere) but the results of thermo style term, thermo style ke, and compute temp/asphere dof rotate, are all 0 and I don’t know why.

Hope you can help me.

Best

Ariel

Hi everybody

I have some questions about how LAMMPS calculates temperature and kinetic
energy.

First, the section of kinetic energy of the termo style says that 'The
kinetic energy of the system *ke* is inferred from the temperature of the
system'. How LAMMPS calculates this temperature?. It doesn't seem to be the
temperature from the the compute temp section, because the manual mentions
that 'The temperature is calculated by the formula KE = dim/2 N k T, where
KE = total kinetic energy of the group of atoms (sum of 1/2 m v^2)'.

​you are incorrect. the thermo class by default *does* create a temperature
compute temp internally, that can be accessed with the compute-ID
thermo_temp.​

Second, how is made the calculation of temperature for the compute
temp/asphere command? The manual only states that includes a 'contribution
from both their translational and rotational kinetic energy'.

​exactly. translation is the same as for compute temp, rotation accordingly
from moments of inertia and angular velocity.​

I'm making these questions because I have a single ellipsoid doing
brownian motion (fix langevin with fix nve/asphere) but the results of
thermo style term, thermo style ke, and compute temp/asphere dof rotate,
are all 0 and I don't know why.

​there are multiple issues that need to be considered here:

- temperature (unlike kinetic energy) for a single particle is not a very
well defined entity. ​temperature is only well defined in the limit of a
very large number of particles when considering the net exchange of energy
between two such systems. in statistical thermodynamics, you can connect
temperature to the kinetic energy based on the hypothesis, that for a
system in equilibrium the (average) temperature is the same throughout.
- when computing temperature from the kinetic energy, you are not exactly
using the number of particles, but the number of degrees of freedom. that
can be tricky with extended particles as it is, but also for point
particles (i.e. translation only), compute temp will subtract by default 3
degrees of freedom, since an MD system is invariant to translation (i.e.
the total momentum is assumed to be zero).
- thus the Thermo class cannot recover your kinetic energy, since your
system is computed to have 0 degrees of freedom (3N-3 gives 0 for N=1) and
correspondingly compute temp will output 0. if you define compute ke, you
should see a non-zero kinetic energy, provided your particle does translate.
- for compute temp/asphere the same applies, but there is a small issue
here. when you define it the way you do to only compute the rotational
temperature, it should not remove the 3 translational degrees of freedom. i
will make a change to the source to this effect. however, you can change
the setting yourself via compute_modify (same for the other computes)

​axel.​