Pastey Dilute Solution
- Posted by Senator
Mar 31, 2019
--
-- DiluteSolution.ex v2
--
include std/console.e
include std/math.e
include std/convert.e
include std/text.e
constant Usage = sprintf("%s", {
"""
Dilute a Chlorine Solution: Dilution Law: V1*C1=V2*C2: V1=V2*C2/C1
eui DiluteSolution.ex <C1> <V2> <C2>
Usage: eui DiluteSolution.ex <C1> <V2> <C2> <d>
eui DiluteSolution.ex <C1> <V2> <C2> <d> <adp>
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 <adp> is added to the
command line, the program will calculate a annual degraded C1
value based on the value of <adp>; Otherwise, the calculations
will be made based upon the nominal value for C1% at the time
of purchase.
option: <adp> allows the user to specify an annual degradation % other
than the default value of 20%. Enter as a whole number or decimal
fraction without the % symbol. Not Entering a value for <adp> or
entering 0 for the adp value will default the value to 20%
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 20% annual rate for 190 days:
eui DiluteSolution.ex 6 32 2 190 -- degrade C1 @ default 20% annual rate
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 -- degrade C1 @ default 20% annual rate
use 0.16 oz of C1 + 14.84 oz of distilled water to make solution V2 C2
eui DiluteSolution.ex 6 15 0.057 190 35 -- degrade @35% annual rate
eui DiluteSolution.ex 6 15 0.057 190 .35 -- degrade @35% annual rate
Use 0.17 oz of C1 + 14.83 oz of (distilled) water to make solution V2 C2
"""
})
procedure DiluteSolution(sequence cmd)
integer d=1
atom V1, C1, V2, C2, adp = 20 -- 20% default annual degradation percentage
if length(cmd)<5 then display(Usage) abort(0) end if
C1 = to_number(cmd[3]) -- % Sodium Hypochlorite of stock Bleach at time of purchase
V2 = to_number(cmd[4]) -- target volume of solution to create with:
C2 = to_number(cmd[5]) -- C2 % Sodium Hypoclorite
if length(cmd)>5 then d=to_number(cmd[6]) if d=0 then d=1 end if end if
if length(cmd)=7 then
adp=to_number(cmd[7])
if adp=0 then adp=20
elsif adp<1 then adp*=100 -- adp can be entered as 0.20 or 20
end if
end if
C1 *= (1-((adp/100)/365.25)*d)
V1 = round((V2*C2)/C1,100)
display(sprintf("\n\nUse %.4g oz of C1 + %.4g oz of (distilled) water\nto make %.4g oz of %.4g%s"&
" Sodium Hypochlorite\n%.4g oz = %.4g tsp\n\t\t\t\t%.4g tblsp\n\t\t\t\t\t%.4g cup\n\t\t\t\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())