Convergence test don't run for an Initial Condition Parameter
Hi,
I'm struggling in running the convergence test in the case of an initial condition parameter. I took as a clear example the tutorial4.py; instead of having nu as a parameter, I have ic, the initial state. It always get the same answer: w{0} has no entry (w{0} is the name of my initial parameter).
What can I do to correct my code?
Thank you for any advice.
Emmanuel
from dolfin import *
from dolfin_adjoint import *
n = 30
mesh = UnitInterval(n)
V = FunctionSpace(mesh, "CG", 2)
def main(ic):
nu = Constant(0.0001)
u = Function(ic)
u_next = Function(V)
v = TestFunction(V)
timestep = Constant(1.0/n)
F = ((u_next - u)/timestep*v
+ u_next*
+ nu*grad(
bc = DirichletBC(V, 0.0, "on_boundary")
t = 0.0
end = 0.2
while (t <= end):
solve(F == 0, u_next, bc)
u.assign(
t += float(timestep)
return u
if __name__ == "__main__":
ic = project(
u = main(ic)
dtm=TimeMeasure()
J = Functional(inner(u, u)*dx*dtm[
dJdnu = compute_gradient(J, InitialConditio
Jnu = assemble(inner(u, u)*dx) # current value
parameters[
def Jhat(nu): # the functional as a pure function of nu
u = main(nu)
return assemble(inner(u, u)*dx)
conv_rate = taylor_test(Jhat, InitialConditio
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Patrick Farrell
- Solved:
- Last query:
- Last reply:
This question was originally filed as bug #1043231.