Boundary Value Problems and Least Squares Minimization

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)
Numerical Solution of Linear Equations
Fixed point iterations and solution of non-linear functions
Process Control: Designing Process and Control Systems for Dynamic Performance Chapter 6. Empirical Model Identification Copyright © Thomas Marlin 2013.
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.
Algebraic, transcendental (i.e., involving trigonometric and exponential functions), ordinary differential equations, or partial differential equations...
P. Venkataraman Mechanical Engineering P. Venkataraman Rochester Institute of Technology DETC2014 – 35148: Continuous Solution for Boundary Value Problems.
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.
Data mining and statistical learning - lecture 6
Response Surface Method Principle Component Analysis
Linear Systems of Equations Ax = b Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und Bioingenieurwissenschaften ETH Hönggerberg/
Curve-Fitting Regression
Review of Matrix Algebra
Ordinary least squares regression (OLS)
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.
Linear Regression Y i =  0 +  1 x i +  i Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und Bioingenieurwissenschaften.
Linear and generalised linear models Purpose of linear models Least-squares solution for linear models Analysis of diagnostics Exponential family and generalised.
Lecture 11 Chemical Reaction Engineering (CRE) is the field that studies the rates and mechanisms of chemical reactions and the design of the reactors.
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.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Non-Linear Simultaneous Equations
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Today’s class Boundary Value Problems Eigenvalue Problems
DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS MEKANIKA SOFTWARE SEMINARS.
Systems of Linear Equations Iterative Methods
Algorithms for a large sparse nonlinear eigenvalue problem Yusaku Yamamoto Dept. of Computational Science & Engineering Nagoya University.
Chapter 6 Finding the Roots of Equations
ME451 Kinematics and Dynamics of Machine Systems Numerical Solution of DAE IVP Newmark Method November 1, 2013 Radu Serban University of Wisconsin-Madison.
10/17/ Gauss-Siedel Method Industrial Engineering Majors Authors: Autar Kaw
Chapter 3 Solution of Algebraic Equations 1 ChE 401: Computational Techniques for Chemical Engineers Fall 2009/2010 DRAFT SLIDES.
10/26/ Gauss-Siedel Method Civil Engineering Majors Authors: Autar Kaw Transforming.
Lecture 7 - Systems of Equations CVEN 302 June 17, 2002.
Chapter 5 MATRIX ALGEBRA: DETEMINANT, REVERSE, EIGENVALUES.
Scientific Computing General Least Squares. Polynomial Least Squares Polynomial Least Squares: We assume that the class of functions is the class of all.
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)
Modelling & Simulation of Chemical Engineering Systems Department of Chemical Engineering King Saud University 501 هعم : تمثيل الأنظمة الهندسية على الحاسب.
Solution of Nonlinear Functions
Ordinary Differential Equations (ODEs) 1Michael Sokolov / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Michael Sokolov ETH Zurich, Institut.
Introduction to Matlab Part II 1Daniel Baur / Introduction to Matlab Part II Daniel Baur / Michael Sokolov ETH Zurich, Institut für Chemie- und Bioingenieurwissenschaften.
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
Linear Regression 1Michael Sokolov / Numerical Methods for Chemical Engineers / Linear Regression Michael Sokolov ETH Zurich, Institut für Chemie- und.
Chapter 2-OPTIMIZATION G.Anuradha. Contents Derivative-based Optimization –Descent Methods –The Method of Steepest Descent –Classical Newton’s Method.
Linear Systems of Equations Iterative and Relaxation Methods Ax = b Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und.
Mechanical Engineering Majors Authors: Autar Kaw
2/26/ Gauss-Siedel Method Electrical Engineering Majors Authors: Autar Kaw
3/6/ Gauss-Siedel Method Major: All Engineering Majors Author: دکتر ابوالفضل رنجبر نوعی
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 32.
Nonlinear Regression 1Michael Sokolov / Numerical Methods for Chemical Engineers / Nonlinear Regression Michael Sokolov ETH Zurich, Institut für Chemie-
Chapter 7. Classification and Prediction
Chapter 7 Matrix Mathematics
Linear Regression.
Lecture 11 Chemical Reaction Engineering (CRE) is the field that studies the rates and mechanisms of chemical reactions and the design of the reactors.
Gauss-Siedel Method.
Autar Kaw Benjamin Rigsby
Lecture 11 Chemical Reaction Engineering (CRE) is the field that studies the rates and mechanisms of chemical reactions and the design of the reactors.
Zero of a Nonlinear System of Algebraic Equations f(x) = 0
Numerical Analysis Lecture14.
Lecture 11 Chemical Reaction Engineering (CRE) is the field that studies the rates and mechanisms of chemical reactions and the design of the reactors.
Programming assignment #1 Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.
Numerical Analysis Lecture11.
Presentation transcript:

Boundary Value Problems and Least Squares Minimization 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 / BVP and PDE

Boundary Value Problems (BVP) for ODEs Problem definition: Find a solution for a system of ODEs Subject to the boundary conditions (BCs): The total number of BCs has to be equal to the number of equations! Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Shooting method A first approach is to transform the BVP into an initial value problem (IVP), by guessing the missing initial conditions and using the BC to refine the guess, until convergence is reached This way, the same algorithms as for IVPs can be used, but the convergence can be very problematic Too high: reduce initial velocity! Target Too low: increase initial velocity! Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Relaxation methods Relaxation methods try to find a solution that «relaxes» from the disturbance that are the initial conditions Example: Dimensionless tubular reactor The solution «relaxes» into the steady state solution Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Visualization Take a look at the discretized internal profile y yin y0 y1 y2 y3 y4 y5 yN yN+1 x L/Δx L Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Relaxation methods (continued) Therefore, we can iterate until convergence: For a first order reaction, we have a linear system With the «boundary conditions» Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Matrix formulation of the linear system If we cast the linear system into matrix form, we get Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Iterative methods Instead of simply iterating, we can use the properties of the matrix to speed up the solution The main idea is to reformulate the problem in the following way The goal is to choose S in a way that is easy to solve (e.g. diagonal, tridiagonal, triangular), but in some sense similar to A to keep ρ[S-1*(S-A)] small The iteration formula therefore reads Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Jacobi’s method The Jacobi method chooses S to be a diagonal matrix The procedure is therefore given by This method is guaranteed to converge if A is diagonally dominant, i.e. Daniel Baur / Numerical Methods for Chemical Engineers / Iterative Methods

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Collocation method A more sophisticated approach is the collocation method; it is based on approximating the unknown function with a sum of polynomials multiplied with unknown coefficients The coefficients are determined by forcing the approximated solution to satisfy the ODE at a number of points equal to the number of coefficients Matlab has a built-in function bvp4c which implements such a method Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Collocation method (continued) We require that at every point Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Transformation into a first order ODE bvp4c solves first order ODEs, so if we remember the «trick» and transform our ODE, we get And the boundary conditions Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Least squares minimization In data fitting, we generally try to solve a problem of the form where f is some model with parameters β, X are the experimental conditions and y are the results x y Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Some nomenclature In prospect of the statistics lecture, please note the differences in nomenclature! p parameters (in linear regression p = m+1) m variables (plus constant term) n measurements / data points Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Linear least squares minimization If the model f(β,X) is linear (this means that the parameters β only appear in linear terms!), we saw that the unique minimizer to the problem reads However, since XTX is much harder to solve (worse conditioned) than X, we can try to find another decomposition where Q is an orthogonal matrix (Q-1 = QT) and R is an upper triangular matrix Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Linear least squares minimization (continued) Substituing our originial problem This yields the same minimizer, but is easier to solve Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Assignment 1 Solve the steady state of the dimensionless tubular reactor using Jacobi’s method. Use Pe = 10; N = 150; Da = 1; ystart = zeros(N,1); n = 1; Define the core of the matrix A; This is easiest done using diag(): After this, change the first and the last row of A to reflect the boundary conditions and define b (see slide 6). Use A = sparse(A); and b = sparse(b); to tell Matlab that the matrices contain mostly zeros. Check with spy(A) if this is true. This will vastly speed up all calculations. Use Jacobi’s iteration formula and iterate until the change in y is smaller than 1e-8 or 1e5 iterations are exceeded. Plot the results using plot(linspace(0,1,N), y) Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Assignment 1 (continued) Solve the same steady state of the dimensionless tubular reactor using bvp4c bvp4c uses a call of the form sol = bvp4c(ode_fun, bc_fun, solinit); ode_fun is a function taking as inputs a scalar t and a vector y, returning as an output dy / dt bc_fun is a function taking as inputs vectors where the boundary conditions are evaluated, returning as output the residual at the boundary solinit is an initial guess for the solution: solinit = bvpinit(range, @initfun) sol is a struct containing the solution and other parameters Plot the solution using plot(sol.x, sol.y(1,:)) and compare with the solution from the first part. More on the usage of bvp4c on the next slide Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Usage of bvp4c In our case use the following Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Exercise 2 Find online the example files from the lecture for the linear least squares problem. We fit a linear model of the form Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Assignment 2 Run example01.m to see the results of the fit. Read through the code and ask questions if you have any. Is the model really linear, even though it contains x2? In the definition of the data matrix X on line 7, there is a vector of ones. Why is that? Check with the definition of a linear model in matrix form Note: no programming will be required for this assignment. Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Exercise 3 Find online the example files from the lecture for the non-linear least squares problem. We fit a model of the form Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Assignment 3 Run example02.m to see the results of the fitting. Read through the code and ask questions if you have any. The functions provide a Hessian and a Jacobian specific to the problem. What could be done to make a solver more general and easier to use (remember back when we implemented the Newton method!)? In what cases can the Newton method fail? In what cases can the Gauss-Newton method fail? Note: no programming will be required for this assignment. Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE