Lecture note · Fig. 12 · fluid dynamics · control
A full pint over the bumps
Numa Koudsie · for readers from the last year of school to the second year of university; ★ marks the heavier mathematics, and every starred result is restated in plain words after it
01A full pint on a moving cart
Carry a full pint across a crowded pub and your hand learns a piece of fluid mechanics before your head does.
Every step jolts the glass a little. The stout lags behind the glass, piles up against one side, runs back to the other, and keeps rocking a few times a second after the jolt has passed. If your steps happen to fall in time with that rocking, each one adds to it, and after four or five steps the stout climbs the wall; the same thing happens with a mug of coffee when you walk at the wrong pace. Experienced bar staff walk smoothly for this reason. A pint of stout has one more thing going for it, its head of foam: a layer a couple of centimetres thick, like whipped cream, that lies on the stout, rubs on the glass and holds its shape when the glass is tilted gently. Because it stands highest, it is also the first thing to go over the rim.
The animation above this note shows a pint of stout in a tulip-shaped glass (the shape Guinness uses) standing on a cart with one wheel, which rolls along a road with bumps. Nothing in it is computed on your device. Each ride was computed ahead of time on a graphics card rented through Kaggle, a service that runs programs on such cards: about a million small parcels of stout in the glass, the head of foam lying on them, and the cart, all pushing on each other. The page stores 30 pictures for each second of a ride and plays them back at their real speed.
What the controls do. The list of rides, under the animation, chooses what is played: each road once with the cart's speed simply held, and then with the controllers that try to keep the stout still; two rides at the end show the glass standing still and given one push, with and without the head. Pause and Play stop and restart the clock; Ride again starts the chosen ride from the beginning; the time bar shows how far the ride has gone and can be dragged to any moment. The strip below the list draws the road's height and the cart's place on it. The panel of readings gives, for the picture on the screen, the cart's speed, the stout and the foam still in the glass and spilled so far, the number of drops of stout and lumps of broken-off foam outside the glass (flying, or come to rest on the cart), the current in the drive motor and the force of the active suspension; every one of them is read from the stored ride, none is computed by your browser. The table under the readings lists, for every ride, how far the surface leaned at most (two measures, the tilt and the lean, both defined in section 11.1: roughly, how much higher the stout stood at the front wall than at the back), the foam and stout spilled and the largest motor current; clicking a row plays that ride.
The words in that table, the controllers, are the subject of the last part of the chapter. A controller is a rule, run by a small computer on the cart a thousand times a second, that reads the cart's sensors and decides what the motor (and, in one case, an actuator in the suspension) should do. The ride list names four: speed held only (the motor just keeps the speed constant), road preview (it also looks at the road ahead), slosh LQR (it watches the stout and pushes against its rocking; LQR stands for linear quadratic regulator, a standard recipe for such a rule) and joint control (the same, plus an active suspension). We shall build each of them from the physics of the earlier sections, and a fifth, the skyhook, a suspension rule that calms the body's bounce as if the body hung from a hook in the sky.
The chapter is built in the order in which the physics is needed. Section 2 collects the measured numbers of the glass, the stout and the foam. Sections 3 and 4 write Newton's law for the stout and find the rhythm of its rocking; sections 5 and 6 follow the rocking's energy into friction at the glass and in the foam. Section 7 adds the cart and the roads. Sections 8 and 9 describe how the computer solves the equations and how it checks that nothing is lost. Sections 10 and 11 explain what the page draws and what the stored rides show, section 12 builds the controllers and reads their rides, and section 13 lists what the model leaves out.
02The pint, measured
Before we write any equation we need the numbers: the shape of the glass, how heavy and how sticky the stout is, and what the head is made of.
The glass. The glass is an imperial pint tulip, the glass in which Guinness is served. Its shape comes from the section drawing of the Irish imperial pint glass published by dimensions.com, which gives the glass as 149 mm tall and 76 mm wide [1]; the model traces the drawing's inner wall and scales it, separately in height and in width, to the size retailers list for the Guinness imperial pint, 160 mm tall and 85 mm wide. The solid base takes the bottom 12.5 mm, so the inside begins there. The shape is therefore a drawing's, not a measurement of a real glass. From the drawing we read the inner radius \(R(z)\) at every height \(z\) above the inner floor, in steps of 0.5 mm (Figure 1). The inside has a small flat floor, of radius 16.3 mm, which curves up quickly into the body: 28.4 mm from the axis already 5 mm above the floor. The body widens slowly to its widest point, radius 39.3 mm at \(z = 116\) mm, and the rim is at \(z = 147.5\) mm. We fill the glass with stout to the depth \(h = 125\) mm. There the radius is
\[ R = 39.1\ \mathrm{mm}, \]and in the top 20 mm below that level it changes by only 0.29 mm: near its surface the stout stands in what is very nearly an upright cylinder. The letter \(R\) without a subscript always means this radius in what follows. The stout fills 426.6 mL. On top lies the head of foam, 19 mm thick, so its top stands at 144 mm, only 3.5 mm below the rim, and the stout's own surface is 22.5 mm below it.
The stout. Benilov, Cummins and Lee give the density and the viscosity of Guinness at 6 °C, the temperature at which it is served: \(\rho = 1007\ \mathrm{kg/m^3}\) and \(\mu = 2.06\ \mathrm{mPa\,s}\) [2, p. 1]. Watamura and co-workers measured 1006 kg/m³ and 2.03 to 2.23 mPa s on samples near 5 °C from which the gas had been removed [3, p. 2 and Supplement], the same within their spread. The viscosity \(\mu\) is the liquid's resistance to shear: the force per unit area needed to slide one layer over another, divided by the shear rate, the difference of their velocities per unit distance between them. How quickly a difference of velocity spreads through the liquid by friction is measured instead by the kinematic viscosity,
\[ \nu = \frac{\mu}{\rho} = 2.05\times10^{-6}\ \mathrm{m^2/s}, \]about twice the value for water at room temperature. A freshly poured pint is cloudy with small bubbles, but they rise into the head within about two minutes (Benilov and co-workers measured a settling time of about 120 s [2, p. 2]), so we treat the settled stout as a plain liquid.
The head. The head is a foam made of the stout's own bubbles. Guinness specifies a head 18 to 20 mm thick, and three pours measured by KegWorks two minutes after pouring gave 17.5, 20.6 and 22.2 mm [4]; we take \(h_f = 19\) mm. Three more numbers describe the foam.
The first is the size of its bubbles. Watamura and co-workers found the stout's bubbles to have a mean diameter \(\bar d = 61\ \mu\mathrm m\), with sizes spread as a log-normal distribution (one in which \(\ln d\) is normally distributed) of width \(s = 0.24\) [3, Supplement, Appendix A]. What matters for a foam is the ratio of the bubbles' total volume to their total surface: the surface, through its tension, holds the energy that resists deformation, and the volume sets how much space that surface has to fill; it is expressed by the Sauter radius \(R_{32} = \tfrac12\langle d^3\rangle/\langle d^2\rangle\). For a log-normal distribution \(\langle d^n\rangle = e^{n m_d + n^2s^2/2}\), with \(m_d\) the mean of \(\ln d\), so \(\bar d = e^{m_d + s^2/2}\) and \(\langle d^3\rangle/\langle d^2\rangle = e^{m_d + 5s^2/2} = \bar d\,e^{2s^2}\). Hence
\[ R_{32} = \tfrac12\,\bar d\,e^{2s^2} = \tfrac12\times61\ \mu\mathrm m\times1.122 = 34.2\ \mu\mathrm m , \]and the model uses \(R_{32} = 34\ \mu\mathrm m\).
The second number is the liquid fraction \(\phi_\ell\), the share of the foam's volume that is liquid; the rest, the gas fraction \(\Phi = 1 - \phi_\ell\), is bubbles. We found no measurement of it for a Guinness head, and it matters, because the foam's strength depends on it steeply (section 6). We estimate it instead. A column of foam drains: liquid runs down through the channels where three bubbles meet until the pull of gravity is balanced by capillary suction, the lower pressure in liquid under strongly curved surfaces. The project's own calculation of that balance (in the research notes kept with the code, notes/fig12/research/data-for-solver.md; not a measurement and not a published value) gives, for bubbles of 34 µm in a column 19 mm tall, a liquid fraction of 0.36 at the bottom and 0.235 at the top, and 25 to 110 minutes to reach it, so a head a few minutes old is at least this wet. Near its bottom the head is then barely a solid (section 6.1 shows why). We take \(\phi_\ell = 0.27\), near the middle of that column, and show in section 6 how much the result depends on this choice. The foam's density follows, since the gas weighs almost nothing: \(\rho_f = \phi_\ell\,\rho = 272\ \mathrm{kg/m^3}\).
The third is the stout's surface. Its surface tension is \(\gamma = 44.2\ \mathrm{mN/m}\). Because proteins sit on it, the surface also resists being stretched: stretching it by a small fraction of its area raises its tension by a modulus times that fraction. This modulus, the dilatational elasticity, is \(E_\infty = 18.7\ \mathrm{mN/m}\) when the stretching is fast (the subscript \(\infty\) stands for that limit of high frequency). Völp and Willenbacher measured both on degassed Guinness at 20 °C [5, Table 2]. We use them unchanged at 6 °C; no values for the cold stout were found, and this is an assumption of the model.
Table 1 collects these inputs.
| Quantity | Value | Source |
|---|---|---|
| inner radius at the fill, \(R\); fill depth, \(h\) | 39.1 mm; 125 mm | section drawing [1], scaled to the retail size |
| density of the stout, \(\rho\) | 1007 kg/m³ | measured [2] |
| viscosity, \(\mu\); kinematic, \(\nu\) | 2.06 mPa s; 2.05 × 10⁻⁶ m²/s | measured at 6 °C [2] |
| head thickness, \(h_f\) | 19 mm | specification and measured pours [4] |
| bubble Sauter radius, \(R_{32}\) | 34 µm | from the measured sizes [3], above |
| liquid fraction, \(\phi_\ell\); foam density, \(\rho_f\) | 0.27; 272 kg/m³ | estimated from drainage (no measurement) |
| surface tension, \(\gamma\); elasticity, \(E_\infty\) | 44.2 mN/m; 18.7 mN/m | measured at 20 °C [5] |
Per unit area of the stout's surface the head has the mass \(m_s = \rho_fh_f = 272 \times 0.019 = 5.17\ \mathrm{kg/m^2}\) and presses with its weight, \(m_sg = 50.7\ \mathrm{Pa}\), with \(g = 9.81\ \mathrm{m/s^2}\). A layer of stout of depth \(d_s\) presses with \(\rho gd_s\), so the head weighs as much as a layer of stout \(m_s/\rho = 5.1\ \mathrm{mm}\) deep. We shall meet this length again and give it a name, \(\lambda_h = m_s/\rho = 5.13\) mm. A flat disc of foam of radius \(R\) and thickness \(h_f\) holds \(\pi R^2h_f = 91.26\ \mathrm{mL}\). On the computer's grid the head is laid on the open area of each column, which follows the glass as it widens slightly above the fill, and holds 91.314 mL, 0.06 % more; that is the head served in every ride, 24.8 g. With the stout's 426.6 mL × 1.007 g/mL = 429.6 g, the cart carries 454.4 g of stout and foam.
03A liquid in a shaken glass
Sit in a bus that brakes and you are thrown forward, though nothing pushed you. Seen from inside the glass, the stout feels the same push every time the cart changes speed.
3.1Newton's law in the glass's frame
It is easiest to describe the stout as a passenger on the cart sees it, because then the glass stands still and the stout moves inside it. The model lets the cart's body, and with it the glass, move only along the road and up and down, never tipping forward or sideways, as if it ran in a guide; a real one-wheeled cart would need a second support or its own balance control, which this figure leaves out. Let the glass's position along the road and its height being \(\mathbf X_g(t)\), and its acceleration \(\mathbf a_g = \ddot{\mathbf X}_g\). We write \(\mathbf a_g = (a, 0, a_z)\): \(a\) is the acceleration forward along the road, \(a_z\) upward, and the cart does not move sideways. A small parcel of stout of mass \(\delta m\) sits at \(\mathbf X_g + \mathbf x\), where \(\mathbf x\) is its position measured from the glass. Newton's second law, which holds for the road (an inertial frame), says \(\delta m\,(\ddot{\mathbf X}_g + \ddot{\mathbf x}) = \mathbf F\), the sum of the real forces on the parcel. Moving \(\delta m\,\mathbf a_g\) to the right,
\[ \delta m\,\ddot{\mathbf x} = \mathbf F - \delta m\,\mathbf a_g . \tag{1} \]In the glass's frame the parcel obeys Newton's law as if a further force \(-\delta m\,\mathbf a_g\) acted on it. This pseudo-force is not exerted by anything; it is the bookkeeping of having chosen an accelerating frame, and it is what throws you forward in the braking bus. It is proportional to the mass, exactly like gravity \(\delta m\,\mathbf g\), with \(\mathbf g = (0, 0, -g)\). The two therefore act together as one effective gravity
\[ \mathbf g_\text{eff} = \mathbf g - \mathbf a_g = (-a,\ 0,\ -(g + a_z)) . \]When the cart speeds up, \(a \gt 0\), the effective gravity tilts backward; when it brakes, forward. When the glass is lifted with an upward acceleration, \(a_z \gt 0\), the stout feels heavier, and when it drops faster than it would fall freely, \(a_z \lt -g\), the stout feels a pull upward.
3.2The equations of a liquid
We now apply (1) to every parcel of the stout at once. Let \(\mathbf u(\mathbf x, t)\) be the velocity of the stout, relative to the glass, at the point \(\mathbf x\) and time \(t\), and \(p(\mathbf x, t)\) its pressure. Three things act on a parcel of volume \(\delta V\) and mass \(\rho\,\delta V\).
Pressure. Take the parcel as a small cube with sides \(\delta x, \delta y, \delta z\). The pressure pushes on its left face with \(p(x)\,\delta y\,\delta z\) and on its right face, the other way, with \(p(x + \delta x)\,\delta y\,\delta z\). The net push along \(x\) is \(-(\partial p/\partial x)\,\delta V\), and in three dimensions the net push is \(-\nabla p\,\delta V\), where \(\nabla p = (\partial p/\partial x, \partial p/\partial y, \partial p/\partial z)\) is the gradient of \(p\), the vector pointing up the steepest rise of pressure. A parcel is pushed from high pressure towards low.
Friction. Picture layers of stout sliding over each other with the velocity \(u_x(y)\). The layer above a plane \(y\) drags the one below with the stress \(\mu\,\partial u_x/\partial y\) per unit area. A slab between \(y\) and \(y + \delta y\) feels this stress on both faces, in opposite directions, and the net force per unit volume is the difference, \(\mu\,\partial^2u_x/\partial y^2\): friction pulls a parcel towards the average velocity of its neighbours, and it acts only where the velocity profile is curved. In three dimensions the friction force per unit volume of a liquid like water is \(\mu\nabla^2\mathbf u + \tfrac13\mu\nabla(\nabla\cdot\mathbf u)\); for a liquid that cannot be compressed the second term vanishes by (3) below, leaving \(\mu\nabla^2\mathbf u\), where \(\nabla^2 = \partial^2/\partial x^2 + \partial^2/\partial y^2 + \partial^2/\partial z^2\) is the Laplacian [6, section 41-2].
Effective gravity. Gravity and the pseudo-force together pull on the parcel with \(\rho\,\mathbf g_\text{eff}\,\delta V\).
The acceleration of the parcel is not \(\partial\mathbf u/\partial t\), the rate of change at a fixed point, because the parcel moves on to where the velocity is different. Following the parcel, its velocity changes at the rate
\[ \frac{\mathrm D\mathbf u}{\mathrm Dt} = \frac{\partial\mathbf u}{\partial t} + (\mathbf u\cdot\nabla)\,\mathbf u , \]the material derivative; the second term, \((\mathbf u\cdot\nabla)\mathbf u = u_x\,\partial\mathbf u/\partial x + u_y\,\partial\mathbf u/\partial y + u_z\,\partial\mathbf u/\partial z\), is the change the parcel sees by being carried along. Dividing Newton's law by \(\rho\,\delta V\) gives the Navier–Stokes equation in the glass's frame,
\[ \frac{\partial\mathbf u}{\partial t} + (\mathbf u\cdot\nabla)\,\mathbf u = -\frac{\nabla p}{\rho} + \nu\nabla^2\mathbf u + \mathbf g - \mathbf a_g . \tag{2} \]Stout, like water, can hardly be compressed: its density is the same everywhere and at all times. Then as much must flow out of any small volume as flows into it. For the cube, the flow in through the left face is \(u_x(x)\,\delta y\,\delta z\) per second and out through the right face \(u_x(x + \delta x)\,\delta y\,\delta z\); the net outflow, summed over the three pairs of faces, is \((\partial u_x/\partial x + \partial u_y/\partial y + \partial u_z/\partial z)\,\delta V\), and it must vanish:
\[ \nabla\cdot\mathbf u = 0 . \tag{3} \]The quantity \(\nabla\cdot\mathbf u\) is the divergence of \(\mathbf u\), the net outflow per unit volume. Equations (2) and (3) are four equations for the four unknowns \(\mathbf u\) and \(p\). The pressure has no equation of its own: it takes whatever values are needed to keep (3) true, which is how the computer will find it (section 8).
3.3The edges of the stout
At the glass the stout cannot pass through: the velocity across the wall vanishes, \(\mathbf u\cdot\hat{\mathbf n} = 0\), with \(\hat{\mathbf n}\) the unit vector at right angles to the wall. A liquid with viscosity also sticks to the glass, so that the velocity along the wall vanishes too (the no-slip condition); section 5 shows that this matters only in a layer less than a millimetre thick. At the top, the surface stands at the height \(z = h + \eta(x, y, t)\), where \(\eta\) is its rise above the rest level. Two conditions hold there. The surface moves with the stout, so it rises at the rate at which the stout under it rises:
\[ \frac{\partial\eta}{\partial t} + u_x\frac{\partial\eta}{\partial x} + u_y\frac{\partial\eta}{\partial y} = u_z \quad\text{at } z = h + \eta . \tag{4} \]And the pressure there equals whatever presses on the surface from above, \(p_s\): zero for a bare surface (we measure pressure from the air's), and the load of the foam under a head (section 6). Surface tension would add a pressure jump proportional to the surface's curvature; for the swing it is small, since gravity outweighs it by the Bond number \(\rho g/(\gamma k^2) = 101\) and would raise the first frequency by only 0.5 %, so the model leaves it out:
\[ p = p_s \quad\text{at } z = h + \eta . \tag{5} \]3.4Three checks
The glass at rest. With \(\mathbf a_g = 0\) and nothing moving, \(\mathbf u = 0\), equation (2) becomes \(\nabla p = \rho\mathbf g\): the pressure does not change sideways and grows downward as \(p = p_s + \rho g\,(h - z)\). This is hydrostatics; the push of the pressure from below balances each parcel's weight.
A steady push. Let the cart speed up at a constant \(a\) for long enough that the stout comes to rest in the glass. Then (2) gives \(\nabla p = \rho\,\mathbf g_\text{eff}\): the surface, along which \(p\) is constant, settles at right angles to the effective gravity, inclined by the angle \(\vartheta\) with \(\tan\vartheta = a/(g + a_z)\). The front wall drops and the back wall rises by \(R\tan\vartheta\). This is the coffee that climbs the back of the cup when you set off.
A rigid liquid. If the stout were frozen, \(\mathbf u = 0\) at all times, (2) would give \(\nabla p = \rho\,\mathbf g_\text{eff}\), and the glass would have to supply the force \(-\int\nabla p\,\mathrm dV = -m\,\mathbf g_\text{eff} = m\,(\mathbf a_g - \mathbf g)\) to the stout of mass \(m\), exactly what it takes to carry a rigid load. Any difference from a rigid load is therefore the stout's own motion in the glass, which section 7 turns into a force on the cart.
To lift the back wall by 3.5 mm, enough to bring the top of the head (which rides on the stout) to the rim, a steady acceleration needs \(R\,a/g = 3.5\) mm, that is \(a = 9.81\times3.5/39.1 = 0.88\ \mathrm{m/s^2}\). To lift the stout itself 22.5 mm, to the rim, takes \(5.65\ \mathrm{m/s^2}\), more than half of \(g\). A steady push strong enough to spill stout is rare; sudden pushes are more dangerous, as the next section shows, and the foam is more delicate than the stout, as section 6 shows.
In the frame of the glass the stout obeys the Navier–Stokes equation (2) with the effective gravity \(\mathbf g - \mathbf a_g\), the condition (3) that it cannot be compressed, no flow through the glass, and the two surface conditions (4) and (5). The cart enters only through its acceleration \(\mathbf a_g\).
04The rhythm of the surface ★
Tap a full glass on the side and its surface rocks to and fro at a rhythm of its own. That rhythm, and how a push of the glass excites it, is what decides whether a pint spills.
For small motions the stout's rocking can be taken apart into modes: patterns of motion in which every parcel moves back and forth at one and the same frequency, all in step, like the standing waves on a guitar string. Each mode has its own frequency, its natural frequency, at which it rocks when left alone. The slowest mode that a push along the road can excite tips the whole surface, up at the front and down at the back and then the other way. This section finds its natural frequency from the shape of the glass and the equation by which the glass drives it. A reader who skips the derivations will find the results restated in the Key result boxes.
4.1The first mode
Why a potential. Friction acts only in thin layers at the glass and under the surface (section 5), so for the bulk of the stout we drop the viscous term of (2). For small motions we also drop \((\mathbf u\cdot\nabla)\mathbf u\), which is a product of two small velocities and so of second order in the size of the swing. What remains is \(\partial\mathbf u/\partial t = -\nabla(p/\rho) + \mathbf g_\text{eff}\). The effective gravity is the same everywhere in the glass at a given moment, so it is the gradient of \(\mathbf g_\text{eff}\cdot\mathbf x = -a\,x - (g + a_z)\,z\), and the right side is a gradient. A velocity field whose rate of change is a gradient and which starts from rest stays a gradient for all time: its curl, the local rate of spin, starts at zero and never changes (Kelvin's circulation theorem for a liquid without friction [6, section 40-2]). We may therefore write \(\mathbf u = \nabla\phi\), with \(\phi\) the velocity potential. Then (3) becomes Laplace's equation, \(\nabla^2\phi = 0\), and the momentum equation reads \(\nabla\big(\partial\phi/\partial t + p/\rho + (g + a_z)\,z + a\,x\big) = 0\): the bracket is the same everywhere. This is the time-dependent form of Bernoulli's law,
\[ \frac{\partial\phi}{\partial t} + \frac{p}{\rho} + (g + a_z)\,z + a\,x = C(t) , \tag{6} \]in which \(C(t)\) depends on time only and can be absorbed into \(\phi\) (adding a function of time to \(\phi\) does not change the velocity). The steady Bernoulli law of school, \(p + \tfrac12\rho v^2 + \rho gz = \text{const}\), is the same law for steady flow with the velocity's square kept; here the flow is unsteady and small, so the term \(\partial\phi/\partial t\) matters and the square, being of second order, is dropped.
The glass as a cylinder. The flow of a surface wave fades with depth over a distance of its wavelength divided by \(2\pi\), here about two centimetres, so the swing lives near the top of the stout, where the tulip is nearly a cylinder. We therefore take an upright cylinder of radius \(R\) filled to the depth \(h\), and hold the glass still for the moment, \(\mathbf a_g = 0\). In cylindrical coordinates \((r, \theta, z)\), with \(\theta = 0\) pointing forward along the road, we look for a potential of the form \(\phi = f(r)\cos\theta\,\mathcal Z(z)\,\cos\omega t\): one wave around the glass, rocking at the angular frequency \(\omega\). In these coordinates \(\nabla^2\phi = \partial^2\phi/\partial r^2 + (1/r)\,\partial\phi/\partial r + (1/r^2)\,\partial^2\phi/\partial\theta^2 + \partial^2\phi/\partial z^2\), and \(\partial^2/\partial\theta^2\) turns \(\cos\theta\) into \(-\cos\theta\). Laplace's equation, divided by \(\phi\), therefore reads
\[ \frac{1}{f}\Big(f'' + \frac{f'}{r}\Big) - \frac{1}{r^2} + \frac{\mathcal Z''}{\mathcal Z} = 0 . \]The last term depends only on \(z\) and the rest only on \(r\), so each must be a constant; we call it \(k^2\), so that \(\mathcal Z'' = k^2\mathcal Z\). The floor allows no flow through it, \(\partial\phi/\partial z = 0\) at \(z = 0\), which picks \(\mathcal Z = \cosh kz\). The radial part becomes \(r^2f'' + rf' + (k^2r^2 - 1)f = 0\), Bessel's equation of order one. Its two solutions are the Bessel functions \(J_1(kr)\) and \(Y_1(kr)\); \(Y_1\) grows without bound on the axis, where the stout's velocity is finite, so \(f = J_1(kr)\) and
\[ \phi = \cos\omega t\;\cos\theta\;J_1(kr)\,\cosh kz . \tag{7} \]The wall allows no flow through it either, \(\partial\phi/\partial r = 0\) at \(r = R\):
\[ J_1'(kR) = 0 \quad\Rightarrow\quad kR = \xi = 1.8412 , \tag{8} \]the first zero of the derivative \(J_1'\). The constant \(k = \xi/R = 47.1\ \mathrm{m^{-1}}\) is the mode's wavenumber, and \(1/k = 21.2\) mm is the depth over which its flow fades (as \(\cosh kz\) does below the surface). At the surface we use (4) and (5) for small motions and apply them at the rest height \(z = h\) instead of \(h + \eta\), which changes them only at second order in \(\eta\): the surface rises with the stout, \(\partial\eta/\partial t = \partial\phi/\partial z\), and (6) with \(p = 0\) at \(z = h + \eta\) gives \(\partial\phi/\partial t + g(h + \eta) = C\), and choosing \(C = gh\) leaves \(\partial\phi/\partial t + g\eta = 0\). Differentiating the second in time and inserting the first eliminates \(\eta\):
\[ \frac{\partial^2\phi}{\partial t^2} + g\,\frac{\partial\phi}{\partial z} = 0 \quad\text{at } z = h . \tag{9} \]Putting (7) into (9) gives \(-\omega^2\cosh kh + gk\sinh kh = 0\), that is,
\[ \omega_{11}^2 = gk\tanh kh = \frac{g\,\xi}{R}\,\tanh\frac{\xi h}{R} . \tag{10} \]An upright cylinder of radius \(R\) filled to depth \(h\) rocks its surface, in its slowest mode, at the angular frequency \(\omega_{11}\) of (10), \(\xi = 1.8412\). For a glass deeper than its radius, \(\tanh(\xi h/R) \approx 1\) and the frequency depends on the width alone: a wide glass rocks slowly, a narrow one fast.
With \(R = 0.0391\) m and \(h = 0.125\) m, \(\xi h/R = 5.886\) and \(\tanh(5.886) = 0.99998\): the depth plays no part. Then \(\omega_{11}^2 = 9.81 \times 1.8412/0.0391 = 461.9\ \mathrm{s^{-2}}\), \(\omega_{11} = 21.49\ \mathrm{rad/s}\) and \(f_{11} = \omega_{11}/2\pi = 3.421\ \mathrm{Hz}\), one swing every 0.292 s. Units: \(g/R\) is \(\mathrm{m\,s^{-2}/m = s^{-2}}\), as \(\omega^2\) must be. The next two modes with one wave around the glass have \(kR = 5.331\) and \(8.536\) and rock at 5.82 and 7.37 Hz.
The surface of this mode is \(\eta \propto J_1(kr)\cos\theta\). It rises at the front wall (\(\theta = 0\)), falls by as much at the back wall (\(\theta = \pi\)), and stays at its rest height along the diameter across the road, \(\theta = \pm\pi/2\), the mode's nodal line. We call the mode's height at the front wall \(q(t)\), so that at the wall \(\eta = q\cos\theta\). The lean of the surface, the height at the front wall minus the height at the back, is then \(2q\).
4.2How the glass drives the swing
Now let the glass accelerate. With \(p = 0\) at the surface, (6) at \(z = h\) reads
\[ \frac{\partial\phi}{\partial t} + (g + a_z)\,\eta + a\,r\cos\theta = 0 \quad\text{at } z = h , \]since \(x = r\cos\theta\). The push enters through the function \(r\cos\theta\), and we need to know how much of it the first mode feels. The functions \(J_1(k_nr)\), one for each zero \(k_nR\) of \(J_1'\), are the solutions of Bessel's equation that satisfy the wall condition; like the sines of a vibrating string they are orthogonal: \(\int_0^RJ_1(k_nr)\,J_1(k_mr)\,r\,\mathrm dr = 0\) for \(n \ne m\), with the weight \(r\) that comes from the area element \(r\,\mathrm dr\,\mathrm d\theta\) [7, §10.6 and §10.22]. Any function of \(r\) can be written as a sum of them, and the share of the first in the function \(r\) is
\[ c_1 = \frac{\int_0^R r\cdot J_1(kr)\,r\,\mathrm dr}{\int_0^R J_1(kr)^2\,r\,\mathrm dr} = \frac{R^3J_1(\xi)/\xi^2}{\tfrac12R^2\left(1 - 1/\xi^2\right)J_1(\xi)^2} = \frac{2R}{(\xi^2 - 1)\,J_1(\xi)} . \]The numerator uses \(\int_0^R r^2J_1(kr)\,\mathrm dr = R^3J_2(\xi)/\xi\), which follows from \(\mathrm d[x^2J_2(x)]/\mathrm dx = x^2J_1(x)\) [7, §10.6], and \(J_2(\xi) = J_1(\xi)/\xi\), which follows from the recurrence \(J_2(x) = J_1(x)/x - J_1'(x)\) and \(J_1'(\xi) = 0\); the denominator is the standard integral of \(J_1^2\) for a function whose slope vanishes at \(r = R\) [7, §10.6 and §10.22]. At the wall the first mode carries the height \(c_1J_1(\xi) = 2R/(\xi^2 - 1) = 0.837\,R\) of the straight line \(r\). We write the first mode's part of the surface as \(\eta = q(t)\,J_1(kr)\cos\theta/J_1(\xi)\), so that \(q\) is its height at the front wall, and its part of the potential as \(\Upsilon(t)\,J_1(kr)\cos\theta\,\cosh kz/\cosh kh\). The two surface conditions, projected on this mode, become
\[ \frac{\dot q}{J_1(\xi)} = k\tanh kh\;\Upsilon, \qquad \dot\Upsilon + (g + a_z)\,\frac{q}{J_1(\xi)} + a\,c_1 = 0 . \]Differentiating the first in time and inserting the second, with \(\omega_{11}^2 = gk\tanh kh\), gives \(\ddot q = -k\tanh kh\,\big[(g + a_z)\,q + a\,c_1J_1(\xi)\big]\), the equation of the driven swing:
The height \(q\) of the surface at the front wall swings like a mass on a spring. A forward acceleration of the glass, \(a \gt 0\), pushes the front of the surface down and the back up. A vertical acceleration does something different: it changes the spring's stiffness, as if gravity were \(g + a_z\). The number \(\beta\), the drive coefficient, says how strongly the glass's push reaches the swing.
A check: the steady push. For a constant \(a\) and \(a_z = 0\), (11) gives the resting value \(q = -\beta a/\omega_{11}^2 = -0.837\,Ra/g\). Section 3.4 found the exact answer \(Ra/g\), the tilted plane. The one-mode answer is 16 % smaller because a tilted plane, the straight line \(r\) in the radial direction, is not a pure first mode: the higher modes of Example 4.1 carry the remaining 16 %. For a steady push the one-mode model is not enough; for sudden pushes, which excite mainly the slowest mode, it is a good description.
A sudden change of speed. Let the glass's speed change by \(\Delta v\) in a time much shorter than a swing (\(\Delta v \lt 0\) when the cart is slowed). Integrating (11) over that short time, the swing's height has no time to change, but its rate jumps: \(\Delta\dot q = -\beta\int a\,\mathrm dt = -\beta\,\Delta v\). A cart that is suddenly slowed therefore sets the front of the surface rising at the rate \(\beta|\Delta v|\): the stout surges forward, as your coffee does when you stop short. Without friction the swing then moves as \(q = -(\beta\Delta v/\omega_{11})\sin\omega_{11}t\), with the amplitude
\[ q_\text{max} = \frac{\beta\,|\Delta v|}{\omega_{11}} . \tag{12} \]For \(\Delta v = -0.1\ \mathrm{m/s}\), \(q_\text{max} = 1.541\times0.1/21.49 = 7.2\) mm.
Many small kicks. Any push \(a(t)\) can be cut into short kicks \(a(t')\,\mathrm dt'\), each of which starts its own swing \(-(\beta/\omega_{11})\,a(t')\,\mathrm dt'\,\sin\omega_{11}(t - t')\). For the linear equation (11) with \(a_z = 0\) the swings simply add, and after the push has ended the swing left behind has the amplitude
\[ q_\text{max} = \frac{\beta}{\omega_{11}}\,\Big|\int a(t')\,e^{j\omega_{11}t'}\,\mathrm dt'\Big| , \tag{13} \]where \(j\) is the imaginary unit, \(j^2 = -1\) (we write \(j\) and not \(i\), which will be an electric current). The integral picks out the part of the push that keeps time with the swing: pushes that come in step with the swing add up, pushes out of step cancel. The free swing on the page is started this way, by a push of the form \(a = 1.0\ \mathrm{m/s^2}\times\sin(\pi t'/T_p)\) lasting \(T_p = 0.146\) s, half a period of the bare stout's first mode, which by (13) leaves an undamped swing of 5.2 mm at the wall (Problem 7). The same push is given to the stout with its head, so that the two swings can be compared directly; it is then a little shorter than half that swing's period, which changes its effect only slightly.
A change of the glass's speed \(\Delta v\), quicker than a swing, sets the surface swinging with the height \(q_\text{max} = \beta|\Delta v|/\omega_{11}\) at the wall, (12): braking makes the front rise first. A longer push \(a(t)\) leaves the swing (13), made only of the part of the push that keeps time with the swing. These two results are used throughout sections 11 and 12.
05Where the swing's energy goes
A tapped glass of water rocks for many seconds; a tapped pint of stout under its head stops almost at once. The difference lies in thin layers where the liquid is forced to move differently from its neighbours.
5.1The damping ratio
Friction turns the swing's energy into heat, and the swing dies away. For a swing whose friction is proportional to its speed, (11) gains a term:
\[ \ddot q + 2\zeta\omega\,\dot q + \omega^2q = 0 , \tag{14} \]with \(\omega\) the natural angular frequency. Its solution, for \(\zeta \lt 1\), is \(q = q_0\,e^{-\zeta\omega t}\cos(\omega_dt + \psi)\) with \(\omega_d = \omega\sqrt{1 - \zeta^2}\): an oscillation whose amplitude falls at the rate \(\sigma = \zeta\omega\). The dimensionless number \(\zeta\) is the damping ratio, the decay rate measured in units of the frequency. From one swing to the next the amplitude falls by the factor \(e^{-2\pi\zeta}\); for the stout's own damping ratio of section 5.4, \(\zeta = 0.0055\), that is about 3 % per swing. The energy of the swing, proportional to the square of its amplitude, falls as \(e^{-2\sigma t}\), so if friction removes the mean power \(\Pi\) from a swing of energy \(E_s\),
\[ \sigma = \frac{\Pi}{2E_s} , \qquad \zeta = \frac{\Pi}{2E_s\omega} . \]We use this to turn every friction into a damping ratio.
5.2The Stokes layer on the glass ★
Picture the stout sliding to and fro along the glass a few times a second. A short distance from the glass it slides freely with the swing's velocity, \(U\cos\omega t\). At the glass it must be at rest, because a viscous liquid sticks to a solid. In between lies a thin layer in which the velocity along the wall, \(u_\parallel(d, t)\), changes from zero at the wall, \(d = 0\), to \(U\cos\omega t\) outside, where \(d\) is the distance from the glass. The pressure gradient that drives the outer flow, \(-\partial p/\partial x_\parallel = \rho\,\partial(U\cos\omega t)/\partial t\), is the same across a thin layer, so the difference \(u' = u_\parallel - U\cos\omega t\) obeys (2), with \(x_\parallel\) the distance along the wall, as the diffusion equation \(\partial u'/\partial t = \nu\,\partial^2u'/\partial d^2\), with \(u' = -U\cos\omega t\) at the wall and \(u' \to 0\) far from it. We try \(u' = \mathrm{Re}\,[\hat u\,e^{j\omega t - (1 + j)d/\delta_s}]\), where \(\mathrm{Re}\) takes the real part of a complex number and \(j\) is the imaginary unit, \(j^2 = -1\). Substituting gives \(j\omega = \nu(1 + j)^2/\delta_s^2 = 2j\nu/\delta_s^2\), so \(\delta_s = \sqrt{2\nu/\omega}\), and the wall condition fixes \(\hat u = -U\). The velocity in the layer is
\[ u_\parallel(d, t) = U\left[\cos\omega t - e^{-d/\delta_s}\cos\!\Big(\omega t - \frac{d}{\delta_s}\Big)\right], \qquad \delta_s = \sqrt{\frac{2\nu}{\omega}} . \tag{15} \]This is the Stokes layer, and \(\delta_s\) is its thickness: by \(d = 2\delta_s\) the velocity is within \(e^{-2} \approx 14\) % of the outer value, and by \(3\delta_s\) within 5 % (Figure 2). The layer stays thin because every half swing the sliding reverses before friction can reach further into the liquid. The model uses one fixed frequency for it, \(\omega = 2\pi\times3.42\ \mathrm{Hz}\), the first mode of a bare stout, which gives \(\delta_s = 0.44\) mm.
The glass feels the stress \(\tau_w = \mu\,\partial u_\parallel/\partial d\) at \(d = 0\). Differentiating (15) and using \(\mu/\delta_s = \rho\nu/\delta_s = \rho\sqrt{\nu\omega/2}\),
\[ \tau_w = \rho\sqrt{\frac{\nu\omega}{2}}\;U\big(\cos\omega t - \sin\omega t\big) . \tag{16} \]The stress has two parts. The first is in step with the sliding velocity \(U\cos\omega t\) and always opposes it: it removes on average \(\langle\rho\sqrt{\nu\omega/2}\,U^2\cos^2\omega t\rangle = \tfrac12\rho\sqrt{\nu\omega/2}\,U^2\) per unit area of wall and per second. The second part is in step with the acceleration; over a full swing it does no work, and its only effect is to make the stout seem slightly heavier, which lowers the frequency by a fraction of the same size as the damping ratio we are about to find [8, eq. (18)]. As a check, the heat produced inside the layer must equal the work done by the wall stress. The velocity gradient is \(\partial u_\parallel/\partial d = \sqrt2\,(U/\delta_s)\,e^{-d/\delta_s}\cos(\omega t - d/\delta_s + \pi/4)\); the time average of its square is \((U^2/\delta_s^2)\,e^{-2d/\delta_s}\), and integrating \(\mu\) times that over \(d\) from 0 to \(\infty\) gives \(\mu U^2/(2\delta_s) = \tfrac12\rho\sqrt{\nu\omega/2}\,U^2\), the same.
The computer's grid, with cells of 1.5 mm, cannot hold a layer of 0.44 mm. The code lets the stout slide along the glass on the grid and puts the friction back by hand: on the area of glass in each cell cut by the glass it applies the stress \(\rho\sqrt{\nu\omega/2}\,u\) to every component \(u\) of the velocity there (the one across the wall is already near zero, so in effect it brakes the sliding). This is exactly the first, in-phase part of (16); for a swing at the frequency \(\omega\) it removes the same energy as the true layer.
\(\omega = 2\pi\times3.42 = 21.49\ \mathrm{rad/s}\), \(\delta_s = \sqrt{2 \times 2.05\times10^{-6}/21.49} = 0.436\ \mathrm{mm}\), and \(\sqrt{\nu\omega/2} = 4.69\ \mathrm{mm/s}\). Stout sliding at 10 mm/s along the glass feels \(1007\times4.69\times10^{-3}\times10\times10^{-3} = 0.047\ \mathrm{Pa}\), a gentle drag that matters only because it acts on every swing.
5.3How fast the glass damps the swing ★
Take the mode (7) with an amplitude \(B\) in front of \(\phi\). Its energy \(E_s\) is its largest kinetic energy, \(\tfrac12\rho\int|\nabla\phi|^2\,\mathrm dV\). Because \(\nabla^2\phi = 0\), \(|\nabla\phi|^2 = \nabla\cdot(\phi\nabla\phi)\), and by the divergence theorem the volume integral equals the surface integral \(\tfrac12\rho\oint\phi\,\partial\phi/\partial n\,\mathrm dS\) over the stout's boundary. On the wall and the floor \(\partial\phi/\partial n = 0\), so only the free surface contributes:
\[ E_s = \tfrac12\rho\,B^2\,k\cosh kh\,\sinh kh\;\pi\!\int_0^R J_1(kr)^2\,r\,\mathrm dr = \frac{\pi\rho B^2}{4}\,k\cosh kh\,\sinh kh\;R^2\Big(1 - \frac1{\xi^2}\Big)J_1(\xi)^2 . \]At the wall the stout slides with \(u_\theta = (1/R)\,\partial\phi/\partial\theta\) and \(u_z = \partial\phi/\partial z\), so the integral of the squared sliding velocity over the wetted wall, at the moment of largest velocity, is
\[ \int_{\text{wall}}\!\big(u_\theta^2 + u_z^2\big)\,\mathrm dS = \pi R\,B^2J_1(\xi)^2\int_0^h\Big(\frac{\cosh^2kz}{R^2} + k^2\sinh^2kz\Big)\mathrm dz . \]The mean power lost is \(\Pi = \tfrac12\rho\sqrt{\nu\omega/2}\) times this integral. For a deep glass, \(kh = 5.89\), both \(\cosh^2kz\) and \(\sinh^2kz\) are close to \(e^{2kz}/4\) wherever they matter, so the \(z\)-integral is \(e^{2kh}(1/R^2 + k^2)/(8k)\) and \(\cosh kh\sinh kh = e^{2kh}/4\). Dividing, \(\sigma = \Pi/2E_s\), everything but the geometry cancels:
\[ \sigma_\text{wall} = \sqrt{\frac{\nu\omega}{2}}\;\frac{\xi^2 + 1}{2R\,(\xi^2 - 1)}, \qquad \zeta_\text{wall} = \frac{\sigma_\text{wall}}{\omega} = \frac{\delta_s}{4R}\,\frac{\xi^2 + 1}{\xi^2 - 1} . \tag{17} \]For the pint, \(\sigma_\text{wall} = 0.110\ \mathrm{s^{-1}}\) and \(\zeta_\text{wall} = 0.0051\). This is the classical result for smooth, laminar flow. Bongarzone and Gallaire give the damping of a mode with \(m\) waves around the glass as the sum of a side-wall, a floor and a bulk part; their side-wall part is \(\sqrt{\nu\omega/2}\,(1 + m^2/\xi^2)\,\xi^2/(2R(\xi^2 - m^2))\) for a deep glass, which for \(m = 1\) is our factor \((\xi^2 + 1)/(2R(\xi^2 - 1))\), \(0.918/R\) [8, eq. (17)].
Engineers write the same result as a logarithmic decrement, the natural logarithm of the ratio of two successive swing heights, \(2\pi\zeta\). With \(\omega^2 = g\xi/R\) for a deep glass, \(\delta_s = \sqrt{2\nu/\omega}\) and (17) give \(\zeta_\text{wall} = \frac{\sqrt2\,(\xi^2 + 1)}{4\,\xi^{1/4}(\xi^2 - 1)}\,\nu^{1/2}R^{-3/4}g^{-1/4} = 0.5575\,\nu^{1/2}R^{-3/4}g^{-1/4}\), and the decrement is \(K_\Lambda\nu^{1/2}R^{-3/4}g^{-1/4}\) with \(K_\Lambda = 3.50\). Stephens, Leonard and Perry quote this laminar theory, due to Miles, as \(K_\Lambda = 3.52\) [9, eqs. (2)–(3)], the same within rounding. Their own experiments, in tanks from 7.6 cm to 3.05 m across, gave \(K_\Lambda = 5.23\), 49 % more [9, eq. (13)], and the handbook of Silveira and Abramson repeats both values [10, eq. (4.10b)]. Real walls, and the line where the surface meets the glass, add friction that the laminar theory leaves out; with \(K_\Lambda = 5.23\) the pint's wall damping would be \(\zeta = 0.0077\). The model uses the laminar value.
5.4The skin under the surface, and the bulk
The model holds the head of foam to vertical motion only (section 6), a choice of the model rather than an observation; under such a head the stout's surface cannot slide sideways, and the head acts on the stout like a lid. Just under it the stout then forms a second Stokes layer, in which the horizontal velocity changes from the lid's, zero, to the swing's. The calculation of 5.3, now with the horizontal velocity on the plane \(z = h\), where \(\int|\nabla_h\phi|^2\,\mathrm dA = k^2\int\phi^2\,\mathrm dA\) (the horizontal Laplacian of \(J_1(kr)\cos\theta\) is \(-k^2\) times the function, and its slope vanishes at the wall), gives \(\Pi/2E_s = \sqrt{\nu\omega/2}\,(k/2)\coth kh\):
\[ \sigma_\text{skin} = \sqrt{\frac{\nu\omega}{2}}\;\frac{k}{2}\coth kh = 0.110\ \mathrm{s^{-1}}, \qquad \zeta_\text{skin} = 0.0051 . \tag{18} \]The code applies the same drag \(\rho\sqrt{\nu\omega/2}\,u\) to the horizontal velocity \(u\) of the top layer of stout cells, over one cell's area each, whenever the head is present. A surface without a head has no such skin in the model. A real stout's surface, covered by a protein film that resists stretching (its \(E_\infty\), section 2), would also resist sliding and could add up to this much damping; the model leaves that out for the stout without its head. Viscosity also acts inside the stout, away from any boundary; for a swing this adds the rate \(2\nu k^2 = 0.0091\ \mathrm{s^{-1}}\) [8, eq. (17)], a damping ratio of 0.0004, which the code obtains by applying viscosity on the grid.
A stout with a clean surface loses its swing to the Stokes layer on the glass and to the bulk, \(\zeta = 0.0051 + 0.0004 = 0.0055\): its amplitude falls by the factor \(e\) in \(1/(\zeta\omega_{11}) = 8.5\) s and halves in about 20.1 swings. A surface held as a lid adds the skin, \(\zeta = 0.0107\) (the parts, rounded, are 0.0051, 0.0051 and 0.0004). The wall's and the skin's rates are nearly equal, \(\sigma_\text{skin}/\sigma_\text{wall} = 1.002\), by a coincidence of the numbers: \((\xi^2 + 1)/(2(\xi^2 - 1))\) and \(\xi/2\) are both about 0.92. These frictions are weak; the head of foam, next, is not.
06The head of foam
A head of foam is a solid that can flow. Press it gently and it springs back, like shaving foam on your palm; push harder and it gives way.
6.1Why a foam is stiff
Pour marbles into a box and they stop settling when about 63.5 % of the space is filled; beyond that they can no longer move past each other, and the packing is said to be jammed. The bubbles of the head fill \(\Phi = 73\) % of it, more than randomly packed spheres can (about 64 %; even the densest ordered packing of spheres fills 74 %), so they are squeezed into rounded polyhedra pressed against each other. To shear the foam we must deform these bubbles further, which stretches their films and costs surface energy. The natural scale of the resulting stress is the pressure inside a bubble, \(2\gamma/R_{32} = 2600\ \mathrm{Pa}\) for a sphere of radius \(R_{32}\). Völp and Willenbacher showed that for foams whose bubble surfaces are stiffened by proteins the right scale also contains the surface's elasticity, the generalized Laplace pressure \(p_L = (\gamma + 2E_\infty)/R_{32}\), and that two laws describe their measurements [5, conclusions]:
\[ p_L = \frac{\gamma + 2E_\infty}{R_{32}}, \qquad G_0 = p_L\,\Phi\,(\Phi - \Phi_c), \qquad \tau_y = 0.25\,p_L\,(\Phi - \Phi_c)^2 , \tag{19} \]with \(\Phi_c = 0.635\) the gas fraction at jamming. \(G_0\) is the shear modulus, the foam's stiffness against small shears (the stress divided by the angle of shear), and \(\tau_y\) the yield stress, the shear stress beyond which the bubbles slide past each other and the foam flows.
\(p_L = (44.2 + 2\times18.7)\times10^{-3}/(34\times10^{-6}) = 2400\ \mathrm{Pa}\). With \(\Phi - \Phi_c = 0.095\): \(G_0 = 2400\times0.73\times0.095 = 166\ \mathrm{Pa}\) and \(\tau_y = 0.25\times2400\times0.095^2 = 5.4\ \mathrm{Pa}\). To picture the yield stress, lay the head on a slope of angle \(\alpha\): its weight pulls it down the slope with the shear stress \(m_sg\sin\alpha\) on its base, and it slides when that exceeds \(\tau_y\). With \(m_sg = 50.7\) Pa the head holds on slopes up to \(\sin\alpha = 0.11\), about 6°. That is why it keeps its shape when the glass is tilted gently and gives way under a jolt.
Because \(\Phi\) lies only 0.095 above jamming, \(\tau_y\) depends steeply on the liquid fraction we estimated in section 2: at \(\phi_\ell = 0.24\) it would be 9.4 Pa, at 0.27 it is 5.4 Pa, and at 0.30 it would be 2.5 Pa. Every number in this section that depends on \(\tau_y\) carries this uncertainty. It also means that near its wetter bottom, where section 2 estimated a liquid fraction of 0.36, the head is close to jamming and barely a solid.
6.2How it flows
Once the head flows, its stress grows with the shear rate \(\dot\gamma\), the rate at which neighbouring layers slide past each other (the dot distinguishes it from the surface tension \(\gamma\)): \(\tau = \tau_y + \tau_v(\dot\gamma)\). The viscous part \(\tau_v\) comes from the stout squeezed through the thin films between bubbles and through the thicker channels where three bubbles meet. Tcholakova and co-workers derived both contributions from the flow in those films and channels and fitted them to experiments [11, eq. (54)]:
\[ \frac{\tau_v}{\gamma/R_{32}} = \underbrace{0.7\,\frac{\mathrm{Ca}_f^{\,0.47}\,\Phi^{5/6}}{(1 - \Phi)^{0.5}}}_{\text{films}} + \underbrace{8\,\frac{\mathrm{Ca}_f^{\,0.7}\,\Phi^{5/6}}{(1 - \Phi)^{0.15}}}_{\text{channels}}, \qquad \mathrm{Ca}_f = \frac{\mu\dot\gamma R_{32}}{\gamma} . \tag{20} \]The capillary number \(\mathrm{Ca}_f\) compares the viscous stress \(\mu\dot\gamma\) with the bubbles' pressure scale \(\gamma/R_{32}\). At \(\dot\gamma = 10\ \mathrm{s^{-1}}\), \(\mathrm{Ca}_f = 1.6\times10^{-5}\); the films give 7.5 Pa and the channels 4.2 Pa, so \(\tau_v = 11.7\ \mathrm{Pa}\) and \(\tau = 17.1\ \mathrm{Pa}\). Their fits cover gas fractions of 0.80 and above; our head, at 0.73, lies outside that range, and we do not know how large the error is. We use the law as it stands and name it as a limit of the model.
6.3The head on the glass
As the surface rocks, the head's edge slides up and down the glass, on the thin film of stout that wets it, at the vertical velocity \(w\) of the surface at the wall. Cantat worked out the friction of bubbles sliding on a wet wall; for bubbles whose surfaces do not stretch along the wall (stiff surfaces, as protein-covered ones are), with her fitted prefactor, the stress on the wall at the sliding speed \(v_s\) is [12, eq. (49) and Fig. 14]
\[ \tau_\text{edge} = Z\,\frac{\gamma}{R_{32}}\Big[6.82\,\mathrm{Ca}_w^{2/3} + 0.94\,\frac{l}{r_m}\,\mathrm{Ca}_w^{1/3}\Big], \qquad \mathrm{Ca}_w = \frac{\mu v_s}{\gamma}, \tag{21} \]where \(\mathrm{Ca}_w\) is now the capillary number of the sliding, \(l\) the length over which a bubble touches the wall and \(r_m\) the radius of the stout's meniscus around it. Cantat fitted \(Z\) and \(l/r_m\) to measurements at several liquid fractions; at the wettest, 0.25, they are \(Z = 0.18\) and \(l/r_m = 0.004\), and the model uses these values unchanged at 0.27. A wet foam's bubbles touch the wall only in a tiny patch beside a large meniscus, which is why \(l/r_m\) is so small; the second term is therefore at most 1.5 % of the first at the slowest speeds of a swing, and we drop it below. The code caps \(\tau_\text{edge}\) at what the foam itself can carry in a layer one bubble across, \(\tau_y + \tau_v\) at the shear rate \(v_s/2R_{32}\), though at the speeds of a swing the cap is never reached: (21) gives 2.1, 9.7, 28 and 45 Pa at 1, 10, 50 and 100 mm/s, the cap 20 to 223 Pa. Because the stress grows only as \(v_s^{2/3}\), the drag per unit speed, \(\tau_\text{edge}/v_s\), grows without bound as the head slows: like dry friction, it stops a small motion in a finite time instead of letting it fade for ever. (A body slowed by a force proportional to \(v^{2/3}\) obeys \(\dot v \propto -v^{2/3}\), so \(v^{1/3}\) falls at a constant rate and reaches zero.)
The head does not slide at full speed through its whole thickness. Sauret and co-workers found that in a foam over a rocking liquid the bubbles' speed falls off upward roughly exponentially, over a length comparable to the wave's \(1/k\) [13, pp. 8 and 10]. The code takes the sliding speed as \(v_se^{-kz'}\) at the height \(z'\) above the stout, with \(1/k = 21.2\) mm. The power lost per unit area of glass, \(\tau_\text{edge}v_s\), then goes as \(v_s^{5/3}\), and integrating it over the head's thickness gives the height over which the edge rubs as if at full speed,
\[ h_\text{eff} = \int_0^{h_f} e^{-5kz'/3}\,\mathrm dz' = \frac{3}{5k}\Big(1 - e^{-5kh_f/3}\Big) = 9.9\ \mathrm{mm} . \tag{22} \]Per unit area of the stout's surface next to the glass, the edge friction acts as a drag \(\kappa\,w\) on the surface's vertical motion, with
\[ \kappa = \frac{\tau_\text{edge}(|w|)\,h_\text{eff}}{|w|}\times\frac{\text{length of glass along that strip of surface}}{\text{area of the strip}} , \]where the code keeps \(|w|\) above 1 mm/s in the denominator so that \(\kappa\) stays finite when the head stops.
How strongly the edge damps the swing. With section 5's energy balance we can turn this friction into a damping ratio. For a swing of height \(q\) at the wall the surface's vertical speed at the glass is \(w = \omega q\sin\omega t\cos\theta\). Dropping the small second term of (21), the edge stress is \(C_e|w|^{2/3}\) with \(C_e = Z(\gamma/R_{32})\,6.82\,(\mu/\gamma)^{2/3} = 206.7\ \mathrm{Pa\,(s/m)^{2/3}}\), and the mean power lost around the glass is \(\Pi = C_eh_\text{eff}R\,(\omega q)^{5/3}\,\langle|\sin|^{5/3}\rangle\oint|\cos\theta|^{5/3}\,\mathrm d\theta\), where the average over a swing is 0.536 and the integral around the glass 3.365. The swing's energy is its largest potential energy, \(E_s = \tfrac12\rho g\int\eta^2\,\mathrm dA = \tfrac14\pi\rho gR^2(1 - 1/\xi^2)\,q^2\). Hence
\[ \zeta_\text{edge} = \frac{\Pi}{2E_s\omega} \propto q^{-1/3} , \]a damping ratio that grows as the swing shrinks, as dry friction does. At the head's frequency (section 6.5) it is 0.62 for a swing of 1 mm at the wall and 0.36 for 5 mm: 65 to 111 times the stout's own friction of section 5.4. The edge of the head alone is enough to stop a swing within about one period. The head's resistance to shear (6.6) adds to this.
6.4The head's weight, and when it breaks off
The head presses on the stout with its weight in the glass's frame, \(m_s\,g'\), where \(g' = g + a_z\) is the apparent gravity, the downward pull per unit mass that the stout feels in the glass (the size of the vertical part of \(\mathbf g_\text{eff}\)): 50.7 Pa at rest. The code puts this pressure on the stout's free surface, (5). When the glass drops faster than it would fall freely, \(g' \lt 0\), the foam would be pulled off the stout rather than pressed on it; the code then sets its weight to zero, since a foam resting on a liquid can press but not pull.
Where the stout's surface rises at the glass, the head rises with it, and its top can pass the rim. Picture the foam above the rim on that side as a small square block of height \(z_+\) and the same width, with the glass gone from beside it. Two loads try to shear it off along its base, the horizontal plane through the rim. The liquid in the foam carries a pressure that grows with depth, as in any liquid, so the block's own weight pushes outward on its free outer face, as water pushes on a dam, with a force per unit length of rim of \(\int_0^{z_+}\rho_fg'\,z\,\mathrm dz = \tfrac12\rho_fg'z_+^2\); spread over the base, of width \(z_+\), that is the shear stress \(\tfrac12\rho_fg'z_+\). And when the glass accelerates away from that rim, toward the opposite side, with the acceleration \(a_\text{out}\), the pseudo-force pulls the block outward over the rim with \(\rho_fa_\text{out}z_+\) per unit area of base. The block breaks away when the two together exceed the yield stress:
\[ \rho_f\Big(\tfrac12|g'|\,z_+ + a_\text{out}\,z_+\Big) \ge \tau_y . \tag{23} \](The code uses \(|g'|\) here, so that a moment of upward pull also counts.) A broken part leaves as a lump in free flight, falling under the effective gravity, until it lands on the cart's body or falls away. This is a simple balance, and a cautious one. A more careful one lets a wedge of foam slide on a plane through the rim's edge inclined at the angle \(\vartheta\): the wedge's weight per unit length, \(\tfrac12\rho_fgz_+^2\cot\vartheta\), pulls along the plane with \(\tfrac12\rho_fgz_+^2\cos\vartheta\), and the plane, of length \(z_+/\sin\vartheta\), resists with \(\tau_yz_+/\sin\vartheta\). They balance at \(z_+ = 4\tau_y/(\rho_fg\sin2\vartheta)\), lowest at \(\vartheta = 45^\circ\): \(z_+ = 4\tau_y/(\rho_fg) = 8.1\) mm at rest, twice the height of (23). The rule (23) therefore lets the head break early rather than late.
At rest, (23) gives \(z_+^* = 2\tau_y/(\rho_fg) = 2\times5.4/(272\times9.81) = 4.1\ \mathrm{mm}\). The head's top starts 3.5 mm below the rim, so the stout must rise \(3.5 + 4.1 = 7.6\ \mathrm{mm}\) at the wall before any foam breaks off. A steady push needs only 1.9 m/s², ordinary braking, to raise the wall that far (Example 3.1). An outward acceleration of 5 m/s² lowers \(z_+^*\) to 2.0 mm. The stout itself spills only when it rises 22.5 mm at the wall, about 3 times higher: on a pint with a head, foam leaves first.
6.5The head's mass ★
Lift a tray with a full glass on it quickly and you feel the glass press harder for a moment: whatever you accelerate upward pushes back with its weight plus its mass times the acceleration. The head lies on the stout like the glass on the tray. As the surface rocks, each patch of foam is carried up and down with the stout under it, so the stout must push it with more than its weight while the surface speeds upward, and with less while it slows. The pressure under the head is therefore
\[ p_s = m_s\Big(g' + \frac{\mathrm dw}{\mathrm dt}\Big) , \tag{24} \]with \(w = \partial\eta/\partial t\) the vertical velocity of the surface there. The first part is the weight of 6.4; on a level surface it is the same everywhere and pushes no wave either way. The second part is new, and it slows the swing. Take a small wave \(\eta = \eta_0\cos(kx - \omega t)\) on stout of depth \(h\), with the potential of section 4 below it, \(\phi = \phi_0\cosh kz\,\sin(kx - \omega t)\), and the glass at rest. The kinematic condition gives \(\partial\eta/\partial t = \partial\phi/\partial z\), that is \(\omega\eta_0 = k\phi_0\sinh kh\). Bernoulli's law (6) at the surface, with the pressure (24) and \(\partial w/\partial t = \partial^2\eta/\partial t^2\), reads \(\rho\,\partial\phi/\partial t + \rho g\eta + m_s\,\partial^2\eta/\partial t^2 = 0\) (the constant part \(m_sg\) is absorbed into \(\phi\)), which gives \(-\rho\omega\phi_0\cosh kh + (\rho g - m_s\omega^2)\,\eta_0 = 0\). Eliminating \(\phi_0\) with the first condition,
\[ \omega^2 = \frac{gk\tanh kh}{1 + \lambda_hk\tanh kh}, \qquad \lambda_h = \frac{m_s}{\rho} . \tag{25} \]The denominator has a plain meaning. A surface wave of wavenumber \(k\) moves the stout down to a depth of about \(1/k\), a mass of about \(\rho/k\) per unit area; the head adds its own \(m_s\), a fraction \(m_sk/\rho = \lambda_hk\) of that, while the restoring force, gravity on the raised stout, stays the same. More mass on the same spring swings more slowly.
The same reasoning changes the drive. In the glass's frame the push along the road acts on the stout as the term \(a\,x\) of (6); the head, which in the model moves only up and down, is carried along the road by the glass and passes no push along the road to the stout. With the head, the surface condition becomes \(\rho\,\partial\phi/\partial t + \rho(g + a_z)\,\eta + m_s\,\partial^2\eta/\partial t^2 + \rho\,a\,x = 0\), and the projection of 4.2 gives
\[ (1 + \lambda_hk\tanh kh)\,\ddot q + \omega_{11}^2\Big(1 + \frac{a_z}{g}\Big)\,q = -\beta\,a . \tag{26} \]Dividing by the bracket, the swing obeys (11) with the head's frequency \(\omega_h = \omega_{11}/\sqrt{1 + \lambda_hk\tanh kh}\) and the smaller drive coefficient \(\beta_h = \beta/(1 + \lambda_hk\tanh kh)\): the push still acts on the stout alone, but now it has to move the head as well.
For the first mode of the pint, \(k = 47.1\ \mathrm{m^{-1}}\) and \(\lambda_h = 5.13\) mm, so \(1 + \lambda_hk\tanh kh = 1.242\). The head lowers the swing's frequency by the factor \(1/\sqrt{1.242} = 0.897\), from 3.421 to 3.070 Hz, and its drive coefficient from \(\beta = 1.541\) to \(\beta_h = 1.241\).
Sauret and co-workers saw a shift of this sign in a rocking cell covered with foam, 3.1 Hz against 3.3 Hz predicted without the foam [13, p. 7]. Section 8 describes how the code carries the head's mass in its pressure step. One consequence for section 5: the code's thin layers use the frequency 3.42 Hz throughout, and at the head's lower frequency the true coefficient \(\sqrt{\nu\omega/2}\) is smaller, so with the head those layers brake the swing about 6 % too strongly, a small error beside the foam's own friction.
6.6The head as a sheet ★
In the model the head rides on the stout: every patch of it moves up and down with the stout's surface below it, at the vertical velocity \(w(x, y)\), and never sideways. In a swing neighbouring columns move at different speeds, so the head between them is sheared on vertical planes at the rate \(\dot\gamma = |\nabla_hw|\), the size of the horizontal gradient of \(w\). On each vertical plane the foam carries the shear stress \(\tau\), pointing along the steepest change of \(w\), that is along \(\nabla_hw/|\nabla_hw|\), where \(\nabla_h\) takes derivatives along \(x\) and \(y\) only; summed over the thickness this is a force per unit length \(h_f\tau\,\nabla_hw/|\nabla_hw|\). A patch of surface feels the difference of these forces on its sides, so the net force per unit area is their divergence, \(\nabla_h\cdot(h_f\,\tau\,\nabla_hw/|\nabla_hw|)\), just as the net friction in section 3.2 was the difference of the stresses on a slab's two faces. We write \(\tau/\dot\gamma = \mu_f\), the foam's effective viscosity: large for slow shear, because of the yield stress, and small for fast shear. Below \(\dot\gamma = 0.05\ \mathrm{s^{-1}}\) the code holds \(\mu_f\) at its value there, 123 Pa s, so that a head sheared very slowly is practically locked. In the computer the head's forces act on the two faces carrying vertical velocity below and above the top cell of stout in each vertical stack of cells (section 8), so that the force is felt by the stout wherever the surface happens to lie within a cell. For their new vertical velocity \(w'\) the code solves, in one step that uses the new velocity on the right (an implicit step, stable however stiff the head is),
\[ \rho\,2\Delta x\,\frac{w' - w}{\Delta t} = \nabla_h\cdot\big(h_f\,\mu_f\,\nabla_hw'\big) - \kappa\,w' . \tag{27} \]Here \(\Delta x = 1.5\) mm is the size of a grid cell, \(\Delta t\) the time step, and \(\rho\,2\Delta x = 3.0\ \mathrm{kg/m^2}\) the mass per area of the two cells. The foam's own mass is not in (27); it enters through the pressure (24) on the surface. Equation (27) is a set of linear equations, one per column, which the code solves by the conjugate-gradient method, an iteration that improves a trial solution step by step and needs only products of the matrix with vectors.
A rough balance shows what the yield stress alone can do. The head resists a swing of wavenumber \(k\) with a force per area of order \(h_f\tau_y\) over the horizontal distance \(1/k\), \(h_f\tau_yk\); gravity pushes a swing of height \(q\) back with \(\rho gq\). The two are equal at
\[ q = \frac{h_f\tau_yk}{\rho g} = \frac{0.019\times5.4\times47.1}{1007\times9.81} = 0.5\ \mathrm{mm} . \]A swing much smaller than this at the wall cannot shear the head, and stops; larger ones shear it and lose energy on every swing. This is an estimate of the order of magnitude, not a measurement. In plain words: a head of foam can hold the stout tilted by about half a millimetre at the wall, a lean of about 1.0 mm, and stops every swing smaller than that.
07The cart and the roads
The glass does not move by itself. It stands on a small cart with one wheel, a spring and a motor, and the stout pushes back on the cart as the cart pushes it.
7.1The cart
The cart is a body on a spring over one wheel, like one corner of a car, with a small electric motor driving the wheel. Table 2 lists its numbers. The body, of mass \(M_b\), includes the glass; the stout and its head, of mass \(m_\ell = 454.4\) g at the start, are added to it, so the mass carried on the spring is \(M_s = M_b + m_\ell = 1.954\) kg. The spring and its damper connect the body to the wheel's axle; the tyre is a second, much stiffer spring between the axle and the road, which pushes up on the wheel with the force \(N\) (the tyre's load) and cannot pull, so \(N \ge 0\): a wheel that bounces off the road has \(N = 0\).
| Part | Symbol | Value |
|---|---|---|
| body with the glass | \(M_b\) | 1.5 kg |
| wheel: mass, radius, moment of inertia | \(m_w,\ R_w,\ I_w\) | 0.3 kg, 40 mm, 2.4 × 10⁻⁴ kg m² |
| suspension spring and damper | \(k_s,\ c_s\) | 600 N/m, 8 N s/m |
| tyre: stiffness and damping | \(k_t,\ c_t\) | 20 kN/m, 5 N s/m |
| drag along the road | \(c_x\) | 2 N s/m |
| motor: gear ratio, torque per ampere, rotor's moment of inertia | \(N_g,\ K_m,\ J_m\) | 10, 0.02 N m/A, 2 × 10⁻⁶ kg m² |
| push at the road per ampere, \(N_gK_m/R_w\) | \(b\) | 5 N/A |
| drive: largest current, supply voltage, winding resistance, current lag | \(I_\text{max},\ V_\text{max},\ R_a,\ \tau_i\) | 3 A, 12 V, 2 Ω, 2 ms |
| tyre's grip on the road | \(\mu_g\) | 0.8 |
| active suspension force: largest, lag | \(F_\text{max},\ \tau_u\) | 40 N, 5 ms |
Along the road the cart obeys Newton's second law. Let \(v\) be its speed and \(i\) the motor's current. The motor pushes it forward with \(b\,i\); the drag resists with \(c_xv\); and the road and the stout push with a force we collect in \(F_d\). The wheel and the motor's rotor turn as the cart moves, and their kinetic energy, \(\tfrac12(I_w + N_g^2J_m)(v/R_w)^2\), counts as if a mass \((I_w + N_g^2J_m)/R_w^2\) moved with the cart (the rotor turns \(N_g\) times faster than the wheel). Hence
\[ M_x\dot v = b\,i - c_xv + F_d , \qquad M_x = M_b + m_\ell + m_w + \frac{I_w + N_g^2J_m}{R_w^2} = 2.529\ \mathrm{kg} . \tag{28} \]The current is not free either. The drive limits it to \(\pm I_\text{max}\). A turning motor is also a generator, and it produces the voltage \(\mathcal E = b\,v\) against its supply (\(b\) is also 5 V per m/s), so the supply \(V_\text{max}\) can drive at most \((V_\text{max} - \mathcal E)/R_a\) forward through the winding's resistance. And an electronic loop makes the current follow its command \(i_\text{cmd}\) only with the lag \(\tau_i\):
\[ \tau_i\,\frac{\mathrm di}{\mathrm dt} = i_\text{reach} - i , \tag{29} \]where \(i_\text{reach}\) is the command clipped first to \(\pm I_\text{max}\) and then to the range from \((-V_\text{max} - \mathcal E)/R_a\) to \((V_\text{max} - \mathcal E)/R_a\). Last, the motor pushes on the road through the tyre's grip, at most \(\mu_gN\) either way; a wheel in the air pushes nothing.
The turning parts add \(0.150 + 0.125 = 0.275\) kg, and \(M_x = 1.5 + 0.4544 + 0.3 + 0.275 = 2.529\) kg. The drive's 3 A push with \(bI_\text{max} = 15\) N, which accelerates the cart at \(15/2.529 = 5.93\ \mathrm{m/s^2}\). At 1.5 m/s the motor's voltage is \(\mathcal E = 7.5\) V, and the supply can drive only \((12 - 7.5)/2 = 2.25\) A forward: 11.25 N. Holding 1.5 m/s against the drag takes \(c_xv/b = 0.6\) A. At rest the tyre carries \(N_0 = (M_s + m_w)\,g = 22.1\) N, and its grip allows 17.7 N; the grip, not the drive, limits the motor whenever the load falls below \(15/0.8 = 18.75\) N.
The body bounces on its spring at \(\sqrt{k_s/M_s}/2\pi = 2.79\) Hz (a little lower, 2.75 Hz, when the tyre's own springiness is counted). The bounce moves the glass up and down, so by (11) it reaches the stout's swing only through \(a_z\), by changing the swing's stiffness, not by pushing it.
7.2The roads
Each bump is a smooth hump of height \(h_b\) and length \(L_b\), centred at \(x_b\): \(z_r = \tfrac12h_b\,[1 + \cos(2\pi(x - x_b)/L_b)]\) for \(|x - x_b| \lt L_b/2\), and zero elsewhere. Its steepest slope is \(\pi h_b/L_b\). Any point of the wheel's rim can touch the road, so its axle rides at the height of the highest point of a circle of radius \(R_w\) rolled along the road. This rounds the axle's path wherever the road curves more tightly than the wheel: the kerb's crest has a radius of curvature \(L_b^2/(2\pi^2h_b) = 24\) mm, less than \(R_w\), so the axle's path is rounded over the crest, but on all three roads the axle's steepest slope stays the road's (Table 3). We write \(z_a(x)\) for the axle's height when the wheel is at \(x\). Table 3 lists the rides. Each starts with the stout at rest in the glass and the cart moving at its set speed \(v_0\), its axle 1 m before the centre of the first bump.
| Ride | Road | Speed | Stored |
|---|---|---|---|
| Five 20 mm bumps in step with the swing | five bumps, \(h_b = 20\) mm, \(L_b = 0.25\) m, 0.29 m apart; steepest slope 0.251 | 1.0 m/s | 8 s |
| One 25 mm bump | one bump, \(h_b = 25\) mm, \(L_b = 0.30\) m; slope 0.262 | 1.0 m/s | 8 s |
| One sharp 30 mm bump (the kerb) | one bump, \(h_b = 30\) mm, \(L_b = 0.12\) m; slope 0.785 | 1.5 m/s | 4 s |
| Standing still, one push (with and without the head) | none: the glass held at rest and given one push along the road, \(a = 1.0\ \mathrm{m/s^2}\times\sin(\pi t'/T_p)\) for \(T_p = 0.146\) s, with \(t'\) the time since the push began at \(t = 0.3\) s | 0 | 5 s |
The first road was built to be dangerous for the stout without its head, and its name in the ride list refers to that swing. Its bumps are 0.29 m apart, so at 1.0 m/s they come 3.448 times a second, 0.8 % faster than the bare stout's 3.421 Hz: each bump would push the bare stout's swing in step with the last, as a child on a swing is pushed once per swing. The head slows the swing (section 6.5), so for the pint with its head the bumps come too fast; section 11 shows what that does.
7.3Who pushes whom
The stout is computed in the glass's frame (section 3), where the walls stand still. Let \(m\) be the stout's mass, \(\mathbf v_g\) the glass's velocity and \(\mathbf P\) the stout's momentum relative to the glass. Seen from the road, the stout's momentum is \(m\mathbf v_g + \mathbf P\). Newton's second law says its rate of change equals the forces on the stout, the glass's push \(\mathbf F_{gs}\) and gravity: \(m\mathbf a_g + \mathrm d\mathbf P/\mathrm dt = \mathbf F_{gs} + m\mathbf g\). By Newton's third law the stout pushes the glass with
\[ -\mathbf F_{gs} = m\,(\mathbf g - \mathbf a_g) - \frac{\mathrm d\mathbf P}{\mathrm dt} . \tag{30} \]The first term is what a rigid load of mass \(m\) does (section 3.4); the code includes it by counting the stout's mass, and the head's, in the cart's mass \(M_x\). What remains, \(\mathbf F = -\mathrm d\mathbf P/\mathrm dt\), is the push of the moving stout: when the stout surges forward in the glass, the glass is pushed back, and the reverse. The head's own up-and-down motion relative to the glass is not in \(\mathbf P\); its mass is counted only as a rigid part of the load. Because the head moves only vertically, this leaves the push along the road, the one that matters for the swing, exact, and affects only the small vertical push.
The code works out \(\mathbf F_n = -(\mathbf P_n - \mathbf P_{n-1})/\Delta t_n\) after each fluid step \(n\) from the particles' momentum, and adds \(\mathbf F_n\Delta t_n\) to an impulse book. The sum over the steps up to the last, \(n_e\), telescopes, \(\sum_{n=1}^{n_e}\mathbf F_n\Delta t_n = -(\mathbf P_{n_e} - \mathbf P_0) = -\mathbf P_{n_e}\), because the stout starts at rest in the glass. The impulse booked on the cart is therefore exactly minus the stout's final momentum, up to rounding. The cart takes each step's push into its own sub-steps during the next fluid step, so it feels the stout's push one step, 2 ms, late; at the head-loaded swing's period, about 326 ms by the theory of section 6.5, that is a phase of a few degrees, which we have not separated from the other errors of the method.
08How the computer does it
The computer follows a million small parcels of stout and a grid of boxes around them, and hands the motion back and forth between the two in every step.
8.1Particles and a grid
Equation (2) has two kinds of work in it. Carrying the stout along with its own motion, the term \((\mathbf u\cdot\nabla)\mathbf u\), is easiest with parcels that move with the liquid: nothing is smeared, and a drop that leaves the glass simply keeps flying. The pressure and the friction are easiest on a fixed grid of boxes, where every box knows its neighbours. The method used here, particle-in-cell, uses both. The box around the glass is divided into 57 × 57 × 114 = 370,386 cubic cells, each 1.5 mm wide; a vertical stack of cells is a column. The stout is 1,001,952 particles, each carrying 0.429 mg (a sphere 0.93 mm across). They were placed two by two by two in every cell the stout fills, with a small random shift; the stout's volume equals 126,399 cells, so there are 7.93 particles per cell's worth of stout, slightly fewer than eight because cells cut by the glass get fewer.
On the grid the pressure is kept at the centre of each cell, and each component of the velocity on the faces of the cells at right angles to it: \(u_x\) on the faces that look along \(x\), and so on. This staggered arrangement is the usual one, because the difference of the pressures in two neighbouring cells then acts exactly on the face between them, where the velocity it changes is kept.
8.2Why the particles carry a small velocity field ★
In each step the particles hand their velocities to the grid and take new ones back. In the plain method each particle carries one velocity. A face then receives the mass-weighted mean of the velocities of the particles within one cell of it, \(u_j = \sum_pm_p\mathcal W_{jp}u_p/\sum_pm_p\mathcal W_{jp}\), where \(\mathcal W_{jp}\) is the trilinear weight of particle \(p\) at face \(j\), the product of three tent functions, each falling from 1 to 0 over one cell; and the particle takes back the value read from the faces by the same weights, \(u_p = \sum_j\mathcal W_{jp}u_j\). Each hand-over is an average over about a cell, and averaging smooths. Take a velocity varying as \(\cos kx\) along one direction, with \(k\) its wavenumber, carried by many evenly spread particles. The hand-over to the grid averages it with the tent weight, and averaging \(\cos k(x + s)\) over the tent of half-width \(\Delta x\) (whose Fourier transform is \(\big(\sin(k\Delta x/2)/(k\Delta x/2)\big)^2\)) multiplies its amplitude by that factor, \(\approx 1 - (k\Delta x)^2/12\); reading back by linear interpolation does the same again. Each step therefore removes the fraction \((k\Delta x)^2/6\) of such a motion, as a strong viscosity would. For the swing \(k\Delta x = 0.071\), so that is 8.3 × 10⁻⁴ per step; since a swing's energy is half kinetic, its amplitude then decays at that fraction divided by twice the step, 2 ms: 0.21 s⁻¹, a damping ratio of 0.0097, about 1.7 times the stout's own friction. (This one-dimensional estimate is an upper bound; for the swing's potential flow the three-dimensional smoothing partly cancels.)
The affine particle-in-cell method of Jiang and co-workers (APIC) removes this loss for motions that vary linearly across a cell [14, section 6]. Each particle carries, for each component of the velocity, a value and a gradient: a small linear velocity field around itself. For the component \(u_x\), carried on the faces \(j\), the two hand-overs read
\[ m_ju_j = \sum_pm_p\mathcal W_{jp}\big(u_p + \mathbf C_p\cdot(\mathbf x_j - \mathbf x_p)\big), \qquad u_p = \sum_j\mathcal W_{jp}\,u_j, \qquad \mathbf C_p = \sum_j\nabla\mathcal W_{jp}\,u_j , \tag{31} \]and the same for the other components. Here \(\mathbf x_j\) is the face's position, \(\mathbf x_p\) the particle's, \(m_p\) its mass, \(m_j = \sum_pm_p\mathcal W_{jp}\) the mass the face receives, and \(\mathbf C_p\) the particle's gradient of \(u_x\). The gain is easy to see. Let the velocity be any linear field, \(u_x(\mathbf x) = u_0 + \mathbf G\cdot\mathbf x\), and let every particle carry it exactly, \(u_p = u_x(\mathbf x_p)\) and \(\mathbf C_p = \mathbf G\). Then \(u_p + \mathbf C_p\cdot(\mathbf x_j - \mathbf x_p) = u_x(\mathbf x_j)\) for every particle, so \(m_ju_j = u_x(\mathbf x_j)\sum_pm_p\mathcal W_{jp}\) and \(u_j = u_x(\mathbf x_j)\): the grid receives the field exactly. Reading back, linear interpolation reproduces a linear field exactly, \(\sum_j\mathcal W_{jp}u_x(\mathbf x_j) = u_x(\mathbf x_p)\), and its gradient, \(\sum_j\nabla\mathcal W_{jp}u_x(\mathbf x_j) = \mathbf G\). A linear field, which includes a rigid rotation and the slow shear of a long wave, survives both hand-overs unchanged, and Jiang and co-workers show that angular momentum is conserved across them [14, abstract]. The smoothing loss of the plain method now starts only at the curvature of the field, two orders higher in \(k\Delta x\), and is negligible for the swing. In plain words: the particles carry not only a velocity but its slope across a cell, so the hand-overs no longer blur a gently varying flow. The method still has losses of its own elsewhere (at the free surface, at the cut cells by the glass, in the time stepping); section 11.2 measures their total, and we have not traced them to their sources.
8.3One step
One fluid step of the code does the following, in this order:
- the particles hand their velocities to the faces of the grid, (31);
- the surface of the stout is found from the particles (8.5), and the height of the surface in every column;
- viscosity is applied on the grid, by one explicit step of \(\nu\nabla^2\mathbf u\), in which each face's new value is \(1 - 6\nu\Delta t/\Delta x^2\) times its old one plus \(\nu\Delta t/\Delta x^2\) times each of its six neighbours'; the step is stable when that first weight does not go negative, \(\nu\Delta t/\Delta x^2 \le 1/6\), and here \(\nu\Delta t/\Delta x^2 = 0.0018\);
- the thin layers act on the velocity: the glass's drag of section 5, the skin's drag on the top cells, and the head's sheet (27); the energy each removes is added to its book;
- the effective gravity gives every face the kick \(\Delta t\,\mathbf g_\text{eff}\);
- the head's load is set on the free surface, (24);
- the pressure is found that makes the velocity free of divergence, (3), and its push is applied (8.4);
- the velocities are extended three cells into the air and the glass, so that particles near the boundaries read sensible values;
- the particles take their velocities back, (31), and move; a particle that would cross the glass is put back inside it, and one that crosses the rim outside the glass's radius has left the glass, is counted as spilled and flies freely;
- the foam above the rim breaks off where (23) says so.
The order of steps 4 and 5 matters. The frictions must act on the motion the stout really has, not on the kick of gravity that the pressure is about to cancel. In a stout at rest, gravity's kick in step 5 and the hydrostatic pressure of step 7 cancel exactly, face by face. If a drag acted after the kick, it would shrink the kick at the faces next to the glass, the pressure would then take back more than was left there, and a flow would appear that no force had caused; the drag would also book the kick's energy as heat. A pint at rest would stir itself. With the frictions before the kick, nothing of the sort can happen.
8.4The pressure
Applying the push \(-\Delta t\,\nabla p/\rho\) to the face velocities must leave no net flow into any cell. That condition is one linear equation per cell, a discrete form of Poisson's equation \(\nabla^2p = (\rho/\Delta t)\,\nabla\cdot\mathbf u\): each cell's equation links its own pressure to the six of its neighbours, so the system has about 126,399 unknowns, one for each cell holding stout, but only seven of them in each equation. The glass cuts through cells at an angle; the code weights each face by the fraction of its area that is open to the stout, as Batty, Bertails and Bridson proposed [15, section 2.1]. They point out a property that matters for section 9: with these weights a stout at rest has the exact hydrostatic pressure as its solution, and that pressure cancels gravity exactly, so nothing moves. The equations are solved by the conjugate-gradient method met in section 6.6, preconditioned by dividing each equation by its diagonal, until the largest residual is below 10⁻⁵ of the largest right-hand side, with at most 600 iterations.
At the free surface the pressure is fixed: zero, or the head's load. The surface usually lies between the centre of a cell full of stout, with pressure \(p_l\), and the centre of a cell of air, at the fraction \(\alpha\) of the way from the first to the second. The code gives the air cell the ghost pressure that puts the surface value \(p_s\) exactly on the surface when the two are joined by a straight line, \(p_l + \alpha(p_g - p_l) = p_s\):
\[ p_g = p_l\Big(1 - \frac1\alpha\Big) + \frac{p_s}{\alpha}, \qquad \alpha \ge 0.05 , \tag{32} \]the boundary condition Batty and co-workers use as well [15, section 2.1]; it is of second order, meaning its error falls as \(\Delta x^2\) when the grid is refined. The lower bound on \(\alpha\) keeps \(1/\alpha\) from growing without limit when the surface passes very close to a cell centre.
The head's mass in the pressure step ★. Under the head, \(p_s\) is not known in advance: by (24) it depends on how fast the surface speeds up, which is what the pressure step is about to decide. Let \(w^*\) be the vertical velocity of the face the surface crosses before the pressure step, \(w'\) after it, and \(w_h\) the head's vertical velocity at the start of the step. The face is updated by \(w' = w^* - (\Delta t/\rho\Delta x)(p_g - p_l)\) with (32), and (24) written over the step is \(p_s = m_s\big(g' + (w' - w_h)/\Delta t\big)\). Inserting (32) and then \(p_s\) into the first,
\[ w'\Big(\alpha + \frac{m_s}{\rho\Delta x}\Big) = \alpha\,w^* - \frac{\Delta t}{\rho\Delta x}\Big(m_sg' - \frac{m_sw_h}{\Delta t} - p_l\Big) , \]which is exactly the face update with (32) once two things are changed:
\[ \alpha \;\to\; \alpha + \frac{m_s}{\rho\,\Delta x}, \qquad p_s \;\to\; m_s\Big(g' + \frac{w^* - w_h}{\Delta t}\Big) . \tag{33} \]On the 1.5 mm grid \(m_s/(\rho\Delta x) = \lambda_h/\Delta x = 3.4\): the surface is pushed back as if it lay 3.4 cells farther from the stout's cell, which is how the stout feels the head's inertia. A stout at rest still has the hydrostatic pressure, with the head's weight, as its exact solution. After the pressure step each column's head velocity \(w_h\) is set to the new velocity \(w'\) of the face its surface crosses, and kept for the next step. The mass is taken into the pressure step itself, and not added afterwards as \(m_s\) times the last step's acceleration, for a reason a short estimate shows. For a wave of wavenumber \(k\) the stout it moves has the mass \(\rho/k\) per area and the head \(m_s\). If the head's push used the last step's acceleration, the surface's acceleration in step \(n\) would obey \((\rho/k)\,\dot w_n = F - m_s\dot w_{n-1}\), with \(F\) the other forces; each step's error is then \(-\lambda_hk\) times the last one's, and it grows from step to step when \(\lambda_hk \gt 1\). On the grid's shortest waves, \(k = \pi/\Delta x\), \(\lambda_hk = 10.7\). Taken into the pressure step, (33) is stable for every wave. In plain words: the stout feels the head's inertia as if its surface lay 3.4 cells further out, and the code solves for the head and the stout together.
8.5Where the surface is
The particles do not say by themselves where the liquid ends. Following Zhu and Bridson [16, section 5], the code computes at every cell centre \(\mathbf x\) the function
\[ \chi(\mathbf x) = |\mathbf x - \bar{\mathbf x}| - r_0, \qquad \bar{\mathbf x} = \frac{\sum_i b_i\mathbf x_i}{\sum_i b_i}, \qquad b_i = \Big(1 - \frac{|\mathbf x - \mathbf x_i|^2}{(2\Delta x)^2}\Big)^3 , \tag{34} \]where the \(\mathbf x_i\) are the positions of the particles within \(2\Delta x\) of \(\mathbf x\), \(\bar{\mathbf x}\) their weighted mean, and \(r_0\) a radius. For a single particle \(\chi\) is the distance from it less \(r_0\); for many, \(\chi \lt 0\) inside the liquid and \(\chi \gt 0\) outside, and the surface is where \(\chi = 0\), the level set of the liquid. Particles within two cells of the glass are reflected in it (in the plane of the wall at the nearest point), so that the wall does not look like a surface. The code uses two radii. For the pressure step \(r_0 = 0.9\,\Delta x\), which closes the small gaps that open between particles near the glass, where a gap would act as a bubble of air. For reading the height of the surface, \(r_0 = 0.505\,\Delta x\), the value that puts the zero on the top of a flat layer seeded as the code seeds it (seen from a point on the top of such a layer, the weighted mean position lies \(0.505\,\Delta x\) below it). In each column the code finds the top of the stout from the first field and then the highest zero of the second in the top three cells; in the rare column where the second finds none, it takes the top less 0.68 of a cell, a fixed offset of the code, and counts the column (no column needed it in the stored rides' rest test). Separately, for the picture and for the reading of drops and lumps, a particle is drawn and counted as a drop when it stands more than 1.5 cells above the surface of its own column and of the eight around it, whether it has left the glass or not.
The columns at the glass need care. The tulip is wider below the fill than at it, so a column at the edge can have its centre inside the glass lower down but outside it at the surface; its stack of stout then ends where the glass ends, not where air begins, and it has no surface of its own. Every number read from the surface in this note therefore uses only the 1,977 columns whose centre lies more than one cell inside the glass at the fill, the trusted columns.
8.6Time step, precision and cost
The step is \(\Delta t = 2\) ms, shorter whenever the fastest particle would cross more than 0.8 of a cell in one step, and the last step before each stored picture is shortened so that the picture falls exactly on its time. Inside each fluid step the cart moves in sub-steps of 0.1 ms. The stout is computed in single precision (about seven significant digits), because the graphics card used, an NVIDIA Tesla T4, is many times slower in double precision; the sums inside the pressure solver's conjugate gradients and the books of section 9 are kept in double precision, the head sheet's in single, and the cart entirely in double. The conjugate-gradient method improves a trial solution of a symmetric linear system along a sequence of directions chosen so that no later step undoes an earlier one. A step of a ride took 84 to 93 ms on the T4, so each simulated second cost 43 to 48 s, and a ride of 8 s about 6 minutes.
09The books
A computation of a liquid must not lose any of it. The program keeps books, as a shop does, and checks in every stored picture that they balance.
The stout. Every one of the 1,001,952 particles is always in exactly one of four places: in the glass, in the air as a drop, at rest on the cart's body, or on the ground. The run counts all four in every stored picture and checks that they add up to the number poured; a stout particle can neither be created nor destroyed by the method, so the books must balance exactly, with no tolerance. In every stored picture of every ride on this page they do: the largest discrepancy is 0 particles. The stout in the glass, shown in the readings, is the number of particles still in it times their mass.
The head. The foam in the glass is its stored thickness in each column times the column's open area, summed over the columns in double precision; the foam broken off is the sum of the lumps' volumes. Together they must equal the 91.314 mL served. Because these are sums of many decimal numbers, they agree only to rounding: the largest discrepancy in any stored picture is 1.3 × 10⁻⁸ mL.
The push on the cart. The impulse book of section 7.3 must equal minus the stout's final momentum relative to the glass. In every ride it does, to a relative difference of at most 9 × 10⁻¹⁵, the rounding of double precision.
The energy of a pint at rest. Stout standing in a glass held still is in equilibrium: the pressure grows with depth as \(p = p_s + \rho g(h - z)\), and nothing moves, so nothing is sheared, and the frictions have nothing to act on. Energy gives a sharp form of this. Let \(E_k\) be the stout's kinetic energy, \(E_p\) its potential energy and \(D\) the energy turned into heat since the start. With the glass held still no outside force does work on the stout, so
\[ E_p(0) - E_p(t) = E_k(t) + D(t) . \tag{35} \]Whatever potential energy the stout loses must reappear as motion or as heat, and for a pint at rest all three terms should be zero. Every run therefore begins with 2 s of the pint at rest on the full grid, and a guard stops the whole run before any ride if the surface in any trusted column ends up more than half a cell (0.75 mm) from the fill, if the root mean square of those differences exceeds a quarter of a cell (0.375 mm), or if any stout or foam has left the glass. For the stored runs the surface after 2 s lies within 0.50 mm of the fill in every trusted column, 0.129 mm in root mean square, and nothing has left the glass. The stout's kinetic plus potential energy fell by 25.4 µJ in those 2 s, the energy the 429.6 g of stout would release by sinking 6.0 µm on average. The heat \(D\) booked by the frictions in that test was not kept with the stored runs, so (35) cannot be closed here; what is kept says that the pint at rest moved by a few micrometres and lost a few tens of microjoules, which is the scale of the test's resolution.
In every stored picture of every ride, every particle of stout is accounted for exactly, the foam to rounding, and the push booked on the cart equals minus the stout's momentum to rounding. A pint at rest stays level to within half a millimetre. A friction may act only on motion the stout really has; acting on a half-finished step, it turns gravity into false heat and a false flow.
10What the page shows
The page shows only what was computed: one stored picture after another, at the speed of the ride.
What is stored. For every thirtieth of a second of each ride the run stores the height of the stout's surface in each trusted column of the grid, in steps of 0.02 mm; the thickness of the head on each column, in steps of 0.1 mm; the position of every drop of stout outside the main body, in steps of 0.1 mm; the position and volume of every lump of foam that has broken off (volume in steps of 0.1 mm³); the cart's position, speed, the heights of its body and wheel, the motor current and the stout's push; the controllers' signals (section 12); and the books of section 9. A list of all files gives each one's size and its SHA-256 fingerprint, a 64-digit number computed from every byte of the file, so that a changed file cannot pass for the original.
How it is played. The page downloads a ride, computes the fingerprint of what arrived and refuses the file if it differs from the listed one. The ride's clock \(T\) then advances by the real time between two frames on your screen, at most 0.1 s at a time, so that a stalled browser resumes where it was instead of jumping. The page draws the stored picture whose time is nearest, number \(\mathrm{round}(30\,T)\), and never a blend of two: a blend of two stored surfaces is not a surface anybody computed. At the end of the stored time it stops and offers to ride again. The words of the readings are rewritten at most four times a second, so that they stay readable while the pictures change 30 times a second.
The readings. The cart's speed is the stored speed of the picture on screen. The stout in the glass and spilled are particle counts times the particle's mass, shown to the milligram. The head in the glass and spilled come from the books of section 9. The count of drops and lumps includes those still flying and those come to rest on the cart's body. The motor current and the active suspension's force are stored with every picture; the force is zero in every ride without an active suspension.
What is data and what is drawing (open)
The surface is drawn on a mesh of rings and angles around the glass's axis; each point of the mesh takes its height from the four stored columns around it, weighted by distance (bilinear interpolation), leaving out columns with no stored height, and the outer ring meets the glass at the height the surface has there. This is interpolation in space, for drawing, from heights rounded to 0.02 mm; there is none in time. The trusted columns end about one cell from the glass, so the last millimetre or two of the drawn surface next to the glass is extended inward from them, not stored. The head is drawn as a layer of the stored thickness on the stored surface, its colour fading to the stout's where it is thinner than 1.5 mm. Drops are dark dots at their stored places, each standing for one particle of 0.43 mm³; lumps are cream balls of their stored volume. The cart, its wheel and its body stand at their stored positions. The glass's tint and highlights, the reddish edge of the stout where it is thin enough for light to pass through, the lettering and the camera are drawing only. The largest lean and tilt in the table were read after the run, by the program that packed the files, from the surface before it was rounded for storage; read from the stored, rounded surface they change by at most 0.02 mm.
11What the computed rides show
A computation is worth trusting when it agrees with what we can work out without it; where it goes beyond that, we should be able to say how each of its numbers was read.
11.1How each number is read
Every number in this section is read from the stored files the page plays; nothing is recomputed by the solver. Two measures describe how far the surface has tipped. The lean is the height of the surface at the front of the glass minus its height at the back, read on the outermost ring of points the trusted columns reach, at the radius \(R - \Delta x/2\), as the page reads the surface (bilinear interpolation between columns; where a point of the ring falls beside the trusted columns, it is read half a cell further in). For a pure first mode the lean is \(2q\). The tilt is twice the part of the surface on that ring that varies as \(\cos\theta\), \(2\times(2/64)\sum\eta\cos\theta\) over 64 equally spaced angles \(\theta\); it removes any rise of the whole surface and every shape except those with one wave around the glass, and for a pure first mode it too is \(2q\). The two differ when the surface is not a pure first mode, which, after a hard jolt, it is not.
For the free swing we need \(q(t)\) itself. We read the \(\cos\theta\) part of the surface on a ring a little inside the outer one, at \(r = \tfrac{13}{16}(R - \Delta x/2) = 31.2\) mm, where every point lies well inside the trusted columns: \(q_\text{ring} = (2/64)\sum\eta\cos\theta\). From 0.1 s after the push ends, \(q_\text{ring}(t)\) is fitted by least squares with a damped cosine plus a constant, \(q_0e^{-t/t_d}\cos(\omega_dt + \psi) + q_c\). The solution of (14) rings at \(\omega_d = \omega\sqrt{1 - \zeta^2}\) and decays at the rate \(1/t_d = \zeta\omega\), so the swing's natural angular frequency is \(\omega = \sqrt{\omega_d^2 + 1/t_d^2}\) and its damping ratio \(\zeta = 1/(\omega t_d)\). For a lightly damped swing \(\omega\) and \(\omega_d\) are the same; for a heavily damped one they are not, and only \(\omega\) can be compared with the theory of sections 4 and 6.
11.2The free swing, without and with the head
Two rides at the end of the ride list hold the glass at rest and give it the one push of Table 3. By (13) that push would leave a bare, undamped first mode swinging with 5.2 mm at the wall, 5.0 mm on the ring we read. Figure 3 shows what the computed stout does. Its first swings without the head are a little smaller than that, because the stout is already losing energy during and right after the push.
Without the head. The stout rings at 3.330 Hz, natural frequency 3.331 Hz, 2.6 % below the 3.421 Hz of (10): the grid of 1.5 mm carries the swing a little slowly, as coarse grids usually do; we have not separated how much of this comes from the surface's representation and how much from the glass's cut cells. Its damping ratio is 0.0160. In this ride the model has the glass's layer and viscosity but no skin, the clean surface of section 5.4, whose physics gives \(\zeta = 0.0055\). The method itself therefore adds about 0.0105, 1.9 times the physics it is meant to carry. This is the price of the 1.5 mm grid and the million particles, and it is a limit of the model: for a stout without its head, the computed swing dies away about three times too fast. A refit of the stored file, independent of the run's own fit, gives 3.331 Hz and \(\zeta = 0.016\).
With the head. The same push gives a swing that rings at 2.639 Hz and decays in \(t_d = 0.128\) s: natural frequency \(\sqrt{\omega_d^2 + 1/t_d^2}/2\pi = 2.915\) Hz and damping ratio \(\zeta = 0.425\); the refit of the stored file gives 2.917 Hz and 0.425. Against this damping the method's own loss, 0.0105, is about 2.5 %. The damping itself can be set beside section 6.3: the fitted swing measured 2.3 mm at the wall, and for that size the edge friction alone predicts \(\zeta_\text{edge} = 0.47\), 11 % above the measured 0.425; a one-term energy estimate for a friction that is not linear agrees with the computation to that extent. For the frequency, the Key result of 6.5 predicts 3.070 Hz from the theory's wavenumber. On this grid, though, the bare stout swings at 3.331 Hz, which by \(\omega^2 = gk\) for a deep glass corresponds to \(k = 44.6\ \mathrm{m^{-1}}\); with (25) the head's mass then lowers the frequency by \(1/\sqrt{1 + \lambda_hk} = 0.902\), to 3.004 Hz. The computed 2.915 Hz is 3.0 % lower still; we have not found the cause (a candidate is that a strongly damped, non-linear swing is not fully described by the fit's single damped cosine). The swing falls by the factor \(e\) in 0.37 of a period and is gone within about one. After 1.5 s the swing on the ring settles at −0.03 mm and does not return to zero: the head holds a small tilt, as a material with a yield stress does (6.6).
Without its head the computed stout swings at 3.331 Hz, close to the theory's 3.421 Hz, and rings for seconds. With its head it swings at 2.915 Hz with a damping ratio of 0.425: the head's friction stops the swing within about one period, and its mass slows it. These two numbers, \(\omega = 18.32\ \mathrm{rad/s}\) and \(\zeta = 0.425\), together with \(\beta_h = 1.241\) from section 6.5, describe the swing the controllers of section 12 are designed for.
11.3How hard each road shakes the pint
With the swing measured, we can ask how hard each road shakes the glass before reading the rides. We ran the cart of the code alone, carrying the pint as a frozen load (the push \(\mathbf F\) of section 7.3 switched off), with its motor current set every millisecond to hold the speed, as in the rides named "speed held only", in the code's sub-steps of 0.1 ms, and recorded the glass's mean acceleration over each step of 2 ms. From \(a(t)\) and (13) follows the swing each road would leave behind if nothing damped it.
| Road | Largest \(|a|\) | \(g + a_z\) | Swing, bare | Swing, with head |
|---|---|---|---|---|
| five 20 mm bumps, 1.0 m/s | 1.6 m/s² | \(−0.7\) to 20.0 m/s² | 45 mm | 10 mm |
| one 25 mm bump, 1.0 m/s | 1.0 m/s² | 1.5 to 17.6 m/s² | 8.5 mm | 7.1 mm |
| kerb, 1.5 m/s | 28.8 m/s² | \(−2.4\) to 20.6 m/s² | 24 mm | 26 mm |
The five gentle bumps push no harder than 1.6 m/s², yet because they come in step with the bare stout's swing they would build it to 45 mm, about 2.0 times the 22.5 mm that brings the stout to the rim. For the stout with its head, which swings more slowly, the same bumps come 18 % too fast, and the undamped swing is only 10 mm: the head's mass has detuned the dangerous road. On the kerb the cart's speed drops by 0.29 m/s within a few hundredths of a second, and the undamped swing comes near the stout's rim height either way; with the head the kerb's swing is even a little larger than the bare stout's: \(\beta_h/\omega\) is a few per cent smaller than \(\beta/\omega_{11}\), but the kerb's push, read through (13), contains 1.16 times as much at the slower swing's frequency. The single big bump would leave 7.1 mm with the head, just below the 7.6 mm that breaks the foam (Example 6.2), and spill no stout. These are upper bounds: the friction of sections 5 and 6, which the free swing has just shown to be strong, reduces them. The table also shows that on the bumps the body falls, for an instant, faster than gravity, \(g + a_z \lt 0\): in the glass's frame the stout then feels no weight, or a slight pull upward.
11.4Whether the heave can pump the swing ★
A vertical acceleration enters (26) inside the bracket, not on the right: it changes the swing's stiffness and acts only on a swing that already exists. Such a term is called parametric. It can pump a swing, as a child pumps a playground swing by standing up and crouching twice in each swing, but only when it beats at about twice the swing's frequency and is strong enough to beat the damping. For a steady heave \(a_z = \varepsilon g\cos\Omega t\) the swing obeys the damped Mathieu equation,
\[ \ddot q + 2\zeta\omega\,\dot q + \omega^2\,(1 + \varepsilon\cos\Omega t)\,q = 0 . \tag{36} \]For small \(\varepsilon\) and \(\zeta\) the swing grows when \(\varepsilon \gt 4\zeta\) at \(\Omega = 2\omega\) (Problem 9). For the bare stout, \(\zeta = 0.0055\), that is a heave of \(4\times0.0055\times9.81 = 0.22\ \mathrm{m/s^2}\) at 6.84 Hz, kept up over many swings. With the head the damping is far too large for that rule, so we followed (36) numerically over one period of the heave and asked whether any solution grows from one period to the next (the solutions after one period are a linear map of the solutions before it, and the swing grows when that map has an eigenvalue larger than one in size; this is Floquet's method). For the computed swing with its head (2.915 Hz, \(\zeta = 0.425\), section 11.2) the lowest threshold is \(\varepsilon = 1.71\), at \(\Omega = 1.81\,\omega\): a heave of 16.8 m/s² at 5.28 Hz, kept up. On the roads here the glass's vertical acceleration stays within \(\pm12\ \mathrm{m/s^2}\) or so of rest (Table 4 gives the extremes of \(g + a_z\)), and in single bumps, not kept up. The heave cannot pump this pint's swing, and the swings of Table 4, which leave the heave out, are not made worse by it.
11.5The rides with the speed held
In the three rides named "speed held only" the motor does nothing but hold the cart's speed (section 12.2 builds this rule). Table 5 gives what the stored files show.
| Road | Tilt | Lean | Foam spilled | Stout spilled | Speed | Current |
|---|---|---|---|---|---|---|
| five 20 mm bumps, 1.0 m/s | 13.6 mm | 13.9 mm | 0.01 mL, from 1.50 s | 0 g | 0.94–1.05 m/s | 2.40 A |
| one 25 mm bump, 1.0 m/s | 8.0 mm | 8.9 mm | 0 mL | 0 g | 0.96–1.04 m/s | 2.00 A |
| kerb, 1.5 m/s | 22.2 mm | 24.3 mm | 2.44 mL, from 0.67 s | 0 g | 1.21–1.52 m/s | 2.98 A |
The five bumps. Without friction the bumps would build the bare stout's swing to 45 mm at the wall (Table 4), a lean of about twice that. With its head the stout leans by at most 13.9 mm: its swing is slower than the bumps, and it loses most of its energy within one period, so pushes that come once a period cannot pump it up. A tiny lump of foam, 0.01 mL, broke over the back rim at 1.50 s. The lean alone would not predict it, since half of 13.9 mm is below the 7.6 mm of Example 6.2; but the surface is not a pure first mode, and at 1.40 s the back wall had risen 8.1 mm while the front had fallen only 5.8 mm.
The single bump leaves a lean of 8.9 mm and spills nothing: the wall rises about half the lean, less than the 7.6 mm at which the foam breaks off (Example 6.2).
The kerb. The cart's speed drops by 0.29 m/s within a few hundredths of a second (Table 5 gives the whole range of speeds over the ride), the stout surges forward, and foam goes over the front rim from 0.67 s on: 2.44 mL of it, in many small lumps. No stout leaves the glass; its surface would have to rise 22.5 mm at the wall, and the lean of 24.3 mm means a rise of about half that.
Where the data come from (open)
The rides were computed by the program tools/fig12/kaggle/stout_jax.py of this site's repository, run on an NVIDIA Tesla T4 in a private Kaggle notebook, and packed into the files the page plays (public/data/fig12/2026-11-14-run10/, listed with their fingerprints in index-jax.json). The three rides with the speed held, the pint at rest and the free swing with the head come from the notebook's version 8 (13 and 14 November 2026, code at commit 96e8a1d). The five controlled rides of section 12 come from version 10 (14 November 2026, commit 58eea68), whose controllers use the drive coefficient with the head's mass, \(\beta_h\). The program's model of the stout and the head is the same in versions 8 and 10 (the file stout_jax.py is unchanged between the two commits; only the run script changed), so the rides with the speed held and the controlled rides can be compared directly. The free swing without the head comes from version 6 (commit 4c10527); without a head, the later changes to the head's model cannot change it. Every number of this note is printed from these files by tools/fig12/kaggle/note_numbers.py and filled in by build_note.py.
12Five controllers
A good waiter carries a tray of full glasses across a crowded room without spilling, and does it with a few plain habits. The cart can be given the same habits, one controller for each.
Watch a waiter with a full tray. He keeps an even pace, because every change of speed rocks the drinks. When he sees a step ahead, he eases into it before he reaches it. When a glass starts to rock, his hand moves with it and takes the rocking out. When he steps down from a kerb, his knees bend so that the tray does not drop with his body. And when somebody bumps into him, none of these habits helps: the jolt is too quick and too strong for his arm, and the drinks slop. In this section we give the cart each habit as a controller, derive it from the equations of the earlier sections, and ask what it can and cannot do with the cart's motor.
12.1The controllers and what they act with
The cart has two ways to act on the glass. The motor pushes it along the road with \(b\,i\) (section 7.1). And its suspension can carry, beside the spring and the damper, an active force \(F_a\) between the body and the axle: an actuator that pushes the two apart or pulls them together, at most \(F_\text{max} = 40\) N, following its command with the lag \(\tau_u = 5\) ms. Each controller runs once every \(T_s = 1\) ms, its sample time, reads only what sensors on a real cart could read, and sets a commanded current \(i_\text{cmd}\), and in two cases a commanded force. Table 6 lists the five.
| Controller, and the waiter's habit | Reads | Commands | Stored rides |
|---|---|---|---|
| speed held only (12.2) an even pace | the wheel's speed | motor current | all three roads |
| road preview (12.4) easing into a step he sees | the speed; the road's slope a little ahead | motor current | the kerb |
| skyhook (12.5) knees that hold the tray level | the body's vertical speed | active force | none on its own |
| slosh LQR (12.6–12.7) the hand against the rocking | the speed; two level probes; the motor current | motor current | the kerb |
| joint control (12.8) hand and knees together | the speed; two level probes; the motor current; a body accelerometer; the spring's stroke; the body's and the wheel's vertical speeds; the tyre's load | motor current and active force | all three roads |
12.2Keeping the pace: the speed loop
Every millisecond the controller reads the speed from a sensor on the wheel and sets
\[ i_\text{cmd} = i_0 + K_p\,(v_0 - v) + K_i\,x_e, \qquad x_e = \int_0^t\big(v_0 - v\big)\,\mathrm dt' , \tag{37} \]with \(v_0\) the speed chosen for the ride and \(i_0 = c_xv_0/b\) the current that holds it against the drag. The first term pushes in proportion to the speed error. The second pushes in proportion to the error's history \(x_e\), the distance by which the cart has fallen behind its schedule, so that no steady error can survive: \(x_e\) would keep growing until the push removed it. This is a proportional-integral, or PI, controller [17, sections 11.1 and 7.4]. To see how it behaves, write \(v = v_0 + \delta v\) and \(i = i_0 + \delta i\), leave out the lag (29), and put (37) into (28) with \(F_d = 0\). The steady parts cancel, since \(bi_0 = c_xv_0\), and we are left with \(M_x\,\dot{\delta v} = b\,\delta i - c_x\delta v\), \(\delta i = -K_p\delta v + K_ix_e\), \(\dot x_e = -\delta v\). Differentiating the first equation once in time removes the integral:
\[ M_x\,\ddot{\delta v} + (c_x + bK_p)\,\dot{\delta v} + bK_i\,\delta v = 0 . \tag{38} \]The gains are \(K_p = M_x\omega_c/b\) with \(\omega_c = 2\pi\times8\) Hz, which makes the loop answer well above the stout's swing, and \(K_i = K_p\omega_c/4\), which without drag gives (38) a double root at \(-\omega_c/2\): for this \(\omega_c\) the speed returns as fast as it can without overshooting. They were fixed in the code for the cart carrying the stout without its head, \(M_x = 2.505\) kg, and kept unchanged when the head was added: \(K_p = 25.18\ \mathrm{A/(m/s)}\) and \(K_i = 316.4\ \mathrm{A/m}\). With the head the cart is 1 % heavier, and the roots of (38) are \(−21.6\) and \(−29.0\ \mathrm{s^{-1}}\).
When the command lies beyond what the drive can give, the integral would keep growing while the motor cannot act on it, and the loop would overshoot later; this is called windup [17, section 11.4]. The code stops the integral while \(|i_\text{cmd}| \ge I_\text{max}\). And the loop helps the stout only indirectly, by taking out part of each jolt. For a disturbing force that varies as \(e^{j\omega t}\), the loop's gain is \(\mathcal L = b\,(K_p + K_i/j\omega)/(M_xj\omega + c_x)\), and with the loop closed the cart's acceleration is \(S = 1/(1 + \mathcal L)\) times what it would be without it; \(S\) is the loop's sensitivity. At the crossover \(\omega_c\) the loop's gain \(|\mathcal L|\) is about one: below it the loop answers a disturbance strongly, above it hardly at all.
Take \(\omega = 18.32\ \mathrm{rad/s}\), the swing with its head. Then \(K_p + K_i/(j\omega) = 25.18 - 17.27j\) A/(m/s), \(M_xj\omega + c_x = 2 + 46.33j\) kg/s, \(\mathcal L = −1.744 - 2.793j\), \(|1 + \mathcal L| = 2.890\) and \(|S| = 0.346\). With the current lag and the half-sample delay of a command held for 1 ms, \(|S| = 0.352\). The speed loop lets 35 % of a jolt near the swing's frequency through to the glass; that is all it does for the stout.
12.3What no controller can do at the kerb
Before building the other controllers we ask how hard the motor can push at all against the kerb, because that settles what any of them can do there. We ran the cart of the code alone over the kerb at 1.5 m/s; at that speed the supply lets the motor push forward with at most 11.25 N (Example 7.1), and with 15 N only once the cart has slowed. We used the pint frozen as a rigid load, the speed loop, sub-steps of 0.1 ms, and recorded every force (Figure 4). The road pushes on the wheel at right angles to the path of the axle; where that path has the slope \(z_a' = \mathrm dz_a/\mathrm dx\), the push along the road is \(-Nz_a'\) for a push \(N\) mostly upward, backward while the wheel climbs. On the kerb the slope reaches 0.785, and to lift the wheel 30 mm in a few hundredths of a second the tyre must push it up hard: its load rises to 105 N, 4.7 times its static value. The road therefore brakes the cart, within 42 ms, with up to 82 N; for 20 ms it pushes back harder than even the motor's 15 N. And the tyre bounces: in the next few tenths of a second the wheel leaves the road 6 times, 92 ms in all, and while it is in the air the motor can push nothing.
The speed loop senses the speed fall and asks for far more than the drive has; the current reaches 2.98 A, and the speed falls from 1.5 to 1.21 m/s. To see what the best possible controller could do, we commanded the full forward current from 4 ms before the wheel touches the kerb, two current lags early so that the current is at its limit while the push is still building, until the top of the climb. The speed first rises a little, to 1.51 m/s, and then falls to 1.23 m/s: a sudden loss of 0.28 m/s within a few hundredths of a second, much less than a swing's period.
Now follow such a sudden loss into the stout. By section 4.2, with the head's \(\beta_h\) of 6.5, a sudden change of speed \(\Delta v\) gives the swing at once the rate \(\dot q = -\beta_h\Delta v\), here positive: the front rises. Kicked from rest, a swing with natural angular frequency \(\omega\) and damping ratio \(\zeta\) then moves as \(q = (\beta_h|\Delta v|/\omega_d)\,e^{-\zeta\omega t}\sin\omega_dt\), with \(\omega_d = \omega\sqrt{1 - \zeta^2}\). Its first peak comes where \(\dot q = 0\), that is where \(\tan\omega_dt = \sqrt{1 - \zeta^2}/\zeta\); there \(\sin\omega_dt = \sqrt{1 - \zeta^2}\), and
\[ q_\text{peak} = \frac{\beta_h|\Delta v|}{\omega}\,e^{-\zeta\omega t_p}, \qquad \omega_dt_p = \arctan\frac{\sqrt{1 - \zeta^2}}{\zeta} , \]with \(t_p\) the time of the first peak. For the computed swing with its head, \(\omega = 18.32\ \mathrm{rad/s}\) and \(\zeta = 0.425\), so \(\omega_d = 16.58\ \mathrm{rad/s}\) and the first peak comes \(t_p = 1.132/16.58 = 68\) ms after the kick, while the wheel is still bouncing. With \(|\Delta v| = 0.28\) m/s, \(\beta_h|\Delta v|/\omega = 1.241\times0.28/18.32 = 18.9\) mm and \(e^{-\zeta\omega t_p} = e^{-0.531} = 0.588\): the wall rises 11.1 mm, more than the 7.6 mm at which the foam breaks over the rim (Example 6.2). As a check, for \(\zeta \to 0\) the peak comes after a quarter period, the exponential tends to 1, and \(q_\text{peak}\) tends to the undamped (12).
On the kerb at 1.5 m/s the road pushes the cart back with up to 82 N, 7.3 times the 11.25 N the motor can push forward with at that speed (its 3 A limit gives 15 N only at lower speeds, because of the 12 V supply), and then throws the wheel into the air for 92 ms in which the motor can push nothing. Even with full forward current commanded in advance, the cart loses 0.28 m/s within a few hundredths of a second. That sudden loss sets the stout swinging, and raises the front wall by about 11.1 mm, more than the foam can stand. A controller can choose what the motor does around the jolt; with this motor it cannot remove the jolt.
12.4Looking ahead: the road preview
The speed loop only reacts: the road must first slow the cart before the loop can push back. A waiter who sees a step coming leans into it as he arrives, and the cart can do the same, because its road is known. The road's push on the wheel is \(-Nz_a'(x)\) (12.3). Estimate the tyre's load by its static value \(N_0 = (M_s + m_w)\,g\) and add to the speed loop's command the current whose push cancels the road's. That current, however, arrives only after the lag \(\tau_i\) of (29). For a command that changes slowly compared with \(\tau_i\), the lag acts as a delay: for a signal \(e^{j\omega t}\), (29) gives \(i = i_\text{cmd}/(1 + j\omega\tau_i)\), and \(1/(1 + j\omega\tau_i) = 1 - j\omega\tau_i + \dots\) agrees to first order with the delay factor \(e^{-j\omega\tau_i} = 1 - j\omega\tau_i + \dots\). The current at time \(t\) is then about the command of time \(t - \tau_i\). To have the right current when the wheel is at \(x\), the command must read the road where the wheel will be one lag later, at \(x + v\tau_i\):
\[ i_\text{cmd} = i_\text{PI} + \frac{N_0\,z_a'(x + v\,\tau_i)}{b} , \tag{39} \]with \(i_\text{PI}\) the command (37). This is feedforward from a disturbance known in advance: looking ahead is what lets it undo the lag, since undoing a delay needs a prediction [17, section 12.4]. A real cart would read the road from a camera or a map; the code reads its own table of the road.
At 1.0 m/s the preview reads the road \(v\tau_i = 2\) mm ahead, at 1.5 m/s 3 mm. The axle's path is at most 0.251 steep on the five bumps and 0.262 on the single bump, so there the preview adds at most \(22.1\times0.262/5 = 1.16\) A, well within the drive. On the kerb the slope reaches 0.785, and the preview asks for \(22.1\times0.785/5 = 3.47\) A, already more than the drive has. And it reckons with the static load of 22.1 N, while the kerb loads the tyre with 105 N: the push it would have to cancel is 82 N, worth 16 A. On gentle bumps the preview can cancel the road's push; on the kerb it saturates as the speed loop does.
12.5The skyhook
Imagine the cart's body hung from a hook in the sky by a damper, the way the waiter's knees hold a tray level while the floor moves: whenever the body moves up or down, the damper resists with a force proportional to the body's own vertical speed \(v_b\), measured against the fixed sky rather than against the wheel. Such a damper calms the body's bounce without passing the road's shocks on to it, as a damper between body and wheel would. No real hook exists, but the active force can play its part:
\[ F_a = -c_\text{sky}\,v_b . \tag{40} \]The code chooses \(c_\text{sky} = 2\times0.70\times\sqrt{k_sM_s'} = 47.6\ \mathrm{N\,s/m}\), with \(M_s'\) the mass on the spring without the head, so that the body alone on its spring would have a damping ratio of 0.70 instead of the passive damper's 0.12. The skyhook acts only on the body's bounce, not on the stout's swing along the road. No stored ride uses it on its own; the joint control of 12.8 has its own, stronger rule for the suspension.
12.6Watching the stout: the slosh LQR ★
The third habit uses what the first two ignore: the waiter watches the drink. The cart can watch its stout through two level probes on the glass (12.7) and act on the swing itself. To design such a controller we put the cart and the first mode into one linear model. Let \(\delta v = v - v_0\) be the speed error, as in 12.2, \(x_e\) its integral as in (37), \(q\) the swing's height at the wall and \(\delta i = i - i_0\) the current beyond the steady one. By (28) with \(F_d = 0\), \(\dot{\delta v} = (b\,\delta i - c_x\delta v)/M_x\). The swing obeys (26) with its damping and, for this design, without the heave (section 11.4 showed the heave cannot pump it; 12.8 adds it back): \(\ddot q = -\omega^2q - 2\zeta\omega\dot q - \beta_ha\), and the glass's acceleration along the road is the cart's, \(a = \dot{\delta v}\). Substituting it, the four quantities \(\mathbf x = (\delta v, q, \dot q, x_e)\), the state, obey \(\dot{\mathbf x} = A\mathbf x + B\,\delta i\) with
\[ A = \begin{pmatrix} -c_x/M_x & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ \beta_hc_x/M_x & -\omega^2 & -2\zeta\omega & 0 \\ -1 & 0 & 0 & 0 \end{pmatrix}, \qquad B = \frac{b}{M_x}\begin{pmatrix} 1 \\ 0 \\ -\beta_h \\ 0 \end{pmatrix} . \tag{41} \]The third row says that the motor reaches the stout only through the glass's acceleration: a push \(b\,\delta i\) accelerates the cart by \(b\,\delta i/M_x\) and drives the swing with \(-\beta_h\) times that. We look for the feedback \(\delta i = -K\mathbf x\), a row \(K\) of four gains, that keeps all four states small without large currents, in the sense that it makes
\[ J = \int_0^\infty\big(\mathbf x^{\mathsf T}Q\,\mathbf x + r_u\,\delta i^2\big)\,\mathrm dt \tag{42} \]as small as possible. Here \(Q\) is the diagonal matrix with the entries \(1/\delta v_\text{m}^2\), \(1/q_\text{m}^2\), \(1/\dot q_\text{m}^2\) and \(1/x_\text{e,m}^2\), and \(r_u = 1/I_\text{max}^2\). Each weight is one over the square of the largest value we are willing to accept, which is Bryson's rule [17, Exercise 7.16]: \(\delta v_\text{m} = 0.05\) m/s, \(q_\text{m} = 2\) mm, \(\dot q_\text{m} = 2\ \mathrm{mm}\times\omega\), \(x_\text{e,m} = 2\) cm, and the drive's 3 A for the current. This is the linear quadratic regulator, LQR. Its answer is a constant gain [17, section 7.5],
\[ K = \frac{1}{r_u}\,B^{\mathsf T}X, \qquad 0 = A^{\mathsf T}X + XA - \frac{1}{r_u}\,XBB^{\mathsf T}X + Q , \tag{43} \]where \(X\) is the symmetric, positive definite solution of the second equation, the algebraic Riccati equation. The idea behind it is short. If \(\mathbf x^{\mathsf T}X\mathbf x\) is the least cost still to come from the state \(\mathbf x\), then along the best path its rate of fall must equal the cost being spent, \(\mathbf x^{\mathsf T}Q\mathbf x + r_u\delta i^2\); minimizing over \(\delta i\) gives \(\delta i = -B^{\mathsf T}X\mathbf x/r_u\), and inserting it back gives (43) for every \(\mathbf x\). The current commanded is \(i_\text{cmd} = i_0 - K\hat{\mathbf x}\), with \(\hat{\mathbf x}\) the estimate of the state that 12.7 builds; \(x_e\) is the controller's own running sum, integrated only while \(|i_\text{cmd}| \lt I_\text{max}\), as in 12.2. The code solves (43) with a standard routine for the Riccati equation.
One gain can be found by hand, and it is a useful check. The fourth column of \(A\) is zero, because nothing in the cart or the stout depends on how far behind schedule the cart is. The \((4,4)\) entry of \(A^{\mathsf T}X + XA\) is then \(2(A_{14}X_{14} + A_{24}X_{24} + A_{34}X_{34} + A_{44}X_{44}) = 0\), and the \((4,4)\) entry of the Riccati equation reduces to \(-(XB)_4^2/r_u + Q_{44} = 0\). Hence \(|K_4| = |(XB)_4|/r_u = \sqrt{Q_{44}/r_u} = I_\text{max}/x_\text{e,m} = 150\ \mathrm{A/m}\), exactly, whatever the stout does.
Which swing the regulator is designed for. The model (41) needs \(\omega\), \(\zeta\) and \(\beta_h\). The controllers of the stored rides use the swing the computed stout actually has, measured in the free swing with the head (computed with the same program, notebook version 8, before the controlled rides of version 10): \(\omega = 18.32\ \mathrm{rad/s}\) and \(\zeta = 0.425\) (section 11.2), and \(\beta_h = 1.241\) (section 6.5). There are two reasons. The filter of 12.7 carries the swing forward between readings with this model, and a model that rang for seconds at 3.421 Hz would predict a swing the stout under its head no longer has. And the gains of (43) are the best ones only for the swing they were computed for.
For the full glass, \(M_x = 2.529\) kg, (43) gives \(K_1 = 71.12\ \mathrm{A/(m/s)}\), \(K_2 = −1228.72\ \mathrm{A/m}\), \(K_3 = −40.50\ \mathrm{A\,s/m}\) and \(K_4 = −150.00\ \mathrm{A/m}\), in the order of \(\mathbf x = (\delta v, q, \dot q, x_e)\); these are, to within \(6 × 10⁻³\) A per unit of state, the gains stored with the rides. Read them with \(i_\text{cmd} = i_0 - K\mathbf x\). A cart 0.1 m/s too fast is asked to brake with 7.1 A, beyond the drive's 3 A. A swing 1 mm high at the front wall, the stout surged forward, adds \(+1.23\) A, a forward push; by (26) a forward acceleration lowers the front, so the push works against the surge. A front rising at 10 mm/s adds 0.40 A forward, and a cart 1 cm behind its schedule 1.5 A.
What the regulator does to the swing. The motion of the loop, \(\dot{\mathbf x} = (A - BK)\mathbf x\), is a sum of terms \(e^{\lambda t}\), with \(\lambda\) the eigenvalues of \(A - BK\). Without control the swing's pair is \(\lambda = -\zeta\omega \pm j\omega\sqrt{1 - \zeta^2} = −7.79 \pm 16.58j\ \mathrm{s^{-1}}\): the swing decays at the rate 7.79 s⁻¹. With the regulator the pair becomes \(−10.83 \pm 7.03j\ \mathrm{s^{-1}}\), a damping ratio of 0.84; the decay is 39 % faster. The other two eigenvalues are \(−2.57\ \mathrm{s^{-1}}\), the slow return of the cart to its schedule, and \(−232\ \mathrm{s^{-1}}\). The same design for the bare stout of the theory (3.421 Hz, \(\zeta = 0.0055\), \(\beta\)) gives \(K = (75.0, −1937.8, −38.9, −150.0)\) and moves the swing's decay rate from 0.12 to 12.0 s⁻¹, about 101 times faster.
For a bare stout the slosh LQR turns a swing that rings for many seconds into one that is gone in a fraction of a second. The head already stops the swing within about one period, and the regulator adds 39 % to its decay rate. What is left for control on this pint is not the ringing after a jolt, which the head removes, but the first surge, and on the kerb that is set by the jolt (12.3).
12.7Seeing the swing: two probes and a Kalman filter ★
The regulator needs \(\delta v\), \(q\) and \(\dot q\), and the cart can measure the last two only indirectly. It carries three sensors. A sensor on the wheel gives the speed, \(y_v = v\), at every sample. Two level probes, thin strips on the inside of the glass at the front (\(\theta = 0\)) and at the back (\(\theta = \pi\)), read the height of the stout where it touches the glass, as a capacitive strip would. At the wall the first mode is \(\eta = q\cos\theta\), \(+q\) at the front and \(-q\) at the back, while anything that lifts the whole surface adds the same to both. Half their difference keeps the swing and drops the rest:
\[ y_q = \tfrac12\big(\eta_\text{front} - \eta_\text{back}\big) . \]In the solver the probes read the surface the last fluid step left: each takes the heights at \(R - 2.5\Delta x\) and \(R - 4\Delta x\) from the nearest columns and extends the straight line through them to the wall. They read once per fluid step, and the controller uses the reading at its next sample. The third input is the motor current, which the drive measures. No noise is added to these readings in the stored rides; the computed surface has small reading errors of its own.
One number, two opinions. The filter that turns these readings into an estimate rests on one idea, best seen for a single number. Suppose we have two independent opinions about \(q\): a prediction \(q^-\) from a model, with variance \(C^-\), and a reading \(y\), with variance \(V_y\). Any blend \(\hat q = q^- + L\,(y - q^-)\) is right on average; its error is \(1 - L\) times the prediction's error plus \(L\) times the reading's, so its variance is \((1 - L)^2C^- + L^2V_y\). Setting the derivative with respect to \(L\) to zero gives the best blend, \(L = C^-/(C^- + V_y)\), whose variance \((1 - L)\,C^-\) is smaller than either opinion's. Between readings the model carries the estimate forward and its uncertainty grows; at each reading the blend pulls it back. That is the Kalman filter [18, Theorem 3], here for three quantities at once.
The filter's model. The filter carries \(\mathbf z = (v, q, \dot q)\), the speed itself rather than its error. Since \(bi_0 = c_xv_0\), the first three rows of (41) read, with the full current \(i\) and with everything the model does not know gathered in \(\mathbf f = (F_d, a_q)\),
\[ \dot{\mathbf z} = A_z\mathbf z + B_z\,i + G\,\mathbf f, \quad A_z = \begin{pmatrix} -c_x/M_x & 0 & 0 \\ 0 & 0 & 1 \\ \beta_hc_x/M_x & -\omega^2 & -2\zeta\omega \end{pmatrix}, \quad B_z = \frac{b}{M_x}\begin{pmatrix} 1 \\ 0 \\ -\beta_h \end{pmatrix}, \quad G = \begin{pmatrix} 1/M_x & 0 \\ 0 & 0 \\ -\beta_h/M_x & 1 \end{pmatrix} . \tag{44} \]Here \(F_d\) is every other force on the cart, the road's and the stout's own push, and \(a_q\) is what the one-mode model gets wrong about the swing. Both are modelled as white noise, a signal whose integral over any time \(T_w\) has the variance \(WT_w\), where \(W\) is its intensity; a quantity that may change by \(\Delta\) within \(T_w\) has \(W \approx \Delta^2/T_w\). The code takes \(W_F = 0.5\ \mathrm{N^2\,s}\), an impulse of about 0.22 N s within 0.1 s, and \(W_a = 0.002\ \mathrm{m^2\,s^{-3}}\), the swing's rate drifting by about 0.026 m/s within one swing; it trusts the speed sensor to \(\sigma_v = 2\) mm/s and the probes to \(\sigma_q = 0.8\) mm. Note the path of \(F_d\) in \(G\): it reaches the swing through \(-\beta_h/M_x\), as the motor's push does, so in the filter's eyes a force that changes the speed must also have set the stout sliding.
From one sample to the next. The controller holds its command for one sample. Integrating (44) over \(T_s\) with \(i\) constant, and writing \([n]\) for the value at the \(n\)-th sample, gives
\[ \mathbf z[n] = A_d\mathbf z[n-1] + B_d\,i[n-1] + \mathbf f[n], \qquad A_d = e^{A_zT_s}, \qquad B_d = \int_0^{T_s}e^{A_zs'}\,\mathrm ds'\;B_z, \qquad Q_d = \mathrm{cov}\,\mathbf f[n] = \int_0^{T_s}e^{A_zs'}\,GWG^{\mathsf T}\,e^{A_z^{\mathsf T}s'}\,\mathrm ds' , \tag{45} \]with \(W = \mathrm{diag}(W_F, W_a)\) and \(e^{M}\) the matrix exponential. Both integrals come from one matrix exponential each. For the first, the exponential of the block matrix \(\big(\begin{smallmatrix} A_z & B_z \\ 0 & 0\end{smallmatrix}\big)T_s\) has \(A_d\) and \(B_d\) as its upper blocks, because the added row describes a current that stays constant. For the second,
\[ \exp\!\Big[\begin{pmatrix} -A_z & GWG^{\mathsf T} \\ 0 & A_z^{\mathsf T}\end{pmatrix}t\Big] = \begin{pmatrix} e^{-A_zt} & \Gamma(t) \\ 0 & e^{A_z^{\mathsf T}t}\end{pmatrix}, \qquad \dot\Gamma = -A_z\Gamma + GWG^{\mathsf T}e^{A_z^{\mathsf T}t}, \quad \Gamma(0) = 0 , \tag{46} \]since the derivative of \(e^{Mt}\) is \(Me^{Mt}\). The equation for \(\Gamma\) is solved by \(\Gamma(t) = e^{-A_zt}\int_0^te^{A_zs'}GWG^{\mathsf T}e^{A_z^{\mathsf T}s'}\,\mathrm ds'\), as differentiating shows, so \(Q_d = A_d\,\Gamma(T_s)\). This device is known as Van Loan's method.
Predict, then correct. The filter keeps an estimate \(\hat{\mathbf z}\) and its error covariance \(C\). At each sample it first predicts with the current measured at the last sample,
\[ \hat{\mathbf z}^-[n] = A_d\hat{\mathbf z}[n-1] + B_d\,i[n-1], \qquad C^-[n] = A_dC[n-1]A_d^{\mathsf T} + Q_d , \tag{47} \]and then blends the prediction with the readings \(\mathbf y[n]\):
\[ \hat{\mathbf z}[n] = \hat{\mathbf z}^-[n] + L[n]\big(\mathbf y[n] - H\hat{\mathbf z}^-[n]\big), \qquad L[n] = C^-[n]H^{\mathsf T}\big(HC^-[n]H^{\mathsf T} + \Sigma\big)^{-1}, \qquad C[n] = (I - L[n]H)\,C^-[n]\,(I - L[n]H)^{\mathsf T} + L[n]\Sigma L[n]^{\mathsf T} . \tag{48} \]\(H\) picks what was read: the row \((1, 0, 0)\) when only the speed is new, and the rows \((1, 0, 0)\) and \((0, 1, 0)\) at the first sample after a fluid step, when the probes have read the surface again; \(\Sigma\) holds the variances \(\sigma_v^2\) and \(\sigma_q^2\). The gain \(L[n]\) is the blend of one number written for several, and the last expression, Joseph's form, equals \((I - L[n]H)\,C^-[n]\) for this gain but stays symmetric and positive in floating point [17, section 8.4]. The filter starts with the stout at rest and the speed at its set value.
After a few hundred samples \(C\) settles into a cycle of two samples, with a probe reading at every second one. At a sample with a probe reading the gains are, rows \(v, q, \dot q\), columns speed and probe,
\[ L = \begin{pmatrix} 0.953 & −0.0038\ \mathrm{s^{-1}} \\ −0.0006\ \mathrm s & 0.060 \\ −1.172 & 0.926\ \mathrm{s^{-1}} \end{pmatrix} . \]If the speed sensor reads 10 mm/s less than predicted, the filter takes 9.5 mm/s off its estimate of the speed and at once raises the swing's rate by 11.7 mm/s: it reads an unexpected loss of speed as a push from outside, which by (44) must also have set the stout surging forward, by about \(\beta_h\) times as much (11.7/9.5 = 1.23, against \(\beta_h = 1.241\)). If a probe reads 1 mm more than predicted, \(\hat q\) moves by 0.060 mm and \(\hat{\dot q}\) by 0.93 mm/s: the filter weighs about 17 readings, 33 ms, a tenth of a swing. Its estimates are then uncertain by 2.0 mm/s in the speed, 0.20 mm in the swing and 6.9 mm/s in its rate (one standard deviation).
Estimate and regulator together. The regulator (43) was designed as if it could see \(\mathbf x\); it is given \(\hat{\mathbf x}\) instead. For a linear model with noise of this kind, designing the two separately is the best possible, the separation principle [17, sections 8.3 and 8.4]: the eigenvalues of the whole loop are those of the regulator together with those of the filter.
12.8The heave, and joint control ★
The last habit is in the knees. A bump does more than push the cart back: it lifts and drops the glass. By (26) with its damping, a vertical acceleration \(a_z\) enters the swing as
\[ \ddot q + 2\zeta\omega\dot q + \omega^2\Big(1 + \frac{a_z}{g}\Big)q = -\beta_ha . \]The push along the road stands on the right; the heave stands inside the bracket, as the parametric term of section 11.4. Joint control answers it twice, with the motor and with the suspension.
The motor cancels the term. A current \(\delta i\) adds \(b\,\delta i/M_x\) to \(a\) and therefore \(-\beta_hb\,\delta i/M_x\) to the right side. Choosing it to equal \(\omega^2(a_z/g)\,q\), the parametric term carried to the right,
\[ i_\text{par} = -\frac{M_x\,\omega^2}{\beta_h\,b}\,\frac{a_z}{g}\,\hat q , \tag{49} \]the swing obeys, wherever \(\hat q = q\), \(\ddot q + 2\zeta\omega\dot q + \omega^2q = -\beta_ha'\), with \(a'\) the acceleration the other currents give: the linear swing the regulator was designed for. A body accelerometer reads \(a_z\) at each sample, and in this design the filter recomputes \(A_d\) and \(B_d\) at each sample with the stiffness \(\omega^2(1 + a_z/g)\). Its size: \(M_x\omega^2/(\beta_hb) = 2.529\times335.5/(1.241\times5) = 136.8\ \mathrm{A/m}\), so a swing of 5 mm while the glass is lifted at 10 m/s² asks for 0.70 A. Section 11.4 showed that the heave cannot pump this swing; (49) only keeps the swing's stiffness at \(\omega^2\) through a jolt.
The suspension's own regulator. The knees are the active force \(F_a\). Its regulator works on the body and the wheel about their resting state, with four deviations \(\mathbf e = (z_s, v_b, v_w, d_t)\): the spring's stroke \(z_s\) beyond its static length, the body's and the wheel's vertical speeds, and the tyre's compression \(d_t\) beyond its static value. With the road's vertical speed left out as an unknown disturbance, Newton's second law for body and wheel gives
\[ M_s\dot v_b = -k_sz_s - c_s\,(v_b - v_w) + F_a, \quad m_w\dot v_w = k_sz_s + c_s\,(v_b - v_w) - F_a + k_td_t - c_tv_w, \quad \dot z_s = v_b - v_w, \quad \dot d_t = -v_w , \tag{50} \]which we write \(\dot{\mathbf e} = A_s\mathbf e + B_sF_a\). The cost weighs the glass's vertical acceleration \(a_z = (-k_sz_s - c_s(v_b - v_w) + F_a)/M_s\), the stroke, the tyre's compression and the force, each by Bryson's rule:
\[ J_s = \int_0^\infty\Big(\frac{a_z^2}{a_\text{m}^2} + \frac{z_s^2}{z_\text{m}^2} + \frac{d_t^2}{d_\text{m}^2} + \frac{F_a^2}{F_\text{m}^2}\Big)\,\mathrm dt , \tag{51} \]with \(a_\text{m} = 0.5\ \mathrm{m/s^2}\), \(z_\text{m} = 10\) mm, \(d_\text{m} = 0.2\) mm and \(F_\text{m} = 40\) N. The tyre is weighed hardest because its static compression is only 1.1 mm: a bounce of the wheel of that size would unload it and leave the motor without grip. Since \(a_z\) contains \(F_a\), its square mixes state and force, and the integrand has the form \(\mathbf e^{\mathsf T}Q_s\mathbf e + 2\,\mathbf e^{\mathsf T}Y_sF_a + R_sF_a^2\), with \(Y_s\) the cross term. Completing the square in \(F_a\), the integrand is \(R_s\,(F_a + R_s^{-1}Y_s^{\mathsf T}\mathbf e)^2 + \mathbf e^{\mathsf T}(Q_s - Y_sR_s^{-1}Y_s^{\mathsf T})\,\mathbf e\): an ordinary LQR in the shifted force \(F_a + R_s^{-1}Y_s^{\mathsf T}\mathbf e\). Solving it and shifting back gives
\[ F_a = -K_s\mathbf e, \qquad K_s = R_s^{-1}\big(B_s^{\mathsf T}X_s + Y_s^{\mathsf T}\big), \qquad 0 = A_s^{\mathsf T}X_s + X_sA_s + Q_s - \big(B_s^{\mathsf T}X_s + Y_s^{\mathsf T}\big)^{\mathsf T}R_s^{-1}\big(B_s^{\mathsf T}X_s + Y_s^{\mathsf T}\big) . \tag{52} \]For the load the rides start with, \(M_s = 1.954\) kg, (52) gives the gains \(−501.22\ \mathrm{N/m}\), \(11.92\ \mathrm{N\,s/m}\), \(−6.34\ \mathrm{N\,s/m}\) and \(630.00\ \mathrm{N/m}\) on \(z_s\), \(v_b\), \(v_w\) and \(d_t\). The first says the most: the force \(-K_{s1}z_s\) works against the spring's \(-k_sz_s\), cancelling 84 % of it, so that the glass rides on an effective spring of 99 N/m. The last says how the tyre is kept loaded: when the tyre unloads, \(d_t \lt 0\), the force \(-K_{s4}d_t\) is positive and pushes the wheel down onto the road. The body's pair of eigenvalues moves from \(−1.93 \pm 17.17j\ \mathrm{s^{-1}}\) (2.75 Hz, damping ratio 0.11) to \(−4.93 \pm 4.98j\ \mathrm{s^{-1}}\) (1.12 Hz, 0.70); the wheel's hop on its tyre stays at 41.7 Hz, its damping ratio rising from 0.08 to 0.12.
Joint control is thus, on the motor, the slosh LQR of 12.6 acting on the estimate of 12.7 plus the cancellation (49), and, on the suspension, the force (52), clipped to \(\pm F_\text{max}\) and delivered with the lag \(\tau_u\). It is one design in the following sense. On a level road with the stout still, the linear model splits into two blocks that do not touch: the cart's speed with the swing, driven by the current, and the body with the wheel, driven by \(F_a\). For the sum of the costs (42) and (51) the Riccati solution splits the same way, and the one regulator is the pair of regulators. They meet only through (49) and the shared reading of \(a_z\).
12.9Every limit and every clock
Table 7 gathers every limit and every clock that the controllers above work under, with where each acts.
| What | Value | How it acts |
|---|---|---|
| drive current | \(\pm3\) A | the command is clipped before the lag (29) |
| supply | 12 V; 5 V per m/s through 2 Ω | at 1.5 m/s at most 2.25 A forward |
| current lag | \(\tau_i = 2\) ms | (29), exact over each sub-step |
| tyre grip | \(\mu_gN\), \(\mu_g = 0.8\) | the motor's push clipped to \(\pm\mu_gN\); nothing in the air |
| active force | \(\pm40\) N, lag \(\tau_u = 5\) ms | the command clipped, then the lag |
| integral \(x_e\) | only while \(|i_\text{cmd}| \lt 3\) A | against windup, in (37) and in the regulators |
| controller sample | \(T_s = 1\) ms | every command held between samples |
| probes | once per fluid step | used at the first sample after the step |
| fluid step | at most 2 ms | section 8.6 |
| cart sub-steps | 0.1 ms | the cart's mechanics and both lags |
The controllers are the site's own (open)
The controllers were first written for an earlier version of this figure that ran a simpler stout model in the browser (removed from the site on 18 November 2026; its controller code stays in the repository). The controllers on the graphics card are a line-by-line port of those controllers (public/scripts/stout-cart.js: Cart.sample, Cart.lqrGains, Cart.suspGains, Observer) into tools/fig12/kaggle/stout_jax.py (class Cart, slosh_lqr, susp_lqr, observer_design). A check (notes/fig12/handoff-jax/portcheck.txt) runs both on the kerb with a rigid load and one and the same probe signal and compares them at every fluid step for the whole ride: the speed loop, the preview and the skyhook agree to 4 × 10⁻¹³ A in the commanded current, the slosh LQR and joint control to 6 × 10⁻⁸ A, because the site solves the Riccati equation by letting it flow to its steady state while the port solves it directly. The gains printed in this note are computed by the port's own functions, and the suspension's agree with those stored with the rides to 8 × 10⁻⁶.
12.10What the controlled rides show
Beside the surface, the head and the cart, each controlled ride stores, for every picture, the current command, the active force, the filter's estimate \(\hat q\), the probes' reading \(y_q\) and the cancellation current \(i_\text{par}\). Table 8 sets each controlled ride beside the speed loop on the same road; the lean and the tilt are read as in section 11.1, and the table under the readings on the page shows the same numbers.
| Road | Controller | Tilt | Lean | Foam | Stout | Current | At 3 A | Active force |
|---|---|---|---|---|---|---|---|---|
| five 20 mm bumps, 1.0 m/s | speed held only | 13.6 mm | 13.9 mm | 0.01 mL | 0 | 2.40 A | 0 | — |
| joint control | 1.00 mm | 1.03 mm | 0 | 0 | 1.72 A | 0 | 7.1 N | |
| one 25 mm bump, 1.0 m/s | speed held only | 8.0 mm | 8.9 mm | 0 | 0 | 2.00 A | 0 | — |
| joint control | 1.03 mm | 0.88 mm | 0 | 0 | 1.65 A | 0 | 7.9 N | |
| kerb, 1.5 m/s | speed held only | 22.2 mm | 24.3 mm | 2.44 mL | 0 | 2.98 A | 6 | — |
| road preview | 23.0 mm | 23.9 mm | 2.51 mL | 0 | 2.95 A | 6 | — | |
| slosh LQR | 20.8 mm | 21.8 mm | 1.63 mL | 0 | 2.97 A | 6 | — | |
| joint control | 24.6 mm | 25.4 mm | 2.07 mL | 0 | 2.93 A | 5 | 11.5 N |
The gentle roads. Over the five bumps joint control leaves a lean of 1.03 mm, against 13.9 mm with the speed held only; over the single bump 0.88 mm, against 8.9 mm. That is about 13 and 10 times less. It does so with less current than the speed loop, 1.72 and 1.65 A against 2.40 and 2.00 A, never near the limit, with an active force of at most 7.1 and 7.9 N and a cancellation current of at most 0.016 A. The filter followed the probes to 0.04 and 0.03 mm root mean square on the two roads, where the probe signal itself had a root mean square of 0.19 and 0.15 mm. No stored ride separates the parts of joint control (there is no ride with the slosh LQR alone on these roads), so the following is an inference, not a measurement. The cancellation current stayed below 0.016 A, too small to matter, and section 11.4 showed that the heave cannot pump the swing. Most of the gain is therefore likely the motor's regulator, which pushes against each surge as it begins; but the suspension also changes the tyre's load \(N\), and with it the road's push \(-Nz_a'\) along the road, so it may share in the gain.
The kerb. Here the controllers change little, as section 12.3 said they must. Every one of them asked for the full current through the jolt, the command at or beyond 3 A in 5 or 6 stored pictures, about 167 to 200 ms, and the first forward surge is about as large under each (Figure 6). Read from the stored lean before 0.8 s, that first peak is 21.2 mm (preview), 21.8 mm (slosh LQR) and 25.4 mm (joint) against 22.2 mm with the speed held; these are not columns of Table 8, whose largest lean may come from the swing back about 0.2 s later. The controllers differ in that swing back: about 24 and 24 mm with the speed held and the preview, 12 mm under the slosh LQR and 17 mm under joint control. The spill changes more. The foam lost 1.63 mL under the slosh LQR and 2.07 mL under joint control, against 2.44 mL with the speed held, and 2.51 mL under the preview, which does not help here. No stout left the glass in any of the four. After the jolt the lean under the slosh LQR and joint control settles at about 1.8 and 2.5 mm on average and does not return to zero within the stored time, while the cart's speed is already back at 1.5 m/s; the head can hold a lean of about 1.0 mm (6.6), the same order, and we have not traced the rest. Joint control leaves the largest first surge of all: we have not separated the causes, but its cancellation current reached 0.904 A in the jolt, where the one-mode model it relies on does not hold. Through the ride the filter's estimate differed from the probes by 0.67 mm (joint) and 0.58 mm (slosh LQR) in root mean square, where the probe signal had 2.66 and 2.02 mm: a one-mode model does not describe a stout whose wheel is thrown off the road. The preview runs no filter.
On roads the motor can answer, joint control keeps the surface's lean near one millimetre where holding the speed alone leaves 8.9 to 13.9 mm, and it uses less current. On a kerb that pushes back far harder than the motor's 11.25 N at that speed, no controller holds the surface: foam goes over the rim under all four, the slosh LQR and joint control only take the edge off the spill (1.63 and 2.07 mL of foam instead of 2.44 mL), and the road preview does not. No ride spills stout.
13Limits, and the next model
Every model leaves things out. The useful question is which of them would change what we see, and by how much.
The grid and the particles. The 1.5 mm grid and its million particles carry the swing a little slowly, 2.6 % below the theory for the bare stout, and add a damping of their own, \(\zeta \approx 0.0105\), about twice the stout's own friction without a head (section 11.2). With the head this is a small part of the damping; without it, the computed swing dies away too fast. The thin layers at the glass and under the surface are below the grid and enter as stresses derived from the laminar theory, at one frequency.
The head. The head moves only up and down with the stout under it; it does not flow sideways over the surface, and its thickness changes only where it breaks off. Its liquid fraction is an estimate, and its yield stress depends on it steeply (section 6.1). Its flow law (20) is used outside the range of gas fractions it was fitted to, its wall friction (21) at a liquid fraction a little beyond Cantat's data, and its breaking rule (23) is a simple balance that lets it break early. It does not drain (that takes tens of minutes), leaves no film on the glass, and its own vertical momentum is not in the push on the cart (section 7.3). The surface properties were measured at 20 °C and used at 6 °C.
Small swings and a guided cart. The theory of sections 4 to 6 assumes swings small against the wavelength, \(kq \ll 1\); in the rides the lean reaches \(kq \approx 0.6\), so the one-mode numbers are estimates there, while the computation itself keeps the full non-linear flow. The undamped bare-stout swing of 45 mm in Table 4 would be far outside that range (\(kq \approx 2\)), which is one more reason to read it only as an upper bound. The model also leaves out surface tension (section 3.3) and keeps the cart's body from pitching or rolling.
Drops. A drop is a single particle of 0.43 mm³ with no surface tension of its own, so drops neither merge nor break. On these rides no stout leaves the glass; at most 11 particles at a time are counted as drops above the surface.
The controllers. The regulator and the filter see the stout as one linear mode, fitted to a free swing that the head damps by a yield stress and by a friction that grows less than linearly with speed, which no single linear mode describes exactly. They do not know the road's push in advance except through the preview, which assumes the static load of the tyre, and none of them plans further ahead than one current lag.
The next model. The plainest lesson concerns the hardware: against a kerb at 1.5 m/s the motor has about 0.14 of the push the road gives, and in the air it has none. A cart meant to carry a full pint over kerbs needs a stronger drive or a softer approach to the kerb (slowing before it), and a controller that plans the motor's whole push over the stretch of road it can see ahead (a model-predictive controller) instead of one lag ahead. For the stout, the next version should let the head slide sideways over the stout, give the regulator and the filter a model of the swing with the head's yield stress in it, and refine the grid near the surface to reduce the method's own damping.
1. Show that the second part of the wall stress (16), \(-\rho\sqrt{\nu\omega/2}\,U\sin\omega t\), does no work over one swing, and that the first part removes \(\tfrac12\rho\sqrt{\nu\omega/2}\,U^2\) per unit area per second on average.
2. With the stout's own damping ratio \(\zeta = 0.0055\) (without the head) and \(\omega_{11} = 21.49\ \mathrm{rad/s}\), find the number of swings after which the amplitude of the swing without the head has halved, and the time after which it has fallen to a tenth. (Answers: 20.1 swings; 19.5 s.)
3. By (17), \(\zeta_\text{wall}\) scales as \(R^{-3/4}\) in a deep glass. For a glass twice as wide, filled as deep, and counting the wall's damping alone, find how much longer its swing takes to fall by the factor \(e\). Mind that \(\omega_{11}\) changes too. (Answer: \(1/(\zeta\omega_{11}) \propto R^{5/4}\), 2.38 times longer.)
4. Derive \(h_\text{eff}\), (22), from a sliding speed \(v_se^{-kz'}\) and a wall stress proportional to the sliding speed to the power 2/3. Find \(h_\text{eff}\) for a head much thicker than \(1/k\).
5. Find the outward acceleration at which the breaking rule (23) lets a head stand only 1 mm above the rim, at rest otherwise. (Answer: about 15 m/s².)
6. Show that the sum \(\sum_n\mathbf F_n\Delta t_n\) of section 7.3 telescopes to \(-\mathbf P_N\). The cart, however, uses \(\mathbf F_{n-1}\) during step \(n\). Write the impulse it actually receives and show how it differs from the booked one when the steps are not all equal.
7. From (13), for the half-sine push \(a = a_p\sin(\pi t'/T_p)\) lasting \(T_p = \pi/\omega_{11}\), half a period, show that \(\int a\,e^{j\omega_{11}t'}\,\mathrm dt' = j\pi a_p/(2\omega_{11})\), so that the swing left behind is \(q_\text{max} = \pi\beta a_p/(2\omega_{11}^2)\). With \(a_p = 1.0\ \mathrm{m/s^2}\) this is 5.2 mm.
8. From the \((4,4)\) entry of the Riccati equation (43), show that the slosh LQR's gain on the integral \(x_e\) is \(|K_4| = I_\text{max}/x_\text{e,m}\), whatever \(\omega\), \(\zeta\) and \(\beta_h\). Which property of the matrix \(A\) of (41) does the proof use?
9. In (36) put \(\Omega = 2\omega\) and look for \(q = c(t)\cos\omega t + s(t)\sin\omega t\) with \(c\) and \(s\) changing slowly. Averaging over one swing, show that \(c\) and \(s\) grow or decay as \(e^{\pm\varepsilon\omega t/4 - \zeta\omega t}\), so that the swing grows when \(\varepsilon \gt 4\zeta\).
10. Derive the cancellation current (49), and evaluate it for a swing of 8 mm at the wall while the glass is lifted at 12 m/s². (Answer: 1.34 A.)
11. The preview (39) treats the current lag \(1/(1 + j\omega\tau_i)\) as the delay \(e^{-j\omega\tau_i}\). At the swing's frequency, 2.915 Hz, compare the phase of the two, and give the magnitude of the first. (Answers: \(−2.0980^\circ\) against \(−2.0990^\circ\); 0.99933.)
12. A swing of damping ratio \(\zeta\) is kicked from rest to the rate \(V\). Show that its first peak is \((V/\omega)\exp\big(-\zeta\arctan(\sqrt{1 - \zeta^2}/\zeta)/\sqrt{1 - \zeta^2}\big)\), and evaluate the exponential for the pint with its head, \(\zeta = 0.425\), and without it, \(\zeta = 0.0055\). (Answers: 0.588; 0.991.)
14Sources
- dimensions.com, “Irish Imperial Pint Glass”: dimensioned elevation and section of the tulip pint (stated height 149 mm, diameter 76 mm). The model traces the inner wall of the section and scales the drawing to the size retailers give for the Guinness imperial pint, 160 mm tall and 85 mm wide (
tools/fig12/glass_profile.py). - E. S. Benilov, C. P. Cummins and W. T. Lee, “Why do bubbles in Guinness sink?”, arXiv:1205.5233 (2012), Am. J. Phys. 81, 88 (2013): p. 1, section II, density and viscosity at 6 °C; p. 2, the settling time.
- T. Watamura, F. Iwatsubo, K. Sugiyama, K. Yamamoto, Y. Yotsumoto and T. Shiono, “Bubble cascade in Guinness beer is caused by gravity current instability”, Sci. Rep. 9, 5718 (2019): p. 2, density, viscosity and mean bubble diameter; Supplementary Information, Appendix A and Table S1.
- KegWorks, “How to pour a Guinness the right way” (26 February 2019): the 18–20 mm specification and three measured heads.
- A. R. Völp and N. Willenbacher, “Shear modulus and yield stress of foams: contribution of interfacial elasticity”, Soft Matter 17, 3937 (2021), open copy at KITopen: Table 1 (Guinness, degassed, 20 °C), Table 2 (44.2 and 18.7 mN/m), the prefactors \(a_d = 1\), \(k_d = 0.25\) and \(\Phi_c = 0.635\).
- R. P. Feynman, R. B. Leighton and M. Sands, The Feynman Lectures on Physics, vol. II, ch. 40, “The flow of dry water”, section 40-2 (vorticity that starts at zero stays zero), and ch. 41, “The flow of wet water”, section 41-2 (the viscous force per unit volume).
- NIST Digital Library of Mathematical Functions, §10.6 (recurrence relations of Bessel functions) and §10.22: eq. (10.22.5), the integral of \(tJ_\nu(at)^2\); eq. (10.22.38), orthogonality of \(J_\nu(\alpha_\ell t)\) over the zeros of \(aJ_\nu(x) + bxJ_\nu'(x)\), here with \(a = 0\).
- A. Bongarzone and F. Gallaire, “Numerical estimate of the viscous damping of capillary-gravity waves”, arXiv:2207.06907 (2022): eq. (17), the laminar damping of bulk, floor and side wall, p. 4.
- D. G. Stephens, H. W. Leonard and T. W. Perry, “Investigation of the damping of liquids in right-circular cylindrical tanks, including the effects of a time-variant liquid depth”, NASA TN D-1367 (1962): summary; eq. (1), the damping factor; eqs. (2)–(3), \(K = 3.52\), pp. 6–7; eq. (13), \(K = 5.23\), p. 13.
- M. Silveira and H. N. Abramson, “Damping of liquid motions and lateral sloshing”, chapter 4 of H. N. Abramson (ed.), The Dynamic Behavior of Liquids in Moving Containers, NASA SP-106 (1966): eqs. (4.3)–(4.6) and (4.10a)–(4.10b), pp. 106–111.
- S. Tcholakova, N. D. Denkov, K. Golemanov, K. P. Ananthapadmanabhan and A. Lips, “Theoretical model of viscous friction inside steadily sheared foams and concentrated emulsions”, Phys. Rev. E 78, 011405 (2008): eq. (1), eqs. (47)–(49) and their range, eq. (54).
- I. Cantat, “Liquid meniscus friction on a wet plate: bubbles, lamellae, and foams”, Phys. Fluids 25, 031303 (2013): eqs. (18) and (49), and the fitted \(Z\) and \(l/r_m\) of Fig. 14, p. 16.
- A. Sauret, F. Boulogne, J. Cappello, E. Dressaire and H. A. Stone, “Damping of liquid sloshing by foams”, Phys. Fluids 27, 022103 (2015): p. 7, the frequency with foam; pp. 8 and 10, the decay of the bubbles' speed with height.
- C. Jiang, C. Schroeder, A. Selle, J. Teran and A. Stomakhin, “The affine particle-in-cell method”, ACM Trans. Graph. 34, 51 (2015): abstract; section 5.3; section 6, eqs. (12)–(14), the transfers on a staggered grid.
- C. Batty, F. Bertails and R. Bridson, “A fast variational framework for accurate solid-fluid coupling”, ACM Trans. Graph. 26, 100 (2007): section 2.1, eq. (7), the face weights, the exact hydrostatic solution and the ghost-fluid surface condition.
- Y. Zhu and R. Bridson, “Animating sand as a fluid”, ACM Trans. Graph. 24, 965 (2005): section 5, eqs. (6)–(10).
- K. J. Åström and R. M. Murray, Feedback Systems: An Introduction for Scientists and Engineers, 2nd ed., Princeton University Press (2021); read in the online edition, version 3.1.5 of 24 July 2020: section 7.4, integral action; section 7.5, eqs. (7.29)–(7.33), the linear quadratic regulator; Exercise 7.16, Bryson's rule; sections 8.3 and 8.4, the separation principle and Theorem 8.4, eq. (8.27), the discrete Kalman filter; section 11.1, PI control; section 11.4, integral windup; section 12.4, eq. (12.13), feedforward from a measured disturbance.
- R. E. Kalman, “A new approach to linear filtering and prediction problems”, Trans. ASME J. Basic Eng. 82, 35–45 (1960), doi:10.1115/1.3662552: Theorem 3, eqs. (21) and (28)–(30), the recursive estimate and its error covariance; eq. (32).
Sources 1, 5, 6, 7, 9, 14, 15, 16, 17 and 18 were read for this note, or its earlier version, in the full texts at the links given; in source 5 the equations are printed as images and were read from the page images. Sources 2, 3, 4, 8, 10, 11, 12 and 13 were read in extracts of their full texts kept with the project's research notes. The block-exponential identity (46) is derived in section 12.7 rather than cited. Every number of this note that is not quoted from a source is printed from the stored rides and the model's code by tools/fig12/kaggle/note_numbers.py.