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.

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:

- 10:00 Lecture 1
- 11:00 Coding Session 1
- (Lunch)
- 2:00 Lecture 2
- 3:00 Coding Session 2

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:

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:

- Pick any smooth function
$f(x)$ , whose derivative$f'(x)_{\rm analytic}$ you know. - Calculate
$f'(x,h)_{\rm numerical}$ , using a first-order and second-order difference. - Evaluate
$\epsilon = |f'(x)_{\rm analytical} - f'(x,h)_{\rm numerical}|$ , as a function of$h$ . - Plot
$\epsilon(h)$ on a log-log plot.

Assignment #2:

- Pick any first-order ODE for which you know the solution, given
$x_0$ ,$f_0$ . - Over a given length L, for a given resolution N, such that
$h = L/N$ , calculate$f_i = f(x_i)$ for all$i<N$ ., using both forward Euler and midpoint methods. - Calculate
$\epsilon = \sum_i h |f_i - f(x_i)_{\rm analytic}|$ - Plot
$\epsilon(h)$ on a log-log plot.

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

with any initial condition you want

Solution is

Update

Where

Forward Time Centered Space:

Lax-Friedrichs:

Godunov:

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

Assignment #4:

- Write a Hydro Code.
- Use Sod Shock Tube initial conditions:

with adiabatic index

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:

- Upgrade the code to second order in space and time.
- Try the Sod shock tube again at second order.
- Set up isentropic pulse ICs:

Try

- Evaluate
$\epsilon = \sum_i h | P/\rho^{\gamma} - 1 |$ as a function of$h$ (or equivalently, as a function of$N$ ). Note this will only converge to zero when evaluated at a time before the shock forms. - Plot
$\epsilon(h)$ on a log-log plot.

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

- 2D/3D
- HLLC
- Moving Mesh Methods
- Magnetohydrodynamics
- Relativistic Fluid Dynamics
- Viscosity
- Cylindrical/Spherical Coordinates
- Gravity
- Parallelization

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

"How to Write a Hydro Code" by Weiqun Zhang