back to index

Simulation 4 - Gas Expansion

The program is essentially equivalent to program 1. However, instead of dice, you start with N dots, each dot representing a particle. Instead of two outcomes {0,1}you have the two outcomes {L,R}, L and R stand for being in the left or the right compartment. The equivalence of the two processes is described in Chapter 7. The program chooses a particle at random, then chooses either R or L at random and place the particle in either the R or L compartment, respectively. The graph follows the total number of particles in the left compartment from the initial to the equilibrium state. This is essentially a simulation of an expansion of an ideal gas.

           

 


Graph: