Unit 3, lesson 17

Mixing and Compartment Models

How a mass balance for the amount of a substance gives a differential equation, why perfect mixing ties the outflow to the concentration, and how variable volume and coupled compartments enter the model.

  • Video 17
  • Mixing and Motion Models

A tank holds 100 liters of brine with 100 grams of dissolved salt. Brine with 2 grams of salt per liter flows in at 3 liters per minute, and the mixed liquid drains at 1 liter per minute, so the tank slowly fills. How much salt does it hold an hour later, and how salty is the liquid then? This lesson answers such questions with a balance for the amount of salt, computes the concentration from that amount, and uses the same bookkeeping for two tanks that exchange liquid. Throughout, tt is time in minutes and a prime means d/dtd/dt.

Key terms

Mass balance

Definition Let M(t)M(t) be the amount of a substance in a compartment at time tt. A mass balance states that

M′(t)=rin(t)−rout(t),M'(t) = r_{\text{in}}(t) - r_{\text{out}}(t),

where rinr_{\text{in}} and routr_{\text{out}} are the rates at which the substance enters and leaves. If the substance is also produced or used up inside the compartment, for example by a reaction or by decay, that rate is added with its sign. Every term has units of amount per time. A stream with volume flow rate qq and concentration cc carries the substance at the rate qcqc, so a single inlet contributes rin=qincinr_{\text{in}} = q_{\text{in}}c_{\text{in}}.

In plain words When nothing is produced or used up inside, the amount changes at the rate it comes in minus the rate it goes out. Liters per minute times grams per liter gives grams per minute, which is the right unit for the rate of change of an amount in grams.

Example A tank holds 40 liters of water with 120 grams of dissolved salt. Pure water enters at 4 liters per minute and the well-mixed liquid leaves at 4 liters per minute, so the volume stays at 40 liters. The inflow carries no salt, and the outflow carries 4⋅M/40=M/104 \cdot M/40 = M/10 grams per minute. Hence

M′=−M10M' = -\frac{M}{10}

with M(0)=120M(0) = 120, and the amount is M(t)=120e−t/10M(t) = 120e^{-t/10} grams. After 10 minutes about 44.144.1 grams remain.

Amount and concentration

Definition The amount M(t)M(t) is the quantity of the substance in the compartment, for example grams of salt. The concentration is the amount per unit volume of liquid,

c(t)=M(t)V(t),c(t) = \frac{M(t)}{V(t)},

defined while the volume V(t)V(t) is positive, and measured in grams per liter when MM is in grams and VV in liters. Balances are written for the amount, because amounts add up and are what the streams carry in and out. When the volume changes, the quotient rule gives

c′=M′V−MV′V2,c' = \frac{M'V - MV'}{V^2},

so c′c' differs from M′/VM'/V by the term −MV′/V2-MV'/V^2, and the amount and the concentration can even change in opposite directions.

In plain words The amount says how much salt the tank holds, and the concentration says how salty each liter is. Adding pure water leaves the first unchanged and lowers the second.

Example A tank with 100 grams of salt in 100 liters has a concentration of 1 gram per liter. Pouring in 100 liters of pure water keeps the amount at 100 grams but halves the concentration to 0.50.5 gram per liter. In the filling tank of the variable volume example below, the amount keeps growing for as long as the tank has room, while the concentration stays below 2 grams per liter.

Perfect mixing

Definition A compartment is perfectly mixed, or well mixed, if the substance is spread uniformly through it at every instant. Then the liquid leaving through an outlet has the current concentration M(t)/V(t)M(t)/V(t), and the outflow rate in the mass balance is

rout(t)=qout(t) M(t)V(t).r_{\text{out}}(t) = q_{\text{out}}(t)\,\frac{M(t)}{V(t)}.

With this rule the balance becomes one equation for the single unknown MM. It is a modeling assumption and not a physical law. Layers of different concentration, slow stirring or a delay between inlet and outlet make the outlet concentration differ from M/VM/V, and then the equation describes a different tank.

In plain words Every liter that leaves is a fair sample of what the tank holds at that moment. That is what lets the outflow be computed from the amount and the volume alone.

Example At the start of the opening problem the tank holds 100 grams in 100 liters and drains at 1 liter per minute. Perfect mixing gives an outlet concentration of 1 gram per liter, so salt leaves at 1 gram per minute at that moment. The incoming concentration of 2 grams per liter does not appear in the outflow term. Writing qoutcinq_{\text{out}}c_{\text{in}} there is a common slip that treats the outgoing liquid as if it had never mixed with the tank.

Variable volume

Definition The liquid volume obeys its own balance V′=qin−qoutV' = q_{\text{in}} - q_{\text{out}}. With constant flows

