Presentation is loading. Please wait.

Presentation is loading. Please wait.

Indo-European network on Advanced Instability Methods Sensitivity and Adjoint operators: a simple matlab example (the discrete adjoint approach)‏

Similar presentations


Presentation on theme: "Indo-European network on Advanced Instability Methods Sensitivity and Adjoint operators: a simple matlab example (the discrete adjoint approach)‏"— Presentation transcript:

1 Indo-European network on Advanced Instability Methods Sensitivity and Adjoint operators: a simple matlab example (the discrete adjoint approach)‏

2 Indo-European network on Advanced Instability Methods Adjoint operator If is a scalar product and A is a linear operator we define the adjoint of A as the operator A + satisfying = for every choice of u and v. If A is a matrix from the definition we have that A + = A t so that the adjoint operator coincides with the transpose. 2

3 Indo-European network on Advanced Instability Methods Numerical Approach To Adjoint Computations: continuous approach 3 Direct Continuous Problem Discretize [A - σ B]  q = 0 Direct Discrete Problem Generalized Eigenvalue Problem q direct eigenvector Direct Continuous Problem Discretize [C – σ B]  z = 0 Discrete Adjoint Problem: Generalized Eigenvalue Problem z adjoint eigenvector Generalized Green’s identity

4 Indo-European network on Advanced Instability Methods Numerical Approach To Adjoint Computations: discrete approach 4 Direct Continuous Problem Discretize [A - σ B]  q = 0 Direct Discrete Problem Generalized Eigenvalue Problem q direct eigenvector Adjoint of discrete problem Direct Continuous Problem z  [A - σ B] = 0 Discrete Adjoint Problem: The adjoint eigvec z is the left eigvec of the direct problem Generalized Green’s identity

5 Indo-European network on Advanced Instability Methods Advantages of discrete adjoint approach The discrete approach have several advantages over the continuous approach. For example  You do not need to derive the continuous adjoint equations using the generalized Green’s theorem (tedious !!!!)‏  The boundary conditions for the adjoint field (which in the continuous approach must be carefully chosen ) are automatically taken into account in the discrete approach. (easy implementation !!!)‏  In the generalized eigenvalue problem the bi-orthogonality conditions between the direct and the adjoint eigenvectors are satisfied to machine precision 5

6 Indo-European network on Advanced Instability Methods Suppose we have the following PDE With boundary and conditions given by Suppose we are interested in evaluating where k(x) is a given function and u(x,T) is the solution at time t=T. Question: How does change with the initial condition ? Answer: 6 A simple example

7 Indo-European network on Advanced Instability Methods The quantity is the sensitivity of with respect to the initial conditions. For a problem with many degree of freedom a convenient way to evaluate the sensitivity is to use the adjoint equations which can be obtained by integrating by parts: A simpe example: integration by part 7 If v(1,t)=v(0,t)=0

8 Indo-European network on Advanced Instability Methods A simple example: the continuous adjoint equation 8 The adjoint equation for the problem is therefore defined as This is a parabolic PDE which must be marched backward in time! = Direct Equation 0 = Adjoint Equation 0 Taking now the initial condition for the adjoint as We obtain

9 Indo-European network on Advanced Instability Methods A simple example: discretization of the direct problem So the variation of of due to a variation in the initial conditions can be expressed as so that the sensitivity previously introduced is given by Let now solve the problem numerically. We start with the following simple discretization of the equation 9

10 Indo-European network on Advanced Instability Methods Example of Matlab Program function [unew]=March(n,m,uold,a,Re,dx,dt)‏ unew=uold; rhs=zeros(n+1,1); for k=1:m+1 uold=unew; A=BuildMat(n,Re,dx,dt); rhs=BuildRhs(n,uold,a,dx,dt); unew=Solve(A,rhs); end 10

11 Indo-European network on Advanced Instability Methods Example: building the adjoint code Direct Initialize var1 Sub1(var1,var2) Sub2(var2,var3)‏ Sub3(var3,var4)‏ Sub4(var5,var6)‏ Solution=var6 11 Adjoint Solution = avar1 AdjSub1(avar1,avar2)‏ AdjSub2(avar2,avar3)‏ AdjSub3(avar3,avar4)‏ AdjSub4(avar5,avar6)‏ Initialize avar6 input --------- output --------- The program that solves the direct equation (marching) is a sequence of linear operations which are executed in a given order. If we want to solve the adjoint equation we have to derive the adjoint of our direct code. This can be done by writing down the adjoint of each direct subroutine (which performs a linear operation between the input and the output) and then calling them in a reversed sequence.

12 Indo-European network on Advanced Instability Methods A simple example: the adjoint of a given subroutine I Sub1(var1,var2) var2=M  var1 End Sub1 12 AdjSub1(avar1,avar2)‏ avar1=M t  avar2 End AdjSub1 Each subroutine performs a linear operation between the input and the output and can be represented through the action of a matrix M. In a real code, however, this operation can be implemented through a complicated sequence of operations and loops. So care must be taken in deriving the correct calling sequence of operations in the adjoint subroutine which gives the correct results.

13 Indo-European network on Advanced Instability Methods A simple example: testing the adjoint subroutine 13 Considering that each subroutine performs a linear operation we can use the definition of the adjoint to test our adjoint subroutine. In fact giving two random values to var1 and avar2 and calling the direct and adjoint subroutine the following identity must be satisfied to machine precision =


Download ppt "Indo-European network on Advanced Instability Methods Sensitivity and Adjoint operators: a simple matlab example (the discrete adjoint approach)‏"

Similar presentations


Ads by Google