Finite Difference Method 10EL20.ppt

34
Presentation Presentation of of Numerical Methods Numerical Methods

Transcript of Finite Difference Method 10EL20.ppt

Page 1: Finite Difference Method 10EL20.ppt

Presentation Presentation of of

Numerical MethodsNumerical Methods

Page 2: Finite Difference Method 10EL20.ppt

05/03/23 2

Presented To: Ma’am Ayesha Kanwal

Presented By: Muhammad Sarwar 10EL20

Page 3: Finite Difference Method 10EL20.ppt

Finite Difference Method

”Read Euler: he is our master in everything.”

Pierre-Simon Laplace (1749-1827)

3

Page 4: Finite Difference Method 10EL20.ppt

Introduction To Differential Eq. An equation that consists of derivatives is

called a differential equation. Differential equations have applications in all

areas of science and engineering. Mathematical formulation of most of the

physical and engineering problems leads to differential equations.

So, it is important for engineers and scientists to know how to set up differential equations

4

Page 5: Finite Difference Method 10EL20.ppt

Types of Diff. EqsDifferential equations are of two types

A. Ordinary differential equations (ODE) B. Partial differential equations (PDE)

An ordinary differential equation is that in which all the derivatives are with respect to a single independent variable.

Examples of Ordinary Differential Equations.

5

Page 6: Finite Difference Method 10EL20.ppt

ODEs with Initial Value Conditions

These are the types of problems we have been solving with RK methods.

All conditions are specified at the same value of the independent variable!

6

Page 7: Finite Difference Method 10EL20.ppt

ODEs with Boundary Value Conditions

In the field of differential equations, a boundary value problem is a differential equation together with a set of additional constraints, called the boundary conditions.

A solution to a boundary value problem is a solution to the differential equation which also satisfies the boundary conditions.

7

