Removed Garetz and Rager IBU calculations, we will only use Tinseth

Thu, 07 Jul 2022 14:17:53 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 07 Jul 2022 14:17:53 +0200
changeset 339
2f3cfb983fcc
parent 338
473479de8c5b
child 340
b9af88bfe972

Removed Garetz and Rager IBU calculations, we will only use Tinseth

src/EditProductExport.cpp file | annotate | diff | comparison | revisions
src/EditRecipeExport.cpp file | annotate | diff | comparison | revisions
src/Utils.cpp file | annotate | diff | comparison | revisions
src/Utils.h file | annotate | diff | comparison | revisions
src/global.cpp file | annotate | diff | comparison | revisions
--- a/src/EditProductExport.cpp	Thu Jul 07 09:54:42 2022 +0200
+++ b/src/EditProductExport.cpp	Thu Jul 07 14:17:53 2022 +0200
@@ -78,7 +78,7 @@
     }
     if (product->est_ibu > 0) {
 	xmlWriter->writeTextElement("EST_IBU", QString::number(product->est_ibu, 'f', 1));
-	xmlWriter->writeTextElement("IBU_METHOD", g_ibu_method[product->ibu_method]);
+	xmlWriter->writeTextElement("IBU_METHOD", g_ibu_method[0]);	// Only Tinseth
     }
     xmlWriter->writeTextElement("BMS_COOLING_TO", QString::number(product->brew_cooling_to, 'f', 1));
 
--- a/src/EditRecipeExport.cpp	Thu Jul 07 09:54:42 2022 +0200
+++ b/src/EditRecipeExport.cpp	Thu Jul 07 14:17:53 2022 +0200
@@ -72,7 +72,7 @@
     }
     if (recipe->est_ibu > 0) {
 	xmlWriter->writeTextElement("EST_IBU", QString::number(recipe->est_ibu, 'f', 1));
-	xmlWriter->writeTextElement("IBU_METHOD", g_ibu_method[recipe->ibu_method]);
+	xmlWriter->writeTextElement("IBU_METHOD", g_ibu_method[0]);	// Only Tinseth
     }
 
     xmlWriter->writeStartElement("STYLE");
--- a/src/Utils.cpp	Thu Jul 07 09:54:42 2022 +0200
+++ b/src/Utils.cpp	Thu Jul 07 14:17:53 2022 +0200
@@ -379,48 +379,33 @@
  * Formula is from the 'Mash Made Easy' spreadsheet.
  * https://mashmadeeasy.yolasite.com/
  * https://www.homebrewtalk.com/threads/a-rather-simplified-whirlpool-hop-ibu-computation-method.701093/
+ *
+ * Source of the formula Mark G. Malowicki.
  */
 double Utils::IBU_reduction(double Tc)
 {
-    return (2.39 * pow(10, 11) * pow(2.71828182846, - (9773 / (Tc + Kelvin))) ) * 1/1.009231744;
+    /*
+     * Original formula plus a small correction factor.
+     */
+    return (2.39 * pow(10, 11) * exp(-(9773 / (Tc + Kelvin))) ) * 1/1.009231743647;
 }
 
 
-double Utils::boilIBU(int Form, double SG, double Volume, double Amount, double Time, double Alpha, int Method)
+double Utils::TinsethIBU(double SG, double Volume, double Amount, double Time, double Alpha)
 {
-    double	ibu = 0.0, sgfactor, boilfactor;
-
     double alpha = Alpha / 100.0;
     double mass = Amount * 1000.0;
 
-    if (Method == 0) { // Tinseth
-        /* http://realbeer.com/hops/research.html */
-        double AddedAlphaAcids = (alpha * mass * 1000) / Volume;
-        double Bigness_factor = 1.65 * pow(0.000125, SG - 1);
-        double BoilTime_factor = ((1 - exp(-0.04 * Time)) / 4.15);
-        ibu = Bigness_factor * BoilTime_factor * AddedAlphaAcids;
-    }
-    if (Method == 2) { // Daniels
-        if (Form == 2) // Leaf
-            boilfactor = -(0.0041 * Time * Time) + (0.6162 * Time) + 1.5779;
-        else
-            boilfactor = -(0.0051 * Time * Time) + (0.7835 * Time) + 1.9348;
-        if (SG < 1.050)
-            sgfactor = 0;
-        else
-            sgfactor = ((SG * 1000) - 1050) / 200;
-        ibu = (mass * (alpha * 100) * boilfactor * 0.1) / (Volume * (1 + sgfactor));
-    }
-    if (Method == 1) { // Rager
-        boilfactor = 18.11 + 13.86 * tanh((Time * 31.32) / 18.27);
-        if (SG < 1.050)
-            sgfactor = 0;
-        else
-            sgfactor = ((SG * 1000) - 1050) / 200;
-        ibu = (mass * (alpha * 100) * boilfactor * 0.1) / (Volume * (1 + sgfactor));
-    }
+    /*
+     * Basic Tinseth formula.
+     * http://realbeer.com/hops/research.html
+     */
+    double AddedAlphaAcids = (alpha * mass * 1000) / Volume;
+    double Bigness_factor = 1.65 * pow(0.000125, SG - 1);
+    double BoilTime_factor = ((1 - exp(-0.04 * Time)) / 4.15);
+    double ibu = Bigness_factor * BoilTime_factor * AddedAlphaAcids;
 
-    //qDebug() << "boilIBU" << Form << SG << Volume << Amount << Time << Alpha << Method << "IBU:" << ibu;
+    qDebug() << "boilIBU" << SG << Volume << Amount << Time << Alpha << "IBU:" << ibu;
     return ibu;
 }
 
