Appendix
This page gathers what the chapters said in passing: how to read the numbers on screen, where this simulation differs from real water, and the works the engine and the chapters rest on.
Units and dimensionless numbers
The simulation’s values in this book have no units. The book measures lengths in heights of the experiment window, which is 16:9, so it is about 1.78 wide. Time is the same as seconds on screen. Every experiment draws 60 frames a second, and every fluid experiment moves its simulation on by 1/60 of a unit of time each frame. Most take one step of 1/60; only the experiments of chapters 0 and 2 take two steps of 1/120. A speed of 1 crosses the height of the experiment window in a second. The engine sets the density to 1. Its pressure stage takes straight off the velocity, so the pressure on screen reads as a value per unit mass, .
To compare numbers without units with real flows, use dimensionless numbers. Pick a typical speed and a typical length for a flow, and the Reynolds number compares the size of the advection term with the size of the viscosity term (chapter 5). Two flows of the same shape at the same Re are the same flow, whatever their size. The engine’s setReynolds works out from the and an experiment sets. Chapter 5’s cylinder ladder uses it; the other experiments set directly. Two more dimensionless numbers appear in the chapters: the Strouhal number , which ties how often eddies break away to the size and speed (chapter 5, 0.177 at Re 150), and the lift coefficient , the lift divided by the oncoming flow’s and the chord (chapter 6, 0.49 at 8°).
The table gives the typical speed and length, the viscosity and the Reynolds number of the seven experiments that have viscosity. The values come straight from the experiments’ definitions.
| Experiment | U | L | ν | Re |
|---|---|---|---|---|
| Ch. 4, a layer spreads | 0.4 | 0.04 | 0.00001, 0.001 | 1600, 16 |
| Ch. 4, a sliding plate | 0.5 | 0.9 | 0.03 | 15 |
| Ch. 4, flow in a channel | 0.2 | 1 | 0.02, 0.04 | 10, 5 |
| Ch. 5, the cylinder ladder | 0.5 | 0.1 | 0.05 – 0.00005 | 1, 40, 150, 1000 |
| Ch. 5, two sliding layers | 0.2 | 0.03 | 0.00001, 0.001 | 600, 6 |
| Ch. 6, the full lab | 0.3 | 0.16 | 0.0001 – 0.002 | 480 – 24 |
| Ch. 6, the wing | 0.5 | 0.4 | 0.0002 | 1000 |
Here is how each experiment picks and . The spreading layer: the first speed at the middle of the layer and the layer’s first width (its standard deviation ). The sliding plate: the plate’s speed and the gap below it. The channel: the speed the water comes in at (the channel’s mean speed) and the channel’s width. The cylinder ladder and the full lab: the speed the water comes in at and the cylinder’s diameter. The two sliding layers: half the difference of their speeds and the half-thickness of the boundary between them. The wing: the speed the water comes in at and the chord. Chapter 0’s lab starts at zero viscosity, and its Viscosity ν slider goes up to 0.002. Chapter 2’s water without its projection, chapter 3’s two experiments and chapter 5’s vortex pair have no viscosity, so they have no Reynolds number.
On the finest grid, 480×270, a cell is 1/270 on a side. On a slow device the quality governor takes the grid down to 240×135. Chapter 3’s pressure sweeps, the three experiments of chapter 4 and chapter 5’s cylinder ladder hold their grid at the coarsest level on every device (242×136 for chapter 4’s two experiments whose left and right edges join, 240×135 for the rest). For chapter 3, that makes one sweep the same picture on every device; for the others, it lets the solve of a large viscosity finish within its fixed number of sweeps.
Since flows of the same shape at the same Re are the same, you can read a flow on screen at a real size. Water at 20 °C has a viscosity of 1.0016 mPa·s and a density of 998.21 kg/m³, so its is about (NIST, in the references below). Read chapter 6’s wing (Re 1000) as a wing with a 4 cm chord in water, and the water moves at : 2.5 cm a second. Read chapter 5’s Re 150 as a cylinder 1 cm across, and the water moves at 1.5 cm a second. Both are very slow water. The flow round real wings and posts usually has a far larger Re.
The limits of this simulation
The engine aims to show flows that are qualitatively right; it is not precise engineering software (computational fluid dynamics, or CFD). It passes four numerical checks: the divergence that remains after the projection, the parabola in a channel, the spread of a diffusing blob of velocity, and the Strouhal number of the vortex street behind a cylinder. The chapters’ side notes said where else it differs from real water, and this section gathers them. The numbers are readings on the author’s computer.
It is two-dimensional. Every fluid experiment is a flow in a plane, with no depth. A real cylinder’s wake at chapter 5’s Re 1000 is three-dimensional turbulence; the coarse two-dimensional picture is not turbulence (chapter 5). Chapter 6’s wing is one section of an endlessly long wing, so no vortices roll off its tips (chapter 6).
The grid depends on the device. The finest grid is 480×270. The quality governor averages the graphics hardware’s time per frame over the last second: above 12 ms it takes the grid one level coarser, and after more than 5 s below 6 ms one level finer. If even the coarsest grid cannot draw 29.5 frames a second, the governor suggests watching the recording instead. Phones start on the coarsest grid. On a coarse grid small swirls are blunter, and chapter 6’s chord spans 54 cells instead of the desktop’s 108 (chapter 6).
Swirls weaken even at zero viscosity. A two-dimensional flow without viscosity should keep its kinetic energy. This engine’s flows lose some. In chapter 0’s lab (a closed box, 480×270, two steps of 1/120, zero viscosity), with no cylinder in the box, the script’s first stroke loses 24 % of its kinetic energy in 2 s. There are two main causes, and changing the step and the grid one at a time tells them apart.
One is the error that comes from splitting each step into stages. The advection stage carries each velocity along the flow without turning it. So inside a swirl, the velocity it carries in leans slightly outward at the end of a step, and when the pressure stage removes that outward part, some of the spin goes with it (chapter 5). This error grows with the length of the step and with the square of how fast the water spins, and hardly depends on the grid. For the stroke above, a step of 1/240 cut the loss to 17 %, and a step of 1/960 to 6 %, under a third of the 24 %. The same stroke at half the speed lost only 5 %. Chapter 5 measured this error with a single vortex sitting on its own: the strength at its middle, at first, fell as and halved in 9 seconds. In chapter 6’s lab, with steps of 1/60, the strongest point of a stirred swirl kept only 37 % after 2 s. That strongest point is a single cell’s reading, so it shifts with the grid (chapter 6); this section tells the two causes apart by energy instead.
The other is smearing: the advection stage interpolates between cells, and that blurs the flow a little at every step. Its other name is numerical diffusion. It is smaller on a finer grid. For the stroke above, a 960×540 grid lost 22 % and a 240×135 grid 26 %. Doubling the grid in each direction cuts the loss by less than a quarter as much as halving the step does. What a step of 1/960 still loses holds more than smearing: it also holds the loss at the walls and the error the pressure solve leaves. So in chapter 0’s lab, most of the weakening is the splitting error, and smearing adds a small share. Stir more gently and the splitting error shrinks faster than smearing does, so the grid’s part grows. At half the speed the stroke loses 6 % on 240×135 against 5 % on 480×270: the coarse grid’s extra loss is about 20 % of the loss on 480×270, against about 9 % at full speed. Both causes also go into the small difference in chapter 5’s Strouhal number; nothing in this book measured their shares apart.
The pressure solve leaves a little divergence. The engine solves for the pressure with a fixed amount of work. Its default solve is two multigrid V-cycles. In the flow with a vortex street behind a cylinder, the divergence that remains after the projection, , was , against the engine check’s limit of . Just after a cylinder dropped into the flow, the divergence rose to , and it fell back under the limit within 6 steps. In chapter 2 the divergence that remains after a stir is about a thousandth of what it is with the projection off (chapter 2), and chapter 3’s Jacobi sweeps show the solve one sweep at a time (chapter 3).
The engine counts obstacles in cells. It only knows, cell by cell, whether a cell is solid. It draws circles and rectangles smooth on screen, but the flow sees a staircase of cells. Chapter 4’s sliding plate sits at a height of 0.9 on screen, but the flow feels it at the middle of its row of cells, 0.9007 (chapter 4). Chapter 6’s wing and the lines you draw show on screen as cells too; the wing is 6.5 cells thick on a desktop (chapter 6). The wing’s shape takes the thickness formula of NACA Report 460 and changes only its last coefficient, −0.1036 instead of −0.1015, to close the trailing edge to a point. The report’s own formula leaves the trailing edge open by about 2 % of the thickness.
There are five kinds of edge. Walls the water sticks to (the boxes of chapters 0 and 2 and of chapter 3’s sweeps, chapter 4’s plate and channel), slippery walls (chapter 3’s pump channel, the top and bottom of chapters 5 and 6), an inlet at a set speed with an outlet where the velocity stops changing (chapter 4’s channel, chapter 5’s ladder, chapter 6’s two experiments), and ends that join (chapter 3’s pump channel, chapter 4’s layer and plate, chapter 5’s pair and two layers). A slippery wall grows no slow layer, and water that leaves through a joined end comes back in at the other (chapter 5). How much of a channel an obstacle blocks changes the flow too. Chapter 5’s cylinder blocks a tenth of the channel. In the engine’s own check, the Strouhal number behind a cylinder at Re 100 came out 9 % above what experiments on real flows find (chapter 5), and the nearby, slippery walls seem to explain it. The nearby walls also go into why chapter 6’s lift coefficient of 0.49 is smaller than thin-airfoil theory’s 0.88 (chapter 6).
The Reynolds numbers are low. Of the experiments with a Reynolds number, those with the advection term on reach at most Re 1000 (the table’s 1600 is chapter 4’s spreading layer, which runs the viscosity term alone). The flow round real wings and bridge piers usually has a far larger Re. At a low Re the slow water next to a surface forms a thick layer, as on chapter 6’s wing (chapter 6).
The ink is only a marker. The ink does not change the flow (chapter 0), and the engine does not let it spread on its own. The stage that carries it interpolates between cells too, so its edges blur a little over time. Each cell just carries an amount of ink along, so ink never thickens where the flow converges; that is why chapter 2 shows the crowding with particles (chapter 2).
Only the same computer gives the same picture. The engine uses fixed steps, fixed numbers of sweeps and seeded random numbers, so on the same computer the same input gives the same frames. Other graphics hardware can differ slightly through floating-point rounding. A recording, too, comes out as the same file again only in the same browser version.
You cannot experiment with a recording. A browser without WebGPU shows a recording from the author’s computer, with its captions, instead of a fluid experiment. In a recording you cannot stir, change a value or draw, even when the script’s last caption invites you to.
References
The works behind the engine’s methods and the chapters. Each entry’s details match its DOI record, the NASA Technical Reports Server, or the NASA or NIST page it links to.
- Francis H. Harlow, J. Eddie Welch. “Numerical Calculation of Time-Dependent Viscous Incompressible Flow of Fluid with Free Surface.” The Physics of Fluids 8(12), 2182–2189, 1965. doi:10.1063/1.1761178. The staggered (MAC) grid: velocities on the faces of a cell, pressure at its centre.
- Jos Stam. “Stable Fluids.” Proceedings of the 26th Annual Conference on Computer Graphics and Interactive Techniques (SIGGRAPH ‘99), 121–128, ACM Press, 1999. doi:10.1145/311535.311548. Splitting a step into forces, advection, diffusion and pressure projection, and advection by tracing back.
- Andrew Selle, Ronald Fedkiw, ByungMoon Kim, Yingjie Liu, Jarek Rossignac. “An Unconditionally Stable MacCormack Method.” Journal of Scientific Computing 35(2–3), 350–371, 2008. doi:10.1007/s10915-007-9166-4. The advection stage’s MacCormack correction and its limiter.
- William L. Briggs, Van Emden Henson, Steve F. McCormick. A Multigrid Tutorial, 2nd ed. Society for Industrial and Applied Mathematics, 2000. doi:10.1137/1.9780898719505. The pressure’s multigrid V-cycles and red-black Gauss–Seidel sweeps.
- Eastman N. Jacobs, Kenneth E. Ward, Robert M. Pinkerton. “The Characteristics of 78 Related Airfoil Sections from Tests in the Variable-Density Wind Tunnel.” NACA Report No. 460, 1933. NASA Technical Reports Server 19930091108. The naming of NACA four-digit sections (camber, its position, thickness) and their thickness formula: chapter 6’s wing.
- NASA Glenn Research Center. “Equal Transit Theory Interactive.” Beginners Guide to Aeronautics. www1.grc.nasa.gov/beginners-guide-to-aeronautics/foilw1/. Chapter 6’s “One misconception” (the equal transit time theory).
- Eric W. Lemmon, Ian H. Bell, Marcia L. Huber, Mark O. McLinden. “Thermophysical Properties of Fluid Systems.” NIST Chemistry WebBook, NIST Standard Reference Database Number 69, P. J. Linstrom and W. G. Mallard, eds. National Institute of Standards and Technology. doi:10.18434/T4D303. Water at 20 °C and 0.101325 MPa: this appendix’s viscosity and density of water. The viscosity comes from the formulation of M. L. Huber et al., “New International Formulation for the Viscosity of H₂O,” Journal of Physical and Chemical Reference Data 38(2), 101–125, 2009, doi:10.1063/1.3088050.