Skip to content

Instantly share code, notes, and snippets.

@jvanderhoof
Created June 9, 2010 01:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvanderhoof/430905 to your computer and use it in GitHub Desktop.
Save jvanderhoof/430905 to your computer and use it in GitHub Desktop.
# some experimentation around generating OG, IBU, & SRM for based on beer ingredients
grains = [{:name => 'Liquid Malt Extract', :amount => 6, :measurement => 'lbs', :efficency => 1, :ppg => 36, :color => 4},
{:name => 'Crystal Malt 60L', :amount => 1, :measurement => 'lbs', :efficency => 0.85, :ppg => 34, :color => 60}]
hops = [{:name => 'Fuggles', :amount => 2, :measurement => 'oz', :aau => 3.6, :time => 30},
{:name => 'Willamette', :amount => 1, :measurement => 'oz', :aau => 4.3, :time => 10}]
total_size = 5
boil_size = 3
total_ppg = 0
total_color = 0
ibu = 0
grains.each do |i|
total_ppg += (i[:amount] * i[:ppg] * i[:efficency])
total_color += (i[:color] * i[:amount]/total_size)
end
srm = (1.4922 * (total_color**0.6859)).round
orginal_gravity = 1 + (total_ppg/total_size).round.to_f/1000
boil_gravity = 1 + (total_ppg/boil_size).round.to_f/1000
e = 2.718281828459045
hops.each {|i| ibu += (((i[:amount] * i[:aau]) * 75 * ((1.65*0.000125**(boil_gravity - 1)) * (1-e**(-0.04*i[:time]))/4.15))/total_size).round }
puts "og: #{orginal_gravity}"
puts "bg: #{boil_gravity}"
puts "ibu: #{ibu}"
puts "srm: #{srm}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment