# HG changeset patch # User Michiel Broek # Date 1575548501 -3600 # Node ID dc618b8a9552e6ea5424666bbcad39c2e547026b # Parent 850e82c1021dd655c2cf3b55b9bae73076cc4404 Refracto calculation for FG is now a global function using the New Cubic method. Fixed to typos in the prod_edit en rec_edit yeastData varialbles. diff -r 850e82c1021d -r dc618b8a9552 README.design --- a/README.design Wed Dec 04 21:52:37 2019 +0100 +++ b/README.design Thu Dec 05 13:21:41 2019 +0100 @@ -14,6 +14,8 @@ Bug: Metingen en berekeningen met afgelezen Brix waardes kloppen niet op het eind van de vergisting. Gaat vooral fout met de Saison. + NOOT: experimentele wijziging is toegevoegd op 5-dec-2019. New Cubic van seanterrill. + Eind SG na koken klopt niet als er suiker in de vergisting toegevoegd wordt. In de js code is dit est_og3 en niet est_og, maar est_og3 is niet beschikbaar in de php code. diff -r 850e82c1021d -r dc618b8a9552 www/js/global.js --- a/www/js/global.js Wed Dec 04 21:52:37 2019 +0100 +++ b/www/js/global.js Thu Dec 05 13:21:41 2019 +0100 @@ -1073,6 +1073,33 @@ +function brix_to_fg(OBrix, FBrix) { + // Brouwhulp, werkt zonder brix_correctie, waarom? + var FGbh = Round(1.0031 - 0.002318474 * OBrix - 0.000007775 * (OBrix * OBrix) - 0.000000034 * Math.pow(OBrix, 3) + + 0.00574 * (FBrix) + 0.00003344 * (FBrix * FBrix) + 0.000000086 * Math.pow(FBrix, 3), 4); + + // from http://seanterrill.com FGoc = old cubix, FGnc = new cubic, FGnl = new linear + var OBc = OBrix / my_brix_correction; + var FBc = FBrix / my_brix_correction; + + // Old Cubic, almost the same a BrouwHulp, different offset and with brix_correction. + var FGoc = Round(1.001843 - 0.002318474 * OBc - 0.000007775 * (OBc * OBc) - 0.000000034 * Math.pow(OBc, 3) + + 0.00574 * (FBc) + 0.00003344 * (FBc * FBc) + 0.000000086 * Math.pow(FBc, 3), 4); + + // New cubic. This looks the best to use. + var FGnc = Round(1 - 0.0044993 * (OBc) + 0.0117741 * (FBc) + + 0.000275806 * (OBc * OBc) - 0.00127169 * (FBc * FBc) - + 0.00000727999 * Math.pow(OBc, 3) + 0.0000632929 * Math.pow(FBc, 3), 4); + + // New linear, results are pretty much too high and way off for heavy beers. + var FGnl = Round(1 - 0.000856829 * OBc + 0.00349412 * FBc, 4); + + console.log('brix_to_fg(' + Round(OBrix, 2) + ', ' + FBrix + ') FGbh:' + FGbh + ' FGoc:' + FGoc + ' FGnc:' + FGnc + ' FGnl:' + FGnl); + return FGnc; +} + + + function estimate_sg(sugars, batch_size) { var plato, sg, i; diff -r 850e82c1021d -r dc618b8a9552 www/js/prod_edit.js --- a/www/js/prod_edit.js Wed Dec 04 21:52:37 2019 +0100 +++ b/www/js/prod_edit.js Thu Dec 05 13:21:41 2019 +0100 @@ -4061,22 +4061,10 @@ if (dataRecord.brew_fermenter_sg >= 1.020) { OBrix = sg_to_brix(dataRecord.brew_fermenter_sg); FBrix = parseFloat(event.args.value); - // Brouwhulp, werkt zonder brix_correctie, waarom? - FG = Round(1.0031 - 0.002318474 * OBrix - 0.000007775 * (OBrix * OBrix) - 0.000000034 * Math.pow(OBrix, 3) + - 0.00574 * (FBrix) + 0.00003344 * (FBrix * FBrix) + 0.000000086 * Math.pow(FBrix, 3), 4); - // from http://seanterrill.com FGoc = old cubix, FGnc = new cubic, FGnl = new linear - var FGoc = Round(1.001843 - 0.002318474 * (OBrix / my_brix_correction) - 0.000007775 * Math.pow(OBrix / my_brix_correction, 2) - - 0.000000034 * Math.pow(OBrix / my_brix_correction, 3) + - 0.00574 * (FBrix / my_brix_correction) + 0.00003344 * Math.pow(FBrix / my_brix_correction, 2) + - 0.000000086 * Math.pow(FBrix / my_brix_correction, 3), 4); - var FGnc = Round(1 - 0.0044993 * (OBrix / my_brix_correction) + 0.0117741 * (FBrix / my_brix_correction) + - 0.000275806 * Math.pow(OBrix / my_brix_correction, 2) - 0.00127169 * Math.pow(FBrix / my_brix_correction, 2) - - 0.00000727999 * Math.pow(OBrix / my_brix_correction, 3) + 0.0000632929 * Math.pow(FBrix / my_brix_correction, 3), 4); - var FGnl = Round(1 - 0.000856829 * (OBrix / my_brix_correction) + 0.00349412 * (FBrix / my_brix_correction), 4); - console.log("OBrix:" + OBrix + " FBrix:" + FBrix + " FG:" + FG + ' FGoc:' + FGoc + ' FGnc:' + FGnc + ' FGnl:' + FGnl); + FG = brix_to_fg(OBrix, FBrix); if (FBrix > 0.05) { - $('#primary_end_sg').val(FGnc); - dataRecord.primary_end_sg = FGnc; + $('#primary_end_sg').val(FG); + dataRecord.primary_end_sg = FG; } calcFermentation(); } @@ -4090,20 +4078,10 @@ if (dataRecord.brew_fermenter_sg >= 1.020) { OBrix = sg_to_brix(dataRecord.brew_fermenter_sg); FBrix = parseFloat(event.args.value); - FG = Round(1.0031 - 0.002318474 * OBrix - 0.000007775 * (OBrix * OBrix) - 0.000000034 * Math.pow(OBrix, 3) + - 0.00574 * (FBrix) + 0.00003344 * (FBrix * FBrix) + 0.000000086 * Math.pow(FBrix, 3), 4); - var FGoc = Round(1.001843 - 0.002318474 * (OBrix / my_brix_correction) - 0.000007775 * Math.pow(OBrix / my_brix_correction, 2) - - 0.000000034 * Math.pow(OBrix / my_brix_correction, 3) + - 0.00574 * (FBrix / my_brix_correction) + 0.00003344 * Math.pow(FBrix / my_brix_correction, 2) + - 0.000000086 * Math.pow(FBrix / my_brix_correction, 3), 4); - var FGnc = Round(1 - 0.0044993 * (OBrix / my_brix_correction) + 0.0117741 * (FBrix / my_brix_correction) + - 0.000275806 * Math.pow(OBrix / my_brix_correction, 2) - 0.00127169 * Math.pow(FBrix / my_brix_correction, 2) - - 0.00000727999 * Math.pow(OBrix / my_brix_correction, 3) + 0.0000632929 * Math.pow(FBrix / my_brix_correction, 3), 4); - var FGnl = Round(1 - 0.000856829 * (OBrix / my_brix_correction) + 0.00349412 * (FBrix / my_brix_correction), 4); - console.log("OBrix:" + OBrix + " FBrix:" + FBrix + " FG:" + FG + ' FGoc:' + FGoc + ' FGnc:' + FGnc + ' FGnl:' + FGnl); + FG = brix_to_fg(OBrix, FBrix); if (FBrix > 0.05) { - $('#secondary_end_sg').val(FGnc); - dataRecord.secondary_end_sg = FGnc; + $('#secondary_end_sg').val(FG); + dataRecord.secondary_end_sg = FG; } calcFermentation(); } @@ -4113,21 +4091,10 @@ if (dataRecord.brew_fermenter_sg >= 1.020) { OBrix = sg_to_brix(dataRecord.brew_fermenter_sg); FBrix = parseFloat(event.args.value); - FG = Round(1.0031 - 0.002318474 * OBrix - 0.000007775 * (OBrix * OBrix) - 0.000000034 * Math.pow(OBrix, 3) + - 0.00574 * (FBrix) + 0.00003344 * (FBrix * FBrix) + 0.000000086 * Math.pow(FBrix, 3), 4); - // from http://seanterrill.com FGoc = old cubix, FGnc = new cubic, FGnl = new linear - var FGoc = Round(1.001843 - 0.002318474 * (OBrix / my_brix_correction) - 0.000007775 * Math.pow(OBrix / my_brix_correction, 2) - - 0.000000034 * Math.pow(OBrix / my_brix_correction, 3) + - 0.00574 * (FBrix / my_brix_correction) + 0.00003344 * Math.pow(FBrix / my_brix_correction, 2) + - 0.000000086 * Math.pow(FBrix / my_brix_correction, 3), 4); - var FGnc = Round(1 - 0.0044993 * (OBrix / my_brix_correction) + 0.0117741 * (FBrix / my_brix_correction) + - 0.000275806 * Math.pow(OBrix / my_brix_correction, 2) - 0.00127169 * Math.pow(FBrix / my_brix_correction, 2) - - 0.00000727999 * Math.pow(OBrix / my_brix_correction, 3) + 0.0000632929 * Math.pow(FBrix / my_brix_correction, 3), 4); - var FGnl = Round(1 - 0.000856829 * (OBrix / my_brix_correction) + 0.00349412 * (FBrix / my_brix_correction), 4); - console.log("OBrix:" + OBrix + " FBrix:" + FBrix + " FG:" + FG + ' FGoc:' + FGoc + ' FGnc:' + FGnc + ' FGnl:' + FGnl); + FG = brix_to_fg(OBrix, FBrix); if (FBrix > 0.05) { - $('#fg').val(FGnc); - dataRecord.fg = FGnc; + $('#fg').val(FG); + dataRecord.fg = FG; } calcFermentation(); } @@ -5357,7 +5324,7 @@ yeastData.y_cells = datarecord.cells; yeastData.y_inventory = datarecord.inventory; yeastData.y_sta1 = datarecord.sta1; - yeastData,y_bacteria = datarecord.bacteria; + yeastData.y_bacteria = datarecord.bacteria; yeastData.y_harvest_top = datarecord.harvest_top; yeastData.y_harvest_time = datarecord.harvest_time; yeastData.y_pitch_temperature = datarecord.pitch_temperature; diff -r 850e82c1021d -r dc618b8a9552 www/js/rec_edit.js --- a/www/js/rec_edit.js Wed Dec 04 21:52:37 2019 +0100 +++ b/www/js/rec_edit.js Thu Dec 05 13:21:41 2019 +0100 @@ -3597,7 +3597,7 @@ yeastData.y_cells = datarecord.cells; yeastData.y_inventory = datarecord.inventory; yeastData.y_sta1 = datarecord.sta1; - yeastData,y_bacteria = datarecord.bacteria; + yeastData.y_bacteria = datarecord.bacteria; yeastData.y_harvest_top = datarecord.harvest_top; yeastData.y_harvest_time = datarecord.harvest_time; yeastData.y_pitch_temperature = datarecord.pitch_temperature;