Skip to content

RandomKiddo/LatticeBoltzmannMethod

Repository files navigation

Lattice Boltzmann Method

A C++/CUDA/NVCC implementation of the Lattice Boltzmann Method for computational fluid dynamics (CFD), utilizing an NVIDIA H100 GPU on a high-performance computing (HPC) resource, with provided Makefiles and executables. Specifically, we investigate the Kármán Vortex Street.

GitHub License GitHub language count GitHub top language GitHub repo size

This project is licensed by the GNU GPLv3 License: Copyright © 2026 RandomKiddo.


Project Overview and Example Results

For more in-depth analysis and details on this project, see the project PDF file.

Below is an example visualization from the simulation output from visualize.py:

vortex_street_zoomed.mp4

We do analysis to prior results, yielding the following $St$ vs. $Re$ plot, showing good agreement, especially with general shape: img


Updating, Compiling, and Running

The JSON file config.json holds the simulation parameters:

{
    "domain": {
        "nx": 4000,
        "ny": 1000
    },
    "physics": {
        "tau": 0.6,
        "u_inlet": 0.1,
        "steps": 150000
    },
    "output": {
        "base_filename": "vortex_street",
        "interval": 1000
    }
}

The domain nx and ny define the xy-domain size. The variable u_inlet controls the inlet velocity (velocity of the incoming fluid) and tau controls the kinematic viscosity. The steps is the total number of steps to take. In output, the base_filename is the base filename for the output (minus the addendums that give simulation parameters in the filename) and the interval is the output interval for the main file output (not the probe or the last step).

Warning

For simulation parameters, decreasing $\tau$ to be close to 0.5 could yield lossy results. This could also cause simulation failure or nan return values. This is a restriction of the code itself.


Analysis

The analysis is done through the Python files strouhal.py and visualize.py. The former compares to numerical numbers important to these kind of simulations, the Strouhal number and Reynolds number. The latter creates the visualizations from the simulation output.


Architecture Changes

This code is built for NVIDIA H100 GPUs. As such the Makefile utilizes the following compile line:

nvcc -O3 -arch=sm_90 main.cu -o lbm_solver

The architecture line -arch=sm_90 is required for the NVIDIA H100 Hopper GPUs.

Important

The architecture line will depend on the GPU being used. The flag -arch=sm90 works for NVIDIA H100 GPUs. For a consumer-level GPU like the NVIDIA RTX 3060, typically the architecture flag -arch=sm_70 works. You will need to look at your specific NVIDIA GPU architecture to know which flag to use.


On Conda Environments and Source Shells

The file load_osc.sh can be used to source necessary files for compilation and running.

source load_osc.sh

It is specifically designed to work on the Ohio Supercomputer Center on the Cardinal cluster. Doing so will load necessary modules like Miniconda and CUDA. This also loads or installs the necessary Conda environment to use the Python analysis files. The environment for Linux HPC usage is in environment.yml. The Conda environment is called lbm and has the necessary packages and versions to run strouhal.py or visualize.py.

Note

If not able to run on the OSC or similar HPC systems, the necessary modules will need to be loaded and linked, and the Python version used will require the necessary installs.


Acknowledgements

This project utilizes Nlohmann's JSON C++ package to read JSON files into C++ for dynamic simulation variables.

It is licensed by the MIT License: Copyright © 2013-2026 Niels Lohmann.

The inferno palette (inferno.pal file) for Gnuplot was accessed from the Gnuplot palette repository.


Back to Top

This page was last edited on 04.24.2026

About

A C++/CUDA/NVCC implementation of the Lattice Boltzmann Method for computational fluid dynamics (CFD), utilizing an NVIDIA H100 GPU on a high-performance computing (HPC) resource, with provided Makefiles and executables. Specifically, we investigate the Kármán Vortex Street.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors