To set the initial conditions let us consider the spheres to be distributed in a lattice, and with random initial velocities. An addtional requirement is that the total energy should be consistent with some desired temperature according to . Furthermore, is advantageous to make the total momentum (which will be conserved in the simulation) equal to zero.
Next, we compute for each pair of particles in the system the time that would take the pair to meet:
For each particle the smallest positive collision time and the corresponding collision partner are memorized. If the particle has no collision partner at positive times, we set and or the largest representable number.
Evidently this calculation is quite costly, since there are pairs to be scanned. However this double loop over all indices has to be performed only once, at the start of the simulation.
Next we identify the smallest among the ``next collision times'', calling it This will give us the time that will pass until the next collision occurring in the entire system. Let the partners in this collision be and .
Now all the particle positions are incremented according to the free motion
law
The elastic collision between the spheres and leads to
new velocities of these two particles
The elementary step of a hard sphere MD calculations now completed. The next step is started by once more searching all the for the smallest element.