Dynamics of two tanks in series​​Authors: Housam Binous and Ahmed Bellagi

Assume volumetric flow rate proportional to liquid volume in the tank :
​
​
q
i
(t)=
k
i
v
i
(t)
where i=1, 2. Initially the two tanks are empty.
​
Feed flow rate is constant equal to 1 except between t = β and t = 2 β where it drops to zero.
In[]:=
q
0
[t_]:=1-UnitStep[t-β]+UnitStep[t-2β]
In[]:=
Plot[
q
0
[t]/.β1,{t,0,5},PlotStyleDarker@Red,AspectRatio1,GridLinesAutomatic,FrameTrue,ImageSize400{1,1},PlotRange{-1,2},FrameLabel{Style["time",14],Style["feed flow rate",14]}]
Out[]=
Numerical solution of the governing equations for β = 1 and
k
i
=k=1.
In[]:=
sol=NDSolve[{(D[
v
1
[t],{t,1}]
q
0
[t]-k
v
1
[t])/.β1/.k1,(D[
v
2
[t],{t,1}]k
v
1
[t]-k
v
2
[t])/.β1/.k1,
v
1
[0]0,
v
2
[0]0},{
v
1
[t],
v
2
[t]},{t,0,10}]
Out[]=

v
1
[t]InterpolatingFunction
Domain: {{0.,10.}}
Output: scalar
[t],
v
2
[t]InterpolatingFunction
Domain: {{0.,10.}}
Output: scalar
[t]
Plotting volume of the second tank versus time
In[]:=
plt1=Plot[
v
2
[t]/.sol,{t,0,10},PlotStyleDarker@Red,AspectRatio1,GridLinesAutomatic,FrameTrue,ImageSize400{1,1},PlotRange{-0.1,1.1},FrameLabel{Style["time",14],Style["second tank volume",14]}]
Out[]=
An analytical solution for
v
2
can be obtained using Laplace Transform.
Eliminating
v
1
, one gets the following second order ODE:
Taking the Laplace Transform, one gets :
In[]:=
Q[s]=LaplaceTransform[
q
0
[t]/.β1,t,s]
Out[]=
1
s
+
-2s

s
-
-s

s
Taking the Inverse Laplace Transform, one obtains an expression for the volume of the second tank.
In[]:=
IV=InverseLaplaceTransform[k/(s+k)^2Q[s],s,t]
Out[]=
1
k
(
-k(-2+t)

(-1+
k(-2+t)

+2k-kt)HeavisideTheta[-2+t]+
-kt

(-1+
kt

-kt+(-
kt

+
k

(1+k(-1+t)))HeavisideTheta[-1+t]))
In[]:=
laplac
2
[t_]:=IV
Plotting the analytical solution for
v
2
(t)
.
In[]:=
plt2=Plot[
laplac
2
[t]/.k1,{t,0,10},PlotStyle{Dashed,Darker@Green},PlotStyleDarker@Red,AspectRatio1,GridLinesAutomatic,FrameTrue,ImageSize400{1,1},PlotRange{-0.1,1.1},FrameLabel{Style["time",14],Style["second tank volume",14]}]
Out[]=
Comparing the numerical and analytical solutions
In[]:=
Show[plt1,plt2]
Out[]=