ayay )( and byby )(

Page 8: Finite Difference Method 10EL20.ppt

Types of Boundary ConditionsThree types of spatial boundary conditions:

Dirichlet Condition

Neumann Condition

Mixed Boundary Condition

No. of Boundary conditions required is order of highest derivative appearing in each independent variable

Here We’ll discuss BVPs with Dirichlet Conditions only… Note that boundary value problems as position-dependent

and initial value problems as time-dependent in most cases.

8

Page 9: Finite Difference Method 10EL20.ppt

What are Finite Differences?A finite difference is a mathematical

expression of the form f(x + b) − f(x + a). If a finite difference is divided by b − a, one gets a difference quotient. T

he approximation of derivatives by finite differences plays a central role in finite difference methods for the numerical solution of differential equations, especially boundary value problems.

9

Page 10: Finite Difference Method 10EL20.ppt

Finite Differences…To find derivative (Slope) of function y=f(x) at

Xn, take a small increment in value of f(x) at Xn and then divide that

increment by the difference of values of function at both points..

10

Page 11: Finite Difference Method 10EL20.ppt

Types of Finite Differences

Three forms are commonly considered: forward, backward, and central differences.

A forward difference is an expression of the form

A backward difference uses the function values at x and x − h, instead of the values at x + h and x:

Finally, the central difference is given by11

Page 12: Finite Difference Method 10EL20.ppt

Geometrical Interpretation of Finite

Differences

12

Page 13: Finite Difference Method 10EL20.ppt

Derivative in terms of FDs

13

First Order derivate with First order Accuracy

First Order Derivate with 2nd order accuracy

2nd order derivative expressed as finite difference

xyy

dxdy ii

1

211

2

2 2x

yyydxyd iii

xyy

dxdy ii

211

Page 14: Finite Difference Method 10EL20.ppt

Errors in Finite DifferencesThe two sources of error in finite difference

methods are round-off error, the loss of precision due to computer rounding of decimal quantities, and truncation error or discretization error, the difference between the exact solution of the finite difference equation and the exact quantity assuming perfect arithmetic (that is, assuming no round-off).

14

Page 15: Finite Difference Method 10EL20.ppt

AccuracyThe accuracy of the finite difference

approximations is given by:forward difference: truncation error: 

backwards difference: truncation error: 

central difference: truncation error: 

15

xO

xO

2xO

Page 16: Finite Difference Method 10EL20.ppt

Solving an ODE using FDsFor example, consider the ordinary

differential equation

For solving this equation we use the finite difference quotient

to approximate the differential equation by first substituting in for u'(x) and applying a little algebra to get

16

Page 17: Finite Difference Method 10EL20.ppt

Finite Difference Method for Boundary

Value ODEs

17

The finite difference method is used to solve ordinary differential equations that have conditions imposed on the boundary rather than at the initial point. These problems are called boundary-value problems. In this chapter, we solve second-order ordinary differential equations of the form

with boundary conditions ayay )( and byby )(

Page 18: Finite Difference Method 10EL20.ppt

FD Method

18

General graphical interpretation of FD method

Substitute finite difference equations for derivatives in the original ODE.This will give us a set of simultaneous algebraic equations that are solved a nodes.

Page 19: Finite Difference Method 10EL20.ppt

FD Method

19

Proof

Page 20: Finite Difference Method 10EL20.ppt

FD Method--Basic Procedure

20

Replace derivatives of governing equations with algebraic difference quotients

Results in a system of algebraic equations solvable for dependent variables at discrete grid points

Analytical solutions provide closed-form expressions –variation of dependent variables in the domain

Numerical solutions (finite difference) - values at discrete points in the domain

Page 21: Finite Difference Method 10EL20.ppt

21

ExampleFor a Circuit containing two storing elements (either both capacitor or both inductors or one capacitor and one inductor), the mathematical model for the circuit takes the form of a second order equation. The boundary values for the given equation are known by measuring voltage across the output terminals.

0122

2

ru

drdurdr

ud

The equation can be modeled using finite differences for derivatives

211

2

2 2r

uuudrud iii

ruu

drdu ii

1

Substituting these approximations gives you,

012

21

211

i

iii

i

iii

ru

ruu

rruuu

0111211122212

ii

iii

i

ur

urrrr

urrr

Page 22: Finite Difference Method 10EL20.ppt

22

SolutionStep 1 At node "5,0 0 ari "0038731.00 u

Step 2 At node "6.56.05,1 01 rrri

06.06.5

16.01

6.51

6.06.51

6.02

6.01

2212202

uuu

00754.38851.57778.2 210 uuu

Step 3 At node ,2i "2.66.06.512 rrr

06.02.6

16.01

2.61

6.02.61

6.02

6.01

3222212

uuu

00466.38504.57778.2 321 uuu

Page 23: Finite Difference Method 10EL20.ppt

23

Solution ContStep 4 At node ,3i "8.66.02.623 rrr

06.08.6

16.01

8.61

6.08.61

6.02

6.01

4232222

uuu

00229.38223.57778.2 432 uuu

Step 5 At node

Step 6 At node

,4i "4.76.08.634 rrr

06.04.7

16.01

4.71

6.04.71

6.02

6.01

5242232

uuu

00030.37990.57778.2 543 uuu

,5i 86.04.745 rrr

"0030769.0|5 bruu

Page 24: Finite Difference Method 10EL20.ppt

24

Solving system of equations

0030769.00000

0038731.0

1000000030.37990.57778.200000229.38223.57778.200000466.38504.57778.200000754.38851.57778.2000001

5

4

3

2

1

0

uuuuuu

0038731.00 u

0036165.01 u

0034222.02 u

0032743.03 u

0031618.04 u

0030769.05 u

Page 25: Finite Difference Method 10EL20.ppt

25

Solution Cont

ruu

drdu

ar

01

6.00038731.00036165.0 00042767.0

2130700042767.03.05

0038731.03.01

10302

6

max

2130720538 tE 59.768

%744.310020538

2130720538

t

Solving the Diff. Eq. Analytically gives the True Value=20538

Page 26: Finite Difference Method 10EL20.ppt

26

Need more accurate answers???

211

2

2 2x

yyydxyd iii

Using the approximation of

xyy

dxdy ii

211and

02

122

112

11

i

iii

i

iii

ru

ruu

rruuu

0

211121

21

122212

i

ii

ii

i

urrr

urr

urrr

Gives you

Page 27: Finite Difference Method 10EL20.ppt

27

Solution Cont5,0 0 ariStep 1 At node

0038731.00 u

Step 2 At node

Step 3 At node

"6.56.05,1 01 rrri

06.06.52

16.01

6.51

6.02

6.01

6.06.521

2212202

uuu

09266.25874.56297.2 210 uuu

,2i 2.66.06.512 rrr

06.02.62

16.01

2.61

6.02

6.01

6.02.621

3222212

uuu

09122.25816.56434.2 321 uuu

Page 28: Finite Difference Method 10EL20.ppt

28

Solution ContStep 4 At node ,3i 8.66.02.623 rrr

06.08.62

16.01

8.61

6.02

6.01

6.08.621

4232222

uuu

09003.25772.56552.2 432 uuu

Step 5 At node

Step 6 At node

,4i 4.76.08.634 rrr

06.04.72

16.01

4.71

6.02

6.01

6.04.721

5242232

uuu

08903.25738.56651.2 543 uuu

,5i "86.04.745 rrr

"0030769.0|5 bruu

Page 29: Finite Difference Method 10EL20.ppt

29

Solving system of equations

0030769.00000

0038731.0

1000008903.25738.56651.200009003.25772.56552.200009122.25816.56434.200009266.25874.56297.2000001

5

4

3

2

1

0

uuuuuu

0038731.00 u

0036115.01 u

0034159.02 u

0032689.03 u

0031586.04 u

0030769.05 u

Page 30: Finite Difference Method 10EL20.ppt

30

Solution Cont 0004925.0

)6.0(20034159.00036115.040038731.03

243 200

ruuu

drdu

ar

206660004925.03.05

0038731.03.01

10302

6

max

1282066620538 tE

%62323.010020538

2066620538

t

Page 31: Finite Difference Method 10EL20.ppt

31

The Finite Difference TableTable 1 Comparisons of answers from two methods

r uexact u1st order |єt| u2nd order |єt|

5 0.0038731 0.0038731 0.0000 0.0038731 0.0000

5.6 0.0036110 0.0036165 1.5160×10−1 0.0036115 1.4540×10−2

6.2 0.0034152 0.0034222 2.0260×10−1 0.0034159 1.8765×10−2

6.8 0.0032683 0.0032743 1.8157×10−1 0.0032689 1.6334×10−2

7.4 0.0031583 0.0031618 1.0903×10−1 0.0031586 9.5665×10−3

8 0.0030769 0.0030769 0.0000 0.0030769 0.0000

Page 32: Finite Difference Method 10EL20.ppt

Solution of given BVP using MATLAB

32

Page 33: Finite Difference Method 10EL20.ppt

Applying BVPs in Real LifeThere are uncountable applications of

differential equations in Real life…In electrical engineering, the behavior of a

RLC circuit is studied using differential equations.

Finding size of capacitor in designing a power supply.

Finding the time instant at which voltage across a capacitor becomes zero.

33

Page 34: Finite Difference Method 10EL20.ppt

Thank You!

Any Questions?

34