Skip to content

Commit

Permalink
Merge main into working branch for PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
ludgerpaehler committed Oct 27, 2024
2 parents d8db8ad + 8698bf0 commit ad9e144
Show file tree
Hide file tree
Showing 19 changed files with 217 additions and 1,463,605 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.msh filter=lfs diff=lfs merge=lfs -text
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ need to _separately_ ensure the solver backend is installed (again, currently al
Alternatively (and this is important for large-scale RL training), the core Hydrogym package can (or will soon be able to) launch reinforcement learning training on a Ray-cluster without an underlying Firedrake install.
For more information and suggested approaches see the [Installation Docs](https://hydrogym.readthedocs.io/en/latest/installation.html).

To add HydroGym to an existing Firedrake installation, and install from the repository, run:

```bash
git clone https://github.com/dynamicslab/hydrogym.git
cd hydrogym
pip install .
```

As the mesh files are stored in [git large file storage](https://git-lfs.github.com/), you will need to install git-lfs
to download the mesh files.

```bash
git lfs install && git lfs fetch --all
```

At which point you are ready to run HydroGym locally.

# Quickstart Guide

Having installed Hydrogym into our virtual environment experimenting with Hydrogym is as easy as starting the Python interpreter
Expand Down
13 changes: 3 additions & 10 deletions examples/cylinder/pressure-probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,8 @@
mesh = "medium"
method = "BDF"

# Configure pressure probes - evenly spaced around the cylinder
# n_probes = 8
# R = 0.5
# probes = [(R * np.cos(theta), R * np.sin(theta))
# for theta in np.linspace(0, 2 * np.pi, n_probes, endpoint=False)]

observation_type = "velocity_probes"

# Velocity probes
observation_type = "velocity_probes"
xp = np.linspace(1.0, 10.0, 16)
yp = np.linspace(-2.0, 2.0, 4)
X, Y = np.meshgrid(xp, yp)
Expand All @@ -39,7 +32,7 @@
Re=100,
mesh=mesh,
velocity_order=velocity_order,
observation_type=observation_type,
observation_type="vorticity_probes",
probes=probes,
)

Expand Down Expand Up @@ -82,7 +75,7 @@ def controller(t, y):
callbacks=callbacks,
method=method,
stabilization=stabilization,
# controller=controller,
# controller=controller, --> TODO: This needs to be done in a more principled fashion
)

data = np.loadtxt(data_file)
Expand Down
15 changes: 3 additions & 12 deletions hydrogym/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class PDEBase(metaclass=abc.ABCMeta):
DEFAULT_MESH = ""
DEFAULT_DT = np.inf

# Timescale used to smooth inputs
# (should be less than any meaningful timescale of the system)
# Timescale used to smooth inputs (should be less than any meaningful timescale of the system)
TAU = 0.0

StateType = TypeVar("StateType")
Expand Down Expand Up @@ -359,7 +358,7 @@ def step(self, iter: int, control: Iterable[float] = None, **kwargs):
"""
raise NotImplementedError

def reset(self, t=0.0):
def reset(self):
"""Reset variables for the timestepper"""
self.t = 0.0

Expand Down Expand Up @@ -497,16 +496,8 @@ def check_complete(self):

def reset(self, t=0.0) -> Union[ArrayLike, Tuple[ArrayLike, dict]]:
self.iter = 0
self.t = 0.

if self.restart_ckpts is not None:
ckpt_index = np.random.randint(0, len(self.restart_ckpts))
self.flow.load_checkpoint(self.restart_ckpts[ckpt_index])
# print("Loaded ckeckpoint:", self.restart_ckpts[ckpt_index], flush=True)

self.flow.reset(q0=self.flow.copy_state() if self.restart_ckpts is not None else self.q0)
self.flow.reset(q0=self.q0, t=t)
self.solver.reset()
info = {}

return self.flow.get_observations(), info

Expand Down
Loading

0 comments on commit ad9e144

Please sign in to comment.