Ordinary Differential Equations (ODEs)

Slides:



Advertisements
Similar presentations
Programming Tips: While Loops and Comparisons 1Daniel Baur / Numerical Methods for Chemical Engineerse Daniel Baur ETH Zurich, Institut für Chemie- und.
Advertisements

Boundary Value Problems and Partial Differential Equations (PDEs)
Fixed point iterations and solution of non-linear functions
Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH Zurich, Institut für Chemie-
Numerical Differentiation and Quadrature (Integration) 1Daniel Baur / Numerical Methods for Chemical Engineers / Numerical Quadrature Daniel Baur ETH Zurich,
Algebraic, transcendental (i.e., involving trigonometric and exponential functions), ordinary differential equations, or partial differential equations...
Ordinary Differential Equations
MATH 685/ CSI 700/ OR 682 Lecture Notes
Systems of Linear Equations
SOLVING SYSTEMS OF LINEAR EQUATIONS. Overview A matrix consists of a rectangular array of elements represented by a single symbol (example: [A]). An individual.
Response Surface Method Principle Component Analysis
1cs542g-term Notes. 2 Solving Nonlinear Systems  Most thoroughly explored in the context of optimization  For systems arising in implicit time.
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.
1cs542g-term Notes  Even if you’re not registered (not handing in assignment 1) send me an to be added to a class list.
Total Recall Math, Part 2 Ordinary diff. equations First order ODE, one boundary/initial condition: Second order ODE.
Linear Systems of Equations Ax = b Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und Bioingenieurwissenschaften ETH Hönggerberg/
Efficient Simulation of Physical System Models Using Inlined Implicit Runge-Kutta Algorithms Vicha Treeaporn Department of Electrical & Computer Engineering.
Tutorial 10 Iterative Methods and Matrix Norms. 2 In an iterative process, the k+1 step is defined via: Iterative processes Eigenvector decomposition.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers Daniel Baur ETH Zurich, Institut.
ECE 530 – Analysis Techniques for Large-Scale Electrical Systems
Differential Equations and Boundary Value Problems
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.
Numerical Solution of Ordinary Differential Equation
MATH 685/ CSI 700/ OR 682 Lecture Notes Lecture 10. Ordinary differential equations. Initial value problems.
1 Chapter 6 Numerical Methods for Ordinary Differential Equations.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Selected Differential System Examples from Lectures.
Boyce/DiPrima 9th ed, Ch 8.4: Multistep Methods Elementary Differential Equations and Boundary Value Problems, 9th edition, by William E. Boyce and Richard.
Lecture 35 Numerical Analysis. Chapter 7 Ordinary Differential Equations.
Systems of Linear Equations Iterative Methods
Autumn 2008 EEE8013 Revision lecture 1 Ordinary Differential Equations.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
MATH 250 Linear Equations and Matrices
ME451 Kinematics and Dynamics of Machine Systems
ME451 Kinematics and Dynamics of Machine Systems Numerical Solution of DAE IVP Newmark Method November 1, 2013 Radu Serban University of Wisconsin-Madison.
Selected Differential System Examples from Lectures
Boundary Value Problems and Least Squares Minimization
Modelling & Simulation of Chemical Engineering Systems Department of Chemical Engineering King Saud University 501 هعم : تمثيل الأنظمة الهندسية على الحاسب.
Integration of 3-body encounter. Figure taken from
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.
Lecture 7 - Systems of Equations CVEN 302 June 17, 2002.
Quadrature rules 1Michael Sokolov / Numerical Methods for Chemical Engineers / Numerical Quadrature Michael Sokolov ETH Zurich, Institut für Chemie- und.
Numerical Differentiation and Quadrature (Integration)
Solution of Nonlinear Functions
CIS888.11V/EE894R/ME894V A Case Study in Computational Science & Engineering We will apply several numerical methods to find a steady state solution of.
Large Timestep Issues Lecture 12 Alessandra Nardi Thanks to Prof. Sangiovanni, Prof. Newton, Prof. White, Deepak Ramaswamy, Michal Rewienski, and Karen.
ECE 576 – Power System Dynamics and Stability Prof. Tom Overbye Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
Ordinary Differential Equations (ODEs) 1Michael Sokolov / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Michael Sokolov ETH Zurich, Institut.
Circuits Theory Examples Newton-Raphson Method. Formula for one-dimensional case: Series of successive solutions: If the iteration process is converged,
ECE 530 – Analysis Techniques for Large-Scale Electrical Systems Prof. Hao Zhu Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
ME451 Kinematics and Dynamics of Machine Systems Numerical Integration. Stiffness: Implicit Methods. October 30, 2013 Radu Serban University of Wisconsin-Madison.
Linear Systems of Equations Iterative and Relaxation Methods Ax = b Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und.
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.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.
ECE 530 – Analysis Techniques for Large-Scale Electrical Systems Prof. Hao Zhu Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 32.
Lecture 11 Alessandra Nardi
ECE 576 – Power System Dynamics and Stability
CSE 245: Computer Aided Circuit Simulation and Verification
Chapter 26.
Numerical Analysis Lecture 37.
Numerical Analysis Lecture11.
Chapter 2 A Survey of Simple Methods and Tools
Presentation transcript:

Ordinary Differential Equations (ODEs) Daniel Baur ETH Zurich, Institut für Chemie- und Bioingenieurwissenschaften ETH Hönggerberg / HCI F128 – Zürich E-Mail: daniel.baur@chem.ethz.ch http://www.morbidelli-group.ethz.ch/education/index Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Definition of an Implicit Algorithm In an implicit algorithm, the function value at the next step appears on the right hand side of the step equation: A simple example is the Backward Euler method: Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Example Consider a batch reactor where these reactions take place In our example k1 = 1 and k2 = 10 Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Analytical Solution The system describing first order reactions in a batch reactor (assuming V = const. and T = const.) has the following general form where A is a (N x N) matrix of constant coefficients The analytical solution to these systems reads where B is matrix of constant coefficients and λ is the vector of the eigenvalues of A B can be found by imposing that the solution satisfies the initial differential equaiton and the initial values of y Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Analytical Solution of the Batch Reactor The Jacobian matrix reads Its eigenvalues are Imposing A0 = 1 and B0 = 0, the solution reads Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Forward Euler Method In the linear case, we can look at the Forward Euler method in a different way, by noticing that With the definition of the Forward Euler algorithm y will only converge towards a value if the spectral radius of the matrix (I + hJ) is smaller than 1, i.e. Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Solution with Forward Euler Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Backward Euler Method As mentioned before, the simplest implicit method is the Backward Euler method If we substitute our problem We obtain In case of linear ODEs, this is a linear system of the form Ax = b that has to be solved at every iteration step Note that in general this can be a non-linear system Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Stability of the Backward Euler Method If we solve for the next step, we get Again the spectral radius of the iteration matrix determines convergence: As we can see, the Backward Euler method is stable for every system that it is well conditioned, i.e. if Re(λmax) < 0 Algorithms with this property are called A-stable algorithms There can be no stability limitation on the step size, which also makes the Backward Euler better for stiff systems than the Forward Euler Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Implicit Trapezoidal Rule The implicit trapezoidal algorithm reads as follows Substituting our problem, we get This is again an A-stable algorithm h = 0.1 h = 0.2 Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

A-Stability of other Algorithms Explicit Runge-Kutta methods, as well as explicit multi-step methods can never be A-stable Note that the Forward Euler method can be seen as both an explicit multi-step method or RK method of order 1 Implicit multi-step methods can only be A-stable if they are of order 2 or lower (second Dahlquist barrier) However, implicit RK methods of higher order can be A-stable Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Multi-Step Algorithms Multi-step methods use not only the current function value yn to compute the next value yn+1, but also function values at previous times (yn-1, ...) In implicit solvers, they can be used in predictor / corrector pairs to avoid solving large systems of equations One example are the Adams-Bashforth-Moulton methods The corrector step can be looped until it converges, i.e. use the yn+1 from the corrector as the prediction and evaluate the corrector again, until its change is sufficiently small Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Convergence of the Corrector Step Let us reformulate the AM corrector step to incorporate the convergence iteration This iteration will only converge if the spectral radius of the iteration matrix is smaller than 1, i.e. This restricts the maximum step size almost as badly as stability issues restrict the Forward Euler method Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Example of the AB/AM Algorithm Startup was done with the Implicit Trapezoid rule; h = 0.2 The convergence loop more than triples the overall time needed, but it increases stability Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Implicit Algorithms and Stiff Problems Since implicit algorithms are generally more stable than explicit algorithms (some are even A-stable!), they fare much better with stiff problems, where the step size is often restricted by stability issues For non-A-stable implicit algorithms, the main goal is usually to get the largest possible stability region, since this is the main advantage of implicit algorithms However, this stability comes at the price of larger computational demand per step, which is needed to solve the arising algebraic equation systems There are however highly specialized algorithms to solve systems arising from implicit solvers, which can take into account special features of the problem like sparseness or bandedness Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Sparse and Banded Matrices It is computationally very advatageous if sparse or in the best case even banded matrices can be used: Sparse: Storing and operating on only 510 non-zero elements (times two for their position) instead of 10’000 Banded: All non-zero elements are grouped in a band around the diagonal, which further simplifies computations Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Variable Step Size and Order Algorithms Since the step size h is of such importance for stability and accuracy, sophisticated algorithms adjust it during runtime This requires error estimation, which is usually done by comparing the result to what the same algorithm produces with a higher order Some algorithms even adjust their order p dynamically Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Assignment 1 Implement the Implicit Trapezoid method (see slide 10) for the batch reactor given on slide 3. Simply use left division «\» to solve the arising linear systems. What is the maximum step size h that still insures stability? What step size h is needed to get a maximum error of 0.1% at all time points, compared to the analytical solution? Plot the solutions. Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Exercise 2 The following reaction scheme is known as the Oregonator A and B are held constant P and Q are constantly withdrawn, therefore ≈ 0 Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Exercise 2 (Continued) This leads to the following system of ODEs Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers

Assignment 2 Solve the system using a suitable built-in Matlab solver (which one? Note the dynamics!), using the following parameters: A = B = 0.5 = const.; k1 = 1.34; k2 = 1e9; k3 = 8e3; k4 = 4e7; k5 = 1; X0 = Y0 = Z0 = 0.2; tspan = [0, 300]; Plot the solution. What is special, given the fact that this is a model for a chemical reaction? Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers