Skip to main content

JAX-LaB

A Python-based, differentiable, massively parallel lattice Boltzmann library for modeling multiphase and multiphysics flows & physics-based machine learning.

Key Features

  • JAX Ecosystem Integration: Works with machine learning libraries such as Equinox, Flax, Haiku, and Optax.
  • Differentiable LBM: Provides differentiable kernels for physics and deep learning applications.
  • Scalable and Portable: Runs on multi-core CPUs, GPUs, and TPUs, with distributed support for simulations spanning hundreds of GPUs and billions of cells.
  • Broad LBM Support: Includes several boundary conditions and collision kernels, along with Shan-Chen and volume-of-fluid (VoF) multiphase, multiphysics, and multicomponent flow modeling.
  • User-Friendly Python Interface: Written entirely in Python, simplifying simulation setup and making library easy to extend.
  • JAX Array and Shardmap: Offers a NumPy-like interface while leaving performance optimization to the compiler.
  • GPU-Optimized: Per-shard boundary indices, scalar wetting/force stencils, and a fused symbolic MRT collision path reduce memory traffic and compiled kernel size.
  • Visualization: Supports multiple output options, including JAX-native ray tracer for in situ surface, volume, and vector-field rendering of GPU/TPU arrays.

Capabilities

Multiphase Flow Modeling

1. Shan-Chen

  • Support for high density ratio flows (tested for density ratios > 1010) using 4th-order isotropic explicit finite difference (EFM) method for gradient computation.
  • Incorporates Equation of State (EOS) to model multiphase flows. Currently implemented EOS include Carnahan-Starling, Peng-Robinson, Redlich-Kwong, Redlich-Kwong-Soave and VanderWaals.
  • Density ratio independent surface tension control by directly modifying pressure tensor (MRT model).

Multicomponent Flow Support

Computations use pytrees to model any number of components, each with its own equation of state, initial condition, and boundary conditions, without requiring library modifications.

Wetting model

2. Thermal Flow

  • Hybrid thermal LBM solver for two- and three-dimensional single-phase, multiphase, and multicomponent flows.
  • Thermal equation is solved using lattice-based finite-difference stencils and fourth-order Runge-Kutta time integration.

3. Volume of Fluid (VoF)

  • Two-lattice free-surface LBM (Mohammadrezaei et al., 2026): liquid and gas each evolve on their own lattice and are coupled only at interface cells, enabling physical density ratios (e.g., air-water 1:1000) with a sharp interface.
  • Surface tension from the interface curvature, contact angles at walls, and an optional viscous normal-stress jump.
  • BGK and MRT collision on D2Q9 and D3Q19; interface work runs only on a compacted band of interface cells, so its cost scales with interface size.

Collision Models

  • BGK
  • Multi-Relaxation Time (MRT)
  • Cascaded (Central Moment)
  • KBC

Lattice

  • D2Q9
  • D3Q19
  • D3Q27

Machine Learning

  • Easy integration with JAX's ecosystem of machine learning libraries
  • Differentiable LBM kernels both for single and multiphase flows
  • Differentiable boundary conditions

Compute Capabilities

  • Distributed Multi-GPU support
  • Mixed-Precision support (store vs compute)
  • Local, per-shard boundary condition indices instead of global lists replicated on every device
  • Scalar neighbor stencils for wetting and Shan-Chen force, avoiding per-direction streamed arrays
  • Fused, symbolic MRT collision matrix

Output

  • Binary and ASCII VTK output using PyVista
  • HDF5/XDMF output using h5py
  • JAX-native in-situ surface, refractive volume, and vector-field rendering and image output
  • Distributed asynchronous checkpointing using orbax
  • 3D mesh voxelizer using trimesh

Boundary Conditions

  • Equilibrium: Sets prescribed velocity or pressure using equilibrium populations.
  • Full-Way Bounceback: Reflects populations to impose a stationary, no-slip wall.
  • Half-Way Bounceback: Imposes a no-slip wall halfway between fluid and solid nodes.
  • Do Nothing: Allows populations to pass through unmodified.
  • Zou-He: Imposes a prescribed velocity or pressure profile.
  • Regularized: Provides a more stable, but more expensive, alternative to Zou-He.
  • Extrapolation Outflow: Reduces wave reflections using extrapolation.
  • Non-Equilibrium Extrapolation: Open boundary condition with prescribed density.
  • Exact Non-Equilibrium Extrapolation: Mass-corrected open boundary condition with prescribed density.
  • Interpolated Bounceback: Applies the Bouzidi scheme to curved or off-lattice walls.
  • Convective Outflow: Supports outflow in applications such as porous media flow.
  • Dirichlet: Prescribes temperature at the boundary.
  • Neumann: Prescribes the normal temperature gradient.