V(t)=V0+(qin−qout) t,V(t) = V_0 + (q_{\text{in}} - q_{\text{out}})\,t,

and the model applies only while V(t)V(t) stays positive and within the capacity of the tank. With perfect mixing, constant flows and a constant incoming concentration, the amount satisfies the linear first-order equation

M′+qoutV(t) M=qin cin.M' + \frac{q_{\text{out}}}{V(t)}\,M = q_{\text{in}}\,c_{\text{in}}.

Its coefficient qout/V(t)q_{\text{out}}/V(t) depends on time whenever the volume changes and liquid drains, and the equation is solved with the integrating factor μ(t)=exp⁡(∫qout/V(t) dt)\mu(t) = \exp\bigl(\int q_{\text{out}}/V(t)\,dt\bigr). Since M=cVM = cV and V′=qin−qoutV' = q_{\text{in}} - q_{\text{out}}, the same assumptions give an equation for the concentration,

c′=qinV(t) (cin−c).c' = \frac{q_{\text{in}}}{V(t)}\,\bigl(c_{\text{in}} - c\bigr).

So while liquid flows in, the concentration moves toward cinc_{\text{in}} without ever crossing it, and it stays at cinc_{\text{in}} if it starts there. While the tank only drains, the concentration stays constant.

In plain words When more liquid enters than leaves, the salt is spread through more and more liquid, so each liter that drains carries less salt than it would from a smaller tank holding the same amount. The outflow coefficient shrinks as the tank fills.

Example In the opening problem V0=100V_0 = 100, qin=3q_{\text{in}} = 3, cin=2c_{\text{in}} = 2 and qout=1q_{\text{out}} = 1, in liters, liters per minute and grams per liter. So V=100+2tV = 100 + 2t and

M′+M100+2t=6,M(0)=100.\begin{gathered} M' + \frac{M}{100 + 2t} = 6, \\[0.4em] M(0) = 100. \end{gathered}

Since ∫dt/(100+2t)=12ln⁡(100+2t)\int dt/(100 + 2t) = \tfrac{1}{2}\ln(100 + 2t), the integrating factor is V\sqrt{V}, and multiplying gives (MV)′=6V(M\sqrt{V})' = 6\sqrt{V}. Using V′=2V' = 2, the derivative of 2V3/22V^{3/2} is 3V1/2V′=6V3V^{1/2}V' = 6\sqrt{V}, so MV=2V3/2+CM\sqrt{V} = 2V^{3/2} + C. At t=0t = 0 this reads 100⋅10=2000+C100 \cdot 10 = 2000 + C, so C=−1000C = -1000 and

M(t)=2V−1000V,c(t)=2−1000V3/2.\begin{aligned} M(t) &= 2V - \frac{1000}{\sqrt{V}}, \\[0.4em] c(t) &= 2 - \frac{1000}{V^{3/2}}. \end{aligned}

Substituting back, M′=4+1000V−3/2M' = 4 + 1000V^{-3/2} equals 6−M/V6 - M/V, and M(0)=100M(0) = 100. After an hour the volume is 220 liters, the amount is about 372.6372.6 grams and the concentration about 1.691.69 grams per liter, rising from 1 toward 2. Keeping the starting volume in the outflow term would give M′=6−M/100M' = 6 - M/100 and only about 325.6325.6 grams after an hour, because that equation overstates how salty the outflow is.

Coupled compartments

Definition A compartment model splits a system into well-mixed compartments with amounts M1,…,MnM_1, \dots, M_n and volumes V1,…,VnV_1, \dots, V_n, and writes one mass balance for each. A flow qq from compartment ii to compartment jj removes the substance from compartment ii at the rate qMi/ViqM_i/V_i and adds it to compartment jj at the same rate. Each volume follows its own balance and stays constant when as much liquid flows into the compartment as flows out. The balances form a system of first-order equations, coupled because the rate of change of each amount depends on the others. In a closed system, where no substance enters or leaves from outside and none is produced or used up, each transfer term appears once with each sign. The balances then add up to zero, and the total amount M1+⋯+MnM_1 + \cdots + M_n is constant.

In plain words Transfers move salt from one tank to another without creating or destroying it. Each transfer is a loss in one balance and the same gain in another, so it cancels when the balances are added.

Example Two well-mixed tanks of 10 liters each exchange liquid at 1 liter per minute in each direction, so both volumes stay at 10 liters, and no salt enters or leaves from outside. Then

M1′=−M110+M210,M2′=M110−M210.\begin{aligned} M_1' &= -\frac{M_1}{10} + \frac{M_2}{10}, \\[0.4em] M_2' &= \frac{M_1}{10} - \frac{M_2}{10}. \end{aligned}

