Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rayleigh-Taylor Instability Simulation

A 2D compressible-Euler simulation of the Rayleigh-Taylor instability, implemented three ways, Python, C, and CUDA, for comparison.

Rayleigh-Taylor Instability Evolution

Density field evolution on a 1024×2048 grid, the characteristic mushroom structures of the Rayleigh-Taylor instability.

What this is

The three runners solve the same equations (2D compressible Euler with artificial diffusion) on the same uniform grid, with periodic boundaries in $x$ and rigid walls in $y$.

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.py and src/common/frame_io.py.

See docs/math.md for the governing equations, time integration, and CFL condition.

Quick start

Dependencies

  • Python: numpy, matplotlib
  • System: ffmpeg (required by animation script), gcc and make (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 matplotlib

Python

python src/python/run.py \
    --Nx 256 --Ny 512 --t-end 2.0 \
    --save-interval 400 \
    --output-dir results/py_256x512_t2

C

Requires 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_t2

CUDA

Requires 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_t2

Plot / animate

python scripts/plot_frame.py results/c_256x512_t2/frame_010000.bin
python scripts/animate.py    results/c_256x512_t2

All three runners accept the same flags; run --help for the full list.

Benchmarks

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.

License

MIT - see LICENSE.

About

2D compressible-Euler simulation of the Rayleigh-Taylor instability, implemented in Python, C, and CUDA.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages