• Please visit and share your knowledge at our sister communities:
  • If you have not, please join our official Homebrewing Facebook Group!

    Homebrewing Facebook Group

Bru'n Water Spreadsheet question

Homebrew Talk

Help Support Homebrew Talk:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Don't have the "resources" to afford Excel? This is a joke, right?

Sadly, its not a joke. Your white privilege is showing. Through my interactions with brewers around the world, I have been made aware of that fact that not everyone has the resources that I may have. It only takes a moment to do the math on someone's minimum (or less) wage and the realities of the cost of living in some places to see that. That luxury of going out to have those 10 beers in the pub is only a dream to some.
 
Sadly, its not a joke. Your white privilege is showing. Through my interactions with brewers around the world, I have been made aware of that fact that not everyone has the resources that I may have. It only takes a moment to do the math on someone's minimum (or less) wage and the realities of the cost of living in some places to see that. That luxury of going out to have those 10 beers in the pub is only a dream to some.

White privilege? Really Martin?

Let's be real blunt: brewing your own beer is not a cost savings endeavor. I think your intelligent and adept enough to know A.J. was talking about hobby brewers being able to afford Excel, not people below the poverty line in various parts of the world, even if they do brew.

I'd wager a guess that someone who is below the poverty line AND is brewing their own beer doesn't really give a hoot about pH estimates and the minutia we talk about on a regular basis.

I think you are combining two separate ideas here. I echo A.J.'s sentiments that if you have enough discretionary income to be able to brew your own beer in the first place, AND you are aware of and interested in manipulating all the levers at your disposal to make the best beer you can, then Excel is a drop in the bucket.

I think the distinction here is the difference between the American brewing hobbyist (who should have zero trouble procuring Excel) and those who brew more out
 
What we are after is a program that will allow us, given a water profile, to explore options for formulation of a grist depending on our requirements for a given brew. If we have the recipe, the target pH and the water characteristics then it is trivial to come up with an addition or subtraction of a source/sink for protons to hit that pH. You don't even need Newton for that. You can choose however you want to do it. Add an acid or base, adjust the amount of a particular malt, add another malt. I think what you may be missing is that the brewer wants to be a part of that. He wants to decide how that adjustment is to be made. That is the way in which a program will be used most of the time. In using it in that way, however, the brewer is, in making his choices, going to want to see the effect of a proposed change. Suppose he increases the sauermalz by a percent. How much does that swing the pH etc. Or he may be sitting down with a blank sheet of paper in front of him with the intention of brewing a "Continental Pilsner". He may want to use certain malts and have an idea as to what the percentage of the malts vis a vis one another should be. He also has an idea as to where the mash pH should be so he will want to see what his proposed recipe's pH is likely to be. Thus he wants quick and easy pH estimates that reflect his original choices and the consequences of his adjustments. What would be the effect on pH of an extra 5% caramel malt? Can that be made up for with a little lactic acid or sauermalz. Newton - Raphson is ideal for this problem and converges in a couple of steps.

Now someone intent on authenticity may decide that he wants to go into the grist formulation process with a water that closely resembles Pilsen's. This is, IMO, kind of silly but someone may want to do it. Thus he may want to know how much DI water to blend with his tap water and how much of certain available salts and, if he wants a particular pH, acids and bases he should add to get that water's ion profile as close as possible to some target he has. That is entirely doable by Solver and I expect by Moore-Penrose Newton- Raphson but I won't really know until I do it (or try to do it). I've been using Solver to do this problem for years.
.
.
.
Now I don't know much about meta heuristic algorithms and that's for sure but I really don't see how they are going to help us here. The space to be searched just isn't that large. I have thought of using simulated annealing on this problem. That has never failed to find a solution for me (but then neither has Moore-Penrose Newton). But I'm going to try Newton first.

Not so sure. Those algorithms grope for a solution and use lots and lots and lots of CPU. They too have definite limitations and don't evidently scale very well

The problem is the term "a solution". There are *many* different solutions to the question "how much of which salts/acids can be used to hit the target water profile and pH". Perhaps one could artificially limit the output by having the user select which salts/acids they have, but even then there would be multiple solutions.

The output should be a list of solutions that the user can select from. Newton-Raphson, Moore-Penrose, Built-in Excel Solver don't live up to this expectation.
 
