Transcript PPT
Runge 2nd Order Method Computer Engineering Majors Authors: Autar Kaw, Charlie Barker http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates 7/12/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 A rectifier-based power supply requires a capacitor to temporarily store power when the rectified waveform from the AC source drops below the target voltage. To properly size this capacitor a first-order ordinary differential equation must be solved. For a particular power supply, with a capacitor of 150 μF, the ordinary differential equation to be solved is 18 cos(120 (t )) 2 v(t ) dv(t ) 1 dt 150 10 6 0.1 max 0.04 ,0 Find voltage across the capacitor at t= 0.00004s. Use step size h=0.00002 18 cos(120 (t )) 2 v dv 1 dt 0.1 max 150 10 6 8 ,0 18 cos(120 (t )) 2 v 0 . 1 max , 0 0 . 04 1 1 v i k1 k 2 h 2 2 http://numericalmethods.eng.usf.edu f t , v vi 1 0.04 1 150 10 6 Solution Step 1: i 0, t0 0, v0 v(0) 0 k1 f t0 , vo f 0,0 1 150 10 6 18 cos(120 (0)) 2 (0) 2.6660 106 0 . 1 max , 0 0.04 k 2 f t0 h, v0 k1h f 0 0.00002,0 2.6660 106 0.00002 f 0.00002, 53.32 1 150 10 6 18 cos(120 (0.00002)) 2 (53.32) ,0 666.67 0.1 max 0.04 1 1 1 1 v1 v0 k1 k 2 h 0 2.6660 106 666.67 0.00002 2 2 2 2 0 1.3327 106 0.00002 26.653V 9 http://numericalmethods.eng.usf.edu Solution Cont Step 2: i 1, t1 t0 h 0 0.00002 0.00002 v1 26.653 V k1 f t1 , v1 f 0.00002, 26.653 1 150 10 6 18 cos(120 (0.00002)) 2 (26.653) ,0 666.67 0.1 max 0.04 k 2 f t1 h, v1 k1h f 0.00002 0.00002, 26.653 666.67 0.00002 f 0.00004, 26.640 1 150 10 6 18 cos120 0.00004 2 26.640 0 . 1 max ,0 666.67 0.04 1 1 1 1 v2 v1 k1 k 2 h 26.653 666.67 666.67 0.00002 2 2 2 2 26.653 666.67 0.00002 26.647V 10 http://numericalmethods.eng.usf.edu Solution Continued The solution to this nonlinear equation at t=0.00004 seconds is v(0.00004) 15.974V 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.00004 0.00002 0.00001 0.000005 0.0000025 v0.00004 53.307 26.640 15.980 15.918 15.970 −37.333 −10.666 −0.0056605 0.055825 0.0044682 v0.00004 15.974V 13 |t | % Et 233.71 65.771 0.035436 0.34947 0.027974 (exact) 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.00004 0.00002 0.00001 0.000005 0.0000025 v0.00004 Euler Heun Midpoint Ralston 106.64 53.307 26.640 15.996 15.993 53.307 26.640 15.980 15.918 15.970 −0.026667 −0.026667 11.642 15.917 15.968 35.529 17.751 15.363 15.917 15.968 v0.00004 15.974V 15 (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.00004 0.00002 0.00001 0.000005 0.0000025 t % Euler Heun 567.59 233.71 66.771 0.13146 0.11268 233.71 65.269 0.031301 0.35683 0.037561 v(0.00004) 15.974V 16 Midpoint Ralston 100.17 122.47 100.17 11.152 27.101 3.8009 0.33187 0.33187 0.012523 0.012523 (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