Skip to main content

HydroGym Logo

Ruff Language: Python License HydroGym Slack

HydroGym: Reinforcement Learning for Fluid Dynamics

96 environments | 7 solver backends | 2D & 3D | Ready for RL training

HydroGym is a comprehensive platform for applying reinforcement learning to fluid dynamics and flow control. With environments ranging from canonical benchmarks to turbulent flows, HydroGym provides a standardized Gymnasium-compatible interface for training RL agents on challenging CFD problems.

Key Features

  • Diverse Environments: 96 pre-configured environments across 7 CFD solvers
  • Standard RL Interface: Gymnasium-compatible API works with Stable-Baselines3, RLlib, and other RL libraries
  • Compute Efficient: Highly optimized GPU & CPU backends for efficient RL deployment ranging from local workstations to exascale HPC systems
  • Scalable: MPI-parallelized solvers for large-scale HPC deployment (MPMD co-launch of RL and solver processes)
  • Multiple Backends: Finite Element (Firedrake), Lattice Boltzmann (MAIA LBM), Finite Volume (MAIA FV), Spectral Element (NEK5000 on CPUs, NekRS on GPUs), Fully Differentiable solvers (JAX, JAX-Fluids)
  • 2D & 3D: From simple 2D benchmarks to complex 3D turbulent flows (Re up to 400,000)
  • Research-Ready: Managed by a complementary HuggingFace repository

Quick Start: gym.make()

The standard way to start any HydroGym environment is gymnasium's gym.make() — one call, the same shape regardless of backend:

import gymnasium as gym
import hydrogym.registration  # registers HydroGym's environment ids

env = gym.make("hydrogym/Cylinder-v0")
obs, info = env.reset()
for _ in range(100):
    action = env.action_space.sample()
    obs, reward, terminated, truncated, info = env.step(action)
env.close()

The exact same shape works for every gymnasium-API backend — only the id (and, for MAIA/Nek, the MPMD launch command underneath) changes:

Backend id Launch
Firedrake hydrogym/Cylinder-v0, RotaryCylinder, Cavity, Pinball, Step python script.py
MAIA hydrogym-maia/Cylinder_2D_Re200-v0 (zero extra args) mpirun -np 1 python script.py : -np N maia properties_run.toml
NEK5000 hydrogym-nek/TCFmini_3D_Re180-v0 (nproc= required) mpirun -np 1 python script.py : -np N nek5000
JAX-Fluids hydrogym-jaxfluids/Nozzle2D-v0, Nozzle3D python script.py

Runnable reference scripts for each: examples/firedrake/getting_started/gym_make_demo.py, examples/maia/getting_started/gym_make_demo.py, examples/nek5000/getting_started/gym_make_demo.py, examples/jaxfluids/gym_make_demo.py.

gym.make() accepts the same settings as the classes — pass env_config={...} (Firedrake, JAX-Fluids) or backend-native kwargs (MAIA, Nek) to override any default, same as constructing the environment directly. MAIA ids other than Cylinder_2D_Re200 have no universal default probe grid and require probe_locations=[...]; gym.make() raises a clear error naming this if it's missing, rather than guessing at flow-geometry-specific defaults.

JAX stays outside gym.make() by design. It implements a functional/JIT (gymnax-style) contract — jax.jit(env.reset_env) / jax.jit(env.step_env), not gymnasium.Env's reset()/step() — because the JAX backend is meant to be traceable through jax.jit/jax.vmap/jax.lax.scan, which a self-mutating gymnasium.Env cannot be. Wrapping it in gym.make() would present a misleading API. Use hydrogym.jax.envs.* directly — see examples/jax/getting_started/.

Lower-level entry points

gym.make() is a thin, optional layer over each backend's own native construction path — every one of them remains fully available, for direct solver access, open-loop control, custom flow/solver classes, or anything gym.make()'s registered defaults don't cover:

We strongly recommend using our pre-built Docker images. They have the HydroGym backends built in, with MPI, CUDA and the Python environment:

