Better FG calculation from the refractometer reading. Now using the Petr Novotny formula.

Sat, 19 Sep 2020 21:25:11 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 19 Sep 2020 21:25:11 +0200
changeset 721
4d7394ced1c3
parent 720
b6a616372a26
child 722
c4457e10d968

Better FG calculation from the refractometer reading. Now using the Petr Novotny formula.

www/js/global.js file | annotate | diff | comparison | revisions
www/js/prod_edit.js file | annotate | diff | comparison | revisions
--- a/www/js/global.js	Fri Sep 18 21:28:45 2020 +0200
+++ b/www/js/global.js	Sat Sep 19 21:25:11 2020 +0200
@@ -1084,32 +1084,28 @@
 
 
 
-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) +
+function brix_to_fg(OPt, FBrix) {
+ // OPt = Original Plato
+ // FBrix = Refractometer reading.
+ // Brouwhulp
+ var FGbh = Round(1.0031 - 0.002318474 * OPt - 0.000007775 * (OPt * OPt) - 0.000000034 * Math.pow(OPt, 3) +
             0.00574 * (FBrix) + 0.00003344 * (FBrix * FBrix) + 0.000000086 * Math.pow(FBrix, 3), 4);
 
- // from http://seanterrill.com   FGoc = old cubic, FGnc = new cubic, FGnl = new linear
- var OBc = OBrix / my_brix_correction;
+ // from http://seanterrill.com   FGnc = new cubic
  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);
+ //console.log('Correction ' + my_brix_correction + ' OPt ' + OPt + ' FBrix ' + FBrix + ' FBc ' + FBc);
 
- // 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);
+ // New cubic by Sean Terrill.
+ var FGnc = Round(1 - 0.0044993 * (OPt) + 0.0117741 * (FBc) +
+            0.000275806 * (OPt * OPt) - 0.00127169 * (FBc * FBc) -
+            0.00000727999 * Math.pow(OPt, 3) + 0.0000632929 * Math.pow(FBc, 3), 4);
 
  // Petr Novotny, Zymurgy July/August 2017. Used by Brewers Friend.
- var FGbf = Round(1 + 0.006276 * FBc - 0.002349 * OBc, 4);
+ var FGbf = Round(1 + 0.006276 * FBc - 0.002349 * OPt, 4);
 
- console.log('brix_to_fg(' + Round(OBrix, 2) + ', ' + FBrix + ') FGbh:' + FGbh + ' FGoc:' + FGoc + ' FGnc:' + FGnc + ' FGnl:' + FGnl + ' FGbf:' + FGbf);
- return FGnc;
+ // The real battle is now between Brouwhulp and Petr Novotny.
+ console.log('brix_to_fg(' + Round(OPt, 2) + ', ' + FBrix + ') FGbh:' + FGbh + ' FGnc:' + FGnc + ' FGbf:' + FGbf);
+ return FGbf;
 }
 
 
--- a/www/js/prod_edit.js	Fri Sep 18 21:28:45 2020 +0200
+++ b/www/js/prod_edit.js	Sat Sep 19 21:25:11 2020 +0200
@@ -4329,7 +4329,7 @@
   $('#primary_end_brix').on('change', function(event) {
    var OBrix, FBrix, FG;
    if (dataRecord.brew_fermenter_sg >= 1.020) {
-    OBrix = sg_to_brix(dataRecord.brew_fermenter_sg);
+    OBrix = sg_to_plato(dataRecord.brew_fermenter_sg);
     FBrix = parseFloat(event.args.value);
     FG = brix_to_fg(OBrix, FBrix);
     if (FBrix > 0.05) {
@@ -4346,7 +4346,7 @@
   $('#secondary_end_brix').on('change', function(event) {
    var OBrix, FBrix, FG;
    if (dataRecord.brew_fermenter_sg >= 1.020) {
-    OBrix = sg_to_brix(dataRecord.brew_fermenter_sg);
+    OBrix = sg_to_plato(dataRecord.brew_fermenter_sg);
     FBrix = parseFloat(event.args.value);
     FG = brix_to_fg(OBrix, FBrix);
     if (FBrix > 0.05) {
@@ -4359,7 +4359,7 @@
   $('#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);
+    OBrix = sg_to_plato(dataRecord.brew_fermenter_sg);
     FBrix = parseFloat(event.args.value);
     FG = brix_to_fg(OBrix, FBrix);
     if (FBrix > 0.05) {

mercurial