This is the same bivalent-antibody avidity model as the 3D biosensor scene, rebuilt as an independent 2D engine: a top-down view of the sensor surface plus a genuine second computation running alongside it. Each antibody is a discrete particle cycling through three Markov states with per-arm rate constants: unbound U, singly bound S1, and doubly bound S2 (bivalent IgG only). A released arm sitting beside its still-attached partner has high local effective concentration and can rebind before the molecule diffuses away:
U --kon[Ag]--> S1 S1 --koff--> U
S1 --k_reb--> S2 S2 --2·koff--> S1
In parallel with the per-particle stochastic simulation, a continuum ODE for the population fractions is integrated every frame with 4th-order Runge–Kutta:
dS1/dt = -(koff+k_reb)·S1 + 2koff·S2
dS2/dt = k_reb·S1 - 2koff·S2
During Wash (no free antigen), diagonalizing this 2×2 linear system gives the slow eigenvalue that governs the long-time decay of the bound fraction S1+S2:
k_eff = [ (3koff + k_reb) - sqrt((3koff + k_reb)^2 - 8koff^2) ] / 2
The chart above the readouts plots both the noisy particle-population curve and the smooth deterministic ODE curve during Wash, live-fit with a least-squares regression on ln(bound). They should converge to the same keff, which in turn should match the closed-form eigenvalue above -- three independent routes to the same number. When k_reb is large relative to koff (strong avidity) k_eff collapses far below the intrinsic koff; switch off "Bivalent IgG" to see k_eff reduce exactly to koff, since a monovalent Fab has no second arm to rebind with.
- Inject / Wash — toggles whether free antigen is available (Inject) or removed so only dissociation and rebinding continue (Wash, used to measure keff).
- Measured keff (particles) — least-squares fit of ln(bound fraction) vs. time over the stochastic particle population.
- Measured keff (ODE) — the same regression applied to the deterministic continuum trajectory, which has no sampling noise.
- Reset — clears every antibody and the ODE state back to unbound and restarts both decay histories.