Astronomy Education

• ### Codes from my Numerical Methods Class

There are a number of examples of various methods (mostly in python) on my course webpage: Numerical Methods for (Astro)Physics. Some of these are repeated below.

Simple Numerical PDE Examples

• ### Godunov methods for linear advection

A simple second-order accurate finite-volume method for the linear advection equation in one-dimension. A choice of reconstruction is provided: Godunov (piecewise constant), Piecewise Linear, and Piecewise Parabolic (PPM). This advects the initial condition through a periodic domain. The code is structured to with the subroutines you would find in a typical hydrodynamics code. Sample output showing a tophat advected for 5 periods with 128 zones.

A python version (without ppm) is available on my github page:
• ### 2nd order finite volume method for Burgers' equation

A simple Fortran second-order accurate finite-volume method for the 1-d Inviscid Burgers' Equation:
ut + [1/2 u2]x = 0
A choice of limiters is provided, and periodic BCs are implemented. The code is structured to with the subroutines you would find in a typical hydrodynamics code.

An alternate python version is available on my github page:
• ### Viscous Burgers' equation solver

Solve:
ut + [ 1/2 u2 ]x = ε uxx
using a second-order Godunov method for advection and Crank-Nicolson implicit diffusion for the viscous term. The two processes are coupled together.

• ### Multigrid examples

A simple python class for solving 1-d Poisson and constant-coefficient Helmholtz equations on a finite-volume grid. The driver program (mg_test.py) solves uxx = sin(x), u(0)=0, u(1)=0. The discretization is second order (mg-converge.png).

Also see pyro for a 2-d solver.
• ### Diffusion

Simple 1-d second-order explicit and implicit diffusion codes. The implicit code uses a Crank-Nicolson time discretization and the banded matrix solver from SciPy.

Also see pyro for a 2-d solver.
• ### Diffusion-reaction equation

Solve:
φt = κ φxx + (1/τ) R(φ)
using Crank-Nicolson diffusion and Strang-split reactions. This setup gives rises to a spreading burning front.

Computational Hydrodynamics

• ### pyro: hydro by example

A tutorial code and set of notes to introduce new students into computational hydrodynamics. The (mostly) python code implements 2-d solvers for linear advection, compressible hydrodynamics, multigrid, implicit diffusion, and incompressible hydrodynamics.

The code and documentation can be found on the pyro website
• ### hydro1d: a 1-d compressible hydro solver

A simple 1-d compressible hydrodynamics code that implements piecewise constant (Godunov), piecewise linear, and piecewise parabolic (PPM) slope reconstruction in a finite-volume framework. Some simple test problems (e.g. Sod) are included.
• ### Castro: an AMR parallel hydro code

Castro solves the equations of compressible hydrodynamics using a dimensionally unsplit PPM method, includes reactions, support for a general equation of state, and self gravity, and uses an adaptive mesh refinement integration strategy with subcycling in time. Castro is developed primarily by my collaborators at CCSE/LBL (I've hacked a bit on the hydro and microphysics). Castro is open-source and distributed can be cloned/forked from its github page.
• ### Maestro: low Mach number stellar hydro

Maestro is optimized to solve low speed convective flow problems in tight hydrostatic equilibrium. A full description can be found on the Maestro page. Maestro can be cloned/forked from its github page.

Parallel Programming

• ### OpenMP Relaxation Solver of Poisson's Equation

Solve the 2-d Poisson equation with pure relaxation (we do a fixed number of iterations). This is parallelized with OpenMP.
• ### MPI Relaxation Solver of Poisson's Equation

Solve the 2-d Poisson equation with pure relaxation (we do a fixed number of iterations). This is parallelized with MPI, doing a one-dimensional domain decomposition in the x direction.
• ### Parallel I/O Tutorial

A simple parallel I/O tutorial showing various ways to output data from a parallel hydrodynamics code into a single HDF5 file.

Microphysics

• ### Python interface to nuclear reaction rate databases

An object-oriented interface to the nuclear reaction databases (including JINA Reaclib).

Other Numerical Examples

• ### Matplotlib Examples

Some useful bits for matplotlib that I've used.
• ### Monte Carlo Demo (Poker Odds)

A simple demonstration of Monte Carlo techniques—computing the odds of the different hands in a straight 5-card poker game.

Utilities

• ### Simple Backup Script

A simple script for automatically backing up several directories in your home directory to another disk mounted on your local system. To have this run automatically, set it up as a cron job.
• ### Fortran Makefile Dependency Generator

A simple simply python script to generate dependency pairs for Fortran 90 source files for use in makefiles.
• ### ApJ Submission Formatter

A simple python script that takes a LaTeX ApJ manuscript and renames all the figures (both in the file and on disk) to conform to the f1.eps, f2.eps, ... naming convention that ApJ wants. Use at your own risk--this is still beta quality. See the notes contained within.
• ### Research Journal

A python script to manage a research journal / logbook in LaTeX. It is distributed (uses git under the hood), so you can use it on all of the machines you work on and keep things in sync, and it is commandline driven, so the barrier to entry to make a journal entry is very low. It supports images in an entry, editing previous entries, and has simple sub-commands to build and display your PDF journal.
• ### Makefile Examples

Makefile examples of increasing complexity, showing how to use macros, the clean target, file interdependencies, debug/production builds, debugging the makefile itself, and storing the git hash of your project into your source code at build time.
• ### mencoder Wrapper

A simple python script that can be used to convert a series of PNG images into AVI and MP4 movies (with MPEG-4 encoding). Supports doubling frames and adding some extra frames at the end. The mencoder options picked seem to be supported on most platforms.