Welcome to Simulink for ChemE's. Today we're going to show how Simulink can be a valuable
tool for modeling all sorts of real world processes. Suppose we have a pressurized system
with two tanks in series. The gas flows into the first tank at a mass flow rate W(i). The
pressures in each tank, P1 and P2, change with time, as do the outlet flow rates from
each tank. The volume in each tank is constant. We're also given the transfer functions, already
in the Laplace domain, describing the relationship between the output and input variables. So
our objective today is to plot P1 prime, P2 prime, and W(i) prime for eighty minutes if the
flow rate of gas, W(i), is instantaneously increased from thirty to forty pounds per
minute, and the instantaneously decreased to thirty five pounds per minute after twenty
minutes. If we look at our equations that are given, we can see the pressure in the
first tank is a function of inlet flow rate, as well as pressure in the second tank. Simultaneously,
the pressure in the second tank is a function of the pressure in the first tank. Let's go
over to Simulink. The process blocks, mux, and scope are already on the screen. We
have to figure out the relationship between these blocks in order to generate an accurate
model of the system. At this point, because we have equations showing how all our variables
are related we don't really need the diagram of the tanks anymore, we can think of the
system in a more abstract way. So we can see in the second equation that P2 is equal to
P1 times a transfer function. That means if we were to express it graphically, P1 would
enter the transfer function block, we can double click on the arrows and label them,
this is P1 prime, and it exits as P2 prime. So P1 enters the transfer function block,
it's multiplied by point eight over five s plus one, and this creates the output P2 prime.
However, we still don't know where this P1 prime arrow is coming from, it's just floating
in space right now. We need to figure out how to create this using our other variables
and transfer functions. According to the first equation, P1 prime is equal to one term minus
another term. One signal is being subtracted from another signal. So if we go into math
operations in the library browser we can express this using a subtract block. Now the first
term in the equation comes from W(i) prime multiplied by a transfer function. Therefore,
draw an arrow from the blocks input to the W(i) prime signal, and connect this to the
positive port on the subtract block. The other comes from P2 multiplied by a different transfer
function. Therefore, draw an arrow from the block's input to the P2 signal, the P2 signal
is coming out right here, so you can just loop this around and connect it, and then
connect the output to the subtract port, the negative port on the subtract block. So this
is all well and good, but we still don't know what W(i) prime is or where it comes from.
We can read the problem statement again. There are two instantaneous changes in flow rate,
which when used together form the initial flow rate W(i) prime. Therefore, we can put
two step functions on the board, and an add block. One step is at time zero, and one step
is at time equals twenty minutes. The initial increase in flow rate is from thirty to forty
pounds per minute. This is an increase of ten pounds per minute, so if expressed in
deviation variables, this step change would start at zero pounds per minute and end at
ten. Therefore, we double click on one of the blocks and make the first step at a step time
of zero ten pounds per minute. Now this step stays in effect, so in order to make the flow
rate decrease by five pounds per minute at the right time, we make the other step occur
at a step time of twenty minutes, start at an initial value of zero, and end at a final
value of negative five. Then we connect the two blocks to the add. Run the simulation
for eighty minutes. Alright, first, first let's check out the step change. Did it behave
the way we expected? It did, it increases to ten pounds per minute, and then at time
equals twenty minutes it decreases to five pounds per minute. An important thing to note
here is the units of the x and y axis. The x axis is time, the y axis is pounds per minute
for the flow rate, but it's psig for the tank pressures. As inlet flow rate increases the
pressure in both tanks increases. Both tank pressures have stable but oscillatory responses
to the change in flow rate. The pressure in the first tank increases more, and at a faster
rate, and the pressure in the first tank also oscillates more when there is a flow rate
change, but eventually pressures in both tanks converge to a final steady state value. If
you want to learn more about Simulink to solve process control problems you can subscribe
to the Lafayette CHBE YouTube channel.