A beautiful plot and three questions
A student shows you a beautiful contour plot of the flow around a car. Smooth colours, sensible streamlines, a drag coefficient to three decimals. You ask three questions: what was y+ on the body, did the mass balance close, and how much did the drag change when the mesh was refined? None of them has an answer.
That student has learned CFD software. They have not yet learned CFD.
To learn CFD from scratch, learn to tell a right answer from a confident one. In practice that means four stages in this order: the few pieces of mathematics that explain why numerical solutions go wrong, a small solver you write yourself and break on purpose, a ladder of benchmark cases with published answers, and only then a commercial or open-source package. This article lays out that path, with a worked example that shows the most important lesson in the subject in ten lines of algebra, and a week-by-week plan at the end.
What does it mean to learn CFD?
Three things, and the software is a fourth that matters least.
- The physics. What the conservation equations say, what each term does, and which terms dominate in your problem. A Reynolds number, a Péclet number and a Mach number tell you more about a flow before you mesh it than most contour plots do afterwards.
- The numerics. How a continuous equation becomes algebra, and what error that introduces. Every finite-volume answer is wrong by a discretisation error, and the skill is knowing its size and its character.
- The judgement. Deciding what to model, checking that the numbers are converged, balanced and insensitive to the mesh, and comparing with something independent. This is verification and validation, and it is what employers and clients pay for.
- The software is the interface to all three. It can be learned in a few weeks once the rest is in place, and it changes every release anyway.
The mathematics you need, and why
Less than most people fear, and more than most tutorials admit.
You need vector calculus (divergence, gradient, the divergence theorem), because the finite-volume method is the divergence theorem applied to a small box. You need to recognise the three classes of partial differential equation, because they behave differently: elliptic problems (steady diffusion, pressure) feel every boundary at once, parabolic problems (unsteady diffusion) march forward in time, and hyperbolic problems (pure convection, waves, shocks) carry information along characteristics and punish schemes that ignore the direction of flow.
And you need Taylor series, because that is where discretisation error comes from. Expand a smooth function about a point and difference it:
Here D_c is the central difference and D_u the upwind difference. The central difference is second order: halve the cell size and its leading error falls by four. The upwind difference is first order, and its leading error term is proportional to a second derivative. Hold that thought. It is the whole of the next section.
Write a small solver and break it
Before you open a commercial interface, write a solver of about forty lines. You will learn more from watching it fail than from a month of tutorials.
A free and well-made starting point is CFD Python, the “12 steps to Navier-Stokes” by Lorena Barba and Gilbert Forsyth: Jupyter notebooks that go from 1D linear convection through diffusion, Burgers’ equation, Laplace and Poisson to 2D cavity and channel flow. The content is under CC-BY 4.0 and the code under BSD-3, so you can use and adapt it freely.
Then do the one experiment every CFD engineer should have done with their own hands.
Worked example: the cell Péclet number
Take steady one-dimensional convection and diffusion of a scalar φ on 0 ≤ x ≤ L, with φ(0) = 0 and φ(L) = 1. The equation and its exact solution are:
With Pe = 50 the solution is almost zero across the domain and rises sharply in a thin layer at the right-hand end. At x = 0.9 L the exact value is about exp(−5) ≈ 0.007.
Discretise with N uniform cells. The quantity that controls everything is the cell Péclet number, Pe_Δ = ρuΔx / Γ = Pe / N. On a uniform grid each scheme reduces to a recurrence whose solutions grow from node to node by a fixed ratio, and that ratio tells you what the scheme does:
The first line is the exact node-to-node ratio, r_c is the ratio produced by central differencing and r_u the ratio produced by first-order upwinding.
On 10 cells, Pe_Δ = 5:
| Scheme | Node-to-node ratio | What you see |
|---|---|---|
| Exact | exp(5) ≈ 148 | A sharp layer in the last cell |
| Central | (1 + 2.5)/(1 − 2.5) ≈ −2.33 | The sign flips from node to node: wiggles, and values outside the range 0 to 1 |
| Upwind | 1 + 5 = 6 | Smooth, monotone, and far too thick a layer |
On 40 cells, Pe_Δ = 1.25: central differencing gives a ratio of about 4.3 against an exact 3.5, smooth and close; upwinding gives 2.25, still visibly smeared.
Two lessons follow, and they are the most important in this article.
Central differencing oscillates when Pe_Δ > 2. The ratio turns negative, and the solution develops wiggles that are not physics. This is the classical result in Patankar’s textbook, and it is why commercial solvers do not use pure central differencing for convection in most flows.
Upwinding never oscillates and is wrong in a way that looks right. The truncation error from the Taylor expansion above, (Δx/2)φ″, acts exactly like extra diffusion. The scheme behaves as if the diffusivity were:
On 10 cells that is 3.5 Γ. Your smooth upwind solution is, to leading order, the solution of a problem with a Péclet number of about 50/3.5 ≈ 14, not 50. Nothing on the screen tells you. The contours are clean, the residuals fall beautifully, and the answer belongs to a different flow.
This is why I would rather a beginner see an oscillating central solution first. The wiggles are honest.
Every modern solver offers bounded higher-order schemes (second-order upwind with limiters, QUICK, TVD families) that sit between the two. You will understand what those settings do only after you have seen the two extremes fail.
Check the order of accuracy
Now refine. Compute the error against the exact solution on two grids with refinement ratio r. With e₁ the error on the coarse grid and e₂ the error on the fine one, the observed order is:
Worked example, illustrative numbers. A second-order scheme gives errors of 0.020 and 0.0051 on grids with Δx and Δx/2, so p = ln(3.92)/ln(2) ≈ 1.97. Correct. If you get 1.0 from a scheme that should be second order, something is first order somewhere: a boundary condition, a gradient, a face interpolation. Finding it is the best numerical education there is. This is the same calculation that sits inside the grid convergence index, explained step by step in our mesh independence article.
Climb a ladder of cases with published answers
Once your own code behaves, move to cases where someone else has published the answer. Each rung teaches one new difficulty, and each has a check you can pass or fail.
| Rung | Case | What it teaches | Reference | The check |
|---|---|---|---|---|
| 1 | 1D convection-diffusion | Schemes, Péclet number, order of accuracy | The exact solution above | The observed order matches the scheme |
| 2 | Lid-driven cavity, Re 100 and 1000 | Pressure-velocity coupling in 2D | Ghia, Ghia and Shin (1982), centreline velocities | Your profiles sit on their tabulated points |
| 3 | Laminar pipe flow | Entrance length, wall gradients | Hagen-Poiseuille: f = 64/Re | The friction factor converges to 64/Re as the mesh is refined |
| 4 | Backward-facing step, laminar | Separation and reattachment | Armaly et al. (1983), measurements | Reattachment length against Reynolds number |
| 5 | Cylinder in a channel, DFG 2D-2 | Unsteady flow, time step | FeatFlow: C_D,max = 3.2200, St = 0.30188 | Shedding appears, and both values come close |
| 6 | Turbulent channel | Wall treatment and the limits of RANS | DNS at Re_τ from 180 to 5200 (Lee and Moser, 2015; data from the Oden Institute) | Mean velocity in wall units against the DNS profile |
| 7 | Heated pipe, turbulent | Heat transfer coefficients | The Gnielinski correlation | Nusselt number within the scatter of the correlation |
Rung 3 deserves a remark. The laminar entrance length is roughly 0.05 Re D, so at Re = 1,000 the profile needs about 50 diameters to develop. A short pipe gives a friction factor well above 64/Re, and that is the developing flow doing what it should. Learning to tell the two apart is exactly the point.
Rung 6 is where most self-taught engineers discover that a turbulence model is a model. Compare the mean velocity profile in wall units with the DNS, once with the first cell at y+ ≈ 1 and once with wall functions at y+ ≈ 50. The k-omega SST and k-epsilon article on this blog explains why the two behave differently.
Rung 5 is also a fine test for anyone, or anything, that claims to set up CFD cases for you; the article on AI agents for CFD uses it for exactly that.
Then learn the software
By now the menus will make sense, because each one is a decision you have already made by hand: the convection scheme, the pressure-velocity coupling, the wall treatment, the time step.
Learn one package well before you sample several. Two free routes are good enough to learn on. OpenFOAM is open source and runs on Linux, or on Windows through WSL. Ansys Student is free for students and educators, runs on Windows, and allows up to 1 million cells for fluid problems on up to four cores, for educational use only. One million cells is enough for every rung of the ladder above, which is not an accident.
Repeat rungs 2, 3 and 5 in the package. If your hand-written cavity and the commercial cavity agree with each other and with Ghia, you have verified both, and you have learned the package’s settings by comparison rather than by trust.
Books worth owning
- Versteeg and Malalasekera, An Introduction to Computational Fluid Dynamics: The Finite Volume Method. The clearest first textbook for the finite-volume method that commercial codes use.
- Patankar, Numerical Heat Transfer and Fluid Flow. Short, old and still the best explanation of why schemes behave as they do.
- Ferziger, Perić and Street, Computational Methods for Fluid Dynamics. The reference for numerics once you are past the basics.
- Moukalled, Mangani and Darwish, The Finite Volume Method in Computational Fluid Dynamics. Bridges the theory to the implementation in OpenFOAM.
- Pope, Turbulent Flows. For when “which turbulence model?” becomes a real question.
A 16-week plan
My suggestion for someone with an engineering degree and about eight to ten hours a week. Each block ends with something you can show.
| Weeks | Work | Deliverable |
|---|---|---|
| 1 and 2 | Taylor series, classes of PDE; CFD Python steps 1 to 4 | A 1D diffusion code with its exact solution |
| 3 and 4 | Convection-diffusion; the Péclet experiment; order of accuracy | A plot of exact, central and upwind solutions at Pe_Δ = 5 and 1.25 |
| 5 and 6 | CFD Python steps 9 to 11; lid-driven cavity | Your cavity against Ghia et al. at Re 100 |
| 7 and 8 | Install one package; repeat the cavity; laminar pipe flow | Friction factor against 64/Re, with mesh refinement |
| 9 and 10 | Meshing: boundary layers, quality metrics; a three-mesh study | A grid convergence index for the pipe |
| 11 and 12 | Turbulence and walls; turbulent channel | u+ against y+ compared with DNS, for two wall treatments |
| 13 and 14 | Unsteady flow; DFG cylinder | Strouhal number and peak drag against the reference |
| 15 and 16 | A small project of your own | A short report with convergence, balances, a mesh study and one comparison with data |
The last deliverable is the one that gets you hired. A report that says “the pressure drop is 1,245 Pa with a numerical uncertainty of 1.6%, and it agrees with the correlation within 4%” is worth more than any number of contour plots.
Common mistakes, as they look on screen
- A smooth solution that was never compared with anything. Upwinding produced it. It may be wrong by a factor, as the worked example shows.
- Wiggles fixed by switching to first order. The wiggles were telling you the mesh is too coarse for the scheme. First order hides the message and keeps the error.
- A tutorial reproduced click by click. It runs, and you cannot say why any setting is what it is. Change one setting at a time and predict the effect before you run.
- A friction factor “wrong” by 30% in a short pipe. It is the entrance length, and the solver is right.
- A turbulent case with no y+ check. The wall treatment was never in its valid range, and the model was not doing what you think.
- Residuals as the only convergence evidence. Monitor the quantity you will report and check the mass balance; the convergence article on this blog explains why.
What I would do
If you have an engineering degree and a few hours a week, follow the order above: mathematics that explains error, a small solver, benchmarks, then software. Do not skip the Péclet experiment. It takes an evening and it changes how you read every contour plot for the rest of your career.
If you already use a commercial package at work and never had the numerical background, do the same path in a compressed form: the Péclet experiment, the cavity against Ghia, a three-mesh study on a case you know. Three weekends. You will start to see which of your old results you would still sign.
If you want structured help, our course CFD Modeling of Liquid and Gas Flows follows the same order of framing, physics, simulation, verification and interpretation, and Heat Transfer in Engineering Applications covers rung 7 and beyond. Either way, keep the rule: no result leaves your desk until it has been compared with something you did not compute yourself.
Sources & further reading
- Barba and Forsyth: CFD Python, 12 steps to Navier-Stokes
- FeatFlow, TU Dortmund: DFG flow around cylinder benchmark 2D-2 (Re = 100)
- Oden Institute, University of Texas at Austin: turbulent channel DNS data
- Ansys Student: free student software and its limits
- Ghia, Ghia and Shin (1982), Journal of Computational Physics: high-Re solutions for incompressible flow
Related service
Model review & custom studies
Know what the model supports, where uncertainty remains and what needs checking.
Explore services