+ All Categories
Home > Documents > Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E....

Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E....

Date post: 05-Jan-2016
Category:
Upload: reynold-garrison
View: 225 times
Download: 3 times
Share this document with a friend
Popular Tags:
30
Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones
Transcript
Page 1: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Solving an elliptic PDE using finite differences

Numerical Methods for PDEs Spring 2007

Jim E. Jones

Page 2: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Many physical processes can be modeled with Partial Differential Equations (PDEs)

fuu yyxx E

t

EH

t

HE

Poisson Equation modeling steady-

state temperature in 2d plate

Maxwell’s equations relating

electric and magnetic fields

2

2

22 1

tv

Wave Equation modeling wave propagation at speed v

Page 3: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

• PDE classified by discriminant: b2-4ac.– Negative discriminant = Elliptic PDE. Example

Laplace’s equation

– Zero discriminant = Parabolic PDE. Example Heat equation

– Positive discriminant = Hyperbolic PDE. Example Wave equation

Partial Differential Equations (PDEs) :2nd order model problems

0 yyxx uu

0 xxt uu

0 ttxx uu

gfueuducubuau yxyyxyxx

Page 4: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

• PDE classified by discriminant: b2-4ac.– Negative discriminant = Elliptic PDE. Example

Laplace’s equation

– Zero discriminant = Parabolic PDE. Example Heat equation

– Positive discriminant = Hyperbolic PDE. Example Wave equation

Partial Differential Equations (PDEs) :2nd order model problems

0 yyxx uu

0 xxt uu

0 ttxx uu

gfueuducubuau yxyyxyxx

Page 5: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Solving PDEs on a computer typically involves discretizing on a grid

Computers typically don’t understand continuous quantities, only discrete ones.

Rather than asking for the temperature as a function u(x,y), we seek to find an approximation to the temperature at each point on a grid.

Page 6: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Discretization approximates the differential problem by an algebraic one

fuu yyxx

fAu

Page 7: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences - derived by interpolation

x0 x1 x2

(xo,u0)

(x1,u1)

(x2,u2)

Construct polynomial interpolating data

Page 8: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences - derived by Lagrange interpolation

x0 x1 x2

(xo,u0)

(x1,u1)

(x2,u2)

21202

10

12101

20

02010

