brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb...

52
Brewing Functions for Excel Introduction pHEst3.xlsb is a file containing several functions that should be useful to people wishing to create Excel spreadsheets for brewers and an example workbook which uses them. Several generally useful, in the brewing context, functions such as ones which convert SG to Plato and Plato to SG are offered. A rather powerful one Converts (similar to VLOOKUP) allows interconversion of units by means of (presumably hidden) tables of unit names and conversion factors. This facilitates user input in any of several units by means of drop down menus (Excel Data Validation). The emphasis, however, is on functions that relate to the estimation of mash pH given malt and water properties and determination of how much acid or base to add to a mash to set pH to a desired value given water and malt properties using the proton accounting approach. The author has for years tried to give this method to brewers without much success and this is evidently because it appears that as soon as the word “proton” is mentioned it is assumed that chemistry well beyond the understanding of the average brewer is involved and people run. Of course, chemistry is the basis for each and every one of these functions. But, we hope, that here we have it pretty well hidden. The Basic Concepts section which immediately follows this one attempts to explain the use of these functions with as little mention of chemistry as possible. We couldn’t, of course, completely leave the chemistry out and it is found in Appendix I. While many of the functions are ready for direct invocation in the same way that any Excel function is invoked, some require a lot of parameters to be passed to them. For example, to calculate the charge on a complete mash (we do this a lot), data on each malt, the water and any additions must be gathered from wherever they are located in a user’s spreadsheet. The example workbook illustrates how this is done. Functions included here that do this data gathering are, of course, unique to the way the data is located in this workbook and so, in their descriptions they are

Transcript of brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb...

Page 1: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Brewing Functions for Excel

Introduction

pHEst3.xlsb is a file containing several functions that should be useful to people wishing to create Excel spreadsheets for brewers and an example workbook which uses them. Several generally useful, in the brewing context, functions such as ones which convert SG to Plato and Plato to SG are offered. A rather powerful one Converts (similar to VLOOKUP) allows interconversion of units by means of (presumably hidden) tables of unit names and conversion factors. This facilitates user input in any of several units by means of drop down menus (Excel Data Validation). The emphasis, however, is on functions that relate to the estimation of mash pH given malt and water properties and determination of how much acid or base to add to a mash to set pH to a desired value given water and malt properties using the proton accounting approach. The author has for years tried to give this method to brewers without much success and this is evidently because it appears that as soon as the word “proton” is mentioned it is assumed that chemistry well beyond the understanding of the average brewer is involved and people run. Of course, chemistry is the basis for each and every one of these functions. But, we hope, that here we have it pretty well hidden. The Basic Concepts section which immediately follows this one attempts to explain the use of these functions with as little mention of chemistry as possible. We couldn’t, of course, completely leave the chemistry out and it is found in Appendix I.

While many of the functions are ready for direct invocation in the same way that any Excel function is invoked, some require a lot of parameters to be passed to them. For example, to calculate the charge on a complete mash (we do this a lot), data on each malt, the water and any additions must be gathered from wherever they are located in a user’s spreadsheet. The example workbook illustrates how this is done. Functions included here that do this data gathering are, of course, unique to the way the data is located in this workbook and so, in their descriptions they are marked “Reference only” to make it clear that they can only be used in the context of the example workbook. We are working on what we hope will be a more generally useable function for mash data collection but it is, at this writing, a torso.

The functions can be invoked from a spreadsheet in the same was as any other Excel function. They can also be called from within macros and other VBA functions. Some of them require multiple parameters to be passed to them. It can be nettlesome to have to enter 5 parameters when typing a formula into a spreadsheet cell though the real time prompt that pops up can be a help. Often it is the case that most of the time parameters have certain values. One of the functions that will be used most, dQWaterCt(pHz, alk, pHs, pHe), returns the amount of acid that must be added to 1L of water with pH equal to pHs and alkalinity of alk (measured by the lab by titrating to pHe) in order to acidify it to a target pH of pHz. Often a user knows his alkalinity but seldom knows what the lab titrated to in order to measure it. And often he doesn’t know the sample pH of his water either. The function requires values for both of these to calculate an answer and so we provide pHs = 7 and pHe = 4.5 (the ISO method value) as defaults. When using dQWaterCt one should, of course, pass the values for these two parameters if he has them. But if he doesn’t he can still use the function. Fortuitously the result is not strongly dependent on either of these parameters and returns a value of about 0.88*alk in most cases.

Page 2: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Default parameters are used liberally throughout the functions to provide necessary values that you may not have knowledge of or that you don’t care about such as values limiting the number of iterations an iterative solver is allowed before giving up and returning an answer. In the function descriptions values for all default parameters are given. The invocation of these functions is exactly as with any regular Excel function. Enter, for example, = dQWaterCt(pHz, alk) to accept the default values for pHs and pHe or = dQWaterCt(pHz, alk, , pHe) to accept the default pHs but specify a value of pHe.

Functions which compute the proton deficit on an entire mash as a function of pH need complete information about the mash parameters. The proton accounting approach relies very heavily on these functions. In the sample workbook included here to illustrate the use of these functions the user can specify up to 8 malts, water parameters and added salts, acids or bases. Thus functions computing proton deficit of the mash need to gather up all this information (31 items) from wherever it is found within the spreadsheet. It is a fairly easy matter to write a function which collects this data from a particular spreadsheet layout (CalcQ, described as a “For reference” function for the sample workbook) but obviously if these functions are to be usable in spreadsheets designed by others there must be a more general approach. Here we offer the concept of assigning a sheet in the workbook solely to the role of organizing this data and to write a function dQQWW which collects it from that sheet and returns the deficit. It now becomes the responsibility of a spreadsheet author to collect these data from wherever he wants to have it in the spreadsheet his users see to that (probably hidden) data organization sheet and then dQQWW can get it from there. dQQWW (incomplete as of this writing) might thus be considered more broadly applicable than CalcQ and is not marked “Reference only”.

Estimating mash pH or controlling it to a desired value which are two of the main tasks asked of brewing spreadsheets requires finding the pH which brings this function to 0 given a mash composition or finding the adjustment to a mash composition which caused it to be 0 at a desired pH.

Caveats

