HomeThermodynamicsVan der Waals Gas

🧪 Van der Waals Gas

Interactive Van der Waals gas simulation: P-V isotherms, critical point, Maxwell equal-area construction, and liquid-vapour phase transitions for CO2, H2O, N2 and ideal gas.

Thermodynamics3DModerate60 FPS
van-der-waals ↗ Open standalone

About this simulation

Real gases deviate from the ideal gas law PV = nRT because molecules attract each other and take up finite space. The Van der Waals equation of state (P + a·n²/V²)(V − n·b) = nRT corrects for both effects with two substance-specific constants: a for intermolecular attraction and b for excluded volume. This simulation plots a family of P–V isotherms for CO₂, H₂O, N₂, or an ideal gas, shades the Maxwell equal-area construction that replaces the equation's unphysical S-shaped loop below the critical temperature, and animates a small LJ-style particle box so you can watch molecules condense from gas to liquid as you compress them.

🔬 What it shows

The main canvas draws multiple isotherms colour-coded from blue (cold) to red (hot), highlights the critical point where the curve's inflection flattens to zero slope, and fills in the binodal (coexistence) dome that separates stable gas, liquid, and two-phase states. The lower canvas animates particles with Lennard-Jones-style attraction and repulsion so you can watch the same phase transition play out molecule by molecule.

🎮 How to use

Pick a Gas Type (CO₂, H₂O, N₂, Ideal), then drag T/Tc to change temperature and Isotherms shown to add or remove curves. The Volume V/Vc slider acts as a piston — sliding it compresses the gas in real time, moving the current-state dot along the isotherm and updating the Phase chip (gas / liquid / two-phase / supercritical).

💡 Did you know?

Above the critical temperature Tc there's no sharp boundary between "gas" and "liquid" at all — the substance becomes a supercritical fluid, the same trick used to make supercritical CO₂ a solvent for decaffeinating coffee.

Frequently asked questions

What does the Van der Waals equation add to the ideal gas law?

It adds two correction terms to PV=nRT: a/V² accounts for the attractive forces between molecules that reduce the pressure they exert on the container walls, and subtracting nb from the volume accounts for the finite size the molecules actually occupy, so they can't be compressed to zero volume.

What do the constants a and b actually represent?

a (in Pa·m⁶/mol²) measures how strongly a gas's molecules attract one another — a larger a means a more pronounced liquefaction curve and higher critical temperature. b (in m³/mol) is the excluded volume per mole, roughly the volume the molecules themselves take up; water and CO₂ have quite different values, which is why their isotherms and critical points look so different in the simulation.

What is the critical point, and what happens there?

The critical point (Tc, Pc, Vc) is where the liquid and vapour phases become identical — the isotherm has a horizontal inflection (∂P/∂V = ∂²P/∂V² = 0). For the Van der Waals equation this works out to Tc = 8a/27Rb, Pc = a/27b², Vc = 3nb; above Tc, no amount of pressure alone will condense the gas into a distinct liquid.

Why does the simulation shade an area instead of drawing the raw S-shaped curve below Tc?

Below the critical temperature, the raw Van der Waals equation predicts an unphysical loop where pressure would rise as volume increases. The Maxwell equal-area construction replaces that loop with a flat horizontal segment at the real vapour pressure, chosen so the shaded areas above and below the line are equal — this enforces that liquid and vapour have the same chemical potential at equilibrium.

What is the molecular panel actually simulating?

It's a simplified 2D particle system with Lennard-Jones-style short-range repulsion and longer-range attraction, scaled by the same parameter a used in the main equation. As you compress the piston or cool the gas, particles slow down and clump together, visually reproducing the same gas-to-liquid transition the P–V diagram shows mathematically.

⚙ Under the hood

Real gas P-V isotherms with the van der Waals equation. Maxwell equal-area construction, critical point, and compressibility factor Z.

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)