-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Begin updating tests to see where the API currently fails. * Add cautionary comment to dissuade users from using the pip package for now. * Update patching branch (#153) * Update docker_development.rst * Automatically launch the virtual environment, and install the editable version of HydroGym into it. * Remove the unused Icepack install, which messes with pip's ability to resolve package versions. * Add dedicated subpage to document the testing of HydroGym for package developers. * Adjust the list of authors to the more generic HydroGym Developers as authors * Bug fix, @nzolman, closes #122 * Fix `bcs` kwarg (#123) * Update conf.py * Update requirements.txt Add sphinx-book-theme * Update quickstart.rst * Update index.rst * Create basics.rst * Update index.rst * Complete refactoring of the docs. * Add in the glossary * Fix pinball BCs * Fix formatting * Fix warnings related to firedrake changes * [WIP] testing BDF/EXT3 solver * Schur complement preconditioning * Schur complement preconditioning * Add BDF to supported solvers * Common base class for firedrake transient solvers * Update pinball env * Update cavity and step * Minor actuator interface changes * Cleanup example script * Fix h5_file -> restart * Add benchmarking script to cavity * P1-P1 working, tuning constants * Set velocity order in flow config * Fix SUPG UFL form * Add GLS * Tested pinball * Tested on pinball * Fix checkpoint loading * Tested step w/ random forcing * Support stabilization in steady-state solver * P1-P1 working, tuning constants * Set velocity order in flow config * Fix SUPG UFL form * Add GLS * Tested pinball * Tested on pinball * Support stabilization in steady-state solver * P1-P1 working, tuning constants * Fix SUPG UFL form * Support stabilization in steady-state solver * Set BDF/GLS/P1P1 to be the defaults * Restore defaults to Taylor-Hood * ZNMF jet actuation for cylinder (#141) * Jet control for cylinder * Jet control for cylinder * Fix defaults for cylinder * Updated PD examples with rotary cylinder * Update hydrogym/firedrake/envs/cylinder/flow.py * Remove PD control example changes (unrelated) * Updates to Step environment (#149) * Helmholtz eigenvalue problem example * [WIP] testing direct stability on cylinder * Link to old code with working SLEPc call * Derive linear control term * Simple test problems for KS algorithm * Testing moving step forcing from solver to flow * Use simple discrete-time filter instead of ActuatorBase * Tested Step w/ forcing * Clean up old forcing code * update_actuation -> advance_time * Updated unsteady.py example script * black * Untrack stability analysis files * Configurable observation space for cylinder (#142) * Configurable observation space for cylinder * Configurable observation space for cylinder * Finish vel/pres probe implementation * Undo changes to examples/ * Add example script * Make probes available to all envs * linting * Remove coarse meshes (#150) * Support loading checkpoint from different function space (#151) * Remove IPCS solver (#152) * Remove IPCS solver * Fix import issues * Remove mixed= kwarg wherever possible * Update PD control example (#143) * Jet control for cylinder * Fix defaults for cylinder * Updated PD examples with rotary cylinder * Update hydrogym/firedrake/envs/cylinder/flow.py * Add bilinear filter for derivative (untested) * Support different filter types * Add and test filtered derivative estimate * Jet control for cylinder * Fix defaults for cylinder * Updated PD examples with rotary cylinder * Update hydrogym/firedrake/envs/cylinder/flow.py * Add bilinear filter for derivative (untested) * Support different filter types * Add and test filtered derivative estimate * Run pre-commit * Clean up phase sweep script * Begin showing the changes respected by Black. * Fix black error. --------- Co-authored-by: Ludger Paehler <[email protected]> --------- Co-authored-by: Jared Callaham <[email protected]> Co-authored-by: Jared Callaham <[email protected]> Co-authored-by: cl126162 <[email protected]> * Move PD controller out to the utilities. * Fix up cylinder tests. * Fix the pinball tests. * Move gradient tests out to dedicated test files. * Begin patching of the tests. * Clean up comments in file. * Render method fixes. * No need to add the velocity order. * Add Readme for the docs. * Fix the tests for the step environment. * Fix most tests, cavity fails on the nonlinear iteration. * Restructure the solver, added stabilization, but still getting solver errors. * Default stabilization change fixed it. * Together with @jcallaham changed the broken default stabilization. * Ruff fixes. * Ruff definitions patch * Fully connect the control test. * Fix last open test. * Reformat tests with black. --------- Co-authored-by: Jared Callaham <[email protected]> Co-authored-by: Jared Callaham <[email protected]> Co-authored-by: cl126162 <[email protected]>
- Loading branch information
1 parent
3af9167
commit f919eba
Showing
23 changed files
with
364 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import os | ||
|
||
import psutil | ||
|
||
import hydrogym.firedrake as hgym | ||
|
||
output_dir = "output" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
"""Simulate step function input at Re=40""" | ||
|
||
import os | ||
|
||
import hydrogym.firedrake as hgym | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Testing of HydroGym | ||
|
||
## Quick-Start | ||
|
||
To run HydroGym's tests one best pulls the `HydroGym-Env` [docker container](https://hub.docker.com/repository/docker/lpaehler/hydrogym-env/general): | ||
|
||
```bash | ||
docker pull lpaehler/hydrogym-env:stable | ||
``` | ||
|
||
and then launches the VSCode Devcontainer into it. At that point one has Firedrake, and | ||
all its dependencies pre-installed. One then needs to activate the virtualenv at the | ||
command line with | ||
|
||
```bash | ||
source /home/firedrake/firedrake/bin/activate | ||
``` | ||
|
||
Install HydroGym | ||
|
||
```bash | ||
pip install . | ||
``` | ||
|
||
And is then set up to run the tests. | ||
|
||
## Running Tests | ||
|
||
```bash | ||
cd test && python -m pytest test_pinball.py | ||
``` | ||
|
||
or to run all tests | ||
|
||
```bash | ||
python -m pytest . | ||
``` | ||
|
||
> The gradient tests are currently not run, and are to be run at your own risk. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,61 @@ | ||
import firedrake_adjoint as fda | ||
from ufl import sin | ||
import pytest | ||
|
||
import hydrogym.firedrake as hgym | ||
|
||
|
||
def test_import_coarse(): | ||
hgym.Cavity(mesh="coarse") | ||
|
||
|
||
def test_import_medium(): | ||
hgym.Cavity(mesh="medium") | ||
hgym.Cavity(Re=500, mesh="medium") | ||
|
||
|
||
def test_import_fine(): | ||
hgym.Cavity(mesh="fine") | ||
|
||
|
||
def test_steady(): | ||
flow = hgym.Cavity(Re=50, mesh="coarse") | ||
|
||
flow = hgym.Cavity(Re=50, mesh="medium") | ||
solver = hgym.NewtonSolver(flow) | ||
solver.solve() | ||
|
||
|
||
def test_steady_actuation(): | ||
flow = hgym.Cavity(Re=50, mesh="coarse") | ||
flow = hgym.Cavity(Re=50, mesh="medium") | ||
flow.set_control(1.0) | ||
|
||
solver = hgym.NewtonSolver(flow) | ||
solver.solve() | ||
|
||
|
||
def test_integrate(): | ||
flow = hgym.Cavity(Re=50, mesh="coarse") | ||
flow = hgym.Cavity(Re=50, mesh="medium") | ||
dt = 1e-4 | ||
|
||
hgym.integrate(flow, t_span=(0, 10 * dt), dt=dt) | ||
hgym.integrate( | ||
flow, | ||
t_span=(0, 2 * dt), | ||
dt=dt, | ||
# stabilization="gls" | ||
) | ||
|
||
|
||
def test_control(): | ||
flow = hgym.Cavity(Re=50, mesh="coarse") | ||
flow = hgym.Cavity(Re=50, mesh="medium") | ||
dt = 1e-4 | ||
|
||
solver = hgym.IPCS(flow, dt=dt) | ||
solver = hgym.SemiImplicitBDF(flow, dt=dt) | ||
|
||
num_steps = 10 | ||
for iter in range(num_steps): | ||
flow.get_observations() | ||
flow = solver.step(iter, control=0.1 * sin(solver.t)) | ||
flow = solver.step(iter, control=0.1 * sin(iter * solver.dt)) | ||
|
||
|
||
def test_env(): | ||
env_config = { | ||
"flow": hgym.Cavity, | ||
"flow_config": {"mesh": "coarse", "Re": 10}, | ||
"solver": hgym.IPCS, | ||
"flow_config": {"mesh": "medium", "Re": 10}, | ||
"solver": hgym.SemiImplicitBDF, | ||
} | ||
env = hgym.FlowEnv(env_config) | ||
|
||
for _ in range(10): | ||
y, reward, done, info = env.step(0.1 * sin(env.solver.t)) | ||
|
||
|
||
def test_grad(): | ||
flow = hgym.Cavity(Re=50, mesh="coarse") | ||
|
||
c = fda.AdjFloat(0.0) | ||
flow.set_control(c) | ||
|
||
solver = hgym.NewtonSolver(flow) | ||
solver.solve() | ||
|
||
(y,) = flow.get_observations() | ||
|
||
dy = fda.compute_gradient(y, fda.Control(c)) | ||
|
||
print(dy) | ||
assert abs(dy) > 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
test_import_medium() | ||
for i in range(10): | ||
y, reward, done, info = env.step(0.1 * sin(i * env.solver.dt)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import firedrake_adjoint as fda | ||
from ufl import sin | ||
import pytest | ||
|
||
import hydrogym.firedrake as hgym | ||
|
||
|
||
def test_grad(): | ||
flow = hgym.Cavity(Re=50, mesh="medium") | ||
|
||
c = fda.AdjFloat(0.0) | ||
flow.set_control(c) | ||
|
||
solver = hgym.NewtonSolver(flow) | ||
solver.solve() | ||
|
||
(y,) = flow.get_observations() | ||
|
||
dy = fda.compute_gradient(y, fda.Control(c)) | ||
|
||
print(dy) | ||
assert abs(dy) > 0 |
Oops, something went wrong.