Flow Lab

Syllabus / Module 16: Capstone Builds

Lesson 16.1

Capstone: 2D Virtual Wind Tunnel

Build a 2D incompressible wind tunnel: MAC grid, inflow/outflow, airfoil obstacle, stable-fluids solver, smoke visualization, and lift/drag estimation.

Written byClaude Sonnet

🌊
Why this matters for simulation: Your first wind tunnel.

By the end of this lesson you can…

  • Assemble a 2D incompressible solver on a MAC grid from semi-Lagrangian advection, implicit diffusion and a masked pressure projection, and say which earlier lesson supplies each piece.
  • Set up inflow, outflow, no-slip walls and a staircase obstacle as boundary values, blocked velocity faces and rows of the pressure matrix.
  • Compute drag and lift coefficients from the pressure on the obstacle's faces plus a first-cell shear estimate.
  • Measure the shedding Strouhal number of a cylinder at Reynolds number 100 from the lift signal, and compare it with a from-memory reference value.
  • Quantify three of the scheme's errors with the lab's own numbers: numerical viscosity, leftover divergence and the staircase boundary.
  • Sweep an airfoil's angle of attack, compare the lab's lift with $2\pi\alpha$, and explain why that lift depends so strongly on the grid.
On this page
·
  1. What we are building
  2. One time step
  3. Reading drag and lift
  4. The cylinder at Re = 100
  5. What the scheme gets wrong
  6. Numerical diffusion
  7. Leftover divergence
  8. The staircase
  9. The airfoil
  10. Computing it
  11. Concept checks
  12. Problems
  13. What comes next
  14. Key Takeaways

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 1616 units long and 66 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.

▶ Video The solver step by step, a cylinder's street growing from a small kick, the pressure on its faces added up into drag and lift, and the same tunnel with a tilted airfoilcaptions only
Transcript
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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 U=1U = 1, ρ=1\rho = 1 and the cylinder’s diameter is D=1D = 1. The tunnel is 16×616 \times 6 on a 128×48128 \times 48 grid, h=1/8h = 1/8, so the cylinder is 88 cells across (the blockage D/HD/H is 1/61/6). At Re=UD/ν=100\mathrm{Re} = UD/\nu = 100 the viscosity is ν=0.01\nu = 0.01. With Δt=0.05\Delta t = 0.05 the Courant number is UΔt/h=0.4U\Delta t/h = 0.4 and the diffusion number r=νΔt/h2r = \nu\Delta t/h^2 is 0.0320.032. Air enters on the left at u=Uu = U, leaves on the right at p=0p = 0, and the top and bottom walls are no-slip.

Every piece is something we have already solved:

One time step

Advect. The air arriving at a uu face left from x−Δt u\mathbf x - \Delta t\,\mathbf u (with vv averaged from the four nearest vv faces). Take the old uu there, interpolated bilinearly, and do the same for vv.

Diffuse. Solve (I−νΔt ∇2)unew=u∗(I - \nu\Delta t\,\nabla^2)\mathbf u^{\text{new}} = \mathbf u^* face by face: (1+4r)u−r(four neighbours)=u∗(1 + 4r)u - r(\text{four neighbours}) = u^*. The diagonal 1.1281.128 dominates, so four sweeps are plenty. A no-slip wall puts a ghost value −u-u behind the wall face, which is a neighbour of value zero; a slip wall drops the neighbour.

Project. Solve Ap~=−h2 div u∗A\tilde p = -h^2\,\mathrm{div}\,\mathbf u^* and subtract the gradient. The tilde marks the Chorin pressure p~=Δt p/ρ\tilde p = \Delta t\,p/\rho, the quantity that appears in u←u−∇p~\mathbf u \leftarrow \mathbf u - \nabla\tilde p, so the physical pressure is p=p~/Δtp = \tilde p/\Delta t. 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 22 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.

◆ Interactive The tunnel: a cylinder at Re = 100 (128 by 48 cells, 40 sweeps). Watch the street grow from the kick, then read the protocol numbers

Loading simulation…

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 p hp\,h away from the fluid, so the xx force is hΔt(∑p~west of a solid−∑p~east of a solid)\tfrac{h}{\Delta t}\big(\sum \tilde p_{\text{west of a solid}} - \sum \tilde p_{\text{east of a solid}}\big) and the yy force follows by the same rule. For shear we use the tangential speed utu_t in that first fluid cell, a distance h/2h/2 from the no-slip surface: a stress νut/(h/2)\nu u_t/(h/2) on a face of length hh gives 2νut2\nu u_t. The coefficients are CD=Fx/(12ρU2L)C_D = F_x/(\tfrac12\rho U^2L) and CL=Fy/(12ρU2L)C_L = F_y/(\tfrac12\rho U^2L) per unit span, with L=DL = D for the cylinder and the chord c=3c = 3 for the airfoil, as in 11.5 Non-dimensionalization & the Reynolds Number.

