Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tools for correcting wort during boil #20

Merged
merged 6 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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