Está en la página 1de 32

Simulink

Cheng-Liang Chen
PSE
LABORATORY
Department of Chemical Engineering
National TAIWAN University
Chen CL 1
MATrixLABoratory
Chen CL 2
Simulink
Chen CL 3
The Simulink Library Browser
Chen CL 4
Simulink Solution of y = 10 sin(t)
Check Results on Screen
dy
dt
= 10 sin(t) y(0) = 0, 0 t 13
y(t) =

13
0
(10 sin(t))dt +y(0)
Note: y(t) = 10(1 cos(t)) (exact solution)
Chen CL 5
Simulink Solution of y = 10 sin(t)
Exporting to MATLAB
dy
dt
= 10 sin(t) y(0) = 0, 0 t 13
y(t) =

13
0
(10 sin(t))dt +y(0)
Note: y(t) = 10(1 cos(t)) (exact solution)
Chen CL 6
Simulink Solution of y = 10y + 2 sin(4t)
dy
dt
= 10y + 2 sin(4t) y(0) = 1, 0 t 3
y(t) =

3
0
(10y + 2 sin(4t))dt +y(0)
Chen CL 7
Linear State-Variable Models
Simulink Model of A Two-Mass System
5 x
1
+ 12 x
1
+ 5x
1
8 x
2
4x
2
= 0
3 x
2
+ 8 x
2
+ 4x
2
8 x
1
4x
1
= f(t)
(m
1
= 5, M 2 = 3, c
1
= 4)
(c
2
= 8, k
1
= 1, k
2
= 4)
(x
1
(0) = 0.2; x
1
(0) = 0; )
(x
2
(0) = 0.5; x
2
(0) = 0; )
Let z
1
x
1
, z
3
x
2
z
1
= z
2
, z
2
= (5z
1
12z
2
+ 4z
3
+ 8z
4
)/5
z
3
= z
4
, z
4
= (4z
1
+ 8z
2
4z
3
8z
4
+f(t))/3
Chen CL 8
d
dt

z
1
z
2
z
3
z
4

0 1 0 0
1
12
5
4
5
8
5
0 0 0 1
4
3
8
3

4
3

8
3

z
1
z
2
z
3
z
4

0
0
0
1
3

f(t)

x
1
x
2

1 0 0 0
0 0 1 0

z
1
z
2
z
3
z
4

0
0

Chen CL 9
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
f
i
(t) = 0.16m
i
(t)
where f
i
(t) is gas ow in scf/min, (scf is cubic feet at standard conditions of 60
o
F
and 1 atm); m
i
(t) is signal to fan, %. The ow through the valve is expressed by
f
o
(t) = 0.00506m
o
(t)

p(t)[p(t) p
1
(t)]
where f
o
(t) is gas ow, scf/min; m
o
(t) is signal to valve, %; p(t) is pressure in
tank, psia; p
1
(t) is downstream pressure from valve, psia.
Chen CL 10
Process Simulation
Simulation of A Gas Process
The volume of the tank is 20 ft
3
, and it can be assumed that the process occurs
isothermally at 60
o
F. The initial steady-state conditions are

f
i
=

f
o
= 8 scfm; p = 40 psia; p
1
= 14.7 psia; m
i
= m
o
= 50 %
An unsteady-state mole balance around the control volume, dened as the fan,
tank, and outlet valve, is
dn(t)
dt
=
V
RT
dp(t)
dt
= f
i
(t) f
o
(t)
= 0.00263 lbmoles/scf is molar density of gas at standard conditions; R = 10.73
psia-ft
3
/lbmoles-
o
R is ideal gas law constant; T = 520
o
R 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 11
Process Simulation
Simulation of A Gas Process
V
RT
dp(t)
dt
= f
i
(t) f
o
(t)
f
i
(t) = 0.16m
i
(t) ( = 0.00263 lbmole/scf, V = 20 ft
3
)
f
o
(t) = 0.00506m
o
(t)

p(t)[p(t) p
1
(t)]
m
i
(0) = m
i
= 50%, m
o
(0) = m
o
= 50%, p
1
(0) = p
1
= 14.7psia
f
o
(0) = f
i
(0) = 0.16m
i
(0) = (0.16)(50) = 8.0 scf/min
f
o
(0) = 0.00506m
o
(0)

p(0)[p(0) p
1
(0)]
p(0) = 39.8 psia

dp(t)
dt
=
RT
V
[f
i
(t) f
o
(t)]
=
(0.00263)(10.73)(520)
20
[f
i
(t) f
o
(t)]
= 0.734[f
i
(t) f
o
(t)] (now: m
i
= 55% at t = 5)
Chen CL 12
f
i
(t) = 0.16m
i
(t),
dp(t)
dt
= 0.734[f
i
(t) f
o
(t)]
f
o
(t) = 0.00506m
o
(t)

p(t)[p(t) p
1
(t)] p
o
(0) = 39.8 m
i
: 50 55%
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
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 15
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/ft
3
, a heat capacity c
p
of 0.80 Btu/lb-
o
F. The
volume V of liquid in the reactor is maintained at 120 ft
3
. 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-
o
F 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-ft
2
-
o
F. 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 T
i
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 c
v
dT(t)
dt
= f(t)c
p
T
i
(t) +UA[T
s
(t) T(t)] f(t)c
p
T(t)
Chen CL 16
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 (C
M
: heat capacitance of coil
metal, Btu/
o
F; w(t): steam rate, lb/min)
C
M
dT
s
(t)
dt
= w(t) UA[T
s
(t) T(t)]
The initial steady-state conditions are T(0) = 150
o
F and T
s
(0) = 230
o
F. Also the
initial design conditions are f(0) = 15 ft
3
/min, T
i
(0) = 100
o
F, 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 17
Process Simulation
Simulation of A Stirred Tank Heater
dT(t)
dt
=
1
V
f(t)[T
i
(t) T(t)] +
UA
V c
v
[T
s
(t) T(t)], T(0) = 150
o
F
dT
s
(t)
dt
=
1
C
M
{w(t) UA[T
s
(t) T(t)]} T
s
(0) = 230
o
F
T
i
(0) = 100
o
F, f(0) = 15ft
3
/min, w(0) = 42.2lb/min
Chen CL 18
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 19
Process Simulation
Simulation of A Stirred Tank Heater
Subsystem Block for The Stirred Tank Heater
Chen CL 20
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
bsis as follows:
dx(t)
dt
= (t)x(t)
ds(t)
dt
=
1
y(t)
(t)x(t)
where y is the yield in biomass per unit mass of substrate and (t) is the biomass
growth rate function (h
1
). 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
Chen CL 21
form:
d(t)
dt
=

m
s(t)
k +s(t)
(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:
= 15h
1
, k = 0.5g/liter, s(0) = 2.5g/liter, (0) =
m
= 1.2h
1
, and
x(0) = 0.001g/liter.
Chen CL 22
Process Simulation
Simulation 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 h
1
, (0) =
m
= 1.2
k = 0.5 g/liter, s(0) = 2.5 g/liter, x(0) = 0.001 g/liter
Chen CL 23
Process Simulation
Simulation of A Batch Bioreactor
Chen CL 24
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
d(t)
dt
= w
i
(t) A
o

2(t)[p(t) p
o
]
where
(t) =
M
RT
p(t)
w
i
(t) kg/s, is the inlet ow from the air compressor, V = 1.5 m
3
, is the volume of
the tank, A
o
= 0.785 cm
2
, is the area of the bullet hole, M = 29 kg/kmole, is the
molecular weight of air, R = 8.314 kPa-m
3
/kmole-K, is the ideal gas law
constant, and temperature T is assumed constant at 70
o
C, p
o
= 500 kPa gauge.
Use Simulink to simulate the process and plot the response of the pressure in the
tank.
Chen CL 25
Process Simulation
Simulation of A Pressure Tank
Chen CL 26
Process Simulation
Simulation of A Pressure Tank
Chen CL 27
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 f
1
and
f
2
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 f
1
. At the initial steady-state conditions the ow
from the tank is 100 gpm, and its concentration is 0.025 moles/cm
3
. The tank
volume is 200 gallons, and the feed compositions are 0.010 and 0.05 moles/cm
3
.
Assume a tight level controller keeps the volume in the tank constant.
Chen CL 28
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 H
r
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
r
A
(t) = k
o
e
E/RT(t)
c
2
A
(t)
lbmoles of A reacted
ft
3
-min
Chen CL 29
where the frequency factor k
o
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,
c
Ai
(t); the inlet temperature of the reactant T
i
(t); the inlet temperature of
cooling liquid T
ci
(t); and the ows f(t) and f
c
(t).
Process information
V = 13.26 ft
3
k
o
= 8.33 10
8
ft
3
/(lbmole-min)
E = 27, 820 Btu/lbmole R = 1.987 Btu/(lbmole-
o
R)
= 55 lbm/ft
3
C
p
= 0.88 Btu/(lbm-
o
F)
H
r
= 12, 000 Btu/lbmole U = 75 Btu/(h-ft
2
-
o
F)
A = 36 ft
2
C
pc
= 1.0 Btu/(lbm-
o
F)
V
c
= 1.56 ft
3
Steady-state values
C
Ai
(t) = 0.5975 lbmole/ft
3
T
i
(t) = 635
o
R
T
c
= 602.7
o
R f = 1.3364 ft
3
/min
c
A
(t) = 0.2068 lbmole/ft
3
T(t) = 678.9
o
R
T
ci
(t) = 540
o
R f
c
(t) = 0.8771 ft
3
/min
Chen CL 30
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 ft
3
/min in process ow, and of 0.1 ft
3
/min in coolant ow.
f(t)c
Ai
(t) f(t)c
A
(t) V r
A
(t) = V
dc
A
(t)
dt
r
A
(t) = k
o
e
E/RT(t)
c
2
A
(t)
f(t)C
p
T
i
(t) UA[T(t) T
c
(t)] f(t)C
p
T(t) V r
A
(H
r
) = V C
v
dT(t)
dt
f
c
(t)
c
C
pc
T
ci
(t) +UA[T(t) T
c
(t)] f
c
(t)
c
C
pc
T
c
(t) = V
c

c
C
vc
dT
c
(t)
dt
Chen CL 31
Thank You for Your Attention
Questions Are Welcome

También podría gustarte