www/js/global.js

changeset 282
f765249d57d7
parent 278
dc22dd5d77fd
child 286
124af734af68
--- a/www/js/global.js	Thu Feb 21 16:36:02 2019 +0100
+++ b/www/js/global.js	Sat Feb 23 19:55:42 2019 +0100
@@ -117,6 +117,7 @@
 	{ id: 0, en: 'Pellet', nl: 'pellets' },
 	{ id: 1, en: 'Plug',   nl: 'plugs' },
 	{ id: 2, en: 'Leaf',   nl: 'bellen' }
+//	{ id: 3, en: 'Leaf wet', nl: 'bellen nat' }
 ];
 var HopFormSource = {
 	localdata: HopFormData,
@@ -786,6 +787,11 @@
  */
 function abvol(og, fg) {
 
+	if ((og - fg) < 0)
+		return 0;
+
+	return (76.08 * (og-fg) / (1.775-og)) * (fg / 0.794); // Daniels
+// brouwhulp
 	if ((4.749804 - fg) != 0)
 		return 486.8693 * (og - fg) / (4.749804 - fg);
 	return 0;
@@ -842,6 +848,9 @@
 	if (Form == 1 ) {	// Plug
 		pfactor += my_factor_plug / 100;
 	}
+//	if (Form == 3) {	// Wet leaf
+//		pfactor += 5.5;	// From https://github.com/chrisgilmerproj/brewday/blob/master/brew/constants.py
+//	}
 
 	if (Method == 0) {	// Tinseth
 		/* http://realbeer.com/hops/research.html */
@@ -958,17 +967,26 @@
 
 
 function sg_to_plato(sg) {
-	if (sg > 0.5)
-		return 259 - 259 / sg;
-	return 0;
+	// http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/
+	return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868;
 }
 
 
 
 function plato_to_sg(plato) {
-	if (plato < 259)
-		return 259 / (259 - plato);
-	return 1.000;
+	return 1 + (plato / (258.6 - ((plato / 258.2) * 227.1)));
+}
+
+
+
+function brix_to_sg(brix) {
+	return plato_to_sg(brix / my_brix_correction);
+}
+
+
+
+function sg_to_brix(sg) {
+	return sg_to_plato(sg) * my_brix_correction;
 }
 
 
@@ -1035,4 +1053,3 @@
 	return f2d + 2*f3d + 3*f4d;
 }
 
-

mercurial