Introduction

Again, if a tank has known, normal geometric dimensions and no internal irregularities, then TankCalc is a better approach — it's simpler and less labor-intensive. But if a tank has internal obstructions, is oddly shaped, is buried or is otherwise inaccessible, and for whatever reason cannot be described in simple geometric terms, then TankFlow may be a better approach.

TankFlow uses a different approach — it requires that the tank be filled in a controlled way, while recording times, flow rates, and content sensor heights, then it performs some mathematics to create a profile.

TankFlow produces storage tank volume profiles, a central issue in the use of storage tanks. There are a number of ways to profile a storage tank, some easy, some difficult. TankCalc , another of my programs, models a tank using geometry — if a tank's dimensions are known and not pathological, geometry is a relatively easy way to create a height/volume profile (see Figure 2) that associates the tank's sensor readings with its volume.

Acquiring TankFlow

Using TankFlow

For maximum measurement accuracy, use a source tank that's larger than the destination tank — this avoids large changes in flow rate as the destination tank fills.

The exact time between measurements is not important, as long as the time is accurately recorded, and as long as plenty of data points are recorded. The data can be entered onto a paper tablet (to be later transcribed into a computer text file), or into a spreadsheet (preferable) or a plain-text file. Each record looks like this:

In this activity, periodic records are made of the time (to the second if possible), the pumping flow rate and the tank content sensor height. At the end of the process, there should be enough records to accurately profile the tank — 100 such records is not too many. This means if two hours are required to fill a tank, measurements should be taken each two minutes or less.

For this kind of analysis, the central (and most difficult) activity is a manual fill profile of the storage tank — everything else relies on an accurate fill and data collection. Here's an outline of the process:

What TankFlow Does

The image in Figure 7 isn't large enough to show the full effect of the graphics feature (click the image for a larger version), but the red dots are the field measurements and the blue line is the trace created by the polynomial regression function. With care in data collection and processing, the mathematical function's trace will align with each of the field data points, showing that it accurately and continuously models the discrete data points, and therefore represents the sensor/volume relationship of the measured tank.

To test the accuracy of the result, move to the "Graphic" tab to see something like this:

In this step TankFlow has converted a discontinuous list of volumes and sensor heights into a continuous mathematical function that can produce a sensor height for any volume, or the reverse. When program parameters are chosen carefully and assuming accurate field measurements, the resulting function can meet the most demanding accuracy requirements.

Move to the "Regression" tab and press "Perform". The result shoud look more or less like this:

This result shows that TankFlow has converted three-column field records (Figure 4) composed of times, flow rates and sensor heights into a two-column tank profile of sensor heights (Figure 5, left) associated with partial volumes (Figure 5, right).

Now move to the "Sensor/Volume" tab and press the "Convert" button. The result should look more or less like this:

For simplicity TankFlow uses the system clipboard for data transfers. All data that's imported and exported to/from TankFlow, goes by way of the system clipboard.

Once a text file (or spreadsheet) has been populated with field measurements, it's time to let TankFlow perform an analysis and create a profile.

Notes

Technical Description

TankFlow addresses a common practical issue with storage tanks — many do not have documentation, and those that do, sometimes have unknown or pathological shapes that prevent a classical geometric analysis.

There are many tank shapes that can be characterized mathematically using these methods and equations and the assistance of a geometry-based program like my own TankCalc. But in practice, only some tanks fit into well-defined geometric categories. Some appear to be simple until one discovers some protrusion within the tank, or a distortion of shape or another reason that prevents a geometric treatment.

Calculus and rates of change

TankFlow addresses these problems by reducing a table of field measurements consisting of time, fill rate and sensor height into a stepwise tank volume profile. This method works because the flow of liquid into a tank represents a rate of change in the tank's volume. Those who have studied Calculus will know the meaning of the term rate of change — it means one may take that rate of change and integrate it over time to get a tank's partial volume at any given time.

TankFlow takes a table of field measurements, each having a time, flow rate and sensor height, and proceeds like this:

For each pair of records (call them A and B), TankFlow takes the provided flow rates and creates an average value equal to $\frac{A+B}{2}$: Figure 8: Computing an average value A little geometric thinking reveals that this average value is exactly right if the flow rate changes in a linear way between A and B. If this is not true, if the flow rate value follows a curved path between A and B, then more data may need to be be collected to preserve accuracy. The flow rate computed in step (1) above is multiplied by the time interval between A and B. This volume change is added to the sum of past volumes to create an incremental tank volume at time B, associated with the sensor height recorded for time B. Steps (1) and (2) above are applied to all the field data to produce a complete stepwise tank volume profile correlated with recorded sensor heights. In essence, the recorded flow rates are numerically integrated to produce a stepwise volume profile for the tank.

The probem with this intermediate result is that it's incremental — there are gaps between volumes listed in the result. What we need is a continuous mathematical function to provide any sensor height for any specified volume, including volumes not recorded, as well as the reverse case (volumes for sensor heights). To get this result, TankFlow uses a method called polynomial regression (on the "Regression" tab) to convert the stepwise volume/sensor height table into a continuous function able to provide any volume for any sensor height or the reverse. The generated function can be exported into other environments and programs, and can be used to create a table of results with user-selected step sizes.

When generated carefully, the polynomial function serves as a very accurate model of the relationship between volume and sensor height, sufficient for any practical purpose. When fully exploited, the function does away with printed tables of values, guesswork, interpolation between known measured values and similar older methods.

Statistical Measures

The mathematical quality of the generated regression result can be gauged by examining the Correlation Coefficient and Standard Error values displayed on the "Regression" tab. The Correlation Coefficient value numerically describes the degree to which the regression result corresponds to the source data, and the Standard Error value provides a convenient gauge of likely errors in the results.

If these statistical measures don't meet requirements, there are some remedies. One is to increase the number and accuracy of the original field measurements, but this may require much time and effort. Another approach is to increase the "Polynomial Degree" value on the "Regression" tab, but this remedy has well-understood limitations — it can create a profile that perfectly matches the entered data at the measured points, but with no connection to reality anywhere else. Here's an example in which an attempt is made to use a polynomial regression technique to exactly match noisy field data:

First, copy this small data set into TankFlow's "Sensor/Volume" tab (second from left), while erasing any prior data that may be present: -1 -1

0 3

1 2.5

2 5

3 4

5 2

7 5

9 4



Directions: copy the above data by dragging your mouse pointer across the numbers, then press Ctrl+C (PC) or Command+C (Macintosh) to copy the data into the system clipboard. Then paste the result into TankFlow's "Sensor/Volume" by entering Ctrl+V (PC) or Command+V (Macintosh).

Now move to the "Regression" tab, select a polynomial degree of 2, and press Perform. Move to the "Graphic" tab to see this result: FIgure 9: Polynomial Degree 2, Correlation coefficient 0.4921, Standard Error 1.5179

Now return to the "Regression" tab, select a polynomial degree of 7, and press "Perform" again. The resulting chart should look like this: Figure 10: Polynomial Degree 7, Correlation coefficient 1.0000, Standard Error 0.0000

The second result is statistically perfect, but meaningless.

In the above experiment, for polynomial degree 2, the regression doesn't agree with the data very well, simply because the data are so poor (or "noisy"). For polynomial degree 7, the regression matches the data exactly at each provided data point, but at the expense of having a pathological shape everywhere else. This shows the consequences of trying too hard to match noisy field data — the resulting analysis shows good statistical agreement with the data, but is otherwise useless and bears no relationship with reality.

The remedy for a case like this is to re-perform the field measurements — get better, more accurate data.

Flow Rate Accuracy

The process described above relies on minimizing systematic errors like time, sensor height measurement and flow rate. Flow rate in particular is a critical element of the analysis. For example, if the measured flow rates are in error by 10%, the tank's overall volume with be in error by this same amount.

TankFlow has a way to deal with this issue. For many tanks, their full capacity is known even though their content profile (Figure 7) is unknown. For a case like this, TankFlow applies a simple linear regression function to the generated incremental volume table, such that the profile is retained but all the values are adjusted so the low and high volumes agree with the correct values.

Here's the linear interpolation equation used by TankFlow:

Where:

$x$ = argument in the $xa,xb$ range

$y$ = result in the $ya,yb$ range

$xa,xb$ = source numerical range

$ya,yb$ = destination numerical range

$xa$ = 32

$xb$ = 212

$ya$ = 0

$yb$ = 100

Values $xa$ and $xb$ specify two known values on the Fahrenheit scale, while $ya$ and $yb$ are assigned the corresponding values in Celsius. If an argument $x$ is submitted in Fahrenheit, the equation will produce a $y$ result in Celsius. And a simple change in assignments can produce the reverse conversion.

In the context of TankFlow, if an inaccurate flow meter creates a table of sensor/volume results that has the right overall shape but the wrong specific values, this interpolation equation can be used to adjust all the values proportionally, thereby canceling out the flow rate errors while retaining the shape of the tank's height/volume profile. To get this result, the TankFlow user moves to the "Regression" tab, enters accurate low and high volume values in the "Correction Low" and "Correction High" windows, enables the adjacent check-boxes, and performs the regression again.

Set up this way, TankFlow uses the above equation to proportionally adjust the entire volume profile to create the expected low and high volume values, while retaining the overall shape of the profile (which is very likely to be correct).

Portable Results

Using the polynomial regression it creates, TankFlow draws a graph and allows creation of a table, but more importantly it provides a way to export a computer language function with appropriate polynomial terms for use elsewhere. On the "Regression" tab is a list of computer languages (top left). Selecting one of the languages generates a computer code function with correct syntax, ready for export via the system clipboard into another environment. Supported languages include C, C++, Java, JavaScript and Python.

One advantage to this function-export feature is that the result is much, much smaller than the tank's original data table. Another is that the function can portably recreate the tank's volume profile within any reasonable accuracy requirements. This allows TankFlow's results to find their way into user-created programs to, for example, print an old-style paper "strapping chart" for use in the field.