beer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/beer.rb +137 -0
- metadata +46 -0
data/lib/beer.rb
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
#
|
2
|
+
# = beer.rb
|
3
|
+
#
|
4
|
+
# A collection of formulas that are
|
5
|
+
# useful during beer (and wine) making.
|
6
|
+
#
|
7
|
+
# Author:: Caleb Phillips <cphillips@smallwhitecube.com>
|
8
|
+
# Version:: 2007.05.20
|
9
|
+
#
|
10
|
+
# == License
|
11
|
+
#
|
12
|
+
# "THE BEER-WARE LICENSE" (Revision 42):
|
13
|
+
# Caleb Phillips <cphillips@smallwhitecube.com> wrote this file.
|
14
|
+
# As long as you retain this notice you can do whatever you want
|
15
|
+
# with this stuff. If we meet some day, and you think this stuff
|
16
|
+
# is worth it, you can buy me a beer in return.
|
17
|
+
|
18
|
+
module Beer
|
19
|
+
|
20
|
+
E=2.71828183
|
21
|
+
|
22
|
+
# Determine original gravity of the wort
|
23
|
+
# in the brew kettle from the volume of
|
24
|
+
# the fermenter (v_cb), the gravity in
|
25
|
+
# the fermenter (og_cb) in gravity points (the 52 in 1.052 SG),
|
26
|
+
# and the volume of the pot (v_pt)
|
27
|
+
def og_pt(og_cb,v_cb,v_pt)
|
28
|
+
(og_cb*v_cb)/v_pt
|
29
|
+
end
|
30
|
+
|
31
|
+
# Calculate utilization percentage for a hop
|
32
|
+
# addition given the time of the boil and the
|
33
|
+
# gravity in the brew kettle at the time of addition
|
34
|
+
def u(og,t)
|
35
|
+
og = (og.to_f)/1000 + 1 if og > 2
|
36
|
+
1.65*(0.000125**(og-1))*((1-(E**(-0.04*t)))/4.15)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Calculate the AAU (Alpha Acid Units) contributed by
|
40
|
+
# a given hops addition, using the alpha percentage (like 6.5)
|
41
|
+
# and the weight in ounces.
|
42
|
+
def aau(w,a)
|
43
|
+
w*a
|
44
|
+
end
|
45
|
+
|
46
|
+
# Find the IBU (international bitterness units) in
|
47
|
+
# a beer given:
|
48
|
+
#
|
49
|
+
# w - an Array of weights (in ounces)
|
50
|
+
# a - an Array of alpha percentages (like 6.5)
|
51
|
+
# t - an Array of times (in minutes)
|
52
|
+
#
|
53
|
+
# For the various hop additions. Also,
|
54
|
+
#
|
55
|
+
# og_pt - the original gravity of the wort in the brew
|
56
|
+
# kettle (in gravity points, the 52 in 1.052 SG)
|
57
|
+
def ibu(w,a,t,og_pt)
|
58
|
+
ret = 0
|
59
|
+
W.each_index{ |i|
|
60
|
+
ret += u(OG_pt,T[i])*aau(W[i],A[i])
|
61
|
+
}
|
62
|
+
ret = ret*75
|
63
|
+
ret = ret/V_cb
|
64
|
+
ret
|
65
|
+
end
|
66
|
+
|
67
|
+
# Temperature correction for specific gravity
|
68
|
+
# for hydrometers calibrated at 59F. Input is
|
69
|
+
# in degrees celsius.
|
70
|
+
# from: http://www.primetab.com/beer.c
|
71
|
+
def sg_correction_c(t)
|
72
|
+
t = t.to_f
|
73
|
+
if t < 3.98
|
74
|
+
-0.000032692*t - 0.000740644
|
75
|
+
elsif t < 50
|
76
|
+
-0.0008031922 - 0.0000473773*t + 0.000007231263*t*t - 0.00000003078278*t*t*t
|
77
|
+
else
|
78
|
+
-0.005431719 + 0.0001963596*t + 0.000002661056*t*t
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# convert degrees fahrenheit to degrees celsius
|
83
|
+
def f_to_c(t)
|
84
|
+
(t.to_f - 32)*(5.0/9.0)
|
85
|
+
end
|
86
|
+
|
87
|
+
# convert gravity to specific gravity
|
88
|
+
def g_to_sg(g)
|
89
|
+
1 + g*0.001
|
90
|
+
end
|
91
|
+
|
92
|
+
# convert specific gravity to gravity
|
93
|
+
def sg_to_g(sg)
|
94
|
+
1000*(sg-1)
|
95
|
+
end
|
96
|
+
|
97
|
+
# convert specific gravity to plato
|
98
|
+
# from: http://www.primetab.com/beer.c
|
99
|
+
# plato is the percentage of sucrose in a water
|
100
|
+
# sucrose solution. It was developed by Kurt Balling
|
101
|
+
# and Fritz Plato. More information here:
|
102
|
+
# http://en.wikipedia.org/wiki/Plato_scale
|
103
|
+
def sg_to_p(sg)
|
104
|
+
-676.67 + 1286.4*sg - 800.47*sg*sg + 190.74*sg*sg*sg
|
105
|
+
end
|
106
|
+
|
107
|
+
# convert specific gravity to degrees brix. degrees brix
|
108
|
+
# is the percentage of sugar. For instance 25 brix means
|
109
|
+
# 25 mg of 100 mg are sugar. See here for more info:
|
110
|
+
# http://en.wikipedia.org/wiki/Brix
|
111
|
+
# Formula from: http://www.brsquared.org/wine/CalcInfo/HydSugAl.htm
|
112
|
+
def sg_to_b(sg)
|
113
|
+
220*(sg - 1) + 1.6
|
114
|
+
end
|
115
|
+
|
116
|
+
# determine potential alchohol using brix and specifig gravity
|
117
|
+
# of the original wort. This is the UC Davis "way" which accounts
|
118
|
+
# for some non-sugar fermentables.
|
119
|
+
# from: http://www.brsquared.org/wine/CalcInfo/HydSugAl.htm
|
120
|
+
def pa_ucd(b,sg)
|
121
|
+
((b-3)*sg)*0.59
|
122
|
+
end
|
123
|
+
|
124
|
+
# determine alchohol by volume using the difference between
|
125
|
+
# original and final gravity
|
126
|
+
# from: http://www.brew-monkey.com/brewschool/introtoextract.php
|
127
|
+
def abv(og,fg)
|
128
|
+
# convert to specific gravity if it looks
|
129
|
+
# like we need it
|
130
|
+
if (og > 2) or (fg > 2)
|
131
|
+
og = g_to_sg(og)
|
132
|
+
fg = g_to_sg(fg)
|
133
|
+
end
|
134
|
+
(og - fg)*131.25
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.3
|
3
|
+
specification_version: 1
|
4
|
+
name: beer
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2007-05-20 00:00:00 -07:00
|
8
|
+
summary: Formulas and Tools for Homebrewing
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: cphillips@smallwhitecube.com
|
12
|
+
homepage: http://svn.smallwhitecube.com/beer/trunk
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire: beer
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Caleb Phillips
|
31
|
+
files:
|
32
|
+
- lib/beer.rb
|
33
|
+
test_files: []
|
34
|
+
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
extra_rdoc_files: []
|
38
|
+
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
requirements: []
|
44
|
+
|
45
|
+
dependencies: []
|
46
|
+
|