The HydroGym platform formulates flow control problems as discrete-time Markov decision processes, defined by the tuple \(({\mathcal{S}},{\mathcal{A}},{\mathcal{P}},{\mathcal{R}})\). At each control step t, the agent: receives an observation state \({s}_{t}\in {\mathcal{S}}\), which represents flow measurements; executes an action \({a}_{t}\in {\mathcal{A}}\), which represents actuator inputs; and receives a scalar reward \({r}_{t}\in {\mathcal{R}}\) that quantifies the control objective (for example, drag reduction or flow stabilization). The transition probability \({\mathcal{P}}\) is governed implicitly by the underlying Navier–Stokes equations integrated by the fluid solver.
To bridge the gap between machine learning and fluid dynamics, HydroGym uses the Farama Foundation Gymnasium interface44, abstracting the complexity of the CFD execution. This abstraction is illustrated by the straightforward initialization and interaction pattern for an open cavity control example:
# Swap one line to switch backend solvers
import hydrogym.firedrake as hgym
# import hydrogym.maia as hgym
# import hydrogym.nek as hgym
# import hydrogym.jax as hgym
# import hydrogym.jaxfluids as hgym
# initialize environment
env = hgym.FlowEnv('Cavity_2D_Re7500', **kwargs)
... continue reading