Fixed 0 IBU for First Wort Hop or Mashhop is used.

Sun, 15 May 2022 11:27:06 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 15 May 2022 11:27:06 +0200
changeset 208
615afedbcd25
parent 207
3b164a0aea90
child 209
19c50b1f58d3

Fixed 0 IBU for First Wort Hop or Mashhop is used.

src/EditProductTab4.cpp file | annotate | diff | comparison | revisions
src/EditRecipeTab3.cpp file | annotate | diff | comparison | revisions
src/PrinterDialog.cpp file | annotate | diff | comparison | revisions
src/Utils.cpp file | annotate | diff | comparison | revisions
src/Utils.h file | annotate | diff | comparison | revisions
--- a/src/EditProductTab4.cpp	Sun May 15 09:57:32 2022 +0200
+++ b/src/EditProductTab4.cpp	Sun May 15 11:27:06 2022 +0200
@@ -96,8 +96,9 @@
 	item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
         ui->hopsTable->setItem(i, 6, item);
 
-	double ibu = Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, product->batch_size, product->hops.at(i).h_amount,
-	                   product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method, 0, product->hops.at(i).h_time, 0);
+	double ibu = Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, product->batch_size,
+			   product->hops.at(i).h_amount, product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method,
+			   0, product->hops.at(i).h_time, 0, product->boil_time);
 	item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
         item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
         ui->hopsTable->setItem(i, 7, item);
@@ -198,11 +199,11 @@
 	ibus += Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg,
 			   product->batch_size, product->hops.at(i).h_amount,
                            product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method,
-			   product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6);
+			   product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time);
 	ferm_ibus += Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg,
 			   product->brew_fermenter_volume + product->brew_fermenter_tcloss, product->hops.at(i).h_amount,
                            product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method,
-			   product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6);
+			   product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time);
 
 	hop_flavour += Utils::hopFlavourContribution(product->hops.at(i).h_time, product->batch_size, product->hops.at(i).h_useat, product->hops.at(i).h_amount);
         hop_aroma += Utils::hopAromaContribution(product->hops.at(i).h_time, product->batch_size, product->hops.at(i).h_useat, product->hops.at(i).h_amount);
@@ -299,7 +300,8 @@
 
     double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg,
                               product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time,
-                              product->hops.at(product->hops_row).h_alpha, product->ibu_method, 0, product->hops.at(product->hops_row).h_time, 0);
+                              product->hops.at(product->hops_row).h_alpha, product->ibu_method, 0, product->hops.at(product->hops_row).h_time, 0,
+			      product->boil_time);
 
     ibuEdit->setValue(ibu);
     item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
@@ -333,7 +335,7 @@
     double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg,
                               product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time,
  			      product->hops.at(product->hops_row).h_alpha, product->ibu_method,
-			      product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6);
+			      product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time);
 
     ibuEdit->setValue(ibu);
     item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
@@ -398,7 +400,7 @@
     double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg,
 		              product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time,
 			      product->hops.at(product->hops_row).h_alpha, product->ibu_method,
-			      product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6);
+			      product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time);
     ibuEdit->setValue(ibu);
 
     ui->hopsTable->setItem(product->hops_row, 0, new QTableWidgetItem(product->hops.at(product->hops_row).h_origin));
@@ -619,7 +621,7 @@
     double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg,
                               product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time,
                               product->hops.at(product->hops_row).h_alpha, product->ibu_method,
-			      product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6);
+			      product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time);
     ibuEdit->setValue(ibu);
 
     hop_instock_changed(true);
--- a/src/EditRecipeTab3.cpp	Sun May 15 09:57:32 2022 +0200
+++ b/src/EditRecipeTab3.cpp	Sun May 15 11:27:06 2022 +0200
@@ -96,7 +96,8 @@
         ui->hopsTable->setItem(i, 6, item);
 
 	double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).h_amount,
-	                   recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, 0, recipe->hops.at(i).h_time, 0);
+	                   recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, 0, recipe->hops.at(i).h_time,
+			   0, recipe->boil_time);
 	item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
         item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
         ui->hopsTable->setItem(i, 7, item);
@@ -184,7 +185,8 @@
     for (int i = 0; i < recipe->hops.size(); i++) {
 
 	ibus += Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).h_amount,
-                           recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, 0, recipe->hops.at(i).h_time, 0);
+                           recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, 0, recipe->hops.at(i).h_time,
+			   0, recipe->boil_time);
 	hop_flavour += Utils::hopFlavourContribution(recipe->hops.at(i).h_time, recipe->batch_size, recipe->hops.at(i).h_useat, recipe->hops.at(i).h_amount);
         hop_aroma += Utils::hopAromaContribution(recipe->hops.at(i).h_time, recipe->batch_size, recipe->hops.at(i).h_useat, recipe->hops.at(i).h_amount);
     }
@@ -272,7 +274,8 @@
 
     double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg,
                               recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time,
-                              recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, 0);
+                              recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time,
+			      0, recipe->boil_time);
 
     ibuEdit->setValue(ibu);
     item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
@@ -305,7 +308,8 @@
 
     double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg,
                               recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time,
