⚛️ Molecular Dynamics — Lennard-Jones Simulation

Watch molecules attract and repel each other in real time using the Lennard-Jones potential — the standard model of Van der Waals interactions — to simulate how simple molecules form liquids, crystals, and gases.

🔬 What It Demonstrates

The Lennard-Jones 12-6 potential models strong short-range repulsion (electron shell overlap) and weak long-range attraction (Van der Waals forces). The ratio of thermal energy to potential well depth determines the phase: gas, liquid, or solid.

🎮 How to Use

Adjust temperature to drive phase transitions from crystal to liquid to gas. Change density with the particle count slider. Watch kinetic energy and pressure readouts update in real time.

💡 Did You Know?

Modern supercomputers run MD simulations of billions of atoms to design new drugs, understand protein folding (AlphaFold), and develop better materials — all using the same Lennard-Jones equations shown here.

About the Molecular Dynamics Simulation

This is a real 3D molecular-dynamics engine that places a few hundred atoms in a cubic box and lets them attract and repel through the Lennard-Jones 12-6 pair potential, V(r) = 4ε[(σ/r)¹² − (σ/r)⁶]. Newton's equations are integrated with the energy-conserving velocity-Verlet algorithm, a velocity-rescaling thermostat holds the chosen temperature, and you can orbit the camera while colour shows each atom's speed. As you change temperature and density you watch matter switch between gas, liquid and solid phases in real time.

The Lennard-Jones model captures the essential physics of Van der Waals interactions — steep short-range repulsion from electron-shell overlap and gentle long-range attraction. The same equations, scaled to billions of atoms on supercomputers, drive research into protein folding, drug binding, crystallisation and the design of new materials.

Frequently Asked Questions

What is the Lennard-Jones potential?

The Lennard-Jones 12-6 potential, V(r) = 4ε[(σ/r)¹² − (σ/r)⁶], models a pair of neutral atoms: a steep r⁻¹² repulsion when electron clouds overlap and a gentle r⁻⁶ attraction from Van der Waals forces. It is the standard textbook model for noble gases and a building block of larger molecular-dynamics force fields.

How does the simulation integrate the motion?

It uses the velocity-Verlet algorithm, a symplectic integrator that updates positions and velocities in two half-steps around a force evaluation. With a small time-step it conserves energy far better than simple Euler integration, which is why molecular-dynamics codes rely on it.

How is temperature controlled?

A velocity-rescaling thermostat gently scales all velocities toward the target temperature. By the equipartition theorem the temperature equals 2·KE/(3N) in reduced units, so rescaling the kinetic energy sets the temperature you choose with the slider.

Why do atoms form a solid, liquid or gas?

The phase is decided by the ratio of thermal energy to the depth of the Lennard-Jones well. At low temperature atoms settle into a crystal (solid); raising temperature lets them flow past one another (liquid); higher still and they fly apart to fill the box (gas). Changing the number of atoms changes the density and shifts these boundaries.

What does the interaction strength ε control?

Epsilon sets the depth of the attractive well in the Lennard-Jones potential. A larger ε binds atoms together more strongly, raising the temperatures at which they melt or boil, while a smaller ε makes the substance more volatile and easier to vaporise.

What does the number-of-atoms slider really change?

It sets both the particle count and, through a fixed target number density, the size of the box. More atoms means a larger but equally dense system, which gives smoother statistics for pressure and temperature while staying close to 60 fps.

What is the virial pressure shown in the readout?

Pressure is computed from the virial expression P = (N·T + Σ r·F / 3) / Volume, which combines the ideal-gas kinetic term with the contribution of inter-atomic forces. It lets you see how compression and attraction affect pressure as the phase changes.

Why are the atoms confined and the forces cut off?

Reflecting walls keep the atoms inside a finite box so you can observe them, and the Lennard-Jones force is truncated beyond r = 2.5σ because the attraction is negligible there. The cutoff dramatically speeds up the force calculation without changing the physics noticeably.

Does this simulation need WebGL?

Yes. The atoms are drawn as a Three.js InstancedMesh of spheres rendered with WebGL, and the camera uses OrbitControls so you can drag to rotate. Any modern device with WebGL support runs it smoothly; the atom count is capped to keep the frame rate near 60 fps.

How does this relate to real scientific research?

The very same Lennard-Jones equations scale up on supercomputers to billions of atoms, modelling protein folding, drug binding and new materials. The gas, liquid and solid phases you see emerge purely from this one pair potential plus temperature and density.