Skip to main content

lettuce

CI Status Documentation Status DOI

GPU-accelerated Lattice Boltzmann Simulations in Python

Lettuce is a Computational Fluid Dynamics framework based on the lattice Boltzmann method (LBM).

  • GPU-Accelerated Computation: Utilizes PyTorch for high performance and efficient GPU utilization.
  • Rapid Prototyping: Supports both 2D and 3D simulations for quick and reliable analysis.
  • Advanced Techniques: Integrates neural networks and automatic differentiation to enhance LBM.
  • Optimized Performance: Includes custom PyTorch extensions for native CUDA kernels.

Resources

Getting Started

To find some very simple examples of how to use lettuce, please have a look at the examples. These will guide you through lettuce's main features. Please ensure you have Jupyter installed to run the Jupyter notebooks.

Installation

  • Install the uv package manager from https://docs.astral.sh/uv/

  • Clone this repository from github and change to it:

    git clone https://github.com/lettucecfd/lettuce
    cd lettuce
    
  • Create a new virtual environment and activate it:

    uv venv
    source .venv/bin/activate
    
  • The pyproject.toml file currently requires at least CUDA 12.4 (we successfully tested CUDA 12.4, 12.6, 12.8 and 13.0). If your GPU does not support this version, you may need to downgrade it. Please note that we cannot guarantee the maintenance for older CUDA versions.

  • Run the install command, depending on your needs (run one of the three options below):

    1. use lettuce (no development) with GPU support:

      uv pip install .
      
    2. use lettuce (no development) with CPU only or specific older CUDA versions (if you do not have access to a GPU or an older GPU) use (cpu, cu124, cu126):

      uv pip install ".[cpu]"
      
    3. use and develop lettuce (code changes take effect in program execution): use the changeable-installation-flag (-e):

      uv pip install -e .
      
  • Check out the convergence order, running on CPU:

    lettuce --no-cuda convergence
    
  • For running a CUDA-driven LBM simulation on one GPU omit the --no-cuda. If CUDA is not found, make sure that CUDA-capable GPU drivers are installed and compatible with the installed cudatoolkit (check cuda version number).

  • Check out the performance, running on GPU:

    lettuce benchmark
    
  • Run the test cases:

    pytest tests
    

Depending on lettuce from another project

The distribution is published as lettucecfd; the import name stays lettuce. Note that the extras above only constrain the PyTorch version — uv's index configuration is not carried in the published package metadata, so uv add lettucecfd[cu128] on its own installs the default PyTorch build from PyPI. To get a specific CUDA build, copy the index configuration into your own pyproject.toml:

[project]
dependencies = ["lettucecfd[cu128]"]

[tool.uv.sources]
torch = [{ index = "pytorch-cu128" }]

[[tool.uv.index]]
name = "pytorch-cu128"
url = "https://download.pytorch.org/whl/cu128"
explicit = true

Substitute cu124, cu126, cu130 or cpu as needed — the extra and the index URL have to name the same variant.

Citation

If you use Lettuce in your research, please cite the following paper:

@inproceedings{bedrunka2021lettuce,
  title={Lettuce: PyTorch-Based Lattice Boltzmann Framework},
  author={Bedrunka, Mario Christopher and Wilde, Dominik and Kliemank, Martin and Reith, Dirk and Foysi, Holger and Kr{\"a}mer, Andreas},
  booktitle={High Performance Computing: ISC High Performance Digital 2021 International Workshops, Frankfurt am Main, Germany, June 24--July 2, 2021, Revised Selected Papers},
  pages={40},
  organization={Springer Nature}
}

Credits

We use the following third-party packages:

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

License

  • Free software: MIT license, as found in the LICENSE file.

Metadata

Release files for lettucecfd 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lettucecfd 0.3.0
File Size Uploaded
lettucecfd-0.3.0.tar.gz 2.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for lettucecfd 0.3.0
File Interpreter ABI Platform
lettucecfd-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.8 MB

Release files / lettucecfd-0.3.0.tar.gz

Download URL lettucecfd-0.3.0.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
ada3429ea4d052a3c875d34f61fa47f9263ca366518ccff30fed2a98ced5b211
BLAKE2b-256 checksum
How to use checksums
887c429082220cd5274f48bea87d4468885ce1216f887946595b98e1bb8dee28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / lettucecfd-0.3.0-py3-none-any.whl

Download URL lettucecfd-0.3.0-py3-none-any.whl
Size 82.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2f311d7c88e4f5fe7f3b19411bb9065ccf6ec48516cf024cdb4cad05b46ef41
BLAKE2b-256 checksum
How to use checksums
a058c7e663d9dc5dde1726cdb84c97cc443c176ed92370f1beaa1ac1c15c1595
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page