Janus colloids — learning general pair interactions from experimental tracks

real-data overdamped multi-particle linear custom-basis 2D non-equilibrium

Self-propelled Janus colloids interact through electrostatic and hydrodynamic forces that cannot be computed from first principles. Hem, Poncet, Ronceray, Nishiguchi and Démery (Soft Matter 2025, doi:10.1039/D5SM00655D) learned them from tracking data instead, with a generic basis: a Fourier series in the two relative orientations times smooth radial functions, for the radial velocity, the transverse velocity and the torque that one colloid induces on another.

This page redoes that analysis with SFI on the experimental tracks the authors distribute with their code — the first 100 frames of their flocking dataset (set A, Iwasawa, Nishiguchi & Sano, Phys. Rev. Research 2021), about 1 700 colloids at 15 frames per second — then simulates the learned model to see whether it flocks.

Tags

real-data · overdamped · multi-particle · linear · custom-basis · 2D · non-equilibrium

stamp_output()
[Generated: 2026-10-19 21:52]

The experiment

Silica spheres of diameter \(\sigma = 3.17\,\mu\)m, half-coated with titanium, swim metal side first under a vertical AC field and organise into a polar flock. The movie of this experiment published with Iwasawa et al. (arXiv:2011.14548, ancillary file, 30 fps):

The tracks — position, heading \(\varphi\) and a track label per detected particle and frame — come from the authors’ repository (5 MB, read without executing code from the file). Particles enter and leave the field of view, so the tracks become a masked collection, with per-frame neighbour lists and a fit mask that keeps particles near the edges (whose neighbours were partly not recorded) as neighbours only:

frames, dt, fov = load_set_a(cache_dir)
R_C = 21.0                                          # interaction range (µm), as in the paper
coll = tracks_collection(frames, dt, fov, cutoff=R_C, margin=40.0)
print(f"{len(frames)} frames at dt = {dt:.4f} s, {coll.datasets[0].X.shape[1]} tracks, "
      f"{np.mean([len(f) for f in frames]):.0f} particles per frame")
100 frames at dt = 0.0667 s, 2079 tracks, 1714 particles per frame

The generic interaction basis

The effect of particle 2 on particle 1 is a radial velocity \(v_r\), a transverse velocity \(v_\theta\) and a torque \(\omega\), functions of the distance \(r\) and of the headings \(\theta_1, \theta_2\) measured from \(\mathbf r_1 - \mathbf r_2\). The paper expands them as \(\sum_l g_l(r) \sum_{|k_1|+|k_2| \le N_a} a_{l,k_1k_2} \cos\text{ or }\sin(k_1\theta_1 + k_2\theta_2)\) — cosines for \(v_r\), sines for \(v_\theta\) and \(\omega\), as parity requires — with \(g_l(r) = r^l e^{-r}/l!\) (\(r\) in µm, \(l = 0, 2, \ldots, 14\), as in the paper’s code). In SFI this is the product of a radial and an angular pair interactor; we multiply the radial functions by a window that vanishes smoothly at \(r_c\) and below \(1.5\,\sigma\), where the tracks hold almost no pairs. Self-propulsion and three more one-body terms complete the basis.

from SFI.bases import unit_axes, x_components
from SFI.bases.pairs import heading_vector, scalar_pair_basis
from SFI.statefunc import Basis

kernels = tapered_polyexp_kernels(cutoff=R_C, onset=(1.0 * SIGMA, 1.5 * SIGMA))


def pair_interactions(Na, box=None):
    return scalar_pair_basis(kernels, dim=3, box=box, spatial_dims=slice(0, 2)) * orientation_features(Na, box=box)


def pair_basis(Na, box=None):
    return pair_interactions(Na, box).dispatch_pairs_from_extras(
        indptr_key="indptr", indices_key="indices", return_as="basis")


x, y, phi = x_components(3)
e_x, e_y, _ = unit_axes(3)
e_heading = heading_vector(dim=3, angle_index=2)                                   # U ê_φ
e_side = phi.elementwisemap(jnp.sin) * e_x - phi.elementwisemap(jnp.cos) * e_y     # ê_φ⊥
one_body = [e_x, e_y, e_heading, e_side]

