html5-img
1 / 30

Scientific Computing

Scientific Computing. Numerical Solution Of Ordinary Differential Equations - Runge-Kutta Methods. Runge-Kutta Methods. If we take more terms in the Taylor’s Series expansion of f(t,x), we would get a more accurate solution algorithm.

louvain
Télécharger la présentation

Scientific Computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Scientific Computing Numerical Solution Of Ordinary Differential Equations - Runge-Kutta Methods

  2. Runge-Kutta Methods • If we take more terms in the Taylor’s Series expansion of f(t,x), we would get a more accurate solution algorithm. • Problem: It is difficult to compute higher-order derivatives numerically. • Idea: Approximate the value of higher derivatives of f(t,x) by evaluating f several times between iterates: ti and ti+1 .

  3. Better Methods • The ODE +IV x(a)= x0 =s can be alternatively solved as an integral equation. For example, on the first interval from x0 to x1 :

  4. Better Methods In general: • The problem is that we don’t know x(t), so evaluating the integral is not trivial. • We assume that if h is small enough, f(t,x) will not change that much over the interval [ti, ti+1]. Using “left-rectangular integration,” • This is the Euler Method. A family of improved versions are called Runge-Kutta methods

  5. Euler Method Euler Solution x xi true solution h ti ti+1 = ti + h Tuncation error: true solution

  6. Euler vs Actual Solution Euler Solution RK methods differ in how they estimate fi For Euler Method (a type of RK method), fi ≈ f(ti, xi) x xi true solution fi h ti ti+1 = ti + h

  7. Runge-Kutta Order 2 Method x xi fi h Weighted average of two slopes x ti ti+αh ti+1

  8. Runge-Kutta Order 2 Method • Let • Then, • Expand k2 using Taylor’s Series in (t,x): where is a point between

  9. Runge-Kutta Order 2 Method Then, The actual Taylor Series expansion for x(ti+h) is: Thus, our weighted average approximation will be good to O(h3) if

  10. Runge-Kutta Order 2 Method So, general RK order 2 Method is: Examples: 1) ω1=1, ω2=0 -> Euler’s Method (Still O(h2) as no averaging) Error is lower than Euler, but now there are 2 calls to f(x,y) required per step Truncation error: true solution

  11. x xi+1 xi x ti+1 ti Heun’s Method (Pav’s RK-Order 2) Heun’s method resulting in where Heun’s method is ~ Trapezoidal Rule in Integration

  12. Midpoint Method resulting in Midpoint method is ~ Midpoint Rule in Integration where

  13. Ralston’s Method Ralston (1962) and Ralston and Rabinowitiz (1978) determined that choosing ω2 = 2/3 provides a minimum bound on the truncation error for the second order RK algorithms. resulting in where

  14. 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 Find the temperature at seconds using Heun’s method. Assume a step size of seconds. http://numericalmethods.eng.usf.edu

  15. Solution Step 1: http://numericalmethods.eng.usf.edu

  16. Solution Cont Step 2: http://numericalmethods.eng.usf.edu

  17. Solution Cont The exact solution of the ordinary differential equation is given by the solution of a non-linear equation as The solution to this nonlinear equation at t=480 seconds is http://numericalmethods.eng.usf.edu

  18. Comparison with exact results Figure 2. Heun’s method results for different step sizes http://numericalmethods.eng.usf.edu

  19. Effect of step size Table 1. Temperature at 480 seconds as a function of step size, h (exact) http://numericalmethods.eng.usf.edu

  20. Comparison of Euler and Runge-Kutta 2nd Order Methods Table 2. Comparison of Euler and the Runge-Kutta methods (exact) http://numericalmethods.eng.usf.edu

  21. Comparison of Euler and Runge-Kutta 2nd Order Methods Table 2. Comparison of Euler and the Runge-Kutta methods (exact) http://numericalmethods.eng.usf.edu

  22. Comparison of Euler and Runge-Kutta 2nd Order Methods Figure 4. Comparison of Euler and Runge Kutta 2nd order methods with exact results. http://numericalmethods.eng.usf.edu

  23. Runge-Kutta Order 4 Method weighted average where different estimates of slope

  24. Runge-Kutta Order 4 Method k2 k4 x k3 k1 ti ti + h/2 ti + h

  25. Runge-Kutta Order 4 Example • Consider Exact Solution • The initial condition is: • The step size is:

  26. Runge-Kutta Order 4 Example The example of a single step:

  27. Runge-Kutta Order 4 Example The RK values are nearly equivalent to those of the exact solution out to x=5. y(5) = -111.4129 (-111.4132) The error is small relative to the exact solution.

  28. Runge-Kutta Order 4 Example A comparison between the 2nd order and the 4th order Runge-Kutta methods show a slight difference.

  29. ERRORS Local (single-step) Global (multi-step) function evals per step RK 1st-order 1 O(h2) O(h) = O(1/n) 2nd-order O(h3) O(h2) = O(1/n2) 2 4th-order O(h5) O(h4) = O(1/n4) 4 “local error” For n steps, Therefore, “global error” Order of global error is 1 less than order of local error

  30. A fair comparison between two RK methods must account the differing number of function calls per step RK1 (Euler Method)- - 1 function call per step t0 t1 t2 t3 t4 t5 t8 t7 t6 RK4 - - 4 function calls per step t0 t1 t2 Example: integrate from 0 to 4 using n=400 function evaluations 1st-order Euler with h = 0.01… global error = O(0.01) 4th-order RK with h = 0.04… global error = O(0.00000256) 104 times less error for same amount of work  FREE LUNCH !!!

More Related