# NVIDIA GPUs (x86_64, cc75-cc120: T4, RTX 20-50, A100, A6000, L40, H100, H200, B200, ...;
# NVIDIA driver >= 525): m-AIA, NekRS, Nek5000, JAX, JAX-Fluids
docker pull clagemann/hydrogym-nvhpc-26.5_cuda-12.9:1.0.2
docker run -it --gpus all --ipc=host clagemann/hydrogym-nvhpc-26.5_cuda-12.9:1.0.2

# CPU only (x86_64): all backends, including Firedrake
docker pull clagemann/hydrogym-cpu:1.0.2
docker run -it --ipc=host clagemann/hydrogym-cpu:1.0.2

Inside, python is the HydroGym environment (/opt/venvs/hydrogym), maia, nekrs, nekrs-mpmd and mpirun are on the PATH, the Nek5000 case executables are in /opt/nek5000/cases/<case>/nek5000, and the HydroGym sources and examples are in /opt/hydrogym. Firedrake (CPU image) has its own environment, source /opt/venvs/firedrake/bin/activate. On clusters, convert the images with apptainer pull docker://...; for NVIDIA GH200 nodes (aarch64) build the Apptainer image from .devcontainer/release/apptainer/, and for AMD GPUs the ROCm image with .devcontainer/scripts/build_rocm_image.sh.

See Container images for the contents, Apptainer use and operational notes, and .devcontainer/README.md for building the images and the matching devcontainer configurations.

Installing from PyPI or from source

HydroGym needs Python 3.11 or newer.

pip install hydrogym              # core; solver extras: hydrogym[firedrake|maia|nek|nekrs|jax|jaxfluids|all]

git lfs install                   # from source: once per machine, before cloning
git clone https://github.com/dynamicslab/hydrogym.git
cd hydrogym && pip install -e ".[jax]"   # or uv sync --locked --extra jax

The pretrained policies (policies/) are part of the repository, not of the PyPI package.

The solver sources under third_party/ are git submodules. They are only needed to build a solver from source (the container images ship them built), so a plain git clone is enough for the Python package. Initialise a single one when you need it, e.g. git submodule update --init third_party/m-AIA. Do not use --recurse-submodules or --recursive: m-AIA contains a nested submodule that is not publicly accessible, so the recursive clone fails.

