Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ig-dolci committed Jun 3, 2024
1 parent e5a01b0 commit d9ca94e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/firedrake_adjoint/test_shape_derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_shape_hessian():
s = Function(S,name="deform")

mesh.coordinates.assign(mesh.coordinates + s)
J = assemble(sin(x[1])* dx(domain=mesh))
J = assemble(cos(x[1])* dx(domain=mesh))
c = Control(s)
Jhat = ReducedFunctional(J, c)

Expand All @@ -83,11 +83,12 @@ def test_shape_hessian():

# Second order taylor
dJdm = assemble(inner(Jhat.derivative(), h)*dx)
Hm = compute_hessian(J, c, h).vector().inner(h.vector())
Hm = assemble(inner(compute_hessian(J, c, h), h)*dx)
r2 = taylor_test(Jhat, s, h, dJdm=dJdm, Hm=Hm)
print(r2)
assert(r2 > 2.9)
Jhat(s)
dJdmm_exact = derivative(derivative(sin(x[1])* dx(domain=mesh),x,h), x, h)
dJdmm_exact = derivative(derivative(cos(x[1]) * dx(domain=mesh), x, h), x, h)
assert(np.isclose(assemble(dJdmm_exact), Hm))


Expand Down

0 comments on commit d9ca94e

Please sign in to comment.