www/includes/formulas.php

changeset 539
fe9ac6d49c4f
parent 446
ee7bcfb8e270
child 544
f3faa54581ff
--- 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. */

mercurial