HP-42S - Time to drain a horizontal cylindrical tank Gerson W. Barbosa Unregistered Posts: 2,761 Threads: 100 Joined: Jul 2005 03-03-2012, 02:12 AM One of the new programs in the software library (Thanks, Don, for pointing them out to us) is a small HP-42S program that calculates the volume of a horizontal cylindrical tank, given its current fluid level, by Ken Delsnider: Perhaps the following could be a companion program to it, but some discussion is required. Years ago at work my chief, also an electrical engineer, gave me a book on Fluid Mechanics and asked me to try to solve this problem. I had not been an outstanding student in that discipline (quite the contrary!), but after an hour or so I managed to find a formula (by following a solved example for a vertical tank in the book). I tested it with a 20-liter water bottle and a small piece of a plastic pen body as a nozzle and it worked. I guess it may work for diesel oil as well (that was the fluid in the original problem) given its low viscosity, but I don't know what discrepancy one could expect when using the formula below. The constant in line 21 has to be recalculated for British units. Formula ```t = 4*L*(sqrt((D - h2)^3) - sqrt((D - h1)^3))/(3*S*c*sqrt(2*g)) ``` where ``` t = time do drain from upper to lower level [s] L = length of the tank [m] D = diameter of the tank [m] h1 = upper level of fluid [m] h2 = lower level of fluid [m] S = cross-sectional area of the nozzle [m^2] g = acceleration of gravity [m/s^2] c = nozzle coefficient (dimensionless) ``` Gerson. ```--------------------------------------------------------------------------------------------- TIME TO DRAIN A HORIZONTAL CYLINDRICAL TANK FROM AN INITIAL LEVEL TO A FINAL LEVEL OF STORAGE 00 { 103-Byte Prgm } 01>LBL "T2MT" 02 MVAR "DIA" 03 MVAR "HT" 04 MVAR "HTF" 05 MVAR "LEN" 06 MVAR "NDIA" 07 MVAR "NC" 08 MVAR "T" 09 RCL "DIA" 10 RCL- "HTF" 11 3 12 Y^X 13 SQRT 14 RCL "DIA" 15 RCL- "HT" 16 3 17 Y^X 18 SQRT 19 - 20 RCL× "LEN" 21 383330.627104 ; (8/15)*10^7/(pi*sqrt(2*9.80665)) 22 × 23 RCL "NDIA" 24 X^2 25 RCL× "NC" 26 ÷ 27 RCL- "T" 28 END DIA = Diameter [m] HT = Initial level of storage [m] HTF = Final level of storage [m] LEN = Length of tank [m] NDIA = Nozzle diameter [mm] NC = Nozzle constant (*) T = Time [s] ``` (*) The nozzle constant is a dimensionless constant related to the ratio of the length and diameter of the nozzle, according to the following table: ``` | NC ------------- l 224.808926919 seconds 3600 / Shift CONVERT ->HMS --> 00h 03m 45s --------------------------------------------------------------------------------------------- ``` Werner Unregistered Posts: 163 Threads: 7 Joined: Jul 2007 03-03-2012, 05:04 AM As far as the TANK program goes, I've had a similar program in my library for several years. Making use of stack and recall arithmetic, and avoiding the "R" variable, it is considerably shorter than the one in the software lib: (OK I cheated a little with shorter variable names as well ;-) ``` { 49-Byte Prgm } *LBL "TANK" MVAR "H" MVAR "V" MVAR "D" MVAR "L" RCL "D" X^2 LASTX 2 / RCL- "H" LASTX / ACOS STO+ ST X ENTER SIN - * 8 / RCL* "L" RCL- "V" END ``` Cheers, Werner Edited: 3 Mar 2012, 7:51 a.m. Gerson W. Barbosa Unregistered Posts: 2,761 Threads: 100 Joined: Jul 2005 03-03-2012, 11:38 AM In my original problem I used this formula, derived from yours: ```V = L*(D^2*ACOS(1 - 2*H/D)/4 + (H - D/2)*sqrt(H*(D - H))) ``` It has the advantage of using only one transcendental function, but it's longer. The following uses your formula and is slightly shorter, but takes up four more bytes: ```00 { 53-Byte Prgm } 01>LBL "TANK" 02 MVAR "L" 03 MVAR "D" 04 MVAR "H" 05 MVAR "V" 06 1 07 RCL "H" 08 STO+ ST X 09 RCL÷ "D" 10 - 11 ACOS 12 STO+ ST X 13 SIN 14 RCL- ST L 15 RCL× "D" 16 RCL× "D" 17 RCL× "L" 18 8 19 ÷ 20 RCL+ "V" 21 END L*D^2*(SIN(2*ACOS(1 - 2*H/D)) - 2*ACOS(1 - 2*H/D))/8 + V = 0 ``` Cheers, Gerson. « Next Oldest | Next Newest »

 Possibly Related Threads… Thread Author Replies Views Last Post [HP Prime]How to get Discrete-Time Fourier Transform uklo 0 1,316 11-18-2013, 08:02 PM Last Post: uklo Date/time formats R. Pienne 4 1,965 11-01-2013, 12:43 PM Last Post: Marcus von Cube, Germany How to set the Date.Time etc on a WP34S Harold A Climer 4 1,681 10-29-2013, 09:32 PM Last Post: FORTIN Pascal Prime: Exam mode (possible duplicate after funny response first time) Paul Townsend (UK) 1 1,288 10-24-2013, 03:09 PM Last Post: Tim Wessman Date/time programs for the HP 35s R. Pienne 0 962 10-03-2013, 02:37 PM Last Post: R. Pienne Nothing like passing the time away... Eddie W. Shore 2 1,219 03-21-2013, 08:23 AM Last Post: Eddie W. Shore New compile-time options for WP-34S Nigel J Dowrick 15 4,296 01-29-2013, 03:25 PM Last Post: Stephan Excessive HP-42S battery drain aj04062 4 1,508 01-13-2013, 10:28 PM Last Post: aj04062 Date & Time disappear on WP 34S René Franquinet 16 4,766 12-10-2012, 08:24 AM Last Post: Walter B In time for HHC 2012 ... Walter B 4 1,473 09-09-2012, 05:30 AM Last Post: fhub

Forum Jump: