Entropy

This program can be used to observe how entropy develops over time for a system with statistical changes. In particular, the temporal fluctuations of the entropy and its increase over time can be easily observed. The example is based on a gas volume in which all particles are initially located in the left half. Specifically, a rectangle with nx*ny boxes is considered, in which each box can assume two states, shown in blue or white. After starting, randomly selected boxes swap their properties in pairs. The entropy of the overall system is calculated from the number of microstates N per macrostate. To do this, the logarithm of N is calculated from the number of blue boxes in the left half(n1) or right half(n2) and the total number of ponds n=n1+n2: n*ln(n)-n1*ln(n1)-n2*ln(n2). This is an approximation for N = n!/(n1!*n2!). The entropy S=kB*ln(N) results from this by multiplication with the Boltzmann constant(kB=1.38*10-23J/K).


Operation

Select the number of boxes in the x-direction(nx) and y-direction(ny) and adjust the zoom for the display if necessary. You can choose between "All left" and "Gradient" and "Random" as the start condition. This selection determines the type of distribution at the start of the calculation. Note: only in the first case is the number of blue boxes exactly nx*ny/2, in the other cases this only applies approximately. Under Swap possibility, you can choose whether only swapping the property between neighbors (as with diffusion and heat conduction) or between any two boxes is permitted. "Calculation speed" is used to set how many swaps (1 to 10000) are carried out between two representations. The calculation is started with Start. By ticking "Show development", a window is opened in which the development of entropy over time is displayed. The time scale is selected in such a way that an exchange per µs takes place. The entropy/kB function displayed as a function of time can be saved and printed as a graph.


Numerical realization

Only boxes are swapped in pairs and the entropy, i.e. ln(N), is calculated for the current states. The expression N=n!/(n1!*n2!) is evaluated using Stirling's approximation: ln(N)=n*ln(n)-n1*ln(n1)-n2*ln(n2). The increase in entropy results automatically from the fact that the system is heading towards its most probable state.