When opening the file that contains the sample workbook and functions the usual warning that it contains macros will appear and you will be asked whether you want to enable them or not. There is a good reason for this warning as a spreadsheet or workbook from an unknown source could easily contain malicious code of which you have no knowledge. I can guarantee that this workbook contains no malicious code but I cannot guarantee that it doesn’t contain some code which could hang up your machine. Every effort has been made to prevent that from happening (for example iterative loops are limited to a certain number of cycles before exiting) but Excel does some strange things. The program may hang up or may crash for unexplained reasons. Sometimes it shows errors (#VALUE!) for no apparent reason. Often highlighting the cell showing that value and hitting return will clear it. The Calculate Spreadsheet buttons do exactly that and sometimes clear these errors.

None of the functions interact with the file system so you need not fear loss or corruption of any files on your machine due to use of these functions.

Page 3: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Basic Concepts

pH

pH has already been mentioned many times. Most readers will know that pH is a measure of how acidic or basic something is based on their high school chemistry class and accept that something with pH < 7 is acid and something with pH > 7 is basic. We would ask users of these functions to set aside those notions for the time being and think of pH as the variable that controls the charge on brewing components. We would ask him to appreciate that each item he puts into his mash has its natural (intrinsic) pH and that associated with that pH is a natural charge1. With a liquid like water the natural pH is the pH we would measure when we insert a pH meter electrode into the water. With a solid it is the pH we would measure when we insert a pH meter into a solution of typical strength made with the item under consideration. This covers things like malts and sodium bicarbonate powder. For things like lye and hydrochloric acid we don’t know (or rather, don’t care about) the pH of the solutions because we know the charge (0 for hydrochloric acid and -1 per mole for lye) and it is charge we are really interested in. pH and charge are intimately related and many of the functions in this set are concerned with calculating one from the other.

Protons and Proton Deficit

We asserted above that each of the items that go into the mash: water, minerals dissolved in it, malts, salts, acids and bases added to a mash by the brewer carry electrical charges. We also assert that the charges on these items are controlled by the pH and that each item comes to us with its own pH and charge. Sometimes we know the pH and charge on an item (e.g a gram of sodium bicarbonate). Sometimes we know the pH but not the charge (e.g. a kg of malt). Sometimes we know the charge but not the exact pH (e.g. a mL of hydrochloric acid has 0 charge and a pH less than 0). Whichever of those cases applies, however, we can always calculate the change in charge associated with a change in pH. That is at the heart of all of this and is what the functions offered here are designed to do.

A proton is a subatomic particle that carries a charge of +1. To use these functions that is all you really have to know. That the proton is made up of two smaller particles with charge +2/3 and one with charge -1/3 is, while perhaps interesting, of no consequence to us here. The proton is the means of transferring charge between mash components.

Base malts have intrinsic pH’s around 5.7. This is higher than we want which is typically around 5.4. To lower the pH we must add protons to the malt thus increasing its charge. Lower pH and 1 It is reasonable to ask “Charge on what?” The answer is “Charge on any ion whose charge is affected by pH.” If, for example, we put sodium bicarbonate, NaH CO3, into water it immediately separates into positively charged sodium ions (Na+¿¿) and negatively charged bicarbonate (HCO3

−¿ ¿) ions. The sodium ions’ charge will stay the same whatever the pH of the mixture but the bicarbonate ion may, depending on pH, either give up a proton becoming a carbonate ion (CO3

−2) with charge – 2 or gain a proton becoming an uncharged carbonic acid (H 2CO3

) molecule.

Page 4: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

increased charge go together. When something, like this base malt, needs protons, we say it has a proton deficit. A proton deficit is the quantity of protons we need to add to a substance to lower its pH from its current or intrinsic pH to a lower pH. A proton deficit only has meaning when an initial and final pH are mentioned. Alkalinity is the proton deficit of water between its source pH and the end point pH of the titration used to measure it. We can get the protons we need from the malt by adding an acid. Anything that supplies protons is an acid. An acid can only supply protons to something whose pH is higher than the pH of the acid. Anything that absorbs protons is a base relative to the acid. Thus acids are said to have a proton surfeit. Rather than introduce a new term we just say that acids have negative proton deficits.

When acid, base, water and malts are mixed the number of protons in the mix does not change from what it is in the components. Thus the sum of the protons absorbed by bases must just equal the number of protons given up by acids. This is the basic principle behind these functions. They calculate the change in charge for the various mash components when the pH changes from the intrinsic pH of the component to a specified pH. When the specified pH is found that causes the sum of the changes (proton deficits) to be 0 the pH of the mixture has been found. If pH is set to pHz, a desired pH and the net deficit is not 0 we then know exactly how many protons must be added or absorbed in order to get it to 0.

Proton Deficits of Strong Acids and Bases

Strong acids and bases are ones that emit or absorb the same number of protons irrespective of pH in the brewing range. These number among them sulfuric acid, hydrochloric acid, and lye. Their proton deficits are determined entirely by how much of them is added and not on the pH.

Weak Acids and Bases

Weak acids and bases emit or absorb protons dependent on the mash pH (in the range of interest to brewers). These include phosphoric acid, lactic acid, lime, sodium carbonate, and sodium bicarbonate. Their proton deficits do depend on pH but are easily calculated. The function QAcid, one of the most used functions in the set, does this for all the weak acids and bases.

Water itself is a weak acid or base depending on pH. There are functions which calculate the proton deficit of water.

Malts

In the case of malt we cannot determine absolute charge but we can determine the charge change on the malt when its pH is changed from its intrinsic pH to a pH of interest i.e. the proton deficit with repect to those two pH values. This we do by adding charge to or absorbing charge from a sample of the malt by adding, respectively, acid or base to it in the laboratory or brewery and measuring the pH for several levels of addition. The pH measured with no acid or base is called the DI water pH (because distilled water is used in these test mashes) and symbolized by pHDI . This is the intrinsic pH of the malt. It alone tells quite a bit about malt properties and is used by some first generation spreadsheets to estimate mash pH. The other measurements are used with

Page 5: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

to determine three other parameters, a1,a2 and a3 (sometimes called a, b and c) which, together with pHDI , completely characterize a malt. The function dQm1kg( pH , pH DI , a1 , a2 , a3) returns the charge change on 1 kg of the malt with parameters given by the five arguments (only the first 3 are required – see the function description).

The reader is probably asking himself at this point whether he will need to be buying lab equipment and spending hours (and it does take hours) measuring malts in order to use the BrewingFuncs functions. The answer is “No”. Of course he can measure if he wants to and will be rewarded with better mash predictions than if he doesn’t and provide valuable information to the community at the same time. If he doesn’t he can still use these formulas with parameter values derived from other sources. For example, Ref. 2 lists early titration data for several malts. pHDI and a1can be deduced from these data and they are listed in the Appendix along with data from other investigators measurements. Just measuring pHDI , which is easy enough to do, or taking a maltster’s spec sheet mash pH as its value, and setting a1=−40 will give better results that first generation spreadsheets that rely on color alone to model malts.

Summary

Charge is conserved. It should be clear from this that if one mash item loses charge, that charge must be taken up by another item. The mechanism for transfer of charge is the migration of protons between the items. A proton is a fundamental subatomic particle that carries a charge of +1. We do not think it necessary, nor desirable, at this point to say any more about protons except that pH is measured as the number of them held by water molecules.

No new protons are produced or destroyed during mash reactions. They simply move between the mash components thus insuring that the sum of the charge changes, which we symbolize by dQ, over all mash components is 0. Thus ∑

idQi=0 in which ∑

i❑(calculated by the native

Excel SUM() function) represents a sum of items labeled by different values of i (for example i=1 might represent the first malt, i=2 added lactic acid etc.) is the basis for mash pH estimation and control. dQi represents the charge change on item number i. In order to figure out what the pH of a mixture of acids (those we add), bases (those we add and those found in our water i.e. alkalinity), malts and water is we guess at what the pH of the mixture might be. A good guess might be 5.4. We then calculate how much charge each item in the mash would lose or gain in being brought to pH 5.4. We total all the changes. By conservation of charge that total is 0 if 5.4 is indeed the mash pH. If it isn’t the gains and losses won’t balance and the sum of the changes won’t be 0. In that case we adjust pH until It is. The pH which brings about balance is the estimated pH.

The other problem we often wish to solve is in determining what we should do to achieve a particular desired pH. Following Ref.1 we call this pHz. The first step in doing this is to compute the sum of the charge changes for the items in the proposed mash at pHz. If it is 0 our mash pH will be pHz. If not we use the same approach is we did in estimating pH. We vary a mash parameter we are able and willing to change until ∑

idQi=0. Given this it is very likely that a

Page 6: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

user of these functions will have in his spreadsheet a column which contains cells holding dQi

values for each mash component and a cell at the bottom containing their sum. The rest of the spreadsheet will contain formulas useful for gathering the users input with regard to the amount and properties of each malt, the amount and properties of the water, the added amounts of salts, acids or bases and so on. Spreadsheets can be as elaborate or simple as required. Between the stock capabilities of Excel and these functions you can do some amazing things. For example, the spreadsheet the author offers with this Add In to illustrate its use, lets the user specify malts properties by choosing from a malt data base using a drop down menu which lists the choices. He can select units (kg, lbs, even shekels) for the malt mass using the drop down menu technology (Data > Validate) of Excel. Convenient push buttons kick off macros which zero ∑

idQifor lactic acid, phosphoric acid or for a selected malt. Mash pH is automatically estimated

any time an input parameter (such as the alkalinity, which can be entered in a number of different units) is changed. Users of these functions can do any or all of these things (and more) and fairly easily, once the concept is grasped, produce a spreadsheet customized to be just the way he wants it to be.

The Functions

Here we list the functions as declared in the VBA code. Each function is listed as it would be typed into a formula in a cell. As does Excel itself we denote optional arguments by enclosing them in […]. Their default values (supplied by the function) are given in each description.

Alk(pHs, Ct, [pHe = 4.5])

Returns the alkalinity in mEq/L of a water at pH = pHs which contains Ct mmol/L carbo. The alkalinity is calculated with respect to an end point titration pH of pHe. This is an optional parameter. If no value is passed the ISO value of 4.5 will be used.

AlkEnd(alk, pHs, [pHa = 4.4], [pHe = 4.5], [Vol = 1])

Converts alkalinity values measured at one pHe to equivalent value at another pHe. Estimates alkalinity from acid addition.

Using the default value of Vol, returns the alkalinity to pHe for a sample (sample pH = pHs) that has measured alkalinity of alk (mEq/L) to end point pHa. With the default pH values, for example, this function would convert an alkalinity measured to end point 4.4 (as is used by Ward Labs) to the ISO alkalinity with its specified end point of 4.5. Calculates the alkalinity to pHe of a sample when alk mEq of acid added to Vol liters lowers the pH from pHs to pHa,

Bicarb2Alk(pH, Bicarb, [pHe = 4.5])

Returns the alkalinity (mEq/L) as a function of the bicarbonate ion at pH. Alkalinity is as defined for a titration ending at pHe. The ISO standard pHe is supplied as a default. This function is here

Page 7: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

because it is so common for people to tell us their bicarbonate content rather than their alkalinity. While it is true that bicarbonate and pH are completely equivalent to pH and alkalinity that assumes that the reported bicarbonate number is accurate. As few know how to calculate bicarbonate correctly from an alkalinity measurement be suspicious of reported bicarbonate levels.

Calcium_CaCl2(Vol, Wt, [nHyd = 0])

Returns calcium ion concentration (mg/L) when Wt grams of calcium chloride carrying nHyd waters of hydration (default 0) are dissolved in Vol L of water.

Calcium_CaSO4(Vol, Wt, [nHyd = 2])

Returns calcium ion concentration (mg/L) when Wt grams of calcium sulfate carrying nHyd waters of hydration (default 2) are dissolved in Vol L of water.

Calcium_CaCO3(Vol, Wt, [nHyd = 0])

Returns calcium ion concentration (mg/L) when Wt grams of calcium carbonate carrying nHyd waters of hydration (default 0) are dissolved in Vol L of water assuming all the CaCO3 dissolves.

Calcium_Lime(Vol, Wt, [nHyd = 0])

Returns calcium ion concentration (mg/L) when Wt grams of calcium hydroxide carrying nHyd waters of hydration (default 0) are dissolved in Vol L of water.

CalcQ(pHz)

Reference only: Returns the charge on a mash at pHz but gathers the information it needs from the locations within a particular spreadsheet, the one that accompanies this manual, for its data. It cannot, therefore, be used with any other. See dQQWW for a more general approach.

Converts(Unit, UnitList, Arg, [ColOff = 1], [Direction = “TO”])

Looks up a conversion factor against a name and scales Arg by the conversion factor. Most useful for interconversion of units. UnitList is a range such as the one depicted in the screen shot below. The first column in the range consists of a list of names that will be searched trying to find a match to the string passed in Unit. When a match is found the conversion factor in the row containing the match and in the column ColOff from the list column is extracted and used to scale Arg either by multiplying it (Direction = “TO”) or dividing it (Direction anything but “TO”, “To” or “to”) by the factor. If no match is found the #VALUE error is returned.

Page 8: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

In the example image Col. S contains a list of names including units. In Col. T are factors by which one would multiply a weight in the listed units to obtain the weight in kg. In Col. U are the factors by which one would multiply a weight in the listed units to obtain a weight in pounds.

If we wished to convert a malt weight in ounces in Cell A1 to its value in kg one would use=Converts(“Malt Weight, Oz”, S42:S48, A1). Note that range specification need include only the names column but S42:U48 would work as well. Converts finds a match for this passed string in Row 44 and, as no column offset has been passed uses the default to find the factor 0.0274091 in Cell T44. It multiples the contents of A1 by this factor.

If we wished to convert that same malt weight in Oz to pounds we would use =Converts(“Malt Weight, Oz”, S42:S48, A1,2) indicating that the conversion factor should be taken from Col. U.

Now suppose we had a malt weight (or any other weight) in pounds and we wanted to convert it to grams. We would type =Converts(“Malt Weight, grams”, S42:S48, A1,2,”FROM”) telling Converts to look up the factor by which one multiplies grams to get pounds (in U48) and divide the contents of A1 by that thus instructing it to convert from pounds to the named units.

Note that Converts can also be used for table lookup. If, for example, Col. S contained a list of the names of various salts, Col. T the salts molecular weights, Col. U their equivalent weights and Col. V their densities one could get the molecular weight of a salt from =Converts(SaltName, S42:S48,1) or it’s density from =Converts(SaltName, S42:S48,1,3). Or if he had X grams of a salt and wanted to know how many equivalents that was he could get that from =Converts(SaltName, S42:S48,X,2,”FROM”)

Not that it doesn’t have to be just, for example, “Lbs”. It could be “Malt Weight, Lbs”. Unit list is the range of a column with a list of all the unit names you wish to use. The column to the right of this column contains conversion factors by which Arg is divided to get into the units you want. For example, if you want to convert to kg the entry in this column in the same row as “Malt Weight, Lbs” would be 2.2. If “Malt Weight, Lbs” is passed as the unit, ColOff is 0 (it’s an optional parameter with default = 0) then Arg/2.2 i.e. Arg converted to kg will be returned.

Page 9: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Other conversion factors can go in other columns. For example, to convert a malt weight in kg back to pounds one would again pass “Malt Weight, Lbs” as the unit and put 1/2.2 = 0.454 into the proper row of the column 2 to the right of the units column. Then Arg, now in kg, woulf be divided by 0.454 to turn it back into a weight in Lbs.

Ct(Alk, pHs, [pHe = 4.5], [Alert = FALSE])

When passed values for a water sample’s alkalinity (in mEq/L), sample pHs and the pHe used as the end point in the alkalinity titration Ct() returns the millimoles of carbo (sum of millimoles of carbonic acid, bicarbonate ion and carbonate ion) in a liter of the sample assuming that the water molecules themselves and carbo species are the only proton absorbers in the sample. pHe is an optional parameter. If a value is not passed the function assumes that it is 4.5 which is the value used in titrations following the ISO standard procedure.

Even pure water has finite alkalinity (Qw1L(pHe)). If you pass alkalinity less than that the carbo formula (see Total Carbo and Alkalinity in Appendix I) would compute a negative value which is impossible so in this event Ct returns 0 unless you have passed Alert = TRUE in which case a message box will appear stating that the error has occurred and that pH, alkalinity and pHe arguments should be checked. The function will return #CALC! (and all cells dependent on the cell which invoked Ct will too).

Ct_CaCO3(Vol, Wt, nHyd As Double = 0)

Returns the total carbo (carbonic plus bicarbonate plus carbonate) mmol/L when Wt grams of calcium carbonate are dissolved in enough water to make Vol liters of solution. Though sodium carbonate does not take it up one has the option to specify nHyd molecules water of hydration if desired. The default is 0. Note that CaCO3 is largely insoluble unless acid is used.

Ct_NaHCO3(Vol, Wt, [nHyd = 0])

Returns the total carbo (carbonic plus bicarbonate plus carbonate) mmol/L when Wt grams of sodium bicarbonate are dissolved in enough water to make Vol liters of solution. Though sodium bicarbonate does not take it up one has the option to specify nHyd molecules water of hydration if desired. The default is 0.

Ct_Na2CO3(Vol, Wt, [nHyd = 0])

Returns the total carbo (carbonic plus bicarbonate plus carbonate) mmol/L when Wt grams of sodium carbonate are dissolved in enough water to make Vol liters of solution. Though sodium One has the option to specify nHyd molecules water of hydration if desired. The default is 0.

Page 10: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

densHClw(Pct, [T = 20] )

Returns the density of an hydrochloric acid solution at temperature T (°C) whose strength is Pct (% w/w). For a 20% solution pass 20. T is an optional argument which defaults to 20 °C if it is omitted.

densH2SO4b(Baume)

Returns the density in grams/ml of sulfuric acid whose strength is expressed by the argument in degrees Baume’.

densH2SO4w(Pct, [T = 20])

Returns the density in g/mL of sulfuric acid of strength Pct (% w/w) at temperature T. If T is not specified 20 °C will be assumed. Requires H2SO4TCor for temperature correction.

dQAMS(pH, Volw, Vola)

Returns the proton deficit when Vola mL of AMS or CRS is added to enough water to make Volw of solution.

dQBicarb1mm(pHz)

Returns proton deficit, in mEq, of 1 mmol of bicarbonate ion with respect to pHz. This would be used to find the proton absorbing capacity of sodium bicarbonate to pHz, for example.

dQBicarb(pH,Vol,Wt)

Returns the deficit (mEq) to pH of water of volume Vol (L) in which Wt grams of sodium bicarbonate have been dissolved.

dQcarbo(pH,pHs,Ct)

Returns the proton deficit from pHs to pH of 1 L of water with carbo content Ct (mmol/L)

dQchalk(pH, Vol, Wt)

Returns the proton deficit (mEq) of Vol (L) of water into which Wt grams of chalk (CaCO3) have been dissolved assuming that the chalk actually dissolves.

dQHCl(pH, Volw, Vola, Conc, Code)

Page 11: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Returns the deficit at pH of Vola mL of Hydrochloric Acid of strength Conc added to enough water to make Volw liters of solution. The integer Code indicates how the concentration is expressed:

Code = 1: Conc is in % w/wCode = 2: Conc is in mEq/mL (i.e.Normality)Code = 3: Conc is in BaumeCode = 4: Conc is in Specific Gravity (not implemented yet)

dQLactic(pH, Volw, Vola, Pct)

Returns the proton defict (mEq/L) of Vola mL of lactic acid of strength Pct (% w/w) when dissolved in Volw liters of solution.

dQlime(pH, Volw,Wt, pKw)

Returns the proton deficit (mEq/L) to pH of Wt grams of calcium hydroxide dissolved in Volw liters of solution. pKw is the ionization constant of water

dQLye(pH, Volw, Wt)

Returns the proton deficit (mEq/L) to pH of Wt grams of sodium hydroxide dissolved in Volw liters of solution. dQPhosphoric(pH, Volw, Vola, Pct)

Returns the deficit at pH of Vola mL of Phosphoric Acid of strength Pct(%w/w) added to enough water to make Volw liters of solution.

dQSodaAsh(pH,Volw, Wt)

Returns the proton deficit (mEq/L) to pH of Wt grams of sodium carbonate dissolved in Volw liters of solution.

dQSulfuric(pH, Volw, Vola, Conc, Code)

'Returns the deficit at pH of Vola mL of Sulfruic Acid of strength Conc added to enough water to make Volw liters of water. Code is an integer which indicates what form the acid strength is epressed in.

Code = 1: Conc is in % w/wCode = 2: Conc is in mEq/mL (i.e.Normality)Code = 3: Conc is in BaumeCode = 4: Conc is in Specific Gravity

Page 12: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

dQm1kg(pHz, pHDI, a1, [a2 = 0], [a3 = 0])

Returns the proton deficit of 1 kg of a malt with deionized water mash pH equal to pHDI and buffering parameters a1, a2 and a3 to pHz. This is the charge change experienced by this malt in being brought to pHz from pHDI and thus the quantity of protons that must be supplied to 1 kg of this malt to bring about this change.

Parameters a2 and a3 are optional. If no values are passed for them they are set to 0. This makes typing this formula a little easier when only the linear buffering term is known.

dQmdpH(pHz, pHDI, a1, [a2 = 0], [a3 =0])

Returns the first derivative of the charge relative to pHDI with respect to pHz for 1 kg of malt with parameters pHDI, a1, a2 and a3

dQQWW(pH, Data)

Returns the proton deficit (mEq) with respect to pH for a mash whose parameters are placed in a spreadsheet range, Data, in a format discussed below. It is similar to CalcQ which is peculiar to the spreadsheet example which accompanies this manual and differs from it in that the range from which is draws its data is strictly formatted as shown in the image here:

To use it a developer locates his input data wherever he wants to for convenience but is then required to copy each input data item into the range Data in the format of the picture. For example, all masses must be in kg or grams and volumes in L or mL. Thus the developer must do unit conversion, where required, as part of the copying process.

One of the biggest benefits of these functions is that they allow one to, among other things, see immediately the effect on mash pH of changing any input parameter. This is done by the FindX function which zeroes the returned value of a function which computes mash proton deficit as a function of pH and all the other input variables. Thus you must have a function that accepts a passed value of pHz, gathers all the input variables from your spreadsheet and returns the total mash deficit. CalcQ does that for a particular spreadsheet developed by the writer as part of the process of generating these functions but is of no use to the general user. As, obviously, users of these functions will want to lay out their own spreadsheets in ways that suit their requirements and preferences we need a way to get input data from those layouts and come up with a deficit. dQQWW does that. As is the case with CalcQ it requires the data to be placed in the spreadsheet in particular locations but with dQQWW the data is formatted into a simple contiguous list. This list can be located anywhere (for example in columns that are hidden from the user or on another sheet). A spreadsheet developer can then locate data items anywhere he likes in the visible part of his spreadsheet and then copy them to the appropriate locations in the range that dQQWW require.

Page 13: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

The image below shows the format for this range. It must be strictly adhered to if dQQWW is to get the correct information2. Data must be in the units specified so in addition to copying input data to the list the developer must first convert to kg, mL or grams as required. Liquid acid concentrations can be specified in any of several ways but the dQQWW needs to know which system is being used and that is specified in the code column. The acid codes are:

Code = 1: Concentration is in % w/wCode = 2: Concentration is in mEq/mL (i.e.Normality)Code = 3: Concentration is in BaumeCode = 4: Concentration is in Specific Gravity

a simple list. It must follow the format of the following picture exactly but it need not start a A1. It can be located anywhere. The Data parameter is a range whose lower limit must be the cell that contains the water volume. Note that the range specified must not contain the labels. All data taken from Data are located relative to the top of the first column with numbers. Thus, for example, the range for the spreadsheet in the picture would be B1:F31 though B1:B31 would suffice. All dQQWW really needs to know is where the water volume is located.

In order to determine charge on source water its original pH, alkalinity and the pH used in the alkalinity titration must be known. These are often ignored by simpler spreadsheets but you are using these functions because you want better predictions. If you do not know the water’s sample pH leave the corresponding cell blank. dQQWW will use pHs = 7 in this case. If you do not know the titration end point pH leave that cell blank. dQQWW will use the ISO standard pHe = 4.5. Similarly, when specifying acids if you do not know the strength leave the cell blank and dQQWW will provide the most likely values (88% for lactic acid and 85% for phosphoric).

It is the user’s responsibility to collect all his input data from wherever it may be and copy it to cells in the exact relative positions in the picture. Values must be converted to metric and, if you have acids with strength expressed in units other than % w/w you must convert to %. There are, of course, functions here to help you do that.

2 Of course one can change the format of the list if he edits dQQWW to look for the data in the new locations.

Page 14: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

dQWaterCt(pHz, Alk, [pHs = 7], [pHe = 4.5])

Returns the charge change (deficit) of 1 L of water with alkalinity Alk (mEq/L, measured to titration pH end point pHe) originally at pHs when acid or base is added to bring it to pHz. This function is used to determine how much acid must be added to brewing water with known pH and alkalinity to acidify it to a desired mash pH, pHz. It is thus one of the most important functions in the set. The returned answer depends, of course, on all three parameters but it is not a strong function of either pHs or pHe. Often the user knows the alkalinity of his water but does

Page 15: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

not know the pH or end point pH which defines the alkalinity. This would, for example, be the case if he measured his water’s alkalinity with an aquarium drop test kit. Thus pHs and pHe are optional parameters set to, respectively, pH 7.0 and pHe 4.5 (ISO standard) if not passed.

The returned result will be > 0 if pH < pHs (proton deficit - protons must be added) and < 0 if pH > pHs (proton surfeit – protons must be absorbed) and is in units of mEq/L.

dQ1kgRow(row, pH)

Reference only: Returns the deficit at pH of 1 kg of the malt located in the passed row of the malt data table in the Voltmeter.

fAcid(n, pH, pK1, [pK2 = 60], [pK3 = 60], [pK4 = 60])

Returns the molar fraction of the species of the ion of an acid that carries charge -n at pH. Thus n = 0 corresponds to the un dissociated acid molecule (e.g. H3 PO4 ¿; n = 1 corresponds to the once dissociated ion (e.g. H 2 PO4

−1). Thus if phosphoric acid is added to water and the solution adjusted to pH, 100*fAcid(0, pH, pK1, pK2, pK3) percent of the phosphoric acid molecues would remain as the acid molecule, 100*fAcid(1, pH, pK1, pK2, pK3) percent of the added molecules would lose one proton and become H 2 PO4

−1 ions and so on.

Only 1 pK must be specified. pK’s not specified are set to 60 by the function this insuring that fAcid will return essentially 0 for n = the subscript on that pK.

FINDabc(Data)

Rinds the a1, a2 and a3 coefficients which characterize a malt from a table of measurements made on it. Data is passed as a range. It is organized in two columns the first of which contains pH values measured for the malt when the proton additions entered into the same row in the second column were added to a sample of it mashed with deionized water. These entries are scaled to mEq/kg malt. Proton additions are positive numbers equal to the product of the normality of the acid used and the number of mL of it added. Converely, for bases, the proton additions are negative numbers (a base removes protons) equal to the nomality of the base solution multiplied by the number of mL added.

Note that this is an array function – it returns an array of three values. Thus when it invoked from a spreadsheet an array must be created (select a row of 3 cells – it seems it must be a row) and when the function is typed shift-ctl-enter must terminate the typing.

FindBicarb(pH)

Reference Only: Returns the amount of sodium bicarbonate needed to zero the proton deficit as calculated by CalcQ which is peculiar to the Voltmeter spreadsheet.

Page 16: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

FindpHz(pH0)

For reference only. Finds the pH of a mash by zeroing CalcQ, q.v. Cannot be used with any spreadsheet except the one for which CalcQ is designed.

FindLactic(pH)

Reference only. Finds the amount of lactic acid necessary to zero the charge on a mash at pH. Useful only in the spreadsheet which comes with these functions.

FindPhosphoric(pH)

Reference only. Finds the amount of Phosphoric acid necessary to zero the charge on a mash at pH. Useful only in the spreadsheet which comes with these functions.

FindRoot(FuncName, [xlo = -1], [xhi = 15], [Tolerance = 1E-06], [MinBisIter = 2], [Iterations = 100])

Seeks x which, when passed to the function named FuncName (passed as a string), will cause it to return 0. That function may accept only the single argument x . If you wish to zero a function that requires more parameters use FindRoot_1.

Searches between xlo and xhi. If no root is found in that interval returns #FIELD to indicate that the field of search needs to be widened (i.e. xlo reduced and/or xhi increased). Usually this function will be used to find the value of pH which zeroes the proton deficit calculated by the function named in FuncName so the range xlo = -1 to xhi = 15is used as the default when xlo and xhi are not passed. This range allows finding the pH when strong acid or base at up to and a bit over 1 Eq/L are involved (not by any means a normal situation). The function works by bisecting the range xlo to xhi and finding which half the root is located in. Thus the root is trapped in successively smaller spans. It does this MinBisIter times after which it estimates x from the most recent value of bisecting x and the slope at that point. If the new solution is within the most recently determined sub range Newton Raphson can be used and FindX is called (with the last bisector as the initial estimate) to find the Newton-Raphson root. If NR isn’t suitable root bisection continues until the span is narrower than Tolerance. The user can keep the function in the bisection mode by specifying a high value for MinBisIter.

If the span xhi – xlo is wider than the tolerance after Iteration repeats and the function has not switched to NR it returns #CALC indicating that it was not able to calculate to the desired accuracy. The number of iterations is set to a default of 1E-6 and the number of iterations to 100 but any values can be passed and these values not only limit root bisection but are passes to FindX if the switch to NR is made. The execution of the spreadsheet can be speeded if tolerance is increased (we don’t need to know pH to more than 3 decimal places if that). Developers should be aware of this and use the widest tolerance they can.

Page 17: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Root bisection is less efficient than Newton-Raphson but more robust as long as the root is trapped between the specified limits and there is only one root. That will be the case with the montonic charge functions found in brewing. Some of these functions, however, have flat portions (at pH values removed from pK values) that would cause Newton-Raphson to fail. That’s what FindRoot is for but use FindX when possible. It will usually do for mash pH determination because while the deficit vs pH functions are curvy enough. An example of where it fails is where one seeks to estimate the pH of a solution of calcium hydroxide. It’s deficit vs pH curve is very flat up to pH of about 10 and unless the Newton-Raphson initial guess is above that it will fail. FindRoot with xlo = 0 and xhi = 14 sets the bisector to 7 initially. After the first iteration it is set to 10.5. The solution, when Ca(OH)2 is added to DI water is a little over 11 so a second iteration of root bisection would be at 11.225 which is close to the solution and past the flat part of the Ca(OH)2 curve.The #FIELD and #CALC error messages are part of Excel but are undocumented. I cannot find any reference to them on the internet so I have no idea what they normally signify. They do loosely fit our needs here, though.

FindRoot_1(FuncName, NoParams, [xlo = -1], [xhi = 14], [Tolerance = 1E-06], [x1 = 0], [x2 = 0], [x3 =0], [MinBisIter = 2[, [Iterations = 100])

Seeks x0 which, when passed to the function named FuncName (passed as a string), will cause it to return 0. FindRoot_1 is just like FindRoot except that the function it calls may accept up to 4 parameters (x0 and 3 others). The number to be passed includes x0 and is specified in NoParams. Values for all parameters (except x0) must be passed to FindRoot_1 or it will pass 0 to the called function for them. Clearly FindRoot_1(FuncName, xlo, xhi,1) will return the same value as FindRoot(FuncName, xlo, xhi). The only reason for having that function is that often it is only pH that is passed to the called function and in those cases the processing of the options offered by FindRoot_1, which consume machine cycles, are wasted. The demonstration spreadsheet has grown to the point where there is a ton of computing going on to the point that speed reduction is noticeable. We have thus become sensitized to reducing computation burden in any way we can.

The last three paragraphs in the description of FindRoot apply to FindRoot_1 as well.

FindX(FuncName, x0, [Tolerance = 1E-6], [Iterations = 100])

Returns the value of x which zeroes FuncName(x) based on Newton-Raphson using an initial guess of X0. The function name is passed as a string, i.e. it must be enclosed in quotes. The tolerance and maximum number of iterations are optional parameters set to, respectively 1E-6 and 100 if no values are passed.

Newton Raphson is fine for most of the functions encountered in brewing as they are smooth, monotonic functions of pH, the usual variable sought. Before using this function to solve arbitrary functions make sure your function is suitable for Newton-Raphson. The iterations limitations should save you if you pass FindX a function not suitable for it.

Page 18: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

FindX_1(FuncName, NoParams, [x1 = 0], [x2 = 0], [x3 = 0], [Tolerance = 1E-6], [Iterations = 100])

This function is identical to FindX except that whereas with that function you can only pass the initial guess, x0, for the variable being iterated, with FindX_1 you can pass up to three additional parameters (x1, x2 and x3). To do this you must tell FindX_1 how many parameters you are passing in NoParams and must pass them. If you don’t the values sent to FuncName for them will be set to 0. NoParams must be between 1 and 4 inclusive. Note that if NoParams = 1 you might as well be using FindX but there is nothing to stop you from zeroing a function with only one parameter with FindX_1

Returns the value of x which zeroes FuncName(x) based on Newton-Raphson using an initial guess of X0. The function name is passed as a string, i.e. it must be enclosed in quotes. The tolerance and maximum number of iterations are optional parameters set to, respectively 1E-6 and 100 if no values are passed.

Newton Raphson is fine for most of the functions encountered in brewing as they are smooth, monotonic functions of pH, the usual variable sought. Before using this function to solve arbitrary functions make sure your function is suitable for Newton-Raphson. The iterations limitations should save you if you pass FindX a function not suitable for it.

GetFromTable(Origin, row, col)

Returns the contents of a cell displaced row rows and col columns from the origin. Note that indexing is relative to the origin meaning that GetFromTable(Origin, 0, 0) returns the contents of the cell specified as the origin.

HClCode(Name, Labels)

Compares Name (passed as a string) to a list of names (range passed in Labels) 43eof hydrochloric acid containing the way in which its strength is described and returns a code indicating the position of the match in the list. The list names can be anything you like and located anywhere you like but the order of strength specification must be as in the list below. The list names can be anything you like and located anywhere you like but the order of strength specification must be as in the list below. This is because the function dQHCl (q. v.) which calls it will calculate deficit for Code 1 assuming that the concentration value passed to it is the acid strength in % w/w. Similarly, it processes Code 2 assuming concentration is Normality, Code 3 assuming concentration is specified in degrees Baume’ and Code 4 assuming strength is specific gravity.

Hydrochloric Acid w/w%Hydrochloric Acid NHydrochloric Acid BeHydrochloric Acid, SG

Page 19: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

H2SO4TCor(Pct, T)

Returns the correction to the density of sulfuric acid of strength Pct at temperature T °C. Used by the sulfuric acid density functions.

LacDens(Pct)

Returns the density in grams/mL of a lactic acid solution of strength in % w/w

LacNorm(pHz, Pct)

Returns the normality in mEq/mL of a lactic acid solution of strength Pct (% w/w) to pH = pHz. This is the quantity of protons that 1 mL of the acid will yield in being brought to pHz.

ListdQ(Name,Strength,pH,Names)

For reference only. This function returns the proton deficit (mEq per gram or mL) with respect to the passed pH of an acid or base with the given Name (string) which is part of a list of names located in the range Names. This function is used to gather data from the workbook spreadsheet Sheet1 and is peculiar to that sheet. The list of names appears in a column. In the column to the right is a list of molecular weights. To the right of that is a column in which deficits with respect to a fixed cell (which has a copy of the desired pH in it) are calculated. These data are for convenience only and are not accessed by ListdQ. To the right of the deficts column are three columns with pKa’s and pKb’s for the various acids and bases. Protons which do not exist for a given acid (e.g. 2nd and 3rd ones for lactic acid) have 60 entered for their pKa’s. ListdQ first matches Name to the list to find the row in which Name occurs (calls MatchRow). It then does Select Case by row to see how to process the other data items in the row to compute the deficit per unit (ml or gram) of the specified acid or base. It returns the deficit (mEq/mL or mEq/g).

Note that the most likely to be selected acids (lactic, phosphoric) and bases (sodium bicarbonate, lime) appear high in the Select Case list so that the searching required by the function will, on average, be lessened.

Also note that while the acid/base data is located in the workbook that accompanies these note in the range S53:X69 that it can be relocated anywhere as the range is passes to the function. Only the range of the Names column need be passed as everything is determined relative to that. And note further that there is one slot in the list for an arbitrary acid (one whose molecular weight and pKa’s can be entered by the user). Additional acids can, of course, be added but the Select Case part of the code will need to be modified to accommodate such additions. Any existing name in the list can be changed to that of another acid as long as its molecular weight and pKa’s are placed in the proper adjacent cells.

log10(x)

Page 20: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Returns the Briggs logarithm (base 10) of x. Apparently Excel doesn’t have this!

MatchRow(Name, Names)

Given a list of text items located in range Names, returns the number of the row whose entry matches Name.

NormHClb(Baume) As Double

Returns the nomality (mEq/ml) of a hydrochloric acid whose strength is Baume degrees Baume. T is an optional parameter. If nothing is passed 20 °C is used.

MaltRow(MaltName)

Reference only: returns the row number of the malt with passed name in a table of malt in the Voltmeter spreadsheet.

NormHClw(Pct, [T = 20])

Returns the nomality (mEq/ml) of a hydrochloric acid solution at temperature T (°C) whose strength is Pct (% w/w). For a 20% solution pass 20. T is an optional parameter. If nothing is passed 20 °C is used.

pHCarbSat(pHs, Ct, Ca, [pfm = 0], [pK2 = 10.38], [pKs = 7.87])

Returns the saturation pH (the pH at which the water is saturated with respect to CaCO3 – above this pH precipitation is likely to occur, below it it is not) of a water sample at pHs with carbo of Ct (mmol/L) and calcium concentration Ca (mg/L). Nominal values for the solubility of Calcite and for the second pK of carbonic acid are supplied as is a nominal value of pfm =0 for ionic strength. The returned value contains a term 5*pfm (so that pfm of 0.02 implies a shift of 0.05 pH units relative to pfm = 0.01. Thus this is the one place in these functions where pfm may be significant. No fuction(s) are as yet available at this time to evaluate pfm.

PhosDens(Pct)

Returns the density in grams mL of phosphoric acid of strength Pct (% w/w)

PhosNorm(pHz, Pct)

Returns the normality in mEq/mL of a phosphoric acid solution of strength Pct (% w/w) to pH = pHz. This is the quantity of protons that 1 mL of the acid will yield in being brought to pHz.

pH_1Step(WtData, MaltData, Qw, Qother, GuesspH, Qweps, Qothereps, eps)

Page 21: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Returns a pH estimate using the Riffe formula, that is, one based on solving the linear equationin pH that results when the non-linear nature of the problem is ignored. Probably most useful for determining the magnitude of the error induced by using the linear solution rather than the iterative one.

Malt WtData is the range of a column with the weights of a group of malts to be mashed. MaltData is a range that contains the descriptive data for these malts. The data for the first malt row must correspond to the weight data is the frst row of the WtData array but the arrays may be located anywhere. The MaltData araray consists of 4 columns. The first contains DI water mash pH’s, the second a1, the third a2 and the fourth a3.

Qw is the water's total proton deficit including that attributable to calcium and magnesium phosphate reaction. Qother is the deficit for acids or bases added to the mash or water. As these are functions of pH we must have a way of coming up with values for them when a linear approach is used. For the Riffe method use the water volume times the alkalinity (mEq/L) for Qwater and the number of moles of each of the acids and based for Qother except in the cases of sulfuric acid, calcium hydroxide and sodium carbonate where you should use twice the number of millmoles of each.

For the basic Riffe formula only pass the first 4 parameters. The others are all optional. The function will take a single Newton-Raphson step from pH = 0 calculating the slope from the linear buffering terms of malts

For the first level of improvement pass also GuesspH. This will cause the algorithm to take a single Newton-Raphson step from Guess pH calculating the slope from all the malt parameters but it will still use the constant values for Qw and Qother.

For the second level of improvement pass Qweps. Qw must be the deficit of the water calculated at pH and QWeps must be the deficit of the water calculated at pH + eps where eps is a small number that must also be passed. It defaults to 1E-6. The same applies to Qother and Qothereps.

For more detail see the Appendix.+¿

Plato(SG)

Returns the strength of a solution of specific gravity SG in °P. Uses the ASBC polynomial for SG < 1.08292 and a fit to ICUMSA data otherwise.

Plato2SG(P)

Returns the specific gravity of a solution of strength P degrees Plato. Inverts Plato(SG).

QAcid(pH, pK1, pK2, pK3, pK4)

Page 22: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Returns the charge on the anions from 1 mmol of an acid with the (up to) 4 pK values passed at pH. Only the first pK is required. If values are not passed for other pK’s they will be set to 60 thus insuring that no charge is attributable to protons associated with them.

QCarb(pH)

Returns QAcid(pH, 6.38, 10.38). As carbonic acid is of interest in so many places this is provided simply to make calling it easier as the pK’s don’t have to be typed. In writing VBA functions you may prefer to use QAcid as some machine cycles are saved by not having to set up the call and return. The same is, actually, true of course when this function is used in a spreadsheet.

dQ

Reference only: Collects all deficit related information from the water sheet (Sheet2) and computes the deficit with respect to pH.

QWater(pH, Ct, Qbalcat)

Used in calculating the pH of a blend of waters. This one is a little hard to understand. If we are given a sample of water at some pH its carbo, Ct mmol/L, will be distributed in some way and will have some negative charge on it as will the water molecules themselves. The water must, therefore, contain some cations of equal magnitude but opposite sign, Qbalcat, that balance this negative charge. There may well be other cations in the water too that are balanced by other anions such as chloride and sulfate. They are not of interest here. For a water sample at pHs with carbo of Ct:

Qbalcat = - (Qw1L(pHs) + Ct*(QAcid(pHs,6.38,10.38))

If we compute Qbalcat thus and put it into QWater with pH and Ct QWater will return 0. If we now blend this water with another water that has its own Ct and Qbalcat values the Ct and Qbalcat values for the blend will be the weighted (by the relative volumes of the waters) average of the individual waters’ values. None of the other cation or anion charges in the water are effected by the pH shift that may occur as a consequence of the blending.

Putting the blend values of Ct and Qbalcat into QWater will give non zero results unless the pH passed is that of the pH of the blend. As the goal is to find this pH one uses QWater with a function, WaterpH(Ct, Qbalcat) q.v., that finds the pH which zeroes the charge returned by Qwater.

Qw1L(pH, pKw)

Returns the charge on one liter of water at pH for the value of pKw passed to the function. If no

Page 23: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

value of pKw is supplied the function sets it to 14, its value at 25°C

RangeCol(Range)

Returns the column number of the first row in the range.

RangeRow(Range)

Returns the row number of the first cell in the range

RangeRows(Range)

Returns the number of rows in the passed range.

SulfuricCode(Name, Labels)

Compares Name (passed as a string) to a list of names (range passed in Labels) of sulfuric acid containing the way in which its strength is described and returns a code indicating the position of the match in the list. The list names can be anything you like and located anywhere you like but the order of strength specification must be as in the list below. This is because the function dQSulfuric (q. v.) which calls it will calculate deficit for Code 1 assuming that the concentration value passed to it is the acid strength in % w/w. Similarly, it processes Code 2 assuming concentration is Normality, Code 3 assuming concentration is specified in degrees Baume’ and Code 4 assuming strength is specific gravity.

Sulfuric Acid w/w%Sulfuric Acid, NSulfuric Acid, BeSulfuric Acid, SG

SulfuricNormb(pH, Be)

Returns the normality of a sulfuric acid solution whose strength is Be (° Baume) at pH given by the first argument.

SulfuricNormSG(pH, SG)

Returns the normality of a sulfuric acid solution whose strength is expressed by its specific gravity at pH given by the first argument.

SulfuricNormw(pH, Pct)

Page 24: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Returns the normality of a sulfuric acid solution whose strength is Pct (% w/w) at pH given by the first argument.

SulfuricNormSG(pH, SG)

Returns the normality of a sulfuric acid solution of specific gravity SG at pH given by the first argument.

TDSLime(bicarb, pHs, alk, [pHe = 4.5])

Returns the amount of limestone (mg/L) that was dissolved to produce water at pHs with alk (mEq/L) alkalinity and bicarb (mg/L) bicarbonate ion content. This is used when estimating gravimetric TDS from a water report. Add up the masses of all the reported ions except carbonate and bicarbonate and add the mass returned by this function.

Note: This function only gives a reasonable answer if the hardness and alkalinity of the water are derived naturally.

testerr(code)

If code is a valid Excel error code testerr(code) returns the appropriate Excel error message. The following codes are the ones we have discovered. Any other code returns #VALUE!

Code Return2000 #NULL!2015 #VALUE!2023 #REF!2036 #NUM!2042 #N/A2043 #GETTING_DATA2045 #SPILL!2046 #CONNECT!2047 #BLOCKED!2048 #UNKNOWN!2049 #FIELD!2050 #CALC!

VolWrt(X,[Vol_water = 1])

Returns the volume of a wort which is a mix of X kg of extract and Vol_water liters of water. Default water volume is 1 L.

Page 25: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

WaterpH(Ct, Qbalcat)

Used with QWater, q.v., which it calls, to find the pH with zeroes out the charge of a blend of waters with total carbo Ct mmol/L and total cation charge to balance the water charges in the original mixed sources. See QWater for a full description of the use of WaterpH

XperL(P)

Returns the mass of extract (kg) in 1 L of wort of strength P (degrees P).

XV2P(X,[Vol = 1])

Finds the strength (°P) of a wort with X kg extract in wort volume Vol. Volume is, by default, 1 L.

Appendix I – The Chemistry

milliMoles, milliEquivalents, Molecular Weight, Equivalent Weight, Normality

The purpose of the functions is, among other things, to allow the computation of the amount of something we need to add to a mash to attain a desired pH. We must, thus, have a means of specifying the quantities of materials that emit or absorb the required amount of charge. How do we measure charge? The answer is in chunks of 6.023 x1023 protons (a proton carries a charge of +1). This very large number is called Avogadro’s Constant and is defined by the fact that 6.023 x1023 atoms of carbon weigh exactly 12 grams. 6.023 x1023 atoms or 6.023 x1023 molecules or 6.023 x1023 objects of any sort is called a mole (short for gram molecule). 6.023 x1023 charges, however, are called an equivalent. Thus an equivalent is a mole of charge. The term may also be applied to an entity that carries the charge. 6.023 x1023 calcium atoms weighs 40 grams. It is said to have a molecular weight of 40 grams even though we are talking about atoms here. Alternatively, though, we could say it has an atomic weight of 40 grams.

A mole of calcium chloride (CaCl2) if dissolved in water immediately separates into one mole of calcium ions, Ca++¿¿, and two moles of chloride ions, Cl−¿¿. The charge on the calcium ions is two moles. Thus we can, and often do in such cases, say that we have two equivalents of calcium and two of chloride ion. An equivalent of calcium must, thus, weigh half what a mole of calcium does. Calcium is said to have an equivalent weight of 20 grams.

As we don’t usually deal in solutions of strength measured in moles the millimole (mmol) and milliequivalent (mEq) are much more convenient units. The emphasis in these functions is on the mEq or mEq per liter (mEq/L) or mEq per kilogram (mEq/kg – malts) as we are most concerned with charge but ultimately we often want a weight. If we find a mash has, at our desired pH, a proton deficit of 114 mEq we know that it must be supplied those 114 mEq of protons from an added acid (or acid malt). If we know that 88% lactic acid supplies (at the desired pH) 11.4 mEq

Page 26: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

protons per mL acid we find right away that we need 10 mL of that lactic acid. The “strength” of an acid in terms of mEq protons it can deliver per mL of it is called its normality.

Similarly, if we find a mash to have a proton deficit of -100 mEq at the desired pH we need to add something that absorbs 100 mEq of protons. Each mmol of lye (NaOH ) absorbs 1 mEq of protons (whatever the pH) so we need 100 mmol of lye to do the job. The molecular weight of lye is 40 grams per mol or 40 mg/mmol so we need 4000 mg (4 g).

The Core

The key concept behind these functions is that charge on substances change when there is a pH change and that at the system equilibrium pH the sum of the charge changes on all the items in a mash is 0. The chemistry tells us how and why the charges change in enough detail to allow us to compute charge changes.

The key to the chemistry is the way in which the deionization of an acid depends on pH. We use carbonic acid, which is responsible for water alkalinity, as an example. Carbonic acid, H 2C O3, has two hydrogen atoms each bound to one of its 3 oxygen atoms by sharing its electron (a hydrogen atom has one proton and one electron) with it. Oxygen has a higher electron affinity than hydrogen and so one of the protons may become loose leaving its electron behind on the oxygen. In accordance with the basics theme set forth in the introduction this proton has to transfer somewhere and where it goes, in a pure solution of carbonic acid, is to a water molecule. This is written as

H 2C O3+ H2O ↔ H3 O+¿+HC O3−¿¿¿

This is a simplification as the water molecules cluster into large super molecules so that this notation really represents the transfer of the proton to one member of a cluster. Even so this notation is often considered too cumbersome and is usually simplified to

H 2C O3↔ H+¿+HC O3−¿¿¿

Here H+¿¿ would literally represent a naked proton, that is, a hydrogen atom that has lost its electron but we must understand that it really represents a proton transferred to a water molecule cluster. The double headed arrow indicates that the proton may transfer back to the bicarbonate ion reforming carbonic acid

The simplified notation makes it easier to write the law of mass action for the reaction

¿¿

In which the bracketed quantities represent the molar concentrations of the enclosed species and K 1 is a constant (that varies a little with temperature). The subscript 1 indicates that this constant pertains to the loss of the first proton. That’s required because a bicarbonate ion can also lose its remaining proton

Page 27: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

HC O3−¿↔ H +¿+C O3

−2¿ ¿

There is a law of mass action equation that applies to this reaction too

¿¿

We now introduce the p operator: p (•)=−log (•). In other words, in applying this operator to a quantity we simply take that quantity’s logarithm (base 10) and reverse the sign of the answer. Applying the p operator to the first equation and using the properties of logarithms we get

p¿

Reader’s will probably not be surprised to learn that p¿ was the original definition of pH and is, even with respect to the current definition, equal to the pH for the weak solutions we are dealing with here.

Rearranging this form of the equation we have

pH−p K 1=p [ H 2C O3 ]−p¿

Now using each side as the power to which 10 is raised we get

10(pH− p K1)=10 p [ H2 C O3 ]− p¿¿

which says that the ratio of the bicarbonate ion (that is, carbonic acid molecules which have lost one proton) concentration to the carbonic acid concentration is 10(pH− p K1). We symbolize this ratio by r1. Doing the same for the dissociation of bicarbonate to carbonate we get

10(pH−p K2)≜r2

Were the acid triprotic (for example, phosphoric acid) we would have a third pK and a third ratio

r3≜10(pH− p K 3)

and so on for as many protons as the acid has to release.

Now let us suppose that we have a solution in which there are x mmol/L of carbonic acid. Then there must be x r1 mmol/L bicarbonate ions and x r1r2 carbonate ions so that the total mmol of carbo (carbonic + bicarbonate + carbonate) must be

CT=x+x r1+x r1 r2

The fraction of these that are carbonic acid is

Page 28: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

f 0=x

x+x r1+xr1 r2= 1

1+r1+r1r2

The subscript 0 indicates that carbonic acid molecules are not charged. They are not dissociated.

The fraction of the total that is bicarbonate ions (single negative charge is)

f 1=r1 x

x+x r1+ xr1 r2=

r1

1+r1+r1 r2=r1 f 0

and the fraction that is doubly charged isf 2=r2 f 1

The subscripts indicate the magnitude of the negative charge on anions of this acid at pH. Remember that the r’s and hence the f’s are a function of the pH and the pK’s of the acid. It is probably clear that where more than two protons are involved

f 0=1

1+r1+r1r 2+r1r2 r3+⋯

The total charge derived from 1 mmol of an arbitrary acid added to pure water at pH is then

Q=0 f 0−1 f 1−2 f 2+⋯

The function QAcid( pH , pK1 , pK2 , pK 3 , pK4) implements this math and returns Q at pH for the (up to 4) pK’s passed to it. The pK values for carbonic acid are pK 1=6.38 and pK 2=10.38.

Advanced: The derivative of this with pH may be of interest for the problem (not as yet addressed here) in which the amounts of salts and acids added to water that best matches desired warer parameters is sought.

∂ Q∂ pH

=−∂ f 1

∂ pH−2

∂ f 2

∂ pH+⋯

There’s some algebra coming∂ f 1

∂ pH=r 1

∂ f 0

∂ pH+f 0

∂ r1

∂ pH

∂ f 0

∂ pH= −1

(1+r 1+r 1r2+⋯)2

∂(1+r1+r1r 2+⋯)∂ pH

∂(1+r1+r1 r2+⋯)∂ pH

=∂r1

∂ pH+r1

∂ r2

∂ pH+r2

∂ r1

∂ pH+⋯

Page 29: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

∂r∂ pH

= ∂∂ pH

10pH 10− pK=10−pK ∂∂ pH

10pH=10− pK ln (10)10pHln(10)

∂ f 0

∂ pH=

−ln (10 ) 10pHln ( 10)(10−pK1−r110−pK2−r2 10−pK1+r1 r210−pK3+⋯)(1+r 1+r 1r2+⋯)2

Acid dQ

As we are interested in charge changes a couple of comments regarding calculating them for acids are appropriate. When given a water at some sample pH, pH s, intending to use it to make a mash which we want at some target pH, pHZ, we need to know how many protons must be supplied to it in order to reach that goal. The charge on 1 mmol of carbo at pH s is QAcid(pH s , pK1 , pK 2¿ and at pHZ is QAcid(pH Z , pK 1 , pK 2¿. The pK’s are those of carbonic acid. The charge that must be supplied to it, per mmol, is then simply the difference between these

dQ=QAcid ( pHZ , pK 1 , pK 2)−QAcid (pH s , pK 1 , pK 2)

We stated in the introductory material in the main part of this document that the lower the pH the more positive the charge. Thus as pH Z< pH s, QAcid ( pHZ , pK 1, pK2 )>QAcid (pH s , pK1 , pK 2) and, even though both are negative numbers, the former is less negative than the latter, dQ will be a positive number. We often refer to dQ as the proton deficit based on this case as, given that we want pH Z< pH s we must get protons from somewhere and the water must, therefore, be deficient in them.

Now let’s suppose that we intend to get those protons from phosphoric acid. Phosphoric acid comes in a bottle containing, presumably, nothing but phosphoric acid and water. We know what its strength is, i.e. what percent of its mass is phosphoric acid and thus we know the phospo (mmol of phosphoric acid plus mmol of mono, di- and tribasic phosphate ion) in a mL of it but we don’t know what its pH is, what the distribution among the ion species is or, therefore, what the charge on a mmol of it might be. But we do know how many mmol of phosphor went into that bottle when the solution was prepared and we know that the charge on them was 0. After being used to bring the pH of our mash to pH Z we know that the charge one each mmol is going to be QAcid ( pH Z , pK 1 , pK 2 , pK 3 ) where the 3 pK’s are now those of phosphoric acid. Thus, as before

dQ=Q ( pH Z )−Q ( pH original )=QAcid ( pHZ , pK 1 , pK 2 , pK 3 )−0<0

Thus the proton deficit of phosphoric acid, with respect to mash pH, is a negative number. This is fine as when we add the deficit of phosphoric acid at pHZto the deficit of the carbo at pH Z we

Page 30: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

want the sum to be 0. But we often refer to a negative deficit as a surfeit. All this can be confusing. Users need to pay attention to sign.

As a third example suppose we contemplate adding sodium bicarbonate to mash or water. In sodium bicarbonate, NaHC O3, sodium ions are linked to bicarbonate ions. As soon as the salt hits water they separate and then some of the bicarbonate ions donate a proton to others so they become carbonate ions and the recipients become carbonic acid molecules. Whatever that distribution may be we don’t know and don’t care because we know the original charge on the bicarbonate ions was -1 per mmol and this bicarbonate added to water that came to some pHZ must have absorbed

dQ=QAcid ( pHZ , pK 1 , pK 2)−Q ( pH original )=QAcid ( pHZ , pK1 , pK 2 )−(−1 )>0

per mmol added NaHC O3. Thus the added bicarbonate, in common with the bicarbonate already in the water, has a positive proton deficit.

Charge on Water

Here we mean just water. That is, we don’t mean the water plus the minerals in it. We mean just the water. For dilute solutions pH=−log ¿ and, thus, the concentration of H+¿¿ is

¿

This is in units of mol/L. We work with the smaller concentration unit of the mmol and so write

¿¿

mmol/L. These hydrogen ions each have a positive charge of 1 and so x mmols of H+¿¿ ions per liter contribute x mmols of positive charge per liter. When speaking of charge we use the units of millequivalents (mEq) and so have, from the hydrogen ions in 1 L of water at pH a positive charge of (1000)10−pH mEq/L. But water at pH also contains negatively charged hydroxyl ions (OH )−¿¿. Their concentration, in mmol/L is

¿

in which pKw is the dissociation constant of water which depends on temperature and is 14 at 25 °C. Thus the total charge on a liter of water is

Qw=1000(10−pH−10( pH− pKw ))

This is returned by the BrewingFuncs function Qw1L(pH, pKw)

Total Carbo and Alkalinity

Page 31: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

We have discussed finding out how much charge must be supplied or absorbed in order to set a given pH. The functions discussed return the charge per mmol of carbo and so the obvious question is how one determines how many mmol of carbo are in his water. The key to finding this out is alkalinity. Alkalinity is nothing more nor less than the proton deficit of 1 L of the water to a standard end point pH. Ward Labs uses pH 4.4, the ISO standard calls for 4.5, a second ISO standard 5.4 and some authors use 4.3. In any case the procedure for finding alkalinity is to titrate a sample of the water with strong acid. As each mmol of strong acid delivers 1 mEq of protons per mmol of the acid the proton deficit of the sample is simply the number of mL of it required to get to the end point pH multiplied by the normality of the acid. Several companies sell 1 N and 0.1 N standard acids for just this purpose. Whatever the sample size and normality of the acid the result is expressed as the number of mEq required to get 1 L of the sample to pH e, the end point pH. In order to find the carbo the first thing we do is subtract Qw ( pH e)−Qw ( pH S )which is the number of protons added to the sample during the titration that wound up attached to water molecule clusters from the total acid used. The remainder is assumed to have reacted exclusively with carbonate and bicarbonate ions. This is not the case if other bases, such as organic acids from decaying plant material, for example, are present. Assuming this to be insignificant then the remaining protons went to conversion of carbonate to bicarbonate and bicarbonate to carbonic. The amount used for this purpose is

CT(QAcid ( pH e )−QAcid ( pH S ))

As this plus the protons that went to water clusters is the total it is clear that

CT=alk−(Qw ( pH e )−Qw ( pH S ))(QAcid ( pH e)−QAcid ( pH S ))

Function Ct(Alk, pHs, pHe) returns a value for CT

Mash Total Proton Deficit, Approximate Linear Solution for pH

The total proton deficit for a mash is:

Q=∑i

mi(a¿¿1 ,i ( pH−pHDI , i )+a2 , i ( pH−pH DI ,i )2+a3 ,i ( pH −pH DI ,i )

3)+Qwater (pH )+Qother ( pH )¿

in which mirepresents the mass of malt number i, a1, i , a2 ,i and a3 ,i are the buffering coefficients for that malt and pH DI , i that malt’s DI mash pH. Qwater (pH ) is the proton deficit of the water at pH. It is also a function of the water’s alkalinity, its sample pH and the end point of the titration used to measure the alkalinity. Qother ( pH ) is the proton deficit of any acids or bases added to the mash. If the acids or bases are strong there is no pH dependency but for lactic and phosphoric acid and even, to a tiny extent, sulfuric, there is a dependence. Protons released by the reaction of calcium and magnesium ions with phosphate must be included in either one or the other of these terms. It doesn’t matter which as they are added.

Page 32: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Clearly this equation is not linear with respect to pH so that when we set Q to 0 and solve for pH we must use an iterative technique such as Newton Raphson and that is exactly what we do with function FindX and FindRoot. FindX uses Newton – Raphson to find the value of pH which zeroes Q starting with an initial guess pH 0. FindRoot differs in that it is given a range within which pH is expected to be found, checks that the root is indeed in that range, does a couple of iterations of root bisection and checks that Newton-Raphson will converge and then starts Newton Raphson using the root bisection estimate as pH 0.

Newton Raphson computes a new guesstimate using

pH 1=pH 0−Q( pH 0) /∂Q( pH 0)

∂ pHAfter n iterations we would have the estimate

pH n= pH n−1−Q( pH n−1)/∂ Q( pHn−1)

∂ pH

and we proceed until |Q ( pH n )∨¿ tolerance. As the problem is pretty close to linear only a few iterations are needed.

∂Q (pH 0)∂ pH

=∑i

mi(a1 ,i+2a2 ,i ( pH −pHDI , i )+3a3 ,i ( pH−pH DI ,i )2)+

∂ Qwater

∂ pH+

∂Qother

∂ pH

If we ignore the non-linearity of the malts (set coefficients a2, i and a3 ,i to 0) and ignore the dependence of Qwater and Qother on pH we can simplify to

Q=∑i

mi a1 , i ( pH−pH DI ,i )+Qwater+Qother

and∂Q (pH 0)

∂ pH=∑

imi a1 ,i

Then

pH 1=pH 0−∑

imi a1 ,i ( pH 0−pHDI , i)+Qwater+Qother

∑i

mi a1 ,i

If we set pH 0=0 we’d then have

pH 1=−−∑

imi a1 ,i pH DI ,i+Qwater+Qother

∑i

mi a1 ,i

=∑

imi a1 ,i pHDI , i−Qwater−Qother

∑i

mi a1 ,i

Page 33: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

pH ≈∑

imi a1 ,i pH DI ,i

∑i

mia1, i

≈∑

imi pH DI ,i

∑i

mi

≠−log(∑imi10−pH DI ,i

∑i

mi )Which is, of course, the same result we would get by solving the linearized Q equation for pH. In Ref. 2 (Riffe) the equation above is proffered as a solution to the mash pH estimation problem. Here we find little advantage in the linear solution as we have FuncX available. But we will note here that a one step solution better than the above solution is available. To get it we

recognize that the malts are non linear in computing Q and ∂ Q

∂ pH and take a single step from

pH 0=5.4

pH 1=5.4−∑

imi a1 , i ∆ pH i+∑

imi a2 ,i ∆ pH i

2+∑i

mi a3 ,i ∆ pH i3+Qwater( pH )+Qother (pH )

∑i

mia1 ,i+∑i

mi a2 ,i ∆ pH i+∑i

mi a3 , i ∆ pH i2+

∂ Qwater

∂ pH+

∂Qother

∂ pH

Here we have defined ∆ pH i=pH n−1−pH DI ,i to make the equation fit on the page. We chose 5.4 as the initial guess thus

pH=5.4−∑

imia1 ,i pH DI ,i+Qwater (pH )+Qother ( pH )

∑i

mia1, i

should represent a pretty good solution – certainly better than that of the equation two before this one as the effect of ignoring non linearity will be smaller. But what to do about Qwater (pH ) and Qother ( pH )? The dependency of these on pH is not strong. Both lactic and phosphoric acids provide about 1 mEq of protons per mmol in the typical range of mash pH. Strong bases, such as NaOH clearly absorb 1 mEq of protons per mmol in coming to typical mash pH. Bicarbonate ions absorb about 1 and carbonate about 2 as in this range the carbonic deficit curve is pretty flat. An approach, then, is to use 1 mEq/mmol for each of these acids and bases except for carbonate salts and sulfuric acid where the number is 2. This is what the first generation spreadsheets do. In using pH_1Step we can do the same or we can use the other functions available here to calculate deficits at a pH close to the expected predicted pH.

Appendix II AMS/CRS

AMS and CRS are the same product i.e. a blend of sulfuric and hydrochloric acids sourced from Murphy and Sons in Nottingham and sold to, respectively, the commercial and home brew

Page 34: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

markets. This statement from Murphy’s website lets us deduce what is in them: “35ml of AMS per hl of this water reduces the alkalinity by 64 mg/litre (ppm) and increases chloride levels by 22.5 mg/litre (ppm) and sulphate levels by 31 mg/litre (ppm).” Thirty five mL thus delivers 2250 mg of chloride which is 2250/35.453/35 = 1.81327 mmol/mL and 3100 mmol of sulfate which is 3100/96.079 = 0.92186 mmol/mL.

The chloride comes from HCl which, as it is completely dissociated, releases 2250/35.453 = 63.4643 mEq/100L = 0.6346 mEq/L of hydrogen ions (protons) into the water and the sulfate from H 2 SO4 which is also almost completely dissociated at alkalinity titration end point and so releases 2*3100/96.079 = 64.5302 mEq/100L = 0.645302 mEq/L. Thus these products are seen to be close to equinormal mixtures of the two acids. The total proton release per liter is the sum of these two per liter i.e. 0.6346 +0.645302 = 1.2799 mEq/L. Multiplying this by 50 gives 63.9951 which confirms Murphy’s 64 ppm alkalinity reduction.

Now 1.2799 mEq/L protons appear when 35 mL of AMS or CRS are added to 100 L of water thus it is clear that the normality of these products is 127.99/35 = 3.65686 mEq/mL. It is also clear that 1 mL of either contains 1.81327 mmol HCl and 0.92186 mmol H 2 SO4. This is how we model AMS and CRS in this workbook and its functions.

Appendix III Malt Data

Weyermann Pneumatic Pils 5.6227 -40.69 14.821 -10.008Weyerman Carafoam 5.886 -28.672 13.692 0Chocolate 600L Crisp 4.69875 -76.43 -0.404 -3.837Caramel 20L Briess (6 Row) 5.12265 -61.941 7.77 0Caramel 80L Briess 4.76565 -89.684 31.837 -10.056Weyermann Floor Pils 5.85475 -31.299 3.869 -1.986Weyermann Sauermalz 3.6165 -292.09 68.443 -5.3985Briess Roast Barley 300L 4.69825 -35.351 -38.11 6.8614Muntons Maris Otter 5.84177 -46.094 7.6213 -2.5325Crisp Maris Otter 5.6894 -46.589 6.3516 -2.623Flaked Barley 5.6437 -36.17 10.342 -2.48Weyermann Wheat Joe Walts 6.07 -44.916 -6.0244 0Munich I Weyermann Joe Walts 5.57 -43.125 12.931 0Melanoidin Weyermann Jow Walts 4.96 -62.532 -3.871 0Sauermalz Weyermann Joe Walts 3.41 -345.93 69.432 0Pils Rahr Joe Walts 5.8 -46.27 3.8476 0Pale Ale Rahr Joe Walts 5.67 -53.632 6.6 0Cara Munich III Weyermann Joe Walts 4.7 -86.21 15.141 0Simpsons Caramalt 13.6 L Joe Walts 5.18 -53.298 -2.7657 0Munich II Weyermann Kai 5.54 -35 0 0Munich I Weyermann Kai 5.44 32.307692 0 0

Page 35: brewingfunctions.yolasite.com  · Web viewBrewing Functions for Excel. Introduction . pHEst3.xlsb is a file containing several functions that should be useful to people wishing to

Munich Light Franco Belges 5.62 -37.5 0 0Vienna Weyermann 5.65 -32 0 0Cara Munich III Weyermann 4.92 -40 0 0Caramunich II Weyermann 4.71 49.494949 0 0Cara Munich I Weyermann 5.1 37.333333 0 0Cara Aroma Weyermann 4.48 60.983607 0 0Crystal 10 L Briess 5.38 -30 0 0Crystal 20L Briess 5.22 29.583333 0 0Crystal 40 L Briess 5.02 37.647059 0 0Crystal 60 L Briess 4.66 48.461538 0 0Crystal 90 L Briess 4.77 48.387097 0 0Crystal 120 L Briess 4.75 48.421053 0 0Crystal 150 L Briess 4.48 49.016393 0 0Roast Barley Briess 4.68 38.823529 0 0Black Patent Briess 4.62 41.481481 0 0Carafa III Weyerman 4.81 39.775281 0 0Carafa I Weyermann 4.71 42.424242 0 0Carafa I (sp) Weyermann 4.73 47.835052 0 0Biscuit 5.08 32.580645 0 0Sauermalz 3.43 138.85463 0 0Sauermalz Weyermann 3.44 158.49558 0 0DWC Cara Pils (measured years ago by AJ) 5.2 -23.23 -14.516 0Flaked Oats Riffe 6.21 -48.2 0 0