0% found this document useful (0 votes)
192 views27 pages

GEG 402 Slides of Runge Kutta Method-1

This document discusses numerical methods for solving ordinary differential equations (ODEs), specifically Euler's method and Runge-Kutta methods. It introduces the 4th order Runge-Kutta method for solving ODEs of the form dy/dx = f(x,y) and provides an example of using it to find the temperature of a cooling ball over time. The method is shown to provide more accurate results than Euler's method, and its accuracy improves with smaller step sizes.

Uploaded by

Dj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
192 views27 pages

GEG 402 Slides of Runge Kutta Method-1

This document discusses numerical methods for solving ordinary differential equations (ODEs), specifically Euler's method and Runge-Kutta methods. It introduces the 4th order Runge-Kutta method for solving ODEs of the form dy/dx = f(x,y) and provides an example of using it to find the temperature of a cooling ball over time. The method is shown to provide more accurate results than Euler's method, and its accuracy improves with smaller step sizes.

Uploaded by

Dj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

GEG 402

Numerical Methods in
Engineering
Numerical analysis of
ordinary differential
equations
Euler’s method
Improvements of Euler’s method
• A fundamental source of error in Euler’s
method is that the derivative at the beginning
of the interval is assumed to apply across the
entire interval.
Numerical Solution Of
Ordinary Differential Equations
- Runge-Kutta Methods
Runge-Kutta 4 th Order Method
For dy
 f ( x, y ), y (0)  y0
dx
Runge Kutta 4th order method is given by
yi 1  yi  k1  2k2  2k3  k4 h
1
6
where
k1  f xi , yi 
 1 1 
k2  f  xi  h, yi  k1h 
 2 2 
 1 1 
k3  f  xi  h, yi  k2 h 
 2 2 

k4  f xi  h, yi  k3h
17
How to write Ordinary Differential
Equation
How does one write a first order differential equation in the form of

 f  x, y 
dy
dx
Example

 2 y  1.3e  x , y0  5
dy
dx
is rewritten as

 1.3e  x  2 y, y0  5
dy
dx
In this case

f  x, y   1.3e  x  2 y 18
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
d
dt
 
 2.20671012  4  81 108 , 0  1200K

Find the temperature at t  480 seconds using Runge-Kutta 4th order method.

Assume a step size of h  240 seconds.


d
dt

 2.2067 1012  4  81 108 

f t,   2.20671012 4  81108 
 i 1   i 
1
k1  2k 2  2k3  k 4 h 19
6
Solution
Step 1: i  0, t0  0, 0   (0)  1200

 
k1  f t0 ,o   f 0,1200  2.20671012 12004  81108  4.5579

   
k2  f  t0  h, 0  k1h   f  0  240,1200   4.5579240
1 1 1 1
 2 2   2 2 
 
 f 120,653.05  2.20671012 653.054  81108  0.38347
   
k3  f  t0  h, 0  k2 h   f  0  240,1200   0.38347240
1 1 1 1
 2 2   2 2 
 
 f 120,1154.0  2.20671012 1154.0 4  81108  3.8954

k 4  f t0  h, 0  k3h   f 0  240,1200   3.984240



 f 240,265.10  2.20671012 265.104  81108  0.0069750 
20
Solution Cont
1   0 
1
k1  2k2  2k3  k4 h
6
 1200   4.5579  2 0.38347  2 3.8954  0.069750240
1
6
 1200   2.1848240
1
6
 675.65K

1 is the approximate temperature at

t  t1  t0  h  0  240  240

 240  1  675.65K
21
Solution Cont
Step 2: i  1, t1  240,1  675.65K

 
k1  f t1,1   f 240,675.65  2.20671012 675.654  81108  0.44199

   
k2  f  t1  h,1  k1h   f  240  240, 675.65   0.44199240
1 1 1 1
 2 2   2 2 
 
 f 360,622.61  2.20671012 622.614  81108  0.31372
   
k3  f  t1  h,1  k2 h   f  240  240,675.65   0.31372240
1 1 1 1
 2 2   2 2 
 
 f 360, 638.00  2.20671012 638.004  81108  0.34775

k 4  f t1  h, 1  k3h   f 240  240,675.65   0.34775240


 
 f 480,592.19  2.20671012 592.194  81108  0.25351
22
Solution Cont
1
 2  1  k1  2k2  2k3  k4 h
6
 675.65   0.44199  2 0.31372  2 0.34775   0.25351240
1
6
 675.65   2.0184240
1
6
 594.91K
2 is the approximate temperature at

t2  t1  h  240  240  480

 480   2  594.91K

23
Solution Cont

The exact solution of the ordinary differential equation is given by the


solution of a non-linear equation as
  300
0.92593ln  1.8519 tan 1 0.00333  0.22067 103 t  2.9282
  300

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

 (480)  647.57K

24
Comparison with exact results
1600
Temperature, θ(K)

1200

h=120
800 Exact
h=240
400

h=480
0
0 200 400 600
-400
Time,t(sec)

Figure 1. Comparison of Runge-Kutta 4th order method with exact solution


25
Effects of step size on Runge-Kutta
4th Order Method
800
Temperature, θ(480)

600

400

200

0
0 100 200 300 400 500
-200
Step size, h

Figure 2. Effect of step size in Runge-Kutta 4th order method


26
Comparison of Euler and Runge-
Kutta Methods
1400
Temperature, θ(K)

1200
4th order
1000

800
Exact
600
Heun
400

200 Euler

0
0 100 200 300 400 500
Time, t(sec)

Figure 3. Comparison of Runge-Kutta methods of 1st, 2nd, and 4th order.


27

You might also like