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

Evaporation in Fontainebleau sandstone
Evaporation in Fontainebleau sandstone.
Drainage through a porous geometry
Drainage through a beadpack geometry.
Rayleigh-Taylor instability
Rayleigh-Taylor instability.
Two-dimensional pool boiling
Three-dimensional pool boiling.
Droplet impingement on an inclined surface
Droplet impingement on an inclined surface.
Droplet evaporation with contact-angle hysteresis
Bubble rising in a column.
Temporal evolution of the density field determined using neural network for the inverse multiphase flow control problem of forming a droplet at t = 900. The MLP output is used as the initial condition for LBM and the backpropagation step during training leverages the auto-differentiation capabilities of JAX-LaB (see paper for details).

In-Situ Rendering

JAX-LaB includes an accelerated ray tracer for rapidly visualizing JAX arrays. Rendered images can be used to create animations or quickly diagnose large simulations running on clusters and HPC systems without any post-processing.

Stanford bunny-shaped droplet falling on a surface
Stanford bunny-shaped droplet falling on a surface

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 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.
  • Visualization: Supports multiple output options, including JAX-native in-situ surface, volume, and vector-field rendering.

Capabilities

Multiphase Flow Modeling

Shan-Chen pseudopotential method with various modifications:

  • Support for high density ratio flows (tested for density ratios > 108) using improved forcing scheme.
  • 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.

Thermal Flow Modeling

  • 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.

Wetting model

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)

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.
  • 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.

Accompanying Paper

The accompanying paper, published in Journal of Advances in Modeling Earth Systems (JAMES), is available here.

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]"

[!NOTE] On macOS, please use the standard CPU installation, as JAX does not support GPU acceleration on this platform.

Run an example:

python3 examples/isothermal/singlephase/cavity2d.py

Solver components live under jax_lab.core, while the JAX-native rendering API lives under jax_lab.render. For example:

from jax_lab.core.lattice import LatticeD2Q9
from jax_lab.core.models import BGKSim
from jax_lab.render import Scene, SurfaceRendering

Citation

If you use this software, please cite it as follows:

@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},
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jax_lab-0.5.2.tar.gz (135.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jax_lab-0.5.2-py3-none-any.whl (100.0 kB view details)

Uploaded Python 3

File details

Details for the file jax_lab-0.5.2.tar.gz.

File metadata

  • Download URL: jax_lab-0.5.2.tar.gz
  • Upload date:
  • Size: 135.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for jax_lab-0.5.2.tar.gz
Algorithm Hash digest
SHA256 806520fb1c50d510f8ceae33c8d0d2dbe6f7d4d10f5f2d4d384b3dc5af85949f
MD5 0587e7a9213e966139295cc601071b1b
BLAKE2b-256 94060c08993dd5f0fff5ddcbdfdd4c705e52b0447c5ddfb182231b4a19c69221

See more details on using hashes here.

Provenance

The following attestation bundles were made for jax_lab-0.5.2.tar.gz:

Publisher: release.yml on piyush-ppradhan/JAX-LaB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jax_lab-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: jax_lab-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 100.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for jax_lab-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9cbbf8eb0873da726e4bcdd70c77c698ca7e02eacea3de8687f5cc0ec09119b4
MD5 971aaeda3c62d983a3e2a81a44c8f6ac
BLAKE2b-256 be3d6a75511150b27087ed8bff0b9c4671226d30a1d937b6636b4f42cae22002

See more details on using hashes here.

Provenance

The following attestation bundles were made for jax_lab-0.5.2-py3-none-any.whl:

Publisher: release.yml on piyush-ppradhan/JAX-LaB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

This release

0.5.2 This release

2 files

0.5.1

2 files

0.5.0

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.0

2 files

0.1.0

2 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