Calculate mash attenuation time using log base 5 instead of a linear function.

Tue, 10 Jan 2023 16:56:21 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 10 Jan 2023 16:56:21 +0100
changeset 453
fc0c10d79539
parent 452
c4c5d02131be
child 454
2dfead81c72f

Calculate mash attenuation time using log base 5 instead of a linear function.

src/Utils.cpp file | annotate | diff | comparison | revisions
src/Utils.h file | annotate | diff | comparison | revisions
--- a/src/Utils.cpp	Mon Jan 09 17:03:19 2023 +0100
+++ b/src/Utils.cpp	Tue Jan 10 16:56:21 2023 +0100
@@ -282,9 +282,22 @@
 }
 
 
+/*
+ * Returns the log base b of y.
+ */
+double Utils::logbase(double y, int b)
+{
+    double lg;
+
+    lg = log10(y) / log10(b);
+    return lg;
+}
+
+
 double Utils::estimate_fg(double psugar, double pcara, double wgratio, double mashtime, double mashtemp, double svg, double og, bool sta1)
 {
     double BD;
+    double att_mashtime;
     double att_mashtemp;
 
     if (psugar > 40)
@@ -305,8 +318,6 @@
     }
     if (svg < 30)
 	svg = 77;
-    if (mashtime > 240)
-	mashtime = 240;
 
     /*
      * Original from brouwhulp:
@@ -322,6 +333,7 @@
     double top_mashtemp = 66.11;	/* Highest fermentable at 151 degrees fahrenheit */
     /*
      * Derived from Karl Troester's data and Matt Kahn.
+     * Original was just: -0.00684 * mashtemp
      */
     if (mashtemp > top_mashtemp) {
 	/* Above optimum mash temperature decrease attenuation */
@@ -331,7 +343,15 @@
         att_mashtemp = -0.00684 * (top_mashtemp + (top_mashtemp - mashtemp) / 4);
     }
 
-    double AttBeer = 0.00825 * svg + 0.00817 * BD + att_mashtemp + 0.00026 * mashtime - 0.00356 * pcara + 0.00553 * psugar;
+    /*
+     * Reference is set at 60 minutes equals old formula
+     * Use log base 5 to create a good realistic response.
+     * With mashtime < 12 minutes, the result will be negative, good.
+     */
+    att_mashtime = logbase(mashtime / 12, 5) * 0.0156;
+    //qDebug() << "estimate_fg temp" << att_mashtemp << "time" << att_mashtime;
+
+    double AttBeer = 0.00825 * svg + 0.00817 * BD + att_mashtemp + att_mashtime - 0.00356 * pcara + 0.00553 * psugar;
     AttBeer += (sta1) ? 0.597:0.547;
     qDebug() << "estimate_fg(" << psugar << pcara << BD << mashtime << mashtemp << svg << og << sta1 << ") AttBeer:" << AttBeer;
     return round((1 + (1 - AttBeer) * (og -1)) * 10000) / 10000;
--- a/src/Utils.h	Mon Jan 09 17:03:19 2023 +0100
+++ b/src/Utils.h	Tue Jan 10 16:56:21 2023 +0100
@@ -29,6 +29,14 @@
     double estimate_sg(double sugars, double batch_size);
 
     /**
+     * @brief Return log with custom base.
+     * @param y The input value.
+     * @param b The base to use.
+     * @return The log result.
+     */
+    double logbase(double y, int b);
+
+    /**
      * @brief Predict FG using recipe data.
      * @param psugar Percentage sugar in the wort.
      * @param pcara Percentage cara/crystal malts in the wort.

mercurial