Every number below follows one protocol. Run to t=100t = 100 (20002000 steps, about six flow-through times 16/U16/U). Average CDC_D over tt from 5050 to 100100. Call max⁡∣CL∣\max|C_L| over that window the lift amplitude. Take the Strouhal number St=fD/U\mathrm{St} = fD/U from the last four periods between upward zero crossings of CLC_L, interpolated linearly, and report it only if the amplitude is at least 0.010.01. A perfectly symmetric cylinder would never shed in exact arithmetic, so the cylinder starts with a small transverse kick v=0.3 e−r2v = 0.3\,e^{-r^2} in the wake.

The cylinder at Re = 100

With 128×48128 \times 48 cells, Δt=0.05\Delta t = 0.05 and 4040 sweeps (the lab’s default; every quoted run was recomputed independently in Python and agrees to round-off):

  • mean CD=1.8956C_D = 1.8956, lift amplitude 0.09720.0972, St=0.1704\mathrm{St} = 0.1704 (a period of 5.8695.869, about 117117 steps);
  • at t=100t = 100: CD=1.897=1.651C_D = 1.897 = 1.651 (pressure) + 0.246+\, 0.246 (shear), so 87%87\% of the drag is pressure;
  • the largest divergence left after the projection is 6.291×10−46.291\times10^{-4} (units U/DU/D).

Known values for an unconfined cylinder at Re=100\mathrm{Re} = 100, all from memory: St≈0.165\mathrm{St} \approx 0.165, mean CD≈1.3C_D \approx 1.3 to 1.41.4, lift amplitude near 0.30.3. The lab’s rhythm is about 3%3\% high, which is good. Its drag is about 40%40\% high and its lift amplitude about three times too small. 11.13 Particle & Lattice Methods: SPH and Lattice Boltzmann measured 0.1910.191 at this Re in a tunnel with the same 1/61/6 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 (128×96128 \times 96 cells, same hh, blockage 1/121/12) gives CD=1.5758C_D = 1.5758, amplitude 0.11190.1119, St=0.1416\mathrm{St} = 0.1416; slip walls on the top and bottom give CD=1.7114C_D = 1.7114, amplitude 0.14580.1458, St=0.1513\mathrm{St} = 0.1513. Confinement does raise the drag. But 0.14160.1416 lies 14%14\% 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 ff cells per step the effective viscosity is νnum=f(1−f)h2/(2Δt)\nu_{\text{num}} = f(1-f)h^2/(2\Delta t). For this lab, f=0.4f = 0.4 and the formula gives 0.03750.0375, almost four times the true ν=0.01\nu = 0.01. 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:

gridcells across DDCDC_Dlift amplitudeSt
64×2464 \times 24441.77101.77100.00260.0026none
96×3696 \times 36661.93941.93940.03030.03030.15960.1596
128×48128 \times 48881.89561.89560.09720.09720.17040.1704
192×72192 \times 7212121.87211.87210.20850.20850.18490.1849

