numerical methods to solve parabolic pdes. mathematical models: 5° classification classification...

79
Numerical methods to solve parabolic PDEs

Upload: della-sandra-burke

Post on 02-Jan-2016

227 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Numerical methods to solve parabolic PDEs

Page 2: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Mathematical models: 5° Classification

Classification based on the type of the solution (except, usually, the empirical models)

1. ANALYTICAL SOLUTIONS MATHEMATICAL ANALYSIS ALGEBRA

2. NUMERICAL SOLUTIONS NUMERICAL COMPUTATION

Ex.: numerical methods for PDE

1. FINITE DIFFERENCE METHOD (FDM)

2. FINITE ELEMENT METHOD (FEM)

3. METHODS OF LOCATION

Page 3: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Partial differential equation (PDE)

Second order Partial differential equation:

where u=f(x,y,t), a function that satisfies this equation and that is at least two times differentiable, is said to be a solution of the equation.

To obtain a unique solution, it is necessary supply some additional information, namely initial (IC) and boundary (BC) conditions.BC must to be of the order N-1 if N is the order of the equation.

0,,,,,,,,,,,2

222

2

2

2

2

tyxut

u

y

u

x

u

t

u

yy

u

yx

u

y

u

x

uF

Page 4: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Classical classification for 2nd order PDE’s

if = b2 - 4ac

< 0 : Elliptic

= 0 : Parabolic

> 0 : Hyperbolic

Partial differential equation (PDE)

Page 5: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Classical classification for 2nd order PDE’s

a=1, b=0, c=1

= b2 - 4ac = -4

Heat conduction equation is elliptic.

0y

T

x

T2

2

2

2

Laplace’s equation for heat

conduction

Partial differential equation (PDE)

Page 6: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Classical classification for 2nd order PDE’s

a=D, b=0, c=0

= b2 - 4ac = 02 - 4D 0 = 0

Diffusion equation is parabolic.

2

2

x

cD

t

c

Molar Diffusion

Partial differential equation (PDE)

Page 7: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Classical classification for 2nd order PDE’s

a=1, b=v, c=0 a=v, b=1, c=0

= b2 - 4ac = v2 = b2 - 4ac = 1

Convection equation is hyperbolic

0h

cv

t

c

Convection in conservation laws

0th

cv

t

c 2

2

2

First order

/t or /h

Partial differential equation (PDE)

Page 8: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Second order Partial differential equation

Classification:

Type Equation Description

Parabolic Unsteady-state problem in which transport by

conduction or diffusion is important

Elliptic Steady-state problem in which transport by

conduction or diffusion is important

Hyperbolic Unsteady-state problem in which transport by

convention phenomenon is important

2

2

2

2

y

u

x

u

t

u

2

2

2

2

,y

u

x

uyxf

x

uv

t

u

Note: An equation can belong to a class in a certain field and another in a different field

Page 9: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Parabolic PDE’s

Parabolic (or diffusion) PDE with one spatial independent variable

2

2

x

u

t

u

2° order PDE

2 independent variables

Linear with constant coefficients

is a diffusion coefficient

t Є [0, +∞]x Є [xA, xB]

I.C.: u(t=0,x)=u*(x) all xB.C.1: u(t, x=xA)=uA(t) all t (simple case)B.C.2: u(t, x=xB)=uB(t) all t (simple case)

Analytical solution: u=u(t,x) where u is a continuous function of t and x

Page 10: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Analytical vs numerical solution

Analytical solutionThe region described by these two independent, continuous variables (t and x) is a part of a plane, for the problem under consideration: the length variable, x, varies between xA and xB, and the time variable, t, increase without limit from 0.

Numerical solutionTo obtain a numerical solution , one replaces these continuous variables with discrete variables.When these two continuous independent variables are replaced by discrete variables (also called x and t), the new variables are defined at specific points located in the same region as shown in Figure. The relations between these discrete variables are finite differential equations, and it is these finite differential equations which are solved numerically on a digital computer.

xA xB x0

t

u=u(t, x)

u=u(tn, xi)

The index i indicates the position along the x-axis, and the index n is used for the t-axis

Page 11: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

The dependent variable, u, is now a function of two discrete independent variables, x and t. It is therefore necessary to use two subscripts to specify the value of u at a given point; thus:

u(xi, tn)=uin

General procedure for solving Parabolic PDE equations

1,2,… i-1, i, i+1,… N-1, N

01

x=xA x=xB

Page 12: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

u(xi, tn)=uin

The value of the dependent variable is unknown at a row of points at each time level, and there are actually an unlimited number of time levels.

It is not feasible to solve for all the unknown values of u simultaneously even when a limited number of time level are considered.

Consequently the technique employed is to solve for the unknown values of u at one time level, using the know values of u at the previous time level.

General procedure for solving Parabolic PDE equations

1 ni

ni uu

1,2,… i-1, i, i+1,… N-1, N

01

x=xA x=xB

Page 13: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

The values of u at the time level when n=0, are given by the initial conditions of equation (IC).These value are used to determine the unknown values of u at the next time level for which n=1. The same computational values is then used to find the values of u for n=2 from the now known values of u at n=1, and so on.

General procedure for solving Parabolic PDE equations

I.C.

1,2,… i-1, i, i+1,… N-1, N

01

x=xA x=xB

....... 1210 ni

niiii uuuuu

I.C.

Page 14: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

This procedure is continued for as many time increments as desired.

Therefore, the finite difference equations are formulated so that they contain values of u at two consecutive levels. The index n is used to designate the last time level at which the value of u are known, and the index n+1 is used to designate the next time level at which variables of the dependent variable are unknown.

General procedure for solving Parabolic PDE equations

1niuniu

t

n+1(i+1,n+1)(i-1,n+1)(i,n+1)

xi i+1i-1

n(i,n)

unknown value unless it is given by a boundary condition.

known value

Page 15: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference Methods

The finite difference method (FDM) was first developed by A. Thom* in the 1920s under the title “The method of square” to solve nonlinear hydrodynamic equations. *A. Thom and C. J. Apelt, Field Computations in Engineering and Physics. London: D. Van Nostrand, 1961.

“The finite difference techniques are based upon the approximations that permit replacing differential equations by finite difference equations. These finite difference approximations are algebraic in form, and the solutions are related to grid points”.

Page 16: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference Methods

Thus, a finite difference solutionbasically involves three steps:

1. Dividing the solution into grids of nodes

2. Approximating the given differential equation by finite difference equivalence that relates the solutions to grid points (In finite difference methods, each derivative of the PDE is replaced by an equivalent finite difference approximation)

3. Solving the finite difference equations subject to the prescribed boundary conditions and/or initial conditions

Page 17: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

If xA=0 and xB=L, the region between 0 and L along the x-axis is divided into N equal increment of size x, whit grid points being placed on each boundary. The time-axis is divided into increments of size t.

tn=n*t

xi=xA+i*x=i*x

Some useful relations between values of the independent variable at adjacent points:xi+1=xi+i*xxi-1=xi-i*x

For many numerical solutions, it will be desirable to increase the size of the time step, t, as the solutions progresses.

Finite Difference Methods

t

n+1(i+1,n+1)(i-1,n+1)(i,n+1)

xi i+1i-1

n(i,n)

0 L

n

mnn tt

1

Page 18: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

All i and n

tn+1

(i+1,n+1)(i-1,n+1)(i,n+1)

xi i+1i-1

n(i,n)

Finite Difference Methods

ni

ntxtx x

u

t

u

,2

2

,

Both sides must to be evaluated at the same conditions (xi and tn)

We will indicate:

nii

n uxtu ,

n

i

n

i x

u

t

u

2

2

The FDM write both sides and check the equality for each grid points

Evaluate at time tn

Evaluate at length xi

Page 19: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

The basis of a finite difference method is the Taylor series expansion of a function.

•Consider a continuous function f(x). Its value at neighboring points can be expressed in terms of a Taylor series as:

(1) f(xi+ ∆x) =f(xi) +(df/dx)xi (∆x) + (d2f/dx2)xi (∆x2)/ 2! +.. +(dnf/dxn)xi (∆xn)/n! +….

•The above series converges if ∆x is small and f(x) is differentiable

•For a converging series, successive terms are progressively smaller

Finite Difference Methods

Page 20: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

The terms in the Taylor series expansion can be rearranged to give

(df/dx)xi =[f(xi+ ∆x) -f(xi)] /∆x-(d2f/dx2)xi (∆x)/2! -…-(dnf/dxn)xi (∆xn-1)/n! -...

Or

(2) (df/dx)xi ≈[f(xi+ ∆x) -f(xi)] /∆x+O(∆x)

•Here O(∆x) implies that the leading term in the neglected terms are of the order of ∆x, i.e., the error in the approximation reduces by a factor of 2 if ∆x is halved.

•Equation (2) is therefore a first order-accurate approximation for the first derivative.

Finite Difference Methods

Page 21: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Other Approximations for a First Derivative

Other approximations are also possible. Writing the Taylor seriesexpansion for f(xi- ∆x), we have

