Oil tanks and dipsticks

[If you’re looking for the partial volume equations of a horizontal oil-tank, this article by Dan Jones has a nice write-up. Of course, you could just get someone to make a dipstick for you. My article only gives an overview of the problem, and how to approach it, from the perspective of a pure mathematician.]

This is the second post about real-life enquiries sent to my maths department, this one from a local engineer. Again, here’s the relevant section of the e-mail, partly to illustrate that, what might not at first seem an engaging problem for a pure mathematician, can turn out to be.

I need to calculate the capacity of a cylindrical tank laid horizontally with domed ends, in order to make an accurate dipstick. I would need to do the calculation several times in order to obtain capacities at varying levels.

This post is about how I went about finding a solution to this problem, and checking how good a solution it was. So now, if you happen to need a dipstick that fits these requirements (or just of a simple cylindrical tank), you can have one precision engineered to order. To continue the barge theme from the previous enquiry, you can also get a dipstick made for your barge’s diesel tank.

Everyone who writes into a maths department with a real-world problem should be rewarded with a decent response: spotting that a problem is amenable to a mathematical solution (and following through by asking someone) is, sadly, not a common enough skill.

My reply, perhaps heretically for a mathematician, asked why it couldn’t be done by physically adding in known volumes of liquid and then measuring the depth of liquid. I also said that to calculate exact measurements, the precise shape would need to be known, but given enough known volume-depth measurements, a couple of measurements of the dome (its width and possibly ‘arc-length’ or perimeter of the cross-section), as well as of the length and radius of the cylinder, I could probably make a very accurate attempt.

What we actually knew

Unfortunately, it turned out that the oil tank was underground, and no-one had seen it for the past 15 years or so. It was also inconvenient to get actual volume-depth readings to calibrate the eventual model, because it was a large, commercial diesel tank in current use. The only measurements that we known were as follows:

  1. The diameter of the cylinder ( 2 r ).
  2. The length of the cylinder ( l ).
  3. The width of the dome ( w ).

The three known measurements (with values replaced with variables, to protect their identity).

The quarter-tank problem

If it weren’t for the domes, and the oil tank would just be a cylinder lying on its side, the problem would be simple, and more importantly, already known: the quarter-tank problem. So called, because the problem can be thought about as follows:

  • We know the depth of liquid when the tank is full (a depth of 2 r metres gives the full volume of the cylinder, \pi r^2 l), and when it is empty (0 metres).
  • We know the volume of liquid when the tank is half-full: by symmetry, a depth of r metres, gives half the volume (\frac{\pi}{2} r^2 l).
  • But how deep should you pour the oil to fill the tank to one quarter of the total volume, \frac{\pi}{4} r^2 l? (The answer is not half the radius.)

I think it’s a good trigonometry or integration exercise to set an A-level student. It’s easy to find an online solution.

For this oil tank, we didn’t want just one depth, we wanted the depth of oil needed for many different given volumes (eg. 10 \text{m}^3, 10.5 \text{m}^3, 11 \text{m}^3, \ldots). In practise we want to find out the volume given by filling the oil tank to any given depth, generate a table of every measurement (just beyond the required level of accuracy), and look up depths that give the volumes we wanted.

For a horizontal cylindrical oil tank, there is a known, straight-forward formula to get the volume for a given depth.

A first approximation

The most important detail we lacked, was any clue as to the shape of the domes. My best guess for a shape that used only the two known dome parameters (the radius of the cylinder is also the radius of the sideways ‘base’ of the dome), was a hemi-ellipsoid: a squashed hemisphere. This seemed like a reasonable guess from my limited knowledge of real-life oil tanks, and I hoped it would give a convenient, reasonably nice formulae.

It does. So that all works out well. I won’t give it here, because I don’t think it’s a particularly enlightening integration, but, it might make a good first-year undergraduate exercise. Also, posting the formula online may reduce the competitive advantage of the engineer who asked me, by an epsilon; and other businesses can surely pay their own way by hiring some needy student of mathematics. I certainly still have a very pleasant interactive spreadsheet that does all of this, if you want to contact me…

Finding upper and lower bounds

So how can we tell how good my approximation actually was? Clearly, without more measurements from the oil tank itself, we can’t really judge how closely the model fits with reality. However, we can get some extra information about how wrong the oil tank model could be in some worst possible scenario.

To do this, we need some extra assumptions about the shape of the oil tank: I’d like to make two which are very reasonable, and you may have already subconsciously made.

  1. The oil tank has rotational symmetry, that is, the shape is a solid of revolution, and completely determined by a cross-section (in fact, we only need the bottom half of a cross-section).
  2. The oil tank is convex.
  3. The central axis is the widest point, with length l+2w metres.

In mathematics, trivial but explicit assumptions such as these can allow us to progress slightly further than expected.

The smallest shape our convex oil tank could be, that satisfies these assumptions, is a cylinder with a cone stuck on to either end. The largest shape it could possibly be is a large cylinder with length l+2w (you can think of this as our original cylinder with two extra cylinders of length w stuck on to either end). Neither of these two extremes feels like a good model for a real-world oil tank, which is a good sign for the first approximation above.

Furthermore, the total volume of the hemi-ellipsoid is exactly half-way between these shapes:

Volume of cone: 1/3 \times \text{base} \times \text{height} = \frac{1}{3} \pi r^2 w.

Volume of hemi-ellipsoid: \frac{1}{2} (\frac{4}{3} \pi r^2 w)= \frac{2}{3} \pi r^2 w.

Volume of extra cylinder: \pi r^2 w.

And \frac{2}{3} is precisely the mean of \frac{1}{3} and 1. This trivia appeals to my mathematical intuition: the hemi-ellipsoid estimate is half-way in some respect between the two unrealistic extremes. This won’t be precisely true for other depths: there’s no simple relationship between the volumes when the imaginary tanks are filled to a quarter of the total depth. However the volume will always be somewhere between the two extreme tanks’ volumes at the same depth.

A few more unshown calculations

The volume of the elongated cylinder at any depth is simple, because we can use the same formula as earlier. The volume of the partially-filled cone is harder. I was unable to see how to integrate it precisely (I admit, I didn’t try that hard), and so as this is a real-world problem I did the integration by numerical methods. This would have upset my younger pure-mathematical self, so I would justify it in the following way:

  1. Not all integrals have a solution expressible with the usual mathematical functions: sin, cos, tan, log, e, \text{etc.}. As a schoolboy I found this fact about the normal distribution very unsatisfying: surely it must have an answer, even if it is so complicated we don’t know it yet? Not so. However, if this makes you sad, you can just define it to be a new elementary function. Maybe the other elementary functions are nicer, but they aren’t so special after all.
  2. When you use the usual special functions, your calculator is only giving you a very good approximation anyway.
  3. If you want to control the error in simple numerical integration, you can use some nice undergraduate analysis, essentially similar to the upper and lower bounds of the oil tank.

Numerical integration: find areas of hyperbolic slices (conic sections), multiply by small height, and add them all up. Having upper and lower bounds again is good.

Here’s the outcome of all that. The domes at either end were very small compared to the full width, so the error was going to be small no matter what approximation was used. The theoretical maximum error for this tank was at most 7% of the volume right near the start, and down to about 3% in the range that the engineer was interested in (one doesn’t care so much about tiny volumes).

Here’s a poorly-labelled graph of the three theoretical oil tanks’ volume against oil depth (mark height). It’s all fairly close together.



Filed under Accessible, Applications, Maths in Life

2 responses to “Oil tanks and dipsticks

  1. The liquid volume in a horizontal cylindrical tank with flat circular sides is known and I need to calculate the liquid height or depth. Please let me know the solved equation and not Integral equations.

    • One of the points of the post, that I could have been more explicit about, is that there might not even be a closed-form (ie. ‘solved’) equation of the form “h(V) = ….”, even if there are formulae for “V(h) = ….” (in most cases at least, judging by Dan Jones’ document, which is the best source I found by searching after I wrote this). However it is certainly possible to calculate numerically (ie. by computer).

      If you need an actual accurate dipstick with intervals either at set or custom height or volume, I would recommend asking Jim’s engineering. I know he has the capability, does get deliver orders across the world, and does do precision engineering of high standard.

      Otherwise, if you want a spreadsheet or program which will perform the calculations for you, I may be able find a mathematician to put you in touch with, who might be willing to create one (for a fee).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s