2009-06

36
MASTER’S THESIS Adjoint method in advection equation Zongyuan GU Department of Mathematical Sciences CHALMERS UNIVERSITY OF TECHNOLOGY GOTHENBURG UNIVERSITY Göteborg, Sweden 2009

Upload: kafung-lee

Post on 04-Dec-2015

215 views

Category:

Documents


0 download

DESCRIPTION

advetion equation

TRANSCRIPT

MASTER’S THESIS

Adjoint method in advection equation

Zongyuan GU

Department of Mathematical SciencesCHALMERS UNIVERSITY OF TECHNOLOGYGOTHENBURG UNIVERSITYGöteborg, Sweden 2009

Thesis for the Degree of Master of Science

Adjoint method in advection equation

Zongyuan GU

Department of Mathematical SciencesChalmers University of Technology and Gothenburg University

SE-412 96 Göteborg, SwedenGöteborg, September 2009

Mathematical SciencesGöteborg 2009

Abstract

This master thesis discuss the consistency of the discrete adjoint methods of differentnumerical schemes. Both linear (JST scheme) and non-linear(flux-limited scheme) aretested in 1D advection equation. This master thesis will show that the discrete adjointmethod may have inconsistency near the shock area. Both theoretical and numerical anal-ysis will be discussed in this thesis.

Acknowledgments

In the first place, I offer my sincerest gratitude to my supervisor in CERFACS(Toulouse,France), Marc MONTAGNAC, who has supported me throughout mythesis with his pa-tience and knowledge. Also, without his confidence in the conclusion, this thesis would nothave been finished. In my daily work , I gratefully acknowledge all members of the CFDgroup in CERFACS for their friendship and help.

I will also thank my examiner, Prof.Nils E M SVANSTEDT who review my thesis andgive me advice and suggestions.

I want to thank Chalmers University of Technology. It’s a wonderful place to study,I have learned a lot of mathematics and mechanics courses from Chalmers which will beused in my whole life I think.

Finally, I thank my parents for their love and support.

Contents

1 Background 41.1 Thesis Environment-CERFACS . . . . . . . . . . . . . . . . . . . . . . .41.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.3 Adjoint in Optimal Design . . . . . . . . . . . . . . . . . . . . . . . . . .51.4 Adjoint in Numerical Error Analysis . . . . . . . . . . . . . . . . .. . . . 6

2 Adjoint Operator 72.1 L2 Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2 General problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.3 Existence and uniqueness . . . . . . . . . . . . . . . . . . . . . . . . . .. 92.4 Numerical approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.5 Continuous adjoint equation for 1D advection equation .. . . . . . . . . . 11

3 Discrete adjoint scheme 123.1 Discrete time term scheme . . . . . . . . . . . . . . . . . . . . . . . . . .123.2 Discrete upwind term scheme . . . . . . . . . . . . . . . . . . . . . . . .. 133.3 Discrete centered term . . . . . . . . . . . . . . . . . . . . . . . . . . . .153.4 General form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.5 Discrete flux-limited scheme . . . . . . . . . . . . . . . . . . . . . . .. . 163.6 Discrete JST scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4 Numerical Simulation 234.1 Flux limited scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234.2 JST scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

5 Conclusion and future work 29

Bibliography 30

A Matlab Code for Advection Equation 31A.1 initfunc.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31A.2 limiter.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31A.3 forward.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

3

1 Background

1.1 Thesis Environment-CERFACS

CERFACS1 is a research organization that aims to develop advanced methods for thenumerical simulation and the algorithmic solution of largescientific and technologicalproblems of interest for research as well as industry, and that requires access to the mostpowerful computers presently available.

CERFACS has seven shareholders (CNES, the French Space Agency; EADS France,European Aeronautic and Defence Space Company; EDF, Electricité de France; Météo-France, the French meteorological service; ONERA, the French Aerospace Lab; SAFRAN,an international high-technology group, TOTAL, a multinational energy company).

CERFACS hosts interdisciplinary teams, both for research and advanced training thatare comprised of: physicists, applied mathematicians, numerical analysts, and softwareengineers.

Approximately 110 people work at CERFACS, including more than 90 researchers andengineers, coming from 10 different countries. They work onspecific projects in sevenmain research areas: parallel algorithms, code coupling, aerodynamics, combustion, cli-mate and environment, data assimilation, and electromagnetism.

This master project is to give the mathematical support in aerodynamics group.

1.2 Introduction

The use of the adjoint method has been become more and more popular in the lasttwenty years in the Computational Fluid Dynamics(CFD) community. The adjoint methodplays a critical role in optimal design problem, and was studied by Jameson [1] and An-derson [2]. For the control problem it was used by Jameson [3]and Jamesonet al. [4], andJohnson [5] studied the application of the adjoint method inerror control area. Besides,Daley [6] has developed the application of adjoint method innumerical weather prediction.In all the above study, the basic idea is to use the adjoint method to compute the sensitiv-ity(derivatives) of an objective function(cost function)with respect to the design problemvariables [8].The adjoint method, mathematically is dealing with the dualproblem instead of the orig-inal problem. In mathematics, specifically in functional analysis, each linear operator ona Hilbert space has a corresponding adjoint operator. Adjoint of operators generalize con-jugate transposes of square matrices to (possibly) infinite-dimensional situations. If onethinks of operators on a Hilbert space as "generalized complex numbers", then the adjointof an operator plays the role of the complex conjugate of a complex number.In this master thesis we focus on the behavior of the adjoint method in advection equation.We study the advection equation because it is simple and important. First, the mathematical

1http://www.cerfacs.fr/

4

form of the advection equation is quite simple so that we can apply and test different numer-ical schemes in both forward problem and adjoint problem easily. Second, the advectionequation is important. Advection, in chemistry and engineering, is a transport mechanismof a substance or a conserved property with a fluid in motion. The fluid motion in advec-tion is described mathematically as a vector field, and the material transported is typicallydescribed as a scalar concentration of substance, which is contained in the fluid. The ad-vection equation has the same form as a convection.In the first part of this thesis project, some applications ofthe adjoint method are presentedand discussed. There are two main applications of the adjoint method — optimal designand numerical error analysis. The industry community is most interested in the optimaldesign problem while academia focus on the numerical error analysis. In chapter 2 weintroduce shortly the main idea of adjoint methods and applythis to a one-dimensionaladvection equation.In the second part of this thesis project, the continuous adjoint and the discrete adjointmethod will be studied and then two schemes will be introduced — flux limited scheme andJST scheme. They both widely used in industry and in most commercial/non-commercialCFD codes like Fluent2, Ansys/CFX3 and OpenFOAM4. The adjoint method will be testedin both schemes with three different limiter functions. Thecontinuous adjoint method isthe analytical adjoint solution to the forward problem which is always true, but the discreteadjoint method is some kind of numerical approach to the adjoint solution. It is shownthat the discrete adjoint method is inconsistent with the continuous adjoint method in someshock area when using the flux-limited scheme, but it’s less inconsistent when using theJST scheme.

All the numerical codes are implemented in Matlab.

1.3 Adjoint in Optimal Design

Theoretical model of adjoint method can be found in Giles [9], from his paper we knowby using the adjoint model, that the derivative of the objective functionals can be formulatedin terms of the state of a model. Suppose we are given some nonlinear objective functionIh(Uh, α), whereUh is the discrete flow solution andα is initially a design variable, whichmay describe the lift or drag of the flow. We start from the residual equation in discreteform:

Rh(Uh, α) = 0. (1)

By differentiating the discrete residual equation with respect to the design variableα, weobtain,

∂Rh

∂Uh

dUh

dα+

∂Rh

∂α= 0. (2)

2http://www.fluent.com/3http://www.ansys.com/products/fluid-dynamics/cfx/4http://www.openfoam.org/

5

The termdUh/dα gives us the change inUh due to the change inα. Then we consider theobjective functionIh(Uh, α). Differenting again with respect toα, we obtain,

dIh

dα=

∂Ih

∂Uh

dUh

dα+

∂Ih

∂α

= −∂Ih

∂Uh(∂Rh

∂Uh)−1∂Rh

∂α+

∂Ih

∂α

= V Th

∂Rh

∂α+

∂Ih

∂α,

(3)

whereVh is the solution of the adjoint equation which has the same form as (2)

V Th = −

∂Ih

∂Uh(∂Rh

∂Uh)−1,

(∂Rh

∂Uh)T Vh + (

∂Ih

∂Uh)T = 0.

(4)

An advantage of the adjoint method in optimal design is that suppose we have a new designvariable, let’s sayβ, then the new derivative of the objective function with respect toβ issimply reads

dIh

dβ= V T

h

∂Rh

∂β+

∂Ih

∂β, (5)

with the same asVh above. So in order to calculate the new derivative of the objectivefunction, we just need to evaluate the term∂Rh/∂β and its dot product withVh, whichreduce the whole computation process.

1.4 Adjoint in Numerical Error Analysis

The other major application of the adjoint method is in the numerical error analysis inCFD. Like above section, suppose we have an objective function Ih(Uh, α) and a discreteforward solutionUh. We define the solution erroreh as

eh = Uh − U(xh), (6)

whereU(xh) is the analytical forward solution evaluated at the discrete mesh pointsxh.From the engineering view, linearizing the (1) gives

Rh(Uh) = Rh(U(xh)) +∂Rh

∂Uheh + O(|eh|) = 0

=⇒ Rh(U(xh)) +∂Rh

∂Uheh ≈ 0.

(7)

6

The first term of the above equation is called truncation error which is related with thediscrete residual operator and the analytical forward solution at discrete mesh points. Thenwe take a look at error of the objective functionI (e.g. lift or drag)

Ih(Uh) − I(U) = (Ih(Uh) − Ih(U(xh)))︸ ︷︷ ︸discrete error

+ (Ih(U(xh)) − I(U))︸ ︷︷ ︸truncation error

. (8)

The discrete error can be estimate as follows:

Ih(Uh) − Ih(U(xh)) ≈∂Ih

∂Uh

eh

= −∂Ih

∂Uh(∂Rh

∂Uh)−1Rh(U(xh))

= V Th Rh(U(xh)),

(9)

Now an interesting thing happens,V Th , the adjoint flow solution appears in the error for-

mula. This means that our error is related to the adjoint flow solution and the truncationerrors in the residuals.

This use of the adjoint method in CFD has been studied by Becker [7] at Heidelberg.In applications, the most important values from an engineering point of view are somecomputable objective functionals(integral) so the error analysis using adjoint method willbe focus studied.

2 Adjoint Operator

2.1 L2 Space

Definition Let D be a domain inRd with the boundary∂D, we define theLebesgue inte-gral as following:

ID(v) =

D

v dx

I∂D(v) =

∂D

v dS

(10)

with thenorm

‖v‖Lp= ‖v‖Lp(D) =

(∫

D|v|p dx)1/p 1 ≤ p ≤ ∞

ess supD |v| p = ∞(11)

The casep = 2 is particular. In this case the space is an inner product space, and hence aHilbert space, with respect to the inner product

(u, v)D =

D

u(x)v(x) dx

(u, v)∂D =

∂D

u(x)v(x) dS

(12)

7

2.2 General problem

We first assume that all the equations and the objective functionalI have been linearizedand define theprimal problem :

Determine I = (g, u)D + (h, Cu)∂D

subject to Lu = f in Dand Bu = e on ∂D

(13)

where theC, L andB are some partial differential operators acting onu. We also definethedual problem:

Determine I = (v, f)D + (C∗v, e)∂D

subject to L∗v = g in Dand B∗v = h on ∂D

(14)

where theC∗, L∗ andB∗ are some partial differential operators acting onv andu, v, e, f ,g andh are some functions. We now have to prove the equivalence between the primal anddual problem, i.e. that

(v, f)D + (C∗v, e)∂D = (v, Lu)D + (C∗v, Bu)∂D

= (L∗v, u)D + (B∗v, Cu)∂D

= (g, u)D + (h, Cu)∂D

The first and the last steps are obvious. What has to be shown isthat

(v, Lu)D + (C∗v, Bu)∂D = (L∗v, u)D + (B∗v, Cu)∂D (15)

holds for all admissibleu andv.For the first term in (15) an integration by parts gives us

(v, Lu)D = (L∗v, u)D + (A1v, A2u)∂D

Next we prove that there existence and unique operatorsB∗ andC∗ such that

(A1v, A2u)∂D = (B∗v, Cu)∂D − (C∗v, Bu)∂D. (16)

holds.For example, if we have an partial differential equation as

Lu :∂u

∂x= f x ∈ D (17)

in CFD optimal control we have some cost function like

I =

D

u2dx (18)

Then the dual problem of the above example reads

Determine I = (v, f)D

subject to L∗v : −∂v

∂x= c in D

(19)

8

2.3 Existence and uniqueness

With the definition of the inner product, the (16) reads∫

∂D

vT Au dA =

∂D

(B∗v)T Cu dA −

∂D

(C∗v)T Bu dA

To prove that the above equation holds for allu andv amounts to prove that

vT Au − (B∗v)T Cu + (C∗v)T Bu = 0 (20)

holds at each point on the boundary∂D which is equivalent to prove that

A − (B∗)T C + (C∗)T B = 0 (21)

We first construct a matricesF andF ∗ as

F =

(BC

), F ∗ =

(−C∗

B∗

).

Then (21) can be written as

A = (F ∗)T F. (22)

In this master thesis we only discuss the case whenF is non-singular which means that theoperatorF ∗ is defined by

F ∗ = (F−1)T AT . (23)

For the uniqueness, we suppose that there exists an operatorT ∗ such that

A = (T ∗)T F. (24)

By the non-singular assumption ofT we get

T ∗ = (F−1)T AT = F ∗. (25)

which show the uniqueness.

2.4 Numerical approach

There are two ways to approach the adjoint equation numerically as shown in figure(1).

• The discrete adjoint method:One discretize the forward equation numerically using somescheme first and thenusing the adjoint operator to derive the discrete adjoint equation.

9

Figure 1: two ways to derive the adjoint models

• The continuous adjoint method:One first using the adjoint operator on the forward equation to get the analytic adjointequation and then using the numerical scheme to discretize it.

The continuous adjoint method is always stable and consistent, now we want study the in-consistency of the discrete adjoint method under some schemes and show what causes thiskind of inconsistency in the discrete adjoint method.For the numerical scheme in order to derive the discrete equation we introduce a so-calledupwind scheme first. In CFD, upwind schemes denote a class of numerical discretizationmethods for solving hyperbolic partial differential equations. Upwind schemes use an adap-tive or solution-sensitive finite difference stencil to numerically simulate more properly thedirection of propagation of information in a flow field. The upwind schemes attempt to dis-cretize hyperbolic partial differential equations by using differences biased in the directiondetermined by the sign of the characteristic speeds.To illustrate the upwind method, consider the following one-dimensional linear advectionequation:

∂c

∂t+

∂(uc)

∂x= 0 (26)

Consider a typical grid pointi in the domain. In a one-dimensional domain, there are onlytwo directions associated with the pointi - left and right. Ifu is positive the left side iscalled upwind side and right side is the downwind side. Similarly, if u is negative theleft side is called downwind side and right side is the upwindside. If the finite differencescheme for the spatial derivative, contains more points in the upwind side, the scheme

10

is called an upwind-biased or simply an upwind scheme. Mathematically, the first orderupwind scheme for 1D advection equation can be written as:

∂(uc)i

∂x=

1

∆x(Ui−1Ci−1 − UiCi) Ui ≥ 0

1

∆x(UiCi − Ui+1Ci+1) Ui < 0

(27)

In this master thesis we also study two other commonly used schemes like the flux-limitedscheme and the JST scheme.

2.5 Continuous adjoint equation for 1D advection equation

In this master thesis we mainly focus on the 1D advection equation [12], which givesthe direct problem:

∂c

∂t+ ∇ · (f(c)) = 0, x ∈ Ω, t0 ≤ t ≤ tF ,

c(t0, x) = c0(x),

c(t, x) = cin(t, x) for x ∈ ∂Ωin,

(28)

where thec(t, x) is the forward solution in the domainΩ ∈ R, and∂Ωin the inflow part ofthe domain boundary. The∇· is divergence operator.Now suppose there is a design variable, parameterα, and the variation of the parameterdα,wherec depends onα.Then we have:

variation of f(c) : f(c) +∂f

∂c

dc

dαdα

variation of c : c +dc

dαdα

(29)

Thus the variation of the first order of the direct problem reads:

∂t[c +

dc

dαdα] + ∇ · [(f(c)) +

∂f

∂c

dc

dαdα] = 0

∂t[dc

dα] + ∇ · [

∂f

∂c

dc

dα] = 0 (30)

Let’s introduce the adjoint variableλT and multiply to (30). After integrating in timedomain and space domain we get

t

Ω

λT [∂

∂t(dc

dα) + ∇ · (

df

dc

dc

dα)] dΩdt = 0. (31)

11

We integrate by parts to get

t

Ω

λT ∂

∂t(dc

dα) dΩdt =

t

Ω

∂λT

∂t

dc

dαdΩdt −

Ω

λ(tF , x)∂c(tF , x)

dαdΩ

+

Ω

λ(t0, x)dc(t0, x)

dαdΩ.

(32)

t

Ω

λT∇ · (∂f

∂c

dc

dα) dΩdt =

t

Ω

(∂f

∂c)T · ∇λ

dc

dαdΩdt −

t

∂Ωin

λT ∂f

∂c

dc

dαdAdt

︸ ︷︷ ︸=0

t

∂Ωout

λT ∂f

∂c

dc

dαdAdt.

(33)

Now consider a cost functional that is defined in terms of the solution:

J =

∫ tF

t0

Ω

g(c(t, x))dxdt +

Ω

p(c(tF , x))dΩ. (34)

the variation of the above functional with the respect toα reads:

dJ

dα=

t

Ω

∂g

∂c

dc

dαdΩdt+

Ω

∂p

∂c

dc

dαdΩ−

t

Ω

λT [∂

∂t(dc

dα) + ∇ · (

df

dc

dc

dα)] dΩdt

︸ ︷︷ ︸=0

. (35)

the calculation ofdJ/dα must be independent ofdc/dα and comparing (31) with (33) weget the following adjoint problem:

∂λ

∂t+ (

∂f

∂c)T · ∇λ = −

∂g

∂c, x ∈ Ω, tF ≥ t ≥ t0

λ(tF , x) =∂p

∂c(tF , x), λ(t, x) = 0 for x ∈ Ωout,

(36)

Note that the adjoint (36) has a backward in time domain comparing to the forward problemand it is a linear non-conservative advection equation in the adjoint variableλ. The flowspeed is determined by the Jacobian of the flux function∂f/∂c, and therefore the wavespeed of the adjoint solution is the same as the wave speed in the forward solution butbackwards in time.

3 Discrete adjoint scheme

3.1 Discrete time term scheme

The time term in the forward problem reads:

∂Cj

∂t=

Cn+1j − Cn

j

∆t. (37)

12

We multiply byλ and integrate in the whole domain.

t

Ω

λ∂Cj

∂t=

J−1∑

j=2

N−1∑

n=1

λnj

Cn+1j − Cn

j

∆t∆x∆t

=J−1∑

j=2

1

∆t(N−1∑

n=1

λnj Cn+1

j −N−1∑

n=1

λnj Cn

j )∆x∆t

=

J−1∑

j=2

1

∆t(

N∑

n=2

λn−1j Cn

j −

N−1∑

n=1

λnj Cn

j )∆x∆t

=

J−1∑

j=2

N−1∑

n=1

λn−1j − λn

j

∆tCn

j ∆x∆t +

J−1∑

j=2

λN−1j CN

j ∆x

︸ ︷︷ ︸boundary term

(38)

So the discrete time term in the adjoint equation becomes:

∂λj

∂t=

λn−1j − λn

j

∆t(39)

This is again proves that the adjoint variable is backward intime domain.

3.2 Discrete upwind term scheme

The first order upwind scheme for the forward problem reads:

∂(uc)i

∂x=

1

∆x(Ui−1Ci−1 − UiCi) Ui ≥ 0

1

∆x(UiCi − Ui+1Ci+1) Ui < 0

(40)

written in a compact form as:

∂(uc)ni

∂x= −(a+)n

j

Cnj−1 − Cn

j

∆x+ (a−)n

j

Cnj+1 − Cn

j

∆x(41)

where(a+)i = max(Ui, 0) and(a−)i = min(Ui, 0), multiply by λnj and sum in the whole

domain we get:

J−1∑

j=2

N−1∑

n=1

λnj [−(a+)n

j

Cnj−1 − Cn

j

∆x︸ ︷︷ ︸I1

+ (a−)nj

Cnj+1 − Cn

j

∆x︸ ︷︷ ︸I2

]∆x∆t (42)

13

for the termI1 andI2 we have the followings:

I1 = −

J−1∑

j=2

N−1∑

n=1

λnj (a+)n

j

Cnj−1 − Cn

j

∆x∆x∆t

= −N−1∑

n=1

1

∆x(J−1∑

j=2

(a+)nj λn

j Cnj−1 −

J−1∑

j=2

(a+)nj λn

j Cnj )∆x∆t

= −N−1∑

n=1

1

∆x(J−2∑

j=1

(a+)nj+1λ

nj+1C

nj −

J−1∑

j=2

(a+)nj λn

j Cnj )∆x∆t

= −

J−1∑

j=2

N−1∑

n=1

(a+)nj+1λ

nj+1 − (a+)n

j λnj

∆xCn

j ∆x∆t −

N−1∑

n=1

(a+)n2λ

n2C

n1 ∆t

+

N−1∑

n=1

(a+)nJλn

JCnJ−1∆t

(43)