If you have Excel you should be able to kluge up the Solver solution. Put the concentration of the ions you want into a set of cells. Into another set of cells put the difference between what you want and what Brun gives you. Calculate the sum of the squares of these differences. Now ask the Solver to minimize that sum of squares by changing the salt entry cells.

I don't believe one can execute Solver on Martin's spreadsheet because it is locked. Even if you could, you would only arrive at one solution of a multi-faceted answer, which may very well be good enough for most (i.e. they may accept that answer) save the most discerning among us.
 
Incorporating such a feature even though some can't use it is beneficial for several reasons:

1.) It establishes a precedent
2.) It demonstrates the feasibility of such advanced features
3.) It paves the way for better algorithms in the future
4.) It saves the end user time
5.) It raises the perceived value of the spreadsheet
6.) It's just plain damn cool

I can't see a reason not to implement it but it's not my spreadsheet.

(P.S. Well there is one reason, and that's the fact that it might be a lot of work to implement, might break certain things in the spreadsheet, etc... but welcome to the wonderful world of "software").
 
But you are still kidding yourself. I assure you that there are plenty of brewers that have a hard time justifying a $100+ software purchase.

Sean Connery's character Jimmy Malone states to Costner's Eliot Ness in "The Untouchables", "What are you willing to do?" when Ness displays the required passion for justice without the stomach for the means in which to enact it.

Hobby brewing is not cheap. Given what some people spend on hops, extract, sugars, equipment, etc. to make a single batch of 5 gallons of beer, not being willing to part with $150 for a software as infinitely malleable and vital for brewing calculations such as Excel is at best comical and at worst negligent (heavy on the hyberbole of course).

If your brewing budget is on such a shoestring that you are unwilling to set yourself up with the tools to be most successful (not just Excel but all manner of Software choices) then you may not be as committed to quality as you say you are (The Royal You/We). In that case, why not just purchase commercial beer that is made to a higher standard and is cheaper? Again, I'm talking about hobby brewers here. We are very much a community comprised, by default, of people who can afford the luxury of brewing their own beer.

It's really a question of reasonable and intelligent allocation of hobby brewing funds. People seem more than willing to part with hard earned brewing budget funds for equipment and ingredients they don't need than for software solutions that can help them infinitely more.

I think of the parallel in the guitar playing community where people are constantly wasting money on this pedal or that pedal when practicing, listening, and absorbing the basics of the instrument typically trump all.
 
The problem is the term "a solution". There are *many* different solutions to the question "how much of which salts/acids can be used to hit the target water profile and pH".
Of course. We are trying to match perhaps 7 ion's concentrations and have perhaps 10 salts, acids and bases we can use. The problem is underdetermined and there are, therefore, an infinite number of solutions.

Perhaps one could artificially limit the output by having the user select which salts/acids they have,
I think it's pretty clear that a user would want to limit the salts the program can choose from to the ones he has in hand. We also find from use of the Solver that broadening the spectrum of input salts/acids/bases given to the program may improve the quality of the match. As an example if the guy wants extra sulfate but doesn't want any more calcium or magnesium he can allow the use of sulfuric acid but that will, of course, change the pH so that the program will also call for some sodium hdroxide, potassium hydroxide or sodium carbonate to compensate for that. He could, of course, just give the program sodium hydroxide or carbonate to work with and get the same result but we want to give him the option to make those choices.

but even then there would be multiple solutions.
If he restricts the number of salts to less than or equal to the number of ions he is trying to match then there is one solution only. But in the general case he should be allowed to select how many he wants to use and there will then be cases where there will be an infinite number of solutions.

The output should be a list of solutions that the user can select from.
Why? I'm missing something here. All he really cares about is getting a solution that gives him the best match to his desired profile given the salts/acids/bases he has available.

Newton-Raphson, Moore-Penrose, Built-in Excel Solver don't live up to this expectation.
The Solver certainly lets him choose which ions he wants to match and which salts/acids/bases he wants to use with any restrictions he wants to place on the amount, for example, of any given salt. It also allows him to weight the ions under consideration in any relative importance he chooses, to chose and arithmetic or geometric error criterion etc. What more could he want? One of the challenges will be making all those choices available to the user more conveniently than the Solver does. My focus right now is on the algorithm with the intention of making a function or subroutine available that will accept an desired water properties list, a list of weights to be assigneded to each of those, a list of chosen additions, a geometric/algebraic flag and a desired pH and return a list of addition quantities. It them becomes the task of a real programmer to interface that to a pretty, functional spreadsheet presentation.

Newto-Raphson and Moore Penrose are parts of the same algorithm - not distinct algorithms. In Newton's method we find how far off we are from a target, find the slope of the target function with respect to the parameter being optimized over, divide the error by the slope and correct the value of the parameter being optimized over by that ratio. That works fine where the error function is Q and the parameter is being estimated is the single parameter pH. Here we have multiple parameters being optimized and thus the slope isn't a simple derivative - it is a matrix of derivatives. You don't divide by a matrix, you multiply by its inverse and only square matrices have inverses. So we have to use a 'pseudo inverse'. MPP (Moore-Penrose Psuedo Inverse) is one of a class having the property that when the problem is overdetermined and the equations inconsistent it picks the best solution. When the problem is undetermined as it is here, it picks the best solution with the minimum norm. Thus it does exactly what we need here.

I was able to use MPP to solve the malt coefficient parameter estimation problem because while the relevant matrix A doesn't have an inverse (it is tall - i.e. not square) A_transpose*A does. Thus Excels built in matrix inversion routine can be used to find MPP. In the ion matching problem A_transpose*A, while square, doesn't have an inverse and so MPP requires SVD to compute. Excel doesn't have SVD capability. It is available, free, as a plug in but I don't realistically expect that even the more advanced brewers would be willing to accept my add in and the Real Statistics add in. The alternative would be for me to haul out Numerical Recipes and port the FORTRAN to VBA. Doable but it's a fairly lengthy piece of code.
 
AJDelange said:
Why? I'm missing something here. All he really cares about is getting a solution that gives him the best match to his desired profile given the salts/acids/bases he has available.

Maybe there's a better match with salts he doesn't have but would/could easily obtain if he knew he could use them/they were beneficial.

Many combinations of salts can result in the same profile. Same thing with acids/bases. Go all baking soda or limit Na by adding in pickling lime, get some Mg from MgCl and some from MgSO4, get some Cl from NaCl and some from CaCl, etc....

Making software that helps the end user by making suggestions *is the purpose of software*. Making software that gives a one off answer and labels it as the only answer not only limits the end user but makes the software appear "dumb".

Imagine such software were in place now, users would come to the "Brew Science" forum, post a screen shot of the list of amounts of salts/acids/bases" and ask "I have the ingredients for #1 but would like #3 what benefit does it have?" As opposed to mumbling conversations about mEq/L of some inane proton not balancing. This would relegate knowledge to a select few but such is the current state of affairs.
 
Maybe there's a better match with salts he doesn't have but would/could easily obtain if he knew he could use them/they were beneficial.
The software I use now has all the salts that could potentially be of benefit and the ability to add any that one might conceivably think of using. Are you suggesting that there are other salts we don't know about?

Many combinations of salts can result in the same profile. Same thing with acids/bases. Go all baking soda or limit Na by adding in pickling lime, get some Mg from MgCl and some from MgSO4, get some Cl from NaCl and some from CaCl, etc....
I covered that in some detail in No. 38.

Making software that helps the end user by making suggestions *is the purpose of software*.
Hardly. Software controls my coffee pot, transforms signals from my depth sounder's transducer to images of fish (though precious few recently) on a screen, translates range measurements from GPS satellites into position data and plots it on a current map, makes sure that map is up to date, compresses audio, video and image data, manages packet switches, steers airplanes, prevents spam callers from ringing my phone, computes the amounts of salts I choose to get an ion profile I want according to an optimality condition I choose, decompresses my blue rays, converts x-ray intensity measurements to CAT scan images, controls my 3D printer, sets the mixture in my car to optimum, transmits pressure reading from my cold room compressor to my cell phone, collects readings of temperature and pressure from my heat pump and sends it to a Web sight, sends me an e-mail if the generator runs, lets me know what my portfolio is worth, automatically sends my insurance payment to the company, converts beer absorption spectra into SRM and SDC data, tells me if someone opens the garage door, automatically records displays and calibrates my pH readings, routes the traces on printed circuit boards, turns the steam on and off automatically to hold the temperature in my HLT to a desired value and, obviously, I could go on. I can think of no software that I have encountered that would "make suggestions" nor would I have any use for such nor can I imagine any manifestation of such software for this particular application. Software is there to do things we can't do (invert a large singular matrix) or don't want to do (like turning my heat pump on as necessary to hold the water in the tank at the right temperature without short cycling the compressors...) and to give us the information we need to make informed decisions.

Making software that gives a one off answer...
Software of this sort models the various brewing components which models, it is presumed, predict well how the component responds to its environment. If you feed x mEq of acid to y mmol of bicarbonate some of it will convert to carbonic acid in a way reliably predicted by the Henderson-Hasselbalch equation. Any program that wants to match an ion profile has to be aware of that. There would be no value is a program that 'advises' one to use sodium bicarbonate rather than sodium carbonate because the brewer using the program wants to use sodium bicarbonate.


and labels it as the only answer not only limits the end user but makes the software appear "dumb".
But it is the answer - the only answer unless you change the input conditions. You seem to be missing the point that the user has all the flexibility he needs. I suspect you aren't reading what I am posting but with respect to this problem and the use of Solver to solve it he can choose salts, optimality criterion, ions to be matched, weighting to be applied, set limits for a salt or salt.


Imagine such software were in place now, users would come to the "Brew Science" forum, post a screen shot of the list of amounts of salts/acids/bases" and ask "I have the ingredients for #1 but would like #3 what benefit does it have?"
Well they can do that now, of course. Not using the current popular spread sheets which do a pretty miserable job of allowing one to set a profile in some cases because the profiles are flawed. And people do it. The answers they usually get are things like "you used an acid and a base. Those cancel each other out so don't use both" or 'You used calcium carbonate, that doesn't work because it doesn't dissolve. Try sodium carbonate". Are you suggesting that the software should do that? Well it does currently. I've seen at least one spreadsheet that caveats against the use of chalk. In the one I'm working on now if you have a mash with a negative proton deficit and try to zero that by adding sauermalz you will get a message box that says you can't do that.

As opposed to mumbling conversations about mEq/L of some inane proton not balancing.
The fact that you think mention of mEq and proton balance inane only indicates that you haven't a clue as to how mash prediction and water formulation work. Proton transfer is at the very heart of it. You cannot hope to write or really even comment on brewing software if you do not understand this concept.

This would relegate knowledge to a select few but such is the current state of affairs.
I remind you that this is the Brewing Science forum. We discuss brewing science here. While it is true that one can write software for brewing applications based purely on empirical observations robust software must depend on the science.
 
I'm not really arguing but rather pointing out that what you appear to be advocating doesn't seem to make much sense in the brewing application and that an AI type solution is not desirable or necessary. Also your comment about mEq seems to indicate that you don't really understand the problem at hand or how to move towards a solution to it based on the science which is what this forum is dedicated to.

I am here to clarify any of this if I can.
 
I'm not really arguing but rather pointing out that what you appear to be advocating doesn't seem to make much sense in the brewing application and that an AI type solution is not desirable or necessary.

Not suggesting an AI solution, rather a Genetic Algorithm.

Also your comment about mEq seems to indicate that you don't really understand the problem at hand or how to move towards a solution to it based on the science which is what this forum is dedicated to.

A little bit of sarcasm and malapropism is all.

I am here to clarify any of this if I can.

Strangely your presence is comforting.
 
Not suggesting an AI solution, rather a Genetic Algorithm.

Checked the article at the link. So this is another meta heuristic algorithm - Simulated Annealing with a different way of coming up with new states to try. These methods are designed for problems where, as the article says, you haven't a clue as to how to solve them. Like an aeroplane wing where each thousands of little areas of mesh interract with hundreds of others to result in overall lift and drag characterisics. Or the deign of a new antenna where each of hundreds of mesh elements interacts with all of the others to determine the current distribution and hence the far field radiation patterns. We try this shape, calculate the current distribution and radiation pattern, see how close it is to what we'd like and if it is better than a previous try accept it and if not reject it. In simulated annealing we reject randomly with the probability dependent on the annealing "temperature". Randomly perturb and iterate. In 'Genetic algorithms' we pick new states to try by producing 'children chromasomes'. Is this more efficient than annealing? Does it lead to better convergence? Does it use less CPU cycles? I don't know and don't really think it matters much because the point is that these algorithms have their application in solving problems that we don't have a clue how to solve otherwise (routing circuit boards, the traveling salesman problem). Matching a profile by using salt additions is not one of those problems! We know very well how to solve it. It is orders of magnitude less complex than any of the four examples I've given here. We could solve it with annealing or a genetic algorithm but why would we want to? Much simpler algorithms (well annealing is pretty simple so lets say much more efficient algorithms) work just as well or better than meta hueristic algorithms so why would we not use them?

I use a meta heuristic algorithm for problems I can't solve otherwise (what your article says they are for). I'm hardly desperate here - at least not yet.
 
The question is how many combinations will be discovered using simulated annealing vs. genetic.

As I've already pointed out, the greatest possible number of combinations (preferably all) need to be discovered to be successful.
 
Let's face it.. Beersmith generates an optimized combo of water salts to achieve a chosen profile in seconds.. It's not using excel. Granted, Beersmith has many flaws in this department, but if Brad can do it, I'm sure Martin can...

Frankly, I wish Brad and Martin would get software married and combine their powers into the perfect piece of love child software....
 
The question is how many combinations will be discovered using simulated annealing vs. genetic.
We aren't really interested in finding more than one solution but if we were we would probably be interested in the solution space, not particular solutions within it. The matrix that tells us how many moles of sodium and sulfate come from 1 mole of sodium sulfate etc. is a mapping between salt space and ion concentration space. As the problem is underdetermined in general, there are many (an infinite number actually) of points in the salt space that map to a single point (the point whose coordinates represent the desired ion concentrations or the point closest to it) in the ion space. Lets say for simplicity that the ion point maps to a line in salt space. A heuristic algorithm picks a starting point (annealing) or group of (genetic) starting points in salt space and maps them into ion space. Annealing then perturbs the starting point in salt space randomly, sees whether the new point is closer to the target or not in ion space, accepts the new point if it is and if it isn't rolls the dice again to decide whether to accept it anyway. A genetic algorithm picks the points that map closest to the target in ion space, discards the rest and then "breeds" (combines) the promising corresponding points in salt space in various ways in the hope that some of the 'children' will map closer to the target point in ion space. Of course we don't know where the target point is in ion space. But we know that it is at the bottom of a well and deduce that we have moved closer to it if the error metric (norm of the vector whose elements are the desired concentration of each ion minus the mapped concentration for that ion) is reduced. Either algorithm will eventually get close enough to the line in salt space that new annealing perturbations or that new children won't deliver further reduction in the error metric. Once that line is reached the algorithm will be terminated because all we care about is that we map to the best fit point in ion space. If we do care about the extent of the solution space in the salt domain we could allow either algorithm to keep running with the criterion for accepting a new perturbation or child being that the error metric does NOT increase. This would eventually map out the solution space. There are doubtless more intelligent means for mapping out the solution space than heuristic guessing such as computing the gradient and moving perpendicular to it.

As I've already pointed out, the greatest possible number of combinations (preferably all) need to be discovered to be successful.
No. Absolutely not. Once we are in the solution space we don't care about the other solutions in that space as they are no better than the first solution we have found. Once we have the sodium and sulfate concentrations we want why would we care that they are arrived at by adding sulfuric acid and lye as opposed to sodium sulfate? Perhaps because we don't have sodium sulfate. If that's the case we wouldn't make sodium sulfate available to the algorithm. If you want to put constraints on the solution you simply change your perturbation rules such that no new annealing point or child can use more than twice as much sodium sulfate as magnesium sulfate (for example if you only had a little sodium sulfate available but plenty of Epsom salts). Or you encode the constraint into the error metric by adding a penalty to it for having sodium sulfate at more than twice magnesium sulfate. Doing either of these things would shrink the size of the solution space but again, once you have found a solution in that space you are finished.

Now interestingly enough there is one criterion for the solutions that may be of interest: finding the one that uses less total salts than any of the others. Again this could be coded into the heuristic algorithm's error function (add the norm of the salts vector to it). But there is a better way that uses far, far, far less computing and that is MPP. MPP finds the solution that has the best rms error AND has the smallest salt vector norm.

You really need to understand this in order to appreciate why heuristic algorithms are not suitable for this problem. In the quote you indicate that we need to find as many solutions as possible, preferably all of them. Do you recognize that there are an infinite number of them? How is any one better than any other? What advantage(s) do you think a heuristic algorithm would confer? And at what cost? Can you support the idea that we need to find as many solutions as possible with any information relevant to the problem at hand?

I practiced engineering for many years and over the course of them encountered many prophets with solutions looking for problems. To be honest, this seems to be one of those cases.
 
Last edited:
Maybe there's a better match with salts he doesn't have but would/could easily obtain if he knew he could use them/they were beneficial.

Many combinations of salts can result in the same profile. Same thing with acids/bases. Go all baking soda or limit Na by adding in pickling lime, get some Mg from MgCl and some from MgSO4, get some Cl from NaCl and some from CaCl, etc....

Making software that helps the end user by making suggestions *is the purpose of software*. Making software that gives a one off answer and labels it as the only answer not only limits the end user but makes the software appear "dumb".

Imagine such software were in place now, users would come to the "Brew Science" forum, post a screen shot of the list of amounts of salts/acids/bases" and ask "I have the ingredients for #1 but would like #3 what benefit does it have?" As opposed to mumbling conversations about mEq/L of some inane proton not balancing. This would relegate knowledge to a select few but such is the current state of affairs.
Wow - I didn't mean to start something like this question ended up to be.

Back to my question....
I just used a different desired profile (brown/full - hopfully OK for the Yoopers Oatmeal Stout) and think I have it close enough now. I kept futzing with the numbers by hand. I spent way more time on this than I wanted though.
I should be good here now, right?

aYoopersfinal.JPG
 
It's hard to answer your question directly because water profiles are always and forever a matter of personal preference. For my oatmeal stout I add only calcium chloride, baking soda, and salt to RO water. Enough CaCl2 to hit ~50 ppm, enough baking soda to hit a targeted 5.50 mash pH, and then lastly enough NaCl to hit 60 ppm sodium.

Edit: I can't read your numbers clearly enough in the attached screenshot to see what analyticals you achieved, or what targeted mash pH you settled upon.
 
Last edited:
Wow - I didn't mean to start something like this question ended up to be.

Back to my question....
I just used a different desired profile (brown/full - hopfully OK for the Yoopers Oatmeal Stout) and think I have it close enough now. I kept futzing with the numbers by hand. I spent way more time on this than I wanted though.
I should be good here now, right?

View attachment 585711

You haven't started anything that wasn't present long before your question was asked.

Your water will be ok. It's best not to rely on those built in profiles, instead learn about what each mineral does and the level that's appropriate for the style. Then you can simply make your own profile on the fly. As discussed earlier, matching those profiles exactly doesn't add anything to the beer. Heck you could just put a teaspoon of CaCl and a teaspoon of Gypsum in your water w/ the baking soda and you most likely wouldn't tell the difference between that and your meticulously labored over salt additions.
 
We aren't really interested in finding more than one solution but if we were we would probably be interested in the solution space, not particular solutions within it. The matrix that tells us how many moles of sodium and sulfate come from 1 mole of sodium sulfate etc. is a mapping between salt space and ion concentration space. As the problem is underdetermined in general, there are many (an infinite number actually) of points in the salt space that map to a single point (the point whose coordinates represent the desired ion concentrations or the point closest to it) in the ion space. Lets say for simplicity that the ion point maps to a line in salt space. A heuristic algorithm picks a starting point (annealing) or group of (genetic) starting points in salt space and maps them into ion space. Annealing then perturbs the starting point in salt space randomly, sees whether the new point is closer to the target or not in ion space, accepts the new point if it is and if it isn't rolls the dice again to decide whether to accept it anyway. A genetic algorithm picks the points that map closest to the target in ion space, discards the rest and then "breeds" (combines) the promising corresponding points in salt space in various ways in the hope that some of the 'children' will map closer to the target point in ion space. Of course we don't know where the target point is in ion space. But we know that it is at the bottom of a well and deduce that we have moved closer to it if the error metric (norm of the vector whose elements are the desired concentration of each ion minus the mapped concentration for that ion) is reduced. Either algorithm will eventually get close enough to the line in salt space that new annealing perturbations or that new children won't deliver further reduction in the error metric. Once that line is reached the algorithm will be terminated because all we care about is that we map to the best fit point in ion space. If we do care about the extent of the solution space in the salt domain we could allow either algorithm to keep running with the criterion for accepting a new perturbation or child being that the error metric does NOT increase. This would eventually map out the solution space. There are doubtless more intelligent means for mapping out the solution space than heuristic guessing such as computing the gradient and moving perpendicular to it.

No. Absolutely not. Once we are in the solution space we don't care about the other solutions in that space as they are no better than the first solution we have found. Once we have the sodium and sulfate concentrations we want why would we care that they are arrived at by adding sulfuric acid and lye as opposed to sodium sulfate? Perhaps because we don't have sodium sulfate. If that's the case we wouldn't make sodium sulfate available to the algorithm. If you want to put constraints on the solution you simply change your perturbation rules such that no new annealing point or child can use more than twice as much sodium sulfate as magnesium sulfate (for example if you only had a little sodium sulfate available but plenty of Epsom salts). Or you encode the constraint into the error metric by adding a penalty to it for having sodium sulfate at more than twice magnesium sulfate. Doing either of these things would shrink the size of the solution space but again, once you have found a solution in that space you are finished.

Now interestingly enough there is one criterion for the solutions that may be of interest: finding the one that uses less total salts than any of the others. Again this could be coded into the heuristic algorithm's error function (add the norm of the salts vector to it). But there is a better way that uses far, far, far less computing and that is MPP. MPP finds the solution that has the best rms error AND has the smallest salt vector norm.

You really need to understand this in order to appreciate why heuristic algorithms are not suitable for this problem. In the quote you indicate that we need to find as many solutions as possible, preferably all of them. Do you recognize that there are an infinite number of them? How is any one better than any other? What advantage(s) do you think a heuristic algorithm would confer? And at what cost? Can you support the idea that we need to find as many solutions as possible with any information relevant to the problem at hand?

I practiced engineering for many years and over the course of them encountered many prophets with solutions looking for problems. To be honest, this seems to be one of those cases.

 
Now that's more like it. Clearly we want an agorithm that gives the right answer and there are lots of those. I this case any one of the right answers will do as none of the others give us a better match to the target profile. But what about on the salt side? The answer that uses the least amount of salt seems a reasonable one to select and MPP gives us that one automatically so it seems a reasonable choice. If we want to steer to a right answer that meets some other criterion we can do that too with MPP. It seems the obvious choice except that we need to implement SVD to use it. Doable but a PITA.
 
Now that's more like it. Clearly we want an agorithm that gives the right answer and there are lots of those. I this case any one of the right answers will do as none of the others give us a better match to the target profile. But what about on the salt side? The answer that uses the least amount of salt seems a reasonable one to select and MPP gives us that one automatically so it seems a reasonable choice. If we want to steer to a right answer that meets some other criterion we can do that too with MPP. It seems the obvious choice except that we need to implement SVD to use it. Doable but a PITA.

Are you talking about Maximum Power Point w/ singular value decomposition or some mutilated form of the image processing boundary finding MPP (minimum perimeter polygons)? I can't recall if SVD is discussed in Numerical Recipes (haven't referenced my copy for years).

