1 / 14

Solution of Nonlinear Functions

Solution of Nonlinear Functions. 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 . Zero of a Nonlinear Function. Problem definition :

ama
Download Presentation

Solution of Nonlinear Functions

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. Solution of Nonlinear Functions Daniel BaurETH Zurich, Institut für Chemie- und BioingenieurwissenschaftenETH Hönggerberg / HCI F128 – ZürichE-Mail: daniel.baur@chem.ethz.chhttp://www.morbidelli-group.ethz.ch/education/index Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  2. Zero of a Nonlinear Function • Problem definition: • Find the solution of the equation f(x) = 0for scalar valued f and x; Look for the solution either in • An interval, generally –∞ < x < ∞ • In the uncertainty interval [a, b], where f(a)f(b) < 0 • Types of algorithms available: • Bisection method • Substitution methods • Methods based on function approximation • Assumptions: • In the defined intervals, at least one solution exists • We are looking for one solution, not all of them Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  3. Bisection Method • Define starting interval [a,b] (check that f(a)f(b) < 0) • Compute x0 = mean(a, b) • Redefine the interval • Set either a = x0 or b = x0 so that f(a)f(b) < 0 is still fulfilled • Iterate 2 and 3 until the requestedprecision is reached • Advantages • After n iterations, the interval is reducedby 2n • Final precision can be predicted a priori • Disadvantages • Function characteristics are not usedto speed up the algorithm b a a x0 Daniel Baur / Numerical Methods for Chemical Engineers / Numerical Quadrature

  4. Substitution Methods • Formulate the function in a way that can be iterated, e.g. • Disadvantages • Needs simple functions • Often diverges(even with linear functions) • Requires a preliminarystudy to assureconvergence Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  5. Newton Method • The Newton method is based on Taylor expansion • Advantages • It has 2nd order convergence • Disadvantages • Convergence is not guaranteedeven if the uncertainty intervalis known • If the derivative must becalculated numerically, the secant method is more convenient x1 x0 Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  6. x0 = 1.8 x1 = 1.7 Secant Newton Secant Method • The Secant is based on the same principles as the Newton method, but it approximates the derivative numerically • Advantages • Does not require the analyticalfirst order derivative • Disadvantages • Convergence is not assuredeven if the uncertainty intervalis known • Convergence order is only 1.618 Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  7. How does Matlab do it? Nonlinear Functions • fzero finds the zero of a scalar valued function; It uses a combination of bisection, secant, and inverse quadratic interpolation methods • roots finds all the roots of a polynomial function;It computes the eigenvalues of the companion matrix, which correspond to the roots of the polynomial • A = diag(ones(n-1,1),-1);A(1,:) = -c(2:n+1)./c(1);eig(A); • Where c is the vector of the polynomial coefficients Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  8. Matlab Syntax Hints • x = fzero(@fun, x0); • @fun is a function taking as input a scalar x, returning as output the scalar function value f(x) • x0 is either an initial guess (if it has length 1) or an uncertainty interval (if it has length 2, then f(x0(1))f(x0(2)) < 0 must be fulfilled) • x = roots(c); • c is a vector containing the polynomial coefficients in the order Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  9. Exercise: CSTR Multiple Steady States • Consider a CSTR where a reaction takes place • We assume the following • V = const., i.e. Qin = Qout = const. • Perfect coolant behavior, i.e. TC,in = TC,out = const. • Constant density and heat capacity of the reaction mixture • Constant reaction enthalpy • Constant feed, i.e. cA,in = const., Tin = const. Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  10. CSTR Mass and Energy Balances • The mass and energy balances read • With the T-dependent reaction rate constant Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  11. Dimensionless Mass and Energy Balances • If we define • We get a dimensionless form Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  12. CSTR Temperature Equilibrium • The steady state concentration of A reads • The temperature in steady state is therefore given by Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  13. Assignment • Plot the total heat flow from and to the reactor vs. the dimensionless reactor temperature • Use α = 49.46; κ0 = 2.17e20; KC = 0.83; η = 0.33 and θC = 0.9. • Which are the attracting (stable) and which are the repelling (unstable) solutions? • What happens to the system when you change the coolant temperature? • Try θC = 0.8 and θC= 1. • How many different steady states do you get in each case? Are the solutions stable or unstable (attracting or repelling)? Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

  14. Assignment (Continued) • Implement and use the bisection method to find the three steady state temperatures of the CSTR, using the parameters from task 1. • Implement and use the secant method to find the three steady state temperature of the CSTR. • The secant method uses two starting guesses; provide a θstart,1 and from this, calculate θstart,2 = (1+ε)*θstart,1. Suggest a value for ε (not too small). • In what range of θstart can you converge to the intermediate solution? • If we look at the Newton Method as a perfect Secant Method (analytical gradient!), we can find a maximum possible range where the intermediate solution can be found. How would you do that? Note the directions of the analytical gradients! Daniel Baur / Numerical Methods for Chemical Engineers / Nonlinear Equations

More Related