runge 2 nd order method - iiser punepgoel/rungekutta.pdfrunge 2 nd order method major: all...

23
Runge 2 nd Order Method Major: All Engineering Majors 4/13/2010 http://numericalmethods.eng.usf.edu 1 Major: All Engineering Majors Authors: Autar Kaw, Charlie Barker http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates

Upload: trantram

Post on 16-Mar-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Runge 2nd Order Method

Major: All Engineering Majors

4/13/2010 http://numericalmethods.eng.usf.edu 1

Major: All Engineering Majors

Authors: Autar Kaw, Charlie Barker

http://numericalmethods.eng.usf.eduTransforming Numerical Methods Education for STEM

Undergraduates

Page 2: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Runge-Kutta 2nd Order Method

http://numericalmethods.eng.usf.edu

Page 3: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Heun’s Method

y

yi+1, predicted

( )hkyhxfSlope ii 1, ++=

( )ii yxfSlope ,=

Heun’s method

2

11 =a

1=p

Here a2=1/2 is chosen

http://numericalmethods.eng.usf.edu3

xxi xi+1

yi

Figure 1 Runge-Kutta 2nd order method (Heun’s method)

( ) ( )[ ]iiii yxfhkyhxfSlopeAverage ,,2

1 1 +++=

11 =p

111 =q

resulting in

hkkyy ii

++=+ 211

2

1

2

1

where

( )ii yxfk ,1 =

( )hkyhxfk ii 12 , ++=

Page 4: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Runge-Kutta 2nd Order Method

Runge Kutta 2nd order method is given by