I still think the user should be exposed to all of the right answers *if they so choose* and each of those answers should be labeled (least amount of salts) (closest match to target - RMS) etc...
 
Wow - I didn't mean to start something like this question ended up to be.

Back to my question....

As this is the Brewing Science thread you can expect that some aspects of Brewing Science may be raised in response to any post here. It's been noted that profiles really kind of a joke - especially the one's that come with first generation spreadsheets and calculators. A water profile consists of a list of ion concentrations. What the authors of the first gen spreadsheets didn't appreciate is that some of the ion concentrations depend on pH. Have you seen a profile that mentions pH? In Brun water Martin wanted, for each profile, a certain concentration of calcium, of magnesium etc. to, for example, match the water of the Isar.He realized that if he just specified those desired amounts there would be a positive ion imbalance that he would have to balance somehow. His solution to this was to balance with bicarbonate (which is indeed what the ions of the Isar are balanced by). So he threw in bicarbonate as necessary to balance each profile. In fiddling with salts to hit a profile one can then add sodium bicarbonate to supply that carbonate as long as the pH of the synthesis is 8.34, the pH at which 98% of the bicarbonate in sodium bicarbonate stays sodium bicarbonate. Thus all of the profiles in Brun are for pH 8.38. How can that be of help to use wanting to synthesize at pH 7 or mash pH?

I'm trying to figure out how to get minerals correct to the recipe for Yoopers Oatmeal Stout recipe. I doubled the recipe for a 11 gallon batch.

I entered Yoopers water numbers as a custom water profile. Before I add anything to the water, the pH is in the correct range. Whenever I add anything to the water, the pH number goes down and gets out of range. How can I correct this?
I'm afraid the answer is to use a better spreadsheet. Some things you add to water (acids, acid malts, blend water with low pH and appreciable alkalinity cause the pH to go down). Other things cause it to go up and still others (neutral salts) should make little if any change.

All of this is more or less mooted by the fact that profiles really aren't that important. Get rid of the alkalinity by whatever means you choose and get the stylistic ions (calcium, chloride, sulfate, sodium) into the ballpark for the style and you are in good shape. These can be tweaked, of course, to make even more pleasing beer. Thus profile matching isn't really that important to a brewer. But, as you may have gathered from some of the noise here, it belongs to a class of problems that is of great interest to engineers and scientists in many disciplines.
 
Last edited:
Are you talking about Maximum Power Point w/ singular value decomposition or some mutilated form of the image processing boundary finding MPP (minimum perimeter polygons)?
You are clearly not reading what I am posting. So why am I posting? Helps me think about this stuff much of which I haven't used in quite a while. Anyway MPP was introduced in No. 38 and mentioned in several other posts. It stands for Moore-Pensrose Pseudoinverse.

