Skip to content

Commit

Permalink
Merge pull request #105 from dynamicslab/sa/bug-fix-Oct23
Browse files Browse the repository at this point in the history
Sa/bug fix oct23
  • Loading branch information
ludgerpaehler authored Nov 10, 2023
2 parents 38826f4 + 1c2625d commit ae22586
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions hydrogym/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def render(self, **kwargs):
"""Plot the current PDE state (called by `gym.Env`)"""
raise NotImplementedError


'''
@ray.remote
class EvaluationActor:
Expand All @@ -215,7 +215,7 @@ def __init__(self, firedrake_instance: "Firedrake_instance", index: int, seeds:
# Add whole class and the two following to have the evaluation logic.
# Pipe Firedrake problem into Evotorch's harness, then simmer down the logic needed to have this
# code here running.

'''

class CallbackBase:
def __init__(self, interval: int = 1):
Expand Down
4 changes: 2 additions & 2 deletions hydrogym/firedrake/envs/cylinder/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import ufl
from firedrake import ds
from ufl import as_vector, atan_2, cos, dot, sign, sin, sqrt
from ufl import as_vector, atan2, cos, dot, sign, sin, sqrt

from hydrogym.firedrake import DampedActuator, FlowConfig

Expand Down Expand Up @@ -37,7 +37,7 @@ def initialize_state(self):
self.U_inf = fd.Constant((1.0, 0.0))

# Set up tangential boundaries to cylinder
theta = atan_2(ufl.real(self.y), ufl.real(self.x)) # Angle from origin
theta = atan2(ufl.real(self.y), ufl.real(self.x)) # Angle from origin
self.rad = fd.Constant(0.5)
self.u_ctrl = [
ufl.as_tensor((self.rad * sin(theta), self.rad * cos(theta)))
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 @@ -6,7 +6,7 @@
import numpy as np
import ufl
from firedrake import ds
from ufl import atan_2, cos, dot, sin
from ufl import atan2, cos, dot, sin

from hydrogym.firedrake import DampedActuator, FlowConfig

Expand Down Expand Up @@ -42,7 +42,7 @@ def initialize_state(self):
self.rad = fd.Constant(self.rad)
self.u_ctrl = []
for cyl_idx in range(len(self.CYLINDER)):
theta = atan_2(
theta = atan2(
ufl.real(self.y - self.y0[cyl_idx]), ufl.real(self.x - self.x0[cyl_idx])
) # Angle from center of cylinder

Expand Down
2 changes: 1 addition & 1 deletion hydrogym/firedrake/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def control_vec(self, mixed=False):

# Control as Function
B.append(
fd.assemble(inner(fd.Constant((0, 0)), v) * dx, bcs=self.collect_bcs())
fd.assemble(inner(fd.Constant((0, 0)), v) * dx, bcs=self.collect_bcs()).riesz_representation(riesz_map = 'l2')
)

# Have to have mixed function space for computing B functions
Expand Down
4 changes: 3 additions & 1 deletion hydrogym/firedrake/solver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import firedrake as fd
import numpy as np
from firedrake import logging
from ufl import div, dot, ds, dx, inner, lhs, nabla_grad, rhs
from ufl import div, dot, ds, dx, inner, lhs, nabla_grad, rhs, as_ufl

import ufl

from hydrogym.core import TransientSolver

Expand Down
4 changes: 2 additions & 2 deletions test/test_cyl.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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 +57,7 @@ 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 ae22586

Please sign in to comment.