Transcript PPT
Runge 4th Order Method Electrical 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 4th Order Method http://numericalmethods.eng.usf.edu Runge-Kutta 4th Order Method For dy f ( x, y ), y (0) y0 dx Runge Kutta 4th order method is given by 1 yi 1 yi k1 2k2 2k3 k4 h 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 3 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 4 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 dv(t ) 18 cos(120 (t )) 2 v(t ) 1 dt 150 10 6 0.1 max ,0 0.04 v(0) 0 Find voltage across the capacitor at t= 0.00004s. Use step size h=0.00002 dv 18 cos(120 (t )) 2 v 1 dt 150 10 f t , v 0.1 max 1 150 10 6 vi 1 vi 5 6 0.04 ,0 18 cos(120 (t )) 2 v ,0 0.1 max 0.04 1 k1 2k 2 2k 3 k 4 h 6 http://numericalmethods.eng.usf.edu Solution i 0, t0 0, v0 0V Step 1: k1 f t0 , v0 f 0, 0 1 150 10 6 18 cos120 0 2 0 ,0 2.6660 106 0.1 max 0.04 1 1 1 1 k 2 f t0 h, v0 k1h f 0 0.00002 , 0 2.6660 106 0.00002 f 0.00001, 26.660 2 2 2 2 1 150 10 6 18 cos120 0.00001 2 (26.660) 0 . 1 max , 0 666.67 0 . 04 1 1 1 1 k3 f t0 h, v0 k 2 h f 0 0.00002, 0 666.67 0.00002 f 0.00001, 0.0066667 2 2 2 2 1 150 10 6 18 cos120 0.00001 2 0.0066667 2.6671106 0 . 1 max , 0 0.04 k 4 f t0 h, v0 k3h f 0 0.0002, 0 2.6671106 0.00002 f 0.00002, 53.342 6 1 150 10 6 18 cos120 0.00002 2 53.342 0 . 1 max , 0 666.67 0 . 04 http://numericalmethods.eng.usf.edu Solution Cont 1 k1 2k2 2k3 k4 h 6 1 0 2.6660 106 2 666.67 2 2.6671106 666.67 0.00002 6 1 0 7.9982 106 0.00002 6 26.661V v1 v0 v1 is the approximate voltage at t t1 t0 h 0 0.00002 0.00002 v0.00002 v1 26.661V 7 http://numericalmethods.eng.usf.edu Solution Cont Step 2: i 1, t1 0.00002, v1 26.641V 18 cos120 0.00002 2 26.661 1 0 . 1 max ,0 666.67 150 10 6 0 . 04 1 1 1 1 k 2 f t1 h, v1 k1h f 0.00002 0.00002 , 26.661 666.67 0.00002 f 0.00003, 26.654 2 2 2 2 k1 f t1 , v1 f 0.00002, 26.661 1 150 10 6 18 cos120 0.00003 2 26.654 ,0 666.67 0.1 max 0.04 1 1 1 1 k3 f t1 h, v1 k 2 h f 0.00002 0.00002 , 26.661 666.67 0.00002 f 0.00003, 26.654 2 2 2 2 1 150 10 6 18 cos120 0.00003 2 26.654 0 . 1 max , 0 666.67 0 . 04 k4 f t1 h, v1 k3h f 0.00002 0.00002, 26.661 666.67 0.00002 f 0.00003, 26.647 8 1 150 10 6 18 cos120 0.00003 2 26.634 0 . 1 max , 0 666.67 0 . 04 http://numericalmethods.eng.usf.edu Solution Cont 1 v2 v1 k1 2k 2 2k3 k 4 h 6 1 26.661 666.67 2 666.67 2 666.67 666.67 0.00002 6 1 26.661 4000.0 0.00002 6 26.647 V v2 is the approximate voltage at t2 t1 h 0.00002 0.00002 0.00004 s v0.00004 v2 26.647V 9 http://numericalmethods.eng.usf.edu Solution Cont The exact solution to the differential equation at t=0.00004 seconds is v0.00004 15.974V 10 http://numericalmethods.eng.usf.edu Comparison with exact results Figure 1. Comparison of Runge-Kutta 4th order method with exact solution 11 http://numericalmethods.eng.usf.edu Effect of step size Table 1 Value of voltage at time, t=0.00004s for different step sizes Step size, h 0.00004 0.00002 0.00001 0.000005 0.0000025 v0.00004 Et |t | % 53.335 26.647 15.986 15.975 15.976 −37.361 −10.673 −0.012299 −0.00050402 −0.0015916 233.89 66.817 0.076996 0.0031552 0.0099639 v(0.00004) 15.974V (exact) 12 http://numericalmethods.eng.usf.edu Effects of step size on RungeKutta 4th Order Method Figure 2. Effect of step size in Runge-Kutta 4th order method 13 http://numericalmethods.eng.usf.edu Comparison of Euler and RungeKutta Methods Figure 3. Comparison of Runge-Kutta methods of 1st, 2nd, and 4th order. 14 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_4th_method.html THE END http://numericalmethods.eng.usf.edu