Top Banner
Adaptive Runge-Kutta • addresses the problem of functions that change rapidly at a point 0 1 2 3 4 5 6 0 5 10 15 20 25 30
24

Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Adaptive Runge-Kutta

• addresses the problem of functions that change rapidly at a point

0

1

2

3

4

5

6

0 5 10 15 20 25 30

Page 2: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Would like to use small size steps in the area of rapid change - normal size steps in area of normal change

Two approaches behind adaptive step size

• look at difference between predictions with different step sizes but same order RK

• look at difference between predictions with different order RK

Page 3: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Step-halving or adpartive Runge-Kutta

let y1 be single-step prediction

let y2 be prediction using two half steps

12 yy

The correction is

1522

yy

fifth order accurate

Page 4: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Example:

00

05.0exp8.32exp97,

y

xxyyxfdx

dy

-1

0

1

2

3

4

5

6

7

0 2 4 6 8 10 12

dy/dx

Page 5: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Integrate y’ from x=0 to 2 using h=2, and improve using adaptive RK

Complete step results areh 2x RK k1 k2 k3 k40 0 5.8 0.60176 0.6018 -0.11112 2.69863 -0.1111 -0.2175 -0.2175 -0.2423

Half step results areh 1x RK k1 k2 k3 k40 0 5.8 2.00221 2.0022 0.60181 2.40177 0.60176 0.08315 0.0831 -0.11112 2.53897 -0.1111 -0.1862 -0.1862 -0.2175

Page 6: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

The correction is

01064.015

69863.253897.215

22 step onesteps two

yyEa

The corrected value is 528324.201064.0538969.2

Compare to true value y(2)=2.524369

%2.0

%6.0

%9.6

1

2

acorr

a

a

E

E

E

Page 7: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Runge-Kutta-Fehlberg

Uses two different RK predictions of different order

Special choice of methods lets you use results from 4th order in 5th order RK - then combine them

Page 8: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Fourth order RK

hkkkkyy ii

64311 1771

512

594

125

621

250

378

37

Fifth order RK

hkkkkkyy ii

654311 4

1

14336

277

55296

13525

48384

18575

27648

2825

Page 9: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Formula for k’s

hkhkhkhkhkyhxfk

hkhkhkhkyhxfk

hkhkhkyhxfk

hkhkyhxfk

hkyhxfk

yxfk

ii

ii

ii

ii

ii

ii

543216

43215

3214

213

12

1

4096

253

110592

44275

13824

575

512

175

55296

1631,

8

7

27

35

27

70

2

5

54

11,

5

6

10

9

10

3,

5

3

40

9

40

3,

10

3

5

1,

5

1

,

Page 10: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

00

05.0exp8.32exp97,

y

xxyyxfdx

dy

Example

Use h=2, and the RKF method

Page 11: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

The results are

RK4=2.542811

RK5=2.554121

and Ea=RK5-RK4=2.554121-2.542811=0.01131

Now adjust stepsize

Page 12: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

If Ea is too small, increase step size

If Ea is too large, decrease step size

presentoldnew

dx

dyhy

hh

Page 13: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Stiffness

stiff equation involves rapidly changing parts and slowly changing parts

xeydx

dy 399820008000

xx eey 24 2000

Solution is

Page 14: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

0

0.5

1

1.5

2

2.5

3

3.5

4

0 0.5 1 1.5 2 2.5

0

0.5

1

1.5

2

2.5

3

-0.001 0.001 0.003 0.005 0.007 0.009 0.011 0.013 0.015

Page 15: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Look at homogeneous part of equation

ydx

dy2000

aydx

dy

In general

Explicit Euler’s method

hayyhdx

dyyy ii

iii 1

Page 16: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

ahy

hayyy

i

iii

11

Look at what happens to y over long time - stability

If then y goes to infinity

So for explicit method to work - small h

11 ah

11 ah

Page 17: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Need to use implicit methods, rather than explicit

Implicit form of the Euler method

hayy

hdt

dyyy

ii

iii

1

11

Can solve to getah

yy ii

11

Page 18: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Implicit Euler is always stable -

as i increases y goes to 0

ah

yy ii

11

Page 19: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Example: xeydx

dy 399820008000

Explict solution:

since a is 2000, let h=0.0001

0

0.5

1

1.5

2

2.5

0 0.01 0.02 0.03 0.04 0.05 0.06

y

yExplicit

heyyyhdx

dyyy ix

iiii

ii *39982000800011

Page 20: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Stability limit is h=0.0005

Try h=0.0007

0

0.5

1

1.5

2

2.5

3

3.5

0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02

y

yExplicit

Page 21: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Try h=0.001

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

0 0.005 0.01 0.015 0.02

y

yExplicit

Page 22: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

h=0.002

-15

-10

-5

0

5

10

15

0 0.005 0.01 0.015 0.02 0.025

sig

n o

f y

* ln

ofa

bs(

y v

alu

e)

lny

lnyExplicit

Page 23: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

Implicit approach:

h

hehyy

heyy

ydx

dyyy

i

i

xi

i

xii

ii

ii

20001

39988000

*3998200080001

1

1

1

11

1

Page 24: Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.

h=0.002

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

0 0.005 0.01 0.015 0.02

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

0 0.5 1 1.5 2 2.5 3

y

yImplicit