@@ -428,6 +413,8 @@
 double Utils::toIBU(int Use, int Form, double SG, double Volume, double Amount, double Boiltime, double Alpha,
 		    int Method, double Whirlpool9, double Whirlpool7, double Whirlpool6, double Fulltime)
 {
+    double loss_boiltemp = 1.0;		/* Loss due to the lower boil temperature at higher altitude.	*/
+
     double ibu = 0.0, whirlibus = 0.0;
     double alpha = Alpha / 100.0;
     double mass = Amount * 1000.0;
@@ -477,7 +464,7 @@
      * IBU's from hops during Mash, FWH and boil.
      */
     if ((Use == HOP_USEAT_MASH) || (Use == HOP_USEAT_FWH) || (Use == HOP_USEAT_BOIL)) {
-	ibu = boilIBU(Form, SG, Volume, Amount, Fulltime, Alpha, Method);
+	ibu = TinsethIBU(SG, Volume, Amount, Fulltime, Alpha);
 	/*
 	 * Corrections for Mash and FWH
 	 */
@@ -502,8 +489,12 @@
 	} else if (Form == HOP_FORMS_EXTRACT) {
 	    // Nothing for now.
 	}
-//	ibu *= IBU_reduction(boilPoint());
-//	qDebug() << "ibu" << ibu << IBU_reduction(boilPoint());
+
+	if (Method > 0) {
+	    loss_boiltemp = IBU_reduction(boilPoint());
+	    ibu *= loss_boiltemp;
+	    qDebug() << "ibu" << ibu << "loss_boiltemp" << loss_boiltemp;
+	}
 
 //    } else if (Use == HOP_USEAT_AROMA) {
 	/*
@@ -515,7 +506,6 @@
 //	qDebug() << "whirlibus" <<  whirlibus << Use;
     }
 
-
     return round((ibu + whirlibus) * 100.0) / 100.0;
 }
 
--- a/src/Utils.h	Thu Jul 07 09:54:42 2022 +0200
+++ b/src/Utils.h	Thu Jul 07 14:17:53 2022 +0200
@@ -54,18 +54,15 @@
     double IBU_reduction(double Tc);
 
     /**
-     * @brief Calculate IBU's of a hop at 100°C.
-     * @param Use HOP_USEAT_MASH HOP_USEAT_FWH HOP_USEAT_BOIL, all others are ignored.
-     * @param Form HOP_FORMS_PELLET HOP_FORMS_PLUG HOP_FORMS_LEAF HOP_FORMS_LEAF_WET HOP_FORMS_CRYO HOP_FORMS_EXTRACT
+     * @brief Calculate IBU's of a hop at 100°C using the Tinseth formula.
      * @param SG the density
      * @param Volume in liters
      * @param Amount in kilograms
      * @param Time in minutes
      * @param Alpha in procent
-     * @param Method, 0 = Tinseth, 1 = Rager, 2 = Daniels
      * @return The calculated IBU's
      */
-    double boilIBU(int Form, double SG, double Volume, double Amount, double Time, double Alpha, int Method);
+    double TinsethIBU(double SG, double Volume, double Amount, double Time, double Alpha);
 
     /**
      * @brief Calculate IBU's of a hop during the whole production process.
@@ -76,7 +73,7 @@
      * @param Amount in kilograms
      * @param Boiltime in minutes
      * @param Alpha in procent
-     * @param Method, 0 = Tinseth, 1 = Rager, 2 = Daniels
+     * @param Method, 0 = Tinseth, 1 = Tinseth++ (+flamout, +whirlpool etc).
      * @param Whirlpool9 time in whirlpool above 80°C or zero.
      * @param Whirlpool7 time in whirlpool between 72°C and 77°C.
      * @param Whirlpool6 time in whirlpool between 60°C amd 66°C.
--- a/src/global.cpp	Thu Jul 07 09:54:42 2022 +0200
+++ b/src/global.cpp	Thu Jul 07 14:17:53 2022 +0200
@@ -66,8 +66,8 @@
 
 const char * g_ibu_method[3] = {
     "Tinseth",
-    "Rager",
-    "Daniels"
+    "Tinseth++",
+    "N/A"
 };
 
 const char * const g_fermentable_types[5] = {

mercurial