(HP-65) Prog. No. 04198A Reverse Osmosis
|
07-28-2023, 05:03 PM
(This post was last modified: 07-28-2023 06:28 PM by SlideRule.)
Post: #1
|
|||
|
|||
(HP-65) Prog. No. 04198A Reverse Osmosis
Extract from Aircraft Industry Wastewater Recycling, EPA-600/2-78-130 (1978/06), Appendix D: Calculator Program for Computing Reverse Osmosis Unit Product and Concentrate Concentrations, pgs 69-71
"The general problem of calculating concentrate concentration and permeate concentration in an unit employing feedback is best solved by a reiterative technique. Such calculation is time consuming unless a computer or programmable calculator is available. This appendix contains a 99-step program devised for use on a Hewlett-Packard HP-65 calculator, that reiterates the necessary calculations until two successive results differ by less than one part in 1000". Program Description Description, Equations, Variables Calculation Steps Operating Limits and Warnings Sample Problem Reference Program {listing} [attachment=12365] BEST! SlideRule |
|||
07-29-2023, 01:32 PM
(This post was last modified: 07-29-2023 04:04 PM by Thomas Klemm.)
Post: #2
|
|||
|
|||
RE: (HP-65) Prog. No. 04198A Reverse Osmosis
Quote:This appendix contains a 99-step program devised for use on a Hewlett-Packard HP-65 calculator, that reiterates the necessary calculations until two successive results differ by less than one part in 1000. Looking at the equations, I wondered why they used fixed-point iteration when a purely algebraic solution is possible: \( \begin{align} C_c &= \frac{Q_f C_f - Q_p C_p}{Q_c} \\ \\ C_m &= \frac{Q_f C_f + C_c(2 Q_l + Q_c)}{Q_f + 2Q_l + Q_c} \\ &= \frac{Q_f C_f + \frac{Q_f C_f - Q_p C_p}{Q_c}(2 Q_l + Q_c)}{Q_f + 2Q_l + Q_c} \\ \\ C_p &= (1 - R) \times C_m \\ &= (1 - R) \times \frac{Q_f C_f + \frac{Q_f C_f - Q_p C_p}{Q_c}(2 Q_l + Q_c)}{Q_f + 2Q_l + Q_c} \\ \end{align} \) WolframAlpha gives: Code: C_1 = (2 C_0 Q_0 (Q_2 + Q_3) (R - 1))/((Q_2 + 2 Q_3) (Q_1 (R - 1) - Q_2) - Q_0 Q_2) From this we can write a function in Python: Code: def osmosis(Q_f, Q_p, Q_c, Q_l, C_f, R): Calling it with the given input values returns the correct result for \(C_p\): osmosis( Q_f = 3.0, Q_p = 2.0, Q_c = 1.0, Q_l = 5.0, C_f = 200, R = 0.8 ) 78.26086956521739 This function can be disassembled with: Code: from dis import dis The result is: Code: 9 0 LOAD_CONST 1 (2) After a bit of find and replace we end up with the following program for the HP-42S: Code: 00 { 54-Byte Prgm } You may have noticed that I rearranged the expression in the Python function a bit. This avoids stack overflow and allows me to use LASTX instead of evaluating \(R - 1\) a second time. Example 3 XEQ "OSMOSIS" 2 R/S 1 R/S 5 R/S 200 R/S 0.8 R/S 78.2609 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)