(3) f(xi-∆x) =f(xi) – (df/dx)xi (∆x) +(d2f/dx2)xi (∆x2)/ 2! -.. +(dnf/dxn)xi (∆xn)/n! +

•Equation (3) can be rearranged to give another first order approximation :

(4) (df/dx)xi ≈[f(xi) -f(xi-∆x)] /∆x+O(∆x)

•Subtracting (3) from (1) gives a second order approximation for df/dx:

(5) (df/dx)xi ≈[f(xi+ ∆x) -f(xi-∆x)] /(2∆x) +O(∆x2)

Finite Difference Methods

Page 22: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

In summary:

• Forward-difference formula (first order-accurate approximation):

(df/dx)xi ≈[f(xi+ ∆x) -f(xi)] /∆x+O(∆x)

•Backward-difference formula (first order-accurate approximation):

(df/dx)xi ≈[f(xi) -f(xi-∆x)] /∆x+O(∆x)

•Central-difference formula (second order-accurate approximation):

(df/dx)xi ≈[f(xi+ ∆x) -f(xi-∆x)] /(2∆x) +O(∆x2)

Finite Difference Methods

Page 23: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Given a function f(x) shown in Fig. 2, we can approximate its derivative, slope or tangent at P by the slope of the arcs PB, PA, or AB, for obtaining the forward difference, backward-difference, and central-difference formulas respectively.

In general, a second order correct analog is always better approximation than is a first order correct analog

Finite Difference Methods

Geometrical interpretation of finite differences

Page 24: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Higher derivates

Upon adding (1) and (3)

(1) f(xi+ ∆x) =f(xi) +(df/dx)xi (∆x) + (d2f/dx2)xi (∆x2)/ 2! +.. +(dnf/dxn)xi (∆xn)/n! +….

(3) f(xi-∆x) =f(xi) – (df/dx)xi (∆x) +(d2f/dx2)xi (∆x2)/ 2! -.. +(dnf/dxn)xi (∆xn)/n! +

we obtain:

f(xi+ ∆x) - f(xi-∆x) =2f(xi) + (d2f/dx2)xi (∆x2)/ 2! +O(∆x4)

and we have:

(d2f/dx2)xi ≈[f(xi+ ∆x) - 2f(xi) + f(xi-∆x)] /(∆x2) +O(∆x2)

(second order-accurate approximation)

Higher order finite difference approximations can be obtained by taking more terms in Taylor series expansion.

Finite Difference Methods

Page 25: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Type of Errors

1)Discretization or truncation error: εi=yi-y(xi)

The discretization error encountered in integrating a differential equation across one step is sometimes called local truncation error.

This error is determined solely by the particular numerical solution procedure selected, that is, by the nature of the approximations present in the method; this type of error is independent of computing equipment characteristics.

Example: when one replace the first derivate by the finite Forward-difference formula, the truncation error is of the order x, while it is of the order x2 when a Central-difference formula is used.

Page 26: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Example:

• Forward-difference formula (the truncation error is of the order of x):

(df/dx)xi ≈[f(xi+ ∆x) -f(xi)] /∆x+O(∆x)

•Backward-difference formula (the truncation error is of the order of x):

(df/dx)xi ≈[f(xi) -f(xi-∆x)] /∆x+O(∆x)

•Central-difference formula (the truncation error is of the order of x2):

(df/dx)xi ≈[f(xi+ ∆x) -f(xi-∆x)] /(2∆x) +O(∆x2)

Finite Difference Methods

Page 27: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Type of Errors

2)The round-off error is determined, for any particular method, by the computing characteristics of the machine which does the calculations due to its finite memory which lead to a an approximation of any irrational number by a “rounded” value.

Page 28: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Reducing the mesh size could increase accuracy, but the mesh size could not be infinitesimal.

Decreasing the truncation error by using a finer mesh may result in increasing the round-off error due to the increased number of arithmetic operations. A point is reached where minimum total error occurs for any particular algorithm using any given word length.

Type of Errors

Page 29: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Analog finite difference equation for each total derivates

• Forward-difference formula (first order-accurate approximation):

(df/dx)xi ≈[f(xi+ ∆x) -f(xi)] /∆x+O(∆x)

•Backward-difference formula (first order-accurate approximation):

(df/dx)xi ≈[f(xi) -f(xi-∆x)] /∆x+O(∆x)

•Central-difference formula (second order-accurate approximation):

(df/dx)xi ≈[f(xi+ ∆x) -f(xi-∆x)] /(2∆x) +O(∆x2)

Second derivate (second order-accurate approximation)

