Back Original

micrographia

Kshitij Lauria

I’ve been working on a new project called micrographia, named after Robert Hooke’s pioneering book. It’s not fully cooked yet, but I want to give you a preview and tell you why I think it’s cool.

At the micro-level the laws of physics are exactly time-reversible, yet at the macro scale there’s a clear arrow of time. This demo explores why.

The project is a collection of interactive pages, each one answering a question and explaining some physics using live simulations that run in a browser. I started making them to help my own understanding of statistical mechanics and physical chemistry. I just found it so helpful to see atoms jiggle around, and to reach in and directly mess with them! Like mixing oil and water with a spoon:

Separation of oil and water, with entropy and energy pulling in opposite directions. Try mixing them with a spoon!

My first job after college was working on biomolecular simulations at D. E. Shaw Research. They designed custom chips and built supercomputers for running huge simulations of complex biological systems. Since leaving that job I’ve had a soft spot for molecular dynamics simulations, but I haven’t done much with them until now.

There are three reasons this project is possible now.

  1. Consumer GPUs are powerful and ubiquitous on laptops and phones.
  2. WGSL is mature and widespread, allowing me to run physics simulation code on your GPU, inside your browser, without going through a bunch of tricky driver and installation stuff. Whether your GPU is integrated or NVIDIA or AMD or Apple, WGSL can run on it. Also, wasm is mature and widespread, so we can have fast compiled Rust code for all the non-GPU parts of simulation.
  3. LLMs have made it possible to write a clean, fast new MD simulator that targets WGSL and to validate it against battle-tested workhorses. There’s a vast literature on writing MD simulators, many existing implementations, and both correctness and performance are easy to measure. Just about perfect for an LLM implemetation.

One of the coolest entropic effects: the depletion effect, which is very important inside our cells. The presence of small particles pushes big particles together purely because that increases entropy.

That’s all for now. I’m working on the demos, writing, and experimenting with recording video of myself talking as I explain the physics. The MD engine works but I think it could be faster. It also needs more features to be able to show certain phenomena I care about.

On the code side, there are some interesting design challenges. The MD engine needs to support interactive changes while the simulation runs: add these particles, turn off this interaction, stir it all with a spoon.

It seems like many interesting phenomena remain out of reach for in-browser simulations, like proper liquid-gas phase transitions. And of course proper simulation of molecular machines like proteins, nucleic acids and ion channels remains a far-off dream.