pairs_2 = pair_basis(Na=2)
basis = Basis.stack([*one_body, pairs_2])
print(f"{basis.n_features} features, {pairs_2.n_features} of them pair interactions")
156 features, 152 of them pair interactions

Inference

Linear SFI, on every frame. The tracks carry localisation noise (we measure it below), so we use Itô-shift moments — the basis is evaluated one frame before each displacement, whose noise it then does not see — with the trapeze Gram matrix. The ill-conditioned radial functions (SFI warns about the Gram matrix) are why this script runs JAX in double precision.

from SFI import OverdampedLangevinInference

inf = OverdampedLangevinInference(coll)
inf.compute_diffusion_constant(method="WeakNoise")
inf.infer_force_linear(basis, M_mode="Ito-shift", G_mode="trapeze")
inf.compute_force_error()

U, U_cov = inf.coeff_block(e_heading)
U = float(np.ravel(U)[0])
print(f"self-propulsion U = {U:.2f} ± {float(np.sqrt(np.ravel(U_cov)[0])):.2f} µm/s")
UserWarning: force Gram condition number 1.60e+11 > 1e+08: the basis is ill-conditioned on these data (collinear or badly scaled features); the coefficients and error estimates are unreliable - drop or rescale features, or sparsify.
self-propulsion U = 9.61 ± 0.16 µm/s

The learned interactions

The analogue of the paper’s Fig. 2, at \(r = 2.5\,\sigma\), the most frequent neighbour distance. Left: how often each pair of relative orientations occurs — neighbours mostly move in the same direction (\(\theta_1 \approx \theta_2\)). Hatching marks where the 95 % confidence interval is wider than the value.

read = interaction_reader(pair_interactions(2))
value, stderr = read(*inf.coeff_block(pairs_2), 2.5 * SIGMA, T1, T2)
t1_obs, t2_obs = relative_orientations(frames, 2.25 * SIGMA, 2.75 * SIGMA)
pairs at $r \approx 2.5\,\sigma$, $v_r/U$, $v_\theta/U$, $\sigma\omega/U$

A repulsion strongest when particle 1 is in front of particle 2 and turned sideways, a weak transverse velocity, and a torque that turns particle 1 away from particle 2, most strongly when particle 2 faces it (\(\theta_2 \approx 0\)) — the “modulated turning away” of the paper. Along \(r\), with the distribution of pair distances:

r = np.linspace(1.3 * SIGMA, 6.5 * SIGMA, 120)
profiles = {t1: read(*inf.coeff_block(pairs_2), r, t1, 0.0) for t1 in (np.pi / 2, 3 * np.pi / 2)}
janus colloids demo

How much noise, and does it matter?

SFI’s measurement-noise estimate \(\hat\Lambda = -\langle \Delta X_t\,\Delta X_{t-1}\rangle\) comes out negative on the positions: successive displacements of a swimmer are correlated, and that persistence, \(\langle F_t F_{t-1}\rangle\Delta t^2\), hides the noise. On the residuals of the fit, \(r_t = \Delta X_t - \hat F(X_t)\Delta t\), the drift is gone and the same estimator works:

Lam, D_res = residual_noise(inf, coll)
noise_sd = np.sqrt(np.clip(np.diag(Lam), 0, None))
D_r = D_res[2, 2]
print("Λ̂ from displacements (x, y, φ):", np.diag(np.asarray(inf.Lambda)).round(4))
print("Λ̂ from residuals     (x, y, φ):", np.diag(Lam).round(4))
print(f"localisation noise {noise_sd[0]:.2f}, {noise_sd[1]:.2f} µm and {np.degrees(noise_sd[2]):.1f}°;  "
      f"rotational diffusion D_r = {D_r:.3f} 1/s")
Λ̂ from displacements (x, y, φ): [-0.0634 -0.0672  0.0007]
Λ̂ from residuals     (x, y, φ): [0.0754 0.1073 0.0014]
localisation noise 0.27, 0.33 µm and 2.1°;  rotational diffusion D_r = 0.064 1/s

