41 Cistern Program - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: 41 Cistern Program (/thread-6677.html) |
RE: 41 Cistern Program - Gerson W. Barbosa - 08-17-2016 04:47 AM (08-16-2016 07:08 PM)Gerson W. Barbosa Wrote: Or, regardless the angle mode, but at the cost of 2.5 bytes and a few milliseconds more: A faster 55-byte solution: Code:
3 2 1 → 7.37021819169 (0.0497 s, 50g) An even faster 60-byte solution: Code:
3 2 1 → 7.37021819169 (0.0352 s, 50g) These require RADIANS mode, however. Also, 2.5 more bytes on the HP-48 (ROT ROT instead of UNROT). ------------------------------------------------------------------------------------ \(V=L\cdot R^{2}\cdot \left \{ Arg\left [ \left ( 1-\frac{H}{R} \right ),\sqrt{1-\left ( 1-\frac{H}{R} \right )^{2}} \right ] - \left ( 1-\frac{H}{R} \right )\cdot \sqrt{1-\left ( 1-\frac{H}{R} \right )^{2}} \right \}\) where \(Arg(a,b) = \tan^{-1}\left ( \frac{b}{a} \right )\) ------------------------------------------------------------------------------------ RE: 41 Cistern Program - wojtek - 08-17-2016 06:08 AM Gerson W. Barbosa ' Wrote: Or, regardless the angle mode, but at the cost of 2.5 bytes and a few milliseconds more: Gerson, you gave 15 variations of the code!! which one d'u like best? RE: 41 Cistern Program - Ángel Martin - 08-17-2016 06:46 AM (08-17-2016 06:08 AM)wojtek Wrote:Gerson W. Barbosa ' Wrote: Or, regardless the angle mode, but at the cost of 2.5 bytes and a few milliseconds more: How about the original hp-41 program, was it ever found? RE: 41 Cistern Program - aurelio - 08-17-2016 09:03 AM (08-17-2016 06:46 AM)Ángel Martin Wrote: How about the original hp-41 program, was it ever found? unfortunately, not yet... I 've not planned to suscribe, yet, to the journal... RE: 41 Cistern Program - Dieter - 08-17-2016 01:30 PM (08-17-2016 06:46 AM)Ángel Martin Wrote: How about the original hp-41 program, was it ever found? Simply make your own. ;-) This version works in any angular mode, be it DEG, RAD or GRAD. It also avoids calculating arccos(1–x) which may get inaccurate for small x. Instead a method with arcsin is used. Code: LBL"CISTERN" If switching to RAD is OK and prompting is not required, here is a shorter version: Code: LBL"CISTERN" Or, if your prefer degrees: Code: LBL"CISTERN" Example: L=10 r=3 h=1 => V=30,9748 Dieter RE: 41 Cistern Program - wojtek - 08-17-2016 02:13 PM « Simply make your own. ;-) » This is perhaps no so simple as it looks. Original program probably include calculations of partial volume of heads of the vessel. Calculating heads' volume can be not so simple as they can be of different shapes, for example spherical, conical etc. As far as I found in the internet calculations of heads' volume in most cases are estimated, the code for it being much longer than for simple cylinder body. On the other hand volume of heads is important as they have significant percentage of the whole volume. It should be said here as well that body of the vessel can have different cross-sections, not only circular, but elliptical for example. If the original program takes account af all this it certainly must be complicated RE: 41 Cistern Program - 4ster - 08-17-2016 02:22 PM And the original program allowed for a sloped tank if necessary. The great programs in the responses here all assume a perfect cylinder on a level base. The program in the original post allowed for different end shapes and slopes, definitely one worth resurrecting from the dead. RE: 41 Cistern Program - aurelio - 08-17-2016 04:51 PM (08-17-2016 02:13 PM)wojtek Wrote: « Simply make your own. ;-) » Here they take in account also the different shape of the heads, unfortunately not a case of sloped vessels.. This can help of course, but is not actually what we are looking for, cause it is a "on-line" calculation. By the way I don't understand very well the graphical rapresentation on the right RE: 41 Cistern Program - Gerson W. Barbosa - 08-18-2016 02:44 AM (08-17-2016 06:08 AM)wojtek Wrote:Gerson W. Barbosa ' Wrote: Or, regardless the angle mode, but at the cost of 2.5 bytes and a few milliseconds more: 15? I've counted only 8. Wait, 11 now: « OVER SQ UNROT SWAP1. UNROT / - DUP ACOS SIN DUP2 R→C ARG UNROT * - * * » « OVER SQ UNROT 1 UNROT SWAP / - DUP ASIN COS * LASTARG R→C ARG SWAP - * * » « OVER / 1. SWAP - DUP ACOS SIN * LASTARG R→C ARG SWAP - OVER * * * » 57.5, 57.5 and 55 bytes, respectively. All require RAD mode. No better than the previous ones, just another attempt. Test with L = 4, R = 3 and H = 2. The exact result is '4*(9*ATAN(√8)-√8)' (33.0008305252831281644394). If I had to discard some, I think I would keep the three programs in post #21. RE: 41 Cistern Program - Gerson W. Barbosa - 08-19-2016 05:03 AM (08-17-2016 04:51 PM)aurelio Wrote: Here they take in account also the different shape of the heads, unfortunately not a case of sloped vessels.. The Oil & Gas article has the formulas. For instance, my unoptimized program for the elliptical head case (237 bytes) gives 0.916297857295 m^3 for D=1m, L=2m, a=0.25m and H=0.5m. No stack-only code this time :-) Gerson. RE: 41 Cistern Program - Csaba Tizedes - 08-19-2016 08:23 AM HP 15C version discussed in Hungarian Calculator Google group - With spherical ends and cylindrial body: AutoCAD calculation: https://groups.google.com/d/msg/szamologep/1MaqhoAhYgw/RwXs0EoO_EQJ https://lh3.googleusercontent.com/-50Pg44f8EFI/VWfaYnCpieI/AAAAAAAABU4/sJ-3B7S-9_M/s1600/Benzintart%25C3%25A1ly.JPG And the 15C program is here: https://groups.google.com/d/msg/szamologep/1MaqhoAhYgw/WhcXHZYrFhUJ Happy translating! Csaba RE: 41 Cistern Program - aurelio - 08-19-2016 11:54 AM (08-19-2016 08:23 AM)Csaba Tizedes Wrote: Happy translating! RE: 41 Cistern Program - wojtek - 08-19-2016 12:49 PM (08-19-2016 08:23 AM)Csaba Tizedes Wrote: https://groups.google.com/d/msg/szamologep/1MaqhoAhYgw/RwXs0EoO_EQJ On android I can see only source of html header, no any data, no program... RE: 41 Cistern Program - Gerson W. Barbosa - 08-19-2016 01:13 PM (08-19-2016 05:03 AM)Gerson W. Barbosa Wrote:(08-17-2016 04:51 PM)aurelio Wrote: Here they take in account also the different shape of the heads, unfortunately not a case of sloped vessels.. (08-19-2016 05:03 AM)Gerson W. Barbosa Wrote:(08-17-2016 04:51 PM)aurelio Wrote: Here they take in account also the different shape of the heads, unfortunately not a case of sloped vessels.. Code:
Fill the stack with L, D, a, h. For a spherical tank, just make L=0 and a = D/2 (for instance, L=0, D=4, a=2 and h=4 --> a full spherical tank). This can be simplified as Code:
The angle mode is irrelevant on the HP 50g if IM(ACOSH) is used instead of ACOS. Size has now been reduced to 191 bytes. 2 1 0.25 0.5 --> 0.916297857295 0 4 2 4 --> 33.5103216383 (32*π/3) 0 4 2 2 -->16.7551608191 (16*π/3) Is the latter half full or half empty? :-) ---------------------------------------------------------------------------------------- \(V= L\left [ \frac{D^{2}}{4}\cos^{-1}\left ( 1-\frac{2h}{D} \right )+ \sqrt{h\left ( D-h \right )}\left ( h-\frac{D}{2} \right ) \right ] +\pi a h^{2}\left ( 1-\frac{2h}{3D} \right )\) Edited to include diagram and equation RE: 41 Cistern Program - Csaba Tizedes - 08-19-2016 04:55 PM (08-19-2016 12:49 PM)wojtek Wrote: groups.google.com - On android I can see only source of html header, no any data, no program...It means only that the Google needs to evolve. If Android which is OS of Google and the Google groups is owned by Google also, but the Android can not to handle Google groups messages, that is a big FAIL. Same thing like Leonardo can not to read his own mirror-writings... Csaba RE: 41 Cistern Program - Csaba Tizedes - 08-19-2016 05:07 PM (08-19-2016 04:55 PM)Csaba Tizedes Wrote:Update: I checked under another user but logged in Google and works perfectly. Maybe you needs to login into your Google account?(08-19-2016 12:49 PM)wojtek Wrote: groups.google.com - On android I can see only source of html header, no any data, no program...It means only that the Google needs to evolve. The text is here but I guess this will not really helpful (Hungarian text only): Code:
Csaba RE: 41 Cistern Program - wojtek - 08-19-2016 07:18 PM Csaba Wrote: "Update: I checked under another user but logged in Google and works perfectly. Maybe you needs to login into your Google account?" I cannot login 'cos I do not see login window. My android is 2.3.3 but I do not think the problem is here. I won't change my device because it is first and last android device I bought. Anyway google apps should accept all google devices regardless of model number. RE: 41 Cistern Program - Gerson W. Barbosa - 08-19-2016 08:37 PM (08-19-2016 01:13 PM)Gerson W. Barbosa Wrote: Or, stack-only, 122.5 bytes: Code:
This of course can be optimized even further, either for size or speed. Size optimization left out as an exercise for the interested reader :-) L D a h --> Volume 2 1 0.25 0.5 --> 0.916297857295 0 4 2 4 --> 33.5103216382 (32*π/3) 0 4 2 2 --> 16.7551608191 (16*π/3) RE: 41 Cistern Program - aurelio - 08-19-2016 10:05 PM Great job Gerson!!! I lost your previous ....sorry strange that in solving the problem is always considered as a parameter the cross section of the head, but not the section, which is assumed always circular Vessels often have elliptical section If I'm not wrong also Oil & Gas Journal article did not consider this case RE: 41 Cistern Program - Csaba Tizedes - 08-19-2016 11:29 PM (08-19-2016 10:05 PM)aurelio Wrote: Vessels often have elliptical section The end of the vessels are spherical in the center and the connected part is a toroid. This is connecting to the short cylindrical part - in the DIN standard. I guess in the ANSI this is same. Csaba |