lecture03 - stony brook university

18
Los Alamos National Laboratory Hydrodynamic Methods Finite Difference Methods for Gas Dynamics 1 LA-UR 99-3985 All numerical solutions to systems of partial differential equations are based on the notion of the discretization of the solution. For time dependent problems the basic concept is to use time-marching to advance the solution from one time level to the next, moving from a discrete representation of the solution at one time to another discrete representation of the solution at the next time. Conservation laws are uniquely suited for such a method since the divergence form of the equations gives a natural relation between spatial averages of the solution at two time levels and the space-time averages of the fluxes. Suppose (t), t n t t n+1 = t n +=t n forms a set of smoothly moving regions in space. We define the average of the state vector: () () t t

Upload: others

Post on 14-Jan-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 1LA-UR 99-3985

All numerical solutions to systems of partial differential equations are based onthe notion of the discretization of the solution. For time dependent problems thebasic concept is to use time-marching to advance the solution from one time levelto the next, moving from a discrete representation of the solution at one time toanother discrete representation of the solution at the next time. Conservation lawsare uniquely suited for such a method since the divergence form of the equationsgives a natural relation between spatial averages of the solution at two time levelsand the space-time averages of the fluxes. Suppose Ω(t), tn ≤ t ≤ tn+1 = tn+=∆tnforms a set of smoothly moving regions in space. We define the average of thestate vector:

( )

( )

t

t

Ω

Ω

Page 2: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 2LA-UR 99-3985

If we define then integrating the moving region form of theconservation law:

u unnt= ( )

ddt t t t

d dA( ) dx x xu f n uv n hΩ Ω

+ • − • =∂Ω

,

from tn to tn+1 we obtain:

u ux

x fn uv nx

x

xh

x

x x

xun n

t

t

t

t

t

tt

t

t

t

t

t

ntd t

dt dAdt d

d

dt d

dt d

d d

dn

n

nn

n

n

n

n

n

n

n n

n

+

∂Ω

= − − • + −−

+

+

+

+

+

+

+

+

1

1

1

1

1

1

1

1

1

1∆∆

Ω

Ω

Ω

Ω

Ω

Ω Ω

Ωb g

b g b g

b g

.

u u x f n hn n tvol

dA tn n

+

∂Ω

= − ++ +

112

12∆

Ω∆ .

This equation is considerable simpler for a fixed domain, Ω(t) = Ω:

Here is the average of flux over a space-time ray on ∂Ω=and is the averageof h over the space time region swept out by Ω from tn to tn+1.

fn+1

2 hn+1

2

Page 3: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 3LA-UR 99-3985

The conservative difference equations of the previous slide form the basis of manyadvanced numerical methods. The basic operation is to construct approximationsfor the integrals of the flux functions over the space-time boundaries of the regionover which the region is averaged, together with an approximation of the integralof the body sources over the space-time volume swept out by this region. Forsimplicity let us focus on the case of one space dimensional flows with no bodyforces. Then if we let Ω correspond to a mesh intervalthe conservative difference equations become:

u u f fin

in

ii

n

i

ntx

+

+

+

+= − −1

12

12

12

12∆

∆.

Here is the average of u over the ith interval, and is the average of the fluxover the interval x = , tn ≤ t ≤ tn+1.

uin f

i

n

+

+

12

12

x x x x x x xi i

ii

i

i− += − ≤ ≤ + =1

2122 2

∆ ∆

xi+ 1

2

Page 4: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 4LA-UR 99-3985

In order for a numerical method to be effective there must be some notion ofconvergence of the discrete solution to the exact solution of the differentialequation in the limit of vanishing grid size. Convergence is generally not obtainedin the pointwise sense (except where the flow is smooth) but is instead obtained insome integral norm such as in L1 or L2 if the domain is compact (as is always thecase in real computations) on locally in the sense that convergence occurs in theappropriate function space on every compact subset of the domain. Since theexact solution to the system of equations is generally unknown, the exact error inthe numerical solution is also unknown. One measure of the appropriateness of anumerical method that can often be computed is the order of accuracy of themethod. This is defined as the residual value of the difference equation if an exactsolution of the corresponding partial differential equation is substituted into thedifference equation. More precisely, we say that the order of accuracy of thenumerical method is if:

Note here we assume that ∆x is of the same order of magnitude as ∆t.

u uf f

( , ) ( , ) O .x t t x tt x

ti

n

i

n

+ − +−

=+

+

+

∆∆ ∆

∆12

12

12

12

α

Page 5: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 5LA-UR 99-3985