(d2f/dx2)xi ≈[f(xi+ ∆x) - 2f(xi) + f(xi-∆x)] /(∆x2) +O(∆x2)

Finite Difference Methods

Page 30: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference analog to the partial derivates

xOx

uu

x

u

x

u ni

ni

tconsn

i

n

i

1

tan

tOt

uu

t

u

t

u ni

ni

n

tconsi

n

i

1

tan

22

111

tan

2

2

2

2 2xO

x

uuu

x

u

x

u nni

ni

tconsn

i

n

i

Forward

Central

Forward

xOx

uu

x

u

x

u ni

ni

tconsn

i

n

i

1

tan

Backward

Partial derivatives of u at the (i,n)th node

Page 31: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Differential equations

2

2

x

u

t

u

Finite difference equations

(algebraic equations)

Estimating derivatives numerically

Page 32: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Consider a simple example of a parabolic (or diffusion) partial differential equation with one spatial independent variable

with (diffusion coefficient) constant.

Finite Differencing of Parabolic PDE’s

2

2

x

u

t

u

xЄ[xA,xB]: I.C.: u(x,0)=uo(x)

t>0 : B.C.1: u(0,t)=uA(t) B.C.2: u(xN,t)=uB(t)

Page 33: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

To apply the difference method to find the solution of a function u(x,t), we divide the solution region in x-t plane into equal rectangles or meshes of sides Δx and Δt.

x = i•Δx, i=1,2,…,N

t = n•Δt . n=1,2,…

1,2,… i-1, i, i+1,… N-1, N

01

x=xA x=xB

t

x

Finite Differencing of Parabolic PDE’s

Page 34: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

In the development of the analog finite difference equation we write

Finite Differencing of Parabolic PDE’s

n

i

n

i x

u

t

u

2

2

Both sides must to be evaluated at the same conditions xi and tn.

All i and n

1,2,… i-1, i, i+1,… N-1, N

01

x=xA x=xB

Then we substitute the analog finite difference equation for each derivates.

Page 35: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference analog to the partial derivates

x

uu

x

u

x

u ni

ni

tconsn

i

n

i

1

tan

2111

tan

2

2

2

2 2

x

uuu

x

u

x

u nni

ni

tconsn

i

n

i

Forward

Central

Forward

x

uu

x

u

x

u ni

ni

tconsn

i

n

i

1

tan

Backward

Partial derivatives of u at the (i,n)th node

tOt

uu

t

u

t

u ni

ni

n

tconsi

n

i

1

tan

Page 36: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Depending on analog finite difference equation used one can obtain different finite difference equations analogous to the:

1. Euler’s Method (explicit or forward)

2. Laasonen’s Method (implicit o backward)

3. Crank-Nicholson Method (implicit)

2

2

x

u

t

u

Page 37: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference schemeEuler’s Method (explicit or forward)

The forward or explicit difference equation is probably the most well known, although it is the least efficient of all the possible equations which can be used.

We use the forward difference formula for the derivative with respective to t and central difference formula with respect to x.

Page 38: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

u(x,t)

x

t

t

uu

t

u ni

ni

n

i

1

211

2

2 2

x

uuu

x

u ni

ni

ni

n

i

n+1

(i,n) (i+1,n)(i-1,n)

(i,n+1)

t

xi xi+1xi-1

n

Euler’s Method (explicit or forward)

Forward

Central

Page 39: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference schemeEuler’s Method (explicit or forward)

211

1 2

x

uuu

t

uu ni

ni

ni

ni

ni

ni

ni

ni

ni

ni uuu

x

tuu 112

1 2

This equation contains only one unknown value, uin+1, and is written

explicitly for this unknown.

Therefore, this explicit formula can be used to compute u(xi,tn+1) explicitly in terms of u(xi,tn) for i=2..N-1 (internal grid points). The computation of the values of the dependent variable is thus made one point at a time.

i=2…N-1

Finite difference equation:n+1

(i,n) (i+1,n)(i-1,n)

(i,n+1)

t

xi xi+1xi-1

n

Page 40: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference schemeEuler’s Method (explicit or forward)

The values of u along the first time row (n=0 or t=0) can be calculated in terms of the boundary and initial conditions, then the values of u along the second row (n=1 or t=Δt) are calculated in terms of the first time row, and so on:

1,2,… i-1, i, i+1,… N-1, N

01

....... 1210 ni

niiii uuuuu

ni

ni

ni

ni

ni uuu

x

tuu 112

1 2

i=2…N-1

Finite difference equation:

I.C.

Page 41: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference schemeEuler’s Method (explicit or forward)

