Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.2.4a1

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.2.4a1
File Size Uploaded
lettucecfd-0.2.4a1.tar.gz 2.8 MB Details

Built distribution (wheel)

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

Total release size: 2.8 MB

Release files / lettucecfd-0.2.4a1.tar.gz

Download URL lettucecfd-0.2.4a1.tar.gz
Size 2.8 MB
Tags Source
SHA-256 checksum
How to use checksums
d009c7dbc10299c3cbda57f86f9e717c52291ce81e4b2a4a081e665f3e54a787
BLAKE2b-256 checksum
How to use checksums
7951be5704357a7531216f46edfaf7279f9a9ba561ac4b363479713796214e9f
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.2.4a1-py3-none-any.whl

Download URL lettucecfd-0.2.4a1-py3-none-any.whl
Size 82.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8b5f8e25de3ef2596bf93fcbe92ccf690fcc477c31c57bf817586c428e9d54b
BLAKE2b-256 checksum
How to use checksums
d72214a08736b643a05a10fafff6f30ecb6f9d8f3db284d646b74d5b128db964
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

0.3.0

2 release files

This release

0.2.4a1 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