ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling,...

16
ES 240: Scientific and Engineering Computation. Cha Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple University

Transcript of ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling,...

Page 1: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Chapter 1: Mathematical Modeling, Numerical

Methods and Problem Solving

Uchechukwu Ofoegbu

Temple University

Page 2: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Model FunctionModel Function

• Dependent variable - a characteristic that usually reflects the behavior or state of the system

• Independent variables - dimensions, such as time and space, along which the system’s behavior is being determined

• Parameters - constants reflective of the system’s properties or composition

• Forcing functions - external influences acting upon the system

Dependentvariable f

independentvariables , parameters,

forcingfunctions

Page 3: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Model Function ExampleModel Function Example

• Assuming a bungee jumper is in mid-flight, an analytical model for the jumper’s velocity, accounting for drag, is

• Dependent variable - velocity v• Independent variables - time t

• Parameters - mass m, drag coefficient cd

• Forcing function - gravitational acceleration g

v t gm

cd

tanhgcd

mt

Page 4: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Model ExampleModel Example

• Let the mass of the jumper be 68.1 kg, and assuming a drag coefficient of 0.25 kg/m.

• We know that g = 9.81• Therefore:

• We can now easily compute the jumper’s velocity at different time periods

)18977.0tanh(6938.511.68

)25.0(81.9tanh

25.0

)1.68(81.9)( tttv

Page 5: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Model ExampleModel Example

Let’s fill in the table below by computing the velocity Let’s fill in the table below by computing the velocity analytically analytically

Time (s) Velocity (m/s)

0 0

2 18.7291

4 33.1117

6 42.0761

8 46.9574

10 49.4213

12 50.6175

∞ 51.6938

Page 6: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Model ResultsModel Results

• We can use a computer program to represent the model graphically:

• Let’s generate the graph below using Matlab

Page 7: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Numerical ModelingNumerical Modeling

• Models can be represented by– Functions– differential equations - these can be solved either using analytical

methods or numerical methods.

• Example:– the bungee jumper velocity equation from before is the analytical

solution to the differential equation

dv

dtg

cd

mv2 Net Force = Downward - UpwardNet Force = Downward - Upward

Page 8: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Numerical MethodsNumerical Methods

• To solve the problem using a numerical method, note that the time rate of change of velocity can be approximated as:

• Therefore:

• This can be summarized as:

;)()()( 2

1

1i

d

ii

ii tvm

cg

tt

tvtv

dv

dt

v

t

v ti1 v ti ti1 ti

Finite Difference MethodFinite Difference Method

)()()()( 12

1 iiid

ii tttvm

cgtvtv

dvdvii/dt/dt ∆∆tt

New Value = Old Value + Slope * Step SizeNew Value = Old Value + Slope * Step Size

Euler’sEuler’sMethodMethod

Page 9: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Numerical SolutionNumerical Solution

Let’s fill in the table below by computing the velocity Let’s fill in the table below by computing the velocity numerically numerically

Time (s) Velocity (m/s)

0 0

2 18.7291

4 33.1117

6 42.0761

8 46.9574

10 49.4213

12 50.6175

∞ 51.6938

Page 10: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Numerical ResultsNumerical Results

100_

analytical

numericalanalyticalErrorAbsolute

•Let’s generate the two graph below using Matlab

Page 11: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Group exerciseGroup exercise

• Compute the jumper’s velocity for 0-12 seconds using a step size of 1

• Tabulate your results, also include the absolute error for each case

• For t = 12, plot of absolute error versus step size

Page 12: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Solution – Step Size = 1 secondSolution – Step Size = 1 secondTime (s) Numerical Velocity

(m/s)Analytical

Velocity (m/s)

Absolute Error (%)

0 0 0 0

1 9.8100 9.6938 1.20

2 19.2667 18.7291 2.87

3 27.7140 26.6147 4.13

4 34.7044 33.1117 4.81

5 40.0930 38.2153 4.91

6 44.0019 42.0761 4.58

7 46.7041 44.9144 3.98

8 48.5065 46.9574 3.30

9 49.6789 48.4057 2.63

10 50.4287 49.4214 2.04

11 50.9030 50.1282 1.55

12 51.2008 50.6175 1.15

Page 13: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Absolute Error AnalysisAbsolute Error Analysis

Step Size Absolute Error (%)

0.5 0.61

1 1.15

2 1.91

Page 14: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Bases for Numerical ModelsBases for Numerical Models

• Conservation laws provide the foundation for many model functions.

Change = increase – decrease

Steady State: Change = 0;

• Different fields of engineering and science apply these laws to different paradigms within the field.

• Among these laws are:– Conservation of mass – chemical engineering– Conservation of momentum – civil and mechanical engr.– Conservation of charge – electrical engineering– Conservation of energy– electrical engineering

Page 15: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Summary of Numerical MethodsSummary of Numerical Methods

• The book is divided into five categories of numerical methods:

Page 16: ES 240: Scientific and Engineering Computation. Chapter 1 Chapter 1: Mathematical Modeling, Numerical Methods and Problem Solving Uchechukwu Ofoegbu Temple.

ES 240: Scientific and Engineering Computation. Chapter 1

Puzzle Puzzle

The longest repeated wordThe longest repeated wordWRITE A METHOD THAT TAKES A SIMPLE STRING AS WRITE A METHOD THAT TAKES A SIMPLE STRING AS

INPUT, AND OUTPUTS ITS LONGEST REPEATED INPUT, AND OUTPUTS ITS LONGEST REPEATED SUBSTRING. WHEN THERE ARE TWO OF EQUAL LENGTH, SUBSTRING. WHEN THERE ARE TWO OF EQUAL LENGTH,

OUTPUT WHICHEVER IS FIRST LEXICOGRAPHICALLY. OUTPUT WHICHEVER IS FIRST LEXICOGRAPHICALLY. EXAMPLESEXAMPLES

abba should return ’a’ abba should return ’a’ abracadabra should return ’abra’ abracadabra should return ’abra’

Mississippi should return ’iss’ Mississippi should return ’iss’