I2 = −

J−1∑

j=2

N−1∑

n=1

λnj (a−)n

j

Cnj+1 − Cn

j

∆x∆x∆t

= −

N−1∑

n=1

1

∆x(

J−1∑

j=2

(a−)nj λn

j Cnj+1 −

J−1∑

j=2

(a−)nj λn

j Cnj )∆x∆t

= −N−1∑

n=1

1

∆x(J−1∑

j=3

(a−)nj−1λ

nj−1C

nj −

J−1∑

j=2

(a−)nj λn

j Cnj )∆x∆t

= −

J−1∑

j=2

N−1∑

n=1

(a−)nj−1λ

nj−1 − (a−)n

j λnj

∆xCn

j ∆x∆t −

N−1∑

n=1

(a−)n1λ

n1C

n2 ∆t

(44)

Add above equation together and focus on the non-boundary terms we get the discreteupwind scheme:

(u∂λ

∂x)ni = −

(a+)nj+1λ

nj+1 − (a+)n

j λnj

∆x+

(a−)nj−1λ

nj−1 − (a−)n

j λnj

∆x(45)

where the continuous adjoint upwind scheme reads:

(u∂λ

∂x)ni = −(a+)n

j

λnj+1 − λn

j

∆x+ (a−)n

j

λnj−1 − λn

j

∆x(46)

we can see that the continuous adjoint scheme is not consistent with the discrete adjointscheme, which will be shown numerically later.

14

3.3 Discrete centered term

The normal centered scheme for advection equation reads

Cn+1j − Cn

j

∆t+

ui+1Ci+1 + uiCi

2−

uiCi + ui−1Ci−1

2∆x

= 0 (47)

Comparing to the upwind scheme, we just need to check the second term of (47) whichreads

=J−1∑

j=2

N−1∑

n=1

λnj

Cnj+1 − Cn

j−1

∆x∆x∆t

=

N−1∑

n=1

1

∆x(

J−1∑

j=2

λnj Cn

j+1 −

J−1∑

j=2

λnj C

nj−1)∆x∆t

=

N−1∑

n=1

1

∆x(

J−1∑

j=3

λnj−1C

nj −

J−2∑

j=1

λnj+1C

nj )∆x∆t

=J−1∑

j=2

N−1∑

n=1

λnj−1 − λn

j+1

∆xCn

j ∆x∆t + f(b)

(48)

So the centered term has the form

(u∂λ

∂x)ni = u

λnj−1 − λn

j+1

∆x(49)

3.4 General form

A more general form of the discrete adjoint form was studied by Zheng [12]. Thebasic idea of the discrete adjoint method is that we first discretize the forward discreteproblem(36), for example:

Cn+1 = Cn + ∆tA(Cn), Cn, Cn+1 ∈ RN , 0 ≤ n ≤ M − 1

tM = tF , C0 = C(t0)(50)

HereA is the discrete flux divergence matrix. Let us introduce aJ associated to (34) as:

J =

M∑

0

g(Cn). (51)

Then the discrete adjoint equation corresponding to (50) becomes:

λn = λn+1 + ∆t

(∂A(C)

∂C

)T

λn+1

λ ∈ RN , M − 1 ≥ n ≥ t0, λM =

∂g

∂C(CM).

(52)

15

3.5 Discrete flux-limited scheme

Now we introduce a scheme which was proposed by Sweby [10]. It’s a high-resolutionmethod that averages the first order upwind method and the Lax-Wendroff method. Con-sider the 1D discrete scheme below:

Cn+1i = Cn

i −∆t

∆x(F n

i+1/2 − F ni−1/2), (53)

where,F ni+1/2 andF n

i−1/2 represent edge fluxes for theith cell at timen. If these edgefluxes can be represented by low and high resolution schemes,then a flux limiter can switchbetween these schemes depending upon the gradients close tothe particular cell, as follows:

Fi+1/2 = F Li+1/2 + φ(ri+1/2)(F

Hi+1/2 − F L

i+1/2), (54)

Fi−1/2 = F Li−1/2 + φ(ri−1/2)(F

Hi−1/2 − F L

i−1/2), (55)

whereF H is high resolution flux whileF L is low resolution flux and theφ(r) is the fluxlimiter function,r represents the ratio of successive gradients on the solution mesh:

ri+1/2 =

Ci − Ci−1

Ci+1 − Ci

u ≥ 0,

Ci+2 − Ci+1

Ci+1 − Ci

u < 0.

(56)

The limiter function is constrained to be greater than or equal to zero, i.e.,r ≥ 0. Therefore,when the limiter is equal to zero (sharp gradient, opposite slopes or zero gradient), the fluxis represented by a low resolution scheme. Similarly, when the limiter is equal to 1 (smoothsolution), it is represented by a high resolution scheme. The various limiters have differingswitching characteristics and are selected according to the particular problem and solutionscheme. No particular limiter has been found to work well forall problems, and a particularchoice is usually made on a trial and error basis.In this master thesis we focus on the 1D linear advection equation with a constant windfield u, therefore the flux function is defined asf(C) = uC. Together with Sweby’s [10]scheme, the low order fluxF L is defined by the first order upwind scheme:

F Li+1/2 =

uCi u ≥ 0,

uCi+1 u < 0.(57)

The high order fluxF H is defined by the Lax-Wendroff scheme:

F Hi+1/2 =

u

2(Ci+1 + Ci − σ(Ci+1 − Ci)). (58)

16

Hereσ = u∆t/∆x denotes the so called Courant number. So the flux function (54) be-comes

Fi+1/2 =

uCi +u(1 − σ)

2φ(ri+1/2)(Ci+1 − Ci) u ≥ 0,

uCi+1 −u(1 + σ)

2φ(ri+1/2)(Ci+1 − Ci) u < 0.

(59)

In this master thesis we choose the limiter function as the van Albada 1 limiter functionwhich is widely used in industry:

φva1(r) =r2 + r

r2 + 1; lim

r→∞

φva1(r) = 1 (60)

To derive the adjoint equation of the above flux-limited scheme, we should write the schemein matrix form:

F n = uCn +u(1 − σ)

2Φ · (−D

T ) · Cn

Cn+1 = Cn −∆t

∆xD · F n = Cn − σD · Cn +

σ(1 − σ)

2(D · Φ · DT ) · Cn

(61)

whereF is the vector of the cell boundary fluxes,D is the backward finite differenceoperator while−D

T is the forward finite difference operator, andΦ is a diagonal matrixwith the limiter values on the diagonal:

F =

F3/2...

FN+1/2

, D =

1 0 . . . −1−1 1 . . . 0

0. . . . . . 0

0 0 −1 1

, Φ =

Φ(r3/2) . . . 0

0. . . 0

0 . . . Φ(rN+1/2)

.

The limiter functionΦ is related toC, so the corresponding discrete adjoint scheme reads:

λn =

[I − σD +

σ(1 − σ)

2D · (Φ · DT · Cn)′

]T

λn+1

=λn+1 − σDT λn+1 +

σ(1 − σ)

2[(Φ · DT · Cn)′]T · (−D

T ) · λn+1,

(62)

where(Φ · DT · Cn)′ denotes the Jacobian of theΦ · DT · Cn with respect toCn, theithrow andjthe column component reads:

∂(Φ · DT · Cn)i

∂Cj=

∂(φ(ri+1/2)(Ci+1 − Ci))