Start with M1(0)=20M_1(0) = 20 and M2(0)=10M_2(0) = 10 grams. The total S=M1+M2S = M_1 + M_2 has S′=0S' = 0, so S=30S = 30. The difference D=M1−M2D = M_1 - M_2 satisfies D′=−D/5D' = -D/5 with D(0)=10D(0) = 10, so D=10e−t/5D = 10e^{-t/5}. Recovering each amount as (S±D)/2(S \pm D)/2 gives

M1(t)=15+5e−t/5,M2(t)=15−5e−t/5.\begin{aligned} M_1(t) &= 15 + 5e^{-t/5}, \\[0.4em] M_2(t) &= 15 - 5e^{-t/5}. \end{aligned}

Both amounts approach 15 grams, where the two concentrations are equal at 1.51.5 grams per liter. Equal concentrations mean equal amounts here only because the volumes are equal.

Check yourself

  1. A 20 liter tank holds pure water. Brine with 4 grams of salt per liter flows in at 2 liters per minute, and the well-mixed liquid flows out at 2 liters per minute. Find the amount of salt M(t)M(t) and the time at which the concentration reaches 2 grams per liter.
Show the answer

The volume stays at 20 liters. Salt enters at 2⋅4=82 \cdot 4 = 8 grams per minute and leaves at 2⋅M/20=M/102 \cdot M/20 = M/10 grams per minute, so M′=8−M/10M' = 8 - M/10 with M(0)=0M(0) = 0. The difference M−80M - 80 satisfies (M−80)′=−(M−80)/10(M - 80)' = -(M - 80)/10 and starts at −80-80, which gives

M(t)=80(1−e−t/10).M(t) = 80\bigl(1 - e^{-t/10}\bigr).

The concentration is c=M/20=4(1−e−t/10)c = M/20 = 4\bigl(1 - e^{-t/10}\bigr). It equals 2 when e−t/10=12e^{-t/10} = \tfrac{1}{2}, that is at t=10ln⁡2≈6.93t = 10\ln 2 \approx 6.93 minutes.

  1. Suppose the filling tank of the variable volume example holds at most 300 liters, and once it is full the extra liquid spills over the top. For which times does the formula M=2V−1000/VM = 2V - 1000/\sqrt{V} apply, how much salt is in the tank when it becomes full, and which equation describes the amount afterwards?
Show the answer

The formula assumes V=100+2tV = 100 + 2t, which reaches 300 liters at t=100t = 100 minutes, so it applies for 0≤t≤1000 \le t \le 100. At that moment

M(100)=600−1000300≈542.3\begin{aligned} M(100) &= 600 - \frac{1000}{\sqrt{300}} \\[0.4em] &\approx 542.3 \end{aligned}

grams, a concentration of about 1.811.81 grams per liter. Afterwards the volume stays at 300 liters and liquid leaves at 3 liters per minute in total, 1 through the outlet and 2 over the top. With perfect mixing both streams have the concentration M/300M/300, so for t≥100t \ge 100

M′=6−M100,M' = 6 - \frac{M}{100},

starting from M(100)≈542.3M(100) \approx 542.3. The amount now approaches 600 grams, which is again 2 grams per liter. Using the old formula past t=100t = 100 would overstate the amount, because it describes a tank that never overflows.

  1. Two well-mixed tanks of 10 liters and 20 liters exchange liquid at 2 liters per minute in each direction, and nothing enters or leaves from outside. Tank 1 starts with 30 grams of salt and tank 2 with none. A classmate expects each tank to end up with 15 grams. Find both amounts as functions of time and their limits.
Show the answer

The volumes stay at 10 and 20 liters, and the balances are

M1′=−2M110+2M220,M2′=2M110−2M220.\begin{aligned} M_1' &= -\frac{2M_1}{10} + \frac{2M_2}{20}, \\[0.4em] M_2' &= \frac{2M_1}{10} - \frac{2M_2}{20}. \end{aligned}

Adding them shows that the total stays at 30 grams, so M2=30−M1M_2 = 30 - M_1 and

M1′=−M15+30−M110=3−3M110.\begin{aligned} M_1' &= -\frac{M_1}{5} + \frac{30 - M_1}{10} \\[0.4em] &= 3 - \frac{3M_1}{10}. \end{aligned}

The equilibrium is M1=10M_1 = 10, and with M1(0)=30M_1(0) = 30 the solution is M1=10+20e−3t/10M_1 = 10 + 20e^{-3t/10}, so M2=20−20e−3t/10M_2 = 20 - 20e^{-3t/10}. The limits are 10 grams and 20 grams, which is 1 gram per liter in each tank. The exchange balances when the concentrations agree, which here is not when the amounts agree. With 15 grams in each tank, the first would hold 1.51.5 grams per liter and the second 0.750.75, and the exchange would keep moving salt into the second tank.

How this lesson connects