28
Introduction to Introduction to Numerical Differential Numerical Differential Equations Equations

Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Introduction to Introduction to Numerical Differential Numerical Differential

EquationsEquations

Page 2: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Partial Differential EquationsPartial Differential Equations• A relation involving an unknown

function of several independent variables and its partial derivativeswith respect to those variables

• Formulate and solve problems that involve unknown functions of several variables in real world

• Completely distinct physical problems may have identical mathematical formulations

Page 3: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

ODE and PDEODE and PDE• Ordinary differential equation (ODE)

• Partial differential equation (PDE)

Page 4: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Types of Types of PDEsPDEs• Hyperbolic equation (Wave Equation)

– Describe propagation of waves– The most simple example:

)(),()()0,(

),(

,0

atxtxuconditioninitialxxu

txUuxua

tu

−Φ=Φ=

=

=∂∂

+∂∂

Page 5: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Types of Types of PDEsPDEs• Parabolic equation (Diffusion Equation)

– Describe energy conservation– The most simple example:

conditioninitialxxutxUuxu

tu

)()0,(),(

,2

2

Φ==

∂∂

=∂∂ γ

Page 6: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Types of Types of PDEsPDEs• Elliptic equation (Equilibrium Equation)

– Describe steady state of heat diffusion– The most simple example:2D Laplacian

Equation

conditioninitialyxyxutyxUu

yu

xu

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

,02

2

2

2

Φ==

=∂∂

+∂∂

Page 7: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Differentiation and IntegrationDifferentiation and Integration

dvdt

v

ta

tdtdva =

v

t

∫=b

avdty

y

DifferentiationDifferentiation IntegrationIntegration

Page 8: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Numerical Operations Numerical Operations • Compute derivatives on discretized

domain: discrete points, 2D grid, 3D grid, unstructured mesh…

• ODE ordinary differential equation• PDE partial differential equation• Approximate continuous derivatives

with numerical differential operators–Use Taylor expansion …

Page 9: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Taylor expansionTaylor expansion• Taylor series expansion

• Assume that the discrete points are distributed equally

( ) ( ) ( ) ( )

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) K

K

!3!2

!3!2

0

30i

0

20i

00i0i

0i

xx3

33

xx2

22

xx0i

000

+′′′−+′′−

+′−+=

−=Δ

+Δ+====

xfxxxfxxxfxxxfxf

xxx

dxfdx

dxfdx

dxdfxxfxf

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) [ ]

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) [ ]3 !3

!2

1 !3

!2

i

3

i

2

ii1-i

i

3

i

2

ii1i

K

K

xfxxfxxfxxfxf

xfxxfxxfxxfxf

′′′Δ−′′Δ

+′Δ−=

+′′′Δ+′′Δ

+′Δ+=+

Page 10: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Forward difference schemeForward difference scheme• From the Taylor expansion

• Forward Differentiation

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) !3

!2 i

3

i

2

ii1i K+′′′Δ+′′Δ

+′Δ=−+ xfxxfxxfxxfxf

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) !3

!2 i

3

i

2

i1ii K+′′′Δ−′′Δ

−−=′Δ + xfxxfxxfxfxfx

( ) ( ) ( ) ( ) ( ) ( ) ( ) !3

!2 i

2

ii1i

i K+′′′Δ−′′Δ

−⎟⎠⎞

⎜⎝⎛

Δ−

=′ + xfxxfxx

xfxfxf

( ) ( ) ( )⎟⎠⎞

⎜⎝⎛

Δ−

≈′ +

xxfxfxf i1i

i

( ) ( ) ( ) ( ) !3

!2

Error ion Approximat i

2

i K+′′′Δ+′′Δ

= xfxxfx

Page 11: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Backward difference schemeBackward difference scheme

( ) ( ) ( ) 1-iii ⎟

⎠⎞

⎜⎝⎛

Δ−

≈′x

xfxfxf

( ) ( ) ( ) ( ) !3

!2

Error ion Approximat i

2

i K+′′′Δ+′′Δ

= xfxxfx

Page 12: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Central difference schemeCentral difference scheme• By averaging FD and BD, central difference

scheme can provide reduced approximation error

• the errors of the forward and backward 1st derivative of the equations have an error of the order of O(Δx) and the central differentiation has an error of order O(Δx2). The central difference has better accuracy and lower error that the others

( ) ( ) ( ) 2

1-i1ii ⎟

⎠⎞

⎜⎝⎛

Δ−

≈′ +

xxfxfxf

( ) ( ) !3

Error ion Approximat i

2

K+′′′Δ= xfx

Page 13: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Second order derivativeSecond order derivative

It will require three terms to get a central 2nd derivative of discrete set of data.

This is central difference scheme, more schemes can be applied to approximate second order derivatives…

