hydrogym
hydrogym copied to clipboard
Pinball Render Fails
Having trouble rendering the Pinball environment (hydrogym==0.1.2.1). Example code for reproducibility and error below. It appears the issue is that FlowConfig is trying to reference self.flow.<attr>. The easiest solution is probably just to replace self.flow.<attr> with self.<attr> in the pinball FlowConfig render() function.
import firedrake as fd
import firedrake_adjoint as fda
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from ufl import dx, inner
import hydrogym.firedrake as hgym
env_config = {
"flow": hgym.Pinball,
"solver": hgym.IPCS,
}
env = hgym.FlowEnv(env_config)
env.reset()
env.render()
Output:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In [1], line 18
15 env = hgym.FlowEnv(env_config)
17 env.reset()
---> 18 env.render()
File /home/firedrake/firedrake/lib/python3.10/site-packages/hydrogym/core.py:355, in FlowEnv.render(self, mode, **kwargs)
354 def render(self, mode="human", **kwargs):
--> 355 self.flow.render(mode=mode, **kwargs)
File /home/firedrake/firedrake/lib/python3.10/site-packages/hydrogym/firedrake/envs/pinball/flow.py:107, in Pinball.render(self, mode, clim, levels, cmap, **kwargs)
105 if levels is None:
106 levels = np.linspace(*clim, 10)
--> 107 vort = fd.project(fd.curl(self.flow.u), self.flow.pressure_space)
108 im = fd.tricontourf(
109 vort,
110 cmap=cmap,
(...)
115 **kwargs,
116 )
118 for (x0, y0) in zip(self.flow.x0, self.flow.y0):
AttributeError: 'Pinball' object has no attribute 'flow'