# PoolMath Calculations

#### Giga Pooli

##### Member
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?

In The Industry
TFP Guide
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

Platinum Supporter
TFP Expert
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).

#### Giga Pooli

##### Member
Would you mind posting the equations PoolMath uses so I can see what's going on under the hood?

#### jblizzle

TFP Expert
Would you mind posting the equations PoolMath uses so I can see what's going on under the hood?
You can pull them up yourself if you view the source of the web page.

#### Giga Pooli

##### Member
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 ];

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;
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...

#### jblizzle

TFP Expert
Well, Jason said they were complicated

Why do you need the equations?

#### Giga Pooli

##### Member
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

Platinum Supporter
TFP Expert
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.