Switched FG calculations from Brix to the new cubic method from http://seanterrill.com. This includes the brix correction factor and seems better then the Brouwhulp formula.

Wed, 04 Dec 2019 21:52:37 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 04 Dec 2019 21:52:37 +0100
changeset 560
850e82c1021d
parent 559
10cc2400b5d5
child 561
dc618b8a9552

Switched FG calculations from Brix to the new cubic method from http://seanterrill.com. This includes the brix correction factor and seems better then the Brouwhulp formula.

www/js/prod_edit.js file | annotate | diff | comparison | revisions
--- a/www/js/prod_edit.js	Tue Dec 03 13:36:24 2019 +0100
+++ b/www/js/prod_edit.js	Wed Dec 04 21:52:37 2019 +0100
@@ -4061,12 +4061,22 @@
    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);
-    //console.log("OBrix:"+OBrix+" FBrix:"+FBrix+" FG:"+FG);
+    // 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);
     if (FBrix > 0.05) {
-     $('#primary_end_sg').val(FG);
-     dataRecord.primary_end_sg = FG;
+     $('#primary_end_sg').val(FGnc);
+     dataRecord.primary_end_sg = FGnc;
     }
     calcFermentation();
    }
@@ -4082,10 +4092,18 @@
     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);
-    //console.log("OBrix:"+OBrix+" FBrix:"+FBrix+" FG:"+FG);
+    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);
     if (FBrix > 0.05) {
-     $('#secondary_end_sg').val(FG);
-     dataRecord.secondary_end_sg = FG;
+     $('#secondary_end_sg').val(FGnc);
+     dataRecord.secondary_end_sg = FGnc;
     }
     calcFermentation();
    }
@@ -4093,14 +4111,23 @@
   $('#final_brix').on('change', function(event) {
    var OBrix, FBrix, FG;
    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);
-   //console.log("OBrix:"+OBrix+" FBrix:"+FBrix+" FG:"+FG);
-   if (FBrix > 0.05) {
-     $('#fg').val(FG);
-     dataRecord.fg = FG;
+    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);
+    if (FBrix > 0.05) {
+     $('#fg').val(FGnc);
+     dataRecord.fg = FGnc;
     }
     calcFermentation();
    }

mercurial