∂Cj

=φ(ri+1/2)∂(Ci+1 − Ci)

∂Cj

+ φr(ri+1/2)∂ri+1/2

∂Cj(Ci+1 − Ci).

(63)

17

Here theφr denotes the partial derivative of the limiter functionφ with respect tor. Withthe definition ofr in (56) we have

∂ri+1/2

∂Cj=

−1

Ci+1 − Cifor j = i − 1,

1 + ri+1/2

Ci+1 − Ci

for j = i,

−ri+1/2

Ci+1 − Cifor j = i + 1,

0 otherwise.

(64)

To sum up the above equations, we get the following discrete adjoint scheme:

λni =λn+1

i + σ(λn+1i+1 − λn+1

i )

−σ(1 − σ)

2[(φ − rφr)

ni+1/2(λ

n+1i+1 − λn+1

i ) − (φ − rφr)ni−1/2(λ

n+1i − λn+1

i−1 )]

−σ(1 − σ)

2[(φr)

ni+3/2(λ

n+1i+2 − λn+1

i+1 ) − (φr)ni+1/2(λ

n+1i+1 − λn+1

i )].

(65)

Here we discuss the constant wind field, so we re-write the above scheme in a similar formas (53) to (55):

λni =λn+1

i +∆t

∆x(Fn+1

i+1/2 − Fn+1i−1/2),

Fn+1i+1/2 =uλn+1

i+1 − u1 − σ

2(φ − rφr)

ni+1/2(λ

n+1i+1 − λn+1

i )

− u1 − σ

2(φr)

ni+3/2(λ

n+1i+2 − λn+1

i+1 )

=uλn+1i+1 − u

1 − σ

2[(φ − rφr)

ni+1/2 + (φr)

ni+3/2ρ

n+1i+1/2](λ

n+1i+1 − λn+1

i ),

(66)

whereρ is the slope ratio in adjoint variable:

ρn+1i+1/2 =

λn+1i+2 − λn+1

i+1

λn+1i+1 − λn+1

i

. (67)

(66) is the discrete adjoint Sweby’s flux-limited scheme. Ifwe apply the forward scheme(53) directly on the continuous adjoint problem (36), we will get the following equivalentform:

λni =λn+1

i +∆t

∆x(F

n+1

i+1/2 − Fn+1

i−1/2),

Fn+1

i+1/2 =uλn+1i+1 − u

1 − σ

2φ(ρn+1

i+1/2)(λn+1i+1 − λn+1

i ).

(68)

18

Comparing (66) with (68), we find that the difference is the limiter function. The adjointlimiter function [(φ − rφr)

ni+1/2 + (φr)

ni+3/2ρ

n+1i+1/2] is replaced by theφ(ρn+1

i+1/2) in the con-tinuous adjoint scheme, which will cause inconsistency if these two limiter functions arenot equal.

3.6 Discrete JST scheme

In this section we introduce a scheme which is popular and widely used in industry,called the Jameson-Schmidt-Turkel(JST) scheme. It was proposed by Jameson, Schmidtand Turkel [11]. It is designed for the Euler equation and we will make some modificationto the JST scheme to satisfy our advection equation. The 1D Euler equations reads

∂C

∂t+

∂F

∂t= 0 (69)

where

C =

ρρuρE

, F =

ρuρuu + p

ρuH

(70)

p, ρ, u, E andH denote the pressure, density, velocity, total energy and total enthalpy.Applying the JST method, one can get the standard JST scheme for Euler equation:

Cn+1i − Cn

i

∆t+

Qni − Dn

i

∆x= 0 (71)

HereQi is called the 2nd order Euler flux andDi is called the dissipation flux:

Qi = hi+1/2 − hi−1/2

Di = di+1/2 − di−1/2

(72)

In the JST scheme theh term is the centered scheme of the flux functionF , but as previousresearch has shown that the centered scheme is unstable, theJST scheme adds the termd,which is called an artificial dissipation term, to make the system stable:

hi+1/2 =F (Ci+1) + F (Ci)

2,

di+1/2 = ǫ(2)i+1/2Ri+1/2(Ci+1 − Ci) − ǫ

(4)i+1/2Ri+1/2(Ci+2 − 3Ci+1 + 3Ci − Ci−1),

(73)

whereRi+1/2 is the maximum wave speed of the system and the coefficientsǫ(2) andǫ(4)

are adapted to the flow. They are defined as followings:

νi =|pi+1 − 2pi + pi−1|

|pi+1| + 2|pi| + |pi−1|,

ǫ(2)i+1/2 = κ(2) max(νi+1, νi),

ǫ(4)i+1/2 = max

(0, (κ(4) − ǫ

(2)i+1/2)

),

(74)

19

where typical values of the constantsκ(2) andκ(4) are:

κ(2) =1

4, κ(2) =

1

256. (75)

To make the above JST scheme adapted to our 1D advection equation (28) we make thefollowing modification:

hi+1/2 =Ui+1Ci+1 + UiCi

2,

νi =|Ci+1 − 2Ci + Ci−1|

|Ci+1| + 2|Ci| + |Ci−1|,

(76)

which will lead to the following advection JST scheme:

∂Ci

∂t= −

1

∆x[Cn

i+1 + Cni

2−

Cni + Cn

i−1

2− ǫ

(2)i+1/2(C

ni+1 − Cn

i )

+ ǫ(4)i+1/2(Ci+2 − 3Ci+1 + 3Ci − Ci−1) + ǫ

(2)i−1/2(C

ni − Cn

i−1)

− ǫ(4)i−1/2(Ci+1 − 3Ci + 3Ci−1 − Ci−2)].

(77)

As we have shown in section 3.4, to derive the discrete adjoint equation of the JST scheme,we first rewrite the (77) inCi terms, which gives us

∂Ci

∂t= −

1

∆x[ǫ

(4)i−1/2Ci−2 + (−

1

2− ǫ

(4)i+1/2 − ǫ

(2)i−1/2 − 3ǫ

(4)i−1/2)Ci−1

+ (ǫ(2)i+1/2 + 3ǫ

(4)i+1/2 + ǫ

(2)i−1/2 + 3ǫ

(4)i−1/2)Ci

+ (1

2− ǫ

(2)i+1/2 − 3ǫ

(4)i+1/2 − ǫ

(4)i−1/2)Ci+1 + ǫ

(4)i+1/2Ci+2].

(78)

Here we first assume that we haveǫ ∼ ǫ(C).The discrete adjoint equation of (77) will have the form of

(∂λ

∂t)i = −

Ui

∆x[∂Ai−2

∂Ci

λi−2 +∂Ai−1

∂Ci

λi−1 +∂Ai

∂Ci

λi +∂Ai+1

∂Ci

λi+1 +∂Ai+2

∂Ci

λi+2], (79)

where

Ai =ǫ(4)i−1/2Ci−2 + (−

1

2− ǫ

(4)i+1/2 − ǫ

(2)i−1/2 − 3ǫ

(4)i−1/2)Ci−1

+ (ǫ(2)i+1/2 + 3ǫ

(4)i+1/2 + ǫ

(2)i−1/2 + 3ǫ

(4)i−1/2)Ci

+ (1

2− ǫ

(2)i+1/2 − 3ǫ

(4)i+1/2 − ǫ

(4)i−1/2)Ci+1 + ǫ

(4)i+1/2Ci+2.

(80)

The partial derivative terms in (79) read

∂Ai−2

∂Ci=(−

∂ǫ(4)i−3/2

∂Ci)Ci−3 + (

∂ǫ(2)i−3/2

∂Ci+ 3

∂ǫ(4)i−3/2

∂Ci)Ci−2

+ (−∂ǫ

(2)i−3/2

∂Ci− 3

∂ǫ(4)i−3/2

∂Ci)Ci−1 + ǫ

(4)i−3/2 +

∂ǫ(4)i−3/2

∂CiCi,

(81)

20

∂Ai−1

∂Ci=

∂ǫ(4)i−3/2

∂CiCi−3 + (−

∂ǫ(4)i−1/2

∂Ci−

∂ǫ(2)i−3/2

∂Ci− 3

∂ǫ(4)i−3/2

∂Ci)Ci−2

+ (∂ǫ

(2)i−1/2

∂Ci+ 3

∂ǫ(4)i−1/2

∂Ci+

∂ǫ(2)i−3/2

∂Ci+ 3

∂ǫ(4)i−3/2

∂Ci)Ci−1

+ (1

2− ǫ

(2)i−1/2 − 3ǫ

(4)i−1/2 − ǫ

(4)i−3/2) + (−

∂ǫ(2)i−1/2

∂Ci

− 3∂ǫ

(4)i−1/2

∂Ci

−∂ǫ

(4)i−3/2

∂Ci

)Ci

+∂ǫ

(4)i−1/2

∂Ci

Ci+1,

(82)

∂Ai

∂Ci=

∂ǫ(4)i−1/2

∂CiCi−2 + (−

∂ǫ(4)i+1/2

∂Ci−

∂ǫ(2)i−1/2

∂Ci− 3

∂ǫ(4)i−1/2

∂Ci)Ci−1

+ (ǫ(2)i+1/2 + 3ǫ

(4)i+1/2 + ǫ

(2)i−1/2 + 3ǫ

(4)i−1/2)

+ (∂ǫ

(2)i+1/2

∂Ci+ 3

∂ǫ(4)i+1/2

∂Ci+

∂ǫ(2)i−1/2

∂Ci+ 3

∂ǫ(4)i−1/2

∂Ci)Ci

+ (−∂ǫ

(2)i+1/2

∂Ci− 3

∂ǫ(4)i+1/2

∂Ci−

∂ǫ(4)i−1/2

∂Ci)Ci+1 +

∂ǫ(4)i+/2

∂CiCi+2,

(83)

∂Ai+1

∂Ci=

∂ǫ(4)i+1/2

∂CiCi−1 + (−

1

2− ǫ

(4)i+3/2 − ǫ

(2)i+1/2 − 3ǫ

(4)i+1/2)

+ (−∂ǫ

(4)i+3/2

∂Ci

−∂ǫ

(2)i+1/2

∂Ci

− 3∂ǫ

(4)i+1/2

∂Ci

)Ci

(∂ǫ

(2)i+3/2

∂Ci

+ 3∂ǫ

(4)i+3/2

∂Ci

+∂ǫ

(2)i+1/2

∂Ci

+ 3∂ǫ

(4)i+1/2

∂Ci

)Ci+1

(−∂ǫ

(2)i+3/2

∂Ci

− 3∂ǫ

(4)i+3/2

∂Ci

−∂ǫ

(4)i+1/2

∂Ci

)Ci+2 +∂ǫ

(4)i+3/2

∂Ci

Ci+3,

(84)

∂Ai+2

∂Ci=ǫ

(4)i+3/2 +

∂ǫ(4)i+3/2

∂CiCi + (−

∂ǫ(2)i+3/2

∂Ci− 3

∂ǫ(4)i+3/2

∂Ci)Ci+1

+ (∂ǫ

(2)i+3/2

∂Ci+ 3

∂ǫ(4)i+3/2

∂Ci)Ci+2 −

∂ǫ(4)i+3/2

∂CiCi+3.

(85)

To make the scheme work well near the shock area in our system,we also should modifythe the coefficientǫ(2) andǫ(4):

ǫ(2) =

1

2if ǫ(2) > 1/100,

0 otherwise.ǫ(4) =

0 if ǫ(2) > 1/100,1

32otherwise.

(86)

21

In this sense the the coefficientǫ(2) andǫ(4) are both constant in the mesh interval if the meshsizeh is large enough therefor can not be treat as a ’point’ and thenthe partial derivativesof the coefficientǫ(2) andǫ(4) with the respect toCi are now vanished in (81) to (85) whichreduces (79) to

(∂λ

∂t)i = −

Ui

∆x

[ǫ(4)i−3/2λi−2 + (

1

2− ǫ

(2)i−1/2 − 3ǫ

(4)i−1/2 − ǫ

(4)i−3/2)λi−1

+ (ǫ(2)i+1/2 + 3ǫ

(4)i+1/2 + ǫ

(2)i−1/2 + 3ǫ

(4)i−1/2)λi

+ (−1

2− ǫ

(4)i+3/2 − ǫ

(2)i+1/2 − 3ǫ

(4)i+1/2)λi+1 + ǫ

(4)i+3/2λi+2

].

(87)

Now we apply the JST directly on the adjoint equation (36)

(∂λ

∂t)i = −

Ui

∆x

[ǫ(4)i+1/2λi−2 + (

1

2− ǫ

(2)i+1/2 − 3ǫ

(4)i+1/2 − ǫ

(4)i−1/2)λi−1

+ (ǫ(2)i+1/2 + 3ǫ

(4)i+1/2 + ǫ

(2)i−1/2 + 3ǫ

(4)i−1/2)λi

+ (−1

2− ǫ

(4)i+1/2 − ǫ

(2)i−1/2 − 3ǫ

(4)i−1/2)λi+1 + ǫ

(4)i−1/2λi+2

].

(88)

We can see that (87) and (88) have the same structure, where the only difference is theindex of the coefficientǫ(2) andǫ(4). The discrete adjoint equation (88) can be written as

(∂λ

∂t)i = −

Ui

∆x

[ǫ(4)i−3/2λi−2 + (

1

2− ǫ

(2)i−1/2 − 3ǫ

(4)i−1/2 − ǫ

(4)i−3/2)λi−1

+ (ǫ(2)i+1/2 + 3ǫ

(4)i+1/2 + ǫ

(2)i−1/2 + 3ǫ

(4)i−1/2)λi

+ (−1

2− ǫ

(4)i+3/2 − ǫ

(2)i+1/2 − 3ǫ

(4)i+1/2)λi+1 + ǫ

(4)i+3/2λi+2

]

−Ui

∆x

[(−ǫ

(4)i−3/2 + ǫ

(4)i+1/2)λi−2 + (−ǫ

(4)i+3/2 + ǫ

(4)i−1/2)λi+2

+ (ǫ(2)i−1/2 + 3ǫ

(4)i−1/2 + ǫ

(4)i−3/2 − ǫ

(2)i+1/2 − 3ǫ

(4)i+1/2 − ǫ

(4)i−1/2)λi−1

+ (ǫ(4)i+3/2 + ǫ

(2)i+1/2 + 3ǫ

(4)i+1/2 − ǫ

(4)i+1/2 − ǫ

(2)i−1/2 − 3ǫ

(4)i−1/2)λi+1

].

(89)

By comparing (87) with (89), the discrete adjoint scheme is the continuous adjoint schemeplus a source term at each grid pointi which will lead to inconsistency. For example, forthose grid points where the values of theǫ(2) andǫ(4) change comparing to the previous gridpoints will lead to inconsistency between the discrete adjoint equation and the continuousadjoint equation. In other words, the source term in (89) will be active if the values of theǫ(2) andǫ(4) ’jump’ at each grid point.

22

4 Numerical Simulation

4.1 Flux limited scheme

For the flux limited scheme of the 1D advection equation in ourcase we set a periodicboundary and a constant wind fieldu = 1 so that we can avoid the inconsistencies due tothe changes in boundary and the changes in wind field. The timedomain readst ∈ [0, 1]and mesh size in time domain is1/200, the space domain readsx ∈ [0, 2] and the meshsize is2/100, all the following figures are plotted at timet = 0.5s.For the initial value of the forward equation we set as following:

C(x, 0) =

2 + 0.1(1 + cos(πx/2)) for x ∈ [0.2, 0.6]0.1(1 + cos(πx/2)) for x ∈ [0, 0.2) ∪ (0.6, 1]

(90)

0 0.5 1 1.5 20

0.5

1

1.5

2

2.5

x

valu

e

Initial value of the forward equation

forward

(a) t=0s

0 0.5 1 1.5 20

0.5

1

1.5

2

2.5

x

valu

e

Initial value of the forward equation

forward

(b) t=0.5s

Figure 2: Initial value of the (90) at t=0s and 0.5s

This initial value contains a square wave and a smallcos function which will make theforward equation behave like a shock wave as shown in figure(2).The results of the van Albada 1 flux limited adjoint solution is shown in in figure(3). Theinteresting part of the adjoint plot is the shock part where the forward solution has a sharpgradients and this leads to the inconsistency of the continuous adjoint solution and thediscrete adjoint solution. We can see that in the large constant part of the forward equation,the van Albada 1 flux limiter value stay constant and there is no inconsistency between thecontinuous adjoint solution and the discrete adjoint solution. But when close to and in thesquare wave parts, the van Albada 1 flux limiter value will repeated shock between1 and0.5 because of the sharp gradient in forward solution and therefore lead the inconsistencyof the continuous adjoint solution and the discrete adjointsolution.Let’s introduce some other popular limiter functions namedminmod - symmetric limiter

23

0 0.5 1 1.5 2−0.5

0

0.5

1

1.5

2

2.5

3

x

valu

e

van albada 1 at 0.5s

continuousdiscreteforwardlimiter value

Figure 3: Continuous and discrete adjoint value at t=0.5

function (Roe, 1986) and van Albada 2 limiter functions (Kermani, 2003), which read:

φmm(r) = max[0, min(1, r)]; limr→∞

φmm(r) = 1 (91)

φva2(r) =2r

r2 + 1; lim

r→∞

φva2(r) = 0 (92)

For numerical result of the minmod - symmetric limiter, see figure(5); for van Albada 2limiter, see figure(6), which all show that near the shock area the inconsistency will occurbetween the continuous adjoint solution and the discrete adjoint solution.

4.2 JST scheme

For the JST scheme shown in figure(7) this scheme avoid large inconsistency betweenthe continuous adjoint solution and the discrete adjoint solution near the shock area suc-cessfully. If we zoom in the shock area of the forward solution(figure(8)), it’s clear that thediscrete adjoint solution is not like the one under flux limited scheme we discuss above,here the inconsistency is really small. From the (89) we knowthat the source term in the

24

0.4 0.5 0.6 0.7 0.8 0.9 1

−0.2

0

0.2

0.4

0.6

0.8

1

x

valu

e

van albada 1 at 0.5s

continuousdiscreteforwardlimiter value

(a) left shock area

1 1.1 1.2 1.3 1.4 1.5 1.6

−0.2

0

0.2

0.4

0.6

0.8

1

x

valu

e

van albada 1 at 0.5s

continuousdiscreteforwardlimiter value

(b) right shock area

Figure 4: Zoom in the shock area

0 0.5 1 1.5 2−0.5

0

0.5

1

1.5

2

2.5

3

x

valu

e

minmod at 0.5s

continuousdiscreteforwardlimiter value

(a) minmod - symmetric limiter

1 1.2 1.4 1.6

−0.2

0

0.2

0.4

0.6

0.8

1

x

valu

e

minmod at 0.5s

continuousdiscreteforwardlimiter value

(b) right shock area

Figure 5: minmod - symmetric limiter

25

0 0.5 1 1.5 2−0.5

0

0.5

1

1.5

2

2.5

3

x

valu

e

van Albada 2 Alternative form at 0.5s

continuousdiscreteforwardlimiter value

(a) van Albada 2 limiter

1.1 1.2 1.3 1.4 1.5 1.6 1.7

−0.5

0

0.5

1

x

valu

e

van Albada 2 Alternative form at 0.5s

continuousdiscreteforwardlimiter value

(b) right shock area

Figure 6: van Albada 2 limiter

discrete equation reads

source = −Ui

∆x

[(−ǫ

(4)i−3/2 + ǫ

(4)i+1/2)λi−2 + (−ǫ

(4)i+3/2 + ǫ

(4)i−1/2)λi+2

+ (ǫ(2)i−1/2 + 3ǫ

(4)i−1/2 + ǫ

(4)i−3/2 − ǫ

(2)i+1/2 − 3ǫ

(4)i+1/2 − ǫ

(4)i−1/2)λi−1

+ (ǫ(4)i+3/2 + ǫ

(2)i+1/2 + 3ǫ

(4)i+1/2 − ǫ

(4)i+1/2 − ǫ

(2)i−1/2 − 3ǫ

(4)i−1/2)λi+1

](93)

Here theǫ act like the limiter function in the flux-limited scheme. In figure (9) and (10),we plot theǫ value separately with the discrete adjoint solution and thecontinuous adjointequation. Near the shock area the values of theǫ(2) and ǫ(4) have jump and this will leadthe source term be active near the shock area. The results in figure (9) and (10) show thatour discrete scheme will lose consistency when the source term is active. Confirming theanalysis in (93), the amplitude of the inconsistency is smaller then the effect we discussedthe flux-limiter function if theǫ(2) andǫ(4) have the opposite jump direction.

26

0 0.5 1 1.5 20

0.5

1

1.5

2

2.5

x

valu

e

JST scheme at t=0.5s

discreteforwardcontinuous

Figure 7: Continuous and discrete adjoint value with JST scheme at t=0.5

0.2 0.3 0.4 0.5 0.6 0.7

0

0.1

0.2

0.3

0.4

0.5

0.6

x

valu

e

JST scheme at t=0.5s

discreteforwardcontinuous

(a) left shock area

1.2 1.4 1.6 1.8

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

x

valu

e

JST scheme at t=0.5s

discreteforwardcontinuous

(b) right shock area

Figure 8: Zoom in the shock area

27

0.5 0.6 0.7 0.8 0.9 1 1.1−0.2

0

0.2

0.4

0.6

0.8

x

valu

e

JST scheme at t=0.5s

discretecontinuousε(2)

(a) left shock area

1.2 1.3 1.4 1.5 1.6 1.7

−0.2

0

0.2

0.4

0.6

0.8

x

valu

e

JST scheme at t=0.5s

discretecontinuousε(2)

(b) right shock area

