Lesson Open Access

CFD Python: the 12 steps to Navier-Stokes equations

Barba, Lorena A.; Forsyth, Gilbert F.

The CFD Python learning module is a set of Jupyter notebooks, consisting of 12 "core" lessons, 3 "bonus" lessons, and a "lesson zero" as a quick intro to Python for numerical computing. This practical module takes students through 12 steps, incrementally guiding them to program a solution to the two-dimensional Navier--Stokes equation, using finite differences. The steps are the following:

  • Steps 1--4 are in one dimension: (i) linear convection with a step-function initial condition (IC) and appropriate boundary conditions (BC); with the same IC/BCs: (ii) nonlinear convection, and (iii) diffusion only; (iv) Burgers’ equation, with a saw-tooth IC and periodic BCs.
  • Steps 5--10 are in two dimensions: (v) linear convection with a square function IC and appropriate BCs; with the same IC/BCs: (vi) nonlinear convection, and (vii) diffusion only; (viii) Burgers’ equation; (ix) Laplace equation, with zero IC and both Neumann and Dirichlet BCs; (x) Poisson equation in 2D.
  • Steps 11--12 solve the Navier--Stokes equation in 2D: (xi) cavity flow; (xii) channel flow.

Students learn many valuable lessons as the module guides them through these steps (they should not skip any!). The incremental nature of the exercises means they get a sense of achievement at the end of each lesson, and they feel they are learning with low effort. As they progress, they naturally practice code re-use and they incrementally learn programming and plotting techniques. As they analyze their results, they learn about numerical diffusion, accuracy, and convergence. In about four weeks, they become moderately proficient programmers and are motivated to start discussing more theoretical matters.

Published in the Journal of Open Source Education
Files (1.9 MB)
Name Size
CFDPython-v1.0.zip
md5:3c7fbac84671726b22e7fdb4f78f323c
1.9 MB Download
3,105
272
views
downloads
All versions This version
Views 3,1053,111
Downloads 272272
Data volume 510.7 MB510.7 MB
Unique views 2,7262,730
Unique downloads 257257

Share

Cite as