Metadata-Version: 2.4
Name: fluidgym
Version: 0.1.1
Summary: Plug-and-Play Benchmarking of Reinforcement Learning Algorithms for Large-Scale Flow Control
Author-email: Jannis Becktepe <jannis.becktepe@tu-dortmund.de>
License: MIT License
        
        Copyright (c) 2026 safe-autonomous-systems
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: <3.14,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSES/Apache-2.0.txt
Requires-Dist: torch==2.9.*
Requires-Dist: gymnasium
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: matplotlib<3.10,>=3.9
Requires-Dist: seaborn
Requires-Dist: huggingface_hub>=1.0.0
Requires-Dist: scikit-image
Requires-Dist: imageio
Requires-Dist: platformdirs
Provides-Extra: dev
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: types-seaborn; extra == "dev"
Requires-Dist: pandas-stubs; extra == "dev"
Requires-Dist: types-setuptools; extra == "dev"
Requires-Dist: scipy-stubs; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
Provides-Extra: experiments
Requires-Dist: hydra-core; extra == "experiments"
Requires-Dist: gymnasium==1.2.1; extra == "experiments"
Requires-Dist: numpy==2.2.6; extra == "experiments"
Requires-Dist: pandas==2.3.2; extra == "experiments"
Requires-Dist: matplotlib==3.9.4; extra == "experiments"
Requires-Dist: seaborn==0.13.2; extra == "experiments"
Requires-Dist: wandb; extra == "experiments"
Requires-Dist: stable-baselines3[extra]==2.7.0; extra == "experiments"
Requires-Dist: rliable; extra == "experiments"
Provides-Extra: sb3
Requires-Dist: gymnasium>=1.2.1; extra == "sb3"
Requires-Dist: stable-baselines3[extra]>=2.7.0; extra == "sb3"
Provides-Extra: torchrl
Requires-Dist: gymnasium>=1.2.1; extra == "torchrl"
Requires-Dist: torchrl; extra == "torchrl"
Provides-Extra: pettingzoo
Requires-Dist: gymnasium>=1.2.1; extra == "pettingzoo"
Requires-Dist: pettingzoo; extra == "pettingzoo"
Dynamic: license-file

<p align="center">
    <a href="./docs/images/logo_lm.png#gh-light-mode-only">
        <img src="./docs/source/_static/img/logo_lm.png#gh-light-mode-only" alt="FluidGym Logo" width="50%"/>
    </a>
    <a href="./docs/images/logo_dm.png#gh-dark-mode-only">
        <img src="./docs/source/_static/img/logo_dm.png#gh-dark-mode-only" alt="FluidGym Logo" width="50%"/>
    </a>
</p>

<table style="border-collapse: collapse; border: none;">
  <tr>
    <td style="border: none; padding: 0;">
      <img src="docs/build/html/_static/img/gifs/cylinder.gif" style="max-width: 100%; height: auto;" />
    </td>
    <td style="border: none; padding: 0;">
      <img src="docs/build/html/_static/img/gifs/rbc.gif" style="max-width: 100%; height: auto;" />
    </td>
    <td style="border: none; padding: 0;">
      <img src="docs/build/html/_static/img/gifs/airfoil.gif" style="max-width: 100%; height: auto;" />
    </td>
    <td style="border: none; padding: 0;">
      <img src="docs/build/html/_static/img/gifs/tcf.gif" style="max-width: 100%; height: auto;" />
    </td>
  </tr>
</table>

<div align="center">

[![PyPI version](https://badge.fury.io/py/fluidgym.svg)](https://badge.fury.io/py/fluidgym)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fluidgym)
![PyTorch](https://img.shields.io/badge/PyTorch-2.9-EE4C2C?logo=pytorch&logoColor=white)
![CUDA](https://img.shields.io/badge/CUDA-12.8-%2376B900)
![License](https://img.shields.io/badge/License-MIT-orange)
[![Linters](https://github.com/safe-autonomous-systems/fluidgym/actions/workflows/linters.yml/badge.svg?branch=main)](https://github.com/safe-autonomous-systems/fluidgym/actions/workflows/linters.yml)
    
</div>

<div align="center">
    <h3>
      <a href="#-installation">Installation</a> |
      <a href="#-getting-started">Getting Started</a> |
      <a href="https://safe-autonomous-systems.github.io/fluidgym">Documentation</a> | 
      <a href="https://arxiv.org/abs/2601.15015">Paper</a> |
      <a href="#-license-&-citation">License & Citation</a>
    </h3>
</div>

---

## Key Features

- **Standalone, GPU-accelerated fluid dynamics** implemented fully in PyTorch — no external CFD solvers required.
- **Fully differentiable environments**, enabling both reinforcement learning and gradient-based control methods.
- **Gymnasium-like API** with seamless integration into common RL frameworks.
- **Standardized benchmarks** with fixed train/validation/test splits for fair and reproducible evaluation.
- **Diverse AFC environments** (2D & 3D) with multiple difficulty levels, covering different regimes.
- **Single-agent and multi-agent support** for centralized and decentralized control.
- **Reference baselines and experiments** provided for widely used RL algorithms PPO and SAC.

### Models & Data
- **All trained models** are publicly available on [HuggingFace](https://huggingface.co/collections/safe-autonomous-systems/fluidgym-benchmark-models).
- **Complete training and test datasets** with results for all experimental runs are released for transparent comparison and reproducibility via our [HuggingFace dataset](https://huggingface.co/datasets/safe-autonomous-systems/fluidgym-experiments).

---

## Introducing FluidGym v0.1

We are happy to announce that FluidGym v0.1 comes with many updates and 
improvements, mainly focusing on more convenient usage and integration with RL 
frameworks:

- **Unified SARL and MARL interface**: Previously, MARL environments implemented public 
```reset_marl()``` and ```step_marl()``` functions. These have been removed and directly
integrated with the ```reset()``` and ```step()``` functions. When creating an 
environemtn via ```fluidgym.make()```, you can now pass a ```use_marl=True``` flag, to
enable MARL and use the ```reset()``` and ```step()``` as before. The only difference is
that they now return a batch of observations and rewards. This has also been updated for
the integrations with PettingZoo and SB3.
- **Gymnasium spaces**: ```FluidEnv``` now has ```action_space``` and 
```observation_space``` attributes consistent with ```gymnasium```. Additionally, the 
previous flattened observations have been replaced by ```Dict``` observation space
containing indivdual fields, such as as velocity and pressure fields, as indivual keys.
Furthermore, the indivual observations are now shaped according to the spatial structure
of the sensors, enabling the use of methods that leverage the spatial structure of the
domain, e.g. CNNs, equivariant networks, etc.
- **Environment wrappers**: Following the new observation spaces, we introduce 
```FluidWrappers```, namely ```FlattenObservation```, ```ObsExtraction```, 
```ActionNoise```, and ```SensorNoise```. The general wrapper interface enables easy
integration of new wrappers as needed.
- **Parallelization**: Using the new ```FluidEnvLike``` protocol, the 
```ParallelFluidEnv``` can now seamlessly be used with all FluidGym wrappers and 
integration wrappers. We updated the example to show how you can use FluidGym across
multiple GPUs.

**Important**: The ```FlattenObservation``` ensure direct compatiblity with our models
on HuggingFace (trained with FluidGym v0.0.2). If you want to use the models, make sure
to install the FluidGym v0.0.2 or use the ```FlattenObservation``` wrapper. In case you
encounter any issues, please report these via an Issue on GitHub. Thank you!

---

## Installation

### 📦 Installation from PyPi

1. Ensure the correct PyTorch version is installed (compatible with CUDA 12.8):
```bash
pip install torch --index-url https://download.pytorch.org/whl/cu128
```

2. Install 

```bash
pip install fluidgym
```

### 🐳 Using Docker

Instead of installing FluidGym you can use one of our Docker containers:

- [fluidgym-runtime](https://hub.docker.com/repository/docker/becktepe/fluidgym-runtime) for running FluidGym
- [fluidgym-devel](https://hub.docker.com/repository/docker/becktepe/fluidgym-devel) for development

Both containers come with the following Miniconda environments:
- ```py310```: Python 3.10
- ```py311```: Python 3.11
- ```py312```: Python 3.12
- ```py313```: Python 3.13

Start the containers with:
```bash
docker run -it --gpus all fluidgym-runtime bash
docker run -it --gpus all fluidgym-devel bash
```

### 🧱 Build from Source

1. Create a new conda environment and activate it:
```bash
conda create -n fluidgym python=3.10
conda activate fluidgym
```

2. Install gcc:
```bash
conda install pip "gcc_linux-64>=6.0,<=11.5" "gxx_linux-64>=6.0,<=11.5"
```

3. Install the latest Pytorch for CUDA 12.8 via pip:
```bash
pip install torch --index-url https://download.pytorch.org/whl/cu128
```

4. Install the matching cuda toolkit via conda:
```bash
conda install cuda-toolkit=12.8 -c nvidia/label/cuda-12.8.1
```

5. Clone the repository and enter the directory, then compile the custom CUDA kernels and install the package (this might take several minutes):
```bash
make install
```

## Getting Started

For an easy start refer to our [documentation](https://safe-autonomous-systems.github.io/fluidgym/) and the [`examples`](examples) directory.
FluidGym provides a ```gymnasium```-like interface that can be used as follows:

```python
import fluidgym

env = fluidgym.make(
    "CylinderJet2D-easy-v0",
)
obs, info = env.reset(seed=42)

for _ in range(50):
    action = env.sample_action()
    obs, reward, term, trunc, info = env.step(action)
    env.render()

    if term or trunc:
        break
```

## License & Citation

This repository is published under the MIT license. If you use FliudGym in your work, please cite us:

```bibtex
@misc{becktepe-fluidgym26,
      title={Plug-and-Play Benchmarking of Reinforcement Learning Algorithms for Large-Scale Flow Control}, 
      author={Jannis Becktepe and Aleksandra Franz and Nils Thuerey and Sebastian Peitz},
      year={2026},
      eprint={2601.15015},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2601.15015}, 
      note={GitHub: https://github.com/safe-autonomous-systems/fluidgym}, 
}
```
