TankProfiler, like its predecessor TankCalc, analyzes and provides data for various kinds of storage tanks. For a user-provided profile, it produces content volume, tables listing incremental volume correlated with sensor height and the reverse, surface area and surface volume.

When I first wrote my storage tank analyzer TankCalc, I had the idea that most storage tanks fell into a relatively small number of categories like that shown above — central cylinders with a few easily-described kinds of end caps. But since then I have received any number of inquiries from owners of oddly-shaped tanks — tanks with something other than a simple cylindrical middle section, and with any number of peculiar end caps, caps that don't fit into simple geometric categories.

In response I have created a much more flexible program, one that, instead of making assumptions about a tank's shape, accepts a user-created dimension profile of the tank, in the form of x,y Cartesian coordinates, and models the tank on that basis.

To use TankProfiler, a user creates a plain-text file containing a dimension profile of the tank to be analyzed. Such a file might contain these x,y coordinate pairs:

0,8
30,30
130,30
160,8

Each x,y coordinate pair provided to TankProfiler describes the perimeter of a circle whose center lies at y coordinate zero, and the circle forms part of the desired tank profile. Expressed another way, each x,y coordinate pair describes a circle having radius y and centered at coordinate x,0. Like this:

Remember that the y coordinates are radii, not diameters. With the above information, TankProfiler will model a tank that looks like this (this image is generated by TankProfiler):

The above example is intentionally simple (nevertheless representing a tank type that the prior program TankCalc cannot manage), but TankProfiler can analyze any number of more complex tank types. Another problem tank that has come to my attention is a large storage tank with stepped sides, another type that TankCalc cannot manage (this image is also produced by TankProfiler):

The above example uses TankProfiler's -u (upright) mode, for which the x and y coordinates are reversed. This example, whose dimensions are greatly exaggerated, turns out to be a fairly common large tank design, in which a very shallow cone (to simplify cleaning) at the bottom ascends into a series of wall sections of differing thicknesses, thickest at the bottom to bear the greater pressures, and thinnest at the top, to save construction costs. TankProfiler easily handles this complex tank type.

The computed volume is limited to the grayed area in the above graphic, and there is no limit to the number of volumes and voids that may be included in a complex profile. This means geometric profiles with multiple walls will be correctly analyzed. But because of this new capability, when writing tank profiles users must be sure that the profile's vectors rotate clockwise around volumes and counterclockwise around voids. Like this:

If this rule isn't followed, the profile will produce an overall negative volume, which will cause TankProfiler to exit with an error message:

Error: volume < 0

Provided with a user-created tank profile, beyond producing a picture to assure the user that he and TankProfiler are on the same wavelength, TankProfiler can produce most of the same results that TankCalc provides:

A table that provides partial tank volumes for given integral sensor heights, for any given sensor step size.

A table that's the reverse of the above — heights for integral volumes. For reasons given below, this table requires more time to generate.

The tank's interior volume, surface area and (if a wall thickness is provided) surface volume.

Results (1) and (2) above can be had for two tank orientations — horizontal and vertical (upright). Result (3) can be used to compute the tank's content weight, its empty weight, and its overall weight.

NOTE: To see a typical use for TankProfiler and see how a tank profile is generated, visit the TankProfiler Case History page.

Acquiring and Installing

Unlike TankCalc and most of my other programs, TankProfiler is a commmand-line application without a graphical user interface (GUI). I chose this design because it allows quick changes to accommodate new requirements over time. One of the problems with this program's predecessor TankCalc is that it's locked into its GUI, which makes changes difficult. Because it is a command-line application written in Python, TankProfiler is easy to modify to meet new requireents.

TankProfiler is Copyright 2013, P. Lutus and is released under the GPL.

Here is what you need to run TankProfiler:

The TankProfiler Python script — just right-click the link and save the script in its own directory under the name "tankprofiler.py".

Python, available for all platforms. Choose Python 2 (TankProfiler will run on Python 3, but requires minor changes to do so).

