This summer, June 13-17 2016 in Campbell room 131, I will be teaching a course entitled "How to Write a Hydro Code". The goal will be for each student to build his or her own hydro code, tailored to individual interests.

This is highly experimental (I've never done this before) and the goal is somewhat ambitious (building a research-grade code in one week) but I think it's always best to aim high.

The course aims to be accessible to undergrads, yet still informative and useful for graduate students and postdocs. At the moment, enrollment is pretty evenly split between these three groups.

There is no official "homework", meaning that all coursework is done in-class, between lectures. I believe it will be much easier to motivate code development if the work is done in the classroom. This will also hopefully motivate collaboration between students.

The final project for the course will be the development of an advanced hydrodynamics code; if students wish, they can team up during the course to develop a single code together.

Course Schedule

The course will take place Monday-Friday, June 13-17. The course is held in Campbell 131, the big classroom.

There will be two lectures each day, and each lecture will be followed by a coding session.

Tentative daily schedule:

Coding sessions will last for 1-2 hours, depending on the task involved and how quickly we move.

Lecture material is tentatively scheduled for the first few days of the week:

Day 1

Hello World!

Introduction to the course, and a brief overview of the possible directions that can be taken as the course unfolds. Possibly some numerical basics such as convergence and Runge-Kutta methods.

Assignment #1:

Assignment #2:

Advection

Methods for solving the advection equation, as a prelude to the full hydrodynamical equations. Conservation laws, stability, numerical diffusion, Courant condition, Lax-Friedrichs and Godunov fluxes.

Assignment #3:

Solve the advection equation

${\partial u \over \partial t} + a {\partial u \over \partial x} = 0$

with any initial condition you want $u(x,0) = u_0(x)$.

Solution is $u(x,t) = u_0(x-at)$.

Update $u_i^n$ using the following:

$u_i^{n+1} = u_i^n - {\Delta t \over \Delta x}( F_{i + 1/2} - F_{i - 1/2} )$

Where $F_{i+1/2}$ is found using the following three methods:

Forward Time Centered Space:

$F_{i + 1/2} = (1/2)( F_i + F_{i+1} )$

Lax-Friedrichs:

$F_{i + 1/2} = (1/2)( F_i + F_{i+1} ) - (1/2){\Delta x \over \Delta t}( u_{i+1} - u_i )$

Godunov:

$F_{i + 1/2} = F_i$ if $a>0$, and $F_{i+1}$ if $a<0$.

Day 2

Euler's Equations

Write a first-order 1D Hydro code. Euler's equations, wavespeeds, Riemann solvers, HLLE. Test problem: Sod shock tube.

Assignment #4:

$\rho_L = 1$, $\rho_R = 0.125$

$P_L = 1$, $P_R = 0.1$

$v_L = 0$, $v_R = 0$.

with adiabatic index $\gamma = 1.4$.

High-Order Methods

Upgrade to a second-order code in space and time. Piecewise linear method, slope limiters, minmod, method-of-lines timestep, Total variation diminishing conditions. Test problem: Isentropic wave.

Assignment #5:

$\rho = \rho^{\rm ref}( 1 + \alpha f(x) )$

$P = K \rho^{\gamma} = P^{\rm ref} (\rho/\rho^{\rm ref})^{\gamma}$

$v = {2 \over {\gamma - 1}} ( c_s - c_s^{\rm ref} )$

Try $\rho^{\rm ref} = 1$, $P^{\rm ref} = 1$, $\alpha = 0.5$, $f(x) = {\rm sin}(2\pi x)$ or something

Additions

I do not have a specific order planned after day 2. This will depend on exactly what everyone wants to learn. Possible topics:

Course Documents

I suppose I will be occasionally posting documents here that you may find useful. Essentially, the course is based around the following two documents:

Chapter 1 of my Thesis

"How to Write a Hydro Code" by Weiqun Zhang

Analytical solution for the Sod shock tube

Parallel advection code