Module: Beer
- Defined in:
- lib/beer.rb
Overview
beer.rb
A collection of formulas that are useful during beer (and wine) making.
- Author
-
Caleb Phillips <[email protected]>
- Version
-
2007.05.20
License
“THE BEER-WARE LICENSE” (Revision 42): Caleb Phillips <[email protected]> wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.
Constant Summary collapse
- E =
2.71828183
Instance Method Summary collapse
-
#aau(w, a) ⇒ Object
Calculate the AAU (Alpha Acid Units) contributed by a given hops addition, using the alpha percentage (like 6.5) and the weight in ounces.
-
#abv(og, fg) ⇒ Object
determine alchohol by volume using the difference between original and final gravity from: www.brew-monkey.com/brewschool/introtoextract.php.
-
#f_to_c(t) ⇒ Object
convert degrees fahrenheit to degrees celsius.
-
#g_to_sg(g) ⇒ Object
convert gravity to specific gravity.
-
#ibu(w, a, t, og_pt) ⇒ Object
Find the IBU (international bitterness units) in a beer given:.
-
#og_pt(og_cb, v_cb, v_pt) ⇒ Object
Determine original gravity of the wort in the brew kettle from the volume of the fermenter (v_cb), the gravity in the fermenter (og_cb) in gravity points (the 52 in 1.052 SG), and the volume of the pot (v_pt).
-
#pa_ucd(b, sg) ⇒ Object
determine potential alchohol using brix and specifig gravity of the original wort.
-
#sg_correction_c(t) ⇒ Object
Temperature correction for specific gravity for hydrometers calibrated at 59F.
-
#sg_to_b(sg) ⇒ Object
convert specific gravity to degrees brix.
-
#sg_to_g(sg) ⇒ Object
convert specific gravity to gravity.
-
#sg_to_p(sg) ⇒ Object
convert specific gravity to plato from: www.primetab.com/beer.c plato is the percentage of sucrose in a water sucrose solution.
-
#u(og, t) ⇒ Object
Calculate utilization percentage for a hop addition given the time of the boil and the gravity in the brew kettle at the time of addition.
Instance Method Details
#aau(w, a) ⇒ Object
Calculate the AAU (Alpha Acid Units) contributed by a given hops addition, using the alpha percentage (like 6.5) and the weight in ounces.
42 43 44 |
# File 'lib/beer.rb', line 42 def aau(w,a) w*a end |
#abv(og, fg) ⇒ Object
determine alchohol by volume using the difference between original and final gravity from: www.brew-monkey.com/brewschool/introtoextract.php
127 128 129 130 131 132 133 134 135 |
# File 'lib/beer.rb', line 127 def abv(og,fg) # convert to specific gravity if it looks # like we need it if (og > 2) or (fg > 2) og = g_to_sg(og) fg = g_to_sg(fg) end (og - fg)*131.25 end |
#f_to_c(t) ⇒ Object
convert degrees fahrenheit to degrees celsius
83 84 85 |
# File 'lib/beer.rb', line 83 def f_to_c(t) (t.to_f - 32)*(5.0/9.0) end |
#g_to_sg(g) ⇒ Object
convert gravity to specific gravity
88 89 90 |
# File 'lib/beer.rb', line 88 def g_to_sg(g) 1 + g*0.001 end |
#ibu(w, a, t, og_pt) ⇒ Object
Find the IBU (international bitterness units) in a beer given:
w - an Array of weights (in ounces) a - an Array of alpha percentages (like 6.5) t - an Array of times (in minutes)
For the various hop additions. Also,
og_pt - the original gravity of the wort in the brew kettle (in gravity points, the 52 in 1.052 SG)
57 58 59 60 61 62 63 64 65 |
# File 'lib/beer.rb', line 57 def ibu(w,a,t,og_pt) ret = 0 W.each_index{ |i| ret += u(OG_pt,T[i])*aau(W[i],A[i]) } ret = ret*75 ret = ret/V_cb ret end |
#og_pt(og_cb, v_cb, v_pt) ⇒ Object
Determine original gravity of the wort in the brew kettle from the volume of the fermenter (v_cb), the gravity in the fermenter (og_cb) in gravity points (the 52 in 1.052 SG), and the volume of the pot (v_pt)
27 28 29 |
# File 'lib/beer.rb', line 27 def og_pt(og_cb,v_cb,v_pt) (og_cb*v_cb)/v_pt end |
#pa_ucd(b, sg) ⇒ Object
determine potential alchohol using brix and specifig gravity of the original wort. This is the UC Davis “way” which accounts for some non-sugar fermentables. from: www.brsquared.org/wine/CalcInfo/HydSugAl.htm
120 121 122 |
# File 'lib/beer.rb', line 120 def pa_ucd(b,sg) ((b-3)*sg)*0.59 end |
#sg_correction_c(t) ⇒ Object
Temperature correction for specific gravity for hydrometers calibrated at 59F. Input is in degrees celsius. from: www.primetab.com/beer.c
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/beer.rb', line 71 def sg_correction_c(t) t = t.to_f if t < 3.98 -0.000032692*t - 0.000740644 elsif t < 50 -0.0008031922 - 0.0000473773*t + 0.000007231263*t*t - 0.00000003078278*t*t*t else -0.005431719 + 0.0001963596*t + 0.000002661056*t*t end end |
#sg_to_b(sg) ⇒ Object
convert specific gravity to degrees brix. degrees brix is the percentage of sugar. For instance 25 brix means 25 mg of 100 mg are sugar. See here for more info: en.wikipedia.org/wiki/Brix Formula from: www.brsquared.org/wine/CalcInfo/HydSugAl.htm
112 113 114 |
# File 'lib/beer.rb', line 112 def sg_to_b(sg) 220*(sg - 1) + 1.6 end |
#sg_to_g(sg) ⇒ Object
convert specific gravity to gravity
93 94 95 |
# File 'lib/beer.rb', line 93 def sg_to_g(sg) 1000*(sg-1) end |
#sg_to_p(sg) ⇒ Object
convert specific gravity to plato from: www.primetab.com/beer.c plato is the percentage of sucrose in a water sucrose solution. It was developed by Kurt Balling and Fritz Plato. More information here: en.wikipedia.org/wiki/Plato_scale
103 104 105 |
# File 'lib/beer.rb', line 103 def sg_to_p(sg) -676.67 + 1286.4*sg - 800.47*sg*sg + 190.74*sg*sg*sg end |
#u(og, t) ⇒ Object
Calculate utilization percentage for a hop addition given the time of the boil and the gravity in the brew kettle at the time of addition
34 35 36 37 |
# File 'lib/beer.rb', line 34 def u(og,t) og = (og.to_f)/1000 + 1 if og > 2 1.65*(0.000125**(og-1))*((1-(E**(-0.04*t)))/4.15) end |