Figure 9:ǫ(2) near the shock area

0.5 0.6 0.7 0.8 0.9

0

0.1

0.2

0.3

0.4

0.5

x

valu

e

JST scheme at t=0.5s

discretecontinuousε(4)

(a) left shock area

1.2 1.3 1.4 1.5 1.6−0.2

−0.1

0

0.1

0.2

0.3

0.4

x

valu

e

JST scheme at t=0.5s

discretecontinuousε(4)

(b) right shock area

Figure 10:ǫ(4) near the shock area

28

5 Conclusion and future work

In this master thesis we discuss properties of the discrete adjoint method under differ-ence numerical schemes and limiter functions.The analysis of flux-limited scheme shows that the discrete adjoint limiter function willhave another form comparing to the continuous adjoint limiter which will lead inconsis-tency in the discrete adjoint equation near the shock area. For different forward limiterfunction, the inconsistency behaves differently. For van Albada 1 limiter, the inconsistencyappears in the both shock area as shown in figure (4) and for minmod - symmetric limiterand van Albada 2 limiter, the inconsistencies appear only inthe right shock area as shownin figure (5) and figure (6).The analysis of JST scheme shows the similar conclusion in the shock area but with lessamplitude because the source term will be vanished at those grid points whereǫ has jumps.

Future work can be extend to the some nonlinear equation suchas Burgers’ equationand high dimension problem like 2D Euler equation where we can directly use the JSTscheme without modification and also there are possibility to consider more schemes ortest more limiter functions.

29

References

[1] A. Jameson, N.A. Pierce and L. Martinelli. Optimum aerodynamic design using theNavier-Stokes equations.AIAA Paper, 97-0101, 1997.

[2] W.K. Anderson and V. Venkatakrishnan. Aerodynamic design optimization on un-structured grids with a continous adjoint formulation.AIAA Paper, 97-0643, 1997.

[3] A. Jameson, Aerodynamic design via control theory.J.Sci.Comput., 3:233-260, 1988.

[4] A. Jameson and J. Reuther. Control theory based airfoil design using the Euler equa-tion. AIAA Paper, 94-4272-CP, 1994.

[5] C. Johnson and R. Rannacher. On error control in CFD.Technical report, Univ Hei-delberg, 1994. Preprint No. 94-13.

[6] R. Delay. Atmospheric Data Analysis.Cambrige University Press: Cambridge, 1991.

[7] R. Becker and R. Rannacher. Weight a posteriori error control in finite elementmethos.Technical report, Univ Heidelberg, 1994. Preprint No. 96-1.

[8] D.G. Cacuci. Sensitivity theory for nonlinear system. I. Nonlinear functional analysisapproach.Journal of Mathematical Physics, 22:2794-2802, 1981.

[9] M.B. Giles and N.A. Pierce. Adjoint equations in CFD: duality, boundary conditionsand solution behaviour’.AIAA Paper 97-1850, 1997.

[10] P.K. Sweby. High resolution schemes using flux limitersfor hyperbolic conservationlaws.SIAM Journal Numerical Analysis 21:996-1011, 1984.

[11] A. Jameson, W. Schmidt and E. Turkel. Numerical solution of the Euler equations byfinite volume methods using Runge Kutta time stepping schemes. AIAA, Fluid andPlasma Dynamics Conference, 14th, Palo Alto, CA, June 23-25, 1981. 15p.

[12] Z. Liu, S. Adrian. On the properties of discrete adjoints of numerical methods for theadvection equation.Int. J. Numer. Mech. Fluids, 2008, 56:769-803.

30

A Matlab Code for Advection Equation

The appendix contains part of the Matlab M-function codes ofthis master thesis projectin CERFACS. Some of the codes are not available in this thesisreport due to copy rights.If you are interested in these codes which you cannot obtain here, do not hesitate to contactZongyuan GU5 by email.

A.1 initfunc.m

Initial value of the advection equation.

1 f unc t i o n [ x , C] = i n i t f u n c (X, nx )2 s t e p =(X(2)−X ( 1 ) ) / nx ;3 x ( 1 ) = s t e p / 2 . 0 ;4 f o r i =1:95 x ( i )= x ( 1 ) + ( i −1)∗ s t e p ;6 C( i ) =0 . 1∗ ( 1 +cos( pi ∗x ( i ) / 2 ) ) ;7 end8 f o r i =10:309 x ( i )= x ( 1 ) + ( i −1)∗ s t e p ;

10 C( i ) =0 . 1∗ ( 1 +cos( pi ∗x ( i ) / 2 ) ) + 2 ;11 end12 f o r i =31:10013 x ( i )= x ( 1 ) + ( i−1)∗ s t e p ;14 C( i ) =0 . 1∗ ( 1 +cos( pi ∗x ( i ) / 2 ) ) ;15 end16 re turn ;

A.2 limiter.m

Limiter function in the flux-limited scheme.

1 f unc t i o n ph i = l i m i t e r ( a , b , c , d , u )2 r =0;3 eps=0 . 0 0 1 ;4 i f abs ( c−b)>=eps5 i f u >=06 r = ( b−a ) / ( c−b ) ;7 e l s e8 r =(d−c ) / ( c−b ) ;

[email protected]

31

9 end10 ph i =( r∗ r + r ) / ( r ∗ r +1 ) ;11 e l s e12 ph i =1;13 end

A.3 forward.m

Solving the forward advection equation using flux-limited scheme.

1 T=[0 1 ] ;2 X=[0 2 ] ;3 n_x =100;4 n_ t =200;5 n t ime =200;6 u =1;7 % INITIAL SOLUTION OF THE DIRECT PROBLEM8 [ x C] = i n i t f u n c (X, n_x ) ;9 f o r i =1: n_ t

10 t ( i )=T ( 1 ) + (T(2)−T ( 1 ) )∗ i / n_ t ;11 end12 C=[0 0 0 C 0 0 0 ] ;13 n=l eng th (C ) ;14 d e l t a =u∗ ( ( T(2)−T ( 1 ) ) / n_ t ) / ( ( X(2)−X ( 1 ) ) / n_x ) ;15 f o r i =2: n t ime16 C=[C ;zeros( 1 , n ) ] ;17 %p e r i o d i c BC18 C( i−1 ,1)=C( i−1, n_x +1 ) ;19 C( i−1 ,2)=C( i−1, n_x +2 ) ;20 C( i−1 ,3)=C( i−1, n_x +3 ) ;21 C( i−1, n_x +4)=C( i−1 ,4) ;22 C( i−1, n_x +5)=C( i−1 ,5) ;23 C( i−1, n_x +6)=C( i−1 ,6) ;24 f o r j =4: n_x+325 C( i , j )=C( i−1, j )− d e l t a / u∗ ( u∗C( i −1, j )+ u∗(1− d e l t a ) / 2∗ . . .26 l i m i t e r (C( i−1, j −1) ,C( i−1, j ) ,C( i −1, j +1 ) ,C( i−1, j +2 ) , u )∗ . . .27 (C( i−1, j +1)−C( i −1, j ))−u∗C( i −1, j −1)−u∗(1− d e l t a ) / 2∗ . . .28 l i m i t e r (C( i−1, j −2) ,C( i−1, j −1) ,C( i−1, j ) ,C( i −1, j +1 ) , u )∗ . . .29 (C( i−1, j )−C( i −1, j −1 ) ) ) ;30 end31 end

32