Sie sind auf Seite 1von 44

Adjoint Method Explained

Sarka Tukova

Adjoint Method Explained p. 1

Structure of the talk


Motivation Example Forward and Adjoint Limitations Store or Recalculate Continuous or Discrete?

Adjoint Method Explained p. 2

Motivation - Sensitivity Analysis


Main objective: to quantify the effects of parameter variations on calculated results Results in assessment of: inuence importance dominance Methods used: forward sensitivity - tangent linear model reverse sensitivity - adjoint model other
Adjoint Method Explained p. 3

Motivation - Other
The adjoint model can also be used for: Error estimation Data assimilation - nding model solutions to best t given data Calibration of model to data Optimisation

Adjoint Method Explained p. 4

General Method
Dene the model equation(s)

Adjoint Method Explained p. 5

General Method
Dene the model equation(s)

Dene the cost function(s)

Adjoint Method Explained p. 5

General Method
Dene the model equation(s)

Dene the cost function(s)

Derive the adjoint equation(s)

Adjoint Method Explained p. 5

Example - Model Equation


Navier-Stokes Equations:
u + (u )u + f k u = p g k + t

Adjoint Method Explained p. 6

Example - Model Equation


Navier-Stokes Equations:
u + (u )u + f k u = p g k + t

First two terms from 1D Navier-Stokes Equation:


u u u u +u =0 F (u, , , m) = F (u, ut , ux , m) = t x t x

Adjoint Method Explained p. 6

Example - Cost Function


Choose a cost function according to what you would like to test. Here we will consider a cost function in a general form:
J=
t

j (x, u, m)dxdt

where m are the control input variables.

Adjoint Method Explained p. 7

Example - Euler-Lagrange Method


To derive the adjoint equation we use the Euler-Lagrange method:

Adjoint Method Explained p. 8

Example - Euler-Lagrange Method


To derive the adjoint equation we use the Euler-Lagrange method: Construct the Lagrange functional from the weak form of Navier-Stokes equations and the cost function:
L(x, u, m) = J (x, u, m) +
t

F u dxdt

where u is the adjoint variable - independent of m!

Adjoint Method Explained p. 8

Example - Differentiating
The sensitivity of the model to the control input variables, m, is found by differentiating L with respect to m:

Adjoint Method Explained p. 9

Example - Differentiating
The sensitivity of the model to the control input variables, m, is found by differentiating L with respect to m:
dL(x, u, m) dJ (x, u, m) = + dm dm dF (u, ut , ux , m) u dxdt dm

Adjoint Method Explained p. 9

Example - Differentiating
The sensitivity of the model to the control input variables, m, is found by differentiating L with respect to m:
dL(x, u, m) dJ (x, u, m) = + dm dm dJ = dm dj dxdt = dm dF (u, ut , ux , m) u dxdt dm jm + ju um dxdt
t

Adjoint Method Explained p. 9

Example - Differentiating
The sensitivity of the model to the control input variables, m, is found by differentiating L with respect to m:
dL(x, u, m) dJ (x, u, m) = + dm dm dJ = dm dj dxdt = dm dF (u, ut , ux , m) u dxdt dm jm + ju um dxdt
t

dF u dxdt = dm

(Fm + Fu um + Fut utm + Fux uxm )u dxdt


t

Adjoint Method Explained p. 9

Example - Integration by Parts


dF u dxdt = dm (Fm + Fu um + Fut utm + Fux uxm )u dxdt
t

Adjoint Method Explained p. 10

Example - Integration by Parts


dF u dxdt = dm (Fm + Fu um + Fut utm + Fux uxm )u dxdt
t

Fut utm u dxdt =


t

[Fut um u ]T 0 dx
t

(Fut u )t um dxdt (Fux u )x um dxdt


t

Fux uxm u dxdt =


t t

Fux um u dldt

Adjoint Method Explained p. 10

Example - Bringing All Together


Hence:
t

dF u dxdt dm

=
t

{Fm u um (Fu u (Fut u )t (Fux u )x )}dxdt

Adjoint Method Explained p. 11

Example - Bringing All Together


Hence:
t

dF u dxdt dm

=
t

{Fm u um (Fu u (Fut u )t (Fux u )x )}dxdt +

[Fut um u ]T 0 dx

Adjoint Method Explained p. 11

Example - Bringing All Together


Hence:
t

dF u dxdt dm

=
t

{Fm u um (Fu u (Fut u )t (Fux u )x )}dxdt +

[Fut um u ]T 0 dx Fux um u dldt


t

Adjoint Method Explained p. 11

Example - Dening the Adjoint Equation


Remember the gradient of the augmented cost function:
dL(x, u, m) dJ (x, u, m) = + dm dm dF (u, ut , ux , m) u dxdt dm

Adjoint Method Explained p. 12

Example - Dening the Adjoint Equation


Remember the gradient of the augmented cost function:
dL(x, u, m) dJ (x, u, m) = + dm dm dF (u, ut , ux , m) u dxdt dm

This now becomes:


dL = dm {Fm u um (Fu u (Fut u )t (Fux u )x ju )+jm }dxdt
t

Adjoint Method Explained p. 12

Example - Dening the Adjoint Equation


Remember the gradient of the augmented cost function:
dL(x, u, m) dJ (x, u, m) = + dm dm dF (u, ut , ux , m) u dxdt dm

This now becomes:


dL = dm {Fm u um (Fu u (Fut u )t (Fux u )x ju )+jm }dxdt
t

[Fut um u ]T 0 dx Fux um u dldt


t

Adjoint Method Explained p. 12

Example - Boundary and Initial Conds


Recall the last two terms:
[Fut um u ]T 0 dx

Fux um u dldt
t

Adjoint Method Explained p. 13

Example - Boundary and Initial Conds


Recall the last two terms:
[Fut um u ]T 0 dx

Fux um u dldt
t

The BCs should be set such that ux = 0 on the boundary. In general these two terms are treated through setting of the appropriate boundary and initial conditions and will be set aside for the rest of the derivation.

Adjoint Method Explained p. 13

Example - Adjoint Equations


This leaves us with:
dL = dm {Fm u um (Fu u (Fut u )t (Fux u )x ju )+jm }dxdt
t

Adjoint Method Explained p. 14

Example - Adjoint Equations


This leaves us with:
dL = dm {Fm u um (Fu u (Fut u )t (Fux u )x ju )+jm }dxdt
t

We now dene the adjoint equation as follows:


Fu u (Fut u )t (Fux u )x = ju

Adjoint Method Explained p. 14

Example - Adjoint Equations


This leaves us with:
dL = dm {Fm u um (Fu u (Fut u )t (Fux u )x ju )+jm }dxdt
t

We now dene the adjoint equation as follows:


Fu u (Fut u )t (Fux u )x = ju

Hence the sensitivity of our model simplies to:


dL = dm (Fm u + jm )dxdt
t

Adjoint Method Explained p. 14

Example - Adjoint Equations


We chose the following form of F for our example:
u u F = +u t x

Adjoint Method Explained p. 15

Example - Adjoint Equations


We chose the following form of F for our example:
u u F = +u t x

Substituting for F in the adjoint equation:


Fu u (Fut u )t (Fux u )x = ju

gives:
u u u u j u u u = x t x x u u u j u = t x u
Adjoint Method Explained p. 15

Forward Sensitivity
The forward sensitivity equation is derived by differentiating F with respect to m:
dF F F u F ut F ux = + + + dm m u m ut x ux m

Adjoint Method Explained p. 16

Forward and Adjoint


Forward sensitivity: shows the development of the initial perturbations of input variables needs to be evaluated for every parameter perturbation we choose to analyse

Adjoint Method Explained p. 17

Forward and Adjoint


Forward sensitivity: shows the development of the initial perturbations of input variables needs to be evaluated for every parameter perturbation we choose to analyse Adjoint sensitivity: nds the source of a specic anomaly does NOT model physical quantities models the sensitivity of a property to these quantities

Adjoint Method Explained p. 17

Tangent linear vs Adjoint


Adjoint: efciently computes sensitivity of a model with a large number of sensitivity parameters and few objective/cost functions simulates the development of sensitivities backwards in time can nd origins of any anomaly Tangent linear: efciently computes sensitivity of a model with relatively few parameters or a large number of objective/cost functions simulates the development of perturbations with time
Adjoint Method Explained p. 18

Limitations
underlying functions non-differentiable in ocean models: sub grid processes often formulated in a non-differentiable way

Adjoint Method Explained p. 19

Limitations
underlying functions non-differentiable in ocean models: sub grid processes often formulated in a non-differentiable way based on linear approximation sensitivities for nonlinear models only valid at a certain point in phase space sensitivities for highly nonlinear (or chaotic) models might change rapidly with varying point of linearization > useless results!

Adjoint Method Explained p. 19

Adjoint methods - store or recalculate?


Relies on ability to efciently store or recompute the simulation in the forward direction store all the data from the forward model re-run the entire model whenever the forward solution is needed store a subset of data and develop interpolation schemes checkpointing

Adjoint Method Explained p. 20

Continuous or Discrete?
Continuous: Nonlinear PDE - Linear PDE - Linear adjoint PDE - discrete adjoint Discrete: Nonlinear PDE - Nonlinear discrete PDE - Linear discrete equations - discrete adjoint equation

Adjoint Method Explained p. 21

Continuous or Discrete?
Advantages of continuous derivation: highlights the physical signicance of adjoint variables in boundary condition cheaper to derive than discrete method adaptive mesh models are naturally consistent with the adjoint equations - easier to implement

Adjoint Method Explained p. 22

Continuous or Discrete?
Advantages of continuous derivation: highlights the physical signicance of adjoint variables in boundary condition cheaper to derive than discrete method adaptive mesh models are naturally consistent with the adjoint equations - easier to implement Advantages of discrete derivation: obtains exact gradient to discrete objective function, optimisation/sensitivity converges fully conceptually straight forward to create program

Adjoint Method Explained p. 22

Continuous or Discrete?
Disadvantages of continuous derivation: possible problems with implementation of boundary conditions - can cause the adjoint models to become inadmissible for the chosen cost function the optimization/sensitivity might not converge

Adjoint Method Explained p. 23

Continuous or Discrete?
Disadvantages of continuous derivation: possible problems with implementation of boundary conditions - can cause the adjoint models to become inadmissible for the chosen cost function the optimization/sensitivity might not converge Disadvantages of discrete derivation: code is long inefcient

Adjoint Method Explained p. 23

THE END

Adjoint Method Explained p. 24

Das könnte Ihnen auch gefallen