21

))((

))((

))((

))((

))((

))(()(

uxxxx

xxxx

uxxxx

xxxx

uxxxx

xxxxxp

Approximate 2nd derivative of u at x1 by 2nd derivative of p

Page 9: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences - derived by Lagrange interpolation

x0 x1 x2

(xo,u0)

(x1,u1)

(x2,u2)

)2(1

))((

2

))((

2

))((

2)(''

2102

21202

12101

02010

uuuh

uxxxx

uxxxx

uxxxx

xp

h

Page 10: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences - derived by Taylor’s Theorem

[Taylor’s Theorem] Suppose f and its first n derivatives are continuous on [a,b], its n+1 derivative exists on [a,b], and xo is in [a,b]. Then for any x in [a,b] there is a c(x) between x and x0 with:

10

)1(

00

0)(

)()!1(

))(()(

)(!

)()(

)()()(

n

n

n

kn

k

k

n

nn

xxn

xcfxR

xxk

xfxP

xRxPxf

Page 11: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences

x0 x1 x2

(xo,u0)

(x1,u1)(x2,u2)

)(24

)('''6

)(''2

)(')()(

)(24

)('''6

)(''2

)(')()(

2)4(

4

1

3

1

2

112

0)4(

4

1

3

1

2

110

cuh

xuh

xuh

xhuxuxu

cuh

xuh

xuh

xhuxuxu

Page 12: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences

x0 x1 x2

(xo,u0)

(x1,u1)(x2,u2)

)]()([24

)('')(2)()(

________________________________________________

)(24

)('''6

)(''2

)(')()(

)(24

)('''6

)(''2

)(')()(

2)4(

0)4(

4

12

120

2)4(

4

1

3

1

2

112

0)4(

4

1

3

1

2

110

cucuh

xuhxuxuxu

cuh

xuh

xuh

xhuxuxu

cuh

xuh

xuh

xhuxuxu

Page 13: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences

x0 x1 x2

(xo,u0)

(x1,u1)(x2,u2)

)]()([24

)('')(2)()(

________________________________________________

)(24

)('''6

)(''2

)(')()(

)(24

)('''6

)(''2

)(')()(

2)4(

0)4(

4

12

120

2)4(

4

1

3

1

2

112

0)4(

4

1

3

1

2

110

cucuh

xuhxuxuxu

cuh

xuh

xuh

xhuxuxu

cuh

xuh

xuh

xhuxuxu

If the 4th derivative is continuous, then the average value of u at co and c2 is attained at some c between them. (Intermediate Value Theorem)

Page 14: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences

x0 x1 x2

(xo,u0)

(x1,u1)(x2,u2)

)(12

)('')(2)()(

________________________________________________

)(24

)('''6

)(''2

)(')()(

)(24

)('''6

)(''2

)(')()(

)4(4

12

120

2)4(

4

1

3

1

2

112

0)4(

4

1

3

1

2

110

cuh

xuhxuxuxu

cuh

xuh

xuh

xhuxuxu

cuh

xuh

xuh

xhuxuxu

If the 4th derivative is continuous, then the average value of u at co and c2 is attained at some c between them

Page 15: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences

)(12

)('')(2)()( )4(4

12

120 cuh

xuhxuxuxu

x0 x1 x2

(xo,u0)

(x1,u1)(x2,u2)

Solving for u’’

)(12

)]()(2)([1

)('' )4(2

21021 cuh

xuxuxuh

xu

Page 16: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite differences

)(12

)('')(2)()( )4(4

12

120 cuh

xuhxuxuxu

x0 x1 x2

(xo,u0)

(x1,u1)(x2,u2)

Solving for u’’

)(12

)]()(2)([1

)('' )4(2

21021 cuh

xuxuxuh

xu

Same approximation we got using interpolation

Page 17: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite difference discretization based on Taylor’s approximation.

)),(),(2),((1

),(2

yhxuyxuyhxuh

yxuxx

Page 18: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite difference discretization based on Taylor’s approximation.

)),(),(2),((1

),(2

yhxuyxuyhxuh

yxuxx

Approximated derivative at a point by an algebraic equation involving function values at nearby points

By Taylor’s Theorem, the error in this approximation (the truncation error) is O(h2)

Page 19: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Finite difference discretization based on Taylor’s approximation.

fuu yyxx ),()),(),(),(4),(),((1

2yxfhyxuyhxuyxuhyxuyhxu

h

Error in approximation is determined by the mesh size h. Difference between differential solution and algebraic solution goes to zero as h does.

Equation for each grid point (x,y)

fAu

Page 20: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Simple Example

1 yyxx uu ]1,0[]1,0[

2u

on

on

Partial Differential Equation

Boundary Conditions

(0,0)

(1,1)

Page 21: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Simple Example

Where are the discrete u values located?

Page 22: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Simple Example

Where are the discrete u values located?

At grid points

Page 23: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Simple Example

Which u-values do we already know?

Page 24: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Simple Example

Which u-values do we already know?

The boundary values are =2

Page 25: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Simple Example

Write down the 9x9 matrix problem for computing the unknown u-values.

Page 26: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Simple Example

Write down the 9x9 matrix problem for computing the unknown u-values.

1 2 3

4 5 6

7 8 9

Page 27: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Linear System

2

2

2

2

2

2

2

2

9

8

7

6

5

4

3

2

1

2

)25(.

41

)25(.

21

)25(.

41

)25(.

21

1)25(.

21

)25(.

41

)25(.

21

)25(.

41

410100000

141010000

014001000

100410100

010141010

001014001

000100410

000010141

000001014

)25(.

1

u

u

u

u

u

u

u

u

u

1 2 3

4 5 6

7 8 9

Page 28: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

MATLAB

Page 29: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

MATLAB

• Debugging – does the solution “look correct”– Symmetry

– Other checks, can we set it up so we know the solution?

Page 30: Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

MATLAB

• To think about on the MLK Holiday break (and to get ready for assignment 1)– How would you code up the simple example?

– How could you allow general mesh size h?

– How could you allow general rhs and bc’s? Perhaps even functions that depend on position: sin(xy)?

– How would you verify your code is working properly?


Recommended