www/js/prod_edit.js

changeset 415
cbeec46450f8
parent 411
077ada2dda9b
child 419
99a7f2a6976e
--- a/www/js/prod_edit.js	Fri Jun 14 20:22:16 2019 +0200
+++ b/www/js/prod_edit.js	Sat Jun 15 17:19:07 2019 +0200
@@ -1787,14 +1787,36 @@
 		}
 	}
 
+	function ResCO2(CO2, T) {
+		//var resco2 = 0.000849151 * T * T - 0.0587512 * T + 1.71137; // brouwhulp
+		var F = T * 1.8 + 32;
+                var resco2 = 3.0378 - 0.050062 * F + 0.00026555 * F * F; // most of the rest
+                //console.log("CO2: "+resco2);
+		return resco2;
+	}
+
 	function CarbCO2toS(CO2, T, SFactor) {
-		// Calculation of disolved CO2 in the beer, brouwhulp.
-		var sugar = SFactor * (CO2 - (0.000849151 * T * T - 0.0587512 * T + 1.71137)) / 0.286;
+		var sugar = SFactor * (CO2 - ResCO2(CO2, T)) / 0.286;
 		if (sugar < 0)
 			sugar = 0;
 		return Math.round(sugar * 1000) / 1000;
 	}
 
+	function GetPressure(CO2, T1, T2) {
+		var F = T2 * 1.8 + 32;
+  		var V = CO2 - ResCO2(CO2, T1);
+		if (V < 0)
+			return 0;
+		var P = -1.09145427669121 + 0.00800006989646477 * T2 + 0.000260276315484684 * T2 * T2 + 0.0215142075945119 * T2 * V +
+			0.674996600795854 * V + -0.00471757220150754 * V * V;
+		//console.log("CO2: "+CO2+" "+V+"  Temp: "+T1+" "+T2+"  Pressure: "+P);
+		if (P < 0)
+			P = 0;
+		P = P * 1.01325; // atm to bar
+		P = Math.round(P * 10) / 10;
+		return P;
+	}
+
 	function CarbCO2ToPressure(CO2, T) {
 		return (CO2 - (-0.000005594056 * Math.pow(T, 4) + 0.000144357886 * Math.pow(T, 3) +
 				0.000362999168 * T * T - 0.064872987645 * T + 1.641145175049)) /
@@ -1836,6 +1858,7 @@
 		$("#bottle_priming_amount").val(Math.round(dataRecord.bottle_priming_amount * 10) / 10);
                 $("#bottle_priming_total").val(dataRecord.bottle_priming_total);
                 $("#bottle_abv").val(Math.round((ABV + dataRecord.bottle_priming_amount * 0.47 / 7.907) * 10) / 10);
+		$("#bottle_pressure").val(GetPressure(dataRecord.bottle_carbonation, TSec, dataRecord.bottle_carbonation_temp));
 
 		// Kegs
 		var Pressure = CarbCO2ToPressure(dataRecord.keg_carbonation, dataRecord.keg_carbonation_temp);
@@ -5799,6 +5822,8 @@
 	$("#bottle_priming_amount").jqxNumberInput( Show1dec );
 	$("#keg_priming_amount").jqxNumberInput( Show1dec );
 	$("#bottle_priming_total").jqxNumberInput( Show1dec );
+	$("#bottle_pressure").jqxTooltip({ content: 'De maximal te verwachten druk tijdens het hergisten.' });
+	$("#bottle_pressure").jqxNumberInput( Show1dec );
 	$("#keg_priming_total").jqxNumberInput( Show1dec );
 	$("#keg_forced_carb").jqxCheckBox({ theme: theme, width: 120, height: 23 });
 	$("#keg_pressure").jqxNumberInput( Show1dec );

mercurial