Wed, 14 Nov 2018 16:49:56 +0100
Added Rager and Daniels IBU calculations to javascript formula.
www/js/global.js | file | annotate | diff | comparison | revisions |
--- a/www/js/global.js Wed Nov 14 15:54:15 2018 +0100 +++ b/www/js/global.js Wed Nov 14 16:49:56 2018 +0100 @@ -86,7 +86,7 @@ /* * Berekeningen uit https://www.hobbybrouwen.nl/forum/index.php/topic,6079.msg69464.html#msg69464 */ -function toIBU_Tinseth(Use, Form, SG, Volume, Amount, Boiltime, Alpha) { +function toIBU(Use, Form, SG, Volume, Amount, Boiltime, Alpha, Method) { var gravity = parseFloat(SG); var liters = parseFloat(Volume); var alpha = parseFloat(Alpha)/100; @@ -94,63 +94,83 @@ var time = parseFloat(Boiltime); var fmoment = 1.0; var pfactor = 1.0; + var ibu = 0; - if ((Use == "Dry Hop") || (Use == "Dry hop")) { - fmoment = 0.0; - } else if (Use == "Whirlpool") { + console.log("toIBU_Tinseth("+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") { - fmoment = 0.7; // Brouwhulp + fmoment += /* Settings.MashHopFactor.Value = -30% */ -30 / 100; // Brouwhulp } else if ((Use == "First Wort") || (Use == "First wort")) { - fmoment = 1.1; // Brouwhulp, Louis, Ozzie - } else if (Use == "Aroma") { - fmoment = 0.0; + fmoment += /* Settings.FWHFactor.Value = 10% */ 10 / 100; // Brouwhulp, Louis, Ozzie } if (Form == "Pellet") { - pfactor = 1.1; + pfactor += /* Settings.PelletFactor.Value = 10% */ 10 / 100; + } + if (Form == "Plug" ) { + pfactor += /* Settings.PlugFactor.Value = 2% */ 2 / 100; } // TODO: sg = (postBoilGravity - 1.0) * batchSize / boilSize; - /* - * 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 - */ - 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 utiisation = Bigness_factor * BoilTime_factor; + 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 + */ + 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 utiisation = Bigness_factor * BoilTime_factor; - console.log(" AddedAlphaAcids:"+AddedAlphaAcids+" Bigness_factor:"+Bigness_factor+" BoilTime_factor:"+BoilTime_factor+" utilisation:"+utiisation); - console.log(" fmoment:"+fmoment+" pfactor:"+pfactor); + 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") { + var boilfactor; + var sgfactor; + if (Form == "Leaf") + boilfactor = -(0.0041*time*time)+(0.6162*time)+1.5779; + else + boilfactor = -(0.0051*time*time)+(0.7835*time)+1.9348; + if (gravity < 1050) + sgfactor = 0; + else + sgfactor = (gravity - 1050) / 200; + ibu = Math.round(fmoment * ((mass * (alpha * 100) * boilfactor * 0.1) / (liters * (1 + sgfactor))) * 10) / 10; + } + if (Method == "Rager") { + var boilfactor; + var sgfactor; + boilfactor = fmoment * 18.11 + 13.86 * Math.tanh((time * 31.32) / 18.27); + if (gravity < 1050) + sgfactor = 0; + else + sgfactor = (gravity - 1050) / 200; + ibu = Math.round((mass * (alpha * 100) * boilfactor * 0.1) / (liters * (1 + sgfactor)) * 10) / 10; + } - var ibu = (Math.round(utiisation * AddedAlphaAcids * fmoment * pfactor * 10) / 10.0); + console.log(" fmoment:"+fmoment+" pfactor:"+pfactor+" IBU:"+ibu); return ibu; } -function toIBU(Use, Form, SG, Volume, Amount, Boiltime, Alpha, Method) { - - console.log("toIBU_Tinseth("+Use+"," + Form + "," + SG + "," + Volume + "," + Amount + "," + Boiltime + "," + Alpha + "," + Method + ")"); - return toIBU_Tinseth(Use, Form, SG, Volume, Amount, Boiltime, Alpha); -} - - /* * Steinie: *