When Cells Bounce Forever
Published:
When Cells Bounce Forever
The Cellular Potts Model simulator had a maddening oscillation problem: two cells bouncing against each other forever, never settling, burning CPU cycles on a biological impossibility. When cells overlap, the naive approach is straightforward – compute the overlap, push them apart. But that push always overshoots.
The naive repulsive correction is proportional to the overlap, but if it overshoots even slightly, the adhesion gradient pulls the cells right back into overlap on the next step. Classic numerical ping-pong:
overlap = (r_a + r_b) − dist(a, b)
push = overlap × (1 − 0.5 × factor)
The fix was a two-pass Gauss-Seidel-like sweep inspired by constraint solvers in game physics. The forward pass applies soft repulsion with factor = 1.0, resolving the worst overlaps first while allowing some residual. The backward pass then sweeps in reverse order with factor = 0.0 (full correction), ensuring that the first pass did not introduce new overlaps with already-processed neighbors. Convergence typically happens in 2-3 iterations instead of the hundreds the old method needed.
On top of that, I implemented Contact Inhibition of Locomotion. When two cells collide, each one repolarizes its migration direction away from the contact normal:
polarity_new = normalize(polarity − 0.3 × contact_direction)
This is not just a numerical trick; CIL is a well-documented phenomenon in neural crest cells and many epithelial tissues. The combination of stable collision resolution and CIL produces migration patterns that finally look biologically plausible. Repository here.
