Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to calculate volume of the tank.

Status
Not open for further replies.

newtofoxpro

Programmer
Sep 16, 2007
301
IN
My Client provide me the following details.

Diameter (CM)
Length (CM)

With this I have to calculate Volume In Liters.

Another question is Client would provide DIPS by stick/scale by CM
Then I have to calculate the product.

 
It looks to me like the best way to go about this task is to take the manufacturer's paper chart and create a lookup table. Forget about the calculations. "

Good Idea, This should works. easy than complex calculations

Immediately I asked to my client if tank is full with fuel is means has 20000 ltrs. But he told me that tanks comes with different sizes/volumes.

Still I am with you "Dave Summers" What I would do is I would make master/lookup table for all available sizes and facility to add/create any new sizes with their chart.

Please give me some time to develop and check it. Thank you.
 
he told me that tanks comes with different sizes/volumes.

Then it should be up to HIM to provide you with what you need for the various sizes to create your tank-specific lookup table - so that you will not have to continue this guessing game (for both you and us) of what is the shape of the tank and its associated size & volume.

Good Luck,
JRB-Bldr
 
If larger tanks still have the same proportions than the reference, you'd see that all values of their lookup table are scaled with the same factor. Thenonle lookup table and a scale factor would be sufficient for all tanks.

Simply see if the lookup volumne value for the corresponding heights (transformed to percentage of full height) would yield a constant factor.

If in doubt, just create as many of those lookup tables as needed, of course.

Bye, Olaf.
 
just create as many of those lookup tables as needed

Or, better yet, create only a single lookup table and have a Tank_ID field or some other field that would designate which specific tank the record values applied to.

Then the customer would somewhere define their Tank to the application and then the lookups would be only for those which matched.

Code:
SELECT *;
   FROM TankVolumes;
   WHERE Tank_ID = cThisTank;
   INTO CURSOR LookUpVols READWRITE

SELECT LookUpVols
<do whatever>

Good Luck,
JRB-Bldr
 
well, of course, data structure will be the same for all tanks, so you can simply add a tank id. Depending on how many tanks there are I'd say a tale per tank is good enough.

The tankid in the tankvolumnes table would be a foreign key in any case, and so you'd either have a parent table or just define 1 is for 20000 litres tank, 2 for 30000 litres etc., but what would you put into a real parent table besides the tank id as primary key? tank volume? That would already be redundant to the max height volume.

Just a feeling, from the pure theory it would always be better to put identically structured data into the same table and then filter by some id(s), true.

Bye, Olaf.

 
Apart from accepted lookup-table solution. I talk to client's old programmer and he give me some visual basic code as under.

Private Function get_volume(r As Double, h As Double, l As Double) As Double
Dim theta As Double
Dim volume As Double
If h = r * 2 Or h > r * 2 Then
'MsgBox ("Dip Height should be less than Dia")
get_volume = 0
Else
theta = 2 * cosinv((r - h) / r)
volume = 0.001 * (((theta * r * r) * 0.5 - (r * (r - h) * Sin(theta / 2))) * l)
get_volume = Round(volume, 2)
End If
End Function

If anybody who understand vb code, request to explain in vfp.
 
Based on a straight translation from VB, the formala would be:

Code:
FUNCTION GetVolume
LPARAMETERS r, h, l
LOCAL theta, volume
theta = 2 * ACOS((r - h) / r)
volume = 0.001 * (((theta * r * r) * 0.5 ;
  - (r * (r - h) * SIN(theta / 2))) * l)
RETURN ROUND(volume, 2)

I've left out the error-checking, which I'm sure you can do yourself.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top