forum-msg-id-133131-edit

Original date:2018-11-08 15:12:40 Edited by: Senator Subject: Dilute Solution yet again

Forked from Re: A Little House Cleaning

Ok, I promise I will not post anymore dilution code. Honest!

```--
-- DiluteSolution.ex
--
include std/console.e
include std/math.e
include std/convert.e

constant Usage = sprintf("%s", {
"""

Dilute a Chlorine Solution: Dilution Law: V1*C1=V2*C2: V1=V2*C2/C1

Usage:

eui DiluteSolution.ex <C1> <V2> <C2>
eui DiluteSolution.ex <C1> <V2> <C2> <d>

C1 = % Sodium Hypochlorite of stock Bleach at time of purchase
V2 = target volume of solution to create with
C2% Sodium Hypochlorite

option: <d> is the number of days since  purchase of C1
+ perhaps an estimate of shelf days prior to purchase.
If d is added to the command line, the program will
calculate a degraded  C1 value based on a 20%
annual rate of degradation. Otherwise, the calculations
will be made based on the nominal value for C1% at
the time of purchase.

EXAMPLES:

To make 32 oz "Cleaner Bleach" with 2% Sodium Hypochlorite:
from stock Bleach with 6% nominal Sodium Hypochlorite:
eui DiluteSolution.ex 6 32 2
use 10.67 oz of C1 + 21.33 oz of distilled water to make solution V2 C2

To degrade C1 by 190 days: eui DiluteSolution.ex 6 32 2 190
use 11.91 oz of C1 + 20.09 oz of distilled water to make solution V2 C2

To make 15 oz "Skin/Wound Wash" with 0.057% Sodium Hypochlorite:
from stock Bleach with 6% nominal Sodium Hypochlorite:
eui DiluteSolution.ex 6 15 0.057 190  -- \$22 Anasept Wound Wash
use 0.16 oz of C1 + 14.84 oz of distilled water to make solution V2 C2
"""

})

procedure DiluteSolution(sequence cmd)
atom V1, C1, V2, C2, adp = (20/100)/365.25
integer d = 0
if length(cmd) <5 then display(Usage) abort(0) end if
C1 = to_number(cmd[3])
V2 = to_number(cmd[4])
C2 = to_number(cmd[5])
if length(cmd) = 6 then    -- degrade C1
d = to_number(cmd[6])
end if
V1= round((V2*C2)/C1,100)
display(sprintf("\n\nUse %.4g oz of C1 + %.4g oz of (distilled) water to make %.4g oz of %.4g%s"&
" Sodium Hypochlorite\n%.4g oz = %.4g tsp\n\t\t\t%.4g tblsp\n\t\t\t%.4gcup\n\t\t\t%.4g ml",
{V1,V2-V1, V2, C2, '%', V1, V1*6, V1*2, V1*0.12, V1*29.57} ))
end procedure

DiluteSolution(command_line())

```