Home▸Molecular Biology▸Molecular Dynamics — 3D Lennard-Jones Fluid

🧬 Molecular Dynamics — 3D Lennard-Jones Fluid

A real WebGL point-cloud fluid: the same repel-close, attract-medium force law and thermostat as the 2D original, now computed with a 3D spatial grid and rendered in true 3D space you can orbit.

Molecular Biology3DModerate60 FPS📱 Mobile-adapted⇄ 2D version
3d-molecular-dynamics-intermolecular-interactions ↗ Open standalone

This 3D companion runs the exact same two-part force law as the 2D original inside a real WebGL cube: each particle pair closer than the repulsion radius pushes apart with force -15 × (1 - dist/REPULSION_RADIUS), and any pair further out (up to the interaction radius) pulls gently together with attraction × sin(π × (dist - REPULSION_RADIUS) / (INTERACTION_RADIUS - REPULSION_RADIUS)) — the identical piecewise Lennard-Jones-style approximation, just evaluated along a real 3D separation vector instead of a 2D one. A Berendsen-style thermostat gently rescales every velocity each frame toward the target temperature exactly as in the 2D version, gravity pulls the cloud downward, and walls bounce particles back with the same damping factor. The 2D version's flat grid of cells becomes a genuine 3D grid of cubes here, so nearby-pair lookups stay fast with hundreds of particles instead of falling back to an O(n²) scan. Raise the temperature to watch the fluid boil into a fast, disordered gas; lower it and increase attraction to watch particles clump into slow-moving droplets, all while orbiting the cube with the mouse.

⚙ Under the hood

A WebGL point-cloud fluid reproducing the 2D original's repel-close/attract-medium force law and thermostat in true 3D: a 3D spatial grid for neighbor lookups, gravity, damped wall bounces, and speed-tinted particle colors read straight from each particle's velocity.

Molecular DynamicsLennard-JonesIntermolecular ForcesThermostat

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

What did you find?

Add reproduction steps (optional)