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

61
MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo [email protected] http://www.bc.inter.edu/facultad/omeza Department of Mechanical Engineering Inter American University of Puerto Rico Bayamon Campus

Upload: daisy-james

Post on 13-Dec-2015

232 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

MEC

N 3

500 I

nte

r -

Bayam

on

Lecture

9Numerical Methods for Engineering

MECN 3500

Professor: Dr. Omar E. Meza [email protected]

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

Bayamon Campus

Page 2: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 3: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Best known numerical method of approximation

Finite Difference

Page 4: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 5: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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.

Page 6: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 7: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 8: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 9: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 10: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 11: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Forward Formulas

Page 12: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Backward Formulas

Page 13: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Centered Formulas

Page 14: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 15: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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:

Page 16: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 17: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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)

Page 18: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 19: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 20: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 21: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 22: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Summary of nodal finite-difference relations for various configurations:

Case 1: Interior Node

Page 23: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Case 2: Node at an Internal Corner with Convection

Page 24: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Case 3: Node at Plane Surface with Convection

Page 25: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Case 4: Node at an External Corner with Convection

Page 26: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Case 5: Node at Plane Surface with Uniform Heat Flux

Page 27: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Solving Finite Difference Equations

Heat Transfer Solved Problem

Page 28: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on The Matrix Inversion

Method

Page 29: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 30: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 31: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Jacobi Iteration Method

Page 32: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 33: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 34: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 35: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 36: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 37: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Gauss-Seidel Iteration

Page 38: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 39: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 40: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 41: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Using Excel

=MINVERSE(A2:C4)

=MMULT(A7:C9,E2:E4)

Matrix Inversion Method

Page 42: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Jacobi Iteration Method using Excel

Page 43: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

43

Gauss-Seidel Iteration Method using Excel

Page 44: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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)

Page 45: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 46: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Matrix Inversion Method

Page 47: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Iteration Method using Excel

Page 48: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

48

Jacobi Iteration Method using Excel

Page 49: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

49

Error Iteration Method using Excel

Page 50: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

50

Gauss-Seidel Iteration Method using Excel

Page 51: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

51

Error Iteration Method using Excel

Page 52: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 53: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 54: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 55: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

55

Iteration Method using Excel

Page 56: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 57: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

Page 58: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

58

Page 59: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 60: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

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

Page 61: MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu

Lecture 9MEC

N 3

500 I

nte

r -

Bayam

on

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

Omar E. Meza Castillo Ph.D.

61