2D Diffusion
Having written over 200 lines of python to simulate a 2D gas and to show it thermalising to the Boltzmann distrubition, it would be a pity not to reuse the code for related experiments.
So if one changes the end of the code to
t=0 dt=0.1 plt.ion() show_molecules(molecules) molecules[0].marker.color("red") molecules[0].marker.pendown() for i in range(len(molecules)): update_collisions(molecules,i) while (t<50): show_molecules(molecules) update_molecules(molecules,dt) if (abs(t-round(t))<0.5*dt): print("Time:",t) t+=dt input("Press enter to close")
one can investigate diffusion. The histogram of the speed distribution is no longer produced (in order to make the code run faster and more smoothly), but instead one disc is changed to be coloured red and to produce a trail, and the simulation now stops after a simulated time of 50. Try running it with the original 500 discs, with 100, and with just 50. Not only does the computer time to perform the simulation drop significantly (from about four minutes for 500 discs), but the track produced by the red disc also changes in character.
It is clear that, with just 50 discs present, the red disk has had far fewer collisions, and achieved a greater displacement, even if the distance travelled may be similar. One may also notice that the density of the discs is not uniform in either case. Randomness does produce fluctuations.
Try decreasing the number of discs further to just ten, and increase the simulation time to around 300. Note that now the red disc is able to travel the full width or height of the box without collision occasionally.
Some Simple Theory
A disc of radius r will collide with any other disc whose centre is within 2r of the first. So to move without collision it needs a clear path of width 4r. Can one estimate how far it can travel before it is likely to collide? After it has travelled a distance λ, the area of the path it has travelled is 4rλ. The expected number of other discs to be found per unit area is, in our case, N/10000 (assuming N other discs, and the area of the box is 10000 units). A collision would be expected once the expected number of discs in the area of the path is one, so, with r=1 as in our case,
4rλ * N/10000 = 1 λ = 2500 / N
This analysis is a bit simplistic. In particular, it concludes that a near-stationary disc never collides, which is wrong. So the estimate of N=25 leading to collisions about once per box-width (or height) is a little high.
The value λ is known as the mean free path.
That it decreases as pressure (particle density) increases frustrates the ability of the gas molecules to carry energy (heat conduction) or momentum (viscosity). In those two cases, the decrease in mean free path and the increase in the number of particles available to transport energy/momentum cancel: the thermal conductivity and viscosity of ideal gases are independent of pressure.
Or almost independent. If the measurement is between two closely-separated plates, and the gas is at low pressure, then, once λ approaches the plate separation, the above arguments fail. Once λ is so large that collisions effectively do not occur on the scale of the apparatus, then, the more molecules present, the more energy or momentum can be transported, and thermal conductivity and viscosity are proportional to pressure in this limit.
At very high pressure another effect becomes important. Above it was stated that, after a disc has travelled a distance λ, the area of the path it has travelled is 4rλ. Not quite -- the area it has occupied after travelling a distance λ is actually 4rλ+4πr2, for there are semicircular caps at the two ends of the path (or, alternatively, even if stationary it must still exclude the centres of other discs from an area of 4πr2). Once λ approaches πr new theory is needed.
λ in air
One mole (6x1023) of air molecules occupies around 24 litres at room temperature and pressure. A air molecule has a radius of around 1.5 Angstroms. So the mean free path would appear to be approximated by:
0.024/6x10230.024 ------------ = ---------- 9π*10-2054π*103
This approximation gives an answer of around 140nm. The accepted answer is 68nm. Either way, λ is safely far from being close to a molecular diameter, or close to the size of any reasonable system, so normal "ideal gas" theory should be applicable.
(What are the errors in our approximation? Neglecting the motion of the other particles when estimating λ leads to an over-estimation by √2. And, for the weak interactions here regarding air molecules as being hard spheres of radius 1.5A is a little inaccurate. They are soft spheres with weak short-range attraction. This increases their effective radius and will again reduce λ.)