Lecture note · Fig. 17 · the living scenes
Living scenes: the physics behind the small pictures of this site
Numa Koudsie · for school students and undergraduates; paragraphs marked ★ are for readers who want every step
1Thirteen small pictures
Look out of a train window at a field of wind turbines. Each turns at its own pace, and for a moment two of them seem to turn together, then drift apart again. Or watch dust in a shaft of sunlight in a quiet room: every speck trembles, though nothing seems to push it. Most of the small pictures on this site are made of moments like these, ordinary sights with a piece of physics underneath.
The pictures are of two kinds. Four are drawings that tell a story without a model of forces behind them: the chip being traced and stamped across a wafer, the seeds growing into a rose, an ear of wheat and grapes, the motes rising through the waterline of the "shores of light", and the cloud atlas that sets the ten kinds of cloud side by side (the forest's sky is drawn from the same atlas). Their rules are written down in the scene's own description and in the guide to the code (docs/scripts/bg-scenes.md), and this note does not pretend they are more.
The others are physics: the spinners (section 2), the paper globes swinging in a vortex street, the dust in a sunbeam (Brownian motion), the three gases mixing (elastic collisions), the swerve of Lucretius' falling atoms, the iron powder on the field lines of magnets and a wire, the harmonica's rings of pressure (the wave equation), the roots growing towards water, and the forest whose trees seed their neighbours. For each of these the site follows one rule, the same rule as for its large simulations. The equations are solved once, carefully, on Kaggle, with every number of the solution stored at the line of code that computes it, and with checks of the solution against what the equations predict on paper. The stored files are kept on this site with their SHA-256 fingerprints; your browser downloads a file, checks its fingerprint, and only plays it back. Nothing you see is recomputed for the display. Where a knob changes the physics, it therefore offers a choice among the values that were computed, and the panel says so; knobs that only change the drawing stay free.
Two scenes are computed on Kaggle so far: the paper globes in the vortex street, and the spinners. The others still compute their picture in your browser as they run, and are moved to Kaggle one at a time; each gets its section in this note when it moves.
2Spinners falling into step
Hang a compass needle in a jar of thick oil and turn a magnet slowly round the jar. The needle follows, a little behind, as if pulled by an elastic thread. Turn the magnet faster and the needle falls further behind, until at some speed it can no longer keep up: it slips back by a whole turn, catches up for a while, and slips again. That moment, when following turns into slipping, is the whole of the spinners scene.
2.1What the scene shows
A rectangular lattice of 72 × 9 small three-armed rotors fills the band; the page draws the middle part of it that fits the screen, one rotor every 28 pixels across and 29.5 down on the home page, closer together here so that the whole lattice fits. Every rotor would turn on its own at its own rate. A field that rotates at a fixed rate \(\Omega\) wanders over the lattice; its footprint is drawn as a faint ring and its direction as a short bar through the ring's centre. Rotors near the centre of the field are pulled towards its direction. Those that are pulled into turning with it are drawn bright; the rest are drawn faint.
The picture we have in mind is Adler's own. In 1946 Robert Adler, an engineer at Zenith Radio, derived the equation for an oscillator pulled by an outside signal of nearly its own frequency, and noted that the same equation describes a pendulum hanging in a viscous fluid inside a rotating container [1]. Our rotors are such needles in oil, and the field is the turned magnet.
2.2The model
Take one rotor, a small magnet with magnetic moment \(m\) (in A m²) on a vertical axis, its angle \(\theta\) measured in the plane. Three torques act on it. A small constant driving torque \(\tau_0\), from a motor or a breath of wind on a pinwheel, would keep it turning. The oil resists turning with a torque \(-\zeta\,\dot\theta\), proportional to the rate, with a friction coefficient \(\zeta\) (in N m s). And a magnetic field of strength \(B\) pointing at the angle \(\varphi\) twists the magnet towards itself with the torque \(m B \sin(\varphi - \theta)\): zero when the magnet points along the field, largest when it stands across it. Newton's law for rotation, with moment of inertia \(I\), reads
\[ I\,\ddot\theta = \tau_0 - \zeta\,\dot\theta + m B \sin(\varphi - \theta). \tag{1}\]In thick oil the inertia hardly matters. A rotor set turning and left alone stops within the time \(I/\zeta\); if that time is short compared with every other time in the problem (we will see that the shortest is about \(1/K\), defined below), the left-hand side of (1) can be dropped. This is the overdamped limit, the same limit in which a spoon sinks through honey at a steady speed instead of accelerating. Dividing by \(\zeta\),
\[ \dot\theta = \omega + K \sin(\varphi - \theta), \qquad \omega = \frac{\tau_0}{\zeta}, \quad K = \frac{m B}{\zeta}. \tag{2}\]Both new symbols are rates, in rad/s. The rotor's own rate \(\omega\) is how fast it turns with no field. The pull \(K\) is the largest change of rate the field can impose. For the field turning steadily, \(\varphi = \Omega t\).
The scene puts \(N = 648\) such rotors at the points of a lattice, with lattice spacing as the unit of length, row \(j\), column \(i\). Their own rates differ: they are drawn once, at random, with \(|\omega_i|\) uniform between 1.5 and 5 rad/s and the sense of turning at random, so that 311 rotors turn the same way as the field and 337 against it. The field's pull is strongest at its centre \(\mathbf s(t)\) and falls off over a footprint of width \(\sigma = 4\) spacings, and each rotor is also pulled towards the angle of its four nearest neighbours with a pull \(\kappa\):
\[ \dot\theta_i = \omega_i + K(\mathbf r_i, t)\,\sin(\Omega t - \theta_i) + \kappa \sum_{j\,\in\,\text{nb}(i)} \sin(\theta_j - \theta_i), \qquad K(\mathbf r, t) = K_0\, e^{-|\mathbf r - \mathbf s(t)|^2/2\sigma^2}. \tag{3}\]The neighbour term is the coupling of the Kuramoto model, the standard model of many oscillators pulling one another into step [2]; a lattice of such oscillators driven by an outside rhythm is studied, for coupling of every oscillator to every other, by Antonsen and co-workers [3]. The field turns at \(\Omega = 3\) rad/s, about one turn every two seconds. Its centre swings across and down the lattice along a closed path, \(s_x = 35.5 + 26.64 \sin(2\pi \cdot 3t/T)\), \(s_y = 4 + 2.97 \sin(2\pi\cdot 5t/T + 1)\), so that it returns to its start after the run of \(T = 80\) s. The two knobs of the panel choose the pull at the centre, \(K_0 \in \{0, 4, 10, 20\}\) rad/s, and the neighbours' pull, \(\kappa \in \{0, 1, 3\}\) rad/s: twelve runs, all computed and stored.
2.3One rotor in a steady field: locking and slipping
Start with one rotor and no neighbours, and hold \(K\) fixed. The question "does the rotor follow the field?" is about the angle between them, so we watch the rotor from a turntable that turns with the field, as you would watch the needle while walking round the jar with the magnet. Write \(\psi = \theta - \Omega t\) for the angle by which the rotor is ahead of the field, and \(\Delta = \omega - \Omega\) for its mistuning, how much faster than the field it would turn on its own. Since \(\dot\psi = \dot\theta - \Omega\) and \(\sin(\Omega t - \theta) = -\sin\psi\), equation (2) becomes
\[ \dot\psi = \Delta - K \sin\psi. \tag{4}\]This is Adler's equation [1]. Everything about one rotor follows from it, and Figure 1 shows how: plot \(\dot\psi\) against \(\psi\). Where the curve lies above zero, \(\psi\) grows; below zero, it shrinks; where it crosses zero, \(\psi\) stands still.
If \(|\Delta| < K\), equation (4) has two points of rest in each turn, where
\[ \sin\psi^* = \frac{\Delta}{K}. \tag{5}\]The rotor stays at a fixed angle from the field and turns at exactly \(\Omega\): it is locked. A rotor that would turn faster than the field (\(\Delta > 0\)) runs ahead of it by \(\psi^*\), held back by the field's torque; a slower one lags behind. Only one of the two points holds. Push the rotor a little away from \(\psi^*\), to \(\psi^* + \delta\); expanding \(\sin(\psi^* + \delta) \approx \sin\psi^* + \delta\cos\psi^*\) in (4) gives \(\dot\delta = -K\cos\psi^*\,\delta\). At the point with \(\cos\psi^* = +\sqrt{1 - \Delta^2/K^2}\) the push dies away,
\[ \delta(t) = \delta(0)\, e^{-t/\tau_\text{lock}}, \qquad \tau_\text{lock} = \frac{1}{\sqrt{K^2 - \Delta^2}}, \tag{6}\]and at the other point, with the opposite sign of the cosine, it grows. The locking is quickest deep inside the locking range and becomes slow at its edge, where \(\tau_\text{lock}\) grows without bound: a rotor that is only just able to lock takes a long time to settle.
If \(|\Delta| > K\), there is no point of rest. The field can slow the rotor's lead, but not stop it: \(\psi\) keeps turning, and every time it gains a whole turn the rotor has slipped one turn relative to the field. The time this takes is the time of one turn of \(\psi\),
\[ T_\text{slip} = \int_{-\pi}^{\pi} \frac{\mathrm d\psi}{\Delta - K\sin\psi} = \frac{2\pi}{\sqrt{\Delta^2 - K^2}}. \tag{7}\]★ The integral is done with the substitution \(u = \tan(\psi/2)\), which turns \(\psi\) from \(-\pi\) to \(\pi\) into \(u\) from \(-\infty\) to \(\infty\), with \(\mathrm d\psi = 2\,\mathrm du/(1 + u^2)\) and \(\sin\psi = 2u/(1 + u^2)\). The integrand becomes \(2\,\mathrm du / (\Delta u^2 - 2Ku + \Delta)\). Completing the square, \(\Delta u^2 - 2Ku + \Delta = \Delta\big[(u - K/\Delta)^2 + a^2\big]\) with \(a^2 = (\Delta^2 - K^2)/\Delta^2\), which is positive exactly when \(|\Delta| > K\). Then \(\int_{-\infty}^{\infty}\mathrm du/\big((u - c)^2 + a^2\big) = \pi/a\), and the integral is \((2/\Delta)(\pi/a) = 2\pi\,\mathrm{sign}(\Delta)/\sqrt{\Delta^2 - K^2}\); its size is (7), and its sign says which way the rotor slips.
A slipping rotor gains one turn on the field every \(T_\text{slip}\), so its mean rate is
\[ \langle\dot\theta\rangle = \Omega + \mathrm{sign}(\Delta)\,\sqrt{\Delta^2 - K^2} \quad (|\Delta| > K), \qquad \langle\dot\theta\rangle = \Omega \quad (|\Delta| \le K). \tag{8}\]An overdamped rotor with own rate \(\omega\), pulled with strength \(K\) by a field turning at \(\Omega\), turns exactly with the field when \(|\omega - \Omega| < K\), at the fixed angle (5), and settles there within \(1/\sqrt{K^2 - (\omega-\Omega)^2}\). Outside that range it slips one turn every \(2\pi/\sqrt{(\omega-\Omega)^2 - K^2}\), and its mean rate (8) is pulled towards \(\Omega\) but not onto it.
Three checks. The units: \(\Delta\) and \(K\) are rates, so \(2\pi/\sqrt{\Delta^2 - K^2}\) is a time. Far from locking, \(|\Delta| \gg K\), equation (8) gives \(\langle\dot\theta\rangle \to \Omega + \Delta = \omega\): a weak field does not matter. Without a field, \(K = 0\), (7) gives \(T_\text{slip} = 2\pi/|\omega - \Omega|\), the time in which two hands turning at \(\omega\) and \(\Omega\) come back to the same angle, the beat of two clocks. A number: a rotor with \(\omega = 5\) rad/s in a field with \(\Omega = 3\) rad/s and \(K = 1\) rad/s has \(\Delta = 2\), slips every \(2\pi/\sqrt3 = 3.63\) s and turns on average at \(3 + \sqrt3 = 4.73\) rad/s.
2.4Which rotors the field can catch
The pull is not the same everywhere: it falls off from \(K_0\) at the field's centre as \(K_0\, e^{-r^2/2\sigma^2}\) at the distance \(r\). A rotor with mistuning \(\Delta\) can be locked only where the pull exceeds \(|\Delta|\), that is inside the locking radius
\[ r_\text{lock} = \sigma \sqrt{2\ln\!\big(K_0/|\Delta|\big)} \qquad (|\Delta| < K_0), \tag{9}\]found by solving \(K_0 e^{-r^2/2\sigma^2} = |\Delta|\) for \(r\). Rotors with \(|\Delta| \ge K_0\) cannot be locked anywhere. The stored rotors fall into two groups (Figure 3). Those that turn the same way as the field have \(\omega\) between 1.5 and 5 rad/s and so \(\Delta\) between −1.5 and 2 rad/s: small mistunings. Those that turn against it have \(\omega\) between −5 and −1.5 rad/s and so \(\Delta\) between −8 and −4.5 rad/s: to lock them the field must first stop them and turn them round.
A worked example with the default \(K_0 = 10\) rad/s. A rotor with \(\omega = 5\) rad/s (\(\Delta = 2\)) is caught within \(r_\text{lock} = 4\sqrt{2\ln 5} = 7.18\) spacings of the centre, almost twice the ring drawn on the screen, and at the centre it settles within \(\tau_\text{lock} = 1/\sqrt{100 - 4} = 0.10\) s. A rotor turning the other way at \(\omega = -5\) rad/s (\(\Delta = -8\)) is caught only within \(4\sqrt{2\ln 1.25} = 2.67\) spacings. With \(K_0 = 4\) rad/s, no rotor that turns against the field can be caught at all, since \(|\Delta| \ge 4.5 > 4\); every rotor that turns with it can, within 4.7 to 6.7 spacings. With \(K_0 = 20\) rad/s every rotor in the lattice can be caught near enough to the centre.
Kaggle tested (9) on the whole lattice code. With the field held still at the centre of the lattice, \(K_0 = 10\) rad/s and \(\kappa = 0\), it ran all 648 rotors for 120 s and counted as locked every rotor that made no slip in the second half of the run. Equation (9) predicts 108 locked rotors; 115 made no slip. The seven rotors that differ all lie just outside their locking radius, and (7) gives their slip periods as 114 to 736 s, longer than the 60 s in which they were watched: they are slipping, but too slowly to be caught at it. No rotor predicted to lock failed to.
2.5A moving field and pulling neighbours
In the scene the field does not stand still. At the middle of its swing its centre moves at \(26.64 \times 2\pi \times 3/80 = 6.3\) spacings per second, and crosses its own footprint, \(2\sigma = 8\) spacings, in 1.3 s. That is long compared with the locking time of a well-tuned rotor (0.1 s at \(K_0 = 10\) rad/s), so near the centre the rotors do lock; but a rotor first has to swing round to its angle (5), and every rotor near the edge of its locking range, where (6) is slow, is still settling when the field has moved on. The panel's readout shows the share of rotors within \(\sigma\) of the field's centre that turn with the field, counted as those whose rate over the last second is within 0.3 rad/s of \(\Omega\). Table 1 lists its average over the stored runs. For comparison, a field that stood still would lock 48 % of the rotors within \(\sigma\) of its centre at \(K_0 = 4\) rad/s, 92 % at 10 and all of them at 20, by (9) with the stored rates; the moving field reaches about half of that.
| pull at the centre \(K_0\) | \(\kappa = 0\) | \(\kappa = 1\) rad/s | \(\kappa = 3\) rad/s | still field, \(\kappa = 0\), by (9) |
|---|---|---|---|---|
| 0 | 7.8 % | 15.7 % | 0.9 % | 0 % |
| 4 rad/s | 21.0 % | 24.3 % | 16.5 % | 48 % |
| 10 rad/s | 47.1 % | 54.1 % | 51.9 % | 92 % |
| 20 rad/s | 64.2 % | 66.6 % | 65.5 % | 100 % |
Table 1. The share of rotors within \(\sigma\) of the field's centre that turn with the field (rate over the last second within 0.3 rad/s of \(\Omega\)), averaged over the 1200 frames of each stored run; last column, the share a still field would lock, from (9) and the stored own rates.
Two entries need a word. With no field at all, 7.8 % still count: 8.6 % of the rotors have an own rate within 0.3 rad/s of \(\Omega\) and pass the test without being pulled. And neighbours can hinder as well as help. A modest pull, \(\kappa = 1\) rad/s, lets a locked rotor drag its neighbours along, and raises the share at every \(K_0\). A strong pull, \(\kappa = 3\) rad/s, makes neighbours agree with one another first. In the Kuramoto picture [2], neighbouring rotors with similar own rates settle on a common rate, near the average of theirs; our reading of the table, not a computed result, is that such a patch is harder for the field to turn than a single rotor, because the field pulls on only part of it while the rest holds it back. Without the field the share then falls to 0.9 %, because almost no patch happens to turn at \(\Omega\).
2.6How the runs were computed and checked
Equation (3) is 648 first-order equations. They were solved on Kaggle with the explicit Runge–Kutta method DOP853 of SciPy (order 8, with an embedded error estimate that chooses each step), with relative and absolute tolerances of \(10^{-9}\), over 80 s; the solver's own interpolation gives the angles at 15 frames per second, 1200 frames per run. The neighbour sums are taken on the whole lattice at once, as four shifted copies of the array of angles, with open edges. The default run took 1040 steps, about 0.08 s each on average; a run with no field and no neighbours, where every rotor simply turns at \(\omega_i\), took 6. All twelve runs and the checks took 62 s on Kaggle's four processors.
Three checks are stored with the runs. First, the single rotor of section 2.3, \(K = 4\) rad/s, for the seven own rates of Figure 2. For the four that slip, the solver records each moment at which \(\psi\) passes a whole turn, and the mean time between these moments is compared with (7): they agree to \(7.7\times10^{-9}\) of the period at worst (for \(\omega = -5\) rad/s, 219 slips in 200 s, 0.906 899 69 s against 0.906 899 68 s). For the three that lock, the mean rate between 100 s and 200 s differs from \(\Omega\) by \(3.7\times10^{-9}\) rad/s at most. Second, the still field of section 2.4. Third, the default run solved again with tolerances of \(10^{-11}\): over all 648 rotors and 1200 frames the angles differ from the stored ones by 0.038 rad at most, a little over 2°. The largest differences belong to rotors that are slipping at that moment, when a tiny change in the moment of the slip moves the angle fast. On the screen this is below the size of a rotor's arm tip.
The angles are stored as whole numbers from 0 to 255, the nearest of 256 equal steps of a turn, so each is off by at most \(\pi/256\), 0.7°. Between two stored frames the page turns each rotor the short way round. This is right as long as no rotor turns more than half a turn between frames: the fastest possible rate is \(|\omega| + K_0 + 4\kappa \le 5 + 20 + 12 = 37\) rad/s, or 2.5 rad per frame at 15 frames per second, less than \(\pi\).
2.7From the equation to the screen
Each rotor is one point of the lattice, drawn as three arms of 10 pixels; the arm with the dot points at \(\theta_i\). Here the lattice is shrunk until all 72 × 9 rotors fit the picture (on a screen narrower than about 960 pixels the spacing stops at 13 pixels and only the middle columns are shown); in the band of the home page each rotor has 28 pixels and you see the middle columns that fit. The faint ring has the radius \(\sigma\), four spacings, and its centre is \(\mathbf s(t)\); the bar through it points along the field, \(\varphi = \Omega t\). Angles grow clockwise on the screen, because the screen's vertical axis points down. A rotor is drawn bright when, between the two stored frames around the moment shown, it turns by the field's turn within 0.6 rad/s of \(\Omega\). This is a rate over one frame, not the one-second rate of the readout, so a slipping rotor flickers bright twice in every slip, when its rate passes through \(\Omega\) on the way up and on the way down; a locked rotor stays bright. The run lasts 80 s; the page plays its first 79 s and then fades the last second into the first, so the loop has no jump in the field's path, while the slipping rotors, which do not return to their start, change angle under the fade.
2.8What the model leaves out
The rotors have no inertia: (2) holds only if \(I/\zeta\) is short compared with \(1/K_0\), 0.05 s at the strongest pull; a heavy rotor in thin oil would overshoot its locking angle and could even be thrown out of lock, a problem governed by the full equation (1), the equation of a damped pendulum driven by a constant torque. The neighbours' pull is the simplest one, \(\sin(\theta_j - \theta_i)\); real neighbouring magnets pull on each other through the dipole field, which depends on the direction of the line between them as well as on the angle between the magnets. And the own rates are fixed numbers: real rotors would be shaken by small random torques, which make a locked rotor slip now and then even inside its locking range, the subject of the noisy Kuramoto model [2].
2.1 Show from (4) that a locked rotor with \(\Delta = K/2\) runs ahead of the field by 30°. For a rotor with \(\omega = 4\) rad/s in the default field (\(K_0 = 10\) rad/s, \(\sigma = 4\)), at which distance from the centre is it ahead by 30°, and at which distance does it stop being locked?
2.2 Near the edge of locking, write \(\Delta = K(1 + \epsilon)\) with small \(\epsilon > 0\). Show from (7) that \(T_\text{slip} \approx 2\pi/(K\sqrt{2\epsilon})\), and explain with Figure 1 why the rotor spends almost the whole slip near \(\psi = \pi/2\).
2.3 Two rotors without a field, \(\dot\theta_1 = \omega_1 + \kappa\sin(\theta_2 - \theta_1)\) and \(\dot\theta_2 = \omega_2 + \kappa\sin(\theta_1 - \theta_2)\). Subtract the equations and show that the difference obeys Adler's equation with \(\Delta = \omega_1 - \omega_2\) and pull \(2\kappa\). When do they lock, and at which common rate?
2.4 Keep the inertia: \(I\ddot\psi + \zeta\dot\psi = \zeta\Delta - mB\sin\psi\). Linearise about the stable angle (5) and find when the approach to it oscillates instead of creeping. Express the condition through \(I/\zeta\) and \(\tau_\text{lock}\).
2.5 On the page, set \(\kappa = 0\) and step \(K_0\) through 4, 10 and 20. At \(K_0 = 4\), the rotors inside the ring that stay faint are, by section 2.4, those turning against the field: check with Figure 3 that no pull below 4.5 rad/s can catch them, and explain with section 2.5 why some rotors turning with the field are still faint just after the ring has arrived.
2.9Further reading
- R. Adler, “A study of locking phenomena in oscillators”, Proceedings of the IRE 34, 351–357 (1946), reprinted in Proceedings of the IEEE 61, 1380–1385 (1973): the derivation of equation (4), the pull-in of a locked oscillator, and the pendulum in a viscous fluid inside a rotating container.
- J. A. Acebrón, L. L. Bonilla, C. J. Pérez Vicente, F. Ritort and R. Spigler, “The Kuramoto model: a simple paradigm for synchronization phenomena”, Reviews of Modern Physics 77, 137–185 (2005): section II (the model and its locking), section III (noise) and section VI (numerical methods).
- T. M. Antonsen Jr., R. T. Faghih, M. Girvan, E. Ott and J. Platig, “External periodic driving of large systems of globally coupled phase oscillators”, arXiv:0711.4135: the Kuramoto model with a field turning at \(\Omega\), the same terms as (3) with every oscillator coupled to every other.