Git LFS: the Firedrake meshes (hydrogym/firedrake/envs/*/*.msh), the Nek5000 case files (third_party/nek5000/cases/), the Nek5000/NekRS case sources (*.usr, *.par, *.udf, also under examples/nekrs/; *.box) and the files of the pretrained policies (policies/<case>/<variant>/seed<k>/) are stored with Git LFS. Run git lfs install before cloning, or git lfs pull in an existing clone; otherwise these files are small pointer files and HydroGym stops with "... is a Git LFS pointer". The wheels on PyPI contain the meshes.

Available Environments

HydroGym provides 96 environments across 7 solver backends. An environment is one folder of the Hugging Face dataset that holds data (flow, Reynolds number, dimension, mesh or grid variant); three more (m-AIA finite volume) are coming soon. The two NekRS cases are GPU implementations of NEK5000 cases and are set up from examples/nekrs. The full list is generated from the dataset by scripts/gen_env_table.py and is in docs/docs/environments.md.

Solver Backend Count Description Dimensions
Firedrake (FEM) 25 Canonical flow control benchmarks 2D
MAIA LBM 59 Lattice Boltzmann method environments 2D, 3D
MAIA Structured FV 1 (+3 coming soon) High-Reynolds-number airfoil and turbulent boundary-layer flows: DRA2303 airfoil at Ma 0.2 with jets today; the Ma 0.7 and surface-wave variants, and the zero-pressure-gradient boundary layer (ZPGTBL*), are coming soon 3D
NEK5000 5 Spectral element turbulent channel/airfoil flow 3D
NekRS (2) GPU spectral element: the NEK5000 turbulent channel and NACA0012 wing 3D
JAX 2 Differentiable fluid dynamics 2D, 3D
JAX-Fluids 4 Compressible shock vector control 2D, 3D

Environment Categories

Canonical Benchmarks (Low-Mid Re):

  • Cylinder wake (Re=100-3900, 2D/3D)
  • Rotating cylinder (Re=100-3900, 2D/3D)
  • Pinball (Re=30-150, 2D/3D)
  • Cavity flow (Re=4200-7500, 2D/3D)
  • Backward-facing step (Re=600, 2D)
  • Square cylinder (Re=200-3900, 2D/3D)
  • Sphere (Re=300-3700, 3D)
  • Cube (Re=300-3700, 3D)
  • Turbulent channel flow (Re_tau=180 and 207, 3D)

Airfoil Control:

  • NACA0012 steady (Re=100-50000, AOA=12-40°, 2D/3D)
  • NACA0012 with gust disturbance (Re=100-50000, 2D/3D)

High Reynolds Number Flows:

  • DRA2303 airfoil with jet actuation (Re=400000, Ma=0.2, 3D); Ma 0.7 and surface-wave actuation: coming soon
  • Zero-pressure-gradient turbulent boundary layer with jet/surface wave actuation (Re_Tau=180-2200, 3D): coming soon
  • NACA0012 airfoil with jet actuation (Re=200000, 3D)

Fully Differentiable Flows:

  • Shock-Vector Control in single divergent nozzle (SVC, Ma>1.0, 2D/3D)
  • Turbulent channel flow (Re_tau=180, 3D)
  • Kolmogorov flow (up to Re=1000, 2D)

Environment Checkpoints

All required environment checkpoints are available via HuggingFace and are downloaded on the fly when an environment is first created (internet connection required). If no internet connection is available at runtime — e.g. on compute nodes in HPC clusters — you can pre-download the environment files as outlined in examples/maia/README.md.

Examples

HydroGym includes comprehensive examples for each solver backend (internet connection required). We highly recommend using our provided docker containers. In the containers the examples are in /opt/hydrogym/examples, which is not writable for a non-root user (e.g. under Apptainer or docker run --user), and the examples write into their directories: copy them first (cp -r /opt/hydrogym/examples ~/hydrogym-examples) and run them from the copy. Each backend's getting_started/ directory includes a gym_make_demo.py (the standard entry point above) alongside the backend-specific, lower-level scripts below (direct construction, SB3 training loops, multi-agent wrappers) — start with gym_make_demo.py unless you need what a specific lower-level script demonstrates.

Firedrake Examples

See examples/firedrake/getting_started/ for detailed documentation.

cd examples/firedrake/getting_started

# Test environment interactively
./run_example_docker.sh

# Train with Stable-Baselines3 (50000 steps; several hours on a CPU node)
./run_example_docker.sh train

MAIA Examples

See examples/maia/getting_started/ for MPMD coupling details.

cd examples/maia/getting_started

# Prepare workspace (downloads from Hugging Face Hub) and 
# Run with MPMD execution (1 Python + 1 MAIA process on GPU)
./run_example_docker.sh

# Prepare workspace and train with Stable-Baselines3
./run_example_docker.sh train

NEK5000 Examples

See examples/nek5000/getting_started/ for interface patterns.

cd examples/nek5000/getting_started

# Test single-agent environment
cd 1_nekenv_single
./run_nekenv_docker.sh

# ... or train with the PettingZoo wrapper and SB3
cd ../3_pettingzoo
./run_pettingzoo_docker.sh train

# ... or run zero-shot transfer learning
cd ../6_zeroshot_wing_demo
./run_pettingzoo_docker.sh

JAX Examples

See examples/jax/getting_started/ for detailed documentation.

cd examples/jax/getting_started

# Test Kolmogorov flow environment
cd 1_kolmogorov
./run_kolmogorov_docker.sh

# ... or test channel flow environment
cd ../2_channel
./run_channel_docker.sh strong_actuation

# ... or train PPO
cd ../3_ppo
./run_ppo_docker.sh --env kolmogorov   # getting-started settings, ~15-20 min on a CPU

Training RL Agents

HydroGym works with standard RL libraries. Example with Stable-Baselines3, built on gym.make():

import gymnasium as gym
import hydrogym.registration
from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import DummyVecEnv, VecNormalize


# Create environment (env_config overrides gym.make()'s registered defaults)
def make_env():
    return gym.make(
        "hydrogym/Cylinder-v0",
        env_config={
            "flow_config": {"mesh": "medium", "Re": 100},
            "solver_config": {"dt": 1e-2},
            "actuation_config": {"num_substeps": 2},
        },
    )


# Vectorize and normalize
env = DummyVecEnv([make_env])
env = VecNormalize(env, norm_obs=True, norm_reward=True)

# Train
model = PPO("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=100000)

Constructing hydrogym.core.FlowEnv/backend-native factories (hydrogym.maia.from_hf, NekEnv.from_hf, ...) directly works exactly the same way and remains fully supported — gym.make() is a thin, optional layer on top, not a replacement; see "Lower-level entry points" above. See also provided examples/ for more details how to leverage individual solver backends for training.

Advanced Features

  • Checkpoint management: Automatic loading from Hugging Face Hub
  • Custom observations: Force sensors, velocity/pressure/vorticity probes, stress sensors
  • Callbacks: Checkpointing, logging, Paraview export
  • Stability analysis: Global stability analysis via SLEPc (Firedrake)
  • Modal decompositions: DMD, POD via modred (Firedrake)
  • Multi-agent RL: PettingZoo interface for distributed actuation (NEK5000)

Documentation

Citation

If you use HydroGym in your research, please cite the following two papers:

@inproceedings{lagemann2025hydrogym,
  title={HydroGym: A Reinforcement Learning Platform for Fluid Dynamics},
  author={Lagemann, Christian and Paehler, Ludger and Callaham, Jared and Mokbel, Sajeda and Ahnert, Samuel and Lagemann, Kai and Lagemann, Esther and Adams, Nikolaus and Brunton, Steven},
  booktitle={7th Annual Learning for Dynamics \& Control Conference},
  pages={497--512},
  year={2025},
  organization={PMLR}
}
@article{lagemann2026hydrogym,
  title={The HydroGym reinforcement learning platform for fluid dynamics},
  author={Lagemann, Christian and Mokbel, Sajeda and Gondrum, Miro and R{\"u}ttgers, Mario and Wang, Yuning and Su{\'a}rez, Pol and Paehler, Ludger and Bezgin, Deniz A. and Buhendwa, Aaron B. and Callaham, Jared L. and Ahnert, Samuel and Zolman, Nicholas and Shao, Xiao and Loiseau, Jean-Christophe and Adams, Nikolaus A. and Meinke, Matthias and Schr{\"o}der, Wolfgang and Lagemann, Kai and Lagemann, Esther and Vinuesa, Ricardo and Brunton, Steven L.},
  journal={Nature},
  volume={657},
  pages={369--376},
  year={2026},
  doi={10.1038/s41586-026-10917-6},
  note={Preprint: arXiv:2512.17534}
}

License

HydroGym is released under the MIT License. See LICENSE for details.

Metadata

Release files for hydrogym 1.0.2

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

Source distribution (sdist)

Source distribution for hydrogym 1.0.2
File Size Uploaded Provenance Actions
hydrogym-1.0.2.tar.gz 21.0 MB With provenance Details for hydrogym-1.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 42.1 MB

Release files / hydrogym-1.0.2.tar.gz

Download URL hydrogym-1.0.2.tar.gz
Size 21.0 MB
Tags Source
SHA-256 checksum
How to use checksums
b34740f5988c81d7bcf4377660507c7ed364473b6c33778f07bfd6c470f5cd68
BLAKE2b-256 checksum
How to use checksums
3007a625a09adaeae23eb1f2b700d49c5ebc217384ed2712faa3c87fc11e6900
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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 30, 2026.

Transparency log

Release files / hydrogym-1.0.2-py3-none-any.whl

Download URL hydrogym-1.0.2-py3-none-any.whl
Size 21.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
67da0a46c73df12057af114a1e3c598ce72c505b711ba35e6f5723b66ab433cf
BLAKE2b-256 checksum
How to use checksums
953719c2eb193eed5aabc8f9661c9edeea472a2e2096c2aa918514b5c485a809
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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 30, 2026.

Transparency log

Security for hydrogym 1.0.2

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 hydrogym-1.0.2.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 30, 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