Download presentation
Presentation is loading. Please wait.
Published byElla Short Modified over 9 years ago
1
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers 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
2
Some repetition Taylor expansion (linearization): In multiple dimensions: Inequalities with absolute values Convergence of linear loops converges if Spectral radius of compound matrices 2Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
3
Stiffness of non-linear problems There exist some methods to predict stiffness of a problem, but only for linear problems, e.g. large stiffness ratio, or different time scales of solution behaviors: 3Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
4
Stiffness of non-linear problems If we have a non-linear problem, one approach is to linearize it and look at the resulting linear problem 4Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
5
Solver tolerances As mentioned last time, sophisticated solvers adapt their step size (and sometimes their order) to fulfill certain criteria on the error estimation In Matlab, the error is estimated at every time point and it has to fulfill |e(i)| ≤ max(RelTol*abs(y(i)),AbsTol(i)) The defaults ( RelTol = 1e-3, AbsTol = 1e-6 ) can be adjusted with the commands options = odeset('abstol',1e-8,'reltol',1e-9); [T,Y] = ode45(@odefun,tSpan,y0,options); 5Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
6
Assignment 1 1.Find the stability region for the second order Heun method (by hand) The second order Heun method reads Use a linear, constant coefficient ODE as test system, i.e. Find an expression of the form abs(...) < 1 that guarantees stability if it is fulfilled 6Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
7
Assignment 1 (continued) 2.Try to use the definition of the complex absolute value to find an expression that does not contain the absolute value operators and use the function stability_region (given online) to plot the stability region. The easiest approach is to substitute a complex number w for h* λ max, defined as w = a + b*i, and then applying the definition of the complex absolute value: Note that for this, you will have to multiply out the square of w (remember that i 2 = -1). Before you resolve the absolute value, bring the complex number into standard form c + d*i 7Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
8
Exercise 2 Consider the following chemical reactions in a batch reactor: 8Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
9
Assignment 2 1.Solve the batch reactor and plot the solutions Use k1 = 1000; k2 = 0.1; y0 = [1, 0.1] and tSpan = [0,1]; Do you expect the system to be stiff? Use the linearization method to check the stiffness ratio at y = y0 (by hand), by calculating the eigenvalues of the Jacobian of the system Use ode45 to solve the system and plot the solutions. Is it stiff? Looking at the Jacobian, can you say why? Note how y changes and how it changes the Jacobian and its eigenvalues! 9Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
10
Exercise 3 The van der Waals equation for some non-ideal gas reads Taking the derivative, we get 10Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
11
Assignment 3 1.Plot the van der Waals equation for 1000 points between V = 0.34 and V = 4 2.Try to approximate the equation by solving the ODE Use ode45, tSpan = [0.34, 4]; and y0 = P(0.34) ; Note that the ODE does not depend on the solution, but only the independent variable (i.e. the first input into your odefun!) Plot the solution of the ODE together with the analytical solution and zoom in to ylim([0, 2]). What do you observe? Try the same with ode15. What do you observe when you zoom in? 3.Plot dP/dV against V in the range we considered. What might be the problem with the solvers, considering what they have to do in the slope field? 4.Tighten both tolerances to 1e-9. Plot the solutions again and zoom in to ylim([0,2]). 11Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.