Download presentation

Presentation is loading. Please wait.

Published byJohnathan Shafto Modified over 2 years ago

1
Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH Zurich, Institut für Chemie- und Bioingenieurwissenschaften ETH Hönggerberg / HCI F128 – Zürich

2
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! 2Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

3
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 3Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Target Too high: reduce initial velocity! Too low: increase initial velocity!

4
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 bvp4c Matlab has a built-in function bvp4c which implements this method; it can also solve singular value problems 4Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

5
Example of a BVP Consider a tubular reactor We can model it as a plug flow reactor (PFR) with back- mixing by using the following partial differential equation D ax is the (effective) axial dispersion coefficient [m 2 /s], v is the linear flow velocity [m/s] and n is the reaction order 5Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE c in c out 0L

6
Tubular Reactor: Dimensionless Form Let us cast the model in dimensionless form by defining Where Pe is the Peclet and Da is the Damköhler number 6Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE The numerical solution of a problem is usually much simpler if it is dimensionless (most variables will range from 0 to 1).

7
Steady State Assumption, Boundary Conditions By assuming steady state, the time variable vanishes and we get an ODE This equation is subject to the Danckwerts BCs (mass balance over inlet, continuous profile at the outlet) 7Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

9
Partial Differential Equations Problem definition: In a partial differential equation (PDE), the solution depends on more than one independent variable, e.g. space and time The function is usually subject to both inital conditions and boundary conditions In our example plus the Danckwerts BCs which apply at all times 9Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

10
Characterization of Second Order PDEs Second order PDEs take the general form where A, B and C are coefficients that may depend on x and y These PDEs fall in one of the following categories 1.B 2 – AC < 0: Elliptic PDE 2.B 2 – AC = 0: Parabolic PDE 3.B 2 – AC > 0: Hyperbolic PDE There are specialized solvers for some types of PDEs, hence knowing its category can be useful for solving a PDE 10Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

11
Numerical Solution of PDEs In general, it can be very difficult to solve PDEs numerically One approach is to discretize all but one dimension of the solution; this way a system of ODEs is obtained that can be solved more easily Note that these ODE systems are usually very stiff There are different ways of discretizing a dimension, for example the collocation method we saw earlier Sophisticated algorithms refine the discretization in places where the solution is still inaccurate pdepe Matlab has a built-in solver for parabolic and elliptic PDEs in two dimensions, pdepe 11Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

12
Unsteady State Tubular Reactor Let us consider the start-up of a tubular reactor, i.e. We can easily see that this is always a parabolic PDE (B = C = 0), hence the Matlab solver is applicable 12Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

13
Method of Finite Differences We can apply the so-called finite differences method, if we remember numerical differentiation Also, we can easily derive a similar expression for the second order derivative 13Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

14
Method of Finite Differences (Continued) The PDE for the start-up of the tubular reactor reads Applying the method of finite differences, we get where Δz = 1/N is the discretization step, N being the number of grid points If we number the grid points with i = 1...N, we get 14Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

15
Method of Finite Differences (Continued) What happens at the boundaries u 1 and u N ? One possibility is to invent pseudo grid-points u 0 and u N+1 that fulfill the boundary conditions In our case 15Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

16
Method of Finite Differences (Continued) Rearranging the equations gives us With the initial conditions and «boundary conditions» 16Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

17
Assignment 1 bvp4c 1.Solve the dimensionless tubular reactor using bvp4c for 50 different values of the Peclet number between 0.01 and 100 and for a reaction of first and second order In both cases use Da = 1 2.Plot the conversion at the end of the reactor (1-c A /c in ) vs. Peclet for both reaction orders; Also plot the ratio between the conversions of the first order and second order reaction What is better for these reactions, a lot of back-mixing (Pe small, CSTR) or ideal plug flow (Pe large, PFR)? What influence does the reaction order have overall and at low or high Peclet numbers? 17Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

18
bvp4c Usage of bvp4c bvp4c bvp4c uses a call of the form sol solinit, options); sol solinit, options); 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 = solinit initializes the solution by using solinit = options = options is an options structure resulting from options = sol is a struct containing the solution and other parameters 18Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

19
bvp4c Usage of bvp4c (Continued) In our case use the following 19Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE function dy = ode_fun(t,y,...) function res = bc_fun(ya,yb,...) function J = jac_fun(t,y,...)

20
Assignment 2 pdepe 1.Use pdepe to solve the startup of the tubular reactor. Consider only the first order reaction with Pe = 100 and Da = 1. Plot the conversion at the end of the reactor vs. dimensionless time. At what time does the solution reach steady state, i.e. how many reactor volumes of solvent will you need? Compare the solution to what you have found in assignment 1, if the difference is smaller than 0.1%, assume that steady state has been reached. 20Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

21
pdepe Usage of pdepe pdepe pdepe uses the following syntax sol = sol = m is a parameter that describes the symmetry of the problem (slab = 0, cylindrical = 1, spherical = 2); in our case slab, so m is a function that describes the PDE in is a function that takes as input a vector x and returns the initial conditions at t is a function that describes the boundary conditions, taking as an input xl, ul, xr, ur and t, returning the BCs in a form: that is, pl, ql, pr and qr 21Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

22
pdepe Usage of pdepe (Continued) In our case, use the following 22Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE 4 Variable Inputs 5 Variable Inputs

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google