Dynamics of two tanks in series  
Author's Data: Housam BINOUS
Department of Chemical Engineering
National Institute of Applied Sciences and Technology
Tunis, TUNISIA
Email: binoushousam@yahoo.com

Assume volumeric flowrate proportional to liquid volume in the tank :  \(TraditionalForm\`q\_i\ \((t)\)\  = \ \(\(k\_i\)\(\ \)\(\(v\_\(\(i\)\(\ \)\)\)(t)\)\(\ \)\)\) where i=1, 2. Initially the two tanks are empty.

Feed flowrate is constant equal to 1 except between t = β and t = 2 β where it drops to zero.

(Subscript[q, 0])[t_] := 
      1 - UnitStep[t - β] + UnitStep[t - 2 β]

Plot[(Subscript[q, 0])[t] /. β -> 1, {t, 0, 5}, 
      PlotStyle -> RGBColor[1, 0, 0], 
      PlotRange -> {-1, 2}]

Numerical solution of the governing equations for β = 1 and (Subscript[k, i]) = k = 1.

sol = 
      NDSolve[{(D[(Subscript[v, 1])[t], {t, 1}] == 
                  (Subscript[q, 0])[t] - k (Subscript[v, 1])[t]) /. β -> 1 /. 
            k -> 
              1, (D[(Subscript[v, 2])[t], {t, 1}] == 
                  k (Subscript[v, 1])[t] - k (Subscript[v, 2])[t]) /. β -> 1 /. 
            k -> 1, (Subscript[v, 1])[0] == 0, (Subscript[v, 2])[0] == 0}, {(Subscript[v, 1])[t], 
          (Subscript[v, 2])[t]}, {t, 0, 10}]

Plotting volume of the second tank versus time

plt1 = 
      Plot[(Subscript[v, 2])[t] /. sol, {t, 0, 10}, PlotStyle -> RGBColor[1, 0, 0], 
        PlotRange -> {0, 1}]

An analytical solution  for (Subscript[v, 2]) can be obtained using Laplace Transform.

Eliminating (Subscript[v, 1]), one gets the following second order ODE:

Taking the Laplace Transform, one gets :

Q[s] = LaplaceTransform[(Subscript[q, 0])[t] /. β -> 1, t, s]

Taking the Inverse Laplace Transform, one obtains an expression for the volume of the second tank.

IV = InverseLaplaceTransform[k/(s + k)^2 Q[s], s, t]

(Subscript[laplac, 2])[t_] := IV

Plotting the analytical solution for (Subscript[v, 2])(t).

plt2 = 
      Plot[(Subscript[laplac, 2])[t] /. k -> 1, {t, 0, 10}, 
        PlotStyle -> RGBColor[0, 1, 0], 
        PlotRange -> {0, 1}]

Comparing the numerical and analytical solutions

Show[plt1,plt2]

Plotting (Subscript[v, 2])(t) for β  =  1 and k =  
          10,  2,  1,  0.5 and 0.1

plt3 = 
      Plot[{k (Subscript[laplac, 2])[t] /. k -> 10, k (Subscript[laplac, 2])[t] /. k -> 2, 
          k (Subscript[laplac, 2])[t] /. k -> 1, k (Subscript[laplac, 2])[t] /. k -> 0.5, 
          k (Subscript[laplac, 2])[t] /. k -> 0.1}, {t, 0, 10}, 
        PlotStyle -> Table[Hue[i/5], {i, 1, 5}], 
        PlotRange -> All]