www/includes/formulas.php

changeset 231
9881453a49b3
parent 164
0a5abea575a9
child 243
b43214d218c0
--- a/www/includes/formulas.php	Fri Feb 01 22:00:49 2019 +0100
+++ b/www/includes/formulas.php	Sat Feb 02 11:53:39 2019 +0100
@@ -181,11 +181,11 @@
  */
 function kw_to_srm($colormethod, $c) {
 
-	if ($colormethod == "Morey")
+	if ($colormethod == 0)	// Morey
 		return 1.4922 * pow($c, 0.6859);
-	if ($colormethod == "Mosher")
+	if ($colormethod == 1)	// Mosher
 		return 0.3 * $c + 4.7;
-	if ($colormethod == "Daniels")
+	if ($colormethod == 2)	// Daniels
 		return 0.2 * $c + 8.4;
 }
 
@@ -205,33 +205,33 @@
 	global $my_factor_plug;
 
 	$fmoment  = 1.0;
-	if (($useat == "Dry Hop") || ($useat == "Dry hop") || ($useat == "Whirlpool") || ($useat == "Aroma")) {
+	if (($useat == 5) || ($useat == 4) || ($useat == 3)) {	// Dry hop, Whirlpool or Aroma
 		$fmoment = 0.0;
-	} else if ($useat == "Mash") {
+	} else if ($useat == 0) {	// Mash
 		$fmoment += $my_factor_mashhop / 100;         // Brouwhulp
-	} else if (($useat == "First Wort") || ($useat == "First wort")) {
+	} else if ($useat == 1) {	// First wort
 		$fmoment += $my_factor_fwh / 100;         // Brouwhulp, Louis, Ozzie
 	}
 
 	$pfactor  = 1.0;
-	if ($form == "Pellet") {
+	if ($form == 0) {	// Pellets
 		$pfactor += $my_factor_pellet / 100;
 	}
-	if ($form == "Plug") {
+	if ($form == 1) {	// Plugs
 		$pfactor += $my_factor_plug / 100;
 	}
 
 	$ibu = 0;
-	if (($method == "Tinseth") || ($method == "Garetz")) {	// For Garetz, we need the $ibu
+	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);
 	}
-	if ($method == "Daniels") {
+	if ($method == 2) {	// Daniels
 
-		if ($form == "Leaf")
+		if ($form == 2)	// Leaf
 			$boilfactor = -(0.0041*$boiltime*$boiltime)+(0.6162*$boiltime)+1.5779;
 		else
 			$boilfactor = -(0.0051*$boiltime*$boiltime)+(0.7835*$boiltime)+1.9348;
@@ -241,7 +241,7 @@
 			$sgfactor = (($sg * 1000) - 1050) / 200;
 		$ibu = $fmoment * (($mass * $alpha * $boilfactor * 0.1) / ($volume * (1 + $sgfactor)));
 	}
-	if ($method == "Rager") {
+	if ($method == 1) {	// Rager
 		$boilfactor = $fmoment * 18.11 + 13.86 * tanh(($boiltime * 31.32) / 18.27);
 		if ($sg < 1.050)
 			$sgfactor = 0;
@@ -249,7 +249,7 @@
 			$sgfactor = (($sg * 1000) - 1050) / 200;
 		$ibu = ($mass * $alpha * $boilfactor * 0.1) / ($volume * (1 + $sgfactor));
 	}
-	if ($method == "Garetz") {
+	if ($method == 3) {	// Garetz, not in use.
 		/* Something is wrong, late hops and dryhops give negative results. */
 		$boilfactor = $fmoment * 6.03253 + 16.5289 * tanh(($boiltime - 19.17323) / 26.8013);
 		$cfactor = $volume / (1.1 * $volume);	// ConcentratieFactor = (Volume na koelen) / (Volume bij Koken)

mercurial