3D Molecular Diffusion of Gases

Lift the partition and watch a light and a heavy gas mix, or let them leak through five pores. Temperature, pressure, chamber size and gas pair are yours.

Switch to 2D

Presets

Playback

Experiment

Conditions

View

Camera

Layers

Quality

Model check

The science

What you are looking at

Two gases share a box with a partition in the middle. In mixing mode the light gas (cyan) starts on the left, the heavy gas (orange) on the right, and lifting the gate lets them spread into each other. In effusion mode both gases start on the left and can only reach the right chamber through five small round pores; the light gas leaks out faster. One molecule of each gas leaves a trace so you can see the random walk.

Equations used

  • Maxwell-Boltzmann speeds: f(v) = 4π (m / 2πkT)3/2 v² exp(-m v² / 2kT), mean speed ⟨v⟩ = sqrt(8kT / πm), rms speed sqrt(3kT/m). Every velocity component is drawn from a Gaussian of width sqrt(kT/m).
  • Mean free path λ = kT / (√2 π d² p) with the kinetic diameter d of each gas (rounded literature values) and the pressure p. Mean time between collisions τ = λ / ⟨v⟩.
  • Collisions with the background gas are a Poisson process: each step a molecule has probability 1 - exp(-dt/τ) to get a fresh Maxwellian velocity. This gives exactly D = kT τ / m = (π/8) λ ⟨v⟩. Hard-sphere kinetic theory gives a coefficient of the same size (about 1/3 to 0.6 depending on the level of approximation), so treat D as a scaling law, not a measured value. Heavier molecules are slower, so D ∝ T3/2 / (p √M).
  • Random walk: ⟨r²⟩ = 6 D t in three dimensions. The diffusion equation ∂c/∂t = D ∂²c/∂x² with reflecting walls and a step initial profile (Fick's second law) has the solution c(x,t) = 1/2 + Σk odd (2 / kπ) (-1)(k-1)/2 cos(kπx/L) exp(-(kπ/L)² D t); the dashed curves in the graphs are this series. The mixing index is 1 - Σ 8 / (kπ)² exp(-(kπ/L)² D t).
  • Effusion (Graham's law): a hole much smaller than the free path passes n⟨v⟩A/4 molecules per unit time, so the rate is proportional to 1/√M and ratelight / rateheavy = √(Mheavy / Mlight). For two equal chambers the fraction that has gone through is (1 - exp(-2kt)) / 2 with k = 10π r² ⟨v⟩ / L for five pores of radius r (in units of L).

Honest simplifications

  • Molecules do not collide with each other; the other gas acts as a background that only re-randomises the velocity. So each gas diffuses on its own with its own D, whereas a real binary mixture has one shared inter-diffusion coefficient D12 and the lighter gas drags the heavy one along.
  • The real free path at normal pressure is far below a micrometre, so a micrometre-sized box would need thousands of collisions per crossing. The picture therefore draws a free path of at least 0.03 chamber lengths (mixing) or 1 chamber length (effusion), marked with * in the readouts; the diffusion coefficient shown uses the drawn value. The graph "D versus temperature" uses the real free path.
  • Time is slowed by about a billion. Spheres are drawn larger than the kinetic diameter for visibility; walls are specular and isothermal; no gravity, no chemical reaction, no bulk flow from a pressure difference.

What to try

  • Mixing, H2 and CO2: the cyan gas spreads much faster; both mixing curves follow their dashed theory.
  • Raise the temperature to 600 K: mean speeds and D rise; the thermometer and heater glow follow.
  • Raise the pressure: the real free path shrinks, so D in the last graph falls roughly as 1/p.
  • Effusion, He and N2: compare the fraction through the pores with the dashed law and read the rate ratio against sqrt(28.0/4.0) = 2.65.

Numerical checks run in this page

(1) sampled speeds against Maxwell-Boltzmann, (2) mean square displacement of free molecules against 6Dt, (3) the simulated step profile against the cosine-series Fick solution, (4) the effusion rate ratio against Graham's law. They use fresh particle sets, independent of the live run, and re-run when the gases or temperature change.

Models and 3D assets: the chamber, gate, five-pore membrane, heater plinth, pressure gauge and thermometer were modelled and texture-baked in Blender and are driven by the equations above in Three.js r160.

Loading model...
Loading Blender model...
Concentration profile along the chamber
Mixing index / fraction through the pores vs time
Speed distributions vs Maxwell-Boltzmann
Diffusion coefficient vs temperature (real pressure)

3D Molecular Diffusion Gas

This simulation demonstrates the principles of molecular diffusion in a gaseous environment. Users can observe how molecules spread out from areas of high concentration to areas of low concentration, illustrating concepts related to thermodynamics and statistical mechanics.

Made with 🟠 Blender · Three.js