+ All Categories
Home > Documents > Numerical Methods for Partial Differential Equations

Numerical Methods for Partial Differential Equations

Date post: 23-Jan-2016
Category:
Upload: eithne
View: 42 times
Download: 0 times
Share this document with a friend
Description:
Numerical Methods for Partial Differential Equations. CAAM 452 Spring 2005 Lecture 9 Instructor: Tim Warburton. Today. Introduction to a very basic finite volume method. Mass Conservation. - PowerPoint PPT Presentation
of 44 /44
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 9 Instructor: Tim Warburton
Transcript
Page 1: Numerical Methods for Partial Differential Equations

Numerical Methods for Partial Differential Equations

CAAM 452

Spring 2005

Lecture 9

Instructor: Tim Warburton

Page 2: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Today

• Introduction to a very basic finite volume method

Page 3: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Mass Conservation

• For the following we are going to consider a 1-dimensional domain which we parameterize with the variable x.

• Now imagine that this line is a figurative representation of a pipe which contains fluid.

• At every point on the line the fluid has a density measured in mass per meter ( with units kgm-1 )

• We define a new function which is a non-negative, real valued function defined on the space-time domain.

x

: [0, )

Page 4: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Derivation of Mass Conservation Law

• Next we consider an arbitrary section of the pipe, say [a,b]

• We now assume that the fluid is not created or destroyed at any point inside the section and is traveling with velocity u (which is a function of space and time). For the moment we will assume that u is positive (i.e. the fluid is flowing in the direction of positive x)

• This allows us to state the following:– The time rate of change of the total fluid inside the section [a,b]

changes only due to the flux of fluid into and out of the pipe at the ends x=a and x=b.

• A simple formula relating these two quantities is:

, , , , ,b

a

dx t dx u b t b t u a t a t

dt

Page 5: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

• In detail:

, , ,, ,b

a

u bd

x t u a tbt tdxd

tt

a

The time rate ofchange of total mass in the section of pipe [a,b]

The flux out of the section at the right end of the section of pipe per unit time

The flux into the section at the left end of the section of pipeper unit time

Page 6: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Use the Fundamental Theorem of Calculus

• Look carefully at the right hand side:

• Clearly we may rewrite this as:

• From which we may deduce:

, , , , ,b

a

dx t dx u b t b t u a t a t

dt

, , ,b b

a a

dx t dx u x t x t dx

dt x

, , , 0b

a

x t u x t x t dxt x

Page 7: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Finally…

• Assuming that the integrand of:

is continuous and noting that this relation holds for all choices of a,b then we may deduce:

• In short hand:

, , , 0b

a

x t u x t x t dxt x

, , , 0x t u x t x tt x

0

u

t x

Page 8: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Advection Equation

• Let’s choose a simple, constant, fluid velocity

• Then the pde reduces to the advection equation:

• This is a pretty easy equation to solve . Consider the change of variables:

,u x t u

0ut x

t t

x x ut

Page 9: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

• Note that the units of each variable are consistent.

• Basic calculus:

• From which we obtain:

t t

x x ut

t xu

t t t t x t x

t x

x x t x x x

0 ut x

u ut x x

t

Page 10: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Solution and Interpretation

• So we know:

• Which we can instantly solve:

where:

• So an interesting property of the advection equation is the way that the profile of the solution does not change shape but it does shift in the positive x direction with constant velocity

0t

0

0

,x t x

x ut

0 : , 0x x t

Page 11: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Space Time Diagram• Let’s track the information:

• The dashed lines are which are known as characteristics of the equation.

• If we choose a point on one of these dashed lines and track back down to t=0 and we will find the value of the density which applies at all points on the dashed line

x

t

Slope = 1

u

x ut const

Page 12: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Recall

• Assuming that the integrand of:

is continuous and noting that this relation holds for all choices of a,b then we may deduce:

• Well – this does not hold if the density is discontinuous and the integral equation is the appropriate representation:

, , , 0b

a

x t u x t x t dxt x

, , , 0x t u x t x tt x

, , , , ,b

a

dx t dx u b t b t u a t a t

dt

Page 13: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

1) Let’s consider the advection equation:

2) Next we take a finite portion of the real line fromx1 to xN divided into N-1 equal length sections

3) In each section we will approximate the density by a constant value

Building a Finite Volume Solver

, , ,b

a

dx t dx u b t u a t

dt

x1 xN

1,..., 1i i N

dx

Page 14: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

In the n’th section the density will be approximated by theconstant:

Piecewise Constant Approximation

x1 xN

n

Page 15: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

• Choosing a = xi, b=xi+1,

• Is approximated (to first order in time) by:

where the time axis has been divided into sections of length dt and the i’th cell average at time n*dt is represented by

• Outstanding question: Now we have to figure out how to evaluate the density at the interval end points given the cell averages.

, , ,b

a

dx t dx u b t u a t

dt

1

1, ,n ni i

i i

dxu x t u x t

dt

1

,i

i

xni

x

x t ndt dx

Page 16: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Upwind Treatment for Flux Terms

• Recall that the solution shifts from left to right as time increases.

• Idea: use the upwind values

t

Slope = 1

u

1 1, , n ni i i iu x t u x t u u

Page 17: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Basic Upwind Finite Volume Method

111n n n

i i i

dt dtu udx dx

1

1

n ni i n n

i i

dxu u

dt

simplify

dtudx

111n n n

i i i

Note we must supply a value for the left most average at each time step: 0n

Page 18: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Basic Upwind Finite Volume Method

1

1

n ni i n n

i i

dxu u

dt

Approximate time derivative and look forsolution

dtudx

111n n n

i i i

Note we must supply a value for the left most average at each time step: 0n

Recall

1, ,i i i

dq dx uq x t uq x t

dt

Approximate fluxes with upwind flux

1i i i

dq dx uq uq

dt

n ni iq

Page 19: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Convergence

• We have constructed a physically reasonable numerical scheme to approximate the advection equation.

• However, we need to do some extra analysis to determine how good at approximating the true PDE the discrete scheme is.

• Let us suppose that the i’th subinterval cell average of the actual solution to the PDE at time T=n*dt is denoted by

1 1

1

1

1

1 1, ,

where q satisfies:

, , ,

i i

i i

i

i

x xni

i i x x

x

i i i

x

q q x ndt q x ndtx x dx

d dq x t dx dxq uq x t uq x t

dt dt

Page 20: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Error Equation

• The goal is to estimate the difference of the exact solution and the numerically obtained solution at some time T=n*dt.

• So we are interested in the error:

• For the given finite volume scheme dt and dx will be related in a fixed manner (i.e. dt = Cdx for some C, independent of dx).

• Suppose we let and then

the scheme is said to be of order s.

, nn n ni i i

TE q

dt

0dt n sE O dt

Page 21: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Norms and Definitions

• We define the discrete p-norms:

• We say that the scheme is convergent at time T in the norm ||.|| if:

• It is said to be accurate of order s if:

1/ pip

ipi

E dx E

0lim 0n

dtndt T

E

as 0n sE O dt dt

Page 22: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Local Truncation Error

• Suppose at the beginning of a time step we actually have the exact solution -- one question we can ask is how large is the error committed in the evaluation of the approximate solution at the end of the time step.

• i.e. choose

• Then

• We expand about xi,tn with Taylor series:

11

1 1

1

1:

n ni i

n n ni i i

n n ni i i

q

dt dtu q u q

dx dx

R qdt

11,n ni iq q

________2 2

31 2

________2 2

1 32

( )2

( )2

n ni i

n ni i

q dx qq q dx O dx

x x

q dt qq q dt O dt

t t

Page 23: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Estimating Truncation Error

• Inserting the formulas for the expanded q’s:

11

________2 2

32

________2 2

32

1: 1

1

1( )

2

( )2

n n n ni i i i

ni

ni

ni

dt dtR u q u q q

dt dx dx

dtu q

dx

dt q dx qu q dx O dx

dt dx x x

q dt qq dt O dt

t t

Page 24: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

________2 2

32

________2 2

32

1

1: ( )

2

( )2

ni

n ni i

ni

dtu q

dx

dt q dx qR u q dx O dx

dt dx x x

q dt qq dt O dt

t t

Estimating Truncation Error

• Removing canceling terms:

Page 25: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Estimating Truncation Error

• Simplifying: ________2 2

32

________2 2

32

( )2

1:

( )2

ni

dt q dx qu dx O dx

dx x x

Rdt

q dt qdt O dt

t t

____ ____

____ ____2 2

2 22 2

:

( ) ( )2 2

ni

q qu

t x

R

dt q dx qO dt u O dx

t x

Page 26: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Final Form

• Using the definition of q

____2

22

: 1 ( )2

ni

udx udt qR O dx

dx x

Using that:

____ ____2 2

22 2

q qu

t x

____ ____

____ ____2 2

2 22 2

:

( ) ( )2 2

ni

q qu

t x

R

dt q dx qO dt u O dx

t x

____ ____

2 22 2

2 2: ( ) ( )

2 2ni

dt q dx qR O dt u O dx

t x

Page 27: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Interpretation of Consistency

So the truncation error is O(dx) under the assumption that dt/dx is a constant..

This essentially implies that the numerical solution diverges from the actual solution by an error of O(dx) every time step.

If we assume that the solution q is smooth enough then the truncation error converges to zero with decreasing dx. This property is known as consistency.

____2

22

: 1 ( )2

ni

udx udt qR O dx

dx x

Page 28: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Error Equation

• We define the error variable:

• We next define the numerical iterator N:

• Then:

• So the new error consists of the action of the numerical scheme on the previous error and the error commited in the approximation of the derivatives.

n n ni i iq E

1n nN

1 1

1

n n n n

n n n n n

n n n n

E N q E q

N q E N q N q q

N q E N q dtR

Page 29: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Abstract Scheme

• Without considering the specific construction of the scheme suppose that the numerical N operator satisfies:

• i.e. N is a contraction operator in some norm then…

N P N Q P Q

