This program uses molecular dynamics to simulate the motion of particles in two dimensions interacting via the Lennard-Jones potential. The output includes the velocity distribution and the kinetic temperature, which is proportional to the mean kinetic energy per particle. The program also uses the demon algorithm to make an independent measure of the temperature.
According to the equipartition theorem, the mean kinetic energy of a particle per degree of freedom is kT/2, where k is Boltzmann's constant and T is the temperature. We can generalize this relation to define the temperature at time t by
kT(t) = (2/d) K(t)/N, (1)
where K is the kinetic energy of the system at time t and d is the spatial dimension. In the following we will consider d = 2.
The temperature that is usually measured in a molecular dynamics simulation is the time average of T(t) over many configurations of the particles. We will refer to this temperature as the kinetic temperature. For two dimensions we write the kinetic temperature as
(The bar denotes the time average.)
Equation (2) holds only if the momentum of the center of mass of the system is fixed. In a simulation, we impose the constraint that the center of mass momentum (in each of the d directions) be zero. Consequently, the system has dN - d independent velocity components rather than dN components, so that the corrected expression for the kinetic temperature is
The presence of the factor (N - 2) rather than N in is an example of a finite size correction that becomes unimportant for large N.
We can also use the demon algorithm to demonstrate that the demon gives an independent measure of the temperature. In this case the demon chooses a particle at random and changes its velocity by a random amount. Because the finite size effects are different for the two measurements, you will find that the results of the two measurements are slightly different.
Updated 5 March 2009.