Skip to content

Commit

Permalink
Merge pull request #20 from chrisgilmerproj/tools_to_correct_wort
Browse files Browse the repository at this point in the history
Add tools for correcting wort during boil
  • Loading branch information
chrisgilmerproj committed Feb 19, 2018
2 parents 625aa8b + a88874a commit 85f8e86
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

## Version 0.0.8

- Add tools to determine amount of sugar needed to correct wort during brew
- Add equation to get boiling point at different altitudes
- Add a gravity-volume converter cli
- Fix grain conversions
Expand Down
3 changes: 2 additions & 1 deletion brew/constants.py
Expand Up @@ -168,5 +168,6 @@
#: Weight Tolerance, considered equal within this range
WEIGHT_TOLERANCE = 0.005

# TBD: Set to zero until more testing is completed
#: Percent of water evaporated during boil, usually 8% or between 8%-10%
BOIL_EVAPORATION = 0.00
BOIL_EVAPORATION = 0.0
19 changes: 18 additions & 1 deletion brew/recipes.py
Expand Up @@ -14,6 +14,7 @@
from .constants import IMPERIAL_TYPES
from .constants import IMPERIAL_UNITS
from .constants import LITER_PER_GAL
from .constants import PPG_DME
from .constants import PPG_CEREAL
from .constants import SI_TYPES
from .constants import SI_UNITS
Expand All @@ -33,6 +34,7 @@
from .utilities.color import calculate_srm_morey
from .utilities.color import calculate_srm_mosher
from .utilities.color import srm_to_ebc
from .utilities.efficiency import get_wort_correction
from .utilities.hops import HopsUtilizationGlennTinseth
from .utilities.sugar import gu_to_sg
from .utilities.sugar import sg_to_gu
Expand Down Expand Up @@ -276,6 +278,17 @@ def get_final_gravity(self):
def fg(self):
return self.get_final_gravity()

def get_wort_correction(self, current_gu, current_volume,
efficiency=PPG_DME):
"""
Get the amount of sugar to add to correct the wort
"""
return get_wort_correction(current_gu,
current_volume,
self.get_original_gravity_units(),
self.final_volume,
efficiency=efficiency)

def get_degrees_plato(self):
"""
Get the degrees plato
Expand Down Expand Up @@ -625,6 +638,10 @@ def format(self, short=False):
kwargs = {}
kwargs.update(recipe_data)
kwargs.update(self.types)
# Additional format information
kwargs.update({
'evaporation': BOIL_EVAPORATION,
})

msg = u""
msg += textwrap.dedent(u"""\
Expand All @@ -635,7 +652,7 @@ def format(self, short=False):
Start Volume: {start_volume:0.1f}
Final Volume: {final_volume:0.1f}
Boil Gravity: {data[boil_gravity]:0.3f}
Boil Gravity: {data[boil_gravity]:0.3f} (Evaporation @ {evaporation:0.1%})
Original Gravity: {data[original_gravity]:0.3f}
Final Gravity: {data[final_gravity]:0.3f}
Expand Down
19 changes: 19 additions & 0 deletions brew/utilities/efficiency.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

from .sugar import sg_to_gu
from ..constants import PPG_DME

__all__ = [
u'calculate_brew_house_yield',
Expand All @@ -25,3 +26,21 @@ def calculate_brew_house_yield(wort_volume, sg, grain_additions):
"""
total_gu = sum([grain_add.gu for grain_add in grain_additions])
return (sg_to_gu(sg) * wort_volume) / total_gu


def get_wort_correction(boil_gravity, boil_volume,
final_gravity, final_volume,
efficiency=PPG_DME):
"""
Get amount of sugar to add to correct wort
Calculate how much additional DME or LME must be added to correct the boil
to hit target final gravity.
:param float boil_gravity: The gravity of the boil in GU
:param float boil_volume: The volume of the boil
:param float final_gravity: The desired final gravity in GU
:param float final_volume: The desired final volume
:param float efficiency: The efficiency of the medium to add
"""
return (final_gravity * final_volume - boil_gravity * boil_volume) / efficiency # noqa
2 changes: 1 addition & 1 deletion tests/test_recipes_imperial.py
Expand Up @@ -280,7 +280,7 @@ def test_format(self):
Start Volume: 7.0
Final Volume: 5.0
Boil Gravity: 1.054
Boil Gravity: 1.054 (Evaporation @ 0.0%)
Original Gravity: 1.076
Final Gravity: 1.019
Expand Down
2 changes: 1 addition & 1 deletion tests/test_recipes_si.py
Expand Up @@ -291,7 +291,7 @@ def test_format(self):
Start Volume: 26.5
Final Volume: 18.9
Boil Gravity: 1.054
Boil Gravity: 1.054 (Evaporation @ 0.0%)
Original Gravity: 1.076
Final Gravity: 1.019
Expand Down

0 comments on commit 85f8e86

Please sign in to comment.