Document 7647617
Download
Report
Transcript Document 7647617
Runge 2nd Order Method
Industrial Engineering Majors
Authors: Autar Kaw, Charlie Barker
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
5/25/2016
http://numericalmethods.eng.usf.edu
1
Runge-Kutta 2nd Order Method
http://numericalmethods.eng.usf.edu
Runge-Kutta 2nd Order Method
For
dy
f ( x, y ), y (0) y0
dx
Runge Kutta 2nd order method is given by
yi 1 yi a1k1 a2 k2 h
where
k1 f xi , yi
k2 f xi p1h, yi q11k1h
3
http://numericalmethods.eng.usf.edu
Heun’s Method
Heun’s method
Slope f xi h, yi k1h
y
Here a2=1/2 is chosen
1
a1
2
p1 1
Slope f xi , yi
q11 1
resulting in
1
1
yi 1 yi k1 k2 h
2
2
where
k1 f xi , yi
yi+1, predicted
Average Slope
yi
xi
1
f xi h, yi k1h f xi , yi
2
xi+1
x
Figure 1 Runge-Kutta 2nd order method (Heun’s method)
k 2 f xi h, yi k1h
4
http://numericalmethods.eng.usf.edu
Midpoint Method
Here a2 1 is chosen, giving
a1 0
p1
1
2
q11
1
2
resulting in
yi 1 yi k2h
where
k1 f xi , yi
1
1
k 2 f xi h, yi k1h
2
2
5
http://numericalmethods.eng.usf.edu
Ralston’s Method
Here a 2 2 is chosen, giving
3
1
3
3
p1
4
3
q11
4
resulting in
a1
2
1
yi 1 yi k1 k 2 h
3
3
where
k1 f xi , yi
3
3
k 2 f xi h, yi k1h
4
4
6
http://numericalmethods.eng.usf.edu
How to write Ordinary Differential
Equation
How does one write a first order differential equation in the form of
dy
f x, y
dx
Example
dy
2 y 1.3e x , y 0 5
dx
is rewritten as
dy
1.3e x 2 y, y 0 5
dx
In this case
f x, y 1.3e x 2 y
7
http://numericalmethods.eng.usf.edu
Example
The open loop response, that is, the speed of the motor to a
voltage input of 20 V, assuming a system without damping is
20 0.02
dw
0.06w
dt
If the initial speed is zero; use the Runge-Kutta 2nd order
method and a step size of h 0.4 s to find the speed at t 0.8 s.
dw
1000 3w
dt
f t , w 1000 3w
1
1
wi 1 wi k1 k 2 h
2
2
8
http://numericalmethods.eng.usf.edu
Solution
Step 1: i 0, t0 0, w0 0
k1 f t0 , wo f 0, 0 1000 30 1000
k2 f t0 h, w0 k1h f 0 0.4, 0 10000.4 f 0.4, 400 1000 3400 200
1
1
w1 w0 k1 k 2 h
2
2
1
1
0 1000 200 0.4
2
2
0 500 100 0.4
160 rad/s
9
http://numericalmethods.eng.usf.edu
Solution Cont
Step 2:
i 1, t1 t0 h 0 0.4 0.4, w1 160
k1 f t1 , w1 f 0.4, 160 1000 3160 520
k 2 f t1 h, w1 k1h f 0.4 0.4, 160 5200.4
f 0.8, 368 1000 3368 104
1
1
w2 w1 k1 k 2 h
2
2
1
1
160 520 104 0.4
2
2
160 2080.4
243.2 rad/s
10
http://numericalmethods.eng.usf.edu
Solution Cont
The exact solution of the ordinary differential equation is
given by
1000 1000 3t
wt
e
3 3
The solution to this nonlinear equation at t=3 minutes is
w0.8 303.09 rad/s
11
http://numericalmethods.eng.usf.edu
Comparison with exact results
Figure 2. Heun’s method results for different step sizes
12
http://numericalmethods.eng.usf.edu
Effect of step size
Table 1 Effect of step size for Heun’s method
Step size, h
0.8
0.4
0.2
0.1
0.05
x3
−160.00
243.20
295.61
301.70
302.79
|t | %
Et
463.09
59.894
7.4823
1.3929
0.30613
152.79
19.761
2.4687
0.45954
0.10100
w0.8 303.09 rad/s (exact)
13
http://numericalmethods.eng.usf.edu
Effects of step size on Heun’s
Method
Figure 3. Effect of step size in Heun’s method
14
http://numericalmethods.eng.usf.edu
Comparison of Euler and RungeKutta 2nd Order Methods
Table 2. Comparison of Euler and the Runge-Kutta methods
Step size,
h
0.8
0.4
0.2
0.1
0.05
15
w0.8
Euler
Heun
Midpoint
Ralston
800
320
324.8
314.11
308.58
−160.00
243.20
295.61
301.70
302.79
−160.00
243.20
295.61
301.70
302.79
−160.00
243.20
295.61
301.70
302.79
w0.8 303.09 rad/s
(exact)
http://numericalmethods.eng.usf.edu
Comparison of Euler and RungeKutta 2nd Order Methods
Table 2 Comparison of Euler and the Runge-Kutta methods
Step size,
h
0.8
0.4
0.2
0.1
0.05
t %
Euler
Heun
Midpoint
Ralston
163.94
5.5792
7.1629
3.6359
1.8113
152.79
19.760
2.4679
0.45861
0.098981
152.79
19.760
2.4679
0.45861
0.098981
152.79
19.760
2.4679
0.45861
0.098981
w0.8 303.09 rad/s
16
(exact)
http://numericalmethods.eng.usf.edu
Comparison of Euler and RungeKutta 2nd Order Methods
Figure 4. Comparison of Euler and Runge Kutta 2nd order
methods with exact results.
17
http://numericalmethods.eng.usf.edu
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
visit
http://numericalmethods.eng.usf.edu/topics/runge_kutt
a_2nd_method.html
THE END
http://numericalmethods.eng.usf.edu