split of adjoint solution

Asked by Lyuda Vynnytska

Hi,
I'd like to know if "split" works for the adjoint solution also. I tried to use in mantle-convection example

(ua, Ta) = split(adjoint)

ValueError: need more than 1 value to unpack

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
dolfin-adjoint Edit question
Assignee:
No assignee Edit question
Solved by:
Patrick Farrell
Solved:
Last query:
Last reply:
Revision history for this message
Best Patrick Farrell (pefarrell) said :
#1

Hi Lyuda,

a) Adjoint solutions always live in the same function space as the original forward solutions. So the adjoint velocity-pressure lives in the MixedFunctionSpace for velocity-pressure, the adjoint temperature lives in the temperature function space, etc.

b) The adjoint solutions are computed in reverse order, i.e. from bottom to top in the HTML visualisation (which is dumped as adjoint.html).

c) Take a look at the adjoint computation loop:

  for (adjoint, var) in compute_adjoint(J, forget=False):
    pass

At the end of that loop, the variable "adjoint" will be the adjoint variable corresponding to whatever was the first variable in the annotation.

d) If you look at the annotation and dig around a bit, the first thing annotated is the initial condition for temperature. (This is far more obvious when you give things names, as I've done in the latest trunk, r446).

e) So, by the above, the "adjoint" variable at the end of that loop is the adjoint temperature, which lives in the temperature function space, and so cannot be split.

f) Now, if you want the adjoint solution for velocity-pressure (which I assume you do, since you're trying to split something), update to r446 and modify the loop to do the following:

   J = Functional(-(1.0/Nu2)*grad(Tfinal)[1]*ds2*dt[FINISH_TIME])
   for (adjoint, var) in compute_adjoint(J, forget=False):
- pass
+ if var.name == "InitialVelocity":
+ (adj_u, adj_p) = split(adjoint)

then adj_u and adj_p will be the adjoint velocity and pressure corresponding to the initial velocity guess computed in compute_initial_conditions.

Hope this helps!

Patrick

Revision history for this message
Lyuda Vynnytska (lyudav) said :
#2

Thanks Patrick Farrell, that solved my question.