To support the plotting function, be sure the Python library matplotlib is installed.

If you want to export PDF versions of the generated tables, install wkhtmltopdf.

That's it.

Program Options and Details

TankProfiler will run on any platform on which Python runs. There are some minor differences between platforms that hopefully won't cause confusion in the following instructions.

When you have installed TankProfiler in its own directory, open a command shell in that directory and type:

This is a convenient way to convert volume results from cubic units into a more useful volume unit like gallons or liters. Any conversion factor may be entered. Remember that cubic units are divided by this factor to produce the displayed result.

-d DEC, --decimals=DEC
result decimal places, default 4

For reasons explained below, the default horizontal mode uses numerical integration and is therefore approximate (the upright (vertical) mode is exact). Because of this, remember when choosing displayed decimal places that not all displayed digits are necessarily meaningful. One way to increase numerical accuracy in the horizontal mode is to increase the number of integration steps (option -i below). This increases accuracy at the expense of runtime.

-D, --draw draw an image of the tank (and save 'tank.png')

This option will draw an image of the profiled tank if your system's Python installation has the matplotlib library installed. Some of the images in this article were generated using this option.

This option provides TankProfiler with a set of Cartesian x,y data pairs describing the tank as explained in the previous section. A typical entry might be:

$ ./tankprofiler.py -f myprofile.txt

The provided file should be plain text, but beyond that, the only formatting requirement is that numerical values for x and y follow each other in sequence, separated by whitespace or any other non-numeric characters.

Another option is to specify '-' as the "file name", which tells TankProfiler to read the standard input for its profile data. Here is an example:

$ echo "0 8 30 30 130 30 160 8" | ./tankprofiler.py -f -

-F OFILE, --ofile=OFILE
output file path (default: stdout)

This option allows entry of a file name for the output data. If no entry is made, the output appears on the standard output. Here are three ways to direct the program's output:

$ ./tankprofiler.py -f myprofile.txt [output appears on the console]

$ ./tankprofiler.py -f myprofile.txt > output.txt

$ ./tankprofiler.py -f myprofile.txt -F output.txt

When using the -H (HTML) and -P (PDF) output options described below, one may (should) specify a file name with an appropriate suffix.

-H, --html use HTML output format (default: CSV)

The default TankProfiler output format is CSV — simple comma-separated values, suitable for entering into a database or spreadsheet program. This option instead creates an HTML-formatted page containing a table of results that looks more or less like this:

This option is used to increase the accuracy of the numerical integrator used in the TankProfiler default horizontal mode. For most applications the default number of integration steps is more than adequate. Increasing the number of integration steps increases runtime.

-m MULT, --mult=MULT volume multiplier for oval tanks, default 1.0000

This is an easy way to acommodate tanks that have an oval cross-section. The entry represents the ratio of tank width to height, like this:

As an example, for a tank that is 36 inches in height and 48 inches in width, the provided profile would describe a cylindrical tank with an 18-inch radius (i.e. 36-inch diameter), and the -m option entry would be (48/36) 1.3333... With this option, all the volume values are adjusted to take the tank's width into account, while the height values are correct for the tank's overall height.

-n, --noprog don't print progress chars

Normally, during lengthy table generation, progress dots are printed to the console. This option suppresses the dots.

-P, --pdf use PDF output format (default: CSV)

As with the HTML option described above, instead of the default CSV output format, this option creates a PDF version of the generated table. This option requires that the wkhtmltopdf program be installed on your system.

-p, --plot plot coordinate points in graphic image

This option plots terminating coordinate points for each line of the graphic image (as in most examples on this page)

By default, TankProfiler creates an incremental table that correlates integral sensor heights with partial tank volumes. This option reverses the relationship and produces a table that correlates integral volumes with sensor heights. To do this, and because of the complexity of the required calculations, TankProfiler uses a root finder method. Root finders are easy to write but run slowly (they typically require eight times the processor time to arrive at a result).

-s STEP, --step=STEP table increment size, default 1.0000

This option accepts a table step size, either in height units or (for the -r reverse mode) volume units. This allows the user to choose the desired table resolution.

-S SOFFSET, --soff=SOFFSET
sensor offset value, default 0.0000

TankProfiler normally profiles the entire tank, from zero height to full height. This option accommodates any physical or other limitations that require the height scale to be offset by a fixed amount. Also see option -V below.

-t TITLE, --title=TITLE
HTML/pdf page title (default none)

This option accepts a title to be included with the -H HTML or -P PDF output options. Remember to encliose multi-word titles in quotes:

$ ./tankprofiler.py -f myprofile.txt -H -t "This is my table"

-u, --upright upright (vertical) tank mode (x and y reversed)

This option analyzes the tank in an upright orientation, as shown in the prior section — the tank's x and y coordinates are reversed. In the default horizontal mode, to produce partial volumes that correspond to sensor heights, an approximate numerical integration method must be used (described below). But in the upright mode, no numerical methods are required and the results are exact (at least as exact as the provided profile data). Because there is no numerical integration, the upright mode produces its results much faster.

-v, --version program version and additional information

This option prints the program version, a copyright notice, and provides an URL for the TankProfile home page.

-V VOFFSET, --voff=VOFFSET
volume offset value, default 0.0000

TankProfiler normally profiles the entire tank, from zero volume to full volume. This option accommodates any physical or other limitations that require the volume scale to be offset by a fixed amount. Also see option -S above.

-w WALL, --wall=WALL tank wall thickness, default 0.0000

This option accepts wall thickness information in the same units as the tank's dimensions, to allow a tank's surface volume to be computed. See -x below.

This option computes some extra values that are useful in a complete tank analysis, i.e. the full analytical volume (not an approximation), the tank's surface area in the input units squared, and the surface volume in the input units cubed if a wall thickness has been provided (see option -w above).

Technical Description

In essence, TankProfiler is a convenient wrapper around mathematical methods that generate its results. This section describes the equations and algorithms that produce those results.

The basic purpose of TankProfiler and its predecessor TankCalc is to correlate the position of a content-height sensor with the tank's partial content volume. For an upright cylindrical tank, such a correlation is trivial:

(1) Volume $ \displaystyle v = \pi r^2 y$

Where y = sensor height. But most tanks have a different shape or orientation, which makes the math more complicated. The next case beyond an upright cylinder, in terms of increasing complexity, is a horizontal cylinder:

The above equation is the key to the numerical integration method used in TankProfiler to compute frustum partial volumes in the horizontal mode. For tank sections that are in essence conical frustums, the numerical method uses this general scheme (for simplicity some details are left out):

The number n of summed disc results is governed by the TankProfiler -i value (default 1000), which is more than adequate for normal purposes.

Volume in Upright (vertical) Mode

For the TankProfiler upright mode, closed-form equations are used and there is no numerical computation, so the results are closed-form and as accurate as the user-supplied profile data. All tank sections that are not bisected by the sensor height y value are modeled as conical frustums using these area and volume equations (source):

(7) $ \displaystyle s = \sqrt{(r_a-r_b)^2 + h^2}$

(8) $ \displaystyle a = \pi (r_a+r_b) s $

(9) $ \displaystyle a = \pi (r_a+r_b) \sqrt{(r_a-r_b)^2 + h^2}$

(10) $ \displaystyle v = \frac{1}{3} \pi h (r_a^2 + r_a r_b + r_b^2)$

It's important to add that the above equations, meant to compute volumes and surface areas for conical frustums, are valid for the limiting cases where h = 0 (disk/washer) and ra = rb (cylinder).

While computing values for the above closed-form frustums as part of a complex tank, TankProfiler eventually gets to a frustum that's bisected by the y value (the sensor height). At that point equations written by the author are used to correlate sensor height y and the partial volume of the bisected frustum:

When computing surface area and surface volume, the same method is used in both the horizontal and upright modes. This means that, regardless of the selected mode, the surface computations are not approximate, but are as accurate as the provided data.