None Notebook

This notebook contains material from CBE30338; content is available on Github.

< 2.1 Process Variables | Contents | Tag Index | 2.3 Blending Tank Simulation >

Open in Colab

Download

2.2 Gravity Drained Tank

2.2.1 Summary

In the example we study the problem of constructing nonlinear process model for the liquid level in a gravity drained tank.

2.2.2 Torricelli's law

Torricelli's law states the velocity of an incompressible liquid stream exiting a liquid tank at level $h$ below the surface is

$$v = \sqrt{2gh}$$

This is the same velocity as an object dropped from a height $h$. The derivation is straightforward. From Bernoulli's principle,

$$\frac{v^2}{2} + gh + \frac{P}{\rho} = \text{constant}$$

Applying this principle, compare a drop of water just below the surface of the water at distance $h$ above the exit, to a drop of water exiting the tank

$$gh + \frac{P_{atm}}{\rho} = \frac{v^2}{2} + \frac{P_{atm}}{\rho}$$$$\implies v^2 = 2gh$$$$\implies v = \sqrt{2gh}$$

Torricelli's law is an approximation that doesn't account for the effects of fluid viscosity, the specific flow geometry near the exit, or other flow non-idealities. Nevertheless it is a useful first approximation for flow from a tank.

2.2.3 Mass Balance for Tank with Constant Cross-Sectional Area

For a tank with constant cross-sectional area, such as a cylindrical or rectangular tank, the liquid height is described by a differential equation

$$A\frac{dh}{dt} = q_{in}(t) - q_{out}(t)$$

where $q_{out}$ is a function of liquid height. Torricelli's law tells the outlet flow from the tank is proportional to square root of the liquid height

$$ q_{out}(h) = C_v\sqrt{h} $$

Dividing by area we obtain a nonlinear ordinary differential equation

$$ \frac{dh}{dt} = - \frac{C_V}{A}\sqrt{h} + \frac{1}{A}q_{in}(t) $$

in our standard form where the LHS derivative appears with a constant coefficient of 1.

2.2.4 Step-by-Step Approach to Nonlinear Simulation

2.2.4.1 Step 1. Initialize Jupyter and Python

The first step in any Python application is to initialize graphics display (if you will be creating graphic output), and import any needed libraries.

The %matplotlib inline is a command telling the Jupyter notebook to display any graphics inside this notebook.

We then import a standard graphics library (matplotlib.pyplot) that will be referred to with the prefix plt, a standard numerical library numpy that will be referred to with the prefix np, and the function odeint from the scipy.integrate library.

2.2.4.2 Step 2. Define parameters

Provide values for all relevant parameters. Use comments to describe the parameters and units.

2.2.4.3 Step 3. Write Functions for the RHS of the Differential Equations

2.2.4.4 Step 4. Choose an Initial Condition, a Time Grid, and Integrate the Differential Equation

2.2.4.5 Step 5. Visualize and Analyze Results

2.2.4.6 Step 6. Adjust and Repeat as Needed

Rarely does a simulation provide you with the information you seek on the first try. You will almost certainly need to revise parameter values, choose different time grids, and add visualization features to obtain the most informative results.

< 2.1 Process Variables | Contents | Tag Index | 2.3 Blending Tank Simulation >

Open in Colab

Download