uCFD: Four Steps to Navier-Stokes
[skip my blabbing and go straight to the lectures]
My philosophy for this class is to get you to solve the Navier-Stokes equations as quickly as possible. In practice, this takes only four steps (if you are new to the subject). In Spring 2019, my students had a working CFD code by the fourth week of class! So, the first part of this class is focused on showing that you actually already know how to solve the Navier-Stokes equations:
- Review of the equations governing fluid flow
- Review of finite difference methods: spatial and temporal discretization
- Solving the transient Advection-Diffusion equation
- Solving the Navier-Stokes equations using the Vorticity-Streamfunction Formulation (\(\omega\) and \(\psi\))
- Solving the Navier-Stokes equations using primitive variables (u, v, w, p)
The second part of the class drills deeper into the many issues encountered in what we just accomplished:
- The finite volume method
- The staggered grid
- Iterative solvers
- Conservative discretization
- The types of numerical errors (diffusive, dispersive)
- How errors show up, and how they impact stability
- Implicit and explicit time integration methods
- High-order advection schemes
- Godunov’s order barrier theorem
- Flux limiters
- The Euler Equations
Finally, the third part covers other topics essential to every CFD practitioner. These include (depending on class background and interests):
- Other Navier-Stokes algorithms (implicit, high-order, SIMPLE-algorithms, All-Speed flows…)
- Turbulent flows
- low-Mach reacting flows
- Parallel Computing
- Multiphase flows
- Unstructured grids
- Verification, Validation, and Uncertainty Quantification
- Commercial software
- Adaptive Mesh Refinement
- Finite Element Methods
I use Python and Jupyter Notebooks EXCLUSIVELY in this class – just because – the near future is Pythonic. This also means that a significant portion of the class is focused on hands-on programming. which brings me to the elephant in the room.
The Elephant in the Room:
Should CFD be taught as a black box using commercial software? or should it be taught with hands on programming ?
Yes 🙂 to both. Because you don’t learn CFD unless you write a CFD code. That’s what happened to me! I used FLUENT throughout my undergrad and had a cursory understanding of CFD but had no clue on what is going. For RANS-type problems, that rarely result in instabilities or other issues that plague CFD practice – be my guest. Use all the CFD you want to use. Such is the case for an experimentalist who, for example, wants to get a rough idea of the air-flow trends in one of his experiments. I urge you to use CFD even if you don’t understand it. But, for a graduate course, such as uCFD – I will take you into the trenches so that you know what it takes to do CFD.
The class is also taught in an open-ended manner to encourage the spirit of independence and the pursuit of knowledge. Some of the projects in this class are:
- Heated lid-driven cavity
- Laminar flow over arbitrary shapes (2D)
- Neural network for drag prediction
- Principal component analysis for reacting confined flow
- Volume of fluid implementation for multiphase incompressible flows
and more to come!
This is my favorite class! And with your help I hope to make it better.
We all stand on the shoulders of giants. I have modeled this course inspired by great CFD teachers: Gretar Tryggvason, Lorena Barba, and Marwan Darwish. I also thank my colleague and collaborator, James C. Sutherland, who has continuously given me feedback on the course and has guest-lectured the parallel computing series.
Many online resources have been useful including Ingo Philipp who inspired me to put together a really nice way to visualize advection (see below). I also wish to thank Rob Stoll and Marc Calaf from Mechanical Engineering (Utah) for sharing their notes which helped me anchor some of the topics that are of interest for their department.
A beautiful way of visualizing advection schemes (uses a moving reference frame)
Sample Results from Class Projects
(courtesy of Mokbel Karam – Flow over obstable (left), flow in heated driven cavity with buoyancy (right) )
Spring 2019 (Jan 7 – April 23, 2019)
Instructor: Prof. Tony Saad
Email: tony.saad@chemeng.utah.edu
Phone Number: 801 585 0344
Office Hours: Thursdays from 1:00 PM to 3:00 PM, by appointment, or if door is open
Office Location: MEB 2286
uCFD Lectures
You can find all Jupyter notebooks related to this course @ https://github.com/saadtony/uCFD. You can also view them cleanly at https://nbviewer.jupyter.org/github/saadtony/uCFD
# | Topic | Handouts | Jupyter Notebooks | Homework |
---|---|---|---|---|
Part I: Four Steps to Navier-Stokes |
||||
1 | Motivation slides – video |
Harlow’s memoir NSF Fluid films IIHR Fluid films Anderson Ch. 1 |
||
2 | The Navier-Stokes Equations – Part 1 slides – video |
Anderson Ch. 2 White Ch. 3 White Ch. 4 |
||
3 | The Navier-Stokes Equations – Part 2 video |
HW1 | ||
4 | Finite Difference Methods (FDM) 1 slides – video |
Pletcher Ch. 3 Anderson Ch. 4 |
1D Advection FDM | |
5 | Finite Difference Methods (FDM) 2 video |
|||
6 | The Advection Diffusion Equation slides – video |
2D Advection-Diffusion FDM | HW2 | |
7 | Navier-Stokes: Vorticity-Streamfunction Formulation 1 slides – video |
|||
8 | Navier-Stokes: Vorticity-Streamfunction Formulation 2 video |
2D Vorticity-Streamfunction Code | ||
9 | Navier-Stokes: Projection Algorithm 1 slides – video |
Project 1 | ||
10 | Navier-Stokes: Projection Algorithm 2 video |
2D Navier-Stokes Solver | ||
Part II: Into the Trenches |
||||
11 | The Finite Volume Method (FVM) slides – video |
|||
12 | FVM Navier Stokes on a Staggered Grid 1 slides – video |
HW 3 | ||
13 | FVM Navier Stokes on a Staggered Grid 2 video |
2D Navier-Stokes FVM Staggered | ||
14 | Project 1 presentations |
hw4 | ||
15 | Iterative Solvers slides |
Strang – Ch 7 | sparse iterative solvers in Python | Project 2 |
16 | Numerical Phenomena slides – video |
|||
17 | The Method of Characteristics slides – video |
hw5 | ||
18 | Hyperbolic Equations 1 (High Order Methods) slides – video |
Darwish Ch. 11 | The k-scheme | |
19 | Hyperbolic Equations 2 (Limiters) video |
Flux Limiters | ||
20 | Project 2 Presentations | hw6 | ||
Part III: Advanced Topics |
||||
21 | Other Navier-Stokes Methods slides – video |
|||
22 | Modeling and Simulation of Turbulent Flows slides – video 1 – video 2 |
|||
23.1 | Tips on Visualization slides – video |
|||
23.2 | Verification, Validation, and Uncertainty Quantification slides – video |
|||
24 | Parallel Computing for CFD (Prof. James C. Sutherland) slides |
|||
25 | Closure slides |
Course Catalog Description
Survey of approaches including time accurate and steady-state methods, explicit and implicit techniques. Eulerian and Lagrangian methods, laminar and turbulent flow, compressible and incompressible approaches, projection methods, stability considerations, etc. Application of CFD to mixing, heat transfer and reaction. Meets with CH EN 5353.
Cross listed with ME EN6720.
Course Objectives
Computational fluid dynamics has come to mean a variety of things depending on who you ask. At its core, however, CFD deals with calculation of a fluid flow. Whether the flow has chemical reactions, heat transfer, structures, etc… as long as there is fluid flow – you are doing CFD. Therefore it makes sense to focus on calculation of the fluid flow in a basic CFD course. We will cover and review the following concepts:
- Review of transport theory, conservation laws, and the Navier-Stokes equations
- Overview of advection/dispersion and diffusionHyperbolic Equations
- Parabolic Equations
- Elliptic equations
- Putting it all together: the Navier-Stokes equations
- Finite difference/finite volume methods
- Modeling and Simulation of Turbulent Flows
- Verification and validation
- low-Mach Reacting Flows
Other Resources
You can find a collection of useful jupyter notebooks on Dr. Saad’s github repository: http://www.github.com/saadtony
Python
This class will make exclusive use of Python – a modern programming language that is suitable for scientific computing. Python is easy to use and – most importantly – free!
We will also focus on using Python within Jupyter Notebooks: a great way to combine text, math, and programming into one document that is edited and executed in a web browser (See this example). You will learn about that in the class. You will also have access to python through your web browser (after the class starts). If you want to download your own Python + Jupyter Notebook, then download the Anaconda distribution here.
Please go here for an easy tutorial on Python by Prof. Saad. In addition, Prof. Saad will hold a few in-class lectures on learning Python.
Python programming:
Python is very ubiquitous and a google search can usually turn up answers to many of your questions. But here are a few ideas of places to look if you want to learn python:
- General Python programming resources:
- CodeAcademy Python class and the you-tube version
- Google’s Python class
- Python for data science
- Trinket is an online programming platform that provides some pretty good python documentation/tutorials.
- Professor Tony Saad has prepared a set of introductory material for python available here.
- A brief tutorial on arrays in python that includes discussion of python lists as well as numpy arrays.
- Python has a vast number of libraries to simplify many tasks. Among those that you will probably use regularly:
- matplotlib provides very powerful (but sometimes challenging to use) plotting capabilities. A quick way to get started on a plot is to look at the matplotlib gallery to obtain code to generate a plot like the one you want to create. Here is another great resource on matplotlib.
- NumPy provides really powerful array handling capabilities like those in Matlab to allow you to create and manipulate arrays of data. It also has some algorithms that operate on the data. We will use numpy extensively in this class.
- SciPy has a large number of algorithms such as interpolation, quadrature (numerical integration), optimization, ODE solvers, linear algebra tools, etc. There is some duplication between NumPy and SciPy.
- pandas provides a lot of data analysis tools. This includes tools to read/write data, analyze and manipulate data, etc.
- SymPy provides support for symbolic mathematics within Python.
- If you are a Matlab user, here are a few resources:
- Numpy for Matlab users (I find this quite useful as a general summary of common Python operations)
- Python primer for Matlab users
Jupyter Notebooks:
Jupyter notebooks allow you to run Python code fragments interspersed with markup text including equations, plots, etc. This is really useful for communicating results, and will be the format required for homework submission.
You will need to familiarize yourself with Jupyter notebooks since you will be submitting homework as a notebook.
Here is a link to a Jupyter notebook that provides a crash course on some of the key features of a notebook.
Web-Based Access for Jupyter Notebooks:
There are two options for web-based access to Jupyter
- You should have access to chen6355.chpc.utah.edu using your University login credentials for the duration of the semester.
- The chemical engineering virtual machine pool. Log in with your ICC credentials and use the UG (not graduate) VM pools. This will open a full windows machine where you can launch jupyter from the start menu.
These are great options if you have consistent web access and don’t want to perform a local python installation on your own laptop.
I will use your utah.edu Email address to communicate with you and send information to class. Please make sure that you have access to your utah email address.
Homework
- Homework is a fundamental piece of the learning process. It will help you strengthen the concepts you learned in class and apply them to new problems.
- The goal of homework is to get you to familiarize yourself with the nomenclature and the types of problems that can be solved with numerical methods.
- Homework assignments will be posted on the homework page of the course web site. Unless otherwise stated, homework is due by the beginning of class on the date indicated on the schedule.
- Solutions will be posted on the class web site shortly after the due date.
- Feel free to “work together” on homework assignments. Discuss the various solutions methods and attempt to learn or fill deficits in your understanding of the subject matter. However, you must submit your own original work. Please do not cross the line of plagiarism and cheating. Such behavior will not be tolerated.
- Homework assignments must be submitted electronically via the course web page. You should write a report describing the problem, your solution, and presenting your results.
Grading policy (tentative)
- 20% each midterm exam (two midterms)
- 25% Homework
- 10% In-Class comprehension quizzes
- 25% Final exam
Grades will be assigned on the following scale, normalized to the highest student in the class (who, by definition, is 100%)
- 92< A ≤ 100, 89 < A- ≤ 92
- 86 < B+ ≤ 89, 81 < B ≤ 86, 78 < B- ≤ 81
- 75 < C+ ≤ 78, 70 < C ≤ 75, 67 < C- ≤ 70
- 64 < D+ ≤ 67, 59 < D ≤ 64, 56 < D- ≤ 59
- E ≤ 56
I reserve the right to adjust this scale downward if I deem it necessary.
Addressing Sexual Misconduct
Title IX makes it clear that violence and harassment based on sex and gender (which includes sexual orientation and gender identity/expression) is a Civil Rights offense subject to the same kinds of accountability and the same kinds of support applied to offenses against other protected categories such as race, national origin, color, religion, age, status as a person with a disability, veteran’s status or genetic information. If you or someone you know has been harassed or assaulted, you are encouraged to report it to the Title IX Coordinator in the Office of Equal Opportunity and Affirmative Action, 135 Park Building, 801-581-8365, or the Office of the Dean of Students, 270 Union Building, 801-581-7066. For support and confidential consultation, contact the Center for Student Wellness, 426 SSB, 801-581-7776. To report to the police, contact the Department of Public Safety, 801-585-2677(COPS).
Academic Misconduct
All instances of academic misconduct will be handled in accordance with the Student Code (http://regulations.utah.edu/academics/6-400.php).
Students with Disabilities (ADA)
The University of Utah seeks to provide equal access to its programs, services, and activities for people with disabilities. If you will need accommodations in this class, reasonable prior notice needs to be given to the Center for Disability Services, 162 Olpin Union Building, (801) 581-5020. CDS will work with you and the instructor to make arrangements for accommodations. All written information in this course can be made available in an alternative format with prior notification to the Center for Disability Services.