Please wait for the animation to completely load.
In this animation N = nR (i.e., kB = 1). This, then, gives the ideal gas law as PV = NT.
In Animation 1 you see an ensemble of particles that looks "natural" once the particles spread throughout the box. You would not expect to see the reverse of this process. Why? Consider Animation 2. This one looks the same running forward or backward. The first animation is an example of an irreversible process, while the second animation is an example of a reversible process. What differentiates the two processes? The concept of entropy. Restart.
Run both animations again. Look at the total energy (kinetic energy) in both cases. Does the energy change? No. The conservation of energy (stated in thermodynamics as the first law of thermodynamics) does not help us determine which of these animations is more likely (since energy is conserved in both cases).
To determine which animation is a more realistic picture of gas particles in a box, we must apply the second law of thermodynamics and the associated concept of entropy. Entropy is a measure of the disorder of a system. Which animation has greater entropy (disorder)? Why? Clearly Animation 2 is a much more ordered system. Animation 1 starts out ordered, yet ends up disordered.
As you watch the first animation, also notice the many different velocity distributions that are possible that still result in the same overall energy (temperature) and pressure. Statistically speaking, it is much, much, much, much more likely for the speeds of an ensemble of particles to be closer to a Maxwell-Boltzmann distribution than to all have the same speeds.
Entropy and the second law of thermodynamics describe what is more likely to happen. It is more likely for particles to go into states of greater disorder because there are more possible "disorderly states" than ordered ones (and the number of possible states is related to the entropy). For example, there are many more ways for a group of particles to follow a Maxwell-Boltzmann distribution than the distribution having identical speeds for each particle. The second law says that entropy either increases or stays the same; irreversible processes cause an increase in entropy. This is our way of knowing whether or not a movie is running forward or backward—as we move forward in time, entropy increases. If entropy decreases somewhere (when electrons are organized to light up a computer screen in a certain manner so you can read this, for example), energy is required, and the energy needed results in an increase in entropy elsewhere so that globally, entropy increases.
Illustration authored by Anne J. Cox.