A compact and fast Matlab code solving the incompressible
Navier-Stokes equations on rectangular domains
mit18086 navierstokes.m
Benjamin Seibold
Applied Mathematics
Massachusetts Institute of Technology
www-math.mit.edu/~seibold
seibold@math.mit.edu
March 31, 2008
1 Introduction
On the following pages you find a documentation for the Matlab program
mit18086 navierstokes.m, as it is used for Course 18.086: Computational Science and En-
gineering II at the Massachusetts Institute of Technology. The code can be downloaded from
the Computational Science and Engineering web page http://www-math.mit.edu/cse. It
is also linked on the course web page http://www-math.mit.edu/18086.
This code shall be used for teaching and learning about incompressible, viscous flows.
It is an example of a simple numerical method for solving the Navier-Stokes equations. It
contains fundamental components, such as discretization on a staggered grid, an implicit
viscosity step, a projection step, as well as the visualization of the solution over time. The
main priorities of the code are
1. Simplicity and compactness: The whole code is one single Matlab file of about
100 lines.
2. Flexibility: The code does not use spectral methods, thus can be modified to more
complex domains, boundary conditions, and flow laws.
3. Visualization: The evolution of the flow field is visualized while the simulation runs.
4. Computational speed: Full vectorization and pre-solving the arising linear systems
in an initialization step results in fast time stepping.
The code provides:
• variable box sizes, grid resolution, time step, and Reynolds numbers
• implicit time stepping for the fluid viscosity
1