And your contribution to this project would be...?....Of course these things require everyone to put aside their pride ("my" spreadsheet, "my" algorithm) and place effort and energy into the construction of the library.
And your contribution to this project would be...?....Of course these things require everyone to put aside their pride ("my" spreadsheet, "my" algorithm) and place effort and energy into the construction of the library.
And your contribution to this project would be...?
It does not use the Solver to determine what the mash pH estimate is or how much lactic acid is needed to hit pH 5.4 with a particular grain bill and water parameters. But it still can be used if, for example you want to hit a particular pH in a grain bill in which crystal malt is 10 percent of the total and sauermalz no more than 3%.But does it still use 'Solver'?
That is correct.AJ is programming VBA Functions.
It does not use Solver to solve the unconstrained problems of finding mash pH and the amounts of acid or base to add to realize a given pH. As such it will blithely estimate a mash pH of -7 if the math drives it that way. If you try to add acid to a recipe that is already acidic it won't let you and will admonish you to add base instead. Nut please remember that I am, at this point, only playing around with new toys. The Solver can and should be used to Solve, for example, constrained problems (e.g. want no more than x% sauermalz).It does not use solver.
Another question with VBA is security. At one time Microsoft removed it from Excel because of security concerns. One can still save spreadsheets in formats that will not run macros.The only question I have is if the inclusion of VBA code into Excel makes it less compatible with a wide array of computing platforms.
It can be used in place of the Solver for certain types of problems like the one of finding mash pH. Yes, Q is a non linear function of pH but it is a monotonic one so that there is only a single root. This is ideal for Newton. Other classes of problems it cannot do and so is not a substitute for Solver. Solver can handle constrained problems and multidimensional ones. Newton can handle multidimensional ones too (e.g. finding the set of salt additions that best match and ion profile) but I can't see doing those in Excel (other than with Solver) because it cannot, AFAIK, invert a non square matrix.Newton-Raphson is an algorithm that can be used in place of solver.
Numerical Recipes in FORTRAN is probably the most useful book I ever owned but one hardly needs anything in it for this application. Sure it's got Newton Raphson and Root Bisection but these are trivial algorithms compared to much of what's in that book. For example the code for finding mash pH isThe book "Numerical Recipes in C" contains implementations useful in the context given in this thread. (or Fortran)
It would be best if a proper software library was coded (with classes, types, structures, functions etc...) to represent the chemical reactions taking place (proton surfeit/defecit) and the water calculations (dilution, combination, etc).
It's not on my website. There is one there that is so primitive I ginned it up while waiting for my turn to speak at an MBAA meeting. But you can use it to get answers using the Solver. This stuff I'm posting about today was cooked up today so it isn't exactly time tested.It seems Mr. Delange has a spreadsheet on his website and several posts with these algorithms on this forum and his website which could be used to implement such software.
As he 'liked' the post he quoted I don't think he was being snarky here. Just asking what part the poster might be willing to take in this endeavor.He discussed on topic. That is enough.
Maybe for you it is but I'm interested enough to find out more.He discussed on topic. That is enough.
Maybe for you it is but I'm interested enough to find out more.
I don’t mind the windows and excel combination, but then again I have 3 windows laptops that all have excel so I might be biased.
Maybe this could be something developed platform agnostic.... say html5 and java script ?
The question is: on who's time and dime? Excel is convenient for me because:
a.) I have it
b.) I can work quickly in it so it doesn't take me a ton of time
You start talking about TRUE coding, doing web-based stuff, etc. and:
a.) My eyes glaze over
b.) It would take up too much of my time, personally
@ajdelange VBA code compiled into a Visual Studio 6.0 .Dll file can be called from worksheet cells saved as an .xlsx format. No macro or VBA code required by the worksheet.That is correct.
I have experience implementing just what you describe. As long as the spreadsheet doesn't use VBA or macros.I don’t mind the windows and excel combination, but then again I have 3 windows laptops that all have excel so I might be biased.
Maybe this could be something developed platform agnostic.... say html5 and java script ?
When I try to compile your functions I get an 'Sub or Function Not Defined' error on the CalcQ(pH0) call.
Thank you @ajdelange for this amazing and much needed work. I can't wait to put it to use!I think this is ready for the general user to play with. It's heavily commented so you should be able to figure out how to use it pretty quickly. Are there problems with it? There probably are. It's only a few hours old at this posting. But if anyone wants to give it a shot just drop me a PM with and e-mail address.
@ajdelange you and I share a passion for brewing water chemistry and now visual basic coding too. I corrected a small typo in the lactic acid code to eliminate a compile error. I look forward to spending most of my day getting acquainted with your voltmeter.Keep in mind that it started out as a teaching/diagnostic tool and it can still teach you a lot though in its current form all the heavy lifting is hidden in the macros (which, to my surprise, only total 365 lines of code, including white space).
@ajdelange you and I share a passion for brewing water chemistry and now visual basic coding too. I corrected a small typo in the lactic acid code to eliminate a compile error. I look forward to spending most of my day getting acquainted with your voltmeter.
@RPIScotty agreed. There is a lot going on here and much to learn. Understanding the concepts of all is where I'm at now.For cracking the nut on the concepts, I would use A.J.’s original solver based troubleshooter/voltmeter.
For implementing into a program or spreadsheet, this new sheet is the one to use.
They do the same thing but the science behind what’s going on is much more explicit in the original.
@RPIScotty agreed. There is a lot going on here and much to learn. Understanding the concepts of all is where I'm at now.
@ajdelange I'm in the process of compiling my cell formulas and VBA code into a .Dll library. The library is then referenced as an Excel Add-in and can be called from any version of Excel. The compiled native Windows byte code is very fast and its functions can be entered into cells or called from VBA. You may find this approach interesting.Late breaking news: Getting rid of my antiquated version of Excel and replacing it with 2016 (it turned out I had 2 more licenses) makes Sheet1.Range("A1").Value = Sheet2.Range("B7").Value work and I haven't had the problem with first execution after compile crash the thing. So stand by.