www/includes/formulas.php

changeset 100
08c92cb740b9
parent 96
107c12c3e49d
child 101
5b6bb99bc52a
--- a/www/includes/formulas.php	Sat Nov 17 15:58:13 2018 +0100
+++ b/www/includes/formulas.php	Sat Nov 17 19:44:39 2018 +0100
@@ -21,20 +21,21 @@
 
 function ebc_to_srm($ebc)
 {
-	// Srm = -1.32303E-12*Ebc4-0.00000000291515*Ebc3+0.00000818515*Ebc2+0.372038*Ebc+0.596351
-	return  -1.32303E-12 * pow($ebc, 4) - 0.00000000291515 * pow($ebc, 3) + 0.00000818515 * pow($ebc, 2) + 0.372038 * $ebc + 0.596351;
-	//  return $ebc * 0.508;
+	$srm = -1.32303E-12 * pow($ebc, 4) - 0.00000000291515 * pow($ebc, 3) + 0.00000818515 * pow($ebc, 2) + 0.372038 * $ebc + 0.596351;
+	if (($ebc < 0) || ($srm < 0))
+		syslog(LOG_NOTICE, "ebc_to_srm(".$ebc.") = ".$srm);
+	return $srm;
 }
 
 
 
 function srm_to_ebc($srm)
 {
-	// EBC = 0.000000000176506*Srm4+ 0.000000154529*Srm3-0.000159428*Srm2+2.68837*Srm-1.6004
-	//
 	// Formule van Adrie Otten. brouwhulp.
-	$ebc = 0.000000000176506 * pow($srm, 4) + 0.000000154529 * pow($srm, 3) - 0.000159428 * pow($srm, 2) + 2.68837 * $srm - 1.6004;
-	return round($ebc);
+	$ebc = round( 0.000000000176506 * pow($srm, 4) + 0.000000154529 * pow($srm, 3) - 0.000159428 * pow($srm, 2) + 2.68837 * $srm - 1.6004 );
+	if (($ebc < 0) || ($srm < 0))
+		syslog(LOG_NOTICE, "srm_to_ebc(".$srm.") = ".$ebc);
+	return $ebc;
 }
 
 

mercurial