Presentation is loading. Please wait.

Presentation is loading. Please wait.

Boundary Value Problems and Partial Differential Equations (PDEs)

Similar presentations


Presentation on theme: "Boundary Value Problems and Partial Differential Equations (PDEs)"— Presentation transcript:

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

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

3 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

4 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 this method; it can also solve singular value problems Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

5 Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE
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 Dax is the (effective) axial dispersion coefficient [m2/s], v is the linear flow velocity [m/s] and n is the reaction order cin cout L Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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 The numerical solution of a problem is usually much simpler if it is dimensionless (most variables will range from 0 to 1). Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

8 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

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 Daniel 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 B2 – AC < 0: Elliptic PDE B2 – AC = 0: Parabolic PDE B2 – AC > 0: Hyperbolic PDE There are specialized solvers for some types of PDEs, hence knowing its category can be useful for solving a PDE Daniel 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 Matlab has a built-in solver for parabolic and elliptic PDEs in two dimensions, pdepe Daniel 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 Daniel 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 Daniel 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 Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

15 Method of Finite Differences (Continued)
What happens at the boundaries u1 and uN? One possibility is to invent pseudo grid-points u0 and uN+1 that fulfill the boundary conditions In our case Daniel 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» Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

17 Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE
Assignment 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 Plot the conversion at the end of the reactor (1-cA/cin) 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? Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

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

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

21 Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE
Usage of pdepe pdepe uses the following syntax sol = m is a parameter that describes the symmetry of the problem (slab = 0, cylindrical = 1, spherical = 2); in our case slab, so m = 0 @pde_fun is a function that describes the PDE in this form: @ic_fun is a function that takes as input a vector x and returns the initial conditions at t = 0 @bc_fun 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 Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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


Download ppt "Boundary Value Problems and Partial Differential Equations (PDEs)"

Similar presentations


Ads by Google