About two pixels of positional noise — as large as the distance a colloid swims in a frame — and a few degrees on the headings. To see what that does to the inference, we let the learned model generate data with a known answer: simulate it from the first frame (periodic box of the size of the field of view, the rotational diffusion just measured, translational diffusion neglected as in the paper), add noise of the measured size, and refit — with Itô-shift, and with the paper’s convention (Stratonovich moments, rectangle Gram matrix, preset="legacy-sfi-v1.0").

D_sim = np.diag([0.0, 0.0, D_r])
x0 = frames[0][:, :3]
sim = dict(box=fov, dt=dt, cutoff=R_C)
X_true = simulate_fitted(inf, one_body, pairs_2, kernels, 2, x0, 10 + len(frames) * dt, D=D_sim,
                         key=jax.random.PRNGKey(1), **sim)[-len(frames):]
rng = np.random.default_rng(0)
X_noisy = X_true + noise_sd * rng.standard_normal(X_true.shape)

configs = sample_pair_configurations(X_true[::10], fov, R_C, 20000, rng)
v_true, _ = read(inf.coeff_block(pairs_2)[0], None, *configs.T)
print(f"{'refit on simulated noisy tracks':34s}    U    error on  v_r   v_θ    ω   (true U = {U:.2f})")
for label, opts in [("Itô-shift, trapeze", dict(M_mode="Ito-shift", G_mode="trapeze")),
                    ("paper: Stratonovich, rectangle", dict(preset="legacy-sfi-v1.0"))]:
    pairs_b = pair_basis(2, box="extras")
    refit = OverdampedLangevinInference(periodic_tracks_collection(X_noisy, dt, fov, cutoff=R_C))
    refit.compute_diffusion_constant(method="WeakNoise")
    refit.infer_force_linear(Basis.stack([*one_body, pairs_b]), **opts)
    v_fit, _ = read(refit.coeff_block(pairs_b)[0], None, *configs.T)
    err = np.sqrt(np.mean((v_fit - v_true) ** 2, 0) / np.mean(v_true ** 2, 0))
    print(f"{label:34s} {float(np.ravel(refit.coeff_block(e_heading)[0])[0]):6.2f}"
          f"   {'':9s}{err[0]:5.2f} {err[1]:5.2f} {err[2]:5.2f}")
refit on simulated noisy tracks       U    error on  v_r   v_θ    ω   (true U = 9.61)
UserWarning: force Gram condition number 8.10e+10 > 1e+08: the basis is ill-conditioned on these data (collinear or badly scaled features); the coefficients and error estimates are unreliable - drop or rescale features, or sparsify.
Itô-shift, trapeze                   9.59             0.14  0.30  0.14
UserWarning: force Gram condition number 5.41e+10 > 1e+08: the basis is ill-conditioned on these data (collinear or badly scaled features); the coefficients and error estimates are unreliable - drop or rescale features, or sparsify.
paper: Stratonovich, rectangle      10.03             0.34  1.26  0.43

(Relative RMS errors over the simulated pairs.) Itô-shift recovers the self-propulsion and, to within roughly 15–30 %, the interactions; the transverse velocity, the weakest of the three, is the least precise. The Stratonovich moments of the paper are thrown off by the noise on the positions: their Itô-to-Stratonovich correction rests on a per-step diffusion estimate that, for particles swimming at \(U\), is dominated by \(U^2\Delta t\).

Does the learned model flock?

As in the paper we fit models of angular order \(N_a = 0\) (isotropic radial interactions only), 1 and 2, and simulate each for 60 s from the first experimental frame. The flock is a balance between turning-away torques and rotational noise, so we also run the first-order model with the paper’s rotational diffusion, \(D_r = 0.092\) s⁻¹.

models = {2: (inf, pairs_2)}
for Na in (0, 1):
    pairs_Na = pair_basis(Na)
    models[Na] = (OverdampedLangevinInference(coll), pairs_Na)
    models[Na][0].compute_diffusion_constant(method="WeakNoise")
    models[Na][0].infer_force_linear(Basis.stack([*one_body, pairs_Na]), M_mode="Ito-shift", G_mode="trapeze")

