Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones."— Presentation transcript:

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

2 Many physical processes can be modeled with Partial Differential Equations (PDEs) Poisson Equation modeling steady- state temperature in 2d plate Maxwell’s equations relating electric and magnetic fields Wave Equation modeling wave propagation at speed v

3 PDE classified by discriminant: b 2 -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) : 2 nd order model problems

4 PDE classified by discriminant: b 2 -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) : 2 nd order model problems

5 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.

6 Discretization approximates the differential problem by an algebraic one

7 Finite differences - derived by interpolation x0x0 x1x1 x2x2 (x o,u 0 ) (x 1,u 1 ) (x 2,u 2 ) Construct polynomial interpolating data

8 Finite differences - derived by Lagrange interpolation x0x0 x1x1 x2x2 (x o,u 0 ) (x 1,u 1 ) (x 2,u 2 ) Approximate 2 nd derivative of u at x 1 by 2 nd derivative of p

9 Finite differences - derived by Lagrange interpolation x0x0 x1x1 x2x2 (x o,u 0 ) (x 1,u 1 ) (x 2,u 2 ) h

10 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 x o is in [a,b]. Then for any x in [a,b] there is a c(x) between x and x 0 with:

11 Finite differences x0x0 x1x1 x2x2 (x o,u 0 ) (x 1,u 1 ) (x 2,u 2 )

12 Finite differences x0x0 x1x1 x2x2 (x o,u 0 ) (x 1,u 1 ) (x 2,u 2 )

13 Finite differences x0x0 x1x1 x2x2 (x o,u 0 ) (x 1,u 1 ) (x 2,u 2 ) If the 4 th derivative is continuous, then the average value of u at c o and c 2 is attained at some c between them. (Intermediate Value Theorem)

14 Finite differences x0x0 x1x1 x2x2 (x o,u 0 ) (x 1,u 1 ) (x 2,u 2 ) If the 4 th derivative is continuous, then the average value of u at c o and c 2 is attained at some c between them

15 Finite differences x0x0 x1x1 x2x2 (x o,u 0 ) (x 1,u 1 ) (x 2,u 2 ) Solving for u’’

16 Finite differences x0x0 x1x1 x2x2 (x o,u 0 ) (x 1,u 1 ) (x 2,u 2 ) Solving for u’’ Same approximation we got using interpolation

17 Finite difference discretization based on Taylor’s approximation.

18 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(h 2 )

19 Finite difference discretization based on Taylor’s approximation. 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)

20 Simple Example on Partial Differential Equation Boundary Conditions (0,0) (1,1)

21 Simple Example Where are the discrete u values located?

22 Simple Example Where are the discrete u values located? At grid points

23 Simple Example Which u-values do we already know?

24 Simple Example Which u-values do we already know? The boundary values are =2

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

26 Simple Example Write down the 9x9 matrix problem for computing the unknown u-values. 1 2 3 45 6 7 89

27 Linear System 1 2 3 45 6 7 89

28 MATLAB

29 Debugging – does the solution “look correct” –Symmetry –Other checks, can we set it up so we know the solution?

30 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?


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

Similar presentations


Ads by Google