mecn 3500 inter - bayamon lecture 9 numerical methods for engineering mecn 3500 professor: dr. omar...

Post on 13-Dec-2015

232 Views

Category:

Documents

7 Downloads

Preview:

Click to see full reader

TRANSCRIPT

MEC

N 3

500 I

nte

r -

Bayam

on

Lecture

9Numerical Methods for Engineering

MECN 3500

Professor: Dr. Omar E. Meza Castilloomeza@bayamon.inter.edu

http://www.bc.inter.edu/facultad/omezaDepartment of Mechanical EngineeringInter American University of Puerto Rico

Bayamon Campus

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on Tentative Lectures Schedule

Topic Lecture

Mathematical Modeling and Engineering Problem Solving 1

Introduction to Matlab 2

Numerical Error 3

Root Finding 4-5-6

System of Linear Equations 7-8

Finite Difference 9

Least Square Curve Fitting

Polynomial Interpolation

Numerical Integration

Ordinary Differential Equations

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Best known numerical method of approximation

Finite Difference

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

To understand the theory of finite differences.

To apply FD to the solution of specific problems as a function of accuracy, condition matrix, and performance of iterative methods.

Course Objectives

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

FINITE DIFFERENCE FORMULATIONOF DIFFERENTIAL EQUATIONS

finite difference form of the first derivative

Taylor series expansion of the function f about the point x,

The smaller the x, the smaller the error, and thus the more accurate the approximation.

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

• The forward Taylor series expansion for f(xi+2) in terms of f(xi) is

• Combine equations:

212

21

22

22

)()()(2)(

_______________________________________

2

)()()()(2

)2(2

)()2)(()()(

)2(2

)()2)(()()(

hxfxfxfxf

hxf

hxfxfxf

hxf

hxfxfxf

hxf

hxfxfxf

iiii

iiii

iiii

iiii

FINITE DIFFERENCE APPROXIMATION OF HIGHER

DERIVATIVE

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

• Solve for f ''(xi):

• This formula is called the second forward finite divided difference and the error of order O(h).

• The second backward finite divided difference which has an error of order O(h) is

221

212

)()(2)()(

)()(2)()(

h

xfxfxfxf

h

xfxfxfxf

iiii

iiii

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

• The second centered finite divided difference which has an error of order O(h2) is

211 )()(2)(

)(h

xfxfxfxf iiii

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

• High accurate estimates can be obtained by retaining more terms of the Taylor series.

hxf

h

xfxfxf

hxf

xxxfxfxf

iiii

iiiiii

2

)('')()()(

2

)(''))(()()(

1

211

• The forward Taylor series expansion is:

• From this, we can write

High-Accuracy Differentiation Formulas

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

• Substitute the second derivative approximation into the formula to yield:

• By collecting terms:

• Inclusion of the 2nd derivative term has improved the accuracy to O(h2).

• This is the forward divided difference formula for the first derivative.

h

xfxfxfxf

hh

xfxfxf

h

xfxfxf

iiii

iii

iii

2

)(3)(4)()(

2

)()(2)()()(

)(

12

212

1

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Forward Formulas

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Backward Formulas

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Centered Formulas

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Example

Estimate f '(1) for f(x) = ex + x using the centered formula of O(h4) with h = 0.25.

Solution

5.15.012

25.125.01

1

75.025.01

5.05.012

12

)()(8)(8)()(

2

1

1

2

2112

hxx

hxx

x

hxx

hxx

h

xfxfxfxfxf

ii

ii

i

ii

ii

iiiii

•From Tables

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

717.33

)149.2()867.2(8)740.4(8982.5

)25.0(12

)5.0()75.0(8)25.1(8)5.1()(

ffff

xf i

•In substituting the values:

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Error Truncation Error: introduced in the

solution by the approximation of the derivative

Local Error: from each term of the equation

Global Error: from the accumulation of local error

Roundoff Error: introduced in the computation by the finite number of digits used by the computer

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Numerical solutions can give answers at only discrete points in the domain, called grid points.

If the PDEs are totally replaced by a system of algebraic equations which can be solved for the values of the flow-field variables at the discrete points only, in this sense, the original PDEs have been discretized. Moreover, this method of discretization is called the method of finite differences.

Introduction to Finite Difference

(i,j)

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

x

Discretization: PDE FDE

Explicit Methods Simple No stable

Implicit Methods More complex Stables

¬∆x®

xm-1 x m m+1

yn+1

yn

yn-1

∆y

m,nu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Summary of nodal finite-difference relations for various configurations:

Case 1: Interior Node

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Case 2: Node at an Internal Corner with Convection

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Case 3: Node at Plane Surface with Convection

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Case 4: Node at an External Corner with Convection

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Case 5: Node at Plane Surface with Uniform Heat Flux

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Solving Finite Difference Equations

Heat Transfer Solved Problem

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on The Matrix Inversion

Method

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Jacobi Iteration Method

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Gauss-Seidel Iteration

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Error Definitions Use absolute value. Computations are repeated until stopping

criterion is satisfied.

If the following Scarborough criterion is met

sa Pre-specified % tolerance

based on the knowledge of your solution

)%n)-(2s 10 (0.5

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Using Excel

=MINVERSE(A2:C4)

=MMULT(A7:C9,E2:E4)

Matrix Inversion Method

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Jacobi Iteration Method using Excel

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

43

Gauss-Seidel Iteration Method using Excel

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

A large industrial furnace is supported on a long column of fireclay brick, which is 1 m by 1 m on a side. During steady-state operation is such that three surfaces of the column are maintained at 500 K while the remaining surface is exposed to 300 K. Using a grid of ∆x=∆y=0.25 m, determine the two-dimensional temperature distribution in the column.

Ts=300 K

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

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

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

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

T11 T12 T13 T21 T22 T23 T31 T32 T33

-4 1 0 1 0 0 0 0 0 T11 -8001 -4 1 0 1 0 0 0 0 T12 -500

0 1 -4 0 0 1 0 0 0 T13

-1000

1 0 0 -4 1 0 1 0 0 T21 -3000 1 0 1 -4 1 0 1 0 T22 = 00 0 1 0 1 -4 0 0 1 T23 -5000 0 0 1 0 0 -4 1 0 T31 -8000 0 0 0 1 0 1 -4 1 T32 -500

0 0 0 0 0 1 0 1 -4 T33

-1000

System of Linear Equations

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Matrix Inversion Method

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Iteration Method using Excel

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

48

Jacobi Iteration Method using Excel

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

49

Error Iteration Method using Excel

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

50

Gauss-Seidel Iteration Method using Excel

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

51

Error Iteration Method using Excel

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

55

Iteration Method using Excel

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

58

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on Example 17.5

59

Fit the data with multiple linear regression

x1 x2 y0 0 5

2 1 10

2.5 2 9

7 3 0

4 6 3

5 2 27

100

5.243

54

544814

4825.765.16

145.166

2

1

0

a

a

a

3,4,5 210 aaa

21 345 xxy

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on Regression in Matlab and Excel

60

Use the polyfit function

Regression in Excel

Use Add Trendline

Regression in Matlab

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Homework7 www.bc.inter.edu/facultad/omeza

Omar E. Meza Castillo Ph.D.

61

top related