A 2D compressible-Euler simulation of the Rayleigh-Taylor instability, implemented three ways, Python, C, and CUDA, for comparison.
Density field evolution on a 1024×2048 grid, the characteristic mushroom structures of the Rayleigh-Taylor instability.
The three runners solve the same equations (2D compressible Euler with artificial diffusion) on the same uniform grid, with periodic boundaries in
Note: Each implementation has its own copy of the CLI and frame writer, kept in sync with the reference spec at
src/common/cli_spec.pyandsrc/common/frame_io.py.
See docs/math.md for the governing equations, time integration, and CFL condition.
- Python:
numpy,matplotlib - System:
ffmpeg(required by animation script),gccandmake(for the C runner),nvcc,make, and a CUDA-capable GPU (for the CUDA runner)
Set up a virtual env for the Python runner and the analysis scripts:
python3 -m venv .venv
source .venv/bin/activate
pip install numpy matplotlibpython src/python/run.py \
--Nx 256 --Ny 512 --t-end 2.0 \
--save-interval 400 \
--output-dir results/py_256x512_t2Requires gcc and make.
make -C src/c
./src/c/run --Nx 256 --Ny 512 --t-end 2.0 \
--save-interval 400 \
--output-dir results/c_256x512_t2Requires nvcc, make, and a CUDA-capable GPU.
make -C src/cuda
./src/cuda/run --Nx 256 --Ny 512 --t-end 2.0 \
--save-interval 400 \
--output-dir results/cuda_256x512_t2python scripts/plot_frame.py results/c_256x512_t2/frame_010000.bin
python scripts/animate.py results/c_256x512_t2All three runners accept the same flags; run --help for the full list.
On a 256×512 grid the CUDA runner reaches ~60 M cell-updates/s, a ~29× speedup over the Python baseline; the C port alone gives ~2.3×. CUDA throughput stays roughly flat as the grid grows, while the CPU runners lose ground once the working set spills out of cache.
See docs/benchmarks.md for the full results table,
methodology, hardware specs, and plots.
MIT - see LICENSE.