I can't recall if SVD is discussed in Numerical Recipes (haven't referenced my copy for years).
Further evidence you aren't reading what I am posting. Also from No. 38.

Excel doesn't have SVD capability. It is available, free, as a plug in but I don't realistically expect that even the more advanced brewers would be willing to accept my add in and the Real Statistics add in. The alternative would be for me to haul out Numerical Recipes and port the FORTRAN to VBA. Doable but it's a fairly lengthy piece of code.

I still think the user should be exposed to all of the right answers *if they so choose* and each of those answers should be labeled (least amount of salts) (closest match to target - RMS) etc...
Use some common sense! There are an infinite number of right answers none of which is any closer to the target match than any other. How will you present those to the user? Will you expose the user to the right answers that contain negative amounts of a salt? I guess I choose not to be exposed to such answers.
 
I will implement a Genetic Algorithm and you can implement Moore-Penrose PseudoInverse with Singular Value Decomposition.

May the best algorithm win.
 
His solution to this was to balance with bicarbonate (which is indeed what the ions of the Isar are balanced by). So he threw in bicarbonate as necessary to balance each profile. In fiddling with salts to hit a profile one can then add sodium bicarbonate to supply that carbonate as long as the pH of the synthesis is 8.34, the pH at which 98% of the bicarbonate in sodium bicarbonate stays sodium bicarbonate. Thus all of the profiles in Brun are for pH 8.38. How can that be of help to use wanting to synthesize at pH 7 or mash pH?

AJ if you wouldn't mind, could you rework the 'true' value of whatever ion(s) you feel is incorrect in that water profile in order to show just how wrong I was with my assumption?

Thanks!
 
Which water profile?

When I last looked at Brun water I totted up all the ions for several profiles and noted that they were balanced. But only at pH 8.4. If you consider any other pH the profiles aren't balanced any more. The charge on bicarbonate changes with pH. The charge on calcium magnesium, sodium, potassium, chloride and sulfate don't (well sulfate does but not enough to worry about). Thus the profiles only balance at 8.38 and as I recall there is a statement to that effect. So I don't know what I can correct. I can offer you a set of software functions that you could plug in to resolve this problem but I don't think you are interested.
 
Well, for example:
Ca:50 Mg:5 Na:27 SO4:50 Cl:60 HCO3:85

As you point out, its really only the alkalinity that varies and I've elected to represent alkalinity with only bicarbonate. The other ionic concentrations are consistent.

I believe I've mentioned this in the past; I use bicarb since its the species that predominantly exists in the range of typical mashing pH. That should be a reasonable assumption.

I guess the other non-concern I have with the bicarb not being accurate, is that alkalinity (bicarb) content is the component that I feel is the first to adjust in our quest for proper mashing pH.
 
Back
Top