22
7/24/2019 BVP_and_PDE http://slidepdf.com/reader/full/bvpandpde 1/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 fr !hemie" und Bioin#enieur$issenschaften ETH H%n##erber# & H!I '* + Zrich E"ail- daniel.baur/chem.eth0.ch htt1-&&$$$.morbidelli"#rou1.eth0.ch&education&inde2 2 2 d ( , ) d ( , ) d ( , ) , , , , d d d  y t z y t z y t z  f y t z t z  =   ÷  

BVP_and_PDE

Embed Size (px)

Citation preview

Page 1: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 1/22

Boundary Value Problems andPartial Differential Equations (PDEs)

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

Daniel Baur 

ETH Zurich, Institut fr !hemie" und Bioin#enieur$issenschaften

ETH H%n##erber# & H!I '* + Zrich

E"ail- daniel.baur/chem.eth0.ch

htt1-&&$$$.morbidelli"#rou1.eth0.ch&education&inde2

2

2

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

d d d

 y t z y t z y t z  f y t z 

t z z 

 =   ÷

 

Page 2: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 2/22

Boundary Value Problems (BVP) for 3DEs

Problem definition:

Find a solution for a system of ODEs

u!"ect to the !oundary conditions #BCs$:

%he total num!er of BCs has to !e e&ual to the num!er of

e&uations'

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

d ( )( , )

d

 y t  y f t y

t ′

= =

0 0( ( ), ) 0

( ( ), ) 0 f f  

 g y t t 

h y t t  

=

=

Page 3: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 3/22

4hootin# ethod

 ) first a**roach is to transform the BVP into an initial +alue

*ro!lem #,VP$- !y guessing the missing initial conditions

and using the BC to refine the guess- until con+ergence is

reached

%his .ay- the same algorithms as for ,VPs can !e used- !ut

the con+ergence can !e +ery *ro!lematic

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

Target

%oo high: reduce initial +elocity'

%oo lo.: increase initial +elocity'

Page 4: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 4/22

!ollocation ethod

 ) more so*histicated a**roach is the collocation method0

it is !ased on a**roimating the un2no.n function .ith a

sum of *olynomials multi*lied .ith un2no.n coefficients

%he coefficients are determined !y forcing the

a**roimated solution to satisfy the ODE at a num!er of

*oints e&ual to the num!er of coefficients Matla! has a !uilt3in function bvp4c .hich im*lements this

method0 it can also sol+e singular +alue *ro!lems

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

1

1

( ) ( ) N 

i i

i

 y t a P t +

== ∑

d( , )

d

 y y f y t 

t t 

= +S

Page 5: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 5/22

E2am1le of a BVP

Consider a tu!ular reactor 

5e can model it as a *lug flo. reactor #PF6$ .ith !ac23

miing !y using the follo.ing *artial differential e&uation

Da2 is the #effecti+e$ aial dis*ersion coefficient 7m(/s8-

5 is the linear flo. +elocity 7m/s8 and n is the reaction order 9Daniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

cin cout

;

A Bnk n    →

2

2

( , )   n A A Aax n A

c t x c c D v k c

t x x

∂ ∂ ∂= − −∂ ∂ ∂

Page 6: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 6/22

Tubular 6eactor- Dimensionless 'orm

;et us cast the model in dimensionless form !y defining

5here Pe is the Peclet and Da is the Dam2<hler num!er 

=Daniel 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).

2

21   n A

in

t t v

 L

c   u u uu Da uc Pe z z  

 x z 

 L

τ  

×Θ = =

∂ ∂ ∂= ⇒ = − − ×∂Θ ∂ ∂

=

( )  1

,

n

n in

ax

 L k c L v Pe Da

 D v

−× ××= =

Page 7: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 7/22

4teady 4tate 7ssum1tion, Boundary !onditions

By assuming steady state- the time +aria!le +anishes and

.e get an ODE

%his e&uation is su!"ect to the Danc2.erts BCs #mass

!alance o+er inlet- continuous *rofile at the outlet$

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

2

2

1 d d0

d d

nu u Da u

 Pe z z 

= − − ×

0

1

1 d( 0) 1 d

d0

d

 z 

 z 

uu z   Pe z 

u

 z 

=

=

= = + ×

=

Page 8: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 8/22

Transformation into a first order 3DE

bvp4c sol+es first order ODEs- so if .e remem!er the

?tric2@ and transform our ODE- .e get

 )nd the !oundary conditions

ADaniel Baur / Numerical Methods for Chemical Engineers / BVP and PDE

1

12

d d

d d

 y u

 y u y

 z z 

=

=B( )

12

2

22 12

d

dd   d d

d d d

n n

 y y

 z  y   u u

 Pe Da u Pe y Da y z z z 

=

 = = × + × = × + × ÷  

1 2

2

1( 0) 1 ( 0)

( 1) 0

 y z y z  Pe

 y z 

= = + × =

= =

Page 9: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 9/22

Partial Differential Equations

Problem definition:

,n a *artial differential e&uation #PDE$- the solution

de*ends on more than one inde*endent +aria!le- eg

s*ace and time %he function is usually su!"ect to !oth inital conditions and

!oundary conditions

,n our eam*le

*lus the Danc2.erts BCs .hich a**ly at all times

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

2

2( , ) 1

( 0) 0

nu z u u  Da u Pe z z 

u z 

∂ Θ ∂ ∂= − − ×∂Θ ∂ ∂Θ = = ∀

Page 10: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 10/22

!haracteri0ation of 4econd 3rder PDEs

econd order PDEs ta2e the general form

.here 7- B and ! are coefficients that may de*end on 2 and y

%hese PDEs fall in one of the follo.ing categories

1 B(  )C : Elli*tic PDE

( B(  )C : Para!olic PDE

B(  )C G : Hy*er!olic PDE

%here are s*ecialiIed sol+ers for some ty*es of PDEs-

hence 2no.ing its category can !e useful for sol+ing a PDE

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

2 0 xx xy yy Au Bu Cu+ + + =K 

Page 11: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 11/22

8umerical 4olution of PDEs

,n general- it can !e +ery difficult to sol+e PDEs numerically

One a**roach is to discretiIe all !ut one dimension of the

solution0 this .ay a system of ODEs is o!tained that can !e

sol+ed more easily Note that these ODE systems are usually +ery stiff 

%here are different .ays of discretiIing a dimension- for

eam*le the collocation method .e sa. earlier 

o*histicated algorithms refine the discretiIation in *laces.here the solution is still inaccurate

Matla! has a !uilt3in sol+er for *ara!olic and elli*tic PDEs

in t.o dimensions- pdepe

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

Page 12: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 12/22

9nsteady 4tate Tubular 6eactor 

;et us consider the start3u* of a tu!ular reactor- ie

5e can easily see that this is al.ays a *ara!olic PDE

#B C $- hence the Matla! sol+er is a**lica!le

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

2

2

0

1

( , ) 1

( 0) 0

1( 0) 1

0

n

 z 

 z 

u z u u Da u

 Pe z z 

u z 

duu z 

 Pe dz 

du

dz 

=

=

∂ Θ ∂ ∂= − − ×

∂Θ ∂ ∂

Θ = = ∀

= = + × ∀Θ

= ∀Θ

Page 13: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 13/22

ethod of 'inite Differences

5e can a**ly the so3called finite differences method- if .e

remem!er numerical differentiation

 )lso- .e can easily deri+e a similar e*ression for the

second order deri+ati+e

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

0 0( ) ( )d ( )

d 2

 f x h f x h f x

 x h

+ − −;

2

0 0 02 2

( ) 2 ( ) ( )d ( )d

 f x h f x f x h f x x h

+ − + −;

Page 14: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 14/22

ethod of 'inite Differences (!ontinued)

%he PDE for the start3u* of the tu!ular reactor reads

 )**lying the method of finite differences- .e get

.here JI 1/N is the discretiIation ste*- N !eing thenum!er of grid *oints

,f .e num!er the grid *oints .ith i 1N- .e get

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

2

d 21

d 2

n z z z z z z z z z z  z 

u u u u u u Da u

 Pe z z 

+∆ −∆ +∆ −∆− + −= − − ×

Θ ∆ ∆

1 1 1 1

2

d 21

d 1 / 2 /

ni i i i i ii

u u u u u u Da u

 Pe N N 

+ − + −− + −= − − ×

Θ

2

2

( , ) 1   nu z u u Da u

 Pe z z 

∂ Θ ∂ ∂= − − ×

∂Θ ∂ ∂

Page 15: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 15/22

ethod of 'inite Differences (!ontinued)

5hat ha**ens at the !oundaries u1 and uNK

One *ossi!ility is to in+ent *seudo grid3*oints u and uNL1 

that fulfill the !oundary conditions

,n our case

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

( )

( )

1 0

0

0

1

0

1

1 11 1

1 /

1 /

 z 

 N N 

u uuu

 Pe z Pe z 

 N Pe u

u  N Pe

u u

=

+

−∂= + = +

∂ ∆

+ ×= +=

Page 16: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 16/22

ethod of 'inite Differences (!ontinued)

6earranging the e&uations gi+es us

5ith the initial conditions and ?!oundary conditions@

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

2 2 21

1 1

d2

d 2 2

nii i i i

u   N N N N N  u u Da u u

 Pe Pe Pe

−+ −

 = − + − − × + + ÷ ÷ ÷Θ    

( )1

0

1

( 0) 0, 1

1 /

1 /

i

 N N 

u i N 

 N Pe uu

 N Pe

u u+

Θ = = =

+ ×=

+

=

Page 17: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 17/22

7ssi#nment

1 ol+e the dimensionless tu!ular reactor using bvp4c for

9 different +alues of the Peclet num!er !et.een 1 and

1 and for a reaction of first and second order 

,n !oth cases use Da 1( Plot the con+ersion at the end of the reactor #13c )/cin$ +s

Peclet for !oth reaction orders0 )lso *lot the ratio !et.een

the con+ersions of the first order and second order

reaction 5hat is !etter for these reactions- a lot of !ac23miing #Pe small-

C%6$ or ideal *lug flo. #Pe large- PF6$K

5hat influence does the reaction order ha+e o+erall and at lo. or

high Peclet num!ersK

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

Page 18: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 18/22

9sa#e of bvp4c

bvp4c uses a call of the form sol = bvp4c(@ode_fun, @bc_fun, solinit, options);

ode:fun is a function ta2ing as in*uts a scalar t and a +ector y-

returning as an out*ut dy & dt

bc:fun is a function ta2ing as in*uts +ectors .here the !oundary

conditions are e+aluated- returning as out*ut the residual at the

!oundary

solinit initialiIes the solution !y using

solinit = bvpinit(range, @initfun)

o1tions is an o*tions structure resulting from

options = bvpset('FJacobian', @jac_fun)

sol is a struct containing the solution and other *arameters

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

Page 19: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 19/22

9sa#e of bvp4c (!ontinued)

,n our case use the follo.ing

1Daniel 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,)

1(1) 1 (2) ( 0)

residual

(2) ( 0)

a a

b

 y y Pe

 y

− − × ==    =

( )

12

22 1

d

d   d

dd

d

n

 y y

 y   z 

 y z  Pe y Da y

 z 

==    = × + ×

1

1

0 1n Pe Da n y Pe−

=  × × ×

J

Page 20: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 20/22

7ssi#nment

1 se pdepe to sol+e the startu* of the tu!ular reactor Consider only the first order reaction .ith Pe 1 and Da 1

Plot the con+ersion at the end of the reactor +s dimensionless time

 )t .hat time does the solution reach steady state- ie ho. many

reactor +olumes of sol+ent .ill you needK Com*are the solution to.hat you ha+e found in assignment 1- if the difference is smaller

than 1- assume that steady state has !een reached

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

Page 21: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 21/22

9sa#e of pdepe

pdepe uses the follo.ing synta sol =

pdepe(!,@pde_fun,@ic_fun,@bc_fun,"!es#,tspan);

m is a *arameter that descri!es the symmetry of the *ro!lem #sla!

- cylindrical 1- s*herical ($0 in our case sla!- so m

@pde_fun is a function that descri!es the PDE in this form:

@ic_fun is a function that ta2es as in*ut a +ector 2 and returns the

initial conditions at t ; <

@bc_fun is a function that descri!es the !oundary conditions- ta2ing

as an in*ut 2l- ul- 2r - ur  and t- returning the BCs in a form:

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

, , , , , , , , ,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 u x

∂  + = ÷∂  

Page 22: BVP_and_PDE

7/24/2019 BVP_and_PDE

http://slidepdf.com/reader/full/bvpandpde 22/22

9sa#e of pdepe (!ontinued)

,n our case- use the follo.ing

4 Varia!le ,n*uts

9 Varia!le ,n*uts

2

2

( , ) 1   nu z u u Da u

 Pe z z 

∂ Θ ∂ ∂

= − − ×∂Θ ∂ ∂

( ) ( )

0

1

, , , , , , 0

11 ( 0) 0

0

 z 

 z 

u p 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

−∂ ∂ ∂ ∂ ∂  = + ÷ ÷ ÷ ÷∂ ∂ ∂ ∂ ∂