ODEs: Adaptive Methods and Stiff Systems

Slides:



Advertisements
Similar presentations
Chapter 6 Differential Equations
Advertisements

MATLAB EXAMPLES Initial-value problems
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 9 Instructor: Tim Warburton.
Integration Techniques
Computational Methods in Physics PHYS 3437
Ordinary Differential Equations
1cs542g-term Notes  Notes for last part of Oct 11 and all of Oct 12 lecture online now  Another extra class this Friday 1-2pm.
Dr. Jie Zou PHY Chapter 9 Ordinary Differential Equations: Initial-Value Problems Lecture (I) 1 1 Besides the main textbook, also see Ref.: “Applied.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 32 Ordinary Differential Equations.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 31 Ordinary Differential Equations.
Initial-Value Problems
Dr. Jie Zou PHY Chapter 9 Ordinary Differential Equations: Initial-Value Problems Lecture (II) 1 1 Besides the main textbook, also see Ref.: “Applied.
8-1 Chapter 8 Differential Equations An equation that defines a relationship between an unknown function and one or more of its derivatives is referred.
ODEs: Initial-Value Problems
Multistep methods previous methods use information at xi to predict yi+1 multistep methods use information from xi-1, xi-2, etc. leads to better results.
Chapter 17 Objectives Recognizing that Newton-Cotes integration formulas are based on the strategy of replacing a complicated function or tabulated data.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Numerical Solutions of Ordinary Differential Equations
Adaptive Runge-Kutta addresses the problem of functions that change rapidly at a point.
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
Chapter 16 Integration of Ordinary Differential Equations.
CISE301_Topic8L31 SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture KFUPM (Term 101) Section 04 Read , 26-2,
Ordinary Differential Equations (ODEs)
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers Daniel Baur ETH Zurich, Institut.
1 Chapter 6 Numerical Methods for Ordinary Differential Equations.
PART 7 Ordinary Differential Equations ODEs
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo Solving ODE.
Boyce/DiPrima 9th ed, Ch 8.4: Multistep Methods Elementary Differential Equations and Boundary Value Problems, 9th edition, by William E. Boyce and Richard.
EE3561_Unit 8Al-Dhaifallah14351 EE 3561 : Computational Methods Unit 8 Solution of Ordinary Differential Equations Lesson 3: Midpoint and Heun’s Predictor.
Modeling and simulation of systems Numerical methods for solving of differential equations Slovak University of Technology Faculty of Material Science.
An Over View of Runge-Kutta Fehlberg and Dormand and Prince Methods. Numerical Methods To Solve Initial Value Problems William Mize.
Modelling & Simulation of Chemical Engineering Systems Department of Chemical Engineering King Saud University 501 هعم : تمثيل الأنظمة الهندسية على الحاسب.
Integration of 3-body encounter. Figure taken from
Scientific Computing Numerical Solution Of Ordinary Differential Equations - Euler’s Method.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. ~ Ordinary Differential Equations ~ Stiffness and Multistep.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 261 Stiffness.
Scientific Computing Multi-Step and Predictor-Corrector Methods.
Ordinary Differential Equations (ODEs) 1Michael Sokolov / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Michael Sokolov ETH Zurich, Institut.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 7 - Chapter 25.
Numerical Analysis – Differential Equation
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
Please remember: When you me, do it to Please type “numerical-15” at the beginning of the subject line Do not reply to my gmail,
Part 6 Chapter 21 Adaptive Methods and Stiff Systems PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
ME451 Kinematics and Dynamics of Machine Systems Numerical Integration. Stiffness: Implicit Methods. October 30, 2013 Radu Serban University of Wisconsin-Madison.
Chapter 5. Ordinary Differential Equation
Today’s class Ordinary Differential Equations Runge-Kutta Methods
Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations.
ECE 576 – Power System Dynamics and Stability Prof. Tom Overbye Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical Calculus and Differential Equations.
1/14  5.2 Euler’s Method Compute the approximations of y(t) at a set of ( usually equally-spaced ) mesh points a = t 0 < t 1
Lecture 39 Numerical Analysis. Chapter 7 Ordinary Differential Equations.
Sec 232: The coefficient tableau 2ed order RK method Expand all f around (x,y) using Taylor expansion in 2d and then choose constants such that the equation.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 32.
CISE301_Topic8L71 CISE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture KFUPM (Term 101) Section 04 Read , 26-2,
Ordinary Differential Equations
Part 7 - Chapter 25.
Numerical Methods by Dr. Laila Fouad.
Class Notes 18: Numerical Methods (1/2)
Class Notes 19: Numerical Methods (2/2)
Chapter 26.
Part 7 - Chapter 25.
Sec:5.4 RUNGE-KUTTA METHODS.
Numerical Analysis Lecture 38.
Adaptive Methods and Stiff Systems
MATH 175: NUMERICAL ANALYSIS II
Implicit and Explicit Runge-Kutta methods
Presentation transcript:

ODEs: Adaptive Methods and Stiff Systems Chapter 21 ODEs: Adaptive Methods and Stiff Systems

Adaptive Runge Kutta Method Use small step size in high gradient region (abrupt change) automatic step size adjustment

Adaptive Runge Kutta Method First approach: Step halving Estimate local truncation error using two different step sizes Solve each step twice, once as a full step and then as two half steps Second approach: Embedded RK methods (also called RK-Fehlberg methods) Estimate local truncation error between two predictions using two different-order RK methods

Step Halving Method y1 – one full step; y2 – two half steps Step Halving (Adaptive RK) method Compute the solutions at each step twice using 4th-order classic RK method Once as a full step h and independently as two half steps (h/2) y1 – one full step; y2 – two half steps Error estimate Correction – 5th-order

Adaptive 4th-order RK Method One full-step with h Two half-steps with h/2 Therefore, Two half-steps

Embedded Runge-Kutta Method MATLAB function: ODE23 BS23 algorithm (Bogacki and Shampine, 1989; Shampine, 1994) Use 3rd-order & 4th-order RK methods simultaneously to solve the ODE and estimate the error for step-size adjustment Error estimate (Note: k1 is the same as k4 from previous step)

Embedded RK Method: ODE23 Uses only three function evaluations (k1, k2, k3) After each step, the error is checked to determine whether it is within desired tolerance. If it is, yi+1 is accepted and k4 becomes k1 for the next time step If the error is too large, the step is repeated with a reduced step sizes until the estimate error is acceptable RelTol: relative tolerance (default = 103) AbsTol: relative tolerance (default = 106)

Adaptive RK Method – ode23 Example 21.2: Use ode23 to solve the following ODE from t = 0 to 4: function yp = ex21_2(t, y) % Example 21.2 in the text book yp = 10*exp(-(t-2)*(t-2)/(2*0.075^2)) - 0.6*y;

(a) RelTol = 103 (b) RelTol = 104 Example 20.2: ode23 >> options = odeset('RelTol',1.e-3); >> ode23('ex21_2', [0 4], 0.5, options); >> options = odeset('RelTol',1.e-4); >> ode23('ex21_2', [0 4], 0.5, options); (a) RelTol = 103 (b) RelTol = 104

Other MATLAB Functions MATLAB Function: ode45 Dormand and Prince (1990) Solve fourth- and fifth-order RK formulas simultaneously Make error estimates for step-size adjustment MATLAB Function: ode113 Adams-Bashforth-Moulton solver (order 1-12) Predictor-corrector method

Runge-Kutta Fehlberg Method Fourth-order Fifth-order These coefficients were developed by Cash and Karp (1990). Also called Cash-Karp RK Method

Runge-Kutta Fehlberg Method Identical coefficients (k1, k2, k3, k4, k5, k6) for both the fourth and fifth order Runge-Kutta-Fehlberg methods Save CPU time Error estimate – use two RK methods of different order to estimate the local truncation error

Runge-Kutta Fehlberg Method First, calculate yi+1 using 4th-order Runge-Kutta Felberg method  (y1)4th Then, calculate yi+1 using 5th-order Runge-Kutta Felberg method  (y2)5th Calculate Error Ea = (y2)5th - (y1)4th Adjust step size according to error estimate

Step Size Control Use step-halving or Runge-Kutta Fehlberg to estimate the local truncation error Adjust the step size according to error estimate Increase the step size if the error is too small and decrease it if the error is too large For fourth-order schemes

Step Size Adjustment For step size increases (RK4, n = 4) For nth-order RK Method For step size increases (RK4, n = 4) For step size decreases, h is implicit in new Reduce hnew also reduce new

Example 21.2 Forcing function Runge-Kutta-Fehlberg method with adaptive step size control t small step size around t = 2 solution t

Predator-Prey Equation A simple predator-prey relationship is described by the Lotka-Volterra model, which we write in terms of a fox population f(t), with birth rate bf and death rate df and a geese population g(t) with birth rate bg and death rate dg

Predator-Prey Equation Example: Given bf = 0.3, df = 0.8, bg = 1.2, dg = 0.6, find the populations of predators and preys as a function of time (t = 0 to 20) using ode45. Predator Prey function yp = predprey(t,y) % Fox (Predator) population y1(t), birth rate bf, death rate df % Geese (prey) poupulation y2(t), birth rate bg, death rate dg bf = 0.3; df = 0.8; bg = 1.2; dg = 0.6; yp = [y(1)*(bf*y(2)-df); y(2)*(bg-dg*y(1))];

Adaptive RK method : ode45 >> tspan=[0 20]; y0 = [1, 2]; >> [t,y] = ode45('predprey',tspan,y0); >> out = [t y] out = 0 1.00000000000000 2.00000000000000 0.08372954771699 0.98466335925883 2.10387606351447 0.16745909543397 0.97217906418030 2.21469691968449 0.25118864315096 0.96261463455261 2.33264806768044 0.33491819086794 0.95606000043195 2.45787517860514 0.62870201024789 0.95940830414765 2.95257534365817 0.92248582962784 1.00915715534212 3.53554512325941 1.21626964900779 1.11944001342999 4.17743733245175 1.51005346838774 1.31420023093313 4.80288705430266 1.70029730481714 1.49877617603179 5.14418160032910 1.89054114124654 1.73932623590652 5.37426899115905 2.08078497767594 2.03724630610217 5.44284022577897 2.27102881410534 2.38123550265509 5.31619117469119 2.46127265053474 2.74867929767025 4.98122010458805 2.65151648696414 3.09373931102751 4.48531246964154 2.84176032339354 3.37201992118282 3.89965751560944 3.03200415982294 3.55414367377695 3.29772307544844 3.21873982743099 3.62508046596480 2.75627545562992 3.40547549503903 3.59592495497541 2.29786856084044 3.59221116264708 3.48499741488926 1.93369109247072 3.77894683025512 3.31638942318525 1.65488750920928 3.94714350340851 3.13529220765148 1.46223282653043 4.11534017656189 2.93901369774356 1.31685686503153 4.28353684971528 2.73779832900552 1.20974621108398 4.45173352286867 2.53877488937042 1.13408335792525 4.65875081398499 2.30372716989349 1.07647855767312 4.86576810510130 2.08503830477357 1.05104469525303 5.07278539621762 1.88590370110986 1.05298367705029 ... ... ... 19.13258672508553 1.39621015109817 1.21506308763510 19.36078504002272 1.26894875046392 1.33168491347240 19.58898335495991 1.16392668931057 1.48284270918163 19.69173751621993 1.12358612912238 1.56325743063018 19.79449167747995 1.08747228241032 1.65192298666833 19.89724583873998 1.05554028549720 1.74928308667197 20.00000000000000 1.02776980338246 1.85579178601841

Predator-Prey Model Time history of predator (fox) and prey (geese) populations

Predator-Prey Model State-space plot

Multistep Methods Runge-Kutta methods Multistep methods -- one-step method -- use intermediate values between ti and ti+1 -- several evaluations of slope per step Multistep methods -- use values at ti , ti-1 , ti-2 etc -- only one evaluation of derivative per step

One-Step and Multistep Methods One-step Multistep

Multi-step methods use several previous points (yi-1 , yi-2 ,…) in addition to the present point yi - explicit (b0 = 0) & implicit methods. - # of the previous steps. Non-self start Huen method* Adams-Bashforth Methods (explicit methods b0 = 0) Admas-Moulton Methods (implicit methods) Predictor-Corrector Methods

Heun’s Method (Review) Start with second-order method Look at Heun’s method (Self-Starting) Euler predictor - O(h2) Trapezoid corrector - O(h3)

Non-Self-Starting Heun’s Method To improve predictor, use 3rd-order Euler method along with the same old corrector iterated until converged Note: are the final results of the corrector iterations at the previous time step

Non-Self Starting Heun’s Method (a) 3rd-order predictor (b) 3rd-order corrector Non-self starting, need yi-1 and yi (two initial values)

Heun’s Method (a) 2nd-order predictor (b) 3rd-order corrector Self-starting, need yi only

Truncation Errors Non-self-starting Heun method Predictor truncation error Corrector truncation error

Modifiers Corrector Modifier Predictor Modifier (not used in textbook) Error in textbook

Non-Self Starting Heun’s Method So the sequence is Predict Adjust prediction* Correct Converged? If not, correct again

Hand Calculations Non-self-starting Heun’s method Need two initial conditions Example: 21.3 (p523- 524) Exact solution: y = 3.076923e 0.8t – 1.076923 e –0.5 t

Hand Calculations – First Step Predictor: Corrector: First Step (i = 0) : need two initial conditions Predictor:

Hand Calculations – First Step Corrector:

Hand Calculations – Second Step Second Step (i = 1) : Predictor:

Hand Calculations – First Step Corrector:

Stiffness A stiff system involves rapidly changing components (usually die away quickly) together with slowly ones Long-time solution is dominated by slow varying components

Numerical Stability Amplification or decay of numerical errors A numerical method is stable if error incurred at one stage of the process do not tend to magnify at later stages Ill-conditioned differential equation -- numerical errors will be magnified regardless of numerical method Stiff differential equation -- require extremely small step size to achieve accurate results

Stability Example problem

Euler Explicit Method Stability criterion Region of absolute stability Amplification factor

Unconditionally stable ! Euler Implicit Method Forward, Backward, or Centered Scheme? Unconditionally stable !

Unconditionally stable Stability Explicit Euler method Second-order Adams-Moulton Implicit methods are in general more stable than explicit methods. If a = 1000, then h  0.002 to ensure stability Unconditionally stable

Example 21.5 Euler Explicit Euler Implicit

MATLAB Functions for Stiff Systems ode15s – based on Gear backward differentiation for stiff problems of low to medium accuracy ode23s – based on modified Rosenbrock formula ode23t – trapezoidal rule with a free interpolant for moderately stiff problems without numerical damping ode23tb – implicit Runge-Kutta formula for more explanation please see page 529

Stiff ODE – van del Pol equation Van der Pol equation for electronic circuit Convert to two first-order ODEs

Stiff ODE – van del Pol equation M-file for van del Pol equation function yp = vanderpol(t,y,mu) % van der Pol equation for electronic circuit % d^2y1/dt^2 - mu*(1-y1^2) * dy1/dt + y1 = 0 % initial conditions, y1(0) = dy1/dt = 1 % convert to two first-order ODEs % The solution becomes progressively stiffer % as mu gets large yp = [y(2); mu*(1-y(1)^2)*y(2)-y(1)];

Nonstiff ODE – van del Pol equation >> [t,y]=ode45(@vanderpol,[0 20],[1 1],[], 1); >> H=plot(t,y(:,1),t,y(:,2),'m--'); >> legend('y1','y2',2);  = 1 ode45

Stiff ODE – van del Pol equation >> [t,y]=ode23s(@vanderpol,[0 6000],[1 1],[], 1000); >> H=plot(t,y(:,1)); >> set(H,'LineWidth',3)  = 1000 ode23s

Bungee Jumper – Coupled ODEs Vertical Dynamics of a jumper connected to a stationary platform with a bungee cord (Ex21.4) Air resistance depending on whether the cord is slack or stretched – use sign(v) for drag force Spring constant k (N/m) and damping coefficient  (N·s/m) Need to solve two simultaneous ODEs for x and v k =  = 0 if x  L

Non-stiff ODEs: Bungee Jumper Use ode45 for non-stiff ODEs to solve for the distance and velocity of a bungee jumper function dydt = bungee(t,y,L,cd,m,k,gamma) g = 9.81; cord = 0; if y(1) > L % determine if the cord exerts a force cord = k/m * (y(1)-L) + gamma/m * y(2); end dydt = [y(2); g - sign(y(2)) * cd/m*y(2)^2 - cord];

Bungee jumper velocity Bungee jumper distance >> [t,y] = ode45(@bungee,[0 50],[0 0],[],30,0.25,68.1,40,8); >> h1 = plot(t,-y(:,1),t,y(:,2),'m--'); >> h2 = legend('x (m)','v(m/s)'); >> set(h1,'LineWidth',3); set(h2,'FontSize',12); Bungee jumper velocity Bungee jumper distance

CVEN 302-501 Homework No. 14 Chapter 21 Prob. 21.3 (30) (Hand Calculation) 21.5 (30) Prob. 21.8 (40) (using MATLAB program except for part a)) Due 12/02/08 before 5:00 pm