Kinetic Theory of Gases Simulator: Maxwell-Boltzmann Distribution

Simulate a two-dimensional hard-disk gas with exact event-driven collisions. The speed histogram is built from the collisions and converges onto the 2-D Maxwell-Boltzmann (Rayleigh) curve.

At a glance

Computes
Speed distribution, temperature, and pressure of a 2-D gas from collisions
You supply
Particle count, temperature, disk radius, box side, and random seed
Use when
You want Maxwell-Boltzmann derived from collisions or pressure checked
Not for
Solving PV = nRT for a laboratory gas Ideal Gas Law and Boyle's Law Calculator
Species
Playback rate

Relative energy change since reset

-1.28e-15

Exact event-driven hard-disk dynamics after 200 reduced time units.

Every disk position comes from the event-driven engine.

Probability density against Particle speed

012340.00.10.20.30.40.50.60.7Measured speeds2-D Rayleigh prediction

Probability density against Particle speed

012340.00.10.20.30.40.50.60.73-D Maxwell contrastExact finite-N density

Boltzmann H (nats) against Simulated time; reference at Analytic grid equilibrium floor

050100150200−5−4−3−2−10Analytic grid equilibrium f…Bias-corrected H(t)
Chart label shortened to “Analytic grid equilibrium f…”. Full reference label: “Analytic grid equilibrium floor”.

Paused at the build-time reference state.

Total kinetic energy
200.0000
Relative energy change since reset
-1.28e-15
Temperature from kinetic energy
1.00000
Pressure from wall impulse
2.1071
Ideal-gas pressure
2.0202
Physical whole-wall pressure
2.0860
Compressibility Z
1.0326 plus or minus 0.0010
Packing fraction
0.01603
Henderson bulk prediction
1.0329
Bias-corrected H excess
0.26 plus or minus 0.04
Relative entropy D_grid
0.3198
H convergence threshold
0.08 nats
Measured gas state
QuantityMeasured value
Total kinetic energy200.0000
Relative energy change since reset-1.28e-15
Temperature from kinetic energy1.00000
Pressure from wall impulse2.1071
Ideal-gas pressure2.0202
Physical whole-wall pressure2.0860
Compressibility Z1.0326 plus or minus 0.0010
Packing fraction0.01603
Henderson bulk prediction1.0329
Bias-corrected H excess0.26 plus or minus 0.04
Relative entropy D_grid0.3198
H convergence threshold0.08 nats
Wall-pressure geometry by species
SpeciesCountAccessible perimeterPressureCompressibility Z
Light20039.60002.1070991.032584
Accumulated relaxation diagnostics
TimeBias-corrected HGrid floorExcesssigma_HD_grid
200.00-2.60115-2.858080.256930.041250.31981

The H trace uses accumulated velocity samples and the Miller-Madow correction. Its excess fluctuates about the grid floor; D_grid is the exactly non-negative companion. Convergence means entering two live sigma_H of the floor.

The predicted 2-D speed moments are 1.00000, 1.25331, and 1.41421.

Export

The reference gas state, distribution and equations were computed when the page was built. Running the simulation needs JavaScript.

How this simulation works

Hard disks move in straight lines between closed-form collision times. A deterministic calendar resolves elastic disk and wall collisions without overlap correction.

The Maxwell-Boltzmann distribution in two dimensions

A two-dimensional box produces the Rayleigh speed density, with a linear factor in speed. The familiar three-dimensional Maxwell form has a quadratic factor and is only a contrast here.

Mean, most probable, and root-mean-square speed

At scale s the ratios are 1 : 1.2533 : 1.4142.

Equipartition and temperature

With two translational degrees of freedom, mean kinetic energy is kBT per particle, not 1.5 kBT.

Pressure, and where the ideal gas law comes from

Pressure is measured from wall impulse. The five-unit window fluctuates by about four percent. Cumulative uncertainty falls as 1 / window, not as its square root.

Henderson describes the bulk limit. This simulation is a finite box with hard walls, so the wall-layer density differs slightly from the bulk density and the measured compressibility can sit just below the bulk prediction.

This page derives what the ideal gas law calculator assumes. It has no solve-for-the-unknown mode. Velocity components are Gaussian; areas under that curve belong on the normal distribution page.

Relaxation to equilibrium

Collisions redistribute velocity while total kinetic energy remains fixed to floating-point roundoff. The accumulated H trace uses a Miller-Madow bias correction and compares against the analytic floor on the same grid. Its corrected excess fluctuates about that floor; D_grid remains non-negative.

What this model assumes

Hard disks in two dimensions, fixed hard walls, elastic collisions, and no force between events.

P = wall impulse / (perimeter x window); Z = P A / (N kB T) How?

How this is calculated

The center-accessible side is S = L - 2r, with A = S squared. Finite disks lift Z above 1 through excluded area.

Formula: P = wall impulse / (perimeter x window); Z = P A / (N kB T)

Performance and scope caps
  • Particle count is capped at 400.
  • Packing fraction is capped at 0.25.
  • The event budget slows simulated time rather than skipping physics.

Sources

  1. Algorithms, 4th edition, 6.1 Event-Driven Simulation. Princeton University. Retrieved .
  2. OpenStax University Physics Volume 2, 2.4 Distribution of Molecular Speeds. OpenStax. Retrieved .
  3. Henderson, A simple equation of state for hard discs. Molecular Physics. Retrieved .
  4. Rapaport, The event scheduling problem in molecular dynamic simulation. Journal of Computational Physics. Retrieved .