- 			      recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, 0);
+ 			      recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time,
+			      0, recipe->boil_time);
 
     ibuEdit->setValue(ibu);
     item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
@@ -369,7 +373,8 @@
 
     double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg,
 		              recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time,
-			      recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, 0);
+			      recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time,
+			      0, recipe->boil_time);
     ibuEdit->setValue(ibu);
 
     ui->hopsTable->setItem(recipe->hops_row, 0, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).h_origin));
@@ -579,7 +584,8 @@
     ibuEdit->setDecimals(1);
     double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg,
                               recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time,
-                              recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, 0);
+                              recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time,
+			      0, recipe->boil_time);
     ibuEdit->setValue(ibu);
 
     hop_instock_changed(true);
--- a/src/PrinterDialog.cpp	Sun May 15 09:57:32 2022 +0200
+++ b/src/PrinterDialog.cpp	Sun May 15 11:27:06 2022 +0200
@@ -432,7 +432,7 @@
 	    cost_hops += cost;
 	    double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size,
 			    	      recipe->hops.at(i).h_amount, recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha,
-				      recipe->ibu_method, 0, recipe->hops.at(i).h_time, 0);
+				      recipe->ibu_method, 0, recipe->hops.at(i).h_time, 0, recipe->boil_time);
 
 	    if (recipe->hops.at(i).h_useat == 2 || recipe->hops.at(i).h_useat == 4)	// Boil or Whirlpool
 		use = hop_useat[recipe->hops.at(i).h_useat] + QString(" %1 min").arg(recipe->hops.at(i).h_time);
--- a/src/Utils.cpp	Sun May 15 09:57:32 2022 +0200
+++ b/src/Utils.cpp	Sun May 15 11:27:06 2022 +0200
@@ -342,7 +342,7 @@
 
 
 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)
+		    int Method, double Whirlpool9, double Whirlpool7, double Whirlpool6, double Fulltime)
 {
     double	fmoment = 1.0, pfactor = 1.0, ibu = 0, boilfactor;
     double	sgfactor, AddedAlphaAcids, Bigness_factor, BoilTime_factor, utiisation;
@@ -353,27 +353,29 @@
     double mass = Amount * 1000.0;
     double time = Boiltime;
 
-    if ((Use == 3) || (Use == 4) || (Use == 5)) {	// Aroma, Whirlpool or Dry hop.
+    if ((Use == HOP_USEAT_AROMA) || (Use == HOP_USEAT_WHIRLPOOL) || (Use == HOP_USEAT_DRY_HOP)) {
 	fmoment = 0.0;
-    } else if (Use == 0) { // Mash
-	fmoment += my_factor_mashhop / 100.0;		// Brouwhulp
-    } else if (Use == 1) { // First wort
-	fmoment += my_factor_fwh / 100.0;			// Brouwhulp, Louis, Ozzie
+    } else if (Use == HOP_USEAT_MASH) {
+	fmoment += my_factor_mashhop / 100.0;	// Brouwhulp
+	time = Fulltime;			// Take the full boiltime
+    } else if (Use == HOP_USEAT_FWH) {
+	fmoment += my_factor_fwh / 100.0;	// Brouwhulp, Louis, Ozzie
+	time = Fulltime;
     }
 
-    if (Form == 0) {				// Pellet
+    if (Form == HOP_FORMS_PELLET) {
 	pfactor += my_factor_pellet / 100.0;
-    } else if (Form == 1) {			// Plug
+    } else if (Form == HOP_FORMS_PLUG) {
 	pfactor += my_factor_plug / 100.0;
-    } else if (Form == 3) {			// Wet leaf
+    } else if (Form == HOP_FORMS_LEAF_WET) {
 	pfactor += my_factor_wethop / 100.0;	// From https://github.com/chrisgilmerproj/brewday/blob/master/brew/constants.py
-    } else if (Form == 4) {			// Cryo hop
+    } else if (Form == HOP_FORMS_CRYO) {
 	pfactor += my_factor_cryohop / 100.0;
     }
 
     // Ideas from Zymurgy March-April 2018. These are not exact formulas!
     double whirlibus = 0.0;
-    if (Use == 3 || Use == 4) { // Flameout or any whirlpool
+    if (Use == HOP_USEAT_AROMA || Use == HOP_USEAT_WHIRLPOOL) { // Flameout or any whirlpool
 
 	if (Whirlpool9) {
 	    // 20 mg/l/50 min
--- a/src/Utils.h	Sun May 15 09:57:32 2022 +0200
+++ b/src/Utils.h	Sun May 15 11:27:06 2022 +0200
@@ -33,7 +33,7 @@
     double kw_to_newebc(int colormethod, double c);
     double abvol(double og, double fg);
     double toIBU(int Use, int Form, double SG, double Volume, double Amount, double Boiltime, double Alpha,
-                 int Method, double Whirlpool9, double Whirlpool7, double Whirlpool6);
+                 int Method, double Whirlpool9, double Whirlpool7, double Whirlpool6, double Fulltime);
     double hopFlavourContribution(double bt, double vol, int use, double amount);
     double hopAromaContribution(double bt, double vol, int use, double amount);
     QString hours_to_string(int hours);

mercurial