Message Boards Message Boards

0
|
8376 Views
|
15 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Amount of liquid in a tank that isn't level

Posted 11 years ago
Hello,

This is my the first time here.

How can I calulate the amount of liquid in a fuel oil tank if the tank is not level?

Looking down from the top of the tank there is an x and y axis. The x axis is running the length of the tank and the y is front to back. At one end I have a sensor measuring  the height of the liquid. If the tank is off on the y axis I wiil get a false reading. The same holds true for the x axis.
If both are off the same, a false reading. 

I was never good at math. So if someone has a formula I would very much appreciate it. Or point me in the right direction.

Thank you for any and all help,

Ken
POSTED BY: Ken McGrath
15 Replies
Posted 11 years ago
Hello again, Ken.

One of the fun things in this group is that people post entertaining problems. I found yours so interesting that I couldn't help thinking about it. I have a nice approach to this that is too long to post in the snippets we use here, but if you contact me I will email you a notebook.

I think they don't like posting personal email addresses here, but you can contact me through my web site which is listed on my profile. (You will see there that I am a consultant, but this is not an offer to work -- I did this for the fun of it and will send you the notebook.)

Best regards,
David



POSTED BY: David Keith
Posted 11 years ago
I'll make a rough approximation here and you can try to decide whether it is good enough or not.

You said you were measuring from one end and trying to estimate how much was in the (slightly) tilted tank. Since the angle is "small", only a few degrees, and the tank isn't completely full or completely empty, so that tilting wouldn't change the amount, then I would multiply the amount calculated from the depth up or down by the sine of the angle of the tilt.

If the far end is tilted down 4 degrees then I would estimate there is more in the tank that the measurement says. Since sin(4 degrees) is 0.0697 I would add 0.0697*measured amount to give adjusted amount.

If the far end is tilted up 2 degrees then I would estimate there is less in the tank than the measurement says. Since sin(2 degrees) is 0.0349 I would subtract 0.0349*measured amount to give the adjusted amount.

WolframAlpha.com can calculate sine for you
http://www.wolframalpha.com/input/?i=sin+4+degrees
Mathematica can do the same, but it is finicky about capitalization and () and [] and decimal points
In[1]:= Sin[4. Degree]

Out[1]= 0.0697565
See if you can do anything to determine whether this approximation will be good enough for you or not.
And this approximation is far far simpler than what the math folks would usually do to get an answer for this.
POSTED BY: Bill Simpson
Posted 11 years ago
It is difficult enough to make certain mathematics is right. Trying to understand a verbal description is even more likely to result in errors. I realize how close to impossible it is to get a diagram done well and perhaps even more difficult to post it here, but a really good clear diagram, something that someone who hasn't been looking over your shoulder and watching what you have been doing for the last couple of days would be certain to understand would be really helpful.

I just can't trust that I really understand exactly how the tank is oriented and which way it is tilting, etc, etc, etc.

Imagine for a moment you are trying to figure out what I'm describing when you haven't been here and can't see all the work I've done.

Second, not an extra .0697 gallons but an extra 500*.0697 gallons which is a total of 534.85 gallons.

AND, think if there is any way you might be able to actually measure the total amount for some small known angle so you can try to verify this estimate process.
POSTED BY: Bill Simpson
Posted 11 years ago
Hi Ken,

This is a very typical volume integration problem. The math issue is not the problem of finding the integral -- the integrand is 1. The problems arise because the boundary conditions force you to break the problem up into numerous subintegrals, generaly where the upper integration limits are functions of the lower integration variables. With this tank problem, the number and nature of the subintegrals depends on how full the tank is and how it's tilted. Very clumsy.

One alternative numerical strategy is overfilling the volume with random points and testing them to determine how many are in the tank, and of those how many are under the top of the liquid level. An example might be a 2D integration of a complex shape. It may be diffcult to segment a symbolic integral, but if you can define a simpler test to see if a point is inside the boundary, and you overfill the region with a known number of random points in a known area, then you know the area per point. You can just count the random points inside the region to estimate its area. The more points the better.

In the code below, I assume a recatangular tank. To make matters simple, I leave the tank level and tilt and displace the liquid level. The liquid level is defined by having a fixed height above a measurement point on the tank base, with a level plane defined by its normal vector. (The usual point-vector definition for a plane.) It's the same problem. Then I fill the entire tank with random points. (If the tank was more complex, it would be easier to fill a larger region and select out the points in the tank.) Then the points are tested to select only those which are under the plane defining the liquid level. Counting the points gives the fill of the tank.

The code below can be executed if loaded into Mathematica and separated into individual cells.

