Optimal heat problem yields zero control and crashes

Asked by Peter Maday

Hi

Using the following reference (https://gist.github.com/funsim/5769594) implementation of the 2D heat optimal control problem the obtained solution is shown to be a uniform zero control followed by the apparent crash of the program ("glibc detected *** python: corrupted double-linked list").

I am using Fenics 1.2 on Ubuntu 12.04 with the latest dolfin-adjoint (1.2.0-0~839~ubuntu12.04.1) version from the launchpad PPA.

My question is if dolfin-adjoint is developed with an earlier version of Fenics in mind, or what other reason might there be for this behavior? (several similar crashes occur during other examples as well)

Thanks!

-----------------------------------------------------------------------------------------
#2D heat optimal control problem

from dolfin import *
from dolfin_adjoint import *

mesh = RectangleMesh(-1, -1, 1, 1, 20, 20)
V = FunctionSpace(mesh, "CG", 1)
u = Function(V, name="State")
m = Function(V, name="Control")
v = TestFunction(V)

F = (inner(grad(u), grad(v)) - m*v)*dx
bc = DirichletBC(V, 0.0, "on_boundary")
solve(F == 0, u, bc)

u_desired = Expression("exp(-1/(1-x[0]*x[0])-1/(1-x[1]*x[1]))")

J = Functional((0.5*inner(u-u_desired, u-u_desired))*dx)

reduced_functional = ReducedFunctional(J, SteadyParameter(m))
m_opt = minimize(reduced_functional, method = "L-BFGS-B", bounds =(0.0,0.5),
options = {"gtol": 1e-12,"ftol": 1e-12,"disp": True})

proj_error = project(u-u_desired,V)

save_file = File("optim_heat.pvd")

# desire solution
proj_udes = project(u_desired,V)
plot(u_desired, mesh, interactive=True, title="Desired")
# Actual solution
solve(F == 0, u, bc)
plot(u, interactive=True, title="Actual")
# L1 error
proj_error = project(u-u_desired,V)
plot(proj_error, interactive=True, title="L1-Error")
# Optimal forcing
plot(m_opt, interactive=True, title="Control")

Question information

Language:
English Edit question
Status:
Solved
For:
dolfin-adjoint Edit question
Assignee:
No assignee Edit question
Solved by:
Simon Funke
Solved:
Last query:
Last reply:
Revision history for this message
Simon Funke (simon-funke) said :
#1

Hi Peter,

I tried the code on my laptop and it runs without crashing (Ubuntu 13.04 + dolfin 1.2 + up to date dolfin-adjoint).
Can you please send me the full stachtrace of the crash?

You might want to make sure you have a recent installation of scipy installed. You should be able to install it with "pip install scipy"

Best wishes,

Simon

Revision history for this message
Best Simon Funke (simon-funke) said :
#2

Regarding the "zero control" issue, I fixed that just now in the dolfin_adjoint trunk. The Ubuntu packages should be automatically build over night. I also updated your gist code accordingly.

Revision history for this message
Peter Maday (madapeti) said :
#3

Thanks Simon Funke, that solved my question.