www/js/global.js

changeset 98
92d6bc8a4cdd
parent 96
107c12c3e49d
child 100
08c92cb740b9
--- a/www/js/global.js	Thu Nov 15 22:36:09 2018 +0100
+++ b/www/js/global.js	Fri Nov 16 16:20:17 2018 +0100
@@ -83,6 +83,41 @@
 
 
 
+function ebc_to_srm(ebc) {
+	return  -1.32303E-12 * Math.pow(ebc, 4) - 0.00000000291515 * Math.pow(ebc, 3) + 0.00000818515 * Math.pow(ebc, 2) + 0.372038 * ebc + 0.596351;
+}
+
+
+
+function srm_to_ebc(srm)
+{
+	var ebc = 0.000000000176506 * Math.pow(srm, 4) + 0.000000154529 * Math.pow(srm, 3) - 0.000159428 * Math.pow(srm, 2) + 2.68837 * srm - 1.6004;
+	return Math.round(ebc);
+}
+
+
+
+/*
+ * Kleurwerking naar SRM
+ */
+function kw_to_srm(colormethod, c) {
+
+	if (colormethod == "Morey")
+		return 1.4922 * Math.pow(c, 0.6859);
+	if (colormethod == "Mosher")
+		return 0.3 * c + 4.7;
+	if (colormethod == "Daniels")
+		return 0.2 * c + 8.4;
+}
+
+
+
+function kw_to_ebc(colormethod, c) {
+	return srm_to_ebc(kw_to_srm(colormethod, c));
+}
+
+
+
 /*
  * Berekeningen uit https://www.hobbybrouwen.nl/forum/index.php/topic,6079.msg69464.html#msg69464
  */
@@ -96,8 +131,6 @@
 	var pfactor = 1.0;
 	var ibu     = 0;
 
-	console.log("toIBU("+Use+"," + Form + "," + SG + "," + Volume + "," + Amount + "," + Boiltime + "," + Alpha + "," + Method + ")");
-
 	if ((Use == "Dry Hop") || (Use == "Dry hop") || (Use == "Whirlpool") || (Use == "Aroma")) {
 		fmoment = 0.0;
 	} else if (Use == "Mash") {
@@ -113,32 +146,12 @@
 		pfactor += /* Settings.PlugFactor.Value = 2% */ 2 / 100;
 	}
 
-	// TODO:  sg = (postBoilGravity - 1.0) * batchSize / boilSize;
-
 	if (Method == "Tinseth") {
-		/*
-		 * http://realbeer.com/hops/research.html
-		 *
-		 *                             decimal AA rating * grams hops * 1000
-		 * mg/l of added alpha acids = -------------------------------------
-		 *			         volume of finished beer in liters
-		 *
-		 * Bigness factor = 1.65 * 0.000125^(wort gravity - 1)
-		 *
-		 *                    1 - e^(-0.04 * time in mins)
-		 * Boil Time factor = ----------------------------
-		 *                               4.15
-		 *
-		 * decimal alpha acid utilization = Bigness factor * Boil Time factor
-		 *
-		 * IBUs = decimal alpha acid utilization * mg/l of added alpha acids
-		 */
+		/* http://realbeer.com/hops/research.html */
 		var AddedAlphaAcids = (alpha * mass * 1000) / liters;
 		var Bigness_factor = 1.65 * Math.pow( 0.000125, gravity - 1);
-		var BoilTime_factor = ((1 - Math.exp(-0.04 * time)) / 4.15);		// Glen Tinseth
+		var BoilTime_factor = ((1 - Math.exp(-0.04 * time)) / 4.15);
 		var utiisation = Bigness_factor * BoilTime_factor;
-
-		console.log(" AddedAlphaAcids:"+AddedAlphaAcids+"  Bigness_factor:"+Bigness_factor+"  BoilTime_factor:"+BoilTime_factor+"  utilisation:"+utiisation);
 		ibu = Math.round(utiisation * AddedAlphaAcids * fmoment * pfactor * 10) / 10.0;
 	}
 	if (Method == "Daniels") {
@@ -165,7 +178,7 @@
 		ibu = Math.round((mass * (alpha * 100) * boilfactor * 0.1) / (liters * (1 + sgfactor)) * 10) / 10;
 	}
 
-	console.log(" fmoment:"+fmoment+"  pfactor:"+pfactor+"  IBU:"+ibu);
+	console.log("toIBU("+Use+"," + Form + "," + SG + "," + Volume + "," + Amount + "," + Boiltime + "," + Alpha + "," + Method + ") :" + ibu);
 	return ibu;
 }
 

mercurial