( ) ( ) ( ) ( ) ( )[ ] xOE 2 22

1-ii1ii Δ+⎟

⎠⎞

⎜⎝⎛

Δ+−

=′′ +

xxfxfxfxf

Page 14: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Use finite difference operationUse finite difference operationto solve PDEto solve PDE

• For simple wave function

• Use time and space differences, we can derive a recursive equation

0=∂∂

+∂∂

xua

tu

)(

0

11

11

nk

nk

nk

nk

nk

nk

nk

nk

uuxtauu

xuua

tuu

−+

−+

−ΔΔ

−=

≈Δ−

+Δ−

Page 15: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Initial and boundary conditionsInitial and boundary conditions• To solve the recursive equation, we

need to know the function that describe the values of u at time 0

• We also have to know the values on the boundary x=0 at any time

)()0,( xxu Φ=

)(),0( xtu Θ=

Page 16: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Truncation ErrorTruncation Error• By using finite operators, we represent

partial derivatives by discrete approximations

• For example, if using Forward Difference– We know in Taylor expansion of x

– In general, the FD() results differs from exact solution D() by a truncation error in the first order of delta_x and delta_t

( ) ( ) ( ) ( ) !3

!2

Error ion Approximat i

2

i K+′′′Δ+′′Δ

= xfxxfx

),O( )()(F txuDuD nk ΔΔ=−

Page 17: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Truncation ErrorsTruncation Errors• Use other scheme, we may achieve

other orders of Δx and Δt• In general

• l and m are the order of truncation errors

),T( )()( mlnk txuLuL ΔΔ=−

Page 18: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

ConsistencyConsistency• Then we define “Consistency” of an finite

difference scheme

0),T( )()(00

→ΔΔ=−

→Δ→Δ

mlnk txuLuLtx

Page 19: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

StabilityStability• Definition:

– Suppose un+1 is a solution at time n+1, u0 is initial condition, a numerical scheme is stable if

– Here || || defines the error of numerical scheme and k, beta are constants

– This should be satisfied for any

01 ukeu tn β≤+

t≤0

Page 20: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Lax TheoremLax Theorem• Convergence: a difference scheme

approximates the PDE is convergent scheme if for any x and t, numerical solution u(n,k) converges to exact solution v(x,t) when Δx 0 and Δt 0

• Lax Theorem: If a consistency two level scheme for a linear PDE is table, then the scheme is convergence

Page 21: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Boundary ConditionsBoundary Conditions• Periodic boundary

• Dirichlet boundary: constant boundary values

• Neumann boundary: first derivative known

),(),0( tnVtV =

)(),( xftxV =

cdx

txdV=

),(

Page 22: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Explicit and Implicit SchemesExplicit and Implicit Schemes• Two different strategy to solve

differential equations• An simple example, to solve

• We could use Euler method and Backward Euler method FD scheme to compute

Page 23: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Euler MethodEuler Method• Very straightforward method, from

• We yields

• This is the most simple explicit scheme

• Explicit means that the new value are defined in terms of things that already known in the previous step

Page 24: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Backward Euler MethodBackward Euler Method• Instead of Euler method, we use

• Then, we get

• This is an implicit scheme• Implicit means that the new value is

defined in terms of things in the same step

Page 25: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Explicit Scheme LimitationExplicit Scheme Limitation• If f(t,y) is simply defined as f = –ay• Then for Euler method:

• The truncate error from 0 to n should not be amplified, this is the requirement for the stability of the explicit scheme

• In order to implement this, we need to satisfy that

01

1

21

)1()1(

)1()1(

yahyah

yahyahahyyynn

nnnnn+

+

−=−==

−=−=−=

L

11 <− ah

Page 26: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

CFL ConditionCFL Condition• This is a simple case of Courant–

Friedrichs–Lewy condition (CFL condition)

• Explicit solver is conditionally stable• Explicit scheme is simple to compute• Explicit scheme requires small time

step. Therefore, require lots of steps to achieve satisfied results

Page 27: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Implicit SchemeImplicit Scheme• For backward Euler method,

• It is easy to find the for any h>0, this implicit scheme is stable

• Implicit scheme is generally unconditionally stable

• We can choose large h to achieve satisfied results in a small number of steps

10

1

11

)1(1 ++

++

+==

+=

−=

nn

n

nnn

ahy

ahyy

ahyyy

L

Page 28: Introduction to Numerical Differential Equationszhao/gpu/lectures/IntroNumericalDifference.pdf · Partial Differential Equations • A relation involving an unknown function of several

Numerical methodsNumerical methods• Many methods exist and are

improved for solving PDEs• How to choose:

–particular applications–Accuracy requirement–performance requirement–Computational resources–…