Documentation

Complete API documentation is available here, or you can build and preview it locally:

pip install -e ".[docs]"
zensical serve

Installation Guide

JAX-LaB is distributed as the jax-lab package (import name jax_lab). The default install targets CPU:

pip install jax-lab

Accelerator support

Hardware acceleration is selected through dependency extras, which delegate the compiled backend packages to JAX's own extras:

pip install "jax-lab[cuda13]"   # NVIDIA GPU (CUDA 13, bundled)
pip install "jax-lab[cuda12]"   # NVIDIA GPU (CUDA 12, bundled)
pip install "jax-lab[tpu]"      # Google TPU
pip install "jax-lab[rocm]"     # AMD GPU (ROCm, local toolkit)

Use cuda13-local/cuda12-local instead if you manage the CUDA toolkit yourself.

Optional I/O and visualization dependencies

The I/O and visualization utilities load their dependencies lazily (at call time, not at import time), so the core solver runs without them. The following packages are only needed if you call the corresponding functions:

Package Required by
PyVista save_fields_vtk, save_BCs_vtk, live_volume_rendering
h5py save_fields_hdf5_xdmf
matplotlib save_image, live_volume_rendering
trimesh + Rtree voxelize_stl

Calling one of these functions without its dependency installed raises an ImportError naming the missing package. The io extra installs all of them at once (recommended for running the examples, most of which write VTK or image output):

pip install "jax-lab[io]"

Extras can be combined, e.g. pip install "jax-lab[cuda13,io]".

Development install

To work on JAX-LaB itself or run the bundled examples, install from source in editable mode:

git clone https://github.com/piyush-ppradhan/JAX-LaB
cd JAX-LaB
pip install -e ".[dev,io]"

Run an example:

python3 examples/isothermal/singlephase/cavity2d.py

Citation

@article{pradhan_jax-lab_2026,
    title = {{JAX}-{LaB}: {A} {High}-{Performance}, {Differentiable} {Lattice} {Boltzmann} {Library} for {Modeling} {Multiphase} {Fluid} {Dynamics} in {Geosciences} and {Engineering}},
    volume = {18},
    copyright = {© 2026 The Author(s). Journal of Advances in Modeling Earth Systems published by Wiley Periodicals LLC on behalf of American Geophysical Union.},
    issn = {1942-2466},
    shorttitle = {{JAX}-{LaB}},
    url = {https://onlinelibrary.wiley.com/doi/abs/10.1029/2025MS005313},
    doi = {10.1029/2025MS005313},
    language = {en},
    number = {2},
    urldate = {2026-02-20},
    journal = {Journal of Advances in Modeling Earth Systems},
    author = {Pradhan, Piyush and Gentine, Pierre and Kelly, Shaina},
    year = {2026},
    keywords = {GPU, JAX, Lattice Boltzmann method, Python, Shan-Chen method, multiphase flow},
    pages = {e2025MS005313},
}

Metadata

Release files for jax-lab 0.6.3

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

Source distribution (sdist)

Source distribution for jax-lab 0.6.3
File Size Uploaded Provenance Actions
jax_lab-0.6.3.tar.gz 218.5 kB With provenance Details for jax_lab-0.6.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jax-lab 0.6.3
File Interpreter ABI Platform Actions
jax_lab-0.6.3-py3-none-any.whl Python 3 none any Details for jax_lab-0.6.3-py3-none-any.whl

Total release size: 390.7 kB

Release files / jax_lab-0.6.3.tar.gz

Download URL jax_lab-0.6.3.tar.gz
Size 218.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8791962c66d1a2a07ca30efa4f6fff7fbed132452e86592a416045dff955fade
BLAKE2b-256 checksum
How to use checksums
4a6d8b12c2cb0b51020d3f3adc32ac74d9ba787af489b73cbabbdc6895316c76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / jax_lab-0.6.3-py3-none-any.whl

Download URL jax_lab-0.6.3-py3-none-any.whl
Size 172.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98b4d5b6565b4a1e3ce6eb8a3a60dbf4692715c81d45bed1720676b447be59e4
BLAKE2b-256 checksum
How to use checksums
719d7a9e2e33118d7f7a4facb9bbe7188184de3507ed1af90473f3ce6ab2649b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for jax-lab 0.6.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jax_lab-0.6.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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