10 Simulink.pdf

download 10 Simulink.pdf

of 32

Transcript of 10 Simulink.pdf

  • 8/11/2019 10 Simulink.pdf

    1/32

    Simulink

    Cheng-Liang Chen

    PSELABORATORY

    Department of Chemical EngineeringNational TAIWAN University

  • 8/11/2019 10 Simulink.pdf

    2/32

    Chen CL 1

    MATrixLABoratory

  • 8/11/2019 10 Simulink.pdf

    3/32

    Chen CL 2

    Simulink

  • 8/11/2019 10 Simulink.pdf

    4/32

    Chen CL 3

    The SimulinkLibrary Browser

  • 8/11/2019 10 Simulink.pdf

    5/32

    Chen CL 4

    Simulink Solution ofy= 10 sin(t)Check Results on Screen

    dydt

    = 10 sin(t) y(0) = 0, 0 t 13

    y(t) =

    130

    (10 sin(t))dt + y(0)

    Note: y(t) = 10(1 cos(t)) (exact solution)

    C C

  • 8/11/2019 10 Simulink.pdf

    6/32

    Chen CL 5

    Simulink Solution ofy= 10 sin(t)Exporting toMATLAB

    dydt

    = 10 sin(t) y(0) = 0, 0 t 13

    y(t) =

    130

    (10 sin(t))dt + y(0)

    Note: y(t) = 10(1 cos(t)) (exact solution)

    Ch CL 6

  • 8/11/2019 10 Simulink.pdf

    7/32

    Chen CL 6

    Simulink Solution ofy= 10y+ 2 sin(4t)

    dydt

    = 10y+ 2 sin(4t) y(0) = 1, 0 t 3

    y(t) =

    30

    (10y+ 2 sin(4t))dt + y(0)

    Ch CL 7

  • 8/11/2019 10 Simulink.pdf

    8/32

    Chen CL 7

    Linear State-Variable ModelsSimulink Model of A Two-Mass System

    5x1+ 12x1+ 5x1 8x2 4x2 = 0

    3x2+ 8x2+ 4x2 8x1 4x1 = f(t)

    (m1= 5, M 2 = 3, c1= 4)

    (c2= 8, k1= 1, k2= 4)

    (x1(0) = 0.2; x1(0) = 0;)

    (x2(0) = 0.5; x2(0) = 0;)

    Let z1 x1, z3 x2

    z1 = z2, z2 = (5z1 12z2+ 4z3+ 8z4)/5

    z3 = z4, z4 = (4z1+ 8z2 4z3 8z4+ f(t))/3

    Ch CL 8

  • 8/11/2019 10 Simulink.pdf

    9/32

    Chen CL 8

    d

    dt

    z1

    z2

    z3

    z4

    =

    0 1 0 0

    1 12545

    85

    0 0 0 143

    83

    43

    83

    z1

    z2

    z3

    z4

    +

    0

    0

    013

    f(t)

    x1

    x2

    =

    1 0 0 0

    0 0 1 0

    z1

    z2

    z3

    z4

    +

    0

    0

    Ch CL 9

  • 8/11/2019 10 Simulink.pdf

    10/32

    Chen CL 9

    Process SimulationSimulation of A Gas Process

    Consider the gas tank shown below. A fan blows air into a tank, and from thetank the air flows out through a valve. Suppose the air flow delivered by the fan isgiven by

    fi(t) = 0.16mi(t)

    where fi(t) is gas flow in scf/min, (scf is cubic feet at standard conditions of60oF

    and1 atm); mi(t) is signal to fan, %. The flow through the valve is expressed by

    fo(t) = 0.00506mo(t)

    p(t)[p(t)p1(t)]

    where fo(t) is gas flow, scf/min; mo(t) is signal to valve, %; p(t) is pressure intank, psia; p1(t) is downstream pressure from valve, psia.

    Chen CL 10

  • 8/11/2019 10 Simulink.pdf

    11/32

    Chen CL 10

    Process SimulationSimulation of A Gas Process

    The volume of the tank is 20 ft3, and it can be assumed that the process occursisothermally at 60oF. The initial steady-state conditions are

    fi= fo= 8 scfm; p= 40 psia; p1= 14.7 psia; mi= mo= 50 %

    An unsteady-state mole balance around the control volume, defined as the fan,

    tank, and outlet valve, is

    dn(t)

    dt =

    V

    RT

    dp(t)

    dt = fi(t) fo(t)

    = 0.00263 lbmoles/scf is molar density of gas at standard conditions; R= 10.73psia-ft3/lbmoles-oR is ideal gas law constant; T= 520oR is gas temperature.

    Please construct a Simulink model to simulate this process, and shows the

    response of the pressure to a step change of5% in the signal to the inlet fan

    (starts from time =5 min.)

    Chen CL 11

  • 8/11/2019 10 Simulink.pdf

    12/32

    Chen CL 11

    Process SimulationSimulation of A Gas Process

    V

    RT

    dp(t)

    dt = fi(t)fo(t)fi(t) = 0.16mi(t) (= 0.00263lbmole/scf, V = 20ft

    3)

    fo(t) = 0.00506mo(t)

    p(t)[p(t)p1(t)]

    mi(0) = mi= 50%, mo(0) = mo= 50%, p1(0) = p1= 14.7psia

    fo(0) = fi(0) = 0.16mi(0) = (0.16)(50) = 8.0 scf/min

    fo(0) = 0.00506mo(0)

    p(0)[p(0)p1(0)]

    p(0) = 39.8 psia

    dp(t)dt

    = RTV

    [fi(t) fo(t)]

    = (0.00263)(10.73)(520)

    20 [fi(t) fo(t)]

    = 0.734[fi(t) fo(t)] (now: mi= 55% at t= 5)

    Chen CL 12

  • 8/11/2019 10 Simulink.pdf

    13/32

    Chen CL 12

    fi(t) = 0.16mi(t), dp(t)

    dt = 0.734[fi(t) fo(t)]

    fo(t) = 0.00506mo(t)p(t)[p(t)p1(t)] po(0) = 39.8 mi: 50 55%

    Chen CL 13

  • 8/11/2019 10 Simulink.pdf

    14/32

    Chen CL 13

    subplot(2,1,1)

    plot(dt,p,m,linewidth,2)

    ylabel(\bf p(t),Fontsize,14);

    title(\bf Gas pressure response to step fan change,Fontsize,14)subplot(2,1,2)

    plot(dt,mi,b,linewidth,2)

    ylabel(\bf m_i(t),Fontsize,14);

    xlabel(\bf t (min),Fontsize,14);

    set(gca,linewidth,3);

    % set(gca,Fontsize,14);

    Chen CL 14

  • 8/11/2019 10 Simulink.pdf

    15/32

    Chen CL 14

    Process SimulationSimulation of A Stirred Tank Heater

    The stirred tank is used to heat a process stream so that its premixed components

    achieve a uniform composition. Temperature control is important in this process

    because a high temperature tends to decompose the product while a lowtemperature results in incomplete mixing.

    Chen CL 15

  • 8/11/2019 10 Simulink.pdf

    16/32

    Chen CL 15

    Process SimulationSimulation of A Stirred Tank Heater

    The tank is heated by steam condensing inside a coil. Aproportional-integral-derivative (PID) controller is used to control the temperaturein the tank by manipulating the steam valve position.The feed has a density of68.0 lb/ft3, a heat capacity cp of0.80 Btu/lb-

    oF. ThevolumeVof liquid in the reactor is maintained at 120ft3. The coil consists of205ft of4-in. schedule 40 steel pipe, weighting 10.8 lb/ft with a heat capacity of0.12

    Btu/lb-o

    F and an outside parameter of4.500 in. The overall heat transfercoefficientU, based on the outside area of the coil, has been estimated as 2.1Btu/min-ft2-oF. The steam available is saturated at a pressure of30 psia; it canbe assumed that its latent heat of condensation is constant at 966 Btu/lb. Itcan also be assumed that the inlet temperature Ti is constant.An energy balance on the liquid in the tank, assume negligible heat losses, perfect

    mixing, and constant volume and physical properties, results in the equation

    V cvdT(t)

    dt =f(t)cpTi(t) + U A[Ts(t) T(t)] f(t)cpT(t)

    Chen CL 16

  • 8/11/2019 10 Simulink.pdf

    17/32

    Chen CL 16

    Process SimulationSimulation of A Stirred Tank Heater

    An energy balance on the coil, assuming that the coil metal is at the sametemperature as the condensing steam, results in (CM: heat capacitance of coilmetal, Btu/oF; w(t): steam rate, lb/min)

    CMdTs(t)

    dt =w(t) U A[Ts(t) T(t)]

    The initial steady-state conditions are T(0) = 150oF andTs(0) = 230oF. Also the

    initial design conditions are f(0) = 15 ft3/min, Ti(0) = 100oF, andw(0) = 42.2

    lb/min.

    Construct a Simulink diagram for the simulation of the heater. shows the

    responses of the temperatures to a step changes in process flow.

    Chen CL 17

  • 8/11/2019 10 Simulink.pdf

    18/32

    Chen CL 17

    Process SimulationSimulation of A Stirred Tank Heater

    dT(t)

    dt = 1

    Vf(t)[T

    i(t) T(t)] + UA

    V cv[T

    s(t) T(t)], T(0) = 150oF

    dTs(t)dt =

    1CM{w(t) U A[Ts(t) T(t)]} Ts(0) = 230

    oF

    Ti(0) = 100oF, f(0) = 15ft3/min, w(0) = 42.2lb/min

    Chen CL 18

  • 8/11/2019 10 Simulink.pdf

    19/32

    Chen CL 18

    Process SimulationSimulation of A Stirred Tank Heater

    Response of heater outlet temperature and steam chest temperature

    to a step change in process flow

    Chen CL 19

  • 8/11/2019 10 Simulink.pdf

    20/32

    Chen CL 19

    Process SimulationSimulation of A Stirred Tank Heater

    Subsystem Block for The Stirred Tank Heater

    Chen CL 20

  • 8/11/2019 10 Simulink.pdf

    21/32

    Process SimulationSimulation of A Batch Bioreactor

    Many important specialty chemical products are produced in bioreactors byprocesses such as fermentation. Most of these processes are carried out in batchmode by filling a tank with a substrate solution and inoculating it with a smallamount of biomass. The biomass, feeding on the substrate, reproduces to producethe desired product, until the substrate is consumed. This example is presented

    here to show some of the special characteristics of biochemical processes.A dynamic model of the growth of the biomass concentration x(t) and of theconsumption of the substrate concentration, s(t), is given on a per unit volumebsis as follows: dx(t)

    dt = (t)x(t)

    ds(t)dt

    = 1y(t)

    (t)x(t)

    where y is the yield in biomass per unit mass of substrate and (t) is the biomassgrowth rate function (h1). This growth rate function is analogous to the kineticmodels used to model chemical reactors. It is designed to match experimental

    data. Here we will use the Monod model with adaptability wich has the following

    Chen CL 21

  • 8/11/2019 10 Simulink.pdf

    22/32

    form:d(t)

    dt =

    m

    s(t)

    k+ s(t) (t)

    where is the adaptability parameter, and k andm are the parameters of the

    model. Please use Simulink to simulate the model with the following data:= 15h1, k= 0.5g/liter, s(0) = 2.5g/liter, (0) =m= 1.2h

    1, and

    x(0) = 0.001g/liter.

    Chen CL 22

  • 8/11/2019 10 Simulink.pdf

    23/32

    Process SimulationSimulation of A Batch Bioreactor

    dx(t)

    dt = (t)x(t)

    ds(t)

    dt = 1

    y(t)x(t)

    d(t)

    dt =

    m

    s(t)k+s(t) (t)

    = 15 h1, (0) =m= 1.2

    k = 0.5 g/liter, s(0) = 2.5 g/liter, x(0) = 0.001 g/liter

    Chen CL 23

  • 8/11/2019 10 Simulink.pdf

    24/32

    Process SimulationSimulation of A Batch Bioreactor

    Chen CL 24

  • 8/11/2019 10 Simulink.pdf

    25/32

    Process SimulationSimulation of A Pressure Tank

    A stray bullet fired by a careless robber punctures the compressed air tank at a gas

    station. The mass balance of air in the tank is

    Vd(t)

    dt =wi(t)Ao

    2(t)[p(t)po]

    where

    (t) = MRT

    p(t)

    wi(t) kg/s, is the inlet flow from the air compressor, V = 1.5 m3, is the volume of

    the tank, Ao= 0.785 cm2, is the area of the bullet hole, M= 29 kg/kmole, is the

    molecular weight of air, R= 8.314 kPa-m3/kmole-K, is the ideal gas law

    constant, and temperature T is assumed constant at 70oC, po= 500 kPa gauge.Use Simulink to simulate the process and plot the response of the pressure in the

    tank.

    Chen CL 25

  • 8/11/2019 10 Simulink.pdf

    26/32

    Process SimulationSimulation of A Pressure Tank

    Chen CL 26

  • 8/11/2019 10 Simulink.pdf

    27/32

    Process SimulationSimulation of A Pressure Tank

    Chen CL 27

  • 8/11/2019 10 Simulink.pdf

    28/32

    Process SimulationSimulation of A Mixing Tank

    Computer-room Exercise

    Consider the mixing process shown below. Assume

    that the density of the input and output streams

    are very similar and that the flow rates f1 and

    f2 are constant. It is desired to understand

    how each inlet concentration affects the outletconcentration. Develop the mathematical model.

    Use Simulink to simulate the mixing process

    and plot the response of the outlet concentration to a step change of5

    gallon/minute (gpm) in flow f1. At the initial steady-state conditions the flow

    from the tank is 100 gpm, and its concentration is 0.025 moles/cm3. The tank

    volume is 200 gallons, and the feed compositions are 0.010 and0.05 moles/cm3.

    Assume a tight level controller keeps the volume in the tank constant.

    Chen CL 28

  • 8/11/2019 10 Simulink.pdf

    29/32

    Process SimulationSimulation of A Nonisothermal Chemical Reaction

    Computer-room Exercise

    Consider a stirred-tank reactor with reaction A B

    as shown below. To remove the heat of reaction the

    reactor is surrounded by a jacket through which a

    cooling liquid flows. Let us assume that the heat

    loss to the surroundings are negligible, and that

    the thermodynamic properties, densities, and heat

    capacities of the reactants and products are both

    equal and constant. The heat of reaction is constant and is given by Hr inBtu/lbmole ofA reacted. Let us also assume that the level of liquid in the reactortank is constant; that is, the rate of mass into the tank is equal to the rate ofmass out of the tank. Finally, the rate of reaction is given by

    rA(t) =koe

    E/RT(t)

    c

    2

    A(t)

    lbmoles of A reacted

    ft3-min

    Chen CL 29

  • 8/11/2019 10 Simulink.pdf

    30/32

    where the frequency factor ko and energy of activation Eare constants. Thefollowing Table gives the steady-state values of the variables and other processspecifications. It is desired to find out how the outlet concentrations ofA andB,and the outlet temperature respond to changes in the inlet concentration ofA,

    cAi(t); the inlet temperature of the reactant Ti(t); the inlet temperature ofcooling liquid Tci(t); and the flows f(t) andfc(t).

    Process information

    V = 13.26 ft3 ko= 8.33 108 ft3/(lbmole-min)

    E= 27, 820 Btu/lbmole R= 1.987 Btu/(lbmole-

    o

    R)= 55 lbm/ft3 Cp= 0.88 Btu/(lbm-

    oF)

    Hr = 12, 000 Btu/lbmole U= 75 Btu/(h-ft2-oF)

    A= 36 ft2 Cpc= 1.0 Btu/(lbm-oF)

    Vc= 1.56 ft3

    Steady-state values

    CAi(t) = 0.5975 lbmole/ft3 Ti(t) = 635

    oR

    Tc= 602.7oR f= 1.3364 ft3/min

    cA(t) = 0.2068 lbmole/ft3 T(t) = 678.9oR

    Tci(t) = 540o

    R fc(t) = 0.8771 ft3

    /min

    Chen CL 30

  • 8/11/2019 10 Simulink.pdf

    31/32

    Assume the reactor is initially at the design conditions. Use Simulink to simulatethe process and plot the response of the reactor temperature to a step change of0.25 ft3/min in process flow, and of0.1 ft3/min in coolant flow.

    f(t)cAi(t) f(t)cA(t) V rA(t) = VdcA(t)dt

    rA(t) = koeE/RT(t)c2A(t)

    f(t)CpTi(t) U A[T(t) Tc(t)] f(t)CpT(t) V rA(Hr) = V CvdT(t)

    dt

    fc(t)cCpcTci(t) + U A[T(t) Tc(t)] fc(t)cCpcTc(t) = VccCvcdTc(t)

    dt

    Chen CL 31

  • 8/11/2019 10 Simulink.pdf

    32/32

    Thank You for Your AttentionQuestions Are Welcome