# uCFD: Four Steps to Navier-Stokes

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:

1. Review of the equations governing fluid flow
2. Review of finite difference methods: spatial and temporal discretization
3. Solving the transient Advection-Diffusion equation
4. Solving the Navier-Stokes equations using the Vorticity-Streamfunction Formulation ($\omega$ and $\psi$)
5. 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
• 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
• 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:

1. Heated lid-driven cavity
2. Laminar flow over arbitrary shapes (2D)
3. Neural network for drag prediction
4. Principal component analysis for reacting confined flow
5. 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)

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
slidesvideo
Harlow’s memoir
NSF Fluid films
IIHR Fluid films
Anderson Ch. 1

2 The Navier-Stokes Equations – Part 1
slidesvideo

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
5 Finite Difference Methods (FDM) 2
video

slides – video
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

21 Other Navier-Stokes Methods
slides – video

22 Modeling and Simulation of Turbulent Flows
slidesvideo 1video 2

23.1 Tips on Visualization
slidesvideo

23.2 Verification, Validation, and Uncertainty Quantification
slidesvideo

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:

### 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:

2. 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.

## 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.

• 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.