+ All Categories
Home > Documents > Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods...

Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods...

Date post: 29-Mar-2015
Category:
Upload: johnathan-shafto
View: 320 times
Download: 1 times
Share this document with a friend
Popular Tags:
22
Boundary Value Problems and Partial Differential Equations (PDEs) 1 Daniel 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 E-Mail: [email protected] http://www.morbidelli-group.ethz.ch/education/index 2 2 d (, ) d (, ) d (, ) , , ,, d d d ytz ytz ytz f ytz t z z
Transcript
Page 1: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Boundary Value Problems andPartial Differential Equations (PDEs)

2

2

d ( , ) d ( , ) d ( , ), , , ,

d d d

y t z y t z y t zf y t z

t z z

Daniel Baur

ETH Zurich, Institut für Chemie- und Bioingenieurwissenschaften

ETH Hönggerberg / HCI F128 – Zürich

E-Mail: [email protected]

http://www.morbidelli-group.ethz.ch/education/index

Page 2: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

2Daniel 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!

d ( )( , )

d

y ty f t y

t

0 0( ( ), ) 0

( ( ), ) 0f f

g y t t

h y t t

Page 3: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

3Daniel 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

Target

Too high: reduce initial velocity!

Too low: increase initial velocity!

Page 4: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

4Daniel 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

1

1

( ) ( )N

i ii

y t a P t

d( , )

d

y yf y t

t t S

Page 5: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

5Daniel 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 A Bnkn cout

2

2

( , ) nA A Aax n A

c t x c cD v k c

t x x

0 L

Page 6: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

6Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

2

2

1 nA

in

t t v

L

c u u uu Da u

c Pe z z

xzL

1

,n

n in

ax

L k cL vPe Da

D v

The numerical solution of a problem is usually much simpler if it

is dimensionless (most variables will range from 0 to 1).

Page 7: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

7Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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)

2

2

1 d d0

d dnu u

Da uPe z z

0

1

1 d( 0) 1

d

d0

d

z

z

uu z

Pe z

u

z

Page 8: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

8Daniel 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

1

12

d d

d d

y u

y uy

z z

12

22

2 12

d

d

d d d

d d dn n

yy

z

y u uPe Da u Pe y Da y

z z z

1 2

2

1( 0) 1 ( 0)

( 1) 0

y z y zPe

y z

Page 9: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

9Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

2

2

( , ) 1

( 0) 0

nu z u uDa u

Pe z zu z

Page 10: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

10Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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 categories1. B2 – AC < 0: Elliptic PDE2. B2 – AC = 0: Parabolic PDE3. 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

2 0xx xy yyAu Bu Cu

Page 11: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

11Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

Page 12: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

12Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

2

2

0

1

( , ) 1

( 0) 0

1( 0) 1

0

n

z

z

u z u uDa u

Pe z zu z

duu z

Pe dz

du

dz

Page 13: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

13Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

0 0( ) ( )d ( )

d 2

f x h f x hf x

x h

20 0 0

2 2

( ) 2 ( ) ( )d ( )

d

f x h f x f x hf x

x h

Page 14: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

14Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

2

d 21

d 2nz z z z z z z z z zz

u u u u u uDa u

Pe z z

1 1 1 12

d 21

d 1/ 2 /ni i i i i ii

u u u u u uDa u

Pe N N

2

2

( , ) 1 nu z u uDa u

Pe z z

Page 15: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

15Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

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

1 00

0

10

1

1 11 1

1 /

1 /

z

N N

u uuu

Pe z Pe z

N Pe uu

N Peu u

Page 16: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

16Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Method of Finite Differences (Continued) Rearranging the equations gives us

With the initial conditions and «boundary conditions»

2 2 21

1 1

d2

d 2 2ni

i i i i

u N N N N Nu u Da u u

Pe Pe Pe

10

1

( 0) 0, 1

1 /

1 /

i

N N

u i N

N Pe uu

N Peu u

Page 17: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

17Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Assignment 1

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-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?

Page 18: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

18Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Usage of bvp4c

bvp4c uses a call of the form sol = bvp4c(@ode_fun, @bc_fun, 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 usingsolinit = bvpinit(range, @initfun)

options is an options structure resulting fromoptions = bvpset('FJacobian', @jac_fun)

sol is a struct containing the solution and other parameters

Page 19: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

19Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Usage of bvp4c (Continued)

In our case use the following

1(1) 1 (2) ( 0)

residual(2) ( 0)

a a

b

y yPe

y

12

22 1

dd d

dd

dn

yy

y zyz

Pe y Da yz

function dy = ode_fun(t,y,...)

function res = bc_fun(ya,yb,...)

11

0 1nPe Da n y Pe

J function J = jac_fun(t,y,...)

Page 20: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

20Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Assignment 21. 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.

Page 21: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

21Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Usage of pdepe

pdepe uses the following syntax sol = pdepe(m,@pde_fun,@ic_fun,@bc_fun,xmesh,tspan);

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

, , , , , , , , ,m mu u u uc x t u x x f x t u s x t u

x t x x x

, , , , , , 0u

p x t u q x t f x t ux

Page 22: Boundary Value Problems and Partial Differential Equations (PDEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE Daniel Baur ETH.

22Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

Usage of pdepe (Continued)

In our case, use the following

2

2

( , ) 1 nu z u uDa u

Pe z z

0

1

, , , , , , 0

11 ( 0) 0

0

z

z

up x t u q x t f x t u

x

uu z

Pe z

du

dz

, , , , , , , , ,m mu u u uc x t u x x f x t u s x t u

x t x x x

4 Variable Inputs

5 Variable Inputs


Recommended