Tutorials
Active-flow-control (AFC) environments developed using the Gym-preCICE adapter.
Install / Use
/learn @gymprecice/TutorialsREADME
Gym-preCICE Tutorials
This repository contains ready-to-run tutorial cases that use the Gym-preCICE adapter. These tutorials can be used as a foundation for creating similar control cases.
To define new control cases, you need to follow a simple file structure with three key components:
new-control-problem
├── <controller-script-name>.py
├── environment.py
└── physics-simulation-engine
├── gymprecice-config.json
├── precice-config.json
├── solver-1
├── solver-2
├── ...
└── solver-n
physics-simulation-engine: is a directory containing PDE-based solver case(s),gymprecice-config.jsonfile for the adapter configuration, andprecice-config.xmlfile for configuring the preCICE coupling library.environment.py: is a Python script defining a class inherited from Gym-preCICE adapter to expose the underlying behaviour of the physics-simulation-engine to the controller.<controller-script-name>.py: is a Python script defining the controller algorithm that interacts with the environment. This may, for instance, be the Proximal Policy Optimisation (PPO) algorithm, the Soft-Actor-Critic (SAC) algorithm, or a simple sinusoidal signal control.
To run the control case, you need to switch to the root directory of the control case, here, new-control-problem, and run
python3 -u <controller-script-name>.py
By default, the output will be saved in a directory called gymprecice-run that is located in the root directory of the control case. However, it is possible to specify a different path for the result directory via gymprecice-config.json file.
Please refer to the tutorial cases and extract the relevant sections that you require for your new control cases.
Run a tutorial
To begin running the tutorial cases, it is necessary to have gymprecice installed beforehand.
To make sure you can successfully run the tutorials, you need to install some example-specific requirements:
-
The tutorials within
closed-loopdirectory rely onOpenFOAMCFD solvers andOpenFOAM-preCICE adapter. Please follow the instructions here to install these dependencies. -
The tutorials within
open-loopdirectory, in addition to OpenFOAM CFD solvers and OpenFOAM-preCICE adapter, rely ondeal.IIsolid solvers anddeal.II-preCICE adapter. Please follow the instructions here to install these dependencies.
Please check out the Quickstart to follow running a control case step by step.
Further instructions
The tutorials and gymprecice were tested on specific version of preCICE, OpenFOAM and OpenFOAM-preCICE adapter on Ubuntu 20.04.6 LTS
preCICEwas installed using
wget https://github.com/precice/precice/releases/download/v2.5.0/libprecice2_2.5.0_focal.deb
sudo apt install ./libprecice2_2.5.0_focal.deb
OpenFOAMwas installed using
curl https://dl.openfoam.com/add-debian-repo.sh | sudo bash
sudo apt-get install openfoam2112-default
followed by adding source /usr/lib/openfoam/openfoam2112/etc/bashrc to the .bashrc file or .zshrc
OpenFOAM-preCICE adapterwas installed locally (without sudo) using
wget https://github.com/precice/openfoam-adapter/releases/download/v1.1.0/openfoam-adapter_v1.1.0_OpenFOAMv1812-v2112-newer.tar.gz
tar -xzvf openfoam-adapter_v1.1.0_OpenFOAMv1812-v2112-newer.tar.gz
cd openfoam-adapter_v1.1.0_OpenFOAMv1812-v2112-newer
./Allwmake
cd ..
Citing Us
If you use Gym-preCICE, please cite the following paper:
@misc{shams2023gymprecice,
title={Gym-preCICE: Reinforcement learning environments for active flow control},
author={Shams, Mosayeb and Elsheikh, Ahmed H},
journal={SoftwareX},
volume={23},
pages={101446},
year={2023},
issn={2352-7110},
doi={https://doi.org/10.1016/j.softx.2023.101446},
eprint={https://arxiv.org/abs/2305.02033},
}
Contributing
See the contributing guidelines CONTRIBUTING.md for information on submitting issues and pull requests.
The Team
Gym-preCICE and its tutorials are primarily developed and maintained by:
- Mosayeb Shams (@mosayebshams) - Lead Developer (Heriot-Watt University)
- Ahmed H. Elsheikh(@ahmed-h-elsheikh) - Co-developer and Supervisor (Heriot-Watt University)
Acknowledgements
This work was supported by the Engineering and Physical Sciences Research Council grants number EP/V048899/1 and EP/Y006143/1.
License
Gym-preCICE and its tutorials are MIT licensed.
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
flutter-tutor
Flutter Learning Tutor Guide You are a friendly computer science tutor specializing in Flutter development. Your role is to guide the student through learning Flutter step by step, not to provide d
groundhog
398Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
last30days-skill
16.9kAI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