(Δt=0.05\Delta t = 0.05 and 4040 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 8080 across the table while CDC_D barely moves. The time step acts in the opposite direction from what intuition says: at Δt=0.025,0.05,0.1\Delta t = 0.025, 0.05, 0.1 the amplitude is 0.0759,0.0972,0.12540.0759, 0.0972, 0.1254 and St=0.1684,0.1704,0.1751\mathrm{St} = 0.1684, 0.1704, 0.1751. A smaller step means more diffusion, because νnum∝1/Δt\nu_{\text{num}} \propto 1/\Delta t.

Leftover divergence

Stam’s twenty sweeps (10.8 Elliptic Solvers: Jacobi, Gauss–Seidel & SOR) leave a residual. Here is what that costs, at 128×48128 \times 48 with the warm start:

solvermax divergence at t=100t = 100CDC_DamplitudeSt
55 sweeps1.053×10−21.053\times10^{-2}1.90131.90130.11990.11990.16940.1694
2020 sweeps1.752×10−31.752\times10^{-3}1.89661.89660.10070.10070.17030.1703
4040 sweeps6.291×10−46.291\times10^{-4}1.89561.89560.09720.09720.17040.1704
conjugate gradientsbelow 10−1310^{-13}1.89531.89530.09580.09580.17050.1705

Warm-started, the forces are forgiving: CDC_D moves by 0.3%0.3\% from 55 sweeps to the exact solve. Switch the warm start off, so each step begins from p~=0\tilde p = 0, and 2020 sweeps leave a divergence of 0.25300.2530, CDC_D falls to 1.29471.2947 and the street disappears (amplitude 0.00380.0038). The pressure is too small to turn the flow around the cylinder, and the solver computes a different flow. At 192×72192 \times 72 the same 4040 sweeps leave 3.792×10−33.792\times10^{-3}, six times more, since Gauss-Seidel needs sweeps growing like N2N^2. Conjugate gradients removed the problem and took about 1515 times longer in the headless run (7171 s against 4.64.6 s on this machine for the same 20002000 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 D=8D = 8 cylinder has 5252 cells, area 0.81250.8125 against π/4=0.7854\pi/4 = 0.7854: 3.5%3.5\% too big. At D=6D = 6 it is 13.2%13.2\% too big, at D=12D = 12 it is 1.0%1.0\% too small. Worse, the result depends on where the cell boundaries fall. Slide the cylinder up by 0,14,12,340, \tfrac14, \tfrac12, \tfrac34 of a cell:

shift (cells)areaCDC_Damplitude
000.81250.81251.89561.89560.09720.0972
0.250.250.781250.781251.81531.81530.09970.0997
0.50.50.75000.75001.83541.83540.05410.0541
0.750.750.781250.781251.81671.81670.11100.1110

The physics does not care about a shift of 1/81/8 of a diameter, yet the drag moves by 4%4\% and the lift amplitude by a factor of two. A body that is rotated shows the same thing: the airfoil below has area 0.62500.6250 at 0∘0^\circ and 0.76560.7656 at 10∘10^\circ, against the true 0.73540.7354, which is −15%-15\% and +4.1%+4.1\%.

The airfoil

Switch the obstacle to a symmetric airfoil of 12%12\% thickness (the standard four-digit profile, quoted from memory), chord c=3c = 3 (2424 cells), quarter-chord fixed, rotated nose up by α\alpha. At Rec=Uc/ν=200\mathrm{Re}_c = Uc/\nu = 200 the flow stays steady up to 15∘15^\circ in the lab. Coefficients use the chord; 128×48128\times48 cells, 4040 sweeps, mean over the last half:

α\alphaCLC_L2πα2\pi\alpharatioCDC_Dmask area
0∘0^\circ0.00000.0000000.49400.49400.62500.6250
3∘3^\circ0.13030.13030.32900.32900.400.400.48140.48140.70310.7031
6∘6^\circ0.40880.40880.65800.65800.620.620.47460.47460.71880.7188
10∘10^\circ0.63630.63631.09661.09660.580.580.52460.52460.76560.7656
15∘15^\circ0.99160.99161.64491.64490.600.600.62910.62910.76560.7656

Lift rises with angle and is almost entirely pressure (at 10∘10^\circ: 0.63430.6343 from pressure, 0.00200.0020 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 60%60\% of the thin-airfoil value 2πα2\pi\alpha of 12.2 Thin Airfoil Theory & Panel Methods, and the missing part has several sources: Re 200200 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 10∘10^\circ the lift is 0.48380.4838 on 96×3696\times36, 0.63630.6363 on 128×48128\times48 and 0.82660.8266 on 192×72192\times72, climbing about 30%30\% per refinement and still short of 1.09661.0966. Take from this lab the trend and the mechanism, not the second digit. Drag is worse: CDC_D is 0.49400.4940 at 0∘0^\circ, of which 0.36250.3625 is the shear estimate, against about 0.190.19 for laminar friction on a flat plate at this Re (from memory). The lab’s drag is two to three times too large.

◆ Interactive The airfoil at Re = 200: drag the angle of attack from 0 to 15 degrees and read Cl, then change the grid and watch the lift move

Loading simulation…

◆ Interactive The same cylinder with 20 sweeps and no warm start: the leftover divergence and the missing street

Loading simulation…

Computing it

The playground builds the masked pressure matrix on a 64×2464 \times 24 grid, D=4D = 4 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 4.004.00 in the cells beside the cylinder (the blocked faces cut off u=1u = 1 there). After 55 sweeps 1.041.04 is left, after 2020 sweeps 0.243710.24371, after 200200 sweeps 0.025120.02512 and after 20002000 sweeps 0.001330.00133. The playground also prints the area of this coarse mask: 1212 cells, 0.75000.7500.

🐍 PythonA masked MAC projection: how many sweeps does the cylinder's blocked flow need?
⌘/Ctrl + Enter

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.

🧪 Coding exerciseExercise: the pressure force on a staircase body
⌘/Ctrl + Enter

Concept checks

✅ Concept check

In the lab ($h = 1/8$, $\nu = 0.01$, $\Delta t = 0.05$), what is the diffusion number $r = \nu\Delta t/h^2$?

✅ Concept check

Twenty Gauss-Seidel sweeps with the pressure restarted from zero every step leave a divergence of $0.2530$ in the lab, and the street disappears. Why?

✅ Concept check

The lab's Strouhal number is $0.1704$ for $D = U = 1$ and $\Delta t = 0.05$. How many time steps are in one shedding period?

✅ Concept check

At fixed grid, the lift amplitude is $0.0759$ at $\Delta t = 0.025$ and $0.1254$ at $\Delta t = 0.1$. What does this say?

✅ Concept checkselect all that apply

Select all that are true of the force readout in the lab.

Problems

✏️ Pen & paperSetting up a finer tunnel●○○

For the 192×72192 \times 72 grid on the same 16×616 \times 6 tunnel, with Re=100\mathrm{Re} = 100 and Δt=0.05\Delta t = 0.05, find hh, the cells across the cylinder, the Courant number and the diffusion number.

Show worked solution

h=16/192=1/12h = 16/192 = 1/12, so the cylinder is 1212 cells across. UΔt/h=0.05×12=0.6U\Delta t/h = 0.05 \times 12 = 0.6. r=νΔt/h2=0.01×0.05×144=0.072r = \nu\Delta t/h^2 = 0.01 \times 0.05 \times 144 = 0.072. The blockage is still 1/61/6. Refining the grid at the same Δt\Delta t raises both numbers.

✏️ Pen & paperCounting the staircase by hand●●○

A cylinder of diameter 88 cells is centred on a cell corner. Cell centres are at half-integer offsets (a,b)(a, b) from the centre, and a cell is solid if a2+b2<16a^2 + b^2 \lt 16. Count the solid cells, give the area in units of D2D^2 and compare with π/4\pi/4.

Show worked solution

Use ∣a∣,∣b∣∈{0.5,1.5,2.5,3.5}|a|, |b| \in \{0.5, 1.5, 2.5, 3.5\} with squares 0.25,2.25,6.25,12.250.25, 2.25, 6.25, 12.25. Listing allowed pairs of these squares with sum below 1616: (0.25,any of four)(0.25, \text{any of four}) gives 44; (2.25,any of four)(2.25, \text{any of four}) gives 44; (6.25,one of the first three)(6.25, \text{one of the first three}) gives 33; (12.25,one of the first two)(12.25, \text{one of the first two}) gives 22. That is 1313 ordered pairs, and each pair of magnitudes occurs in 44 sign choices, so 5252 cells. The area is 52/64=0.812552/64 = 0.8125, against π/4=0.7854\pi/4 = 0.7854: 3.5%3.5\% high, as the lab’s readout shows.

✏️ Pen & paperHow wrong is the staircase force?●●●

A solid block is ww cells wide and nn cells tall, in a pressure field p=axp = a x (physical pressure, sampled at the fluid cell centres). Use the exercise’s rule to find FxF_x, compare it with the exact −∫∇p dA=−a (area)-\int\nabla p\,dA = -a\,(\text{area}), and say what the relative error is for w=3w = 3.

Show worked solution

The block’s left face is at x0x_0 and its right face at x1=x0+whx_1 = x_0 + wh. West cells have centres at x0−h/2x_0 - h/2 and push +x+x, east cells at x1+h/2x_1 + h/2 push −x-x, each over nn faces of length hh: Fx=nh (a(x0−h2)−a(x1+h2))=−a nh (wh+h)=−a nh2(w+1)F_x = nh\,\big(a(x_0 - \tfrac h2) - a(x_1 + \tfrac h2)\big) = -a\,nh\,(wh + h) = -a\,nh^2(w+1). The exact value is −a w n h2-a\,w\,n\,h^2. The ratio is (w+1)/w(w+1)/w: for w=3w = 3 the discrete force is 33%33\% 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 1/w1/w, 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 CLC_L 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 p=p~/Δtp = \tilde p/\Delta t on each fluid-solid face plus a first-cell shear estimate; the cylinder’s drag is 87%87\% pressure.
  • At Re 100100 on 128×48128\times48 cells the lab’s Strouhal number is 0.17040.1704 (reference about 0.1650.165, from memory); its drag 1.89561.8956 is about 40%40\% high and its lift amplitude 0.09720.0972 is about a third of the reference.
  • Numerical viscosity grows with 1/Δt1/\Delta t and with coarseness: the lift amplitude goes from 0.00260.0026 (no street) at 64×2464\times24 to 0.20850.2085 at 192×72192\times72.
  • A warm-started pressure makes 55 to 4040 sweeps agree on forces to 0.3%0.3\%; a cold start with 2020 sweeps leaves divergence 0.25300.2530 and loses the street.
  • The staircase makes the answer depend on where the cell boundaries fall: a quarter-cell shift moved CDC_D by 4%4\% and halved the lift amplitude at one offset.
  • The airfoil’s lift is mostly pressure and reaches about 60%60\% of 2πα2\pi\alpha at Re 200200, but it climbs about 30%30\% 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.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.