Last active
December 16, 2015 10:59
-
-
Save thearn/5424289 to your computer and use it in GitHub Desktop.
A simple command-line app to help profile homebrew'ed beer. User inputs starting temperature, starting original gravity, and the app will compute and print temperature-adjusted original gravity and max potential ABV. Final (post-fermentation) temperature and specific-gravity can also be input to calculate effective ABV, calories per serving, and…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def adjust(t, og): | |
t2 = 1.34722124e-4 * t | |
t3 = 2.04052596e-6 * t ** 2 | |
t4 = 2.32820948e-9 * t ** 3 | |
sgcf = 1.00130346 - t2 + t3 - t4 | |
sg = og * sgcf | |
adjusted_og = sg | |
OE = -668.962 + 1262.45 * sg - 776.43 * sg * sg + 182.94 * sg * sg * sg | |
abv_max = (sg - 1) * 105 * 1.25 | |
return adjusted_og, OE, abv_max | |
def profile(t1, t2, og, fg): | |
adjusted_og, OE, abv_max1 = adjust(t1, og) | |
adjusted_fg, AE, abv_max2 = adjust(t2, fg) | |
q = .22 + 0.001 * OE | |
RE = (q * OE + AE) / (1 + q) | |
RA = (OE - RE) / OE * 100 | |
abw = (OE - RE) / (2.0665 - 0.010665 * OE) | |
abv = abw * adjusted_fg / 0.794 | |
cal = 3.55 * adjusted_fg * (4.08 * RE + 7.1 * abw) | |
return adjusted_fg, RE, RA, abw, abv, cal | |
if __name__ == "__main__": | |
t1 = float(raw_input("Starting temp. (F): ")) | |
og = float(raw_input("Original specific gravity (OG): ")) | |
adjusted_og, OE, abv_max = adjust(t1, og) | |
print "Adjusted OG: ", adjusted_og | |
print "Original extract: ", OE, "%" | |
print "Maximum potential ABV: ", abv_max, "%" | |
t2 = float(raw_input("Final temp. (F): ")) | |
fg = float(raw_input("Final specific gravity (FG): ")) | |
adjusted_fg, RE, RA, abw, abv, cal = profile(t1, t2, og, fg) | |
print "Adjusted FG: ", adjusted_fg | |
print "Real extract: ", RE, "%" | |
print "Real attenuation: ", RA, "%" | |
print "Alcohol (by weight) : ", abw, "%" | |
print "Alcohol (by volume) : ", abv, "%" | |
print "Calories (12 fl oz.): ", cal | |
raw_input("Press return to quit.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like this idea, don't understand it though..