Hello Mr. Dokken,

I have attached the minimal code that gives me the error for line search. In the below code, I am trying to minimize my function ( `(1-|d|)**2*W(y)`

) WRT two variables (`y, d`

).

```
from dolfin import *
from dolfin_adjoint import *
import moola
mesh = RectangleMesh(Point(-1,-1),Point(1,1), 20, 20)
V = VectorFunctionSpace(mesh, "CG", 1)
dy, dd = TrialFunction(V), TrialFunction(V)
vy, vd = TestFunction(V), TestFunction(V)
y, d = Function(V), Function(V)
def bottom(x, on_boundary):
return x[1] < -1 + DOLFIN_EPS and on_boundary
def top(x, on_boundary):
return x[1] > 1 - DOLFIN_EPS and on_boundary
load1 = Expression(("x[0]","x[1] - t"), t=0.05, degree=1)
load2 = Expression(("x[0]","x[1] + t"), t=0.05, degree=1)
bcs1_y = DirichletBC(V, load1, bottom)
bcs2_y = DirichletBC(V, load2, top)
bcs_y = [bcs1_y, bcs2_y]
y_assign = Expression(("x[0]", "x[1]"), degree=1)
y.assign(project(y_assign, V)) #initial guess
bcs1_d = DirichletBC(V, Constant((0.0, 0.0)), bottom)
bcs2_d = DirichletBC(V, Constant((1, 1)), top)
bcs_d = [bcs1_d, bcs2_d]
d_assign = Constant((0.5, 0.5))
d.assign(project(d_assign, V)) #initial guess
def W(y):
F = grad(y)
return 0.5*tr(F.T*F) + (det(F)-1)**2 -ln(det(F)) # strain energy density (compressible Mooney-Rivlin)
vy, vd = project(y, V, bcs=bcs_y), project(d, V, bcs=bcs_d)
J = assemble( (1-dot(vd,vd)**0.5)**2*W(vy)*dx )
m1, m2 = Control(y), Control(d)
J_hat = ReducedFunctional(J, [m1, m2])
m_opt = minimize(J_hat, method = "L-BFGS-B",\
options = {"gtol": 1e-6, "ftol": 1e-16, "maxfun": 30000, "maxiter": 30000, "maxls": 200})
J_hat(m_opt)
y_opt, d_opt = m_opt[0], m_opt[1]
```

Thank you so much!