Page 30: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Estimating Error in Terms of Initial Error and Cumulative Truncation Error

1

1

1

1

1 1

1 0

1

triangle inequality

contraction property of

.....

n n n n n

n n n n n

n n n n n

n n n

n n n

m nn m

m

E N q E N q dtR

E N q E N q dt R

E q E q dt R N

E E dt R

E dt R dt R

E E dt R

by induction

Page 31: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Error at a Time T (independent of dx,dt)

• If the method is consistent (and the actual solution is smooth enough) then:

• As dx -> 0 the initial error ->0 and consequently the numerical error at time T tends to zero with decreasing dx (and dt).

1 0

1

1 0

1,..max

m nn m

m

n m

m n

E E dt R

E E T R

1 0 nE E T O dx

Page 32: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Specific Case: Stability and Consistency for the Upwind Finite Volume Scheme

• We already proved that the upwind FV scheme is consistent.

• We still need to prove stability of.

111n n n

i i i

Page 33: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Stability in the Discrete 1-norm

11

11 1

11

1

11

1 1

11 1

1

01

0 1

1

1 triangle inequality

1 assuming 0 1

n n ni i i

Nn n

ii

Nn ni i

i

N Nn ni i

i i

Nn n

ii

n n

dx

dx

dx dx

dx dx

dx

So here’s the interesting story. In the case of a zero boundarycondition then we automatically observe that the operator is a contraction operator.

Page 34: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Boundary Condition

• Suppose are two numerical solutions with

• Then:

• i.e. if we are spot on with the left boundary condition the N iterator is indeed a contraction.

, 0 0n n

1 10 01 1

1

n n n n n n

n n

dx

Page 35: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Relaxation on Stability Condition

• Previous contraction condition on the numerical iterator N

• A less stringent condition is:

• Where alpha is a constant independent of dt as dt->0

N P N Q P Q

1N P N Q dt P Q

Page 36: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Relaxation on Stability Condition

• In this case the stability analysis yields:

1

1

1

1 1

11 0

1

0

1,..

1

1 1

.....

1 1

max Ndt=T

n n n n n

n n n n n

n n n

n n n

m nn n mn m

m

T m

m n

E N q E N q dtR

E q E q dt R

E dt E dt R

dt dt E dt R dt R

E dt E dt dt R

e E T R

Page 37: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Interpretation

• Relaxing the stability yields a possible exponential growth – but this growth is independent of T so if we reduce dt (and dx) then the error will decay to zero for fixed T.

1 0

1,..max , Ndt=Tn T m

m nE e E T R

Page 38: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Homework 2

• Due on Friday

• Recall report presentation policy

• Time will be given in class on Wednesday to go over questions.

Page 39: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Homework 2

Q1) Solve the pde analytically on the domain

Q2) Solve the pde analytically.

Q3) Solve the pde analytically

and explain what happens to the density along the characteristics.

2

2 0

( , 0) x

t x

x t e

, [0, )

2

2 2

( , 0) x

x tt x

x t e

2

3

( , 0) x

t x

x t e

PTO

Page 40: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Homework 2 contQ4) Implement the numerical approximation of:

By:

2

3 0

( , 0) x

t x

x t e

1 1

11

0 1

00

Geometry:

14, 4,

1 1

Scheme:

1

3

Initial Condition :

, 02

Boundary Condition :

0

N i N

n n ni i i

i ii

N i ix x x x x

N N

dt

dx

x xt

Page 41: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Homework 2 cont

Q4 cont)

For N=10,40,160,320,640,1280 run to t=100, with: dx = (8/(N-1)) dt = dx/6

On the same graph, plot t on the horizontal axis and error on the vertical axis. The graph should consist of a sequence of 6 curves – one for each choice of dx.

Comment on the curves.

NOTE: For the purposes of this test we define error as: 1

1max ,

2n n i i

ii N

x xerror ndt

Page 42: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Lecture 5

• We will define stability for a numerical scheme and investigate stability for the upwind scheme.

• We will compare this scheme with a finite difference scheme.

• We will consider alternative ways to approximate the flux functions.

Page 43: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Homework 2 correction

Q4) Implement the numerical approximation of:

By:

2

3 0

( , 0) x

t x

x t e

1 1

11

0 1

00

Geometry:

14, 4,

1 1

Scheme:

1

3

Initial Condition :

, 02

Boundary Condition :

0

N i N

n n ni i i

i ii

N i ix x x x x

N N

dt

dx

x xt

Page 44: Numerical Methods for Partial Differential Equations

CAAM 452 Spring 2005

Homework 2 cont

Q4 cont)

For N=10,40,160,320,640,1280 run to t=10, with: dx = (8/(N-1)) dt = dx/6

Use

On the same graph, plot t on the horizontal axis and error on the vertical axis. The graph should consist of a sequence of 6 curves – one for each choice of dx.

Comment on the curves.

NOTE: For the purposes of this test we define error as:

1

1max ,

2n n i i

ii N

x xerror ndt

10 0 11n n n

N

dt dtu udx dx


Recommended