Multiple tangent linear evaluations
Dear Patrick, Simon or other dolfin-adjoint developer,
I have been trying to run the tangent linear model several times for different parameter values but have gotten a 0 vector on the second run. Between the tlm evals I would like to evaluate the forward model as I am doing an optimization and I need to check convergence.
Is there a way to adjust the script below so it computes the right value on the second tlm evaluation? It works if the second forward run is disabled, but it is unfortunatly necessary for my application (non linear least squares optimization of Cardiac mechanics).
Cheers,
Gabriel
"""
Implementation of Burger's equation with nonlinear solve in each
timestep
"""
import sys
from dolfin import *
from dolfin_adjoint import *
n = 4
mesh = UnitIntervalMesh(n)
V = FunctionSpace(mesh, "CG", 2)
def Dt(u, u_, timestep):
return (u - u_)/timestep
def main(ic, annotate=False):
u_ = Function(ic, name="Velocity")
u = Function(V, name="VelocityN
v = TestFunction(V)
nu = Constant(0.0001)
timestep = Constant(1.0/n)
F = (Dt(u, u_, timestep)*v
+ u*u.dx(0)*v + nu*u.dx(
bc = DirichletBC(V, 0.0, "on_boundary")
t = 0.0
end = 0.2
while (t <= end):
solve(F == 0, u, bc, annotate=annotate)
t += float(timestep)
return u_, nu
if __name__ == "__main__":
ic = project(
forward, nu = main(ic, annotate=True)
print "First tlm run"
for val, var in compute_
if val: print val.vector(
forward, nu = main(ic, annotate=False)
print "Second tlm run"
nu.
for val, var in compute_
if val: print val.vector(
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Patrick Farrell
- Solved:
- Last query:
- Last reply: