PoolMath Calculations

Nov 6, 2014
5
0
Australia
#1
I'm a bit confused by how the PoolMath app is working out how much acid to add to my pool. As an example I set the level of TA and Borate to zero (so there is no buffering capacity), and have the current pH at 7 with a goal of 6. I have a 40,000L pool to which I'm adding 31.45% acid, which has a molarity of about 10M and as a strong acid is fully dissociated in water. Chemical theory tells us that I should have a H[SUP]+[/SUP] concentration of 1x10[SUP]-7[/SUP]M at the starting pH, and my goal pH has a concentration of 1x10[SUP]-6[/SUP]M. To add the difference of 9x10[SUP]-7[/SUP]M to 40,000L I'll need 3.6mL of acid. But the PoolMath app says 740mL. What's going on? Also, how does the app mathematically account for buffering capacity from Boric and TA?
 

pooladdict

In The Industry
TFP Guide
May 15, 2007
819
0
New Brunswick Canada
#2
Welcome to TFP

I will let others with a more extensive chemical background take this one. But I would say it's formulas based on where you are and where you want to get. Ph7 to Ph6 would calculate x amount.
 

JasonLion

LifeTime Supporter
Platinum Supporter
TFP Expert
May 7, 2007
37,879
5
Silver Spring, MD
#3
PH calculations are quite complex, with a number of non-linear factors to keep in mind. PoolMath doesn't do the full calculation, and instead uses a quadratic approximation. In the normal ranges that occur in pools this is quite accurate, but when you stray from the normal ranges it can be off by quite a bit.

TA of zero is way outside the normal range, and I would not expect it to work. Worse, if TA is 0, PH must be well below 5. So the example you have given can't possibly happen in the real world and none of the math should be expected to work.

PoolMath takes both TA and Boric acid levels into account when calculating PH changes in the PH section towards the top, but ignores those factors in the Effects of adding chemicals section at the bottom (which uses a much simpler approximation than the one the PH section uses).
 
Nov 6, 2014
5
0
Australia
#6
I tried that but I'm not well versed with the code. I can see that this is the relevant section:

function CalcPH()
{
var mamul = [2.0, 1.11111, 1.0, .909091, 2.16897, 1.08448 ];
var temp, adj, delta, extra;

delta=parseFloat(document.F.PHto.value)-parseFloat(document.F.PHfrom.value);
delta*=GetGallons();
temp=(parseFloat(document.F.PHfrom.value)+
parseFloat(document.F.PHto.value))/2;
adj=(192.1626 + -60.1221*temp + 6.0752*temp*temp + -0.1943*temp*temp*temp) *
(parseInt(document.F.TAfrom.value)+13.91) / 114.6;
extra=(-5.476259 + 2.414292*temp + -0.355882*temp*temp +
0.01755*temp*temp*temp) * parseInt(document.F.BORfrom.value);
extra*=delta;
delta*=adj;
if (parseFloat(document.F.PHfrom.value)<parseFloat(document.F.PHto.value)) {
// Washing soda, soda ash
temp=(delta/218.68)+(extra/218.68);
document.F.PHU1oz.value=PutWeight(temp);
document.F.PHU1vol.value=PutVolume(temp * 0.8715);

// Borax
temp=(delta/110.05)+(extra/110.05);
document.F.PHU2oz.value=PutWeight(temp);
document.F.PHU2vol.value=PutVolume(temp * 0.9586);
}
else {
document.F.PHU1oz.value=document.F.PHU1vol.value=0;
document.F.PHU2oz.value=document.F.PHU2vol.value=0;
}

if (parseFloat(document.F.PHfrom.value)>parseFloat(document.F.PHto.value)) {
// Muriatic acid
temp=(delta / -240.15 * mamul[document.F.MApop.selectedIndex])+
(extra / -240.15 * mamul[document.F.MApop.selectedIndex]);
document.F.PHD1oz.value=PutVolume(temp);

// Dry acid
temp=(delta/-178.66)+(extra/-178.66);
document.F.PHD2oz.value=PutWeight(temp);
document.F.PHD2vol.value=PutVolume(temp * 0.6657);
}
else {
document.F.PHD1oz.value=0;
document.F.PHD2oz.value=document.F.PHD2vol.value=0;
}
}
...but I can't make head nor tail of what's going on there...
 
Nov 6, 2014
5
0
Australia
#8
I'm trying to work out how they're calculating the amount of acid required. It doesn't seem to be from first principles, as the basic relationship between pH and [H[SUP]+[/SUP]] in the absence of any buffering capacity doesn't hold. It's not the equations that I find complicated, it's the format that they're presented in as HTML code that I can't understand.
 

JasonLion

LifeTime Supporter
Platinum Supporter
TFP Expert
May 7, 2007
37,879
5
Silver Spring, MD
#9
It has been a long time since I worked on this. I believe I started from the following curve fit:

adj=(192.1626 + -60.1221*Avg_PH + 6.0752*Avg_PH*Avg_PH + -0.1943*Avg_PH*Avg_PH*Avg_PH) * (Starting_TA+13.91) / 114.6;

With subsequent adjustments for borate level and which chemical is being used.

The data I used for curve fitting was calculated using chem geek's PoolEquations spreadsheet, which is based on detailed equations derived from the underlying chemistry. The math it uses is way beyond what is practical on a web page.
 

chem geek

LifeTime Supporter
TFP Expert
Mar 28, 2007
12,082
2
San Rafael, CA USA
#11
You can look at the Pool Equations spreadsheet but it's very complicated which is why Jason did a curve fit approximation. In your extreme example, if you were to set pH to 7.0, TA, FC, CYA, CH, TDS, Borates all to zero and use 40,000 liters, then put in the same numbers except 6.0 for pH and you will see it says 12.5 ml of Muriatic Acid (31.45% HCl) and 10.4 grams of sodium bicarbonate because the TA is specified as 0, but you probably don't want to keep the TA at 0 and want to let that drop from adding acid so you would instead press the "Calculate Acid/Base/TA" button (twice to make sure the iterations get rid of any residual error) and see that it takes 4.0 ml of acid and that the TA drops to -0.05 ppm (you have to click on the field to see this low a number that otherwise rounds to 0.0 in the U.I.).

The 31.45% HCl has a density of 1.159 g/ml (kg/l) so one liter weighs 1159 grams and HCl is 36.46094 g/mole so that's 0.3145 * 1159 / 36.46094 = 9.997 moles/liter (M). The difference of 9x10[sup]-7[/sup] moles/liter in 40,000 liters is 0.036 moles so 0.036 * 36.46094 / 1.159 / 0.3145 = 3.6 ml. The reason the spreadsheet calculates 4.0 ml is that the assumption of the difference being 9x10[sup]-7[/sup] is wrong because it doesn't account for the dissociation of water. At 27ºC the pKa of water is 13.934 so the H[sup]+[/sup] goes from 1.00x10[sup]-7[/sup] to 1.00x10[sup]-6[/sup], but the OH[sup]-[/sup] goes from 1.16x10[sup]-7[/sup] to 1.16x10[sup]-8[/sup]. The actual hydrogen atom difference is given by the change in [H[sup]+[/sup]]-[OH[sup]-[/sup]] which is 9.884x10[sup]-7[/sup] - -0.16x10[sup]-7[/sup] = 1x10[sup]-6[/sup] so we have 1x10[sup]-6[/sup] * 40,000 * 36.46095 / 1.159 / 0.3145 = 4.0 ml which matches the spreadsheet (the spreadsheet is very slightly different in the next digit because of the small ionic strength that is slightly higher after the acid addition.