1) BS3 is gen 1, but as stated above, if it is using Riffe's highly respected formulas (as RPIScotty attests), it has an undeniably high pedigree in that regard.
I've responded to this post before but am doing so again on a different part of it i.e. that quoted above. I was looking at the Riffe formula the other day and got a "hey, that looks familiar!" twinge. And indeed it is. This is going to get a bit technical so don't feel bad if you are not one of the small group interested in this stuff (e.g. people developing spreadsheets - maybe this should be under Brewing Software.
The proton deficit of a mash at pHz is
Q(pH) = ∑_i mi*(a1i*∆pHi + a2i*∆pHi^2 + a3i*∆pHi^3) + Qw(pH) + Qo(pH)
in which mi represents the mass of malt number i, ∆pHi = pH - pHDi where pH is a pH of interest (e.g. the desired mash pH) and pHDi the pH of a mash made with malt i and deionized water, a1i the linear buffering coefficient for malt i, a2i the quadratic buffering coefficient for malt i and a3i the cubic. Qw is the proton deficit of the water (mostly due to alkalinity) and Qo the deficit of other stuff in the mash, that is the acids or bases the brewer has added to set pH. Both of these are non linear functions of pH as is, obviously, the sum over the malts. The pH of the mash is the pH that sets Q(pH) = 0 at which pH the protons contributed by acid malts and added acids just equal the protons absorbed by the basic malts, the water's alkalinity and any added bases. As the function is clearly non linear we can't write a simple equation pH = formula to solve it. What we have to do is guess what we think the answer might be and call this pHo. pHo = 5.4, in the middle of the range of desirable mash pH's might be a good guess. We then find the rate of change of the function with pH at pHo. This is symbolized by dQo/dpH. Those familiar with a little calculus will easily perceive that
dQo/dpH = ∑_i mi*(a1i +2*a2i*∆pHi + 3*a3i*∆pHi^2) + dQw(pHo)/dpH + dQo(pHo)/dpH
∆pHi = pHo - pHDi in this formula
We now "correct" our initial guess and come up with a new guess, pH1
pH1 = pHo - Q(pHo)/(dQo/dpH)
We then repeat the process until we are satisfied that Q(pHn) is sufficiently close to 0. Those with some familiarity will recognize that this is the Newton - Raphson algorithm. It is how mash pH is found in the Gen II software.
Gen I programs don't (AFAIK) do iterative processing (though any Excel spreadsheet is capable through its Solver and other means). So what they do is say "Lets pretend the malts are linear, that the water's deficit is given by the alkalinity and that the number of protons absorbed or released by added acids and bases are constants". This implies that the a2 and a3 coefficients are both 0 as are dQw(pHo)/dpH and dQo(pHo)/dpH. These assumptions simplify Q to
Q(pHo) = ∑_i mi*a1i*(pHo - pHDi) - Qw - Qo
and dQo/dpH to
dQo/dpH = ∑_i mi*a1i
The first guess is then
pH1 = pHo - (∑_i mi*a1i*(pHo - pHDi) + Qw(pH) + Qo(pH))/∑_i mi*a1i
There is no reason to make a second or subsequent guesses as the linearized approximation to Q will be 0 at pH1.
Now Riffe went one step further (to his detriment). He set pHo = 0. This changes pH1 to
pH1 = - (∑_i mi*a1i*(- pHDi) + Qw(pH) + Qo(pH))/∑_i mi*a1i
Rearranging the signs
pH1 = (∑_i mi*a1i*pHDi - Qw + Qo)/∑_i mi*a1i
This is the Riffe equation arrived at by solving Q(pH) = ∑_i mi*a1i*(pH - pHDi) + Qw + Qo for pH. Appreciating that this is essentially taking the first step in a Newton-Raphson solution might have let him perceive that one does not need to completely throw away non linear malt information (where it is available) nor does one have to neglect the dependence of the deficits of bicarbonate (added or alkalinity derived), lactic, phosphoric or other acids and bases on pH in order to have a non iterative solution. One has everything he needs to compute
pH1 = pHo -( ∑_i mi*(a1i*∆pHi + a2i*∆pHi^2 + a3i*∆pHi^3) + Qw(pH) + Qo(pH) )/(∑_i mi*(a1i +2*a2i*∆pHi + 3*a3i*∆pHi^2) + dQw(pHo)/dpH + dQo(pHo)/dpH)
and thus get a better answer than the current form of the equation. To do so he must compute the water and addition deficits and their derivatives. While the formulas for dQw/dpH and dQo/dpH are algebraic nightmares it is easy enough to get these derivatives from, for example
dQw/dpH = ( Qw(pH + epsilon) - Qw(pH) )/epsilon
where epsilon is a very small number.
All the formulas above are there to show the relationship of the Riffe equation to the first step of Newton-Raphson. The message to be taken away here is that a developer will get a better answer from
pH = 5.4 - Q(5.4)/dQ(5.4)/dpH
with dQ/dpH = ( Q(pH + epsilon) - Q(pH) )/epsilon than he will from the Riffe formula as it is now stated. Note that improvement depends on how non linear the mash is and is typically quite small but it can be up to 0.05 pH or more in some cases. If one is to use a linear malt model and constant Qw and Qo there is no advantage. Of course its still better to write code to implement Newton- Raphson.