Visualizations
419 / 500

419 · Emergence

Self-Assembly

Lipid membrane patches assemble themselves from a random soup into closed vesicles.

Each particle is a small patch of lipid bilayer, drawn as lipids back to back with heads out and tails in, simulated with the one-particle-thick membrane model of Yuan and coworkers. An anisotropic pair potential only rewards patches that sit side by side with their normals perpendicular to the bond and splayed by a set angle, so patches line up into sheets that prefer a certain curvature, and a second parameter sets how hard that order is enforced: the membrane's bending rigidity. Overdamped Brownian dynamics, using the exact gradients of the potential for forces and torques and a periodic cell list, runs dozens of steps a frame. From noise you watch the disc-to-vesicle route: fragments stick into curved sheets, sheets join edge to edge, and once the exposed edges cost more than bending, they close into vesicles whose trapped water is tinted.

Try it. Drag through the membranes to squeeze, tear and pinch vesicles and watch the edges zip back together. Click to drop in a puff of new patches. Curvature sets the vesicle size, Concentration adds or removes material, Add sterols stiffens the membranes that carry them, and Heat and cool melts everything back into soup to assemble again (arrow keys, S, H and R work too).

  • Brownian dynamics
  • Anisotropic pair potential
  • Cell lists
  • Union-find census

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a 2D self-assembling membrane simulation with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Scatter about 400 particles at random in a box with wrap-around edges. Each has a position and an angle; the angle's unit vector n is the direction its membrane faces.
- Give each pair of particles closer than 2.6 a potential that makes them stick side by side: a short-range repulsion below 1.12 and an attraction out to 2.6, and multiply the attraction by a factor that is largest when both n vectors are perpendicular to the line joining the pair and parallel to each other (the cross product of each n with the unit separation, multiplied together, works well).
- Compute forces and torques as minus the gradient of that energy, then move every particle with overdamped Brownian dynamics: position += force * dt + a Gaussian kick of size sqrt(2 kT dt), and the same for the angle with its torque. Use a grid of cells for the neighbor search so it stays fast.
- Draw each particle as a short bar perpendicular to n so you can see chains forming.

Once that works, make it beautiful:
- Add a spontaneous curvature: reward neighboring n vectors that splay apart by a small angle theta0, so chains curl up and close into rings.
- Draw each particle as a little bilayer: two lipids back to back with round heads facing out and thin tails meeting in the middle, outer heads in one color and inner heads in another.
- Let me drag the mouse to push particles aside and squeeze the vesicles, and add sliders for temperature and curvature.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as counting closed vesicles with union-find, tinting the water trapped inside them, or a heat-and-cool button that melts everything and lets it assemble again.
PreviousTriangle CentersDrag a triangle: 46 Kimberling centers, the Euler line and Morley's triangle follow. NextRogue WavesA storm swell where walls of water rise from nowhere through nonlinear focusing.

Related visualizations

  • Cell SortingEmergence A Cellular Potts tissue unmixes itself by differential adhesion, on a stained slide.
  • Particle LifeEmergence Colored particles with simple attractions that assemble into living cells.
  • Melting CrystalSimulation Nearly 2,000 atoms freeze into crystal grains, melt and boil from one pairwise force.
  • Social AmoebaeEmergence Starving amoebae relay spiral waves of cAMP and stream together into mounds.
  • GastrulationSimulation A vertex-model embryo folds its own gut, purely from cell mechanics.
  • Seashell PatternsNature Meinhardt's lip chemistry paints tents, bands and dots onto a growing 3D shell.
  • Active AstersEmergence Microtubules and motor proteins self-organize into asters, in two-color fluorescence.
  • Slime MoldEmergence Simple agents leave trails that self-organize into living networks.
  • Turing PatternsEmergence Two chemicals react and diffuse into coral, spots and stripes.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs