10.34: numerical methods applied to chemical engineering · the first integral can be handled with...

26
10.34: Numerical Methods Applied to Chemical Engineering Lecture 18: Differential Algebraic Equations 1

Upload: others

Post on 25-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

10.34: Numerical Methods Applied to

Chemical Engineering

Lecture 18: Differential Algebraic Equations

1

Page 2: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Quiz 1 Results• Mean: 77

Standard deviation: 12

2

0

5

10

15

20

<50 50-59 60-69 70-79 80-89 >89

Page 3: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Recap

• Numerical integration

• Implicit methods for ODE-IVPs

3

Page 4: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

4

• Improper integrals:

• Of the sort:

• Can be split into two domains of integration

• The first integral can be handled with ODE-IVP methods or polynomial interpolation

• The second must be handled separately through either:

• transformation onto a finite domain

• or substitution of an asymptotic approximation

• This same idea applies to integrable singularities as well.

Recap

Z 1

t0

f(⌧)d⌧

Z 1

t0

f(⌧)d⌧ =

Z tf

t0

f(⌧)d⌧ +

Z 1

tf

f(⌧)d⌧

Page 5: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

5

• Improper integrals:

• Example:

Recap

Z tf

0

cos ⌧p⌧

d⌧

⇡Z t0

0

1� ⌧2/2p⌧

d⌧ +

Z tf

t0

cos ⌧p⌧

d⌧

⇡ 2t1/20 � 1

5

t5/20 +

Z tf

t0

cos ⌧p⌧

d⌧

Page 6: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

6

• Example:

• Use implicit Euler to solve:

Recap

dx

dt

= �x, x(0) = x0

Give a closed form formula for the numerical solution

Page 7: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Recap• Example:

• Use implicit Euler to solve:

dx

• Let:

• Stability:

7

dt

= �x, x(0) = x0

xk = x(k�t)

xk+1 = xk +�t�xk+1

xk+1 =1

1��t�

xk

xk =

✓1

1��t�

◆k

x0

|1��t�| � 1 ) (1��tRe�)2 + (�tIm�)2 � 1

�t�

Page 8: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Recap• Example:

• Use implicit Euler to solve:

dx

• Numerical solution:

• Exact solution:

• Stability and accuracy do not correlate! 8

dt

= �x, x(0) = x0xk+1 = xk +�t�xk+1

xk+1 =1

1��t�

xk

xk =

✓1

1��t�

◆k

x0

xk = x0ek��t

�t�

Page 9: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Differential Algebraic Equations• Problems of the sort:

f

✓dx

x,

• Called “well-posed” when x, f 2 R

N

• Example: stirred tank 1

9

dt, t

◆= 0, x(0) = x0

c1(t) c2(t)dc2dt

=Q

V(c1(t)� c2(t))

c1(t) = �(t)

c1(0) = �(0), c2(0) = c0

Solution:c1(t) = �(t)c2(t) = c2(0)e

�(Q/V )t

+Q

V

Z t

0�(t0)e�(Q/V )(t�t0)dt0

( ) ( )

cc

Page 10: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Differential Algebraic Equations• Problems of the sort:

f

✓dx

x,

• Called “well-posed” when x, f 2 R

N

• Example: stirred tank 1

10

dt, t

◆= 0, x(0) = x0

c1(t) c2(t)✓

dc2dt � Q

V (c1(t)� c2(t))c1(t)� �(t)

◆= 0

✓c1(0)c2(0)

◆=

✓�(0)c0

Page 11: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Differential Algebraic Equations• Problems of the sort:

• Called “well-posed” when x,

• Example: stirred tank 2

11

f 2 R

N

f

✓x,

dx

dt, t

◆= 0, x(0) = x0

c1(t) c2(t)dc2dt

=Q

V(c1(t)� c2(t))

Solution:

c2(t) = �(t)

c1(t) = c0, c2(0) = �(0)

c2(t) = �(t)

c1(t) = �(t) +V

Q�

Page 12: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

12

• Common in dynamic simulations involving conservation, constraints, or equilibria.

• Conservation of total:

• energy

• mass

• momentum

• particle number

• atomic species

• charge

• Models of reaction networks utilizing the pseudo-steady-state approximation.

• Models of control neglecting controller dynamics.

Differential Algebraic Equations

Page 13: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

13

• Problems of the sort:

• is called the “mass matrix”

• Stirred tank example 1:

• Semi-explicit form:

• When mass matrix is full rank these problems can be solved by applying typical ODE-IVP techniques to:

Semi-explicit DAEsM

dx

dt= f(x, t), x(0) = x0

M

✓dc2dt � Q

V (c1(t)� c2(t))c1(t)� �(t)

◆= 0

✓1 00 0

◆d

dtc =

✓QV �Q

V�1 0

◆c+

✓0

�(t)

dx

dt= M

�1f(x, t)

Page 14: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Semi-explicit DAEs• Write stirred tank example 2 in semi-explicit form:

14

c1(t) c2(t) dc2dt

=Q

V(c1(t)� c2(t))

c2(t) = �(t)

Page 15: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

15

• Problems of the sort:

• is called the “mass matrix”

• Many semi-explicit DAEs can be written in the simplified form:

• where

• are called the differential states

• are called the algebraic states