The explicit formula is simple to implement, and especially easy to use for computing the value of u at each time level, but the its computation is slow. In general, a numerical solution must converge to the solution of the corresponding differential equation when the finite increments , x and t, are decreased in size.Analysis as shown that a very restrictive relationship between the size of x and that of t must be satisfied in order for the solution of forward equation to approach that of the differential equation.The restriction required that:

One should use very small t and large x which results to a stable solution but with low accuracy (in order to minimize the truncation error in the x analogs (O (x2)), the size of x must be small).

2

12

x

t

Page 42: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference schemeEuler’s Method (explicit or forward)

The many transient problems which have boundary conditions independent of time approach a steady state condition. For these problems:

The time increment can be continuously increased and made quite large as the solution progresses towards steady state without causing significant truncation error in the time analog.However, for the forward difference equation, the size of t must remain on the order of (x)2 for the solution to be stable. Thus, a very small value of t must be used for stability even when larger value could be used without causing truncation error.

A finite difference equation which does not have this restriction is, therefore, a much better one to use as an analog to the differential equation

2

2

x

u

t

u

xЄ[xA,xB]:I.C.: u(x,0)=uo(x)

t>0 : B.C.1: u(0,t)=uA

B.C.2: u(xN,t)=uB

Page 43: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Laasonen’s Method (implicit o backward)

In searching for a new finite difference equation which does not have a restriction on the size of t for stability, we might write the finite differences analogs for the derivates at the new or unknown time which is indexed by n+1.

1

2

21

n

i

n

i x

u

t

u

Page 44: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Laasonen’s Method (implicit o backward)t

n+1

(i,n)

(i+1,n+1)(i-1,n+1) (i,n+1)

xxi xi+1xi-1

n

u(x,t)

x

t

t

uu

t

u ni

ni

n

i

11

2

11

111

1

2

2 2

x

uuu

x

u ni

ni

ni

n

i

Note: The backward one is the only possible to be implement

Page 45: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Laasonen’s Method (implicit o backward)

ni

ni

ni

ni uuuu

x

tif

11

111

2

21

:

1

2

21 n

i

n

i x

u

t

u

t

n+1

(i,n)

(i+1,n+1)(i-1,n+1) (i,n+1)

xxi xi+1xi-1

n

2

11

111

1 2

x

uuu

t

uu ni

ni

ni

ni

ni

Page 46: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Laasonen’s Method (implicit o backward)

ni

ni

ni

ni uuuu

1

111

1 21

i=2…N-1

This equation is implicit; that is, it contains three values of the dependent values , u, at the unknown time level, n+1.For N-1 increments in x and the boundary conditions of equation:

B.C.1: u(0,t)=uA; B.C.2: u(xN,t)=uB

there will be N-2 unknown values of u at each time level, and there are N-2 equations, one corresponding to each points. In summary:

N-2 equations (1) for 2<=i<=N-1B.C.1 for i=1: u1

n+1=uA

B.C.2 for i=N: uNn+1=uB

(1)

Page 47: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Laasonen’s Method (implicit o backward)

The resulting set of equation represents a linear system in which the coefficient matrix is tridiagonal. If N=7, for each time level, one should calculate ui

n+1 as:B.C1: u1

n+1=uA

B.C.2: u7n+1=uB

The equation can thus be solved by the Thomas method to obtain N-2 values of ui

n+1. The same method can be used to obtain the values uin+2

from the now known values of uin+1

Bn

n

n

nA

n

n

n

n

n

n

uu

u

u

u

uu

u

u

u

u

u

6

5

4

3

2

16

15

14

13

12

12000

1200

0120

0012

00012

Page 48: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Laasonen’s Method (implicit o backward)

There is no restriction on the size of t for stability of the backward difference equation.

The size of t can therefore be set, independently of the size of x, to minimize the truncation error of the Taylor series in time.

All the values of u at the first unknown time level (n=1) will be computed from the initial values (n=0).

In the solution of these equations on a digital computer, it is usual practice to keep the size of x constant throughout the calculation.

Page 49: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Laasonen’s Method (implicit o backward)

If the boundary conditions are of the form of equation:

B.C.1: u(0,t)=uA; B.C.2: u(xN,t)=uB

so that the transient solution approaches a steady state condition, it is usual practice to increase the size of t as the solution progresses in order to obtain the solution in a minimum computing time.

This is because as the steady-state conditions are approached, the difference in values of u from one time level to the next diminishes if a constant time increment is used. Similarly, as the steady-state conditions are approached, the size of second and the higher time derivates decrease; thus, the same truncation error will result from a larger t as the steady-state is approached.

Page 50: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

