Basic ODE story – tank with pumps

applicationsmathematical modelingordinary differential equations

Full tank has $500$ liter of water containing $0.2\%$ of salt. One pipe pumps clear water in ($100$ liters per minute) and the other gets the mixture from the tank ($100$ liters per minute too). Assume salt dissolves in water instantly. Find the function that describes the concentration of salt in a tank at any given time $t$.


I solved this easily:
$$
x(t + \Delta t)500L = 500Lx(t) + \Delta t \frac{100L}{min}(0 – x(t))\\
\frac{x(t + \Delta t)500L – 500L x(t)}{\Delta t} = -x(t) \frac{100L}{min}\\
x' = -\frac{1}{5}x \implies x(t) = e^{-0.2t}
$$

Now, lets spin the example a little:

Our tank has 400 liter of water containing $0.5$% of salt. One pipe pumps the clear water in (10 liters per minute) and second one pumps the solution out (20 liters per minute).

How to find the solution then? The answer should be $x(t) = \frac{(t-40)^2}{800}$.

EDIT: I'd appreciate the downvoter to tell me why they think the question is not well suited to the stackexchange site.

Best Answer

You do the same thing, only now the volume is also variable, so that for the "salt mass" = "salt concentration" times "volume" you get $$ x(t+Δt)V(t+Δt)=x(t)V(t)-x(t)V_{out}Δt \\ V(t+Δt)=V(t)+(V_{in}-V_{out})Δt $$ so that applying the product rule of differentiation $$ \dot x(t)V(t)+x(t)\dot V(t)=-x(t)V_{out} \\ \dot V(t)=V_{in}-V_{out} $$ where $V_{out}=20L/min$ and $V_{in}-V_{out}=-10L/min$. This gives directly $V(t)=400-10t$, $t$ in minutes.

So it remains to solve a nice linear ODE $$ (400-10t)\dot x(t)+10x(t)=0 \implies x(t)=C(400-10t). $$ By the initial conditions $C=0.005/400=0.01/800$. As density and volume shrink linearly, their product, the total mass of salt in the tank, follow the quadratic law $$ x(t)V(t)=\frac{(40-t)^2}{800}. $$