You are on page 1of 35

Simulink

Cheng-Liang Chen
LABORATORY

PSE

Department of Chemical Engineering National TAIWAN University

Chen CL

MATrixLABoratory

Chen CL

Simulink

Chen CL

The Simulink Library Browser

Chen CL

Simulink Solution of y = 10 sin(t)


Check Results on Screen
dy = 10 sin(t) dt 13 y (t) =
0

y (0) = 0, 0 t 13

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

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

Chen CL

Simulink Solution of y = 10 sin(t)


Exporting to MATLAB
dy = 10 sin(t) dt 13 y (t) =
0

y (0) = 0, 0 t 13

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

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

Chen CL

Simulink Solution of y = 10 sin(t)


Exporting to MATLAB
% Ex_9_2.m for plot of Ex_9_2.mdl % plot(t, y,o,Color,[1,0,0],... LineStyle,-,LineWidth,2) axis([0 15 0 22]); xlabel(\bf Time,FontSize,16) ylabel(\bf y(t),FontSize,16) set(gca,FontSize,16,LineWidth,2) title(\bf Solution of dy/dt=10 sin(t), y(0)=0,FontSize,14)

Chen CL

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


Exporting to MATLAB
dy = 10y + 2 sin(4t) dt 3 y (t) =
0

y (0) = 1, 0 t 3

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

Chen CL

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


Exporting to MATLAB
% Ex_9_3.m for plot of Ex_9_3.mdl % plot(t, y,o,Color,[1,0,0],... LineStyle,-,LineWidth,2) axis([0 3 -0.2 1.2]); xlabel(\bf Time,FontSize,16) ylabel(\bf y(t),FontSize,16) set(gca,FontSize,16,LineWidth,2) title(\bf Solution of dy/dt=2sin(4t)-10y, y(0)=1,FontSize,14)

Chen CL

Linear State-Variable Models


Simulink Model of A Two-Mass System
5 x1 + 12x 1 + 5x1 8x 2 4x2 = 0 3 x2 + 8x 2 + 4x2 8x 1 4x1 = f (t) (m1 = 5, M 2 = 3, c1 = 4) (c2 = 8, k1 = 1, k2 = 4) (x1(0) = 0.2; x 1(0) = 0; ) (x2(0) = 0.5; x 2(0) = 0; ) Let z1 x1, z3 x2 z 1 = z2 , z 3 = z4 , z 2 = (5z1 12z2 + 4z3 + 8z4)/5 z 4 = (4z1 + 8z2 4z3 8z4 + f (t))/3

Chen CL

10

0 1 z1 1 12 d z2 5 = 0 dt 0 z3 8 4 z4 3 3 x1 x2

0 z1 0 0 4 8 0 5 5 z2 f (t) + 0 1 z3 0 1 4 8 z 4 3 3 3 z1 1 0 0 0 z2 + 0 0 0 1 0 0 z3 z4

Chen CL

11

Process Simulation
Simulation of A Gas Process
Consider the gas tank shown below. A fan blows air into a tank, and from the tank the air ows out through a valve. Suppose the air ow delivered by the fan is given by fi(t) = 0.16mi(t) where fi(t) is gas ow in scf/min, (scf is cubic feet at standard conditions of 60oF and 1 atm); mi(t) is signal to fan, %. The ow through the valve is expressed by fo(t) = 0.00506mo(t) p(t)[p(t) p1(t)] where fo(t) is gas ow, scf/min; mo(t) is signal to valve, %; p(t) is pressure in tank, psia; p1(t) is downstream pressure from valve, psia.

Chen CL

12

Process Simulation
Simulation of A Gas Process
The volume of the tank is 20 ft3, and it can be assumed that the process occurs isothermally at 60oF. The initial steady-state conditions are f = 40 psia; p 1 = 14.7 psia; m i = m o = 50 % i = fo = 8 scfm; p An unsteady-state mole balance around the control volume, dened as the fan, tank, and outlet valve, is V dp(t) dn(t) = = fi(t) fo(t) dt RT dt = 0.00263 lbmoles/scf is molar density of gas at standard conditions; R = 10.73 psia-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 of 5% in the signal to the inlet fan (starts from time =5 min.)