Laasonen’s Method (implicit o backward)

The backward difference equation is an efficient one, and it is simple to use.

However, it is only first-order correct in time.

It is desirable to find a second-order correct analog to this derivates

2

11

111

1 2

x

uuu

t

uu ni

ni

ni

ni

ni

first order-accurate approximation

second order-accurate approximation

Page 51: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

uti

n1

22u

x2

i

n1

2

t

n+1

(i,n)

(i+1,n+1)(i-1,n+1) (i,n+1)

xxi xi+1xi-1

n (i-1,n) (i+1,n)

+n+1/2

Crank-Nicholson Method (implicit)

In the Crank-Nicholson equation all the finite difference are written about the point (xi, tn+1/2) (point designated by a cross) which is halfway between the known and the unknown time levels.

Values of the dependent variable, u, are computed only at the points designated by circles.

Page 52: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

t

n+1

(i,n)

(i+1,n+1)(i-1,n+1) (i,n+1)

xxi xi+1xi-1

n (i-1,n) (i+1,n)

+n+1/2

Crank-Nicholson Method (implicit)

t

uutuu

t

u ni

ni

ni

ni

n

i

11

2

1

22

Second order correct analog of the time derivate at the point (xi, tn+1/2) (Central formula at the time level tn+1/2)

Truncation error: 22

2tO

tO

Page 53: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

t

n+1

(i,n)

(i+1,n+1)(i-1,n+1) (i,n+1)

xxi xi+1xi-1

n (i-1,n) (i+1,n)

+n+1/2

Crank-Nicholson Method (implicit)

The second order space derivate at the point (xi, tn+1/2)

2

11

111

211

2

1,

2

2

1

2

2

2

2

2

1,

2

2

22

2

1

2

x

uuu

x

uuu

x

u

xu

xu

x

u

ni

ni

ni

ni

ni

ni

ni

n

i

n

i

ni

2

2/11

2/12/11

2

1,

2

2 2

x

uuu

x

u ni

ni

ni

ni

The second order space derivate at the point (xi, tn+1/2) is approximated by the arithmetic average of the central difference formulas at the point (xi, tn) and (xi, tn+1)

Page 54: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

ni

ni

ni

ni

ni

ni u

x

tu

x

tu

x

tu

x

tu

x

tu

x

t12212

112

12

112 2

122

12

Crank-Nicholson Method (implicit)

Crank-Nicholson finite difference equation which is second-order correct in both x and t:

22

:x

tif

2

11

111

211

1 22

2

1

x

uuu

x

uuu

t

uu ni

ni

ni

ni

ni

ni

ni

ni

ni

ni

ni

ni

ni

ni uuuuuu 11

11

111 2121

Page 55: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

This equation is implicit as it contains the same three unknown values of u that are found in the backward difference equation. Similarly, this equation and its two boundary conditions can be solved by the Thomas method.

Crank-Nicholson Method (implicit)

t

n+1

(i,n)

(i+1,n+1)(i-1,n+1) (i,n+1)

xxi xi+1xi-1

n (i-1,n) (i+1,n)

+n+1/2

u(x,t)

x

t

ni

ni

ni

ni

ni

ni uuuuuu 11

11

111 2121

Page 56: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

