diff --git a/beer/admin.py b/beer/admin.py index 86d8d95..8ef67a9 100644 --- a/beer/admin.py +++ b/beer/admin.py @@ -7,7 +7,6 @@ from beer.models import Batch, Recipe, Mash, MashStep, \ from yeast.models import Yeast from config.extras import BREWFATHER_APP_ROOT -from beer.extras import plato_sg class SampleInline(admin.TabularInline): diff --git a/beer/models.py b/beer/models.py index d690235..defcab3 100644 --- a/beer/models.py +++ b/beer/models.py @@ -44,13 +44,13 @@ class Batch(CustomModel): # Brewday Measurements # ------------------------------------------------------------------------- - ## Mash + # Mash first_runnings = models.DecimalField( max_digits=8, decimal_places=4, null=True, blank=True) mash_ph = models.DecimalField( max_digits=4, decimal_places=3, null=True, blank=True) - ## Boil + # Boil pre_boil_vol = models.DecimalField( max_digits=8, decimal_places=4, null=True, blank=True) pre_boil_sg = models.DecimalField( @@ -60,7 +60,7 @@ class Batch(CustomModel): post_boil_sg = models.DecimalField( max_digits=5, decimal_places=4, null=True, blank=True) - ## Ferment + # Ferment fermenter_topup_vol = models.DecimalField( max_digits=8, decimal_places=4, null=True, blank=True) fermenter_vol = models.DecimalField( @@ -70,11 +70,11 @@ class Batch(CustomModel): final_sg = models.DecimalField( max_digits=5, decimal_places=4, null=True, blank=True) - # Properties Needed: (https://braukaiser.com/wiki/index.php/Troubleshooting_Brewhouse_Efficiency) + # Properties Needed: + # braukaiser.com/wiki/index.php/Troubleshooting_Brewhouse_Efficiency # - Mash Efficiency # - ABV # - Attenuation - # - Actual Boil-Off Rate # - Actual Trub/Chiller Loss # ------------------------------------------------------------------------- @@ -83,7 +83,7 @@ class Batch(CustomModel): @property def brewhouse_efficiency(self): try: - return round(self.boil_extract_kg/self.recipe.total_extract_kg,4) + return round(self.boil_extract_kg/self.recipe.total_extract_kg, 4) except ZeroDivisionError: return 0 @@ -94,17 +94,23 @@ class Batch(CustomModel): @property def conversion_efficiency(self): """ Calculate conversion efficiency of mash.""" - if self.first_runnings is None or self.recipe.fermentable_weight_kg == 0: + if (self.first_runnings is None + or self.recipe.fermentable_weight_kg == 0): return '-' return round((sg_plato(self.first_runnings)/self.recipe.fw_max) - * (100-self.recipe.fw_max) / (100-sg_plato(self.first_runnings)) - , 4) + * (100-self.recipe.fw_max) + / (100-sg_plato(self.first_runnings)), 4) @property def boil_off_calcualted(self): return float(self.pre_boil_vol - self.post_boil_vol) * .96 + @property + def trub_loss_calculated(self): + transfered_volume = self.fermenter_vol - self.fermenter_topup_vol + return self.post_boil_vol-transfered_volume + @property def brewfather_url(self): return '{}/tabs/batches/batch/{}'.format( @@ -392,7 +398,8 @@ class Fermentable(CustomIngredient): @property def extract_percent(self): - return ((float(self.potential)-1)*1000/46.17) * (1-float(self.moisture)/100) + return (((float(self.potential)-1)*1000/46.17) + * (1-float(self.moisture)/100)) def __str__(self): return self.name @@ -485,7 +492,8 @@ class RecipeHop(CustomModel): + (self.recipe.original_sg-1)) / 2) if self.use == 1: - conc = (float((self.hop.alpha/100)) * float(self.quantity)*0.0352739619 + conc = (float(self.hop.alpha/100) + * convert(self.quantity, 'g', 'oz') * 7490/convert(self.recipe.final_volume, 'l', 'gal')) util = (hop_bonus*1.65*0.000125**average_wort_sg * ((1-2.71828182845904**(-0.04*self.time)) / 4.15))