This simulation models a stirred-tank blending process in which two inlet streams (stream 1 with mass fraction \(x_1\) of species A and stream 2 with \(x_2 = 0\)) mix in a tank, and a single outlet stream leaves the tank. Select a view with the buttons at the top:
Use the sliders to set the nominal flow rates \(w_1\) and \(w_2\), the size of the step change \(\Delta w_1\), the inlet mass fraction \(x_1\), and the initial mass fraction \(x_0\) in the tank. Setting \(x_0\) different from \(\bar{x}\) starts the system away from steady state.
A total mass balance and a species-A mass balance on the well-mixed tank, with constant density \(\rho\), yield the nonlinear model:
\[ \frac{dV}{dt} = \frac{1}{\rho}\left(w_1 + w_2 - w\right) \] \[ \frac{dx}{dt} = \frac{1}{\rho V}\left[\,w_1\,(x_1 - x) + w_2\,(x_2 - x)\,\right] \]where \(V\) is the tank volume (m\(^3\)), \(x\) is the mass fraction of species A in the tank and in the outlet stream, \(w_1\) and \(w_2\) are the inlet mass flow rates (kg/s), \(w\) is the outlet mass flow rate (kg/s), and \(x_1\) and \(x_2\) are the inlet mass fractions. At steady state, the mass fraction in the tank is:
\[ \bar{x} = \frac{w_1 x_1 + w_2 x_2}{w_1 + w_2} \]The volume does not have a unique steady state; because filling a tank is an integrating process, \(V\) increases or decreases without bound whenever the inlet and outlet flow rates differ. A desired operating volume \(\bar{V}\) (here the initial volume) is therefore specified.
Linearizing around \((\bar{V}, \bar{x})\) with the nominal inputs \(\bar{u} = (\bar{w}_1, \bar{w}_2, \bar{w})\) and defining the deviation variables \(V' = V - \bar{V}\), \(x' = x - \bar{x}\), \(w_1' = w_1 - \bar{w}_1\), \(w_2' = w_2 - \bar{w}_2\), and \(w' = w - \bar{w}\) gives the state-space model \(\dot{\mathbf{x}} = A\mathbf{x} + B\mathbf{u}\) with state \(\mathbf{x} = (V',\,x')\) and input \(\mathbf{u} = (w_1',\,w_2',\,w')\):
\[ A = \begin{bmatrix} 0 & 0 \\[4pt] 0 & \dfrac{-(\bar{w}_1 + \bar{w}_2)}{\rho \bar{V}} \end{bmatrix} \qquad B = \begin{bmatrix} \dfrac{1}{\rho} & \dfrac{1}{\rho} & -\dfrac{1}{\rho} \\[8pt] \dfrac{x_1 - \bar{x}}{\rho \bar{V}} & \dfrac{x_2 - \bar{x}}{\rho \bar{V}} & 0 \end{bmatrix} \]The volume equation is linear and independent of \(x\), so the linear model reproduces it exactly. The mass-fraction response of the linear model is approximate, but for a small step change the agreement with the nonlinear model is good. The steady-state gain matrix \(K = C(-A)^{-1}B + D\) cannot be evaluated because \(A\) is singular, which reflects the absence of a unique steady-state volume. Parameter values: \(\rho = 1000\) kg/m\(^3\), \(x_2 = 0\), \(\bar{V} = V_0 = 10\) m\(^3\), and a simulation time of 3600 s. The equations are integrated with a fourth-order Runge–Kutta method.
This browser-based simulation was created by John L. Falconer using Claude AI. It is based on a MATLAB simulation by Martha Grover (Georgia Institute of Technology, 2017) and its Python translation by John Hedengren (Brigham Young University, 2017) for a blending-process screencast series on dynamic simulation, steady states, deviation variables, and linearization.
It was prepared with support from the National Science Foundation (grants DUE 2336987 and DUE 2336988) as part of the LearnChemE project at the Department of Chemical and Biological Engineering, University of Colorado Boulder.