A positive order of accuracy ensures that the finite difference method is consistentwith the corresponding partial differential equation in that, as the mesh is refined,solutions to the partial differential equation solve (to the order of accuracy) thedifference equation. To be useful in practice a numerical method needs to be atleast first order accurate. Most modern shock capturing numerical methods aresecond order accurate everywhere except near shocks or contact discontinuities.Also the order of accuracy is generally computed using smooth solutions. Ifdiscontinuous solutions are consider as well, the accuracy of the method mustalso include some notion of locating the discontinuities in the approximatelycorrect location. For example we might require that the integral of the differenceequation residual over any finite domain be proportional to the volume of thedomain times the appropriate power of ∆t.

This formula ensures that the jump discontinuities are located correctly to withinthe accuracy of the method.

dx x t t x tt x

b a ti

n

i

n

a

b u uf f

( , ) ( , ) O+ − +−

= −+

+

+

∆∆ ∆

∆12

12

12

12

α

Page 6: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 6LA-UR 99-3985

In order for a difference method to be useful it is important that effects liketruncation errors (closely related to the order of accuracy of the method) and finitearithmetic round off not dominate the numerical solution. Ideally these errorsshould stay bounded as the solution operator evolves. More formally, we interpretthe finite difference method time stepping in terms of an evolution operator C(∆t)so that the solution at each successive time is found by the operation un = C(∆t)un-1

= ⋅⋅⋅ = C(∆t)nu0. For simplicity let us assume that ∆t is fixed and C(∆t) is linear.Richtmyer expresses the notion of stability as the requirement that as ∆t → 0 nocomponent of u0 be amplified by the numerical procedure. Therefore, we say thenumerical method is stable, if for a given T there is some τ > 0, so that infinite setof operators:

is uniformly bounded. Note that stability is a property of the numerical method,not the partial differential equation.

n∆∆∆

,0

0< <

≤ ≤

Page 7: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 7LA-UR 99-3985

One of the few general theorems on the convergence of finite difference methodsis due to Lax and states that for a consistent scheme (positive order of accuracy)stability is a necessary and sufficient condition for convergence. More preciselywe have:Suppose that the initial value problem for the linear differential equation,

where A is a linear operator on a Banach space and u0 is a given element of is well posed. Then for a finite difference approximation that satisfies theconsistency condition, stability is the necessary and sufficient condition forconvergence.

For our purposes is a function space such as L2 and A is a differential operatoron the function space. See Richtmyer and Morton, “Difference methods for initialvalue problem” for a proof of the Lax Equivalence Theorem.

ddt

u t Au t t T

u u

= ≤ ≤

=

,

,

0

0 0

Page 8: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 8LA-UR 99-3985

The notion of order of accuracy of a numerical method can be illustrated byderiving the Lax-Wendroff method for the system of conservation laws,

0.

This method is also very useful in practice. The basic idea is to expand u(x,t) in aTaylor series to second order in time for fixed x, use the partial differentialequation to replace the time derivatives with spatial derivatives, and the usecentral differences to approximate the resulting spatial derivative to second order.The resulting finite difference equation is then by construction second orderaccurate. Let A = df/du be the Jacobi matrix for the flux function. Then we canexpand u(x,t+∆t) as follows:

Page 9: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 9LA-UR 99-3985

u u u u

u u f u f u

u u f u A u

u

x t t x tt

x t tt

x t t t

x t t x tx

x t tx t

x t t t

x t t x tx

x t tx t

x t t t

x t

, , , , O

, , , , O

, , , , O

,

+ = + ∂∂

+ ∂∂

+

+ = −∂

∂− ∂

∂∂

∂+

+ = −∂

∂− ∂

∂∂∂

+

∆ ∆ ∆ ∆

∆ ∆ ∆ ∆

∆ ∆ ∆ ∆

2

2

23

23

23

2

2

2

+ = −∂

∂+ ∂

∂∂

∂+

+ = − + − − +

+ + − − −

∆ ∆ ∆ ∆

∆ ∆∆

∆ ∆

∆∆

∆ ∆ ∆

t x tx

x t tx x

x t t t

x t t x t tx

x x t x x t

tx

x x t x x t x t x x t

u f u A f u

u u f u f u

A u f u f u A u f u

, , , O

, , , ,

, , , ,

23

2

212

12 2 2

x t x x t t, , O− − +f u ∆ ∆ 3

If we let x = i∆x, t = n∆t, we obtain the difference method:

u u f f A f f A f fin

in

in

in

in

in

in

in

in

int

xtx

++ − + + − −= − − + − − −1

1 1

2

1 2 1 1 2 112

12

∆∆

∆∆ / /

Page 10: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 10LA-UR 99-3985

f f f A f fin i

nin

in

in

int

x++ +

+ += + − −1 21 2 1

1 2 1212/

// ,∆

and we let In practice the Lax-Wendroff method isimplemented as a two step method that is identical with the above formula forlinear fluxes (constant A), and is also second order in general.

u u u f f

f f u

u u f f

in i

nin

in

in

in

in

in

in

in

in

tx

tx

++ +

+

++

++

+++

−+

= + − −

=

= − −

1 21 2 1

1

1 21 2

1 21 2

11 21 2

1 21 2

212/

/

//

//

//

//

∆∆

∆∆

It can be shown (see Richtmyer and Morton) that for constant A the Lax-Wendroffmethod is stable provided |λ|∆t/∆x < 1 for all eigenvalues of A. For gas dynamicsthis condition becomes (|u|+c) ∆t/∆x < 1 for all velocities u and sound speed c.

A Ain

in

inu u+ += +1 2 1 2/ / .

Page 11: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 11LA-UR 99-3985

One further modification to the Lax-Wendroff is needed before it can be used asan effective finite difference method for gas dynamics. In the presence ofdiscontinuities this method generates severe oscillations that can destroy theintegrity of the computation. These oscillations can be damped by the addition ofartificial viscosity to the numerical method. It is beyond the scope of this courseto discuss the analysis of artificial viscosity. Listed below are two modificationsto the Lax-Wendroff fluxes that have proven to be useful in practice.

Linear artificial viscosity: We modify the Lax-Wendroff fluxes by adding a termthat mimics the diffusive term uxx added to the right hand side of theconservation law.

in

in

in

in

++

++

− + −1 21 2

1 21 2

1 1//

//

Lax Wendroff

The artificial viscosity coefficient a might be taken of the form a = χs where χ is anumerical parameter and s is the maximum wave speed at the point being updated.

Page 12: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 12LA-UR 99-3985

Lapidus artificial viscosity: For gas dynamics a more adaptive method ofartificial viscosity that increases the artificial viscosity in regions of large gradientwhile reducing it in smooth regions was proposed by Lapidus (see Richtmyer andMorton). Let the coefficients , k = 0, 1, 2. be chosen by the interpolationformulas:

gik+1 2/

g g u c g u c u c u c

g g u g u u u

g g u c g u

i i in

in

i in

in

in

in

in

in

i i in

i in

in

in

i i in

in

i i

+ + + + + + + + +

+ + + + + +

+ + + + + +

+ + + + = + − +

+ + = −

+ − +

1 20

1 21

1 2 1 2 1 22

1 2 1 22

1 1

1 20

1 21

1 2 1 22

1 22

1

1 20

1 21

1 2 1 2 1 22

1

/ / / / / / /

/ / / / /

/ / / / / /

χ

χ

2 1 22

1 1n

in

in

in

in

inc u c u c− = − − −+ + +/ .χ

u u u f f u u

f f u u u

u u f f

in i

nin

i in

in

i in

in

in

in

i in

in

in

in

in

in

tx

g g

g

tx

++ +

+ + + +

++

++

+ +

+++

−+

= + − + − − −

= − −

= − −

1 21 2 1

1 22

1 1 21

1

1 21 2

1 21 2

1 20

1

11 21 2

1 21 2

212

12

12

//

/ /

//

//

/

//

// .

∆∆

∆∆

Then the modified Lapidus artificial viscosity Lax-Wendroff method is:

Remark: For this method the stability condition is modified:

u c tx

+ < + −∆∆

14 2

2 1 2χ χ/

Page 13: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 13LA-UR 99-3985

Godunov’s method computes the numerical fluxes using the solution to a Riemannproblem. The value of the numerical flux is given by the formula:

in

in

++

++

1 21 2

1 21 2

//

//

Where is the solution evaluated along the time axis of the Riemann problemwith data ul = ui and ur = ui+1. This method has the advantage of producingsmooth and stable shock profiles. Its disadvantages are that it is only first orderaccurate and is quite diffusive. In practice the Godunov method is used as acomponent in a higher order method in which the numerical method adaptsbetween a high order method for smooth flow regions and the Godunov method inregions with large gradients in the flow variables. Stability requires that thesolutions to the Riemann problems at the cell edges not interact during the timestep. Thus the stability condition becomes:

uin++1 21 2//

max , :shock speeds u c all Riemann problem solutions tx

+ <∆∆

1

Page 14: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 14LA-UR 99-3985

Most modern compressible hydrodynamics use some version of a higher orderextension of the Godunov method. It is beyond the scope of this course to go intothese methods in detail. These higher order Godunov methods are all outgrowthsof the original method of van Leer. Some of the basic ideas in these higher orderextensions of Godunov’s method include:

•Reconstruction: Given a piecewise constant function construct a higher orderinterpolant whose cell averages equal the piecewise constant values.•Limiting: Modify the high order interpolant to eliminate or moderate overshootat cell edges.•Riemann solvers: Construct approximate solutions to the Riemann problemsbetween states at the cell edges as determined from the interpolant.•Method of Characteristics: Use the smooth form of the partial differentialequations to compute high order updates of a spatially variable flow. (Themethod of characteristics will be discussed in the next lecture.

Page 15: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 15LA-UR 99-3985

All of the difference methods discussed in this lecture have extensions (often quitecomplicated) to systems with more than one space dimension. Current computertechnology makes high resolution computations possible for two spacedimensional flows on moderately priced computers. Currently three dimensionalflows require expensive supercomputers for even moderate resolution.One standard technique for constructing multiple space dimensional solvers fromone space dimensional solvers is operator splitting. This method has proven to bequite effective in gas dynamics. The basic idea is to solve one dimensionalproblems by freezing the flow in all directions except one, and then use thesolution from each successive one dimensional problem as the data for the nextsweep. We can illustrate this more easily by example in two space dimensions.Suppose we have the system:

∂∂

+ ∂∂

+ ∂∂

=( ) ( ) 0

Consider the two one dimensional systems, where we treat on space variable as aparameter:

∂∂

+ ∂∂

= ∂∂

+ ∂∂

=, , ( ) , , , , ( ) , ,0 0

Page 16: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 16LA-UR 99-3985

If we treat y as a parameter in updating the x operator split equation and x as aparameter in the y equation, we obtain two one dimensional systems of equations.Suppose that is a discrete representation of the solution. Let denotethe row and column vectors of the solution respectively, and let Lx and Ly bediscrete update operators for the two respective operator split equations. Then weupdate the solution a follows.

uijn u u⋅ ⋅j

ninand

⋅+

⋅ ⋅+

⋅+

⋅+

⋅+

⋅+

⋅+

jn

x jn

in

y in

in

y in

jn

x jn

2 1 2 2 2 2 1

2 1 2 1 2 2 2 1

Omitting the spatial subscripts we see that an update from an even time step to thenext odd time step consists of an x sweep following by a y sweep, while odd stepsare updated by a y sweep followed by an x sweep.

2 1 2

2 2 2 1

ny x

n

nx y

n

+

+ +

The technique of alternating the order of the sweeps is called Strang splitting andincreases the order of accuracy of the 2D update from first to second orderassuming the one dimensional methods are at least second order accurate.

Page 17: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 17LA-UR 99-3985

1. Show that for the scalar advection equation ut + a ux = 0, a > 0, the Godunov method isfirst order accurate for smooth solutions. (Hint: the general solution of this equation isu(x,t) = f(x at) for an arbitrary function f(x).)

2. Show that the Lax-Wendroff method for the scalar advection equation corresponds to afinite central difference expansion of the equation ut + a ux = a2/2 t uxx. This illustratesthe presence of numerical viscosity in the Lax-Wendroff method. One goal of artificialviscosity is to cancel this viscous term.

3. Suppose that un(x) is periodic on the interval [- , ]. Define un+1(x) by the Lax-Wendroffupdate of un(x) for the scalar advection equation:

If ûn(k) are the Fourier coefficients of un(x) show that:

The quantity g is called the amplification matrix (here 1x1) of the difference method.Show that the stability condition a∆t/∆x < 1 is equivalent to the requirement thatg(a∆t/∆x, ) lies inside the unit circle except at = 0.

u x u x a tx

u x x u x x a tx

u x x u x u x xn n n n n n n+ = − + − − + + − + −121

212

2∆∆

∆ ∆ ∆∆

∆ ∆

u k g a tx

k x u k

g i

n n+ =

= − − −

1

21 1

∆∆

∆,

( , ) sin cosα β α β α β

Page 18: lecture03 - Stony Brook University

Los Alamos National LaboratoryHydrodynamic Methods Finite Difference Methods for Gas Dynamics 18LA-UR 99-3985

• R. Richtmyer and K. W. Morton, Difference Methods for Initial-Value Problem (2nd ed.),Interscience Publishers, 1967

• R. J. LeVeque, Numerical Methods for Conservation Laws, Birkhäuser, 1990.

• E. F. Toro, Riemann Solvers and Numerical Methods for Fluid Dynamics, Springer-Verlag, 1997.

• E. Godlewski, P.-A. Raviart, Numerical Approximation of Systems of HyperbolicConservation Laws, Springer-Verlag, 1996.

• See the references in the books of Toro, or Godlewski and Raviart for references to theoriginal papers of van Leer, Colella and Woodward, and Harten for more information onhigher order Godunov methods