A granular gas consists of macroscopic particles — grains, beads, or sand — moving rapidly and colliding inelastically with each other. Unlike molecular gases, each collision in a granular gas permanently removes kinetic energy, causing the system to spontaneously cool. This simulation places 500 hard discs in a 2D box and models their dynamics using event-driven molecular dynamics: the next collision is found analytically, particles are advanced to that moment, and collision velocities are updated with the chosen coefficient of restitution r. The granular temperature Tg = ⟨v²⟩/2 is tracked in real time and plotted on a log-log scale, allowing direct verification of Haff's cooling law (Tg ∝ t−2). At low r, spontaneous density clustering emerges from the uniform initial state — a hallmark of the granular clustering instability.
Granular materials are ubiquitous in industry (pharmaceuticals, mining, agriculture) and nature (avalanches, dunes, planetary ring systems). Their collective behaviour defies classical thermodynamics: a granular gas cannot reach thermal equilibrium because energy is not conserved in collisions. The interplay between inelastic dissipation, driving forces, and boundary conditions creates rich non-equilibrium phenomena including pattern formation, shock waves, and the inelastic collapse singularity. This simulation lets you explore these phenomena interactively, switching between free cooling and vibration-driven steady states.
A granular gas is an assembly of macroscopic particles (grains, beads, sand) that move rapidly and collide inelastically with each other, analogous to a molecular gas but with one crucial difference: collisions dissipate kinetic energy. This permanent energy loss causes the system to cool spontaneously, distinguishing it fundamentally from ordinary molecular gases.
The coefficient of restitution r (0 ≤ r ≤ 1) quantifies how elastic a collision is. r=1 means a perfectly elastic collision conserving all kinetic energy. r=0 means a perfectly inelastic collision where particles stick together. For real granular materials r typically lies between 0.6 and 0.99. Use the slider to vary r and observe how inelasticity drives cooling and clustering.
Haff's cooling law (1983) predicts that granular temperature Tg decays as Tg(t) ∝ (1 + t/t*)⁻², approaching Tg ∝ t−2 at large times. The characteristic time t* depends on initial temperature, particle density, and (1−r²). The simulation plots log(Tg) vs log(t) so you can verify the −2 slope.
Inelastic collapse is a mathematical singularity at very low restitution: a cluster of particles can undergo infinitely many collisions in finite time, causing relative velocities to reach zero. In real simulations with r < ~0.3, a velocity floor cutoff is applied to avoid infinite collision loops while still showing clustering behaviour.
Even a homogeneous granular gas with r < 1 is unstable to density fluctuations. Denser regions dissipate more energy, cool faster, develop lower pressure, and attract more particles — a runaway instability. The result is spontaneous cluster formation: dense cold clusters surrounded by hot dilute regions. Reducing r makes clustering more pronounced.
In Vibration mode, a sinusoidally oscillating bottom wall injects energy into the granular gas, compensating for collisional dissipation. At steady state the system reaches a non-equilibrium stationary state where energy input balances energy loss — the basis of many industrial granular processing applications like vibrating conveyors and hoppers.
Granular temperature Tg is defined as Tg = ⟨v²⟩/2 (mean kinetic energy per particle). Unlike thermodynamic temperature it is not related to thermal Brownian motion; it measures the random fluctuating velocity component. It serves as the fundamental order parameter for granular hydrodynamics and drops to zero as grains cluster and rest.
This simulation uses event-driven molecular dynamics (EDMD): instead of fixed time steps, it finds the next collision analytically (solving quadratic equations for disc-disc and disc-wall intersection times), advances all particles to that time, applies the collision response, and repeats. A cell-list (spatial hashing) reduces the O(N²) collision search to O(N) per time unit, enabling real-time browser simulation.
When r is significantly less than 1, repeated collisions rapidly reduce relative speeds. Particles that collide repeatedly essentially stick together. Neighbours also lose speed and join the cluster. Because granular pressure is proportional to Tg, cold clusters exert less pressure than surrounding hot regions and cannot resist compression, leading to runaway density increase.
This simulation illustrates: (1) inelastic vs elastic collisions and energy conservation; (2) emergence of macroscopic dissipation laws from microscopic collision rules; (3) spontaneous symmetry breaking and pattern formation in non-equilibrium systems; (4) the concept of a non-equilibrium steady state under driving. Students can verify Haff's law from the log-log slope, measure clustering onset time as a function of r, and compare free-cooling vs vibration-driven regimes.