Conservation of Mass#
import numpy as np
import matplotlib.pyplot as plt
import scipy.integrate as spi
Mass Balance Equation#
The law of conservation of mass states that the mass of a closed system does not change. This implies that mass cannot be created or destroyed. Conservation of mass implies the balance equation for an open system
where:
\(M(t)\) is the mass in the system over time \(t\)
\(Q_{in}\) is the mass flow rate into the system with dimensions MT-1
\(Q_{out}\) is the mass flow rate out of the system with dimensions MT-1
See also
Check out Wikipedia: Conservation of Mass for more information.
Dilution#
A tank contains a salt water solution. To dilute the solution, pure water is pumped into the tank and mixed. The solution is drained from the tank at the same rate as water is pumped into the tank. How does the concentration of the solution change over time?
Let’s define the variables and parameters in the model:
Description |
Symbol |
Dimensions |
Type |
---|---|---|---|
mass of salt in the tank |
\(M\) |
M |
dependent variable |
time |
\(t\) |
T |
independent variable |
initial mass of salt in the tank |
\(M_0\) |
M |
parameter |
flow rate of fluid in/out of the tank |
\(Q\) |
L3T-1 |
parameter |
volume of solution |
\(V_0\) |
L3 |
parameter |
Note that the rate of salt flowing out of the tank is \(\frac{MQ}{V}\). Apply the mass balance equation to get
Apply the nondimensionalization procedure. Let \(t = [t]t^*\) and \(M = [M]M^*\) and make the substitution
Choose \([t] = \frac{V}{Q}\) and \([M] = M_0\) and write
Solve the equation to find \(M^*(t) = e^{-t^*}\). Equivalently, \(M(t) = M_0e^{-Qt/V}\).
Withdrawing from a Pension#
The concept of mass transfer is very general! Consider the problem of withdrawing from a pension. A pension is a financial asset that earns interest and a retiree will withdraw funds from the pension for living expenses. Create a mathematical model of a retiree living on a pension.
Let’s define the variables and parameters in the model:
Description |
Symbol |
Dimensions |
Type |
---|---|---|---|
total value of the pension |
\(M\) |
N |
dependent variable |
time |
\(t\) |
T |
independent variable |
rate of return |
\(r\) |
T-1 |
parameter |
rate of withdrawal |
\(w\) |
NT-1 |
parameter |
Assume that the rate of return and rate of withdrawal are constant. Apply the mass balance equation to get
Apply the nondimensionalization procedure. Let \(t = [t]t^*\) and \(M = [M]M^*\) and make the substitution
Divide by the derivative coefficient
Choose \([t] = 1/r\) and \([M] = w/r\) and write
where \(M_0^* = \frac{rM_0}{w}\).
Solve the equation to find \(M^*(t) = (M_0^* - 1)e^{t^*} + 1\). Equivalently,
Two Tank System#
Suppose two tanks are connected such that solution from each tank flows into the other at the same rate. Now suppose salt water solution is pumped into the first tank at a constant rate and solution from the second tank is pumped out of the tank and removed from the system at the same rate so that the total volume of solution in the two-tank system reamins constant. Create a mathematical model of the salt concentration in both tanks.
Let’s define the variables and parameters in the model:
Description |
Symbol |
Dimensions |
Type |
---|---|---|---|
mass of salt tank 1 |
\(M_1\) |
M |
dependent variable |
mass of salt tank 2 |
\(M_2\) |
M |
dependent variable |
time |
\(t\) |
T |
independent variable |
salt concentration of solution flowing into tank 1 |
\(C\) |
M L-3 |
parameter |
flow rate of solution into tank 1 |
\(Q_1\) |
L3T-1 |
parameter |
flow rate of solution from tank 1 to tank 2 |
\(Q_0\) |
L3T-1 |
parameter |
volume of solution in tank 1 |
\(V_1\) |
L3 |
parameter |
Apply the mass balance equation to each tank to derive the equations
Apply the nondimensionalization procedure. Let \(t = [t]t^*\), \(M_1 = [M_1]M_1^*\) and \(M_2 = [M_2]M_2^*\) and make the substitution
Divide by the derivative coefficient in each equation
There are 3 unknowns and 6 coefficients and so there are many choices. Let’s choose
and then define the dimensionless parameters
Write the system in terms of the new dimensionless variables and parameters to get
Plot some solutions:
nu = 1
rho = 1
f = lambda u,t: np.array([1 + u[1] - nu*u[0],u[0] - (1+rho)/nu*u[1]])
u0 = [1,1]
t = np.linspace(0,10,100)
u = spi.odeint(f,u0,t)
plt.plot(t,u[:,0],t,u[:,1])
plt.legend(['Tank 1','Tank 2']), plt.grid(True)
plt.show()