Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Ig-dolci committed Jun 19, 2024
1 parent a6aec14 commit b317169
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tests/firedrake_adjoint/test_optimisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
from firedrake.adjoint import *


# def test_optimisation_constant_control():
# """This tests a list of controls in a minimisation (through scipy L-BFGS-B)"""
# mesh = UnitSquareMesh(1, 1)
# R = FunctionSpace(mesh, "R", 0)
def test_optimisation_constant_control():
"""This tests a list of controls in a minimisation (through scipy L-BFGS-B)"""
mesh = UnitSquareMesh(1, 1)
R = FunctionSpace(mesh, "R", 0)

# n = 3
# x = [Function(R) for i in range(n)]
# c = [Control(xi) for xi in x]
n = 3
x = [Function(R) for i in range(n)]
c = [Control(xi) for xi in x]

# # Rosenbrock function https://en.wikipedia.org/wiki/Rosenbrock_function
# # with minimum at x = (1, 1, 1, ...)
# f = sum(100*(x[i+1] - x[i]**2)**2 + (1 - x[i])**2 for i in range(n-1))
# Rosenbrock function https://en.wikipedia.org/wiki/Rosenbrock_function
# with minimum at x = (1, 1, 1, ...)
f = sum(100*(x[i+1] - x[i]**2)**2 + (1 - x[i])**2 for i in range(n-1))

# J = assemble(f * dx(domain=mesh))
# rf = ReducedFunctional(J, c)
# result = minimize(rf)
# assert_allclose([float(xi) for xi in result], 1., rtol=1e-4)
J = assemble(f * dx(domain=mesh))
rf = ReducedFunctional(J, c)
result = minimize(rf)
assert_allclose([float(xi) for xi in result], 1., rtol=1e-4)


def _simple_helmholz_model(V, source):
Expand Down

0 comments on commit b317169

Please sign in to comment.