In these lectures a relatively simple method to simulate the unsteady two-dimensional flow of two immiscible fluids, separated by a sharp interface, is introduced. The flow solver is an explicit projection finite-volume method, third order in time and second order in space, and the interface motion is computed using a front-tracking method, where connected marker point that move with the flow identify the interface. The method is described in detail and a numerical code is developed, using a step-by-step approach where we start with a simple but not very accurate code and gradually make it more complete and more accurate. The code is written in Matlab, but the information presented here should allow an implementation in any other programming language. Here we assume two-dimensional flows, but most of the discussion carries over to fully three-dimensional flows in a straightforward way. This is, in particular, true for the flow solver. I hope to add slides explaining front-tracking in 3D later.

The final code developed below is CodeC3-frt-st-RK3.m

1: Introduction. What do we want to do and why? A few historical notes. |
Video (14.32 minutes); |
Slides Slides+text |
Quiz |

2: One-Fluid Formulation. We derive the Navier-Stokes equations for flows with sharp interfaces, with a particular focus on the "one-fluid" formulation. |
Video (13.37 minutes); |
Slides Slides+text |
Quiz |

3: Flow Solver. We write a simple code for two-dimensional flow, using a first order explicit projection method on a regular staggered grid, for variable density flow. The density is updated by solving a simple advection/diffusion equation.
Code (CodeC1-advChi.m); |
Video 1 (20.38 minutes); Video 2 (11.56 minutes); Video 3 (11.09 minutes); |
Slides 1 Slides 1+text Slides 2 Slides 2+text Slides 3 Slides 3+text |
Quiz 1 Quiz 2 Quiz 3 |

4: Advecting Interfaces. We explore the different ways a marker function for sharply stratified flow can be advected, dicussing volume of fluid, level set and front tracking methods. We then replace the advection/diffusion equation for the density inthe flow solver by the front-tracking. |
Video (21.00 minutes); |
Slides Slides+text |
Quiz |

5: Front Tracking. We write a simple front-tracking code for two-dimensional flow, using connected marker particles to identify the interface, and then construct a marker function from the location of the interface.
Code (CodeC2-frt.m); |
Video 1 (13.47 minutes); Video 2 (10.09 minutes); |
Slides 1 Slides 1+text Slides 2 Slides 2+text |
Quiz 1 Quiz 2 |

6: More Complete Code. We make the flow solver third order in time, add surface tension, and allow different viscosities in the different fluids. The results is a code capable of producing fairly accurate results for two-dimensional flows with sharp interfaces.
Code (CodeC3-frt-st-RK3.m); |
Video (13.18 minutes); |
Slides Slides+text |
Quiz |

7: Results and Tests. We use our code to simulate the collision of a drop with a wall and the rise of a bubble, on different grids, examinig the convergence properties of the method. We then modify the code slightly and do the same for the Rayleigh-Taylor instability. |
Video (21.29 minutes); |
Slides Slides+text |
Quiz |

Eventually, I hope to add a few more lectures and codes, dealing with stretched grids, periodic domains, axisymmetric domains, and possibly other physical effects, in addition to changes needed for 3D domains. In the fullness of time, I may also add something about the various numerical advances that have been made over the years, such as advanced methods for the advection, including monotonicity and consistency for the momentum advection, advanced pressure solvers, improved surface tension methods, and efforts to accurately capture the viscous boundary conditions. Although these improvements are important for some problems, in many cases they are not essential and a large number of problems have been simulated with codes like the one presented here.

**Python Version:** MATLAB is a great program development platform, but unfortunately it is not free. The codes developed here should run in free alternatives such as GNU Octave, but I have not tested that and some minor modifications may be needed. To provide another alternative, Tingyi Lu, a highschools student working with us in the summer of 2018, rewrote the codes in Python. Her report and the codes can be downloaded as a zipped folder.

**Fortran 2D Code:** The MATLAB codes presented here are mostly for learning, but can also be used for implementing and testing new ideas. For production runs, however, more advanced programming languages are preferable. A zipped folder with a fortran 90 code for 2D flow can be downloaded here. The code allows different boundary conditions and initial interface configurations. It is a recent rewrite of an older code that has been used for results described in a number of publications.

**Funding:** The main funding source for this tutorial is NSF Grant CBET 1335913: Multiscale Simulations of Multiphase Flows.

**DISCLAIMER:** The material presented here is, of course, made availabe without any explicit or implicit guarantee or warrant for correctness, completeness, currentness, or fitness for any particular purpose. It is, on the other hand, completely free and can be used for any purpose, in any context, without compensation or acknowledgement. However, if you do something interesting with the material an acknowledgement would be nice!

Last updated 2/4/2019 by Gretar Tryggvason