Tank Blending
![]() | ![]() | ![]() | ![]() |
|---|
Create a dynamic model of concentration and temperature based on a physics-based derivation from species and energy balance equations. A mixing tank has a liquid inlet stream and outlet stream. The tank is well mixed so the concentration and temperature are assumed to be the same throughout the reactor.

Start with the species and energy balance equations and derive the dynamic concentration and temperature response. Develop the concentration response and then add the temperature response. Assume a constant volume V of 100 m3 and an inlet flow rate `\dot V` or q of 100 m3/hr.
Solution: Species Balance
The first objective is to predict the concentration of A over a simulation time horizon. A species balance is created by relating the accumulation, inlet, and outlet terms of the number of moles n of species A. The accumulation of A, d(nA)/dt, in a control volume is calculated by inlet, outlet, reaction generation, and reaction consumption rates.
$$\frac{dn_A}{dt} = \sum \dot n_{A_{in}} - \sum \dot n_{A_{out}} + \sum \dot n_{A_{gen}} - \sum \dot n_{A_{cons}}$$
The molar amount, nA is often measured as a concentration, cA. In this application there are no reaction terms so the species balance can be simplified.
$$\frac{dc_A V}{dt} = c_{A_{in}} \dot V_{in} - c_{A_{out}} \dot V_{out}$$

import matplotlib.pyplot as plt
from scipy.integrate import odeint
# define mixing model
def mixer(x,t,Tf,Caf):
# Inputs (2):
# Tf = Feed Temperature (K)
# Caf = Feed Concentration (mol/m^3)
# States (2):
# Concentration of A (mol/m^3)
Ca = x[0]
# Parameters:
# Volumetric Flowrate (m^3/hr)
q = 100
# Volume of CSTR (m^3)
V = 100
# Calculate concentration derivative
dCadt = q/V*(Caf - Ca)
return dCadt
# Initial Condition
Ca0 = 0.0
# Feed Temperature (K)
Tf = 300
# Feed Concentration (mol/m^3)
Caf = 1
# Time Interval (min)
t = np.linspace(0,10,100)
# Simulate mixer
Ca = odeint(mixer,Ca0,t,args=(Tf,Caf))
# Construct results and save data file
# Column 1 = time
# Column 2 = concentration
data = np.vstack((t,Ca.T)) # vertical stack
data = data.T # transpose data
np.savetxt('data.txt',data,delimiter=',')
# Plot the results
plt.plot(t,Ca,'r-',linewidth=3)
plt.ylabel('Ca (mol/L)')
plt.legend(['Concentration'],loc='best')
plt.xlabel('Time (hr)')
plt.show()
Exercise: Add Energy Balance
An energy balance for this application starts with the balance equation for enthalpy, h. Enthalpy is related to temperature as m cp (T-Tref) where cp is the heat capacity. With a constant reference temperature (Tref), this reduces to the following.
$$m\,c_p\frac{dT}{dt} = \sum \dot m_{in} c_p \left( T_{in} - T_{ref} \right) - \sum \dot m_{out} c_p \left( T_{out} - T_{ref} \right) + Q + W_s$$
There is no heat input `Q`, shaft work `W_s`, or reaction. Reduce this energy balance by eliminating any terms and simplifying the expression. Implement the additional energy balance equation and simulate a feed temperature change from 350 K to 300 K. The tank fluid is initially at 350 K. The liquid heat capacity is constant and does not depend on the concentration of A.
Energy Balance Solution
TCLab Exercise
See TCLab Radiative Heat Transfer
Generative AI Learning
Use these prompts to test your understanding after completing the exercise. Direct the AI - do not let it do the exercise for you.
App: Simulate without code in the Blending Tank Control Studio - step the feed concentration and dilution flow, watch the outlet concentration lag with the tank color tracking composition, and export the CSV for your report.
What to Turn In
Submit a short report (PDF, 1-2 pages) that curates your results into a demonstration of what you learned. You may use Generative AI to help write the report, but you must guide it to the correct visualizations, justifications, and assumptions. Answer these questions:
- Include your simulation plot (Python or app) of outlet concentration for a step in inlet concentration. What is the time constant, and how does it compare to V/q?
- Show the balance equations with your assumptions listed, and verify the steady-state outlet concentration by hand.
- From the app: what did the dilution-flow disturbance do to the outlet concentration, and how long did recovery take relative to V/q?
- From the flawed-derivation prompt: what was the planted error and did you catch it?