Chen CL

13

Process Simulation
Simulation of A Gas Process
V dp(t) = fi(t) fo(t) RT dt fi(t) = 0.16mi(t) ( = 0.00263 lbmole/scf, V = 20 ft3) fo(t) = 0.00506mo(t) p(t)[p(t) p1(t)] mi(0) = m i = 50%, mo(0) = m o = 50%, p1(0) = p 1 = 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 RT dp(t) [fi(t) fo(t)] = V dt (0.00263)(10.73)(520) = [fi(t) fo(t)] 20 = 0.734[fi(t) fo(t)] (now: mi = 55% at t = 5)

Chen CL

14

dp(t) fi(t) = 0.16mi(t), = 0.734[fi(t) fo(t)], mi : 50 55% (at t = 5) dt fo(t) = 0.00506mo(t) p(t)[p(t) p1(t)] po(0) = 39.8, m0 = 50%

Chen CL

15

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

16

Process Simulation
Simulation 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 low temperature results in incomplete mixing.

Chen CL

17

Process Simulation
Simulation of A Stirred Tank Heater
The tank is heated by steam condensing inside a coil. A proportional-integral-derivative (PID) controller is used to control the temperature in the tank by manipulating the steam valve position. The feed has a density of 68.0 lb/ft3, a heat capacity cp of 0.80 Btu/lb-oF. The volume V of liquid in the reactor is maintained at 120 ft3. The coil consists of 205 ft of 4-in. schedule 40 steel pipe, weighting 10.8 lb/ft with a heat capacity of 0.12 Btu/lb-oF and an outside parameter of 4.500 in. The overall heat transfer coecient U , based on the outside area of the coil, has been estimated as 2.1 Btu/min-ft2-oF. The steam available is saturated at a pressure of 30 psia; it can be assumed that its latent heat of condensation is constant at 966 Btu/lb. It can 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 dT (t) = f (t)cpTi(t) + U A[Ts(t) T (t)] f (t)cpT (t) V cv dt

Chen CL

18

Process Simulation
Simulation of A Stirred Tank Heater
An energy balance on the coil, assuming that the coil metal is at the same temperature as the condensing steam, results in (CM : heat capacitance of coil metal, Btu/oF; w(t): steam rate, lb/min) dTs(t) CM = w(t) U A[Ts(t) T (t)] dt The initial steady-state conditions are T (0) = 150oF and Ts(0) = 230oF. Also the initial design conditions are f (0) = 15 ft3/min, Ti(0) = 100oF, and w(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 ow.

Chen CL

19

Process Simulation
Simulation of A Stirred Tank Heater
dT (t) dt dTs (t) dt

= =

Ti(0) = 100 F, f (0) = 15ft /min, w(0) = 42.2lb/min

1 UA f ( t )[ T ( t ) T ( t )] + i V V cv [Ts (t) 1 CM {w (t) U A[Ts (t) T (t)]} o 3

T (t)],

T (0) = 150oF

Ts(0) = 230oF

Chen CL

20

Process Simulation
Simulation of A Stirred Tank Heater Subsystem Block for The Stirred Tank Heater

Chen CL

21

Process Simulation
Simulation of A Stirred Tank Heater Subsystem Block for The Stirred Tank Heater

Chen CL

22

Process Simulation
Simulation of A Stirred Tank Heater
Response of heater outlet temperature and steam chest temperature to a step change in process ow

Chen CL

23

Process Simulation
Simulation of A Batch Bioreactor
Many important specialty chemical products are produced in bioreactors by processes such as fermentation. Most of these processes are carried out in batch mode by lling a tank with a substrate solution and inoculating it with a small amount of biomass. The biomass, feeding on the substrate, reproduces to produce the 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 the consumption of the substrate concentration, s(t), is given on a per unit volume dx(t) bsis as follows: = (t)x(t) dt ds(t) 1 = (t)x(t) dt y (t)

Chen CL

24

Process Simulation
Simulation of A Batch Bioreactor
where y is the yield in biomass per unit mass of substrate and (t) is the biomass growth rate function (h1). This growth rate function is analogous to the kinetic models 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 form: s(t) d(t) = m (t) dt k + s(t) where is the adaptability parameter, and k and m 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.2h1, and x(0) = 0.001g/liter.

Chen CL

25

Process Simulation
Simulation of A Batch Bioreactor
ds(t) dx(t) 1 = (t)x(t) = y (t)x(t) dt dt d(t) s(t) 1 = m k+ ( t ) = 15 h , (0) = m = 1.2 s ( t ) dt k = 0.5 g/liter, s(0) = 2.5 g/liter, x(0) = 0.001 g/liter

Chen CL

26

Process Simulation
Simulation of A Batch Bioreactor

Chen CL

27

Process Simulation
Simulation of A Pressure Tank
A stray bullet red by a careless robber punctures the compressed air tank at a gas station. The mass balance of air in the tank is V where d(t) = wi(t) Ao dt 2(t)[p(t) po]

M p(t) RT wi(t) kg/s, is the inlet ow 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. (t) =

Chen CL

28

Process Simulation
Simulation of A Pressure Tank

Chen CL

29

Process Simulation
Simulation of A Pressure Tank

Chen CL

30

Process Simulation
Simulation 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 ow rates f1 and f2 are constant. It is desired to understand how each inlet concentration aects the outlet concentration. Develop the mathematical model. Use Simulink to simulate the mixing process and plot the response of the outlet concentration to a step change of 5 gallon/minute (gpm) in ow f1. At the initial steady-state conditions the ow 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 and 0.05 moles/cm3. Assume a tight level controller keeps the volume in the tank constant.

Chen CL

31

Process Simulation
Simulation 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 ows. 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 in Btu/lbmole of A reacted. Let us also assume that the level of liquid in the reactor tank is constant; that is, the rate of mass into the tank is equal to the rate of mass out of the tank. Finally, the rate of reaction is given by rA(t) = koeE/RT (t)c2 A (t) lbmoles of A reacted ft3-min

Chen CL

32

where the frequency factor ko and energy of activation E are constants. The following Table gives the steady-state values of the variables and other process specications. It is desired to nd out how the outlet concentrations of A and B , and the outlet temperature respond to changes in the inlet concentration of A, cAi(t); the inlet temperature of the reactant Ti(t); the inlet temperature of cooling liquid Tci(t); and the ows f (t) and fc(t). Process information V = E= = Hr = A= Vc = CAi(t) = Tc = cA(t) = Tci(t) = 13.26 ft3 27, 820 Btu/lbmole 55 lbm/ft3 12, 000 Btu/lbmole 36 ft2 1.56 ft3 0.5975 lbmole/ft3 602.7oR 0.2068 lbmole/ft3 540oR ko = R= Cp = U= Cpc = 8.33 108 ft3/(lbmole-min) 1.987 Btu/(lbmole-oR) 0.88 Btu/(lbm-oF) 75 Btu/(h-ft2-oF) 1.0 Btu/(lbm-oF)

Steady-state values Ti(t) = f= T (t) = fc(t) = 635oR 1.3364 ft3/min 678.9oR 0.8771 ft3/min

Chen CL

33

Assume the reactor is initially at the design conditions. Use Simulink to simulate the process and plot the response of the reactor temperature to a step change of 0.25 ft3/min in process ow, and of 0.1 ft3/min in coolant ow. f (t)cAi(t) f (t)cA(t) V rA(t) = rA(t) = f (t)CpTi(t) U A[T (t) Tc(t)] f (t)CpT (t) V rA(Hr ) = fc(t)cCpcTci(t) + U A[T (t) Tc(t)] fc(t)cCpcTc(t) = dcA(t) V dt koeE/RT (t)c2 A (t) dT (t) V Cv dt dTc(t) VccCvc dt

Chen CL

34

Thank You for Your Attention


Questions Are Welcome

You might also like