Module 10 built the parts. 10.7 Semi-Lagrangian Advection carried quantities along characteristics, 10.4 Implicit Methods & Crank–Nicolson made diffusion stable at any step, 10.8 Elliptic Solvers: Jacobi, Gauss–Seidel & SOR and 10.11 2D Grids, Boundary Conditions & Staggered (MAC) Grids supplied the pressure matrix and its wall rows, and 11.11 Stam's Stable Fluids, Step by Step put them in order. Modules 11 and 12 said what to look for: drag, the shedding street, lift. This capstone assembles one solver, a tunnel units long and tall, puts a cylinder in it and then an airfoil, and reads off what a wind tunnel gives. Getting numbers is the easy half. The skill is knowing how far to believe them, so we set each number beside a known value and ask where the gap comes from.
Transcript
- Every piece of the tunnel is a lesson we have already solved. Advection is semi-Lagrangian, from lesson ten point seven. Diffusion is one implicit solve per component, from ten point four. The projection is the Poisson solve of ten point eight, on the staggered grid of ten point eleven, with the wall, outlet and obstacle rows. One time step is advect, diffuse, project. In our units the inflow speed and the cylinder diameter are 1. The tunnel is 16 by 6 on 128 by 48 cells, so h is 1 over 8. At Reynolds number 100 the viscosity is 0.01, the Courant number is 0.4 and the diffusion number is 0.032.
- Air enters on the left at speed 1, leaves on the right at pressure 0, and the top and bottom walls are no-slip. The cylinder is a mask of solid cells: a cell is solid if its centre lies inside the body. Every face that touches a solid cell is blocked, and the pressure row drops that neighbour. At 8 cells across the mask has 52 cells, an area of 0.8125 against pi over 4, which is 0.7854: 3.5 percent too big. The staircase is the first error to remember.
- Kick the cylinder gently and a vortex street grows. Run to t equal 100. Averaged over the last half, the drag coefficient is 1.8956 and the lift swings by plus or minus 0.0972. Between upward zero crossings of the lift, the last 4 periods average 5.869, which gives a Strouhal number of 0.1704. At t equal 100 the drag is 1.897: 1.651 from pressure and 0.246 from shear, so 87 percent is pressure.
- Now the honest comparison, with reference values from memory. The Strouhal number is about 0.165, and ours is 0.1704, about 3 percent high. The drag is about 1.3 to 1.4, and ours is 1.8956, about 40 percent high. The lift amplitude is near 0.3, and ours is about three times smaller. Part of the gap is the tunnel: with half the blockage, the drag falls to 1.5758, but the Strouhal number drops to 0.1416, 14 percent below the reference. Slip walls give 1.7114. The numerical errors are as large as the correction we are trying to make.
- Where does the error come from? Semi-Lagrangian interpolation smooths. In this lab a shift of 0.4 cells per step gives a numerical viscosity of 0.0375, almost four times the true 0.01. So the grid matters. On 64 by 24 cells, 4 across the cylinder, there is no street at all. On 96 by 36 the Strouhal number is 0.1596, on 128 by 48 it is 0.1704, and on 192 by 72 it is 0.1849. The lift amplitude grows by a factor of 80 while the drag barely moves.
- The pressure solver matters too. With the pressure warm-started from the last step, 5 sweeps leave a divergence of 1.053 times 10 to the minus 2, 20 leave 1.752 times 10 to the minus 3, and 40 leave 6.291 times 10 to the minus 4. The drag moves only 0.3 percent. Switch the warm start off and 20 sweeps leave a divergence of 0.2530. The drag falls to 1.2947 and the street disappears: the solver is now computing a different flow. On the finer 192 by 72 grid the same 40 sweeps leave 3.792 times 10 to the minus 3.
- Now the airfoil: a symmetric 12 percent section at Reynolds number 200 based on the chord. Nothing tells the solver a circulation. Lift is almost all pressure, rising with angle: 0.1303 at 3 degrees, 0.4088 at 6, 0.6363 at 10 and 0.9916 at 15, about 60 percent of 2 pi alpha. And it depends on the grid: at 10 degrees it is 0.4838, 0.6363 and 0.8266 on the three grids, still short of 1.0966. Take the trend and the mechanism, not the second digit.
- So what do we believe? The shedding rhythm to a few percent, with a grid dependence we measured. Not the drag: 40 percent high for the cylinder, two to three times too large for the airfoil. Not the cylinder's lift amplitude, 3 times too small. State the grid, step, solver and protocol behind every number. Upgrades exist, sharper interpolation, cut cells, multigrid, but none are built here. Next comes Module 13, which opens with feedback. The tunnel gives it a sensor: a controller would read the lift and turn the angle of attack to hold it, with the delay the flow's own response puts in the loop.
What we are building
Units are chosen so that , and the cylinder’s diameter is . The tunnel is on a grid, , so the cylinder is cells across (the blockage is ). At the viscosity is . With the Courant number is and the diffusion number is . Air enters on the left at , leaves on the right at , and the top and bottom walls are no-slip.
Every piece is something we have already solved:
- Advection: semi-Lagrangian (10.7 Semi-Lagrangian Advection): trace each velocity face back along the flow for and interpolate bilinearly.
- Diffusion: one implicit solve per component (10.4 Implicit Methods & Crank–Nicolson), a few red-black Gauss-Seidel sweeps of a diagonally dominant matrix.
- Projection: the Poisson solve of 10.8 Elliptic Solvers: Jacobi, Gauss–Seidel & SOR on the staggered stencils of 10.11 2D Grids, Boundary Conditions & Staggered (MAC) Grids.
- Boundaries: the wall, outlet and obstacle rows of 10.11 2D Grids, Boundary Conditions & Staggered (MAC) Grids and the ghost values of 11.11 Stam's Stable Fluids, Step by Step.
One time step
Advect. The air arriving at a face left from (with averaged from the four nearest faces). Take the old there, interpolated bilinearly, and do the same for .
Diffuse. Solve face by face: . The diagonal dominates, so four sweeps are plenty. A no-slip wall puts a ghost value behind the wall face, which is a neighbour of value zero; a slip wall drops the neighbour.
Project. Solve and subtract the gradient. The tilde marks the Chorin pressure , the quantity that appears in , so the physical pressure is . The obstacle is a mask of solid cells. Every face that touches a solid cell is blocked: its velocity is zero and the pressure row drops that neighbour. A fluid cell’s diagonal is the number of unblocked neighbours, plus in the last column for the outlet. Solid cells keep a dummy row. Because of the outlet this matrix is not singular, so the closed-box compatibility condition of 10.11 2D Grids, Boundary Conditions & Staggered (MAC) Grids does not bite. The sweeps start from the last step’s pressure, a warm start: the pressure changes little per step. That one line decides a lot, as we will see.
Reading drag and lift
The force on the body is the pressure pushing on its surface plus the shear dragging along it. On the staircase every fluid cell that touches a solid cell contributes away from the fluid, so the force is and the force follows by the same rule. For shear we use the tangential speed in that first fluid cell, a distance from the no-slip surface: a stress on a face of length gives . The coefficients are and per unit span, with for the cylinder and the chord for the airfoil, as in 11.5 Non-dimensionalization & the Reynolds Number.
Every number below follows one protocol. Run to ( steps, about six flow-through times ). Average over from to . Call over that window the lift amplitude. Take the Strouhal number from the last four periods between upward zero crossings of , interpolated linearly, and report it only if the amplitude is at least . A perfectly symmetric cylinder would never shed in exact arithmetic, so the cylinder starts with a small transverse kick in the wake.
The cylinder at Re = 100
With cells, and sweeps (the lab’s default; every quoted run was recomputed independently in Python and agrees to round-off):
- mean , lift amplitude , (a period of , about steps);
- at : (pressure) (shear), so of the drag is pressure;
- the largest divergence left after the projection is (units ).
Known values for an unconfined cylinder at , all from memory: , mean to , lift amplitude near . The lab’s rhythm is about high, which is good. Its drag is about high and its lift amplitude about three times too small. 11.13 Particle & Lattice Methods: SPH and Lattice Boltzmann measured at this Re in a tunnel with the same blockage, so scatter of this size between honest codes is normal.
Part of the gap is the tunnel. Two runs change only the tunnel: a tall tunnel ( cells, same , blockage ) gives , amplitude , ; slip walls on the top and bottom give , amplitude , . Confinement does raise the drag. But lies below the reference, so with half the confinement we overshoot it from the other side. The numerical errors are as large as the physical correction we are trying to make, which is why we now look at them one by one.
What the scheme gets wrong
Numerical diffusion
10.7 Semi-Lagrangian Advection showed that interpolation smooths: for a shift of cells per step the effective viscosity is . For this lab, and the formula gives , almost four times the true . That is a worst case, for a uniform stream; the real effect is smaller and uneven, but it is why the grid matters so much:
| grid | cells across | lift amplitude | St | |
|---|---|---|---|---|
| none | ||||
( and sweeps throughout.) The coarsest grid has no street at all: numerical viscosity lowered the effective Reynolds number below the shedding threshold. The lift amplitude then grows by a factor of about across the table while barely moves. The time step acts in the opposite direction from what intuition says: at the amplitude is and . A smaller step means more diffusion, because .
Leftover divergence
Stam’s twenty sweeps (10.8 Elliptic Solvers: Jacobi, Gauss–Seidel & SOR) leave a residual. Here is what that costs, at with the warm start:
| solver | max divergence at | amplitude | St | |
|---|---|---|---|---|
| sweeps | ||||
| sweeps | ||||
| sweeps | ||||
| conjugate gradients | below |
Warm-started, the forces are forgiving: moves by from sweeps to the exact solve. Switch the warm start off, so each step begins from , and sweeps leave a divergence of , falls to and the street disappears (amplitude ). The pressure is too small to turn the flow around the cylinder, and the solver computes a different flow. At the same sweeps leave , six times more, since Gauss-Seidel needs sweeps growing like . Conjugate gradients removed the problem and took about times longer in the headless run ( s against s on this machine for the same steps).
The staircase
The mask contains a cell if its centre lies inside the body, so the area is a whole number of cells. The cylinder has cells, area against : too big. At it is too big, at it is too small. Worse, the result depends on where the cell boundaries fall. Slide the cylinder up by of a cell:
| shift (cells) | area | amplitude | |
|---|---|---|---|
The physics does not care about a shift of of a diameter, yet the drag moves by and the lift amplitude by a factor of two. A body that is rotated shows the same thing: the airfoil below has area at and at , against the true , which is and .
The airfoil
Switch the obstacle to a symmetric airfoil of thickness (the standard four-digit profile, quoted from memory), chord ( cells), quarter-chord fixed, rotated nose up by . At the flow stays steady up to in the lab. Coefficients use the chord; cells, sweeps, mean over the last half:
| ratio | mask area | ||||
|---|---|---|---|---|---|
Lift rises with angle and is almost entirely pressure (at : from pressure, from shear). Nothing in the solver is told a circulation. 12.1 Airfoils, Circulation & Lift had to impose the Kutta condition on the potential flow of 11.7 Potential Flow & Stream Functions; here no-slip walls and a thin trailing edge do the choosing, and the starting vortex of 11.6 Vorticity Dynamics & Circulation carries the opposite circulation away (from memory, this is how viscous solvers meet the Kutta condition). The lab reaches only about of the thin-airfoil value of 12.2 Thin Airfoil Theory & Panel Methods, and the missing part has several sources: Re is nowhere near flight Reynolds numbers, the chord is half the tunnel height, and the body is about three cells thick.
The grid matters most. At the lift is on , on and on , climbing about per refinement and still short of . Take from this lab the trend and the mechanism, not the second digit. Drag is worse: is at , of which is the shear estimate, against about for laminar friction on a flat plate at this Re (from memory). The lab’s drag is two to three times too large.
Computing it
The playground builds the masked pressure matrix on a grid, cells, and projects a uniform wind with the cylinder in it from a cold start. Red-black Gauss-Seidel does what Stam’s sweeps do. The wind starts with divergence in the cells beside the cylinder (the blocked faces cut off there). After sweeps is left, after sweeps , after sweeps and after sweeps . The playground also prints the area of this coarse mask: cells, .
The exercise. Write the pressure half of the force readout: loop over the four ways a fluid cell can touch a solid one. The tests use a closed block, where uniform pressure must give zero and linear pressure has a known answer.
Concept checks
Problems
For the grid on the same tunnel, with and , find , the cells across the cylinder, the Courant number and the diffusion number.
Show worked solution
, so the cylinder is cells across. . . The blockage is still . Refining the grid at the same raises both numbers.
A cylinder of diameter cells is centred on a cell corner. Cell centres are at half-integer offsets from the centre, and a cell is solid if . Count the solid cells, give the area in units of and compare with .
Show worked solution
Use with squares . Listing allowed pairs of these squares with sum below : gives ; gives ; gives ; gives . That is ordered pairs, and each pair of magnitudes occurs in sign choices, so cells. The area is , against : high, as the lab’s readout shows.
A solid block is cells wide and cells tall, in a pressure field (physical pressure, sampled at the fluid cell centres). Use the exercise’s rule to find , compare it with the exact , and say what the relative error is for .
Show worked solution
The block’s left face is at and its right face at . West cells have centres at and push , east cells at push , each over faces of length : . The exact value is . The ratio is : for the discrete force is too large. The cause is that the pressure is sampled half a cell outside each face, so the effective body is one cell longer. The error shrinks as , like the area error of the staircase.
What comes next
We built a working wind tunnel and then distrusted it, which is what a simulation engineer does. Obvious upgrades exist (a sharper interpolation against numerical diffusion, a cut-cell treatment against the staircase, multigrid against the sweeps), none built here. The next row in the course is Module 13, which opens with feedback and block diagrams. The wind tunnel gives it a natural sensor: here we turned the angle of attack by hand, but a controller would read and turn the angle to hold it, with the delay that the flow’s own response puts in the loop. The later capstone, a six-degree-of-freedom flight simulator with an autopilot, is 16.2 Capstone: 6-DOF Flight Simulator with Autopilot.
Key Takeaways
- One step is advect, diffuse, project: semi-Lagrangian advection, an implicit diffusion solve and a masked pressure projection on a MAC grid, with an obstacle mask that blocks faces and drops neighbours from the pressure rows.
- Forces come from the Chorin pressure on each fluid-solid face plus a first-cell shear estimate; the cylinder’s drag is pressure.
- At Re on cells the lab’s Strouhal number is (reference about , from memory); its drag is about high and its lift amplitude is about a third of the reference.
- Numerical viscosity grows with and with coarseness: the lift amplitude goes from (no street) at to at .
- A warm-started pressure makes to sweeps agree on forces to ; a cold start with sweeps leaves divergence and loses the street.
- The staircase makes the answer depend on where the cell boundaries fall: a quarter-cell shift moved by and halved the lift amplitude at one offset.
- The airfoil’s lift is mostly pressure and reaches about of at Re , but it climbs about per grid refinement; its drag is not trustworthy on these grids.
- State the grid, step, solver and protocol behind every number, and test each error source separately.