Added ABV clculation.

Mon, 12 Nov 2018 11:32:16 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 12 Nov 2018 11:32:16 +0100
changeset 88
0a39cbdcf085
parent 87
7f1d0abe5571
child 89
082c23b26055

Added ABV clculation.

www/import/from_brouwhulp.php file | annotate | diff | comparison | revisions
www/includes/formulas.php file | annotate | diff | comparison | revisions
www/rec_print.php file | annotate | diff | comparison | revisions
--- a/www/import/from_brouwhulp.php	Sun Nov 11 23:15:46 2018 +0100
+++ b/www/import/from_brouwhulp.php	Mon Nov 12 11:32:16 2018 +0100
@@ -837,6 +837,8 @@
 		$sql .= "', est_og='" . floatval($og);
 		$fg = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $og);
 		$sql .= "', est_fg='" . floatval($fg);
+		$abv = abvol($og, $fg);
+		$sql .= "', est_abv='" . floatval($abv);
 
 		$sql .= "';";
 		if (! $result = mysqli_query($db, $sql)) {
--- a/www/includes/formulas.php	Sun Nov 11 23:15:46 2018 +0100
+++ b/www/includes/formulas.php	Mon Nov 12 11:32:16 2018 +0100
@@ -163,12 +163,19 @@
 
 	$AttBeer = 0.00825 * $attenuation + 0.00817 * $BD - 0.00684 * $Temp + 0.00026 * $TotTme - 0.00356 * $percCara + 0.00553 * $percSugar + 0.547;
 	$fg = 1 + (1 - $AttBeer) * ($og - 1);
-//	echo $percSugar.' '.$percCara.' '.$attenuation.' attn '.$AttBeer.'  FG '.$fg.PHP_EOL;
 	return $fg;
 }
 
 
 
+function abvol($og, $fg) {
+	if ((4.749804 - $fg) <> 0)
+		return 486.8693 * ($og - $fg) / (4.749804 - $fg);
+	return 0;
+}
+
+
+
 /*
 
 Brouwhulp data.pas
--- a/www/rec_print.php	Sun Nov 11 23:15:46 2018 +0100
+++ b/www/rec_print.php	Mon Nov 12 11:32:16 2018 +0100
@@ -408,6 +408,7 @@
 		$this->Cell(25,5,'('.sprintf("%.3f",$row['st_fg_min']).' - '.sprintf("%.3f",$row['st_fg_max']).')',0,0,'L',true);
 		$this->Ln();
 
+		$row['est_abv'] = abvol($row['est_og'], $row['est_fg']);
 		$this->SetX($this->TableX);
 		$this->Cell(35,5,'Geschat alcohol',0,0,'L',true);
 		$this->Cell(25,5,sprintf("%.1f",$row['est_abv']).'%',0,0,'L',true);

mercurial