Semi-explicit DAEsM

dx

dt= f(x, t), x(0) = x0

M

dx

dt= f(x,y, t)

0 = g(x,y, t)

x

y

x(0) = x0

0 = g(x0,y(0), t)

Page 16: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Fully implicit DAEs• Example: mass-spring system

• Conservation of energy:

16

E =1

2m(x)2 +

1

2kx

2

f(x, x, t) =1

2m(x)2 +

1

2kx

2 � E = 0

x = a cos(!t)

has a solution:

1

2

ma2!2sin

2(!t) +

1

2

ka2 cos2(!t) = E

! =

rk

m, a =

rE

k

Page 17: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

17

• Many problems contain non-linearities with respect to differentials of the state variables.

• If is full rank, then the DAE can be represented as an equivalent ODE:

Fully implicit DAEs

f (x, x, t) = 0, x(0) = x0

@f

@x

����t,x

df =@f

@x

����t,x

dx+@f

@x

����t,x

dx+@f

@t

����x,x

dt = 0

dx

dt= �

@f

@x

����t,x

!�1 @f

@x

����t,x

dx

dt+

@f

@t

����x,x

!= 0

Page 18: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Fully implicit DAEs• Example: mass-spring system

• Conservation of energy:

18

E =1

2m(x)2 +

1

2kx

2

f(x, x, t) =1

2m(x)2 +

1

2kx

2 � E = 0

transform to ODE

@f

@x

= mx,

@f

@x

= kx,

@f

@t

= 0

x = � k

m

x

Page 19: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

Fully implicit DAEs• Example: molecular dynamics

• Conservation of energy:

• Simplectic integrators used to integrate equations of motion while exerting control over error in the total energy.

19

E =1

2mkxk22 +

↓0 = x · (mx+rV (x))

f(x,x, t) =1

2mkxk22 + V (x)� E

df =@f

@x

����t,x

dx+@f

@x

����t,x

dx+@f

@t

����x,x

dt = 0

@f

@x= mx

V (x)

Page 20: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

20

• Consider the semi-explicit DAE:

• Consider applying the forward Euler approximation:

• Determining the algebraic states always requires solution of a nonlinear equation.

• DAE simulation methods are inherently implicit.

Numerical Simulation of DAEs

dx

dt= f(x,y, t)

0 = g(x,y, t)

x(0) = x0

x(t+�t)� x(t) = �tf(x(t),y(t), t)

0 = g(x(t),y(t), t)

Page 21: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

21

• Consider the fully implicit DAE:

• No way in general to avoid solving systems of nonlinear equations.

• Backward difference approximations for are substituted and time marching solutions determined.

• Example, backward Euler approximation:

Numerical Simulation of DAEs

f(x, x, t) = 0, x(0) = x0

x

f

✓x(tk),

x(tk)� x(tk�1)

tk � tk�1, tk

◆= 0

f

✓x(tk+1),

x(tk+1)� x(tk)

tk+1 � tk, tk+1

◆= 0

solve:

solve:

for:

for:

x(tk)

x(tk+1)

Page 22: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

22

• Consider the semi-explicit DAE:

• No way in general to avoid solving systems of nonlinear equations.

• Backward difference approximations for are substituted and time marching solutions determined.

• Example, backward Euler approximation:

Numerical Simulation of DAEs

x

solve:

dx

dt= f(x,y, t)

x(0) = x0

0 = g(x,y, t)

0 =x(tk)� x(tk�1)

tk � tk�1� f(x(tk),y(tk), tk)

0 = g(x(tk),y(tk), tk)

for:x(tk)

Page 23: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

23

• How suitable are such approaches?

• Consider stirred tank example 1:

Numerical Simulation of DAEs

dc2dt

=Q

V(c1(t)� c2(t))

c1(t) = �(t)

c1(tk) = �(tk)

c2(tk) =1

1 + QV (tk � tk�1)

✓c2(tk�1) +

Q

V(tk � tk�1)c1(tk)

Apply backward Euler method:

+O((tk � tk�1)2)

Page 24: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

24

• How suitable are such approaches?

• Consider stirred tank example 2:

Numerical Simulation of DAEs

dc2dt

=Q

V(c1(t)� c2(t))

c2(t) = �(t)

c2(tk) = �(tk)

c1(tk) = c2(tk) +V

Q

✓c2(tk)� c2(tk�1)

tk � tk�1

Apply backward Euler method:

+O(tk � tk�1)

Page 25: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

25

• How suitable are such approaches?

• Consider the system of DAEs:

Numerical Simulation of DAEs

What is the exact solution?Apply backward Euler method:

c2 = c1(t)

c3 = c2(t)

0 = c3(t)� �(t)

c3(tk) = �(tk)

c2(tk) =c3(tk)� c3(tk�1)

tk � tk�1

c1(tk) =c2(tk)� c2(tk�1)

tk � tk�1

+O(tk � tk�1)

+O(1) !

Page 26: 10.34: Numerical Methods Applied to Chemical Engineering · The first integral can be handled with ODE-IVP methods . or polynomial interpolation • The second must be handled separately

MIT OpenCourseWarehttps://ocw.mit.edu

10.34 Numerical Methods Applied to Chemical EngineeringFall 2015

For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.