Printed outputs have IBUs for whirlpool hops. Removed some debug console logs.

Sun, 27 Oct 2019 22:39:28 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 27 Oct 2019 22:39:28 +0100
changeset 539
fe9ac6d49c4f
parent 538
41d21817608e
child 540
756fe9afe72b

Printed outputs have IBUs for whirlpool hops. Removed some debug console logs.

www/includes/formulas.php file | annotate | diff | comparison | revisions
www/js/global.js file | annotate | diff | comparison | revisions
www/js/prod_edit.js file | annotate | diff | comparison | revisions
www/prod_forum.php file | annotate | diff | comparison | revisions
www/prod_print.php file | annotate | diff | comparison | revisions
www/rec_forum.php file | annotate | diff | comparison | revisions
www/rec_print.php file | annotate | diff | comparison | revisions
--- a/www/includes/formulas.php	Sun Oct 27 20:20:09 2019 +0100
+++ b/www/includes/formulas.php	Sun Oct 27 22:39:28 2019 +0100
@@ -202,7 +202,7 @@
 
 
 
-function calc_IBU($useat, $form, $sg, $volume, $mass, $boiltime, $alpha, $method)
+function calc_IBU($useat, $form, $sg, $volume, $mass, $boiltime, $alpha, $method, $whirlpool9, $whirlpool7, $whirlpool6)
 {
 	global $my_factor_mashhop;
 	global $my_factor_fwh;
@@ -234,13 +234,23 @@
                 $pfactor += $my_factor_cryohop / 100;
         }
 
+	$whirlibus = 0;
+        if ($useat == 4) { // Any whirlpool
+		if ($whirlpool9)
+			$whirlibus += ($mass * ($alpha / 100) * 20) / $volume * $whirlpool9 / 50;
+		if ($whirlpool7)
+			$whirlibus += ($mass * ($alpha / 100) * 6) / $volume * $whirlpool7 / 50;
+		if ($whirlpool6)
+			$whirlibus += ($mass * ($alpha / 100) * 2) / $volume * $whirlpool6 / 50;
+	}
+
 	$ibu = 0;
 	if (($method == 0) || ($method == 3)) {	// Tinseth or Garetz // For Garetz, we need the $ibu
 		$AddedAlphaAcids = (($alpha / 100) * $mass * 1000) / $volume;
 		$Bigness_factor = 1.65 * pow( 0.000125, $sg - 1);
 		$BoilTime_factor = ((1 - exp(-0.04 * $boiltime)) / 4.15);
 		$utiisation = $Bigness_factor * $BoilTime_factor;
-		$ibu = (round($utiisation * $AddedAlphaAcids * $fmoment * $pfactor * 10) / 10.0);
+		$ibu = (round(($utiisation * $AddedAlphaAcids * $fmoment * $pfactor + $whirlibus) * 10) / 10.0);
 	}
 	if ($method == 2) {	// Daniels
 
@@ -252,7 +262,7 @@
 			$sgfactor = 0;
 		else
 			$sgfactor = (($sg * 1000) - 1050) / 200;
-		$ibu = $fmoment * (($mass * $alpha * $boilfactor * 0.1) / ($volume * (1 + $sgfactor)));
+		$ibu = $fmoment * (($mass * $alpha * $boilfactor * 0.1) / ($volume * (1 + $sgfactor))) + $whirlibus;
 	}
 	if ($method == 1) {	// Rager
 		$boilfactor = $fmoment * 18.11 + 13.86 * tanh(($boiltime * 31.32) / 18.27);
@@ -260,7 +270,7 @@
 			$sgfactor = 0;
 		else
 			$sgfactor = (($sg * 1000) - 1050) / 200;
-		$ibu = ($mass * $alpha * $boilfactor * 0.1) / ($volume * (1 + $sgfactor));
+		$ibu = ($mass * $alpha * $boilfactor * 0.1) / ($volume * (1 + $sgfactor)) + $whirlibus;
 	}
 	if ($method == 3) {	// Garetz, not in use.
 		/* Something is wrong, late hops and dryhops give negative results. */
--- a/www/js/global.js	Sun Oct 27 20:20:09 2019 +0100
+++ b/www/js/global.js	Sun Oct 27 22:39:28 2019 +0100
@@ -907,17 +907,17 @@
   if (Whirlpool9) {
    // 20 mg/l/50 min
    whirlibus += (alpha * mass * 20) / liters * (Whirlpool9 / 50);
-   console.log('Whirlpool9:' + alpha * mass * 20 + ' liter:' + liters + ' time:' + Whirlpool9 + ' ibu' + (alpha * mass * 20) / liters * (Whirlpool9 / 50));
+   //console.log('Whirlpool9:' + alpha * mass * 20 + ' liter:' + liters + ' time:' + Whirlpool9 + ' ibu' + (alpha * mass * 20) / liters * (Whirlpool9 / 50));
   }
   if (Whirlpool7) {
    // 6 mg/l/50 min
    whirlibus += (alpha * mass * 6) / liters * (Whirlpool7 / 50);
-   console.log('Whirlpool7:' + alpha * mass * 6 + ' liter:' + liters + ' time:' + Whirlpool7 + ' ibu' + (alpha * mass * 6) / liters * (Whirlpool7 / 50));
+   //console.log('Whirlpool7:' + alpha * mass * 6 + ' liter:' + liters + ' time:' + Whirlpool7 + ' ibu' + (alpha * mass * 6) / liters * (Whirlpool7 / 50));
   }
   if (Whirlpool6) {
    // 2 mg/l/50 min
    whirlibus += (alpha * mass * 2) / liters * (Whirlpool6 / 50);
-   console.log('Whirlpool6:' + alpha * mass * 2 + ' liter:' + liters + ' time:' + Whirlpool6 + ' ibu' + (alpha * mass * 2) / liters * (Whirlpool6 / 50));
+   //console.log('Whirlpool6:' + alpha * mass * 2 + ' liter:' + liters + ' time:' + Whirlpool6 + ' ibu' + (alpha * mass * 2) / liters * (Whirlpool6 / 50));
   }
  }
 