def run(Na, D, seed):
    fitted, pairs_Na = models[Na]
    return simulate_fitted(fitted, one_body, pairs_Na, kernels, Na, x0, 60.0, D=D, key=jax.random.PRNGKey(seed), **sim)


runs = {Na: run(Na, D_sim, 10 + Na) for Na in (0, 1, 2)}
runs["1, paper D_r"] = run(1, np.diag([0.0, 0.0, 0.092]), 11)
for name, X in runs.items():
    print(f"N_a = {name}: polar order after 60 s = {np.abs(np.exp(1j * X[-1, :, 2]).mean()):.2f}")
UserWarning: force Gram condition number 2.23e+09 > 1e+08: the basis is ill-conditioned on these data (collinear or badly scaled features); the coefficients and error estimates are unreliable - drop or rescale features, or sparsify.
UserWarning: force Gram condition number 3.54e+10 > 1e+08: the basis is ill-conditioned on these data (collinear or badly scaled features); the coefficients and error estimates are unreliable - drop or rescale features, or sparsify.
N_a = 0: polar order after 60 s = 0.02
N_a = 1: polar order after 60 s = 0.43
N_a = 2: polar order after 60 s = 0.77
N_a = 1, paper D_r: polar order after 60 s = 0.05

The experiment (left) and the second-order model (right), from the same frame, over the 6.7 s of the recording:


Statistics the fit never used: the polar order \(C(S)\) in square regions of area \(S\) (second half of each run), the polarity autocorrelation \(f_p(\tau) = \langle\cos[\varphi(t+\tau) - \varphi(t)]\rangle\), and the density of neighbours around a particle in its own frame.

sides = np.array([10.0, 20.0, 40.0, 84.0, 168.0])
lags = np.arange(0, 451, 5)
C_data = polar_order_vs_area(frames, fov, sides)
fp_data = polarity_autocorrelation(np.where(present, X_obs[..., 2], np.nan), lags[lags < len(frames)])
C_sim = {Na: polar_order_vs_area(list(X[len(X) // 2:]), fov, sides) for Na, X in runs.items()}
fp_sim = {Na: polarity_autocorrelation(X[..., 2], lags[lags < len(X)]) for Na, X in runs.items()}
rho_data = body_frame_density(frames, fov)
rho_sim = body_frame_density(list(runs[2][len(runs[2]) // 2::5]), fov, periodic=True)
  • polar order, polarity autocorrelation
  • experiment, model $N_a = 2$

Isotropic interactions alone (\(N_a = 0\)) do not flock: the order of the first frame is lost and \(C(S)\) falls as \(S^{-1/2}\). The second-order model reproduces the experiment — the polar order at all region sizes, the polarity autocorrelation over the recording, the ring of neighbours at \(r \approx 2.5\,\sigma\). The first-order model keeps a weaker order with the rotational diffusion measured here and none with the paper’s larger \(D_r\): as in the paper, the second angular order is needed.

Comparison with the paper

With 3 % of the data the qualitative picture of the paper is recovered — the self-propulsion speed, a mostly isotropic repulsion, a weak transverse velocity, a modulated turning-away torque, and a flocking simulation. Where we differ:

  • Localisation noise. About two pixels on positions, not “below one pixel”. At this level the paper’s Stratonovich estimator overestimates \(U\) and misses the radial velocity substantially in the bootstrap above; the amplitudes of its Fig. 2 are uncertain to that extent.

  • Rotational diffusion. Measured on the residuals of the fit, \(D_r\) comes out about a third below the paper’s 0.092 s⁻¹. The conclusion that the second angular order is needed holds at both values, but how much order the first-order model keeps depends on it.

  • Radial basis. The paper’s text describes \(g_l\) with \(l = 0 \ldots 7\) and \(r_0 = 2\,\mu\)m; its code — and this page — use \(l = 0, 2, \ldots, 14\) with \(r_0 = 1\,\mu\)m. The code also truncates them at \(r_c\) while still nonzero, which biases Stratonovich moments; the window here vanishes smoothly.

Thumbnail

Total running time of the script: (34 minutes 47.812 seconds)

🏷 Tags: real-data, overdamped, multi-particle, linear, custom-basis, 2D, non-equilibrium

Gallery generated by Sphinx-Gallery