Skip to content

Commit

Permalink
Reformat to make black happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
ludgerpaehler committed Nov 26, 2023
1 parent 759f738 commit 2b5efe3
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
5 changes: 2 additions & 3 deletions examples/cavity/rllib/ppo_train.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Modified from https://github.com/ray-project/ray/blob/master/rllib/examples/custom_env.py
import os

import ray

# from common import *
Expand All @@ -23,9 +24,7 @@

# Can also register the env creator function explicitly with:
# register_env("corridor", lambda config: SimpleCorridor(config))
ModelCatalog.register_custom_model(
"cav_actor", TorchCustomModel
)
ModelCatalog.register_custom_model("cav_actor", TorchCustomModel)

# Set up the printing callback
log = hydrogym.io.LogCallback(
Expand Down
2 changes: 1 addition & 1 deletion examples/cavity/solve-steady.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
dof = flow.mixed_space.dim()
hgym.print(f"Total dof: {dof} --- dof/rank: {int(dof/fd.COMM_WORLD.size)}")

for (i, Re) in enumerate(Re_init):
for i, Re in enumerate(Re_init):
flow.Re.assign(Re)
hgym.print(f"Steady solve at Re={Re_init[i]}")
solver = hgym.NewtonSolver(flow, solver_parameters=solver_parameters)
Expand Down
2 changes: 1 addition & 1 deletion examples/cavity/unsteady.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# ramp to get the steady state
Re_init = [500, 1000, 2000, 4000, Re]

for (i, Re) in enumerate(Re_init):
for i, Re in enumerate(Re_init):
flow.Re.assign(Re)
hgym.print(f"Steady solve at Re={Re_init[i]}")
solver = hgym.NewtonSolver(flow, solver_parameters=solver_parameters)
Expand Down
2 changes: 1 addition & 1 deletion examples/step/solve-steady.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
dof = flow.mixed_space.dim()
hgym.print(f"Total dof: {dof} --- dof/rank: {int(dof/fd.COMM_WORLD.size)}")

for (i, Re) in enumerate(Re_init):
for i, Re in enumerate(Re_init):
flow.Re.assign(Re)
hgym.print(f"Steady solve at Re={Re_init[i]}")
solver = hgym.NewtonSolver(flow, solver_parameters=solver_parameters)
Expand Down
2 changes: 1 addition & 1 deletion examples/step/unsteady.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# ramp to get the steady state
Re_init = np.arange(100, Re + 100, 100, dtype=float)

for (i, Re) in enumerate(Re_init):
for i, Re in enumerate(Re_init):
flow.Re.assign(Re)
hgym.print(f"Steady solve at Re={Re_init[i]}")
solver = hgym.NewtonSolver(flow, solver_parameters=solver_parameters)
Expand Down
4 changes: 2 additions & 2 deletions hydrogym/firedrake/envs/pinball/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Pinball(FlowConfig):
y0 = [0.0, 0.5 * rad, -0.5 * rad]

ACT_DIM = len(CYLINDER)
OBS_DIM = 2 * len(CYLINDER) # [CL, CD] for each cyliner
OBS_DIM = 2 * len(CYLINDER) # [CL, CD] for each cyliner
MAX_CONTROL = 0.5 * np.pi
TAU = 1.0 # TODO: Tune this based on vortex shedding period
I_CM = 1.0 # Moment of inertia
Expand Down Expand Up @@ -120,6 +120,6 @@ def render(self, mode="human", clim=None, levels=None, cmap="RdBu", **kwargs):
**kwargs,
)

for (x0, y0) in zip(self.flow.x0, self.flow.y0):
for x0, y0 in zip(self.flow.x0, self.flow.y0):
cyl = plt.Circle((x0, y0), self.flow.rad, edgecolor="k", facecolor="gray")
im.axes.add_artist(cyl)
9 changes: 4 additions & 5 deletions hydrogym/firedrake/solver.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import firedrake as fd
import numpy as np
from firedrake import logging
from ufl import div, dot, ds, dx, inner, lhs, nabla_grad, rhs, as_ufl

import ufl
from firedrake import logging
from ufl import as_ufl, div, dot, ds, dx, inner, lhs, nabla_grad, rhs

from hydrogym.core import TransientSolver

Expand Down Expand Up @@ -185,7 +184,7 @@ def step(self, iter, control=None):
self.predictor.solve()
if control is not None:
control = self.flow.update_actuators(control, self.dt)
for (B, ctrl) in zip(self.B, control):
for B, ctrl in zip(self.B, control):
Bu, _ = B.split()
self.u += Bu * fd.Constant(ctrl)

Expand Down Expand Up @@ -303,7 +302,7 @@ def rmatvec(q_vec):
N = q.vector().size()
A = LinearOperator(shape=(N, N), matvec=lmatvec, rmatvec=rmatvec)
B = np.zeros((N, len(self.B)))
for (i, Bi) in enumerate(self.B):
for i, Bi in enumerate(self.B):
B[:, i] = get_array(Bi)
return A, B

Expand Down
2 changes: 1 addition & 1 deletion hydrogym/firedrake/utils/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def pod(
# Save for visualization
if pvd_dest is not None:
pvd = fd.File(f"{output_dir}/{pvd_dest}", "w")
for (i, mode) in enumerate(mode_handles):
for i, mode in enumerate(mode_handles):
u, p = mode.get().as_function().split()
pvd.write(u, p, flow.vorticity(u))

Expand Down
6 changes: 4 additions & 2 deletions test/test_cyl.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def test_steady_rotation(tol=1e-3):
assert abs(CL - 0.0594) < tol
assert abs(CD - 1.2852) < tol # Re = 100

'''

"""
def test_steady_grad():
flow = hgym.Cylinder(Re=100, mesh="coarse")
Expand All @@ -57,7 +58,8 @@ def test_steady_grad():
dJ = fda.compute_gradient(J, fda.Control(omega))
assert abs(dJ) > 0
'''
"""


def test_integrate():
flow = hgym.Cylinder(mesh="coarse")
Expand Down

0 comments on commit 2b5efe3

Please sign in to comment.