Post Reply 
41 Cistern Program
08-17-2016, 04:47 AM
Post: #21
RE: 41 Cistern Program
(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:

« OVER / 1 SWAP - DUP
ACOSH IM SWAP DUP
ACOS SIN * - SWAP SQ * *
»

A faster 55-byte solution:

Code:

  « OVER / 1. SWAP - 
    DUP ACOS SIN DUP2 R→C 
    ARG UNROT * - SWAP SQ 
    * *
  »

3 2 1 → 7.37021819169 (0.0497 s, 50g)

An even faster 60-byte solution:

Code:

  « OVER / 1. SWAP - 1.
    OVER SQ - √ DUP2 R→C 
    ARG UNROT * - SWAP SQ 
    * *
  »

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 )\)

------------------------------------------------------------------------------------
Find all posts by this user
Quote this message in a reply
08-17-2016, 06:08 AM
Post: #22
RE: 41 Cistern Program
Gerson W. Barbosa ' Wrote:  Or, regardless the angle mode, but at the cost of 2.5 bytes and a few milliseconds more:
« OVER / 1 SWAP - DUP
ACOSH IM SWAP DUP
ACOS SIN * - SWAP SQ * *
»

Gerson, you gave 15 variations of the code!! which one d'u like best?
Find all posts by this user
Quote this message in a reply
08-17-2016, 06:46 AM
Post: #23
RE: 41 Cistern Program
(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:
« OVER / 1 SWAP - DUP
ACOSH IM SWAP DUP
ACOS SIN * - SWAP SQ * *
»

Gerson, you gave 15 variations of the code!! which one d'u like best?


How about the original hp-41 program, was it ever found?

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
08-17-2016, 09:03 AM
Post: #24
RE: 41 Cistern Program
(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... Smile
Find all posts by this user
Quote this message in a reply
08-17-2016, 01:30 PM (This post was last modified: 08-17-2016 01:43 PM by Dieter.)
Post: #25
RE: 41 Cistern Program
(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"
" L↑R↑H=?"
PROMPT
X<>Y
ST* Z
ST* Z
ST+ X
/
SQRT
ASIN
4
*
SIN
LASTX
-1
ACOS
/
PI
*
X<>Y
-
*
2
/
"V="
ARCL X
AVIEW
END

If switching to RAD is OK and prompting is not required, here is a shorter version:

Code:
LBL"CISTERN"
RAD
X<>Y
ST* Z
ST* Z
ST+ X
/
SQRT
ASIN
4
*
ENTER
SIN
-
*
2
/
END

Or, if your prefer degrees:

Code:
LBL"CISTERN"
DEG
X<>Y
ST* Z
ST* Z
ST+ X
/
SQRT
ASIN
4
*
D-R
LASTX
SIN
-
*
2
/
END

Example:

L=10
r=3
h=1

=> V=30,9748

Dieter
Find all posts by this user
Quote this message in a reply
08-17-2016, 02:13 PM (This post was last modified: 08-17-2016 07:58 PM by wojtek.)
Post: #26
RE: 41 Cistern Program
« 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
Find all posts by this user
Quote this message in a reply
08-17-2016, 02:22 PM
Post: #27
RE: 41 Cistern Program
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.

Steve
In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42
Find all posts by this user
Quote this message in a reply
08-17-2016, 04:51 PM (This post was last modified: 08-17-2016 04:53 PM by aurelio.)
Post: #28
RE: 41 Cistern Program
(08-17-2016 02:13 PM)wojtek Wrote:  « 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 elyptical for example.
If the original program takes account af all this it certainly must be complicated

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 Smile
Find all posts by this user
Quote this message in a reply
08-18-2016, 02:44 AM (This post was last modified: 08-18-2016 02:50 AM by Gerson W. Barbosa.)
Post: #29
RE: 41 Cistern Program
(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:
« OVER / 1 SWAP - DUP
ACOSH IM SWAP DUP
ACOS SIN * - SWAP SQ * *
»

Gerson, you gave 15 variations of the code!! which one d'u like best?

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.
Find all posts by this user
Quote this message in a reply
08-19-2016, 05:03 AM
Post: #30
RE: 41 Cistern Program
(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..
This can help of course, but is not actually what we are looking for, cause it is a "on-line" calculation.

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.
Find all posts by this user
Quote this message in a reply
08-19-2016, 08:23 AM (This post was last modified: 08-19-2016 08:25 AM by Csaba Tizedes.)
Post: #31
RE: 41 Cistern Program
HP 15C version discussed in Hungarian Calculator Google group - With spherical ends and cylindrial body:
AutoCAD calculation:
https://groups.google.com/d/msg/szamolog...Xs0EoO_EQJ
https://lh3.googleusercontent.com/-50Pg4...25A1ly.JPG

And the 15C program is here:
https://groups.google.com/d/msg/szamolog...cXHZYrFhUJ

Happy translating! Smile

Csaba
Find all posts by this user
Quote this message in a reply
08-19-2016, 11:54 AM
Post: #32
RE: 41 Cistern Program
(08-19-2016 08:23 AM)Csaba Tizedes Wrote:  Happy translating! Smile
Csaba

Smile Smile Smile
Find all posts by this user
Quote this message in a reply
08-19-2016, 12:49 PM
Post: #33
RE: 41 Cistern Program
(08-19-2016 08:23 AM)Csaba Tizedes Wrote:  https://groups.google.com/d/msg/szamolog...Xs0EoO_EQJ
https://lh3.googleusercontent.com/-50Pg4...25A1ly.JPG

And the 15C program is here:
https://groups.google.com/d/msg/szamolog...cXHZYrFhUJ

On android I can see only source of html header, no any data, no program...
Find all posts by this user
Quote this message in a reply
08-19-2016, 01:13 PM (This post was last modified: 08-19-2016 07:31 PM by Gerson W. Barbosa.)
Post: #34
RE: 41 Cistern Program
(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..
This can help of course, but is not actually what we are looking for, cause it is a "on-line" calculation.

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 :-)

(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..
This can help of course, but is not actually what we are looking for, cause it is a "on-line" calculation.

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 :-)

Code:

%%HP: T(3)A(D)F(.);
\<< \-> L D a h
  \<< 'SQ(D)/4.*(L*(IM(ACOSH(1.-2.*h/D))-2./D*(1.-2.*h/D)*\v/(h*(D-h)))+2.*a*\pi/D*(h+4./(3.*SQ(D))*(D/2.-h)^3.-D/6.))' EVAL
  \>>
\>>

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:


%%HP: T(3)A(D)F(.);
\<< \-> L D a h
  \<< 'SQ(D)/4.*L*IM(ACOSH(1.-2.*h/D))+\pi*a*SQ(h)*(1.-2.*h/(3.*D))+L*\v/(h*(D-h))*(h-D/2.)' EVAL
  \>>
\>>


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? :-)

----------------------------------------------------------------------------------------

[Image: 28987150362_c3cdcf3319.jpg]


\(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
Find all posts by this user
Quote this message in a reply
08-19-2016, 04:55 PM
Post: #35
RE: 41 Cistern Program
(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
Find all posts by this user
Quote this message in a reply
08-19-2016, 05:07 PM
Post: #36
RE: 41 Cistern Program
(08-19-2016 04:55 PM)Csaba Tizedes Wrote:  
(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
Update: I checked under another user but logged in Google and works perfectly. Maybe you needs to login into your Google account?

The text is here but I guess this will not really helpful (Hungarian text only):

Code:

A kis HP15C-m szerint 2497.8 liter van benne.
A program - minden magyarázat nélkül:

LBL B
  STO 1
  RCL 0
  SQ
  RCL 6
  RCL-1
  SQ
  -
  SQRT
  STO 5
  1/x
  RCL×2
  COS-1
  STO 3
  RCL×5
  RCL 3
  SIN
  RCL×2
  -
  RCL×5
  RCL 3
  SIN
  RCL×5
  RCL×4
  +
  2
  ×
RTN

A változók:
R0: R; a 0.2m-es gömbszelet sugara, R=2.60m
R1: h; ez az integrálás futó változója, h=0.0m ... 0.6m
R2: R-m; egy segédváltozó, ahol m=0.2m, a gömbszelet magassága
R3: alfa; egy szöget tárolok benne, az egyes gömbszeletek központi szögének a fele különböző magasságokon
R4: L; a tartály hossza L=3m
R5: r; az egyes gömbszeletek sugara különböző magasságokon
R6: d/2; a 2m átmérő fele, azaz 1m van benne tárolva

Futtatáshoz:
2.60 STO 0
2.40 STO 2
3.00 STO 4
1.00 STO 6
f RAD (csak radián módban működik a program!)
f FIX 4
0 ENTER 0.6 f INTEGRATE B
rövid futás után a kijelzőn a 2.4978 m3 érték

[Image: Benzintart%25C3%25A1ly.JPG]

Csaba
Find all posts by this user
Quote this message in a reply
08-19-2016, 07:18 PM (This post was last modified: 08-19-2016 07:24 PM by wojtek.)
Post: #37
RE: 41 Cistern Program
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.
Find all posts by this user
Quote this message in a reply
08-19-2016, 08:37 PM (This post was last modified: 08-19-2016 08:40 PM by Gerson W. Barbosa.)
Post: #38
RE: 41 Cistern Program
(08-19-2016 01:13 PM)Gerson W. Barbosa Wrote:  
Code:

%%HP: T(3)A(D)F(.);
\<< \-> L D a h
  \<< 'SQ(D)/4.*L*IM(ACOSH(1.-2.*h/D))+\pi*a*SQ(h)*(1.-2.*h/(3.*D))+L*\v/(h*(D-h))*(h-D/2.)' EVAL
  \>>
\>>

Or, stack-only, 122.5 bytes:

Code:

%%HP: T(3)A(D)F(.);
\<< SWAP PICK3 PICK3 DUP + SWAP 3. * 1. UNROT / - * \pi * OVER SQ * 4. ROLLD DUP + OVER / NEG 1. + DUP ACOSH IM SWAP 1. OVER SQ - \v/ * - SWAP SQ * * 4. / +
\>>

This of course can be optimized even further, either for size or speed. Size optimization left out as an exercise for the interested reader :-)

[Image: 28987150362_c3cdcf3319.jpg]

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)
Find all posts by this user
Quote this message in a reply
08-19-2016, 10:05 PM (This post was last modified: 08-19-2016 10:09 PM by aurelio.)
Post: #39
RE: 41 Cistern Program
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
Find all posts by this user
Quote this message in a reply
08-19-2016, 11:29 PM
Post: #40
RE: 41 Cistern Program
(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
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)