You are on page 1of 8

Process Simulation

Computer Exersice 1
3UREOHP  0L[LQJ 7DQN (material balances and MATLAB) A stirred mixing tank has one inlets and one outlet. A model of the tank is developed in Example 1.1 to 1.5 in the lecture note. a) Put up the total material balance over the tank. Assume that the outlet flow is proportional to the volume (total mass) in the tank, T RXW = N RXW 9 . Assume the following data set: T  PV T  PV  NJP NRXW 

b) Solve the dynamic problem numerically using ode23. Start the simulation with an empty tank and stop at t=100. Write the equation on VWDWHVSDFH IRUP in a Mfile in the following way seen below. Let us call this kind of M-file that contains the model description a 0RGHO ILOH. The command will be [tsol,msol]=ode23(mixtankdyn,[0 100],0); and the plot commad will be plot(tsol,msol) function dm = mixtank(t,m) dm = c) Solve the steady-state problem numerically using fzero. Write the equation on UHVLGXDO IRUP in a M-file in the following way seen below. This kind of M-file is also a 0RGHO ILOH. Note the similarities between the two model files. Guess a initial value on the mass variable. Assume that we guess mguess=2000. The command will be msol=fzero('mixtankstat',2000) function res = mixtank(m) res = 3UREOHP  0L[LQJ 7DQN (material balances and MATLAB) A stirred mixing tank has two inlets and one outlet. The volume is assumed to be constant (controlled). The first inlet is a fresh feed with high composition of a component A. The second inlet is a recycle stream with low composition of A. a) Develop a component mass balance and list our assumptions. Rewrite the component mass balance as a composition equation. Express it also as a concentration change equation. Assume the following data: 9  P T  PV [  NTNJ T  PV [  NJNJ  NJP At the beginning (time zero) the mixing tank is full of recycled liquid. b) Solve the dynamic problem numerically using ode23. Write the composition equation in an M-file (0RGHO ILOH) in the following way.

function dx = mixtank(t,x) dx = 3UREOHP  0L[LQJ 7DQN (energy balance) Assume that the mixing tank in Problem 2 is heated with steam in a jacket. The heat transfer of the jacket can be described as 4 NK$K 7V 7 . Assume the following data: &S  N-NJ& 7  & 7  & 7F  & NK  N:P& and $K  P a) Develop an energy balance over the mixing tank and list our assumptions. b) Assume constant density and heat capacity and rewrite the energy balance into a temperature change equation. c) Solve the dynamic temperature equation for an initial value of  &. 3UREOHP  %XIIHU 7DQN ZLWK +HDWLQJ (balance equations and MATLAB) The buffer tank similar to the tank form Problem 1.1 to 1.3 has two inlets and one outlet. The tank is open and has cylindrical geometry, 9 $WDQN K. The height in the tank changes and the cross section area is $WDQN  P The heating model and parameters are identical to Problem 3. The flow rates, compositions and temperatures are as follows; T  PV [  7  & T VLQ Z W PV [  7  & TRXW  PV &S  N-NJ& and  NJP a) Develop mass balance component balance and energy balance over the buffer tank. Express the equation system in the states: height, composition and temperature. b) Write a 0RGHO ILOH for the equation system in a). Simulate the dynamic tank behaviour. Assume that Z . Plot the height, composition and temperature. c) Simulate the tank with one larger Z and one lower Z. Discuss the result.

Computer Exersice 1 - $ 6ROXWLRQ


3UREOHP  a) Assumptions: Well-mixed vessel means the same density in the whole tank and in outlet GP G9 GP = = Z1 + Z2 ZRXW = T1 + T 2 T RXW = (T1 + T 2 T RXW ) GW GW GW

+ Acc GP $ G[ Z) Z ( Z + Z5 ) Z) [) + Z5 [5 = Z0 [0 + [) + 5 [ 5 ) [ = GW GW P P P Z is mass flow; [ is composition of A b) An example of a dynamic (state space) model file. In
function dm=mixtankdyn(t,m)

= Out

( Z + Z5 ) G[ Z Z + E[ = D where D = ) [) + 5 [ 5 and E = ) GW P P P G[ D H EW + EH EW [ = H EW D G [HEW = H EW DGW [H EW = H EW + &1 E GW D D D [ (W ) = + &1H EW [(W = 0) = + &1 = [0 &1 = [0 E E E ( Z) + Z5 ) ( Z + Z5 ) ) W W D ( Z [ + Z5 [5 ) 1 H P + [0H P [ (W ) = 1 H EW + [0 H EW = ) ) E ( Z) + Z5 )

( )

% MIXTANK is a well-stirred tank model % with two inlets and one outlet. % Constant density. % parameters rho=1000; q1=0.1; q2=0.3; kout=0.1; % equations V=m/rho; w1=rho*q1; w2=rho*q2; wout=rho*kout*V; % mass balance on dynamic state space form dm = w1 + w2 wout; >WVROPVRO@ RGH
PL[WDQNG\Q
> @   SORW WVROPVRO

4000 3500 3000 2500 2000 1500 1000 500 0

10

20

30

40

50

60

70

80

90

100

( Z + Z5 ) G[ Z Z + E[ = D where D = ) [) + 5 [ 5 and E = ) GW P P P G[ D H EW + EH EW [ = H EW D G [HEW = H EW DGW [H EW = H EW + &1 E GW D D D [ (W ) = + &1H EW [(W = 0) = + &1 = [0 &1 = [0 E E E ( Z) + Z5 ) ( Z + Z5 ) ) W W D ( Z [ + Z5 [5 ) 1 H P + [0H P [ (W ) = 1 H EW + [0 H EW = ) ) E ( Z) + Z5 ) c) An example of a steady-state (residual) model file.

( )

function res=mixtankstat(m) % MIXTANK is a well-stirred tank model % with two inlets and one outlet. % Constant density. % parameters rho=1000; q1=0.1; q2=0.3; kout=0.1; % equations V=m/rho; w1=rho*q1; w2=rho*q2; wout=rho*kout*V; % mass balance on residual form res = w1 + w2 wout; PVRO I]HUR
PL[WDQNVWDW
 msol = 4.0000e+003

3UREOHP  a) Assumptions: b) The component balance is written in mixtank M-file. The model is solved using ode23.
type mixtank function dx=mixtank(t,x) % MIXTANK is a well-stirred tank model % with two inlets and one outlet. % Constant volume and density. % parameters V=4; rho=1000; q1=0.1; q2=0.3; x1=0.9; x2=0.1; % equations m=rho*V; w1=rho*q1; w2=rho*q2; % component balance dx = (w1*x1+w2*x2)/m -(w1+w2)/m*x; >W[@ RGH
PL[WDQN
> @  SORW W[

0.35

0.3

0.25

0.2

0.15

0.1

10

15

20

25

30

35

40

45

50

3UREOHP  a and b)Assumptions:

Constant volume and density means constant mass and that outlet mass flow is equal to the sum of the inflows Well-mixed vessel means the same enthalpy in the whole tank and in outlet Constant heat capacity

(Note that the temperature differential equation is mathematically idential with the component balance in Problem 1. It can be written as G[GW  D [ E! c) heated tank model is as follows.
W\SH KHDWWDQN function dTemp=heattank(t,Temp) % HEATTANK is a well-stirred heated tank model % with two inlets and one outlet. % Constant heat capacity, volume and density. % (pressure-volume work neglected) % parameters V=4; rho=1000; q1=0.1; q2=0.3; T1=10; T2=50; Ts=95; kh=5; Ah=75; Cp=4.18; % equations m=rho*V; w1=rho*q1; w2=rho*q2; % component balance dTemp = (w1*T1+w2*T2)/m +(kh*Ah)/(m*Cp)*(Ts-Temp)-(w1+w2)/m*Temp;

+ Acc G (PK) Z) K) + Z5 K5 + 4 = Z0 K0 + GW Z is mass flow; K is enthalpy K = & S (7 7UHI ) In G& S (7 7UHI ) =

= Out

( Z + Z5 ) GK Z) Z N $ = K) + 5 K5 + K K (7V 7 ) ) K GW P P P P

( Z + Z5 ) Z) Z N $ & S (7) 7UHI ) + 5 & S (75 7UHI ) + K K (7V 7 ) ) & S (7 7UHI ) GW P P P P ( Z + Z5 ) ( Z + Z5 ) N $ Z G7 Z) Z Z = &S & S7) + 5 & S75 + K K (7V 7 ) ) & S7 ) & S7UHI + 5 & S7UHI ) & S7UH P P GW P P P P P N $ ( Z + Z5 ) G7 Z) Z = 7) + 5 75 + K K (7V 7 ) ) 7 GW P P & SP P
>WWHPS@ RGH
KHDWWDQN
> @  SORW WWHPS

50 45 40 35 30 25 20 15 10

10

15

20

25

30

35

40

45

50

3UREOHP  See the solution in the lecture notes or in the Process Simulation compendium.
W\SH EXIIHUWDQN function dy=buffertank(t,y) % BUFFERTANK is a well-stirred open tank model % with two inlets and one outlet. % Constant heat capacity and density. % states z=y(1); %level x=y(2); %composition Temp=y(3);%temperature % parameters w=0.05; rho=1000; q1=0.1; q2=0.3+0.05*sin(w*t); qout=0.4; x1=0.9; x2=0.1; T1=10; T2=50; Ts=95; kh=5; Ah=75; Cp=4.18; Atank=6; % equations m=Atank*z*rho; w1=rho*q1; w2=rho*q2; wout=rho*qout; Q=kh*Ah*(Ts-Temp);

% balances dz = (w1+w2-wout)/(rho*Atank); dx = (w1*x1+w2*x2)/m -(w1+w2)/m*x; dTemp = (w1*T1+w2*T2)/m +Q/(m*Cp)-(w1+w2)/m*Temp; dy=[dz;dx;dTemp]; >W\@ RGH
EXIIHUWDQN
> @>@  SORW W\ 

1.4 1.35 1.3 1.25 1.2 1.15 1.1 1.05 1

20

40

60

80

100

120

140

160

180

200

You might also like