Entropy Simulation#
July 29, 2023
by Prince Javier
I was reading the book Existential Physics by Sabine Hossenfelder. There she discussed what entropy is and how “tautological” the definition is. From the book:
“The equilibrium state is the state you are likely to reach, and the state you are likely to reach is the state of highest entropy—that’s just how entropy is defined. The second law of thermodynamics, hence, is almost tautological. It merely says that a system is most likely to do the most likely thing, which is to increase its entropy.”
Below, we simulate a simple example of how entropy naturally increases by definition. The rules of the simulation are simple:
You start with a grid of blue and white particles such that the upper half is initially all blue and the lower half is initially all white
The particles will randomly swap with neighboring particles
You will see how entropy increases over time as a result of this process.
Entropy can be viewed as a measure of the number of possible “microstates” a thing can assume without changing the “macrostate” of the system.
Say you are to mix two colors of paint - white and blue paint. Now you pour the blue on the upper half of a cardboard and white on the lower half. Say you do not distinguish between different blue particles. They are all the same. And you do not distinguish between different white particles. But you distinguish between white and blue particles.
You can define your macrostate as the number of blue particles on the upper half (or similarly the number of white particles on the lower half). You can then define your microstate as the number of possible arrangements of blue particles on the upper half or white particles on the lower half.
Now, if there are only blue particles in the upper half, and white particles in the lower half, then there’s only 1 microstate for this macrostate. So the entropy is low. But if the two paints start to mix, you get more possible combinations of microstates for the same macrostate – there will be more ways to arrange a mix of blue and white particles for the same number of blue particles (macrostate).
Why will the paint mix? Because that is physics in action. Mixing will be the likely thing to happen due to particle motion. Eventually, the blue and white paint will be fully mixed, maximizing entropy.
Mathematically, entropy is calculated as the logarithm of the number of possible combinations. This is because the number of combinations can easily become a very large value. In this notebook, we simplify the entropy calculation as:
\(log(n! / (r!(n - r)!))\)
where \(r\) is the number of blue particles in the upper half of the box and \(n\) is the number of particles in total in the upper box.