For0)0(),,( yyyxf

dx

dy==

http://numericalmethods.eng.usf.edu4

Runge Kutta 2nd order method is given by

( )hkakayy ii 22111 ++=+

where

( )ii yxfk ,1 =

( )hkqyhpxfk ii 11112 , ++=

Page 5: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Midpoint MethodHere 12 =a is chosen, giving

01 =a

2

11 =p

http://numericalmethods.eng.usf.edu5

2

111 =q

resulting in

hkyy ii 21 +=+

where

( )ii yxfk ,1 =

++= hkyhxfk ii 12

2

1,

2

1

Page 6: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Ralston’s MethodHere

3

22 =a is chosen, giving

3

11 =a

4

31 =p

http://numericalmethods.eng.usf.edu6

4

4

311 =q

resulting in

hkkyy ii

++=+ 211

3

2

3

1

where

( )ii yxfk ,1 =

++= hkyhxfk ii 12

4

3,

4

3

Page 7: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

How to write Ordinary Differential Equation

How does one write a first order differential equation in the form of

( )yxfdx

dy,=

http://numericalmethods.eng.usf.edu7

Example

( ) 50,3.12 ==+− yey

dx

dy x

is rewritten as

( ) 50,23.1 =−=− yye

dx

dy x

In this case

( ) yeyxfx 23.1, −=

Page 8: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Example

A ball at 1200K is allowed to cool down in air at an ambient temperature

of 300K. Assuming heat is lost only due to radiation, the differential

equation for the temperature of the ball is given by

( ) ( ) Kd

12000,1081102067.2 8412=θ×−θ×−=

θ −

http://numericalmethods.eng.usf.edu8

( ) ( ) Kdt

12000,1081102067.2 =θ×−θ×−=

Find the temperature at 480=t seconds using Heun’s method. Assume a step size of

240=h seconds.

( )8412 1081102067.2 ×−θ×−=θ −

dt

d

( ) ( )8412 1081102067.2, ×−θ×−=θ−

tf

hkkii

++=+ 211

2

1

2

1θθ

Page 9: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

SolutionStep 1: Kti 1200)0(,0,0 00 ==== θθ

( )

( )

( )10811200102067.2

1200,0

,

8412

01

×−×−=

=

=

f

tfk oθ ( )

( )( )

( )09.106,240

2405579.41200,2400

, 1002

=

−++=

++=

f

f

hkhtfk θ

http://numericalmethods.eng.usf.edu9

( )5579.4

10811200102067.2 8412

−=

×−×−=− ( )

( )017595.0

108109.106102067.2

09.106,240

8412

=

×−×−=

=

f

( ) ( )

( )

K

hkk

16.655

2402702.21200

240017595.02

15579.4

2

11200

2

1

2

12101

=

−+=

+−+=

++= θθ

Page 10: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Solution Cont

Step 2: Khtti 16.655,2402400,1 101 ==+=+== θ

( )

( )

( )108116.655102067.2

16.655,240

,

8412

111

×−×−=

=

=

f

tfk θ ( )

( )( )

( )87.561,480

24038869.016.655,240240

, 1112

=

−++=

++=

f

f

hkhtfk θ

http://numericalmethods.eng.usf.edu10

( )38869.0

108116.655102067.2 8412

−=

×−×−=− ( )

( )20206.0

108187.561102067.2

87.561,480

8412

−=

×−×−=

=

f

( ) ( )

( )

K

hkk

27.584

24029538.016.655

24020206.02

138869.0

2

116.655

2

1

2

12112

=

−+=

−+−+=

++= θθ

Page 11: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Solution Cont

The exact solution of the ordinary differential equation is given by thesolution of a non-linear equation as

300−θ

http://numericalmethods.eng.usf.edu11

( ) 9282.21022067.00033333.0tan8519.1300

300ln92593.0 31

−×−=−+

− −− tθθ

θ

The solution to this nonlinear equation at t=480 seconds is

K57.647)480( =θ

Page 12: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Comparison with exact results

800

1200

Tem

pera

ture

,θ(K

)

Exact h=120

http://numericalmethods.eng.usf.edu12

Figure 2. Heun’s method results for different step sizes

-400

0

400

0 100 200 300 400 500

Time, t(sec)

Tem

pera

ture

,

h=240

h=480

Page 13: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Effect of step size

Table 1. Temperature at 480 seconds as a function of step size, h

Step size, h θ(480) Et |єt|%

http://numericalmethods.eng.usf.edu13

480

240

120

60

30

−393.87

584.27

651.35

649.91

648.21

1041.4

63.304

−3.7762

−2.3406

−0.63219

160.82

9.7756

0.58313

0.36145

0.097625

K57.647)480( =θ (exact)

Page 14: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Effects of step size on Heun’s Method

400

600

800T

em

pera

ture

,θ(4

80)

http://numericalmethods.eng.usf.edu14

Figure 3. Effect of step size in Heun’s method

-400

-200

0

200

0 100 200 300 400 500

Step size, h

Tem

pera

ture

,

Page 15: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Step size,

h

θ(480)

Euler Heun Midpoint Ralston

Comparison of Euler and Runge-Kutta 2nd Order Methods

Table 2. Comparison of Euler and the Runge-Kutta methods

Euler Heun Midpoint Ralston

480

240

120

60

30

−987.84

110.32

546.77

614.97

632.77

−393.87

584.27

651.35

649.91

648.21

1208.4

976.87

690.20

654.85

649.02

449.78

690.01

667.71

652.25

648.61

http://numericalmethods.eng.usf.edu15

K57.647)480( =θ (exact)

Page 16: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Comparison of Euler and Runge-Kutta 2nd Order Methods

Table 2. Comparison of Euler and the Runge-Kutta methods

Step size, %t∈

http://numericalmethods.eng.usf.edu16

hEuler Heun Midpoint Ralston

480

240

120

60

30

252.54

82.964

15.566

5.0352

2.2864

160.82

9.7756

0.58313

0.36145

0.097625

86.612

50.851

6.5823

1.1239

0.22353

30.544

6.5537

3.1092

0.72299

0.15940

K57.647)480( =θ (exact)

Page 17: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Comparison of Euler and Runge-Kutta 2nd Order Methods

900

1000

1100

1200Tem

pera

ture

, Ralston

Midpoint

θ(K

)

http://numericalmethods.eng.usf.edu17

Figure 4. Comparison of Euler and Runge Kutta 2nd order methods with exact results.

500

600

700

800

900

0 100 200 300 400 500 600

Time, t (sec)

Tem

pera

ture

,

Analytical

Ralston

Euler

Heun

Page 18: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

http://numericalmethods.eng.usf.edu18

Page 19: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

http://numericalmethods.eng.usf.edu 19

Page 20: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

http://numericalmethods.eng.usf.edu20

Page 21: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

http://numericalmethods.eng.usf.edu21

Page 22: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

Additional Resources

For all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please and MAPLE, blogs, related physical problems, please visit

http://numericalmethods.eng.usf.edu/topics/runge_kutta_2nd_method.html

Page 23: Runge 2 nd Order Method - IISER Punepgoel/RungeKutta.pdfRunge 2 nd Order Method Major: All Engineering Majors 4/13/2010 1 Authors: Autar Kaw, Charlie Barker Transforming Numerical

THE ENDTHE END

http://numericalmethods.eng.usf.edu