Best,
David
 (* Define tank volume lxwxh and determine if {x,y,z} is in the tank *)
 
 
 inTank[{x_, y_, z_}, {l_, w_, h_}] := -l/2 < x < l/2 && -w/2 < y <
    w/2 && 0 < z < h
 
 (* define z[{x_,y_},{xm_,ym_,zm_},{xt_,yt_,zt_}] for {x,y} on the \
 tank floor and liquid measured to have depth zm above the point \
 {xm_,ym} on the tank floor, and with the liquid surface a plane \
passing through measurement point {xm,ym,zm} and normal to vector \
{xt_,yt_,zt} which defines the tilt of the liquid surface *)
z[{x_, y_}, {xm_, ym_, zm_}, {xt_, yt_, zt_}] := Module[
  {nx, ny, nz, zz},
  {nx, ny, nz} = Normalize[{xt, yt, zt}];
  zz /. Solve[{nx, ny, nz}.({x, y, zz} - {xm, ym, zm}) == 0, zz][[1]]
  ]

(* Fill the tank with random points *)
points[{l_, w_, h_}, n_] := Table[
  {RandomReal[{-l/2, l/2}], RandomReal[{-w/2, w/2}],
   RandomReal[{0, h}]}, {n}]

(* make a set of sampling points that fills the tank. For a moe \
complex tank shape it make be more convenient to fill a space that \
enclosed the tank, and then select points within the tank. *)
samplingPoints = points[{2, 3, 4}, 10000];

(* This just plots them. *)ListPointPlot3D[samplingPoints,
BoxRatios -> Automatic]

(* This selects only those points beneath the plane defining the \
liquid level *)
filledPoints =
Select[samplingPoints, #[[3]] <
    z[#[[{1, 2}]], {0.5, 1, 3}, {.1, .2, 1}] &]

(* Plot those *)
filledPlot = ListPointPlot3D[filledPoints, BoxRatios -> Automatic]

(* This is the fraction of sample points in the tank which are under \
the liquid level *)
filledFraction = Length[filledPoints]/Length[samplingPoints] // N

Export["filled.png", filledPlot]

Here is a plot of the points representing the partially filled tilted tank:
POSTED BY: David Keith
Posted 11 years ago
Thank you
POSTED BY: Ken McGrath
Posted 11 years ago
Is the tank a cylinder? A cube? Does it have "flat" ends? Or hemispherical ends? Are the dimensions of the tank known? Exactly where the measurement is being made? The angle the tank is off level? I'll warn you, the answer is probably going to be more complicated than you expect or are hoping for.
POSTED BY: Bill Simpson
Posted 11 years ago
The tank can be any one of the above. I've worked out the tank with the  hemispherical ends as far as volume goes.
The angle  could be 2-4 degrees.
POSTED BY: Ken McGrath
Posted 11 years ago
How precisely do you need to know the answer? Is the measurement distance also at an angle of 2-4 degrees or is it exactly vertical?
If you need a lot of accuracy, and perhaps even if you don't we perhaps need a good diagram showing exactly what the situation is.
POSTED BY: Bill Simpson
Posted 11 years ago
The measurement distance will be at the sane angle.
POSTED BY: Ken McGrath
Posted 11 years ago
Sorry I didn't get back to you sooner. I had to step out for a while. I will check out the above but, what if it's  tilted in both dierections. For example 4 degrees on the x and 2.5 on the y ?

I think I am reading the result incorrectly. So in a 500 gallon tank it would only be a difference of 0.0697 gallons?
POSTED BY: Ken McGrath
Posted 11 years ago
Bill,

I would like to thank for your help and understanding.

I'll work on a drawing. This may take some time.

Ken
POSTED BY: Ken McGrath
Posted 11 years ago
Posted 11 years ago
That helps.

If you could make measurements from half way down the length of the tank, under what looks like the bracket used to lift the tank, then as it tilts you would gain on the lower end about as much as you would lose on the upper end and so the adjustment would be zero. That is ignoring for the moment whether you are measuring the depth exactly vertically from the place you are measuring or measuring at a right angle to the long axis of the tank.

If you could make measurements from exactly at the end of the length of the tank then the adjustment estimate I made earlier would be fully added or fully subtracted.

Since your diagram shows a few ports down the length of your tank, neither at the center or at the end, that I am assuming you will measure through then you need to take the position of that port into account. Half way between the center and the end I think you would add or subtract half that adjustment, a third of the way from the end to the center I think you would use two thirds of that adjustment, a quarter of the way from the end and you use three quarters of the adjustment.

Now if the tank has "rolled" so that the ports are no longer directly above the center axis, but you are still measuring "vertically" to the bottom of the tank, and I'm thinking the same multiplier as before. Four degrees would mean multiplying the measured by 1.0697, two degrees would mean multiplying by 1.0349. And that would be whether it is rolled forward or backward, either of those means increasing the estimate from the measured.

Then if the far end of the tank is 4 degrees lower then multiply by another 1.0697, if it is four degrees higher then divide by 1.0697, two degrees multiply or divide by 1.0349

All this depends on the tank not being so full that it has reached the top edge of the tank and not so full that it isn't covering the bottom edge of the tank. If either of those are the case then my fudge factors will be too big.

Please find some way of testing this if you need to depend on the answer.
Thanks
POSTED BY: Bill Simpson
Posted 11 years ago
Thank for all the help Bill and David.

Best regards,,

Ken
POSTED BY: Ken McGrath
Posted 11 years ago
I noted that we can attach files, so I've attached the notebook.
Best regards,
David
Attachments:
POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract