lecture 10 - mathematicsmath.mit.edu/~stoopn/18.086/lecture10-11.pdf · nonlinear transport &...

32
Lecture 10 18.086

Upload: others

Post on 30-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Lecture 1018.086

Page 2: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Info• No lecture on Thursday in a week

(March 17)

• PSet back tonight

Page 3: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Nonlinear transport & conservation laws

• What if transport becomes nonlinear?

Page 4: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Remember: Nonlinear transport

• A first attempt at understanding what is going on comes from analyzing the characteristic lines

• Simplest example:

6.6 Nonlinear Flow and Conservation Laws 519

We mention two proposals that in principle can pass all our tests (but the fourth requirement of computational eficiency is a constant challenge to everybody):

IV. Spectral methods (often in the form of "mortared" finite elements)

V. Discontinuous Galerkin (different polynomials within each element)

That list is almost a rough guide to conferences on computational engineering. Look for accuracies p > 10 in spectral methods and p > 4 in DG methods. For stability, finite volume methods can add diffusion. Finite differences can use upwinding.

This section will explain how p = 2 has been attained without oscillation at shocks. Nonlinear smoot hers are added to Lax- Wendroff (I think only nonlinear terms can truly defeat Gibbs). Do not underestimate that achievement. Second order accuracy is the big step forward, and oscillation was once thought to be unavoidable.

Burgers' Equation and Characteristics

The outstanding example, together with traffic flow, is Burgers' equat ion wi th flux f (u) = $u2. The "inviscid" equation has no viscosity vu,, to prevent shocks:

du lnviscid Burgers' equation

dx

We will approach this conservation law in three ways:

1. By following characteristics until they separate or collide (trouble arrives)

2. By an exact formula (17), which is possible in one space dimension

3. By finite difference and finite volume methods, which are the practical choice.

A fourth (good) way adds vu,,. The limiting u as v -+ 0 is the viscosity solution. Start with the linear equation ut = c u, and u(x, t) = u(x + ct, 0). The initial

value at xo is carried along the characteristic line x + ct = xo. Those lines are parallel when the velocity c is a constant. No chance that characteristic lines will meet.

The conservation law ut + uu, = 0 will be solved by u(x, t) = u(x - ut, 0). Every initial value uo = u(xo, 0) is carried along a characteristic line x - uot = xo. Those lines are not parallel because their slopes depend on the initial value uo. For the conservation law ut + f (u), = 0, the characteristic lines are x - f '(uo)t = xo.

Example 3 The formula u ( x , t ) = u ( x - ut, 0) involves u on both sides. I t gives the solution "implicitly." If u(x, 0) = 1 - x at the start, the formula must be solved for u:

1-x Solution u = 1 - (x - ut) gives (I - t)u = I - x and u = -

1 - t This u solves Burgers' equation, since ut = (1 - x) / ( l - t)2 is equal to -2121,.

• We can use the implicit ansatz

• Characteristics for initial conditions all meet in (x,t)=(1,1)!

u(x, t) = u(x� ut, 0)

u(x, 0) = 1� x

• Solution is not defined at (x,t)=(1,1) => so what do we do?

6.6 Nonlinear Flow and Conservation Laws 519

We mention two proposals that in principle can pass all our tests (but the fourth requirement of computational eficiency is a constant challenge to everybody):

IV. Spectral methods (often in the form of "mortared" finite elements)

V. Discontinuous Galerkin (different polynomials within each element)

That list is almost a rough guide to conferences on computational engineering. Look for accuracies p > 10 in spectral methods and p > 4 in DG methods. For stability, finite volume methods can add diffusion. Finite differences can use upwinding.

This section will explain how p = 2 has been attained without oscillation at shocks. Nonlinear smoot hers are added to Lax- Wendroff (I think only nonlinear terms can truly defeat Gibbs). Do not underestimate that achievement. Second order accuracy is the big step forward, and oscillation was once thought to be unavoidable.

Burgers' Equation and Characteristics

The outstanding example, together with traffic flow, is Burgers' equat ion wi th flux f (u) = $u2. The "inviscid" equation has no viscosity vu,, to prevent shocks:

du lnviscid Burgers' equation

dx

We will approach this conservation law in three ways:

1. By following characteristics until they separate or collide (trouble arrives)

2. By an exact formula (17), which is possible in one space dimension

3. By finite difference and finite volume methods, which are the practical choice.

A fourth (good) way adds vu,,. The limiting u as v -+ 0 is the viscosity solution. Start with the linear equation ut = c u, and u(x, t) = u(x + ct, 0). The initial

value at xo is carried along the characteristic line x + ct = xo. Those lines are parallel when the velocity c is a constant. No chance that characteristic lines will meet.

The conservation law ut + uu, = 0 will be solved by u(x, t) = u(x - ut, 0). Every initial value uo = u(xo, 0) is carried along a characteristic line x - uot = xo. Those lines are not parallel because their slopes depend on the initial value uo. For the conservation law ut + f (u), = 0, the characteristic lines are x - f '(uo)t = xo.

Example 3 The formula u ( x , t ) = u ( x - ut, 0) involves u on both sides. I t gives the solution "implicitly." If u(x, 0) = 1 - x at the start, the formula must be solved for u:

1-x Solution u = 1 - (x - ut) gives (I - t)u = I - x and u = -

1 - t This u solves Burgers' equation, since ut = (1 - x) / ( l - t)2 is equal to -2121,.

Page 5: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Nonlinear transport & conservation laws

• A more famous example of issues with characteristics is the Riemann problem:

• Take again Burger’s equation:

6.6 Nonlinear Flow and Conservation Laws 519

We mention two proposals that in principle can pass all our tests (but the fourth requirement of computational eficiency is a constant challenge to everybody):

IV. Spectral methods (often in the form of "mortared" finite elements)

V. Discontinuous Galerkin (different polynomials within each element)

That list is almost a rough guide to conferences on computational engineering. Look for accuracies p > 10 in spectral methods and p > 4 in DG methods. For stability, finite volume methods can add diffusion. Finite differences can use upwinding.

This section will explain how p = 2 has been attained without oscillation at shocks. Nonlinear smoot hers are added to Lax- Wendroff (I think only nonlinear terms can truly defeat Gibbs). Do not underestimate that achievement. Second order accuracy is the big step forward, and oscillation was once thought to be unavoidable.

Burgers' Equation and Characteristics

The outstanding example, together with traffic flow, is Burgers' equat ion wi th flux f (u) = $u2. The "inviscid" equation has no viscosity vu,, to prevent shocks:

du lnviscid Burgers' equation

dx

We will approach this conservation law in three ways:

1. By following characteristics until they separate or collide (trouble arrives)

2. By an exact formula (17), which is possible in one space dimension

3. By finite difference and finite volume methods, which are the practical choice.

A fourth (good) way adds vu,,. The limiting u as v -+ 0 is the viscosity solution. Start with the linear equation ut = c u, and u(x, t) = u(x + ct, 0). The initial

value at xo is carried along the characteristic line x + ct = xo. Those lines are parallel when the velocity c is a constant. No chance that characteristic lines will meet.

The conservation law ut + uu, = 0 will be solved by u(x, t) = u(x - ut, 0). Every initial value uo = u(xo, 0) is carried along a characteristic line x - uot = xo. Those lines are not parallel because their slopes depend on the initial value uo. For the conservation law ut + f (u), = 0, the characteristic lines are x - f '(uo)t = xo.

Example 3 The formula u ( x , t ) = u ( x - ut, 0) involves u on both sides. I t gives the solution "implicitly." If u(x, 0) = 1 - x at the start, the formula must be solved for u:

1-x Solution u = 1 - (x - ut) gives (I - t)u = I - x and u = -

1 - t This u solves Burgers' equation, since ut = (1 - x) / ( l - t)2 is equal to -2121,.

• Riemann problem: How does solution evolve in time for initial conditions

520 Chapter 6 Initial Value Problems

When characteristic lines have different slopes, they can meet (carrying different uo). In this extreme example, all lines x - (1 - xo)t = xo meet at the same point x = 1, t = 1. The solution u = (1 - x ) / ( l - t) becomes 010 at that point. Beyond their meeting point, the characteristics cannot decide u(x, t).

A more fundamental example is the Riemann problem, which starts from two constant values u = A and u = B. Everything depends on whether A > B or A < B. On the left side of Figure 6.15, with A > B, the characteristics meet. On the right side, with A < B, the characteristics separate. In both cases, we don't have a single characteristic through each point that is safely carrying one correct initial value. This Riemann problem has two characteristics through some points, or none:

t t

A > B: shock A < B: fan

Figure 6.15: A shock when characteristics meet, a fan when they separate.

Shock Characteristics collide (light goes red: speed drops from 60 to 0) Fan Characteristics separate (light goes green: speed up from 0 to 60)

The Riemann problem is how to connect 60 with 0, when the characteristics don't give the answer. A shock will be sharp braking. Drivers only see the car ahead in this model. A fan will be gradual acceleration, as the cars speed up and spread out.

Shocks

After trouble arrives, the integral form will guide the choice of the correct solution u. Suppose u has different values UL and UR at points a = XL and b = XR on the left and right sides, close to the shock. Equation (1) decides where the jump must occur:

Integral form

Suppose the position of the shock is x = X ( t ) . Integrate from XL to X to XR. The values of u(x, t) inside the integral are close to the constants u~ and UR:

Left side XL, UL d . - [ ( X - X L ) ~ L + ( x R - X ) U R ] f f(uR)-f(uL) = O . (9) Right side XR, U R dt

u(x, 0) = A, x < 0 , and u(x, 0) = B, x � 0

Page 6: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

How to find shock wave or fan solution?

• Physically, we could add a bit of diffusion to avoid discontinuities, then let D -> 0

• Not very feasible numerically…

• Note: There is an example in the book (analytical) for

see Lect.

u

t

+ uu

x

= ✏u

x

x

Page 7: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Conservation laws• Burger’s equation

creates discontinuities

6.6 Nonlinear Flow and Conservation Laws 519

We mention two proposals that in principle can pass all our tests (but the fourth requirement of computational eficiency is a constant challenge to everybody):

IV. Spectral methods (often in the form of "mortared" finite elements)

V. Discontinuous Galerkin (different polynomials within each element)

That list is almost a rough guide to conferences on computational engineering. Look for accuracies p > 10 in spectral methods and p > 4 in DG methods. For stability, finite volume methods can add diffusion. Finite differences can use upwinding.

This section will explain how p = 2 has been attained without oscillation at shocks. Nonlinear smoot hers are added to Lax- Wendroff (I think only nonlinear terms can truly defeat Gibbs). Do not underestimate that achievement. Second order accuracy is the big step forward, and oscillation was once thought to be unavoidable.

Burgers' Equation and Characteristics

The outstanding example, together with traffic flow, is Burgers' equat ion wi th flux f (u) = $u2. The "inviscid" equation has no viscosity vu,, to prevent shocks:

du lnviscid Burgers' equation

dx

We will approach this conservation law in three ways:

1. By following characteristics until they separate or collide (trouble arrives)

2. By an exact formula (17), which is possible in one space dimension

3. By finite difference and finite volume methods, which are the practical choice.

A fourth (good) way adds vu,,. The limiting u as v -+ 0 is the viscosity solution. Start with the linear equation ut = c u, and u(x, t) = u(x + ct, 0). The initial

value at xo is carried along the characteristic line x + ct = xo. Those lines are parallel when the velocity c is a constant. No chance that characteristic lines will meet.

The conservation law ut + uu, = 0 will be solved by u(x, t) = u(x - ut, 0). Every initial value uo = u(xo, 0) is carried along a characteristic line x - uot = xo. Those lines are not parallel because their slopes depend on the initial value uo. For the conservation law ut + f (u), = 0, the characteristic lines are x - f '(uo)t = xo.

Example 3 The formula u ( x , t ) = u ( x - ut, 0) involves u on both sides. I t gives the solution "implicitly." If u(x, 0) = 1 - x at the start, the formula must be solved for u:

1-x Solution u = 1 - (x - ut) gives (I - t)u = I - x and u = -

1 - t This u solves Burgers' equation, since ut = (1 - x) / ( l - t)2 is equal to -2121,.

• Mathematical description using integral form (=conservation law)

• In general, conservation laws read

u

t

+ f(u, ux

, . . .)x

= 0 () d

dt

Zb

a

udx+ f(u(b), ux

(b), . . .)� f(u(a), ux

(a), . . .) = 0

• Special form above: Diffusion is also a conservation law…

Page 8: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Weak solutions• Integral form is not very handy, because we have to show it holds for all times and all intervals

• Instead: Use the weak form: Multiply PDE with a test function ɸ and integrate over time and space.

• Assuming ɸ has compact support (almost everywhere zero), integration by parts gives (for Burger’s equation):

• For Burgers eq: One can show (PSet 2) that the shock in the Riemann problem with initial condition

Z 1

0

Z 1

�1[�

t

u+ �

x

f(u)]dxdt = �Z 1

�1�(x, 0)u(x, 0)dx,

520 Chapter 6 Initial Value Problems

When characteristic lines have different slopes, they can meet (carrying different uo). In this extreme example, all lines x - (1 - xo)t = xo meet at the same point x = 1, t = 1. The solution u = (1 - x ) / ( l - t) becomes 010 at that point. Beyond their meeting point, the characteristics cannot decide u(x, t).

A more fundamental example is the Riemann problem, which starts from two constant values u = A and u = B. Everything depends on whether A > B or A < B. On the left side of Figure 6.15, with A > B, the characteristics meet. On the right side, with A < B, the characteristics separate. In both cases, we don't have a single characteristic through each point that is safely carrying one correct initial value. This Riemann problem has two characteristics through some points, or none:

t t

A > B: shock A < B: fan

Figure 6.15: A shock when characteristics meet, a fan when they separate.

Shock Characteristics collide (light goes red: speed drops from 60 to 0) Fan Characteristics separate (light goes green: speed up from 0 to 60)

The Riemann problem is how to connect 60 with 0, when the characteristics don't give the answer. A shock will be sharp braking. Drivers only see the car ahead in this model. A fan will be gradual acceleration, as the cars speed up and spread out.

Shocks

After trouble arrives, the integral form will guide the choice of the correct solution u. Suppose u has different values UL and UR at points a = XL and b = XR on the left and right sides, close to the shock. Equation (1) decides where the jump must occur:

Integral form

Suppose the position of the shock is x = X ( t ) . Integrate from XL to X to XR. The values of u(x, t) inside the integral are close to the constants u~ and UR:

Left side XL, UL d . - [ ( X - X L ) ~ L + ( x R - X ) U R ] f f(uR)-f(uL) = O . (9) Right side XR, U R dt

here: uL=0, uR =-1

is solved by:

with shock speed

Lecture

with uL>uR

s =uL + uR

2

u(x, 0) =

(uL x < 0

uR x > 0

u(x, t) =

(uL x < st

uR x > st

uRuL

uRuL

ut

+ fx

(u) = 0

Page 9: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

RH jump condition• The previous example was specific for Burger’s equation. But there is a

general condition that determines the shock speed.

• Rankine-Hugoniot (RH) jump condition:

s =f(uL)� f(uR)

uL � uR=

[f ]

[u]

• uL, uR: value of u on the left & right of the shock

• Also valid for initial conditions that are not piecewise linear. Then uL, uR: value of u infinitesimally close to shock

Lecture

The shock speed s of a conservation law with flux f is

Page 10: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Rarefaction waves• How does the Riemann problem look like when there are no shocks?

520 Chapter 6 Initial Value Problems

When characteristic lines have different slopes, they can meet (carrying different uo). In this extreme example, all lines x - (1 - xo)t = xo meet at the same point x = 1, t = 1. The solution u = (1 - x ) / ( l - t) becomes 010 at that point. Beyond their meeting point, the characteristics cannot decide u(x, t).

A more fundamental example is the Riemann problem, which starts from two constant values u = A and u = B. Everything depends on whether A > B or A < B. On the left side of Figure 6.15, with A > B, the characteristics meet. On the right side, with A < B, the characteristics separate. In both cases, we don't have a single characteristic through each point that is safely carrying one correct initial value. This Riemann problem has two characteristics through some points, or none:

t t

A > B: shock A < B: fan

Figure 6.15: A shock when characteristics meet, a fan when they separate.

Shock Characteristics collide (light goes red: speed drops from 60 to 0) Fan Characteristics separate (light goes green: speed up from 0 to 60)

The Riemann problem is how to connect 60 with 0, when the characteristics don't give the answer. A shock will be sharp braking. Drivers only see the car ahead in this model. A fan will be gradual acceleration, as the cars speed up and spread out.

Shocks

After trouble arrives, the integral form will guide the choice of the correct solution u. Suppose u has different values UL and UR at points a = XL and b = XR on the left and right sides, close to the shock. Equation (1) decides where the jump must occur:

Integral form

Suppose the position of the shock is x = X ( t ) . Integrate from XL to X to XR. The values of u(x, t) inside the integral are close to the constants u~ and UR:

Left side XL, UL d . - [ ( X - X L ) ~ L + ( x R - X ) U R ] f f(uR)-f(uL) = O . (9) Right side XR, U R dt

• Correct (weak) solution (for Burgers eq): Rarefaction wave:

u(x, t) =

8>><

>>:

uL x < uLtx

t

uLt x uRt

uR x > uRt

uL uR

uL uR

uL uR

• Think of cars starting to drive at green light…

• Unfortunately, a shock would also be a weak solution in this case!!!• We need another criterium to decide for a shock vs. a fan…

Page 11: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Entropy condition• Note that characteristics must collide for a shock to occur, while

they separate for fans. This can be formulated in the entropy condition:

f 0(uL) > s > f 0(uR)If => shocks otherwise: fans with u(x,t) = x/t

Page 12: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

A first numerical try• Simple idea: Discretize flux, not PDE!

6.6 Nonlinear Flow and Conservation Laws 525

Example 7 Two-phase flow (oil and water) in a porous medium. The equation for the water fraction u(x, t) can be written as a conservation law:

Buckley-Leverett

These conservation laws do not include dissipation. We try t o avoid resolving small scale processes like viscosity and diffusion and heat conduction. Their efFects will be felt in the "entropy condition" that chooses the physically correct solution (a shock or a fan in ID).

Difference Methods and Flux Functions

Now we turn to numerical methods for conservation laws. The key to a reliable difference method is to maintain the conservation ! Replace df /dx by dzflerences A f of the flux. Don't take the derivative df /dx = u u, and work with u times Au:

du d du du Start from - + - f (u) = 0 and not from - + f '(u) - = 0 . a t dx a t dx

You will see the idea immediately for the first-order upwind approximation:

Upwind (for f '>o) Uj,n+l - Uj,n f (Uj+l,n) - f (Uj,n) At + = 0 Ax

By staying with the flux f , this approximation preserves the conservation form. Since the equation is discrete, the integral u(x, t)dx is replaced by a sum of Ujn. The integral over a 5 x < b in equation (1) becomes a sum of the equations (24) over any integers A 5 j 5 B. The time derivative of u becomes a forward difference:

B Discrete conservation uj,n+l - uj , - FA,^) = 0 (25)

j=A

The change in mass C Ujn still comes from the flux. Notice how the flux f (Ujn) at intermediate points between A and B was added and subtracted (so it disappeared). The discrete sum form in (25) is parallel to the continuous integral form in (1).

The key decision in nonlinear finite differences is the flux function. Certainly we will want methods other than upwind. They will be nonlinear forms of Lax-Friedrichs and Lax-Wendroff and more. A valuable step for all approximate methods is to see that conservation comes automatically from a numerical flux function 1":

At Conservation form Uj,n+l - uj,n + [~ j+ l ,n - Fj,n] = 0 .

In the upwind method, the numerical flux is just Fj,, = f (Ujjn). In Lax-F'riedrichs and Lax-Wendroff, the flux will involve both Uj,, and Uj-l,n. Other methods have

• E.g. upwind finite differences (assuming f’ > 0)

6.6 Nonlinear Flow and Conservation Laws 525

Example 7 Two-phase flow (oil and water) in a porous medium. The equation for the water fraction u(x, t) can be written as a conservation law:

Buckley-Leverett

These conservation laws do not include dissipation. We try t o avoid resolving small scale processes like viscosity and diffusion and heat conduction. Their efFects will be felt in the "entropy condition" that chooses the physically correct solution (a shock or a fan in ID).

Difference Methods and Flux Functions

Now we turn to numerical methods for conservation laws. The key to a reliable difference method is to maintain the conservation ! Replace df /dx by dzflerences A f of the flux. Don't take the derivative df /dx = u u, and work with u times Au:

du d du du Start from - + - f (u) = 0 and not from - + f '(u) - = 0 . a t dx a t dx

You will see the idea immediately for the first-order upwind approximation:

Upwind (for f '>o) Uj,n+l - Uj,n f (Uj+l,n) - f (Uj,n) At + = 0 Ax

By staying with the flux f , this approximation preserves the conservation form. Since the equation is discrete, the integral u(x, t)dx is replaced by a sum of Ujn. The integral over a 5 x < b in equation (1) becomes a sum of the equations (24) over any integers A 5 j 5 B. The time derivative of u becomes a forward difference:

B Discrete conservation uj,n+l - uj , - FA,^) = 0 (25)

j=A

The change in mass C Ujn still comes from the flux. Notice how the flux f (Ujn) at intermediate points between A and B was added and subtracted (so it disappeared). The discrete sum form in (25) is parallel to the continuous integral form in (1).

The key decision in nonlinear finite differences is the flux function. Certainly we will want methods other than upwind. They will be nonlinear forms of Lax-Friedrichs and Lax-Wendroff and more. A valuable step for all approximate methods is to see that conservation comes automatically from a numerical flux function 1":

At Conservation form Uj,n+l - uj,n + [~ j+ l ,n - Fj,n] = 0 .

In the upwind method, the numerical flux is just Fj,, = f (Ujjn). In Lax-F'riedrichs and Lax-Wendroff, the flux will involve both Uj,, and Uj-l,n. Other methods have

6.6 Nonlinear Flow and Conservation Laws 525

Example 7 Two-phase flow (oil and water) in a porous medium. The equation for the water fraction u(x, t) can be written as a conservation law:

Buckley-Leverett

These conservation laws do not include dissipation. We try t o avoid resolving small scale processes like viscosity and diffusion and heat conduction. Their efFects will be felt in the "entropy condition" that chooses the physically correct solution (a shock or a fan in ID).

Difference Methods and Flux Functions

Now we turn to numerical methods for conservation laws. The key to a reliable difference method is to maintain the conservation ! Replace df /dx by dzflerences A f of the flux. Don't take the derivative df /dx = u u, and work with u times Au:

du d du du Start from - + - f (u) = 0 and not from - + f '(u) - = 0 . a t dx a t dx

You will see the idea immediately for the first-order upwind approximation:

Upwind (for f '>o) Uj,n+l - Uj,n f (Uj+l,n) - f (Uj,n) At + = 0 Ax

By staying with the flux f , this approximation preserves the conservation form. Since the equation is discrete, the integral u(x, t)dx is replaced by a sum of Ujn. The integral over a 5 x < b in equation (1) becomes a sum of the equations (24) over any integers A 5 j 5 B. The time derivative of u becomes a forward difference:

B Discrete conservation uj,n+l - uj , - FA,^) = 0 (25)

j=A

The change in mass C Ujn still comes from the flux. Notice how the flux f (Ujn) at intermediate points between A and B was added and subtracted (so it disappeared). The discrete sum form in (25) is parallel to the continuous integral form in (1).

The key decision in nonlinear finite differences is the flux function. Certainly we will want methods other than upwind. They will be nonlinear forms of Lax-Friedrichs and Lax-Wendroff and more. A valuable step for all approximate methods is to see that conservation comes automatically from a numerical flux function 1":

At Conservation form Uj,n+l - uj,n + [~ j+ l ,n - Fj,n] = 0 .

In the upwind method, the numerical flux is just Fj,, = f (Ujjn). In Lax-F'riedrichs and Lax-Wendroff, the flux will involve both Uj,, and Uj-l,n. Other methods have

• The advantage of this approach (apart from allowing discont. u) is that the conservation law is automatically fulfilled:

Lecture

Page 13: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Numerical flux function• In fact, we have just seen that any scheme of the form

Uj,n+1 � Uj,n

�t

=1

�x

[F (Uj�p,n, Uj�p+1,n, . . . , Uj+q,n)

�F (Uj�p+1,n, Uj�p+2,n, . . . , Uj+q+1,n)]

is a conservative scheme (meaning total U inside a domain is determined only by flux F at boundaries)

• Of course we cannot freely combine values of U into a flux:

526 Chapter 6 Initial Value Problems

flux functions that depend on several neighboring U's. We need a consistency condi- tion to guarantee that the numerical flux F is in line with the true flux f :

Consistency The flux F (Uj+,, . . . , Uj-,) satisfies F (u, . . . , u) = f (u). (27)

Under this condition, a convergent method will solve the right conservation law. The construction of numerical methods rest on a good choice of the flux function F.

Example 8 Watch how nonlinear Lax-Friedrichs fits into this conservation form:

To match equation (26), insert Uj,n-UJ,n into the parentheses and insert f (U,,,) - f (U,,,) into the brackets. This produces A t U / A t + A z F / A x = 0 with a new flux F :

1 Ax Lax-Friedrichs flux F~~ = 5 [f ( u ~ ) + f (u3+l)] - 2at(U3+l - UJ).

Finite Volume Methods

Finite volume methods do not think of Uj,, as an approximation to u(jAx,nAt). These methods connect directly to the integral form of the conservation law. So it is natural for U j , to approximate the cell average Tij,, from ( j - $)Ax to ( j + ;)Ax:

- 1 ( j + i ) ~ x Cell average Uj,n approximates uj,, = - / u(x, nAt) dx .

AX (,-+)AX (30)

Integrating ut + f (u), = 0 over a cell, the exact average satisfies the integral form (1):

Change in (3++)Ax

cell average '' I U(X, 1) dx + [f(uJ++,n) - i(uJ-+,n)] = 0 . dt (J-;)*x

(31)

The fluxes are at the midpoints where cells meet. And if we integrate also over a time step, then ut + f (u), = 0 is perfectly averaged over a space-time cell:

( j + + ) ~ x (3+4)Ax

Cell integrals /' U(X, t n + ~ ) dx - l-;)Ax U(X, tn) dx + (j-+)AX in x and t have

(n+l)At (n+l)At (32) htc + A,T = o

L A , f (uj+;,t) d t -

L A , f (u,-;, t ) dt = 0 .

• Question: How to choose flux F in the best way…

Page 14: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

A first numerical try• Upwind finite differences (assuming f’ > 0)

6.6 Nonlinear Flow and Conservation Laws 525

Example 7 Two-phase flow (oil and water) in a porous medium. The equation for the water fraction u(x, t) can be written as a conservation law:

Buckley-Leverett

These conservation laws do not include dissipation. We try t o avoid resolving small scale processes like viscosity and diffusion and heat conduction. Their efFects will be felt in the "entropy condition" that chooses the physically correct solution (a shock or a fan in ID).

Difference Methods and Flux Functions

Now we turn to numerical methods for conservation laws. The key to a reliable difference method is to maintain the conservation ! Replace df /dx by dzflerences A f of the flux. Don't take the derivative df /dx = u u, and work with u times Au:

du d du du Start from - + - f (u) = 0 and not from - + f '(u) - = 0 . a t dx a t dx

You will see the idea immediately for the first-order upwind approximation:

Upwind (for f '>o) Uj,n+l - Uj,n f (Uj+l,n) - f (Uj,n) At + = 0 Ax

By staying with the flux f , this approximation preserves the conservation form. Since the equation is discrete, the integral u(x, t)dx is replaced by a sum of Ujn. The integral over a 5 x < b in equation (1) becomes a sum of the equations (24) over any integers A 5 j 5 B. The time derivative of u becomes a forward difference:

B Discrete conservation uj,n+l - uj , - FA,^) = 0 (25)

j=A

The change in mass C Ujn still comes from the flux. Notice how the flux f (Ujn) at intermediate points between A and B was added and subtracted (so it disappeared). The discrete sum form in (25) is parallel to the continuous integral form in (1).

The key decision in nonlinear finite differences is the flux function. Certainly we will want methods other than upwind. They will be nonlinear forms of Lax-Friedrichs and Lax-Wendroff and more. A valuable step for all approximate methods is to see that conservation comes automatically from a numerical flux function 1":

At Conservation form Uj,n+l - uj,n + [~ j+ l ,n - Fj,n] = 0 .

In the upwind method, the numerical flux is just Fj,, = f (Ujjn). In Lax-F'riedrichs and Lax-Wendroff, the flux will involve both Uj,, and Uj-l,n. Other methods have

• We can extend this scheme to capture both flux directions:

• Using Fj,n = f(Uj,n), this can be written asUj,n+1 � Uj,n

�t

=1

�x

[Fj+1,n � Fj,n]

Fj,n =

(f(Uj,n) f 0(Uj,n) > 0

f(Uj�1,n) f 0(Uj,n) < 0

• First-order method, but fails for certain initial conditions (see LeVeque. p. 134)

Page 15: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Lecture 1118.086

Page 16: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Last time: Conservation laws• Burger’s equation

creates discontinuities

6.6 Nonlinear Flow and Conservation Laws 519

We mention two proposals that in principle can pass all our tests (but the fourth requirement of computational eficiency is a constant challenge to everybody):

IV. Spectral methods (often in the form of "mortared" finite elements)

V. Discontinuous Galerkin (different polynomials within each element)

That list is almost a rough guide to conferences on computational engineering. Look for accuracies p > 10 in spectral methods and p > 4 in DG methods. For stability, finite volume methods can add diffusion. Finite differences can use upwinding.

This section will explain how p = 2 has been attained without oscillation at shocks. Nonlinear smoot hers are added to Lax- Wendroff (I think only nonlinear terms can truly defeat Gibbs). Do not underestimate that achievement. Second order accuracy is the big step forward, and oscillation was once thought to be unavoidable.

Burgers' Equation and Characteristics

The outstanding example, together with traffic flow, is Burgers' equat ion wi th flux f (u) = $u2. The "inviscid" equation has no viscosity vu,, to prevent shocks:

du lnviscid Burgers' equation

dx

We will approach this conservation law in three ways:

1. By following characteristics until they separate or collide (trouble arrives)

2. By an exact formula (17), which is possible in one space dimension

3. By finite difference and finite volume methods, which are the practical choice.

A fourth (good) way adds vu,,. The limiting u as v -+ 0 is the viscosity solution. Start with the linear equation ut = c u, and u(x, t) = u(x + ct, 0). The initial

value at xo is carried along the characteristic line x + ct = xo. Those lines are parallel when the velocity c is a constant. No chance that characteristic lines will meet.

The conservation law ut + uu, = 0 will be solved by u(x, t) = u(x - ut, 0). Every initial value uo = u(xo, 0) is carried along a characteristic line x - uot = xo. Those lines are not parallel because their slopes depend on the initial value uo. For the conservation law ut + f (u), = 0, the characteristic lines are x - f '(uo)t = xo.

Example 3 The formula u ( x , t ) = u ( x - ut, 0) involves u on both sides. I t gives the solution "implicitly." If u(x, 0) = 1 - x at the start, the formula must be solved for u:

1-x Solution u = 1 - (x - ut) gives (I - t)u = I - x and u = -

1 - t This u solves Burgers' equation, since ut = (1 - x) / ( l - t)2 is equal to -2121,.

• Mathematical description using integral form (=conservation law)

• In general, conservation laws read

u

t

+ f(u, ux

, . . .)x

= 0 () d

dt

Zb

a

udx+ f(u(b), ux

(b), . . .)� f(u(a), ux

(a), . . .) = 0

• Special form above: Diffusion is also a conservation law…

Page 17: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Last time: RH jump condition

• The previous example was specific for Burger’s equation. But there is a general condition that determines the shock speed.

• Rankine-Hugoniot (RH) jump condition:

s =f(uL)� f(uR)

uL � uR=

[f ]

[u]

• uL, uR: value of u on the left & right of the shock

• Also valid for initial conditions that are not piecewise linear. Then uL, uR: value of u infinitesimally close to shock

Lecture

The shock speed s of a conservation law with flux f is

Page 18: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Last time: Conservation laws• Simple idea: Discretize flux, not PDE!

6.6 Nonlinear Flow and Conservation Laws 525

Example 7 Two-phase flow (oil and water) in a porous medium. The equation for the water fraction u(x, t) can be written as a conservation law:

Buckley-Leverett

These conservation laws do not include dissipation. We try t o avoid resolving small scale processes like viscosity and diffusion and heat conduction. Their efFects will be felt in the "entropy condition" that chooses the physically correct solution (a shock or a fan in ID).

Difference Methods and Flux Functions

Now we turn to numerical methods for conservation laws. The key to a reliable difference method is to maintain the conservation ! Replace df /dx by dzflerences A f of the flux. Don't take the derivative df /dx = u u, and work with u times Au:

du d du du Start from - + - f (u) = 0 and not from - + f '(u) - = 0 . a t dx a t dx

You will see the idea immediately for the first-order upwind approximation:

Upwind (for f '>o) Uj,n+l - Uj,n f (Uj+l,n) - f (Uj,n) At + = 0 Ax

By staying with the flux f , this approximation preserves the conservation form. Since the equation is discrete, the integral u(x, t)dx is replaced by a sum of Ujn. The integral over a 5 x < b in equation (1) becomes a sum of the equations (24) over any integers A 5 j 5 B. The time derivative of u becomes a forward difference:

B Discrete conservation uj,n+l - uj , - FA,^) = 0 (25)

j=A

The change in mass C Ujn still comes from the flux. Notice how the flux f (Ujn) at intermediate points between A and B was added and subtracted (so it disappeared). The discrete sum form in (25) is parallel to the continuous integral form in (1).

The key decision in nonlinear finite differences is the flux function. Certainly we will want methods other than upwind. They will be nonlinear forms of Lax-Friedrichs and Lax-Wendroff and more. A valuable step for all approximate methods is to see that conservation comes automatically from a numerical flux function 1":

At Conservation form Uj,n+l - uj,n + [~ j+ l ,n - Fj,n] = 0 .

In the upwind method, the numerical flux is just Fj,, = f (Ujjn). In Lax-F'riedrichs and Lax-Wendroff, the flux will involve both Uj,, and Uj-l,n. Other methods have

• E.g. upwind finite differences (assuming f’ > 0)

6.6 Nonlinear Flow and Conservation Laws 525

Example 7 Two-phase flow (oil and water) in a porous medium. The equation for the water fraction u(x, t) can be written as a conservation law:

Buckley-Leverett

These conservation laws do not include dissipation. We try t o avoid resolving small scale processes like viscosity and diffusion and heat conduction. Their efFects will be felt in the "entropy condition" that chooses the physically correct solution (a shock or a fan in ID).

Difference Methods and Flux Functions

Now we turn to numerical methods for conservation laws. The key to a reliable difference method is to maintain the conservation ! Replace df /dx by dzflerences A f of the flux. Don't take the derivative df /dx = u u, and work with u times Au:

du d du du Start from - + - f (u) = 0 and not from - + f '(u) - = 0 . a t dx a t dx

You will see the idea immediately for the first-order upwind approximation:

Upwind (for f '>o) Uj,n+l - Uj,n f (Uj+l,n) - f (Uj,n) At + = 0 Ax

By staying with the flux f , this approximation preserves the conservation form. Since the equation is discrete, the integral u(x, t)dx is replaced by a sum of Ujn. The integral over a 5 x < b in equation (1) becomes a sum of the equations (24) over any integers A 5 j 5 B. The time derivative of u becomes a forward difference:

B Discrete conservation uj,n+l - uj , - FA,^) = 0 (25)

j=A

The change in mass C Ujn still comes from the flux. Notice how the flux f (Ujn) at intermediate points between A and B was added and subtracted (so it disappeared). The discrete sum form in (25) is parallel to the continuous integral form in (1).

The key decision in nonlinear finite differences is the flux function. Certainly we will want methods other than upwind. They will be nonlinear forms of Lax-Friedrichs and Lax-Wendroff and more. A valuable step for all approximate methods is to see that conservation comes automatically from a numerical flux function 1":

At Conservation form Uj,n+l - uj,n + [~ j+ l ,n - Fj,n] = 0 .

In the upwind method, the numerical flux is just Fj,, = f (Ujjn). In Lax-F'riedrichs and Lax-Wendroff, the flux will involve both Uj,, and Uj-l,n. Other methods have

• Advantage: conservation law is automatically fulfilled!

Uj,n+1 � Uj,n

�t

=1

�x

[Fj+1,n � Fj,n]

• Using Fj,n = f(Uj,n), this can be written as

• We can extend this scheme to capture both flux directions:

Fj,n =

(f(Uj,n) f 0(Uj,n) > 0

f(Uj�1,n) f 0(Uj,n) < 0

Page 19: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Lax-Friedrichs for nonlinear conservation laws

• Remember Lax-Friedrichs for linear 1-way wave eq:

6.3 Accuracy and Stability for ut = c ux 479

Figure 6.7: The upwind (forward difference) method is stable for r = % but not d . Those coefficients 1 and r/2 and 9 - 1 2 go into the growth factor G, when the solution is a pure exponential and eikx is factored out:

Unstable: IGI > 1 G = l + - e ikAx - Te-ikAx - 2 2

- 1 + ir sin k A x . (19)

The real part is 1. The magnitude is I GI 2 1. Its graph is on the left side of Figure 6.8.

3. Lax-F'riedrichs recovers stability for centered differences by changing the time difference. Replace U j , by the average f ( ~ j + ~ , ~ + Uj-l,n) of its neighbors:

1 uj,n+l - 5(uj+l,n uj-1,n) Uj+l,n - Uj-l,n Lax- Friedrichs

At = C

2Ax

Two old values Uj+l,n and Uj_l,n produce each new value Uj,,+1. Moving terms to the right-hand side, the coefficients are f (1 + r) and 4 (1 - r). The growth factor is

' + ,ikAx ' - -ikAz - G = - +- e - cos k A x + ir sin k A x . 2 2

The absolute value is [GI2 = (cos AX)^ + r2(sin AX)^. In Figure 6.8, IGI < 1 when r2 5 1. This stability condition agrees again with the CFL condition.

Forward in time-centered in space + G = l + i r s i n k A x

Lax-F'riedrichs G = cos kAx + ir sin kAx -,

Stable for r2 < - 1

Figure 6.8: Equation (18) is unstable for all r . Equation (20) is stable for r2 5 1.

Notice that c and r can be negative. The wave can go either way. This will be useful for the two-way wave equation, but the accuracy is still first-order. The

• The nonlinear, conservative formulation is:

526 Chapter 6 Initial Value Problems

flux functions that depend on several neighboring U's. We need a consistency condi- tion to guarantee that the numerical flux F is in line with the true flux f :

Consistency The flux F (Uj+,, . . . , Uj-,) satisfies F (u, . . . , u) = f (u). (27)

Under this condition, a convergent method will solve the right conservation law. The construction of numerical methods rest on a good choice of the flux function F.

Example 8 Watch how nonlinear Lax-Friedrichs fits into this conservation form:

To match equation (26), insert Uj,n-UJ,n into the parentheses and insert f (U,,,) - f (U,,,) into the brackets. This produces A t U / A t + A z F / A x = 0 with a new flux F :

1 Ax Lax-Friedrichs flux F~~ = 5 [f ( u ~ ) + f (u3+l)] - 2at(U3+l - UJ).

Finite Volume Methods

Finite volume methods do not think of Uj,, as an approximation to u(jAx,nAt). These methods connect directly to the integral form of the conservation law. So it is natural for U j , to approximate the cell average Tij,, from ( j - $)Ax to ( j + ;)Ax:

- 1 ( j + i ) ~ x Cell average Uj,n approximates uj,, = - / u(x, nAt) dx .

AX (,-+)AX (30)

Integrating ut + f (u), = 0 over a cell, the exact average satisfies the integral form (1):

Change in (3++)Ax

cell average '' I U(X, 1) dx + [f(uJ++,n) - i(uJ-+,n)] = 0 . dt (J-;)*x

(31)

The fluxes are at the midpoints where cells meet. And if we integrate also over a time step, then ut + f (u), = 0 is perfectly averaged over a space-time cell:

( j + + ) ~ x (3+4)Ax

Cell integrals /' U(X, t n + ~ ) dx - l-;)Ax U(X, tn) dx + (j-+)AX in x and t have

(n+l)At (n+l)At (32) htc + A,T = o

L A , f (uj+;,t) d t -

L A , f (u,-;, t ) dt = 0 .

526 Chapter 6 Initial Value Problems

flux functions that depend on several neighboring U's. We need a consistency condi- tion to guarantee that the numerical flux F is in line with the true flux f :

Consistency The flux F (Uj+,, . . . , Uj-,) satisfies F (u, . . . , u) = f (u). (27)

Under this condition, a convergent method will solve the right conservation law. The construction of numerical methods rest on a good choice of the flux function F.

Example 8 Watch how nonlinear Lax-Friedrichs fits into this conservation form:

To match equation (26), insert Uj,n-UJ,n into the parentheses and insert f (U,,,) - f (U,,,) into the brackets. This produces A t U / A t + A z F / A x = 0 with a new flux F :

1 Ax Lax-Friedrichs flux F~~ = 5 [f ( u ~ ) + f (u3+l)] - 2at(U3+l - UJ).

Finite Volume Methods

Finite volume methods do not think of Uj,, as an approximation to u(jAx,nAt). These methods connect directly to the integral form of the conservation law. So it is natural for U j , to approximate the cell average Tij,, from ( j - $)Ax to ( j + ;)Ax:

- 1 ( j + i ) ~ x Cell average Uj,n approximates uj,, = - / u(x, nAt) dx .

AX (,-+)AX (30)

Integrating ut + f (u), = 0 over a cell, the exact average satisfies the integral form (1):

Change in (3++)Ax

cell average '' I U(X, 1) dx + [f(uJ++,n) - i(uJ-+,n)] = 0 . dt (J-;)*x

(31)

The fluxes are at the midpoints where cells meet. And if we integrate also over a time step, then ut + f (u), = 0 is perfectly averaged over a space-time cell:

( j + + ) ~ x (3+4)Ax

Cell integrals /' U(X, t n + ~ ) dx - l-;)Ax U(X, tn) dx + (j-+)AX in x and t have

(n+l)At (n+l)At (32) htc + A,T = o

L A , f (uj+;,t) d t -

L A , f (u,-;, t ) dt = 0 .

• This can be written in the standard discrete conservative form (see before)

by introducing the LF flux

j+1

Uj,n+1 � Uj,n

�t

=1

�x

[Fj+1,n � Fj,n]

Page 20: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Lax-Friedrichs for nonlinear conservation laws

• As in the linear case, Lax-Friedrichs is only first-order accurate.• It captures both directions, but the central difference flux term creates extra

diffusion!

• We could just try to use Lax-Wendroff (which was second order), but this creates oscillations…

• Schemes that avoid oscillations are called total variation diminishing (TVD) methods

• Define total variation (TV):

528 Chapter 6 Initial Value Problems

Godunov's integral is easy because the solution E is constant up that line x = x3+;. It is coming along characteristics from the constant initial value UJln. We only have to ensure that no characteristics coming from neighboring constants Uj-lln or U3+11n reach that line before the time step ends. The Courant-Friedrichs-Lewy stability condition for Godunov will be r = I f '(u)lAt/Ax 5 4 , because a characteristic from outside need only cross half a cell to reach x j+t .

For ut = cu,, upwind and Godunov are identical. The important point is that Godunov's met hod deals naturally with systems of conservation laws. Those give n scalar Riemann problems and n characteristics. The bad point is that the piecewise constant construction only allows first-order accuracy. This will be fixed by a combination of Godunov and Lax-Wendroff. Above all, the essential idea is to control oscillations by a "flux limiter."

These first-order methods, upwind and Lax-Friedrichs and Godunov, correspond to difference equations Uj,,+l = xakUj+k ln in which all coeficients have ak 2 0. These are m o n o t o n e schemes, stable but only first-order accurate (Problem 4, Section 6.3). A nonlinear scheme is monotone provided its flux function F decreases when any U3+k,n increases. We move on to Lax-Wendroff, which is not monotone.

Lax-Wendroff with Flux Limiter

For linear ut + au, = 0 with r = a AtlAx, the Lax-Wendroff method adds ~ T ~ A ~ U , , ~ to the Lax-Friedrichs formula for UJ,n+l. Equivalently, it adds i(r2 - r)A:U,, to the upwind formula. This cancels the first-order error and upgrades the accuracy to second-order. But oscillations come in. We write the Lax-Wendroff flux in this linear case f (u) = au, to show the new term that is added to the upwind flux F UP = aU.

Lax- Wendroff flux a > 0, wind from left FUN I + T = au3 + a (I - g) (uj+1 - u ~ ) .

2

Everybody looks closely at that last term. It has taken a lot of care to modify this formula so that oscillations are controlled. A good measure of the oscillation of both u and U is the to t a l variation, which adds all movements up and down:

O" du 03

Total variation TV(u) = /__ 1 1 dx TV(U) = x IUJ+I - U,I -03

(36)

A TVD method (total variation diminishing) achieves TV(Un+l) < TV(Un). This will preserve the property of the true solution, that TV(u(t)) never increases. Shocks can only reduce TV(u), from the entropy condition in a nonlinear conservation law. But a linear TVD method cannot exceed first-order accuracy. The Lax-Wendroff oscillations increase TV(U). We need a nonlinear method even for a linear problem!

• A TVD method has the property

528 Chapter 6 Initial Value Problems

Godunov's integral is easy because the solution E is constant up that line x = x3+;. It is coming along characteristics from the constant initial value UJln. We only have to ensure that no characteristics coming from neighboring constants Uj-lln or U3+11n reach that line before the time step ends. The Courant-Friedrichs-Lewy stability condition for Godunov will be r = I f '(u)lAt/Ax 5 4 , because a characteristic from outside need only cross half a cell to reach x j+t .

For ut = cu,, upwind and Godunov are identical. The important point is that Godunov's met hod deals naturally with systems of conservation laws. Those give n scalar Riemann problems and n characteristics. The bad point is that the piecewise constant construction only allows first-order accuracy. This will be fixed by a combination of Godunov and Lax-Wendroff. Above all, the essential idea is to control oscillations by a "flux limiter."

These first-order methods, upwind and Lax-Friedrichs and Godunov, correspond to difference equations Uj,,+l = xakUj+k ln in which all coeficients have ak 2 0. These are m o n o t o n e schemes, stable but only first-order accurate (Problem 4, Section 6.3). A nonlinear scheme is monotone provided its flux function F decreases when any U3+k,n increases. We move on to Lax-Wendroff, which is not monotone.

Lax-Wendroff with Flux Limiter

For linear ut + au, = 0 with r = a AtlAx, the Lax-Wendroff method adds ~ T ~ A ~ U , , ~ to the Lax-Friedrichs formula for UJ,n+l. Equivalently, it adds i(r2 - r)A:U,, to the upwind formula. This cancels the first-order error and upgrades the accuracy to second-order. But oscillations come in. We write the Lax-Wendroff flux in this linear case f (u) = au, to show the new term that is added to the upwind flux F UP = aU.

Lax- Wendroff flux a > 0, wind from left FUN I + T = au3 + a (I - g) (uj+1 - u ~ ) .

2

Everybody looks closely at that last term. It has taken a lot of care to modify this formula so that oscillations are controlled. A good measure of the oscillation of both u and U is the to t a l variation, which adds all movements up and down:

O" du 03

Total variation TV(u) = /__ 1 1 dx TV(U) = x IUJ+I - U,I -03

(36)

A TVD method (total variation diminishing) achieves TV(Un+l) < TV(Un). This will preserve the property of the true solution, that TV(u(t)) never increases. Shocks can only reduce TV(u), from the entropy condition in a nonlinear conservation law. But a linear TVD method cannot exceed first-order accuracy. The Lax-Wendroff oscillations increase TV(U). We need a nonlinear method even for a linear problem!

Page 21: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Godunov’s method• Some problems so far:

• Upwind is good, but we need to know direction (i.e. velocity) of wave. Problem: System of equations!

• Lax-Friedrichs has no upwind direction problems, but high diffusion and thus low accuracy

• 2nd order methods (e.g. LW) are prone to oscillations.

• How can we find schemes (in particular numerical flux functions) that are high order, direction-independent and TVD?

• Godunov’s method: A systematic way to construct TVD numerical flux functions (more details in Strang’s book and in R.J. LeVeque, Numerical Methods for Conservation Laws)

Linear numerical schemes for solving partial differential equations (PDE’s) that are TVD can be at most first-order accurate.

• But: Godunov’s theorem:

Page 22: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Flux-limiting methods• Linear in Godunov’s theorem means a scheme where the scheme itself

(flux function, coefficients etc.) are constant, i.e do not change their form depending on the current solution.

• => Use nonlinear numerical scheme, e.g. flux-limiter methods• Idea: Combine high-order flux FH (good for smooth part) with low-order

flux FL (TVD, good for shock)

176 16 High Resolution Methods

plus some artificial viscosity, but the resulting viscosity coefficient is typically very com-plicated and not at all intuitive.

There are a wide variety of approaches that can be taken, and often there are closeconnections between the methods developed by quite different means. We will concentrateon just two classes of methods that are quite popular: flux-limiter methods and slope-limiter methods. More comprehensive reviews of many high resolution methods are givenby Colella and Woodward[98] and Zalesak(102].

16.2 Flux-limiter methodsIn this approach, we begin by choosing a high order flux FH(U; j) (e.g., the Lax-Wendroffflux) that works well in smooth regions, and a low order flux F,,(U; j) (typically somemonotone method) that behaves well near discontinuities. We then attempt to hybridizethese two into a single flux F in such a way that F reduces to F in smooth regions and toFL near discontinuities. The main idea is outlined here, although for nonlinear problemsthe actual hybridization may be more complicated.

We can view the high order flux as consisting of the low order flux plus a correction:

F,(U;j) = FL(U;j) + [F,(U;j) - Fr.(U;j)]. (16.9)

In a flux-limiter method, the magnitude of this correction is limited depending on thedata, so the flux becomes

F(U;j) = FL(U;j) + 4'(U;j) [FH(U;j) - FL(U;j)] (16.10)

where 4(U; j) is the limiter. If the data U is smooth near U; then 4(U; j) should be nearI while in the vicinity of a discontinuity we want 4(U; j) to be near zero. (In practice,allowing a wider range of values for' often works better.)

Note that we can rewrite (16.10) as

F(U;j) = F,(U;j) - (1 - 4(U;j))[Fs(U;j) - FL.(U;j)1 (16.11)

and comparison with (16.8) gives the equivalent artificial viscosity for this type of method.One of the earliest high resolution methods, the flux-corrected transport (FCT)

method of Boris and Book[2], can be viewed as a flux-limiter method. They refer to thecorrection term in (16.9) as the antidiffusive flux, since the low order flux F. contains toomuch diffusion for smooth data and the correction compensates. The FCT strategy is toadd in as much of this antidiffusive flux as possible without increasing the variation ofthe solution, leading to a simple and effective algorithm.

Ilybrid methods of this form were also introduced by Harten and Zwas[36] at roughlythe same time. More recently, a wide variety of methods of this form have been proposed,e.g., (27], (60], [651, [101].

• Choose 𝚽 close to 0 near shock, near 1 away from shock

Page 23: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Flux-limiter for Lax-Wendroff• Remember Lax-Wendroff for 1-way wave eq. ut+aux=0

Uj,n+1 � Uj,n

�t

= �a

Uj+1,n � Uj�1,n

2�x

+�t

2a

2Uj+1,n � 2Uj,n + Uj�1,n

�x

2

• Can write it like an “upwind plus correction” method:

Uj,n+1 = Uj,n � r(Uj,n � Uj�1,n)�1

2r(1� r)(Uj+1,n � 2Uj,n + Uj�1,n)

F (U, j) = aUj +1

2a(1� r)(Uj+1 � Uj)

• Corresponding flux:

Then, LW can be written as (Fj+1,n = F(U,j+1) etc.)Uj,n+1 � Uj,n

�t

=1

�x

[Fj+1,n � Fj,n]

Lecture

• The correction term increases accuracy (next term in series expansion), but we have seen it leads to oscillations

Page 24: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Flux-limiter for Lax-WendroffF (U, j) = aUj +

1

2a(1� r)(Uj+1 � Uj)

• Lax-Wendroff flux (prev. slide):

• This flux is an upwind flux (aUj) corrected with a high-order flux! • We replace F(U,j) by

F (U, j) = aUj +1

2a(1� r)(Uj+1 � Uj)�j

• How should we choose ? �j

• Naturally, it should depend on the quantity close to 1 for U smoothfar from 1 for shock in U

• It can be shown: No oscillations for

0 �(✓) 2✓ and 0 �(✓) 2

✓j =Uj � Uj�1

Uj+1 � Uj

for all 𝛳

• For nonlinear equations: replace speed a by the local speed (see LeVeque, p. 181)

Page 25: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Flux-limiter for Lax-Wendroff

• Choices for �(✓)

6.6 Nonlinear Flow and Conservation Laws 529

The key idea is to limit the higher accuracy term in Lax-Wendroff by a "flux limiter" 4j+f that switches away from 1 at a shock. Choosing 4 is all-important:

Flux-limited . . ~ I l r n l t = Lax-Wendroff 3+;

Thus # = 1 is Lax-Wendroff and q5 = 0 is upwind. For best accuracy we come as near to q5 = 1 as the TVD condition will allow. How to know when 4 stops oscillations?

A shock is diagnosed by the slope ratio rj that compares successive differences:

Slope ratio near 0 at a shock near 1 for smooth U

The flux factor 4j+1 will involve this ratio rj . A monotone flux function F in (37) and a TVD difference method require two conditions derived in [ l o g , 1101 :

TVD conditions O < # ( r ) < 2 r and 0 < 4 ( r ) < 2 . (39)

Summary We have reached high resolution without unacceptable oscillations. Linear Lax-Wendroff violates (39) for small r , but Figure 6.18 shows three choices of the flux limiter $(r ) that will keep the flux function monotone. A key step forward.

LW 2t is not total vari tion diminis k ,

Figure 6.18: Three flux limiters +(r) that satisfy the conditions (39) for TVD.

The KdV Equation

Let me end with the Korteweg-deVries equation, not because it is typical but because it is so remarkable. Its unique features are not obvious from the equation itself:

KdV equation ut + 6 u u x +u,,, = 0 . (40)

𝜙(𝛳)

𝛳

F (U, j) = aUj +1

2a(1� r)(Uj+1 � Uj)�j

• LW-flux with flux-limiter:

Page 26: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Finite volume method• Another interpretation of the discrete conservation law: Finite volume method• Directly approximates the integral form:

526 Chapter 6 Initial Value Problems

flux functions that depend on several neighboring U's. We need a consistency condi- tion to guarantee that the numerical flux F is in line with the true flux f :

Consistency The flux F (Uj+,, . . . , Uj-,) satisfies F (u, . . . , u) = f (u). (27)

Under this condition, a convergent method will solve the right conservation law. The construction of numerical methods rest on a good choice of the flux function F.

Example 8 Watch how nonlinear Lax-Friedrichs fits into this conservation form:

To match equation (26), insert Uj,n-UJ,n into the parentheses and insert f (U,,,) - f (U,,,) into the brackets. This produces A t U / A t + A z F / A x = 0 with a new flux F :

1 Ax Lax-Friedrichs flux F~~ = 5 [f ( u ~ ) + f (u3+l)] - 2at(U3+l - UJ).

Finite Volume Methods

Finite volume methods do not think of Uj,, as an approximation to u(jAx,nAt). These methods connect directly to the integral form of the conservation law. So it is natural for U j , to approximate the cell average Tij,, from ( j - $)Ax to ( j + ;)Ax:

- 1 ( j + i ) ~ x Cell average Uj,n approximates uj,, = - / u(x, nAt) dx .

AX (,-+)AX (30)

Integrating ut + f (u), = 0 over a cell, the exact average satisfies the integral form (1):

Change in (3++)Ax

cell average '' I U(X, 1) dx + [f(uJ++,n) - i(uJ-+,n)] = 0 . dt (J-;)*x

(31)

The fluxes are at the midpoints where cells meet. And if we integrate also over a time step, then ut + f (u), = 0 is perfectly averaged over a space-time cell:

( j + + ) ~ x (3+4)Ax

Cell integrals /' U(X, t n + ~ ) dx - l-;)Ax U(X, tn) dx + (j-+)AX in x and t have

(n+l)At (n+l)At (32) htc + A,T = o

L A , f (uj+;,t) d t -

L A , f (u,-;, t ) dt = 0 .

526 Chapter 6 Initial Value Problems

flux functions that depend on several neighboring U's. We need a consistency condi- tion to guarantee that the numerical flux F is in line with the true flux f :

Consistency The flux F (Uj+,, . . . , Uj-,) satisfies F (u, . . . , u) = f (u). (27)

Under this condition, a convergent method will solve the right conservation law. The construction of numerical methods rest on a good choice of the flux function F.

Example 8 Watch how nonlinear Lax-Friedrichs fits into this conservation form:

To match equation (26), insert Uj,n-UJ,n into the parentheses and insert f (U,,,) - f (U,,,) into the brackets. This produces A t U / A t + A z F / A x = 0 with a new flux F :

1 Ax Lax-Friedrichs flux F~~ = 5 [f ( u ~ ) + f (u3+l)] - 2at(U3+l - UJ).

Finite Volume Methods

Finite volume methods do not think of Uj,, as an approximation to u(jAx,nAt). These methods connect directly to the integral form of the conservation law. So it is natural for U j , to approximate the cell average Tij,, from ( j - $)Ax to ( j + ;)Ax:

- 1 ( j + i ) ~ x Cell average Uj,n approximates uj,, = - / u(x, nAt) dx .

AX (,-+)AX (30)

Integrating ut + f (u), = 0 over a cell, the exact average satisfies the integral form (1):

Change in (3++)Ax

cell average '' I U(X, 1) dx + [f(uJ++,n) - i(uJ-+,n)] = 0 . dt (J-;)*x

(31)

The fluxes are at the midpoints where cells meet. And if we integrate also over a time step, then ut + f (u), = 0 is perfectly averaged over a space-time cell:

( j + + ) ~ x (3+4)Ax

Cell integrals /' U(X, t n + ~ ) dx - l-;)Ax U(X, tn) dx + (j-+)AX in x and t have

(n+l)At (n+l)At (32) htc + A,T = o

L A , f (uj+;,t) d t -

L A , f (u,-;, t ) dt = 0 .

526 Chapter 6 Initial Value Problems

flux functions that depend on several neighboring U's. We need a consistency condi- tion to guarantee that the numerical flux F is in line with the true flux f :

Consistency The flux F (Uj+,, . . . , Uj-,) satisfies F (u, . . . , u) = f (u). (27)

Under this condition, a convergent method will solve the right conservation law. The construction of numerical methods rest on a good choice of the flux function F.

Example 8 Watch how nonlinear Lax-Friedrichs fits into this conservation form:

To match equation (26), insert Uj,n-UJ,n into the parentheses and insert f (U,,,) - f (U,,,) into the brackets. This produces A t U / A t + A z F / A x = 0 with a new flux F :

1 Ax Lax-Friedrichs flux F~~ = 5 [f ( u ~ ) + f (u3+l)] - 2at(U3+l - UJ).

Finite Volume Methods

Finite volume methods do not think of Uj,, as an approximation to u(jAx,nAt). These methods connect directly to the integral form of the conservation law. So it is natural for U j , to approximate the cell average Tij,, from ( j - $)Ax to ( j + ;)Ax:

- 1 ( j + i ) ~ x Cell average Uj,n approximates uj,, = - / u(x, nAt) dx .

AX (,-+)AX (30)

Integrating ut + f (u), = 0 over a cell, the exact average satisfies the integral form (1):

Change in (3++)Ax

cell average '' I U(X, 1) dx + [f(uJ++,n) - i(uJ-+,n)] = 0 . dt (J-;)*x

(31)

The fluxes are at the midpoints where cells meet. And if we integrate also over a time step, then ut + f (u), = 0 is perfectly averaged over a space-time cell:

( j + + ) ~ x (3+4)Ax

Cell integrals /' U(X, t n + ~ ) dx - l-;)Ax U(X, tn) dx + (j-+)AX in x and t have

(n+l)At (n+l)At (32) htc + A,T = o

L A , f (uj+;,t) d t -

L A , f (u,-;, t ) dt = 0 .

• Integrate in time from n to n+1 to obtain the finite volume conservation law

Page 27: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Finite volume method

526 Chapter 6 Initial Value Problems

flux functions that depend on several neighboring U's. We need a consistency condi- tion to guarantee that the numerical flux F is in line with the true flux f :

Consistency The flux F (Uj+,, . . . , Uj-,) satisfies F (u, . . . , u) = f (u). (27)

Under this condition, a convergent method will solve the right conservation law. The construction of numerical methods rest on a good choice of the flux function F.

Example 8 Watch how nonlinear Lax-Friedrichs fits into this conservation form:

To match equation (26), insert Uj,n-UJ,n into the parentheses and insert f (U,,,) - f (U,,,) into the brackets. This produces A t U / A t + A z F / A x = 0 with a new flux F :

1 Ax Lax-Friedrichs flux F~~ = 5 [f ( u ~ ) + f (u3+l)] - 2at(U3+l - UJ).

Finite Volume Methods

Finite volume methods do not think of Uj,, as an approximation to u(jAx,nAt). These methods connect directly to the integral form of the conservation law. So it is natural for U j , to approximate the cell average Tij,, from ( j - $)Ax to ( j + ;)Ax:

- 1 ( j + i ) ~ x Cell average Uj,n approximates uj,, = - / u(x, nAt) dx .

AX (,-+)AX (30)

Integrating ut + f (u), = 0 over a cell, the exact average satisfies the integral form (1):

Change in (3++)Ax

cell average '' I U(X, 1) dx + [f(uJ++,n) - i(uJ-+,n)] = 0 . dt (J-;)*x

(31)

The fluxes are at the midpoints where cells meet. And if we integrate also over a time step, then ut + f (u), = 0 is perfectly averaged over a space-time cell:

( j + + ) ~ x (3+4)Ax

Cell integrals /' U(X, t n + ~ ) dx - l-;)Ax U(X, tn) dx + (j-+)AX in x and t have

(n+l)At (n+l)At (32) htc + A,T = o

L A , f (uj+;,t) d t -

L A , f (u,-;, t ) dt = 0 .

• Using the integral form

can be written as

526 Chapter 6 Initial Value Problems

flux functions that depend on several neighboring U's. We need a consistency condi- tion to guarantee that the numerical flux F is in line with the true flux f :

Consistency The flux F (Uj+,, . . . , Uj-,) satisfies F (u, . . . , u) = f (u). (27)

Under this condition, a convergent method will solve the right conservation law. The construction of numerical methods rest on a good choice of the flux function F.

Example 8 Watch how nonlinear Lax-Friedrichs fits into this conservation form:

To match equation (26), insert Uj,n-UJ,n into the parentheses and insert f (U,,,) - f (U,,,) into the brackets. This produces A t U / A t + A z F / A x = 0 with a new flux F :

1 Ax Lax-Friedrichs flux F~~ = 5 [f ( u ~ ) + f (u3+l)] - 2at(U3+l - UJ).

Finite Volume Methods

Finite volume methods do not think of Uj,, as an approximation to u(jAx,nAt). These methods connect directly to the integral form of the conservation law. So it is natural for U j , to approximate the cell average Tij,, from ( j - $)Ax to ( j + ;)Ax:

- 1 ( j + i ) ~ x Cell average Uj,n approximates uj,, = - / u(x, nAt) dx .

AX (,-+)AX (30)

Integrating ut + f (u), = 0 over a cell, the exact average satisfies the integral form (1):

Change in (3++)Ax

cell average '' I U(X, 1) dx + [f(uJ++,n) - i(uJ-+,n)] = 0 . dt (J-;)*x

(31)

The fluxes are at the midpoints where cells meet. And if we integrate also over a time step, then ut + f (u), = 0 is perfectly averaged over a space-time cell:

( j + + ) ~ x (3+4)Ax

Cell integrals /' U(X, t n + ~ ) dx - l-;)Ax U(X, tn) dx + (j-+)AX in x and t have

(n+l)At (n+l)At (32) htc + A,T = o

L A , f (uj+;,t) d t -

L A , f (u,-;, t ) dt = 0 .

1

�t

(uj,n+1 � uj,n) +1

�t

1

�x

Z (n+1)�t

n�tf(uj+ 1

2, t)dt� 1

�t

1

�x

Z (n+1)�t

n�tf(uj� 1

2, t)dt = 0

Using the time-averaged flux this becomes

1

�t

(uj,n+1 � uj,n) +1

�x

⇣fj+ 1

2 ,n� fj� 1

2 ,n

⌘= 0

fj+ 12 ,n

=1

�t

Z (n+1)�t

n�tf(uj+ 1

2, t)dt

Page 28: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Finite volume method• Treat as independent variables Uj,n, approximate average fluxes by :uj,n

• Easiest choice for numerical flux F: Assume f is constant over one time step, ie.

• Note: We need to interpolate U to half-grid points!

6.6 Nonlinear Flow and Conservation Laws 527

Figure 6.17: Flux balance is exact for 'ii, f and approximate for U, F in (33).

The total mass in a cell changes between t, and tntl by the total flux into that cell. Thus finite volume methods come with a staggered grid in space-time (Figure 6.17). On this staggered grid we must write the numerical flux as Fj+; rather than F,:

Finite volume 1 1 - At (Uj.n+l - uj,n) + ( ~ j + $ , ~ -5-1,) 2 ' = O . (33)

Morton and Sonar give a detailed analysis of finite volume methods, with optimal recovery to increase accuracy (since all test functions V are piecewise constant) [117].

Upwind and Godunov Fluxes

The simple upwind method is more complex than it looks, because it changes direction with the wind. Information is coming along characteristics. For ut = c u,, the wind direction depends on the (fixed) sign of c. For ut + f (u), = 0, the direction depends on the (possibly variable) sign of f '(u). Those signs determine the upwind flux F"':

The upwind numerical fluz FF; is either f (Uj,,) or f (Uj+l,,).

Lax-Friedrichs avoided that sign dependence by using the average in (29), but its accuracy is low. LF is more dissipative than the upwind method. (Lax-Friedrichs uses Uj+l and Uj-l where upwind stays in one cell.) We need a systematic approach in which the accuracy can be upgraded to reach high resolution.

The first step was taken by Godunov (he applied it to gas dynamics):

1. At time nAt, construct ~ ( x ) = Uj,, = constant in each cell j

2. Solve ut + f (u), = 0 starting from this piecewise constant ~ ( x ) at nAt

3. Take the cell averages of that solution at time (n + 1)At as Uj,n+l.

Since Uj,, and Uj,n+l match the x-integrals in the exact conservation form (32), that equation tells us Godunov's numerical flux function:

Godunov flux

1

�t

(Uj,n+1 � Uj,n) +1

�x

⇣Fj+ 1

2 ,n� Fj� 1

2 ,n

⌘= 0

Fj+ 12 ,n

• Note: Other choices of F can lead to implicit schemes

Fj+ 12 ,n

= f(Uj+ 12 ,n�t)

Page 29: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Why finite volumes?• Grid can be arbitrary, conservation law always fulfilled

Different Types of FV Grids, Cont’d

•Other specialized variants – Cell centered vs. Cell vertex

– Structured: • All mesh points lie on

intersection two/three lines

– vs. Unstructured: • Meshes formed of triangular or

quadrilateral cells in 2D, or tetrahedra or pyramids in 3D

• Cells are identified by their numbers (can not be indentified by coordinate lines, e.g. i.j)

• Remarks – Discretization principles the same for all grid variants

• => For now, we work with (a): Cell centered ( i,j is the center of the cell, similar to FD) • In 3D, a cell has a finite volume (but if unit distance perpendicular to plane is assumed, it behaves as 2D)

– What changes are the relations between various locations on the grid and accuracies

2.29 Numerical Fluid Mechanics PFJL Lecture 18, 11 11

© Springer. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/fairuse. Source: Cebeci, T., J. Shao, et al.

. Springer, 2005.

Approximation of Surface Integrals, Cont’d

1D surfaces (2D CV) • Goal: estimate Fe ³ fI dA

Se

• Simplest approximation: midpoint rule (2nd order) – Fe is approximated as a product of

the integrand at cell-face center (itself approximation of mean value over surface) and the cell-face area

³ § [ 2 ·F f dA f S f S � O('y2 ) | ¨ f ( ) f ( ye ) �[ f '( ye ) � f ''( e 2 ¸ ey y ) � R [ y � ye I e e e e 2!S © ¹e

– Since fe is not available, it has to be obtained by interpolation

• Has to be computed with 2nd order accuracy to preserve accuracy of midpoint rule

e ef S

2.29 Numerical Fluid Mechanics PFJL Lecture 18, 13 13

yj+1

xi-1 xi xi+1

yj-1

y

ji

x

yj

NW

WW W

SW S SE

E EE

N NE

∆y

∆x

nw

s

nw neneP

sw se

e

yj+1

xi-1 xi xi+1

yj-1

y

ji

x

yj

NW

WW W

SW S SE

E EE

N NE

∆y

∆x

nw

s

nw neneP

sw se

e

Notation used for a Cartesian 2D and D grid. mage by M T penCourse are.

Page 30: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Example•

AREP

O fi

nite

vol

ume

code

(Vol

ker S

prin

gel)

Page 31: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Navier-Stokes / Flow problems

• Tricky equation, tricky numerics…

• Incompressible Navier-Stokes equation:

6.7 Fluid Flow and Navier-Stokes 533

6.7 FLUID FLOW AND NAVIER-STOKES

The velocity of a viscous incompressible fluid is governed by the Navier-Stokes equa- tions. The dimensionless form brings out the importance of the Reynolds number Re. The velocity is a divergence-free vector u and the pressure is a scalar p:

du Navier-Stokes 1 - + ( u - V ) u = - V p + - n u + f dt Re (1) Continuity equation d i v u = V = u = O (2)

Equation (1) is Newton's Law for the momentum with mass density normalized to 1. The external force f is often absent. Four terms deserve immediate comments:

1. The Laplacian A u applies to each component of u . Viscosity produces dissipation.

2. The constraint div u = 0 (no time derivative in this equation) comes from incompressibility and conservation of mass : const ant density.

3. The pressure p(x, y, t ) is the Lagrange multiplier for that constraint V u = 0. The pressure gradient -Vp drives the flow in equation (I) .

4. The nonlinear term (u V ) u comes from the movement of the fluid. Newton's Law is applied to moving particles, and as they move we have to follow them. The transport rule (28) will be the key. In 2D the velocity u has components u(x, y, t) and v(x, y, t) , and (u V ) u also has two components:

uu, + vuy Components of (u V ) u (3)

The first term is neater if uu, is written as ;(u2),. That looks hard to do for vuy. The product rule for ( U V ) ~ will give an extra term uvy. But zero divergence saves us with u, = -vy. Subtracting the unwanted uvy is the same as adding another uuZ:

Simplify uux + vuy = uux + ( U V ) ~ + UU, = (u2), + ( U V ) ~ . (4)

The same device works for uv, + vvy. (It also extends to 3D.) I will write both components of the 2D momentum equation (1) in a form ready for finite differences:

x direction ~t + PX = (UXX + uyy)/Re - (u2)X - ( 2 1 ~ ) ~ + fi y direction vt + Py = (VXX + vyy)/Re - (uv), - (v2)Y + f2 (5)

The derivation of these Navier-Stokes equations is based on conservation of mass and momentum. This will be quite standard (the choice between Euler and Lagrange is important in equation (26) for mass conservation). To progress directly toward a numerical solution we must know some of the possible boundary conditions.

momentum balancecontinuity/incompr.

equation• In this dimensionless form, the only physical parameter is the Reynolds

number Re

• Pressure p is a Lagrange multiplier, adjusted such that the incompressibility condition is fulfilled.

534 Chapter 6 Initial Value Problems

Boundary Conditions in 2D Flow

Suppose that the physical boundaries are in the coordinate directions, horizontal and vertical. The velocity vector u is still (u, v). At a vertical boundary, u is the normal component of velocity and v is the tangential component. We may have an inflow condition at the left end and an outflow condition (no stress) at the right end:

Inflow across a vertical boundary u = uo and v = vo are prescribed (6) 1 du av Outflow across a vertical boundary - - - p = O and - = 0 Re dx ax

In a channel flow, no fluid crosses the upper and lower horizontal boundaries. The no-slip condition further requires that the fluid is at rest:

No-slip along a u = 0 (from viscosity) and v = 0 (no crossing) (8) horizontal boundary

Along a sloping boundary, the velocity vector is separated into normal and tangen- tial components. The inflow and no-slip conditions st ill prescribe both components, and d/dx in (7) changes to d ldn for outflow (like a free end). Our examples will show other possibilities, staying with horizontal and vertical boundaries.

If we prescribe the outward flow u-n on the whole boundary, then div u = 0 would require u = n ds = 0. Please note the difference between u n and duldn = Vu n, a normal component and a normal derivative.

The Reynolds Number

To reach the Reynolds number Re, the Navier-Stokes equations have been made dimensionless. Physical conservation laws have dimensions. The key to the physics is the relative importance of inertial forces and viscous forces.

inertial forces (a velocity U ) (a length L) Reynoldsnumber R e = % - viscous forces (kinematic viscosity v) (9)

Example 1 Flow in a long channel Here L would be the width of the channel, and U could be the inflow velocity. The number v is a ratio p l p of the material constant p (the dynamic viscosity) to the density p.

Experience is needed to identify an appropriate length scale L and velocity U , characteristic of the flow. Here is a light-hearted scale of Re for some familiar motions:

Reynolds lo-3 += lo0 + lo3 + lo6 -+ lo9 number Re bacteria blood baseball ship

It is natural to compare Re with the Pkclet number Pe = convection/diffusion in Section 6.5. When a flow is driven by gravity, the F'roude number Fr = U / f i

Page 32: Lecture 10 - Mathematicsmath.mit.edu/~stoopn/18.086/Lecture10-11.pdf · Nonlinear transport & conservation laws • A more famous example of issues with characteristics is the Riemann

Example: 2D flow in a lid-driven cavity

• Consider 2D box, with no-slip boundary conditions at three boundaries:

536 Chapter 6 Initial Value Problems

leads to Poisson's equation for the pressure. This splitting method first creates a velocity vector U* from Un at the start of the step. Then Un+' comes from U*:

Explicit convection U* - un 1 n u * At + (Un v)Un = -vpn + - + f n (10) Implicit diffusion Re

2 Un+' is the divergence-free part of U*. The pressure pn+' accounts for div U*:

Poisson for p U* = u"+' + grad(pn+' - pn) yields Apn+' = div U* + Apn (11)

Poisson is the equation we know best (also the most expensive). It separates U* into a divergence-free part Un+' and a curl-free field grad (pn+l - pn). Those subspaces are orthogonal complements, with correct boundary conditions. The computation of p on a finite difference grid is usually called Chorin's projection method.

selected streamlines

Figure 6.20: Lid-driven cavity flow u = (u, v) in 2D. A triple p, U, V grid in a cell.

Very Staggered Grids

Those steps need to be executed on an actual grid. Normally U, V, and p are defined at different points, as in Figure 6.20. The pressure p, is located at the center of the i, j cell. The horizontal velocity U is level with that point, but on the edges of the cell (p and U are staggered on row 2). The vertical velocity V is above and below the center (again on the cell edges so V and p are staggered up each column). The three grids for p, U, V bring many conveniences and some unavoidable problems.

A first question is notation for the grid values of U and V. I shall venture a small proposal. The discrete values on the edges would naturally be Uz+;,, and V,,,,;, to the right of i, j and above. The inconvenient "+in is just removed in [66] to leave Ui4 and Kjj. But this can be confusing, since 2, j refers to three different points.

I suggest simply deleting the "4" while leaving the + sign as in U,+, and V, + . Similarly Uz-, and V,- can be values on the left edge and lower edge: see Figure 6.20.

This triple grid avoids a checkerboard oscillation from centered differences p, andp,:

Checkerboard pressure p* on white squares and p* * on black squares. (12)

on a rectangular domain ⌦ = [0, l

x

]⇥[0, l

y

]. The four domain boundaries are denoted North,South, West, and East. The domain is fixed in time, and we consider no-slip boundaryconditions on each wall, i.e.

u(x, l

y

) = u

N

(x) v(x, l

y

) = 0 (4)u(x, 0) = u

S

(x) v(x, 0) = 0 (5)u(0, y) = 0 v(0, y) = v

W

(y) (6)u(l

x

, y) = 0 v(lx

, y) = v

E

(y) (7)

A derivation of the Navier-Stokes equations can be found in [2]. The momentum equations(1) and (2) describe the time evolution of the velocity field (u, v) under inertial and viscousforces. The pressure p is a Lagrange multiplier to satisfy the incompressibility condition(3). Note that the momentum equations are already put into a numerics-friendly form. Thenonlinear terms on the right hand side equal

(u2)x

+ (uv)y

= uu

x

+ vu

y

(8)

(uv)x

+ (v2)y

= uv

x

+ vv

y

(9)

which follows by the chain rule and equation (3). The above right hand side is often writtenin vector form as (u ·r)u. We choose to numerically discretize the form on the left handside, because it is closer to a conservation form.

The incompressibility condition is not a time evolution equation, but an algebraic condi-tion. We incorporate this condition by using a projection approach [1]: Evolve the momen-tum equations neglecting the pressure, then project onto the subspace of divergence-freevelocity fields.

3 Visualization

Every fixed number of time steps the current pressure and velocity field are visualized.The pressure field is shown as a color plot with some contour lines. On top of this, thenormalized velocity field is shown as a quiver plot, i.e. little arrows indicate the direction ofthe flow. Since in a lid driven cavity the flow rate varies significantly over di↵erent areas,outputting the normalized velocity field is a common procedure. Additionally, stream linesare shown. Those are paths particles would take in the flow if the velocity field was frozenat the current instant in time. Since the velocity field is divergence-free, the streamlines areclosed. The stream lines are contour lines of the stream function q. It is a function whoseorthogonal gradient is the velocity field

(rq)? = u () �q

y

= u and q

x

= v (10)

Applying the 2d-curl to this equation yields

��q = r⇥ (rq)? = r⇥ u () ��q = �q

yy

� q

xx

= u

y

� v

x

(11)

The stream function exists since the compatibility condition r ·u = u

x

+v

y

= 0 is satisfied.

3

on a rectangular domain ⌦ = [0, l

x

]⇥[0, l

y

]. The four domain boundaries are denoted North,South, West, and East. The domain is fixed in time, and we consider no-slip boundaryconditions on each wall, i.e.

u(x, l

y

) = u

N

(x) v(x, l

y

) = 0 (4)u(x, 0) = u

S

(x) v(x, 0) = 0 (5)u(0, y) = 0 v(0, y) = v

W

(y) (6)u(l

x

, y) = 0 v(lx

, y) = v

E

(y) (7)

A derivation of the Navier-Stokes equations can be found in [2]. The momentum equations(1) and (2) describe the time evolution of the velocity field (u, v) under inertial and viscousforces. The pressure p is a Lagrange multiplier to satisfy the incompressibility condition(3). Note that the momentum equations are already put into a numerics-friendly form. Thenonlinear terms on the right hand side equal

(u2)x

+ (uv)y

= uu

x

+ vu

y

(8)

(uv)x

+ (v2)y

= uv

x

+ vv

y

(9)

which follows by the chain rule and equation (3). The above right hand side is often writtenin vector form as (u ·r)u. We choose to numerically discretize the form on the left handside, because it is closer to a conservation form.

The incompressibility condition is not a time evolution equation, but an algebraic condi-tion. We incorporate this condition by using a projection approach [1]: Evolve the momen-tum equations neglecting the pressure, then project onto the subspace of divergence-freevelocity fields.

3 Visualization

Every fixed number of time steps the current pressure and velocity field are visualized.The pressure field is shown as a color plot with some contour lines. On top of this, thenormalized velocity field is shown as a quiver plot, i.e. little arrows indicate the direction ofthe flow. Since in a lid driven cavity the flow rate varies significantly over di↵erent areas,outputting the normalized velocity field is a common procedure. Additionally, stream linesare shown. Those are paths particles would take in the flow if the velocity field was frozenat the current instant in time. Since the velocity field is divergence-free, the streamlines areclosed. The stream lines are contour lines of the stream function q. It is a function whoseorthogonal gradient is the velocity field

(rq)? = u () �q

y

= u and q

x

= v (10)

Applying the 2d-curl to this equation yields

��q = r⇥ (rq)? = r⇥ u () ��q = �q

yy

� q

xx

= u

y

� v

x

(11)

The stream function exists since the compatibility condition r ·u = u

x

+v

y

= 0 is satisfied.

3

• In 2D, we can write the NS equations in component form as

• visualization of pressure field, velocity field and streamlines

• automatic transition from central to donor-cell discretization for the nonlinear advec-tion part

• fast computation of the time-dependent solution for small to moderate mesh sizes

The code does not provide:

• 3d

• unstructured meshes or complex geometries

• time-dependent geometries

• adaptivity, such as local mesh refinement, time step control, etc.

• non-constant viscosity or density

• higher order time stepping

• turbulence models

• time and memory e�ciency for large computations

The code qualifies as a basis for modifications and extensions. The following extensionshave already been applied to the code by MIT students and other users:

• external forces

• inflow and outflow boundaries

• addition of a drag region

• geometry change to a backwards facing step

• time dependent geometries

• coupling with an advection-di↵usion equation

2 Incompressible Navier-Stokes Equations

We consider the incompressible Navier-Stokes equations in two space dimensions

u

t

+ p

x

= �(u2)x

� (uv)y

+1

Re

(uxx

+ u

yy

) (1)

v

t

+ p

y

= �(uv)x

� (v2)y

+1

Re

(vxx

+ v

yy

) (2)

u

x

+ v

y

= 0 (3)

2• The boundary conditions will be

on a rectangular domain ⌦ = [0, l

x

]⇥[0, l

y

]. The four domain boundaries are denoted North,South, West, and East. The domain is fixed in time, and we consider no-slip boundaryconditions on each wall, i.e.

u(x, l

y

) = u

N

(x) v(x, l

y

) = 0 (4)u(x, 0) = u

S

(x) v(x, 0) = 0 (5)u(0, y) = 0 v(0, y) = v

W

(y) (6)u(l

x

, y) = 0 v(lx

, y) = v

E

(y) (7)

A derivation of the Navier-Stokes equations can be found in [2]. The momentum equations(1) and (2) describe the time evolution of the velocity field (u, v) under inertial and viscousforces. The pressure p is a Lagrange multiplier to satisfy the incompressibility condition(3). Note that the momentum equations are already put into a numerics-friendly form. Thenonlinear terms on the right hand side equal

(u2)x

+ (uv)y

= uu

x

+ vu

y

(8)

(uv)x

+ (v2)y

= uv

x

+ vv

y

(9)

which follows by the chain rule and equation (3). The above right hand side is often writtenin vector form as (u ·r)u. We choose to numerically discretize the form on the left handside, because it is closer to a conservation form.

The incompressibility condition is not a time evolution equation, but an algebraic condi-tion. We incorporate this condition by using a projection approach [1]: Evolve the momen-tum equations neglecting the pressure, then project onto the subspace of divergence-freevelocity fields.

3 Visualization

Every fixed number of time steps the current pressure and velocity field are visualized.The pressure field is shown as a color plot with some contour lines. On top of this, thenormalized velocity field is shown as a quiver plot, i.e. little arrows indicate the direction ofthe flow. Since in a lid driven cavity the flow rate varies significantly over di↵erent areas,outputting the normalized velocity field is a common procedure. Additionally, stream linesare shown. Those are paths particles would take in the flow if the velocity field was frozenat the current instant in time. Since the velocity field is divergence-free, the streamlines areclosed. The stream lines are contour lines of the stream function q. It is a function whoseorthogonal gradient is the velocity field

(rq)? = u () �q

y

= u and q

x

= v (10)

Applying the 2d-curl to this equation yields

��q = r⇥ (rq)? = r⇥ u () ��q = �q

yy

� q

xx

= u

y

� v

x

(11)

The stream function exists since the compatibility condition r ·u = u

x

+v

y

= 0 is satisfied.

3

Lecture