diff -r cd1403633e96 -r bcc4583fd013 www/js/global.js --- a/www/js/global.js Sun Dec 09 22:27:38 2018 +0100 +++ b/www/js/global.js Mon Dec 10 22:20:19 2018 +0100 @@ -235,6 +235,36 @@ } + +function estimate_fg(percSugar, percCara, WGratio, TotTme, Temp, attenuation, og) { + + var BD; + + console.log("estimate_fg("+percSugar+","+percCara+","+WGratio+","+TotTme+","+Temp+","+attenuation+","+og+")"); + + if (percSugar > 40) + percSugar = 0; + if (percCara > 50) + percCara = 0; + if ((WGratio > 0) && (TotTme > 0)) { + BD = WGratio; + BD = max(2, min(5.5, BD)); + Temp = max(60, min(72, Temp)); + } else { + BD = 3.5; + Temp = 67; + TotTme = 75; + } + if (attenuation < 30) + attenuation = 77; + + var AttBeer = 0.00825 * attenuation + 0.00817 * BD - 0.00684 * Temp + 0.00026 * TotTme - 0.00356 * percCara + 0.00553 * percSugar + 0.547; + var fg = Math.round((1 + (1 - AttBeer) * (og - 1)) * 1000) / 1000; + console.log("fg:"+fg); + return fg; +} + + /* * Steinie: *