Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.

Slides:



Advertisements
Similar presentations
Lecture on Numerical Analysis Dr.-Ing. Michael Dumbser
Advertisements

Programming Tips: While Loops and Comparisons 1Daniel Baur / Numerical Methods for Chemical Engineerse Daniel Baur ETH Zurich, Institut für Chemie- und.
Boundary Value Problems and Partial Differential Equations (PDEs)
Chapter 6 Differential Equations
MATLAB EXAMPLES Initial-value problems
Fixed point iterations and solution of non-linear functions
Introduction to Matlab 7
Differential Equations Math Review with Matlab: Finding Solutions to Differential Equations S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department.
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,
Linear Regression 1Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression Daniel Baur ETH Zurich, Institut für Chemie- und Bioingenieurwissenschaften.
ODE jiangyushan. Pendulum As a example of a system that is nonlinear, consider the swinging pendulum shown above. When the mass of the pendulum is small.
Section 2.1 MODELING VIA SYSTEMS. A tale of rabbits and foxes Suppose you have two populations: rabbits and foxes. R(t) represents the population of rabbits.
Systems of Linear Equations
Response Surface Method Principle Component Analysis
MAT 594CM S10Fundamentals of Spatial ComputingAngus Forbes Week 2 : Dynamics & Numerical Methods Goal : To write a simple physics simulation Topics: Intro.
Linear Systems of Equations Ax = b Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und Bioingenieurwissenschaften ETH Hönggerberg/
Ordinary Differential Equations. Outline Announcements: –Homework II: Solutions on web –Homework III: due Wed. by 5, by Structs Differential Equations.
Ordinary Differential Equations. Outline Announcements: –Homework II: Solutions on web –Homework III: due Wed. by 5, by Homework II Differential.
Ordinary Differential Equations. Outline Announcements: –Homework II: Solutions on web –Homework III: due Wed. by 5, by Homework II Differential.
Non Linear Regression Y i = f(  x i ) +  i Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und Bioingenieurwissenschaften.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Chapter 16 Integration of Ordinary Differential Equations.
Ordinary Differential Equations (ODEs)
Differential Equations
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
Solving ODEs UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Fin500J Topic 7Fall 2010 Olin Business School 1 Fin500J Mathematical Foundations in Finance Topic 7: Numerical Methods for Solving Ordinary Differential.
MATLAB Ordinary Differential Equations – Part I Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University September.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
In the previous two sections, we focused on finding solutions to differential equations. However, most differential equations cannot be solved explicitly.
Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo Solving ODE.
Lecture 35 Numerical Analysis. Chapter 7 Ordinary Differential Equations.
Systems of Linear Equations Iterative Methods
EE3561_Unit 8Al-Dhaifallah14351 EE 3561 : Computational Methods Unit 8 Solution of Ordinary Differential Equations Lesson 3: Midpoint and Heun’s Predictor.
Boundary Value Problems and Least Squares Minimization
Integration of 3-body encounter. Figure taken from
CEE162/262c Lecture 2: Nonlinear ODEs and phase diagrams1 CEE162 Lecture 2: Nonlinear ODEs and phase diagrams; predator-prey Overview Nonlinear chaotic.
Autar Kaw Humberto Isaza Transforming Numerical Methods Education for STEM Undergraduates.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 12.
Quadrature rules 1Michael Sokolov / Numerical Methods for Chemical Engineers / Numerical Quadrature Michael Sokolov ETH Zurich, Institut für Chemie- und.
Beginning Programming for Engineers
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Physics for Games Spring 2012.
Numerical Differentiation and Quadrature (Integration)
BEH.420 Matlab Tutorial Bambang Adiwijaya 09/20/01.
Solution of Nonlinear Functions
Ordinary Differential Equations (ODEs) 1Michael Sokolov / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Michael Sokolov ETH Zurich, Institut.
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
Lecture 6: Time Response 1.Time response determination Review of differential equation approach Introduce transfer function approach 2.MATLAB commands.
Intro to Simulink April 15, Copyright , Andy Packard. This work is licensed under the Creative Commons.
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.
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.
Intro to Simulink Modified by Gary Balas 20 Feb 2011 Copyright , Andy Packard. This work is licensed under.
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.
Nonlinear Regression 1Michael Sokolov / Numerical Methods for Chemical Engineers / Nonlinear Regression Michael Sokolov ETH Zurich, Institut für Chemie-
Engineering Problem Solution
Modeling and Simulation Dr. Mohammad Kilani
Numerical Methods by Dr. Laila Fouad.
Zero of a Nonlinear System of Algebraic Equations f(x) = 0
Sec:25.3 RUNGE-KUTTA METHODS.
Sec:5.4 RUNGE-KUTTA METHODS.
Presentation transcript:

Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut für Chemie- und Bioingenieurwissenschaften ETH Hönggerberg / HCI F128 – Zürich

Problem Definition  We are going to look at initial value problems of explicit ODE systems, which means that they can be cast in the following form 2Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Higher Order ODEs  Higher order explicit ODEs can be cast into the first order form by using the following «trick»  Therefore, a system of ODEs of order n can be reduced to first order by adding n-1 variables and equations  Example: 3Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

ODEs as vector field  Since we know the derivatives as function of time and solution, we can calculate them at every point in time and space 4Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

ODE systems as vector fields  We can do the same for ODEs systems with two variables, at a certain time point 5Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Example: A 1-D First Order ODE  Consider the following initial value problem  This ODE and its solution follow a general form (Johann Bernoulli, Basel, 17 th – 18 th century) 6Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Some Nomenclature  On the next slide, the following notation will be used 7Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Numerical Solution of a 1-D First Order ODE  Since we know the first derivative, Taylor expansion suggests itself as a first approach  This is known as the Euler method, named after Leonhard Euler (Basel, 18 th century) 8Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

How does Matlab do it? Non-Stiff Solvers  ode45  ode45 : Most general solver, best to try first; Uses an explicit Runge-Kutta pair (Dormand-Prince, p = 4 and 5)  ode23ode45  ode23 : More efficient than ode45 at crude tolerances, better with moderate stiffness; Uses an explicit Runge- Kutta pair (Bogacki-Shampine, p = 2 and 3).  ode113  ode113 : Better at stringent tolerances and when the ODE function file is very expensive to evaluate; Uses a variable order Adams-Bashforth-Moulton method 9Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

How does Matlab do it? Stiff Solvers  ode15sode45  ode15s : Use this if ode45 fails or is very inefficient and you suspect that the problem is stiff; Uses multi-step numerical differentiation formulas (approximates the derivative in the next point by extrapolation from the previous points)  ode23sode15s  ode23s may be more efficient than ode15s at crude tolerances and for some problems (especially if there are largely different time-scales / dynamics involved); Uses a modified Rosenbrock formula of order 2 (one-step method) 10Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Matlab Syntax Hints [T, Y] = ode45(ode_fun, tspan, y0, …);  All ODE-solvers use the syntax [T, Y] = ode45(ode_fun, tspan, y0, …);  ode_fun is a function handle taking two inputs, a scalar t (current time point) and a vector y (current function values), and returning as output a vector of the derivatives dy/dt in these points  tspan is either a two component vector [tstart, tend] or a vector of time points where the solution is needed [tstart, t1, t2,...]  y0 are the values of y at tstart f_new y, k, p);  Use parametrizing functions to pass more arguments to ode_fun if needed f_new y, k, p);  This can be done directly in the solver call  [T, Y] = y, k, p), tspan, y0); 11Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Exercise 1: Damped harmonic oscillator  A mass on a string is subject to a force when out of equilibrium  According to Newton’s second law (including friction), the resulting movement follows the solution to an ODE: 12Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers m y F Spring force Friction

Assignment 1 1.Rewrite the motion equation for the damped harmonic oscillator as an explicit, first order ODE system ode45 2.Use ode45 to solve the problem function dy = harm_osc(t, y, m, k, a)  Set up a function file to calculate the derivatives, its header should read something like function dy = harm_osc(t, y, m, k, a) m = 1; k = 10; a = 0.5; y0 = 1; dy/dt0 = 0;  Set m = 1; k = 10; a = 0.5; y0 = 1; dy/dt0 = 0; tSpan = [0, 20];  Use tSpan = [0, 20]; 3.Plot the position of the mass y against time 4.Plot the speed of the mass dy/dt against time 13Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Exercise 2: Radioactive decay  A decaying radioactive element changes its concentration according to the ODE where k is the decay constant  The analytical solution to this problem reads 14Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Assignment 2 1.Plot the behavior of the radioactive decay problem as a vector field in the y vs t plane vector_field.m  Find online the function vector_field.m. It plots the derivatives of first order ODEs in different space and time points  Plot the vector field for y values between 0 and 1, time between 0 and 2 and k = 1. Can you see what a solver has to do?  Is it possible to switch from one trajectory in the vector field to another? What follows for the uniqueness of the solutions? 2.Implement the forward Euler method in a function file function [t,y] = eulerForward(f, t0, tend, y0, h)  The file header should read something like function [t,y] = eulerForward(f, t0, tend, y0, h) y0 = 1, k = 1 h = 0.1 t0 = 0 tEnd = 10  Use y0 = 1, k = 1 and h = 0.1 to solve the radioactive decay problem from t0 = 0 to tEnd = 10 and plot the solution together with the analytical solution. h  What happens if you increase the step size h ? What happens if you increase the step size above 2? 15Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Exercise 3: Lotka-Volterra equations  Predator-prey dynamics can be modeled with a simple ODE system: where x is the number of prey, y is the number of predators and a, b, c, d are parameters 16Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers

Assignment 3 1.Plot the behavior of the predator-prey system as a vector field in the x vs y plane vector_field2D.m  Find online the function vector_field2D.m which plots this vector field  Plot x and y between 0 and 1, and use a = c = 0.5 and b = d = 1  Without solving the ODEs, what can you say about the solution behavior just by looking at the trajectories? ode45x0 = y0 = 0.3 tSpan = [0, 50]; 2.Solve the system using ode45, and x0 = y0 = 0.3 as initial values, and tSpan = [0, 50];  Plot x and y against t. Can you observe what you predicted in 1? 17Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers