Simple Tank
===
- total mass balance:
$\begin{Bmatrix}\text{mass}\\ \text{accumulation}\end{Bmatrix} = \begin{Bmatrix}\text{sum}\\ \text{of mass}\\ \text{inflows}\end{Bmatrix} - \begin{Bmatrix}\text{sum}\\ \text{of mass}\\ \text{outflows}\end{Bmatrix}$
\
$\dfrac{\text dm(t)}{\text dt} = \dot m_\text{in}(t) - \dot m_\text{out}(t) \qquad \qquad m(t)=\rho(t)V(t), \ \dot m(t)=\rho(t)q(t)$
- assume $\rho$ is constant
\
$\dfrac{\text dV(t)}{\text dt} = q_\text{in}(t) - q_\text{out}(t)$
- output equation
\
$h(t) = V(t)/A \qquad \qquad$ note: $A$ is a constant parameter
#### Blender (Tank with two inflows and a dissolved substance)

- equation for the total mass balance from the simple tank example holds (note: assumption of constant density might not); there are two inflows though:
$\dfrac{\text dm(t)}{\text dt} = \dot m_\text{in,1}(t) + \dot m_\text{in,2}(t) - \dot m_\text{out}(t)$
- component mass balance:
$\begin{Bmatrix}\text{component}\\ \text{mass}\\ \text{accumulation}\end{Bmatrix} = \begin{Bmatrix}\text{sum of}\\ \text{component}\\ \text{mass inflows}\end{Bmatrix} - \begin{Bmatrix}\text{sum}\\ \text{of component}\\ \text{mass outflows}\end{Bmatrix}$
\
$\dfrac{\text d\left[c(t)m(t)\right]}{\text dt} = c_\text{in,1}(t)\dot m_\text{in,1}(t) + c_\text{in,2}(t)\dot m_\text{in,2}(t) - c(t)\dot m_\text{out}(t) \quad \ [c(t)]=\dfrac{\text{kg of component}}{\text{kg of solution}}$
\
$m(t)\dfrac{\text dc(t)}{\text dt} + c(t)\underbrace{\dfrac{\text dm(t)}{\text dt}}_{\dot m_\text{in,1}(t) + \dot m_\text{in,2}(t) - \dot m_\text{out}(t)} = c_\text{in,1}(t)\dot m_\text{in,1}(t) + c_\text{in,2}(t)\dot m_\text{in,2}(t) - c(t)\dot m_\text{out}(t)$
\
$m(t)\dfrac{\text dc(t)}{\text dt} + c(t)\left[\dot m_\text{in,1}(t) + \dot m_\text{in,2}(t) - \dot m_\text{out}(t)\right] = c_\text{in,1}(t)\dot m_\text{in,1}(t) + c_\text{in,2}(t)\dot m_\text{in,2}(t) - c(t)\dot m_\text{out}(t)$
- cancel $- c(t)\dot m_\text{out}(t)$ on both sides
$m(t)\dfrac{\text dc(t)}{\text dt} = - c(t)\left[\dot m_\text{in,1}(t) + \dot m_\text{in,2}(t)\right] + c_\text{in,1}(t)\dot m_\text{in,1}(t) + c_\text{in,2}(t)\dot m_\text{in,2}(t)$
- complete (nonlinear) model
$\dfrac{\text dm(t)}{\text dt} = \dot m_\text{in,1}(t) + \dot m_\text{in,2}(t) - \dot m_\text{out}(t)$
$m(t)\dfrac{\text dc(t)}{\text dt} = - c(t)\left[\dot m_\text{in,1}(t) + \dot m_\text{in,2}(t)\right] + c_\text{in,1}(t)\dot m_\text{in,1}(t) + c_\text{in,2}(t)\dot m_\text{in,2}(t)$
- simplified model (const. total mass $\text dm(t)/\text dt = \dot m_\text{in,1}(t) + \dot m_\text{in,2}(t) - \dot m_\text{out}(t)=0$)
- this hold if $\dot m_\text{out}$ manipulated by a controller
$m\dfrac{\text dc(t)}{\text dt} = - c(t)\underbrace{\left[\dot m_\text{in,1}(t) + \dot m_\text{in,2}(t)\right]}_{\dot m_\text{out}} + c_\text{in,1}(t)\dot m_\text{in,1}(t) + c_\text{in,2}(t)\dot m_\text{in,2}(t)$
- final simplified model
$m\dfrac{\text dc(t)}{\text dt} = - c(t)\dot m_\text{out}(t) + c_\text{in,1}(t)\dot m_\text{in,1}(t) + c_\text{in,2}(t)\dot m_\text{in,2}(t)$
- steady state of a model (full or simplified)
$c = \dfrac{c_\text{in,1}\dot m_\text{in,1} + c_\text{in,2}\dot m_\text{in,2}}{\dot m_\text{out}} = \dfrac{c_\text{in,1}\dot m_\text{in,1} + c_\text{in,2}\dot m_\text{in,2}}{\dot m_\text{in,1} + \dot m_\text{in,2}}$
$c = \underbrace{\dfrac{\dot m_\text{in,1}}{\dot m_\text{out}}}_{K_1}c_\text{in,1} + \underbrace{\dfrac{\dot m_\text{in,2}}{\dot m_\text{out}}}_{K_2}c_\text{in,2} = \underbrace{\dfrac{\dot m_\text{in,1}}{\dot m_\text{in,1} + \dot m_\text{in,2}}}_{K_1}c_\text{in,1} + \underbrace{\dfrac{\dot m_\text{in,2}}{\dot m_\text{in,1} + \dot m_\text{in,2}}}_{K_2}c_\text{in,2}$
- finding the time constant of a simplified model
$\underbrace{\dfrac{m(t)}{\dot m_\text{out}(t)}}_T\dfrac{\text dc(t)}{\text dt} = - c(t) + \dfrac{\dot m_\text{in,1}(t)}{\dot m_\text{out}(t)}c_\text{in,1}(t) + \dfrac{\dot m_\text{in,2}(t)}{\dot m_\text{out}(t)}c_\text{in,2}(t)$
$G(s) =\dfrac{Y(s)}{U(s)}= \dfrac{K}{Ts+1} \ \to \ Ty'(t) = -y(t) + Ku(t)$
$Y(s)(Ts+1)= KU(s)$
$y(t) + Ty'(t)=Ku(t)$
$Ty'(t) = -y(t) + Ku(t)$
- further simplification ($c_{\text{in},2}(t)=0$, $c_{\text{in}}(t)\equiv c_{\text{in},1}(t)$, $m_{\text{in}}(t)\equiv m_{\text{in},1}(t)$), i.e. we are diluting the first stream by the second one in the blender
$\underbrace{\dfrac{m(t)}{\dot m_\text{out}(t)}}_T\dfrac{\text dc(t)}{\text dt} = - c(t) + \underbrace{\dfrac{\dot m_\text{in}(t)}{\dot m_\text{out}(t)}}_{K_{c_\text{in}\to c}}\underbrace{c_\text{in}(t)}_{\text{DV}} = - c(t) + \underbrace{\dfrac{c_\text{in}(t)}{\dot m_\text{out}(t)}}_{K_{\dot m_\text{in}\to c}}\underbrace{\dot m_\text{in}(t)}_{\text{MV}}$
- note $[T]=\text s$
$Ty'(t) = -y(t) + Ku(t)$
$Ty'(0) = -y(0) + Ku(0)$
$y'(0) = K/T$
$y(t) = K (1 - \text e^{-\frac{t}{T}})$
$Y(s)(Ts+1)= KU(s) \to Y(s)(Ts+1)= \dfrac{K}{s}$
$Y(s)= \dfrac{K}{s(Ts+1)} = \dfrac{A}{s} + \dfrac{B}{Ts+1}$
$K = A(Ts+1) + Bs$
$s^0: \ K=A$
$s^1: \ 0=AT+B \to B = -AT = -KT$
$Y(s)= \dfrac{K}{s} + \dfrac{-KT}{Ts+1}= \dfrac{K}{s} + \dfrac{-K}{s+1/T}$
$\mathcal L\{\text e^{-at}\}=\dfrac{1}{s+a}$
$y(t) = K(1-\text e^{-\frac{t}{T}})$
$y(T) = K (1 - \text e^{-\frac{T}{T}}) = K (1-e^{-1}) = K(1-0.3679) = 0.6321K$