The Crank-Nicholson Method requires more computations per time step than the backward difference method to evaluate the right side of the equation (this side contains values of u at three length positions at the known time level instead of the one value found in the backward difference equation.

However, a larger time increment can be used for the Crank-Nicholson equation , since its time derivate analog is second order correct, fewer time steps are thus necessary to computes values of the dependent variable for a given elapsed time.

Thus the Crank-Nicholson equation is more efficient than the backward difference method and is the preferred method for obtaining numerical solutions to parabolic differential equations.

Crank-Nicholson Method (implicit)

ni

ni

ni

ni

ni

ni uuuuuu 11

11

111 2121

Page 57: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

The Crank-Nicholson equation, like the backward difference equation, is stable for all ratios of x to t.

Crank-Nicholson Method (implicit)

ni

ni

ni

ni

ni

ni uuuuuu 11

11

111 2121

Page 58: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

In matrix form the system of equations becomes

Crank-Nicholson Method (implicit)

n1n BuAu

ni

ni

ni

ni

ni

ni uuuuuu 11

11

111 2121

1nN

1ni

1n0

1n

u

u

u

u

nN

ni

n0

n

u

u

u

u

Vector of unknown values Vector of known values

Page 59: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Finite Difference scheme

The resulting set of equation represents a linear system in which the coefficient matrix is tridiagonal. If N=7, for each time level, one should calculate ui

n+1 as:B.C1: u1

n+1=uA

B.C.2: u7n+1=uB

The equation can thus be solved by the Thomas method to obtain N-2 values of ui

n+1. The same method can be used to obtain the values uin+2

from the now known values of uin+1

Bnnn

n

n

nA

nnn

n

n

n

n

n

uuuu

u

u

u

uuuu

u

u

u

u

u

326

5

4

3

321

16

15

14

13

12

)21(

)21(

21000

2100

0210

0021

00021

Crank-Nicholson Method (implicit)

Page 60: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Numerical methods to solve parabolic PDEs:

Boundary conditions

Page 61: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

2

2

x

u

t

u

2° order PDE

2 independent variables

Linear with constant coefficients

is a diffusion coefficient

I.C.: t = 0 u(x,0) = u0(x)

The boundary conditions for partial differential equations of second order must to be two and they can arise as expressions containing the values of the unknown function u and / or its first derivatives ∂u/∂x

Page 62: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

The condition of the Dirichlet is the simplest case of boundary conditions. In general, it provides the boundary conditions for the possible dependence on the time variable through the function C (t) and F (t) (which can also be constant)

We write the finite difference equation at the internal nodes of the domain including the nodes adjacent to the boundary (i=2…N-1). Then in this equations we replace the value of the function on the boundary value (known) imposed by the condition.

B.C.1: x=0 -> u(t, x=0)=C(t) all t (simple case)B.C.2: x=L -> u(t, x=L)=F(t) all t (simple case)

Dirichlet condition

Page 63: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

Example:

Dirichlet condition

2

2

x

u

t

u

I.C.: t = 0 u(x,0) = u0(x)

B.C.1: x=0 -> u(t, x=0)=C(t) all t (simple case)B.C.2: x=L -> u(t, x=L)=F(t) all t (simple case)

where C(t) and F(t) can be also constant

Page 64: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

Example: Laasonen’s Method (implicit o backward)

B.C1: x=0: u1n+1=uA(t)

B.C.2: x=L: uNn+1=uB(t)

N°eq=(N-2) (1) + 2BC = N

(1)

x=0 x=L

1 2 N-2 N-1 N

ni

ni

ni

ni uuuu

1

111

1 21

i=2…N-1

Dirichlet condition

Page 65: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

The case of the Neumann condition differs from the previous by the fact that the unknown function is also unknown on the boundary, on which, however, the derivative is known.

Therefore, for the same discrete grid, you must obtain one equation more (for each Neumann condition) than in the Dirichlet case.

F(t) x

u L x

C(t) x

u 0 x

Lx

0x

Neumann condition

Page 66: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

Example:

2

2

x

u

t

u

I.C.: t = 0 u(x,0) = u0(x)

B.C.1: x=0 -> u(t, x=0)=C(t) all t (simple case)

B.C.2: x=L -> u(t, x=L) ->(∂u/∂x)=q all t (simple case)where q is known

The finite-difference equation must be write, as in the previous case, for all internal nodes (i=2..N-1), and the boundary condition will provide an additional equation for the unknown value of the function on the boundary

Neumann condition

Page 67: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

Example: Laasonen’s Method

B.C1: x=0: u1n+1=uA(t)

B.C.2: x=L:

N°eq=(N-2) (1) + 2BC = N

(1)

x=0 x=L

1 2 N-2 N-1 N

2

111

121

11 2

x

uuu

t

uu nN

nN

nN

nN

nN

qx

uu nN

nN

1

11

Backward formula

Neumann condition (1)

Page 68: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

B.C.2: x=L:

qx

uu nN

nN

1

11

Note: The expression used for the first derivative, being "backward" and not central, is only accurate to first order.

To improve this aspect, it is useful to write a formula that is central to the position of the edge (i=N), which is when we know the value of the first derivative.

This node can be obtained by considering an outside "fictitious node".

Backward formula

Neumann condition

Page 69: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

Using the following discretization:

one can write the discretized equation also for the N node as

where uN+1n+1 is the value taken by function in the fictitious node

x=0 x=L

1 2 N-2 N-1 N N+1

i=2..N -> N-1 equations

Neumann condition (2)

2

11

111

1 2

x

uuu

t

uu ni

ni

ni

ni

ni

2

11

111

1 2

x

uuu

t

uu nN

nN

nN

nN

nN

i=N

Page 70: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

In summary:

x=0 x=L

0 1 N-2 N-1 N N+1

2

11

111

1 2

x

uuu

t

uu nN

nN

nN

nN

nN

qx

uu nN

nN

2 1

11BC2: x=L

(Central formula)11

11N 2u

n

Nn uxq

Neumann condition (2)

i=2..N -> N-1 equations

Page 71: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

In summary:

x=0 x=L

0 1 N-2 N-1 N N+1

x

q

x

uu

t

uu nN

nN

nN

nN

222

2

111

1

Again we have N equations in N unknowns, and thus all of the formulas employed for the derivatives of space are the second order. It should also be noted that the formula used for the first derivative is formally second order accurate, but for a double-interval (2x).

Neumann conditionxx

Page 72: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

x=0 x=L

0 1 N-2 N-1 N N+1

A further improvement can be achieved using the following discretization:

Note: the grid is distributed so as to drop the last pair of nodes, formed by the last node (N) and the outside fictitious node (N+1), straddling the boundary on which the Neumann condition is imposed. In this way we write the balance equation, as in the previous case, for all internal nodes to the node N, while the boundary condition will be written as:

Neumann condition

x/2x/2

qx

uu nN

nN

11 BC2: x=L (Central formula)

Page 73: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

In summary:

Neumann condition (3)

x=0 x=L

0 1 N-2 N-1 N N+1

x/2x/2

qx

uu nN

nN

11

2

11

111

1 2

x

uuu

t

uu nN

nN

nN

nN

nN

i=2..N -> N-1 equations

Central and therefore accurate to second order, and for a range of x.

BC2: x=L

The latter method is thus preferable to others when the Neumann condition is "pure“, that is, not involving the boundary value of the function.

Page 74: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Boundary conditions

The flow is not assigned as a value (q), but is determined by an exchange coefficient multiplied by a driving force which is a function of the unknown value taken by the function on the edge, thus giving rise to a boundary condition known as “third type” or “mixed“.

It will be more natural adopt the second method, which involves both the fictitious node and the node at the edge.

Third type” or “mixed condition

tCx

txuBtxuA

xx

00

,,

tFx

txuEtxuD

LxLx

,,

LxLx

TTh

x

Tk Example

Page 75: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Convergence and stability of FDM for 2° order linear parabolic Equations

U(x,t) is the exact solution of partial differential problem in IR 't. u is the exact solution of finite difference equations used to approximate the differential problem.

Intuitively, it is expected to be a "good" method when:u->U when x, t ->0

More precisely, one can say for example that, if uin is the value of u

calculated at the point (xi, tn) of the integration domain, and if

then the finite difference method is said to be convergent.

If U is the vector generated by evaluating U(xi, tn), then U-u is said to be the discretization error, and is the direct consequence of the truncation error in finite difference formulas.

Definition of convergence

nitxUu nini

tx

,,lim00

Page 76: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Convergence and stability of FDM for 2° order linear parabolic Equations

u is the exact solution of finite difference equations used to approximate the differential problem

ũ is the numerical solution of the same problem

As a result of rounding errors (roundoff) introduced by the machine is always:

u≠ũ

A method is said to be stable if (ũ –u) does not diverges as the number of discretization nodes increases.

Euler’s method is stable when: (Stability Parameter)

Both Laasonen’s Method and Crank-Nicholson equations, are stable for all ratios of x to t.

(Stability Parameter)

Definition of numerical stability

2

12

x

t

2x

t

Page 77: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Convergence and stability of FDM for 2° order linear parabolic Equations

A finite difference scheme is called consistent if, making the limit for finite increments of the independent variables that tend to zero, it returns the differential expression that you want to approximate.

Note: all the three schemes examined in this course are consistent. Of course, what matters is the construction of methods which can prove the convergence, since at the end the only solution is becoming available is the numerical one which, hopefully, is close to the exact one. Convergence Lax’s theorem

A finite difference method for a second order linear PDE schemes that use consistent scheme, and that is numerically stable, is convergent.

Definition of consistency

Page 78: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

Parabolic PDE’s

Parabolic (or diffusion) PDE with one spatial independent variable: general form

t Є [0, +∞]x Є [xA, xB]

I.C.: u(t=0,x)=u*(x) all xB.C.1: u(t, x=xA)=uA(t) all t (simple case)B.C.2: u(t, x=xB)=uB(t) all t (simple case)

Analytical solution: u=u(t,x) where u is a continuous function of t and x

txuSx

txu

x

txu

t

txu,

,,,2

2

Page 79: Numerical methods to solve parabolic PDEs. Mathematical models: 5° Classification Classification based on the type of the solution (except, usually, the

PARABOLIC PDE Linear generation term

Explicit method

txukx

txu

t

txu,

,,2

2

ni

ni

ni

ni

ni

ni utkuuu

x

tuu

1121 2

Parabolic PDE’s