987 Acid = Math.round(Acid * 100) / 100; |
987 Acid = Math.round(Acid * 100) / 100; |
988 dataRecord.sparge_acid_amount = Acid / 1000; |
988 dataRecord.sparge_acid_amount = Acid / 1000; |
989 $("#sparge_acid_amount").val(Acid); |
989 $("#sparge_acid_amount").val(Acid); |
990 } |
990 } |
991 |
991 |
|
992 /* |
|
993 * Change OG of recipe but keep the water volumes. |
|
994 */ |
992 function calcFermentablesFromOG(OG) { |
995 function calcFermentablesFromOG(OG) { |
993 |
996 |
994 console.log("calcFermentablesFromOG("+OG+")"); |
997 console.log("calcFermentablesFromOG("+OG+")"); |
995 var efficiency = parseFloat($("#efficiency").jqxNumberInput('decimal')); |
998 var efficiency = parseFloat($("#efficiency").jqxNumberInput('decimal')); |
996 var rows = $('#fermentableGrid').jqxGrid('getrows'); |
999 var sug = sg_to_plato(OG) * parseFloat($("#batch_size").jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg |
997 var sug = sg_to_plato(OG) * parseFloat($("#batch_size").jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg |
1000 var tot = 0; |
998 var tot = 0; |
1001 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
999 for (var i = 0; i < rows.length; i++) { |
1002 |
1000 var row = rows[i]; |
1003 for (var i = 0; i < rowscount; i++) { |
|
1004 var row = $("#fermentableGrid").jqxGrid('getrowdata', i); |
1001 var d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
1005 var d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
1002 if (row.f_added == 0) // Mash |
1006 if (row.f_added == 0) // Mash |
1003 d = efficiency / 100 * d; |
1007 d = efficiency / 100 * d; |
1004 tot += d; |
1008 tot += d; |
1005 } |
1009 } |
1006 |
|
1007 var totmass = 0; |
1010 var totmass = 0; |
1008 if (tot) |
1011 if (tot) |
1009 totmass = sug / tot; |
1012 totmass = sug / tot; |
1010 |
1013 |
1011 if (totmass) { |
1014 if (totmass) { |
1012 for (var i = 0; i < rows.length; i++) { |
1015 for (i = 0; i < rowscount; i++) { |
1013 var row = rows[i]; |
1016 var row = $("#fermentableGrid").jqxGrid('getrowdata', i); |
1014 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_amount", row.f_percentage / 100 * totmass); |
1017 var amount = row.f_percentage / 100 * totmass; |
1015 } |
1018 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_amount", amount); |
1016 } |
1019 } |
1017 //CalcWaterBalance; |
1020 } |
1018 }; |
1021 }; |
1019 |
1022 |
1020 function calcFG() { |
1023 function calcFG() { |
1021 var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal')))); |
1024 var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal')))); |
1022 dataRecord.est_fg = fg; |
1025 dataRecord.est_fg = fg; |