baigiang_mophong

Upload: anh-duc

Post on 04-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 Baigiang_MoPhong

    1/46

    Phn 2: m phng my tnhModeling, simulation and optimization for chemical process

    Instructor: Hoang Ngoc Ha

    Email: [email protected]

    B mn QT&TB

  • 7/29/2019 Baigiang_MoPhong

    2/46

    Introduction

    Numerical

    Analysis

    Computer

    Programming

    SIMULATION

  • 7/29/2019 Baigiang_MoPhong

    3/46

    Computer simulation

    Some simulation techniques for solving some

    of the systems of equations Solution of (nonlinear) algebraic equations

    Ordinary differential equations (ODEs)

    Partial differential equations (PDEs)

    Numerical methods

    Iterative methods Discrete difference methods

    Femlab, Fortran, Ansys Matlab/Simulink

  • 7/29/2019 Baigiang_MoPhong

    4/46

    Computer simulation

    Computer programming

    Assume that you know some computerprogramming language

    We are not interested in generating the most

    efficient and elegant code but in solving problems(from point of view of engineers) Including extensive comment statements

    Use of symbols (the same ones in the equations

    describing the systems) Debugging (for mistakes in coding and/or in logic)

  • 7/29/2019 Baigiang_MoPhong

    5/46

    Computer simulation

    Example:

  • 7/29/2019 Baigiang_MoPhong

    6/46

    Computer simulation

  • 7/29/2019 Baigiang_MoPhong

    7/46

    Computer simulation

  • 7/29/2019 Baigiang_MoPhong

    8/46

    Computer simulation

    Interval halving (chia i khong)

  • 7/29/2019 Baigiang_MoPhong

    9/46

    Computer simulation

    This problem can be formulated under the

    following form:

    The goal is to find the solution of thisnonlinear equations (in ONE VARIABLE)

    Tools (Iterative methods) Bisection method (phng php phn on)

    Newtons (or Newton-Raphson) method

    f(x) = 0, x R

  • 7/29/2019 Baigiang_MoPhong

    10/46

    Iterative method

    Intermediate value theorem Iffis a real-valued continuous function on the

    interval [a, b], and u is a number between f(a) and

    f(b), then there is a such that f(c) = uc [a, b]

    Iff(a) and f(b) are of opposite sign, there exist a numberp in [a, b] with f(p)=0

  • 7/29/2019 Baigiang_MoPhong

    11/46

    Iterative method Bisection method

    Computer programming: Matlab

  • 7/29/2019 Baigiang_MoPhong

    12/46

    Iterative method Newtons method

    Numerical solutions of nonlinear systems of equations (ofSEVERAL VARIABLES) (See Ref.)

  • 7/29/2019 Baigiang_MoPhong

    13/46

    Computer simulation

    Interpolation and polynomial approximation

    Interpolation and the Lagrange polynomial Cubic spline interpolation

    Numerical differentiation and intergration

    Numerical differentiation

    Richardsons extrapolation

    (See Ref.)

  • 7/29/2019 Baigiang_MoPhong

    14/46

    Numerical intergration of OrdinaryDifferential Equations (ODEs)

  • 7/29/2019 Baigiang_MoPhong

    15/46

    Numerical intergration of OrdinaryDifferential Equations (ODEs)

    y(t)

    ttN

    x

    y(tN)x

    t0

    y(t0)x

    t1

    y(t1)

    Interpolation

  • 7/29/2019 Baigiang_MoPhong

    16/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs) Tools:

    Eulers method

    Higher-Order Taylor methods

    Runge-Kutta methods

  • 7/29/2019 Baigiang_MoPhong

    17/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs) Eulers method

  • 7/29/2019 Baigiang_MoPhong

    18/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs) Eulers method

  • 7/29/2019 Baigiang_MoPhong

    19/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs) Example

    Exact solution?

    y(t) = 0.5exp(t) + (t + 1)2

    P/p Eulern=10?

    y0 = y t2 + 1, t [0 2]y(0) = 0.5

    Approximate solution?

    n = 10 h = ban

    = 0.2

    Computer programming: Matlab

  • 7/29/2019 Baigiang_MoPhong

    20/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs) Local truncation error

    The local truncation error in Eulers method is O(h)

    Definition

  • 7/29/2019 Baigiang_MoPhong

    21/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs) Higher-Order Taylor methods

  • 7/29/2019 Baigiang_MoPhong

    22/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs) Higher-Order Taylor methods

  • 7/29/2019 Baigiang_MoPhong

    23/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs) Runge-Kutta methods

  • 7/29/2019 Baigiang_MoPhong

    24/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs) Runge-Kutta methods

    Xy dng cng thc tnh theo m khngphi o hm tay , cn xp x m khngdng o hm vi

    Minh ha qua k=2

    wi+1 wiT(k)

    O(hk)

    f(t, y)

    T(2)(t, y) = f(t, y) + h2

    f0(t, y)

    f0

    (t, y) = f0

    t(t, y) + f0

    y(t, y)y0

    (t)

  • 7/29/2019 Baigiang_MoPhong

    25/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs)Nh vy

    Cn tm vi sai s a1, 1, 1

    a1f(t + 1, y + 1) ' T(2)(t, y)

    O(h2

    )

    T(2)(t, y) = f(t, y) + h2

    f0t(t, y) +h2

    f0y(t, y)f(t, y)

    f(t + 1, y + 1) ' f(t, y) + f0t(t, y)1+f0y(t, y)1

  • 7/29/2019 Baigiang_MoPhong

    26/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs)Cn chn

    ng nht hai v

    a1f(t, y) + a11f0

    t(t, y) + a11f0

    y(t, y) =f(t, y) + h2 f

    0

    t(t, y) +h2 f

    0

    y(t, y)f(t, y)

    a1 = 1

    a11 =h

    2a11 =

    h2

    f(t, y)

    a1 = 11

    = h21 =h2

    f(t, y)

  • 7/29/2019 Baigiang_MoPhong

    27/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs)

    S trung im (R_K bc 2)

    wi+1 = wi + hT(2)(ti, wi)

    wi+1 = wi + hh

    f(ti +h2

    , wi +h2

    f(ti, wi))i

    w0 = k1 =

    h

    2

    f(ti, wi)k2 = hf(ti + h2 , wi + k1)wi+1 = wi + k2

    Computer programming: Matlab

  • 7/29/2019 Baigiang_MoPhong

    28/46

    Numerical intergration of Ordinary

    Differential Equations (ODEs)S R_K bc 4

    w0 = k1 = hf(ti, wi)

    k2 = hf(ti + h2 , wi + k12 )k3 = hf(ti +

    h2

    , wi +k22

    )

    k4 = hf(ti + h, wi + k3)wi+1 = wi +16 (k1 + 2k2 + 2k3 + k4)

    V nh tc R_K cho h v vit chng trnh R_K cho h

  • 7/29/2019 Baigiang_MoPhong

    29/46

    Numerical intergration of Partial

    Differential Equations (PDEs) Click here

  • 7/29/2019 Baigiang_MoPhong

    30/46

    Gii thiu chung

    u = u(x . . . , t)mt i lng vt l ca h kho st

    n chemical species

    Inlet material and/orenergetic flux

    Outlet material

    and/or energetic flux

    Pk kSk = 0

    dV

    {C, T . . . } H PHN BProfile

    Local observation

  • 7/29/2019 Baigiang_MoPhong

    31/46

    Ba dng phng trnh o hm ring c

    bnng hc bin h thng c

    th thuc v cc dng phng trnh sau:

    u = u(x . . . , t)

    Phng trnh elliptic (tnh-static)2u

    x2 +

    2u

    y2 = f(x, y)

    P/t parabolic (b/ton truyn nhit)ut

    = a2 2u

    x2

    Phng trnh hyperbolic (b/ton truyn sng)2u

    t2= a2

    2ux2

  • 7/29/2019 Baigiang_MoPhong

    32/46

    Ba dng phng trnh o hm ring c

    bn Phng php tm nghim

    Phng php gii tch Phng php s

    tng: xp x sai phn cc o hm ring ti cc im ri rc (kg,tg)

    v tnh gi tr ca ti u = u(x . . . , t)

    u(x,t)t

    u(x,t+t)u(x,t)

    t

    x

    t

    (x, t)

    (x,t + t)t

    u(x, t)

  • 7/29/2019 Baigiang_MoPhong

    33/46

    Xp x sai phn

    2u(x,t)x2

    u(x+x,t)2u(x,t)+u(xx,t)

    (x)2

    (x, t)

    (x +x, t)(xx, t)

    t

    x

    x

  • 7/29/2019 Baigiang_MoPhong

    34/46

    Xp x sai phn

    x

    y

    P1

    P = (x, y)

    x P

    y P3

    P2

    P4

    2u(P)x2

    + 2u(P)y2

    u(P1)+u(P2)+u(P3)+u(P4)4u(P)

    h2

    h = x = y

  • 7/29/2019 Baigiang_MoPhong

    35/46

    BI TON ELLIPTIC

    Bi ton elliptic vi iu kin bin Dirichlet(u =

    2ux2

    + 2u

    y2= f(x, y), (x, y) R2

    u(x, y) = g(x, y), (x, y)

  • 7/29/2019 Baigiang_MoPhong

    36/46

    BI TON ELLIPTIC

    Phn hoch v to li : chia nh bi

    cc ng thng // vi Oxv Oy

    h = x = y

    To li bc chia cch u

    K hiu P1,P2, P3v P4 l 4

    im ri rc x/q P

    u(P) u(P1)+u(P2)+u(P3)+u(P4)4u(P)h2

    Ln lt thay vo phng trnh elliptic, s

    dng cng thc xp x& iu kin bin

    Pk = (xk, yk)H PTTT n uk = u(Pk)

  • 7/29/2019 Baigiang_MoPhong

    37/46

    BI TON ELLIPTIC

    Example

    Li 4 nt n nh s 4 gi tr cn tm. SD PTSP & Gi tr trn bin H PTTT

    M phng Matlab

  • 7/29/2019 Baigiang_MoPhong

    38/46

    BI TON PARABOLIC (m hnh

    truyn nhit)

  • 7/29/2019 Baigiang_MoPhong

    39/46

    BI TON PARABOLIC (m hnh

    truyn nhit)

  • 7/29/2019 Baigiang_MoPhong

    40/46

    Mc th k: t = kt

    Mc th 0: bitu(0)Mc th 1: cha bitu(1)

    BI TON PARABOLIC (m hnh

    truyn nhit) Phn hoch v xp x

    Chia cch u bc vx

    t

    u(k) = (. . . uki . . . )

    Xp xo hm ring cp 1: TIN - LIu(x,t)t

  • 7/29/2019 Baigiang_MoPhong

    41/46

    BI TON PARABOLIC (m hnh

    truyn nhit) V d

    S hin (s/p tin) S n (s/p li)

  • 7/29/2019 Baigiang_MoPhong

    42/46

    BI TON PARABOLIC (m hnh

    truyn nhit tng qut)

    Min = {(x, t)|0 x 1, t 0}

    Sai phn tin & Sai phn li

    Xp x ut

    , ux

    , 2u

    x2& K bin, u Gi tr u ti cc im li

  • 7/29/2019 Baigiang_MoPhong

    43/46

    BI TON PARABOLIC (m hnh

    truyn nhit)

    T A A h h

  • 7/29/2019 Baigiang_MoPhong

    44/46

    BI TON PARABOLIC (m hnh

    truyn nhit)K hiu u(k) = [uk1 . . . u

    kn], f

    (k) = [fk1 . . . f kn ]

    BI TON PARABOLIC ( h h

  • 7/29/2019 Baigiang_MoPhong

    45/46

    BI TON PARABOLIC (m hnh

    truyn nhit) S Crank-Nicholson

    O li

  • 7/29/2019 Baigiang_MoPhong

    46/46

    Outline

    General introduction

    Structure and operation of chemical engineeringsystems

    What is a chemical process?

    Motivation examples Part I: Process modeling

    Part II: Computer simulation

    Part III: Optimization of chemical processes