--- a/www/js/prod_edit.js	Sun Oct 27 20:20:09 2019 +0100
+++ b/www/js/prod_edit.js	Sun Oct 27 22:39:28 2019 +0100
@@ -823,15 +823,12 @@
     { name: 'h_avail', type: 'int' }
    ],
    addrow: function(rowid, rowdata, position, commit) {
-    console.log('hop addrow ' + rowid);
     commit(true);
    },
    deleterow: function(rowid, commit) {
-    console.log('hop deleterow ' + rowid);
     commit(true);
    },
    updaterow: function(rowid, rowdata, commit) {
-    console.log('hop updaterow ' + rowid);
     commit(true);
    }
   },
@@ -1030,15 +1027,12 @@
     { name: 'm_avail', type: 'int' }
    ],
    addrow: function(rowid, rowdata, position, commit) {
-    console.log('misc addrow ' + rowid);
     commit(true);
    },
    deleterow: function(rowid, commit) {
-    console.log('misc deleterow ' + rowid);
     commit(true);
    },
    updaterow: function(rowid, rowdata, commit) {
-    console.log('misc updaterow ' + rowid);
     commit(true);
    }
   },
@@ -2418,9 +2412,8 @@
  };
 
  function whirlpoolHops() {
-  console.log('whirlpoolHops()');
   var row, i, time, rowscount;
-  if (!(rowscount =  $('#hopGrid').jqxGrid('getdatainformation').rowscount))
+  if (!(rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount))
    return;
   if (rowscount == 0)
    return;
--- a/www/prod_forum.php	Sun Oct 27 20:20:09 2019 +0100
+++ b/www/prod_forum.php	Sun Oct 27 22:39:28 2019 +0100
@@ -127,7 +127,8 @@
 	$amount = floatval($item['h_amount']) * 1000;
 	$time   = floatval($item['h_time']);
         $alpha  = floatval($item['h_alpha']);
-	$ibu    = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $amount, $time, $alpha, $row['ibu_method']);
+	$ibu    = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $amount, $time, $alpha,
+		$row['ibu_method'], $row['brew_whirlpool9'], $row['brew_whirlpool7'], $row['brew_whirlpool6']);
 	$moment = $hopuse[$item['h_useat']];
         if (($item['h_useat'] == 2) || ($item['h_useat'] == 4)) {    // Boil or Whirlpool
         	$moment = $hopuse[$item['h_useat']].' '.$time." minuten";
--- a/www/prod_print.php	Sun Oct 27 20:20:09 2019 +0100
+++ b/www/prod_print.php	Sun Oct 27 22:39:28 2019 +0100
@@ -260,7 +260,8 @@
 			} else if ($item['h_useat'] == 5) {	// Dryhop
 				$moment = $hopuse[$item['h_useat']].' '.sprintf("%.0f", $time / 1440).' dagen';
 			}
-			$ibu = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha, $row['ibu_method']);
+			$ibu = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha,
+				$row['ibu_method'], $row['brew_whirlpool9'], $row['brew_whirlpool7'], $row['brew_whirlpool6']);
 			$total_ibus += $ibu;
 
 			if ($amount > 1)
--- a/www/rec_forum.php	Sun Oct 27 20:20:09 2019 +0100
+++ b/www/rec_forum.php	Sun Oct 27 22:39:28 2019 +0100
@@ -127,7 +127,8 @@
 	$amount = floatval($item['h_amount']) * 1000;
 	$time   = floatval($item['h_time']);
         $alpha  = floatval($item['h_alpha']);
-	$ibu    = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $amount, $time, $alpha, $row['ibu_method']);
+	$ibu    = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $amount, $time, $alpha,
+		$row['ibu_method'], $row['brew_whirlpool9'], $row['brew_whirlpool7'], $row['brew_whirlpool6']);
 	$moment = $hopuse[$item['h_useat']];
         if (($item['h_useat'] == 2) || ($item['h_useat'] == 4)) {    // Boil or Whirlpool
         	$moment = $hopuse[$item['h_useat']].' '.$time." minuten";
--- a/www/rec_print.php	Sun Oct 27 20:20:09 2019 +0100
+++ b/www/rec_print.php	Sun Oct 27 22:39:28 2019 +0100
@@ -230,7 +230,8 @@
 			} else if ($item['h_useat'] == 5) {	// Dryhop
 				$moment  = $hopuse[$item['h_useat']].' '.sprintf("%.0f", $time / 1440).' dagen';
 			}
-			$ibu = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha, $row['ibu_method']);
+			$ibu = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $mass, $time, $alpha,
+				$row['ibu_method'], $row['brew_whirlpool9'], $row['brew_whirlpool7'], $row['brew_whirlpool6']);
 			$total_ibus += $ibu;
 
 			if ($amount > 1)

mercurial