Skip to content

DapperBrew/DapperCalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DapperCalc

DapperCalc contains various calculations that power DapperBrew. This work is ongoing. Calculations may be incomplete, or incorrect.

TODO

  • abv
  • abw
  • plato2sg
  • sg2plato
  • aau
  • utilization
  • ibu
  • mcu
  • srm
  • sg2gp
  • gp2sg
  • real extract
  • calories
  • apparent attenuation
  • real attenuation
  • dilution calc
  • specific gravity to gravity pnits
  • water addition
  • malt addition
  • shrinkage
  • evapPerHour
  • totalBoilLoss
  • postBoilVolume
  • postBoilGravity
  • weight to volume
  • shrinkage
  • refractometer reading adjustment
  • hydromteter temp adjust
  • yeast starter

Modules

sg2platonumber

Convert specific gravity (sg) to plato

plato2sgnumber

Convert plato to specific gravity (sg)

originalExtractnumber

Calculate original extract from original gravity.

apparentExtractnumber

Calculate apparent extract from final gravity.

attenuationCoefficientnumber

Calculate attenuation coefficient from original extract.

realExtractnumber

Calculate real extract from starting gravity & final gravity.

abwnumber

Calculates the Alcohol by weight (ABW)

abvnumber

Calculates the alcohol by volume (abv)

caloriesAlcoholnumber

Calculate number of calories from Alcohol in 12oz serving.

caloriesCarbsnumber

Calculate number of calories from carbs in 12oz serving.

caloriesTotalnumber

Calculate number of calories in 12oz serving.

aAttenuationnumber

Calculate the apparent attenuation

rAttenuationnumber

Calculate the real attenuation

aaunumber

Calculate Alpha Acid Units

utilizationnumber

Hop Utilization (Tinseth)

ibunumber

Calculate IBU for hop addition (Tinseth / pellets)

srm2lovibondnumber

SRM to Lovibond

lovibond2srmnumber

Lovibond to SRM

mcunumber

Calculate Malt Color Units

srm.number

Calculates color (SRM) of eer using standard reference method (Morey equation)

sg2gpnumber

Convert specific gravity (sg) to gravity points.

gp2sgnumber

Convert gravity points to specific gravity (sg)

dilutenumber

Calculate new SG when wort is diluted

adjustWaternumber

Calculate water needed to reach target gravity.

adjustExtractnumber

Calculate how much extract (in lb) is needed to reach target gravity.

evapLossPerHournumber

Calculate how much volume (gallons) is lost per hour to evaperation

totalBoilLossnumber

Calculate total volume (gallons) lost during boil to evaperation

shrinkagenumber

Volume lost after wort cools (in gallons)

postBoilVolumenumber

Calculate post boil volume (gallons)

postBoilGravitynumber

Calculate post boil gravity.

estimateOriginalGravitynumber

Estimate Original Gravity

estimateFinalGravitynumber

Estimate Final Gravity Points

estimateFinalGravitynumber

Estimate Final Gravity (adjusted for simple sugars & mash temp)

sg2plato ⇒ number

Convert specific gravity (sg) to plato

Returns: number - (-616.868) + (1111.14 x sg) - (630.272 x sg^2) + (135.997 x sg^3)

Param Type Description
sg number the specific gravity (sg)

Example

// returns 21.1
sg2plato(1.088);

plato2sg ⇒ number

Convert plato to specific gravity (sg)

Returns: number - plato / (258.6 -((plato / 258.2) x 227.1)) + 1

Param Type Description
plato number plato number to be converted

Example

// returns 1.074
plato2sg(18);

originalExtract ⇒ number

Calculate original extract from original gravity.

Returns: number - OE = -668.962 + (1262.45 * OG ) - (776.43 * OG^2) + (182.94 * OG^3)
See: Dr. Michael Hall article, Zymurgy, Summer 1995

Param Type Description
og number original gravity (og)

Example

// returns 21.1
originalExtract(1.088);

apparentExtract ⇒ number

Calculate apparent extract from final gravity.

Returns: number - AE = -668.962 + (1262.45 * FG ) - (776.43 * FG^2) + (182.94 * FG^3)
See: Dr. Michael Hall article, Zymurgy, Summer 1995

Param Type Description
fg number final gravity (fg)

Example

// returns 3.07
apparentExtract(1.012);

attenuationCoefficient ⇒ number

Calculate attenuation coefficient from original extract.

Returns: number - q = .22 + (.001 * OE)
See: Dr. Michael Hall article, Zymurgy, Summer 1995

Param Type Description
oe number original extract (oe)

Example

// returns 3.07
attenuationCoefficient(21.1);

realExtract ⇒ number

Calculate real extract from starting gravity & final gravity.

Returns: number - RE = ((q * OE) + AE) / (1 + q)
See

  • Dr. Michael Hall article, Zymurgy, Summer 1995
  • (not currently used) hbd.org/ensmingr
Param Type Description
og number original gravity (og)
fg number final gravity (fg)

Example

// returns 6.5697
realExtract(1.088, 1.012);

abw ⇒ number

Calculates the Alcohol by weight (ABW)

Returns: number - (abv x 0.79336) / fg

Param Type Description
og number The original gravity (og)
fg number The final gravity (nfg)

Example

// returns 7.23
abw(1.088, 1.019);

abv ⇒ number

Calculates the alcohol by volume (abv)

Returns: number - abw * (FG / .749);

Param Type Description
og number original gravity (og)
fg number final gravity (fg)

Example

// returns 10.2
abv(1.089, 1.012);

caloriesAlcohol ⇒ number

Calculate number of calories from Alcohol in 12oz serving.

Returns: number - 1881.22 * fg * ((og - fg) / (1.775 - og))
See: www.homebrewersassociation.org

Param Type Description
og number original gravity (og)
fg number final gravity (fg)

Example

// returns 210.61
caloriesAlcohol(1.088, 1.012);

caloriesCarbs ⇒ number

Calculate number of calories from carbs in 12oz serving.

Returns: number - 3550.0 * fg * ((0.1808 * og) + ((0.8192 * fg) - 1.0004))
See: www.homebrewersassociation.org

Param Type Description
og number original gravity (og)
fg number final gravity (fg)

Example

// returns 91.04
caloriesCarbs(1.088, 1.012);

caloriesTotal ⇒ number

Calculate number of calories in 12oz serving.

Returns: number - calories from alcohol + calories from carbs
See: www.homebrewersassociation.org

Param Type Description
og number original gravity (og)
fg number final gravity (fg)

Example

// returns 301.65
caloriesTotal(1.088, 1.012);

aAttenuation ⇒ number

Calculate the apparent attenuation

Returns: number - 100 x (1 - (°Pf / °Pi))
See: hbd.org/ensmingr

Param Type Description
og number original gravity (og)
fg number final gravity (fg)

Example

// return 85.3
aAttenuation(1.088, 1.012);

rAttenuation ⇒ number

Calculate the real attenuation

Returns: number - 100 x (1 - (real extract / °Pi)
See: hbd.org/ensmingr

Param Type Description
og number original gravity (og)
fg number final gravity (fg)

Example

// return 68.9
rAttenuation(1.088, 1.012);

aau ⇒ number

Calculate Alpha Acid Units

Returns: number - weight x Alpha Acid Percentage
Todo

  • Add imperial unit option (grams)
Param Type Description
weight number weight of hops (in oz)
aa number Alpha Acidic percentage

Example

// returns 18
aau(1.5, 12);

utilization ⇒ number

Hop Utilization (Tinseth)

Returns: number - utilization = bigness factor x boil time factor
See: realbeer.com
Todo

  • Add rager scale option
Param Type Description
time number time left in boil (minutes)
gravity number Specific gravity (sg) of pre-boil wort

Example

// returns 0.2348476097710606
utilization(60, 1.048);

ibu ⇒ number

Calculate IBU for hop addition (Tinseth / pellets)

Returns: number - (aau x utilization x 74.89) / volume
See: howtobrew.com/
Todo

  • allow for grams for hops
  • allow for liter for volume
  • allow for rager scale
  • allow for whole hops
Param Type Description
weight number Weight of hops (oz)
aa number Alpha acids percentage of hops
time number time left in boil (minutes)
gravity number Specific Gravity of wort (pre-boil)
volume number post boil volume (gallons)
adjust number percentage to adjust hop utilization

Example

// returns 63.3
ibu(1.5, 12, 60, 1.048, 5.5);

srm2lovibond ⇒ number

SRM to Lovibond

Returns: number - Lovibond = (SRM + 0.76) / 1.3546
See: https://en.wikipedia.org/wiki/Standard_Reference_Method

Param Type Description
srm number SRM # to be converted

Example

// return 6.5
srm2lovibond(8);

// return 22.7
srm2lovibond(30);

lovibond2srm ⇒ number

Lovibond to SRM

Returns: number - SRM = (1.3546 × lovibond) - 0.76
See: https://en.wikipedia.org/wiki/Standard_Reference_Method

Param Type Description
srm number Lovibond # to be converted

Example

// return 8.7
lovibond2srm(7);

// return 30.4
lovibond2srm(23);

mcu ⇒ number

Calculate Malt Color Units

Returns: number - (weight * lovibond) / volume
Todo

  • support kg for weight
  • support liter for volume
Param Type Description
weight number weight of grain/fermentable (in lb)
lovibond number color of grains in lovibond
volume number batch size (in gallons) including deadspace/trub loss

Example

// return 5.727
mcu(9, 3.5, 5.5);

srm. ⇒ number

Calculates color (SRM) of eer using standard reference method (Morey equation)

Returns: number - 1.4922 x (MCU ^ 0.6859)

Param Type Description
...mcuNum number MCU units to covert to SRM. Accepts infinite # of arguments.

Example

// returns 4.9
srm(5.72);

// returns 6.4
srm(5.72, 2.54);

sg2gp ⇒ number

Convert specific gravity (sg) to gravity points.

Returns: number - (sg - 1) x 1000

Param Type Description
sg number The specific gravity (sg)

Example

// return 88
sg2gp(1.088);

gp2sg ⇒ number

Convert gravity points to specific gravity (sg)

Returns: number - (gravity points / 1000) + 1

Param Type Description
gp number Gravitiy points

Example

// return 1.088
gp2sg(88);

dilute ⇒ number

Calculate new SG when wort is diluted

Returns: number - (returns SG) GP = (Initial Volume * initial GP) / New Total Volume

Param Type Description
sg number Specific Gravity of pre-diluted wort
volume number initial volume
volumeAdd number Volume of water to add

Example

// return 1.046
dilute(1.054, 6, 1);

adjustWater ⇒ number

Calculate water needed to reach target gravity.

Returns: number - (volume x sg / target gravity points) - volume
Todo

  • support liters for input volume
  • support liters for return
Param Type Description
sg number Current/Specific gravity (sg)
tg number Target gravity
volume number current volume (gallons)

Example

// return .64
adjustWater(1.088, 1.078, 5);

adjustExtract ⇒ number

Calculate how much extract (in lb) is needed to reach target gravity.

Returns: number - lb = (target gravity - sg) x volume / extract gravity points
Todo

  • support liters for input volume.
  • support kilograms for output volume
Param Type Description
sg number Current / specific gravity (sg)
tg number target gravity
volume number volume (gallons)
extract string | number 'DME', 'LME', or custom gravity point value.

Example

// return 1.39
adjustExtract(1.078, 1.088, 5, 'LME');

// return 1.14
adjustExtract(1.078, 1.088, 5, 'DME');

// return 1.14
adjustExtract(1.078, 1.088, 5, 46);

evapLossPerHour ⇒ number

Calculate how much volume (gallons) is lost per hour to evaperation

Returns: number - volume x (percentage lost per hour / 100)
Todo

  • option for input volume to be liters
  • option for output volume to be liters
Param Type Default Description
volume number pre-boil volume (gallons)
ratePerHour number percentage or voluem lost per hour
[rateMeasurement] string "percentage" set rate measurement to 'percentage' or 'volume'

Example

// return 0.60
evapPerHour(6, 10);

// return 0.60
evapPerHour(6, 10, 'percentage');

// return 0.50
evapPerHour(6, .5, 'volume');

totalBoilLoss ⇒ number

Calculate total volume (gallons) lost during boil to evaperation

Returns: number - evapLossPerHour x (boilTime / 60)
Todo

  • support volume input in liters
  • support volume output in liters
Param Type Description
lossPerHour number amount of volume (in lb) lost per hour to evaperation
boilTime number length of boil (in minutes)

Example

// return 0.90
totalBoilLoss(.60, 90);

shrinkage ⇒ number

Volume lost after wort cools (in gallons)

Returns: number - volume x (percentage/100)
Todo

  • support input volume in liters
  • support return volume in liters
  • support boilLoss in liters
Param Type Default Description
volume number pre-boil volume (gallons)
boilLoss number Amount of volume (gallons) lost to boil.
[percentage] number 4 percentage the wort shrinks due to cooling

Example

// return 0.24
shrinkage(7, 0.90);

// return 0.15
shrinkage(7, 0.90, 3);

postBoilVolume ⇒ number

Calculate post boil volume (gallons)

Returns: number - start_volume - (boil_loss + shrink_loss)
Todo

  • support input startVal in liters
  • support input boilLoss in liters
  • support input shrinkLoss in liters
  • support return value in liters
Param Type Description
startVol number Starting volume pre-boil (gallons)
boilLoss number volume loss to boil (gallons)
shrinkLoss number volume loss to shrinking during cooling (gallons)

Example

// return 6.86
postBoilVolume(7, 0.90, 0.24)

postBoilGravity ⇒ number

Calculate post boil gravity.

Returns: number - (starting_volume x gravity_points) / final_volume
Todo

  • support starting volume in liters
  • support final volume in liters
Param Type Description
startVol number Starting volume (gallons)
sg number starting gravity (sg)
finalVol number Final volume (gallons)

Example

// return 1.072
postBoilGravity(7, 1.059, 5.71)

estimateOriginalGravity ⇒ number

Estimate Original Gravity

Returns: number - (gravityPoints * efficiency) / volume
Todo

  • support liters
Param Type Description
gravityPoints number Total gravity points of fermentables
sugarPoints number Total gravity points from sugars (dextrose, etc)
efficiency number (mash or brewhouse)
vol number into fermentor (if brewhouse eff) or pre-boil vol (if mash eff)

Example

// return 1.061
estimateOriginalGravity(429, 46, 75, 6)

estimateFinalGravity ⇒ number

Estimate Final Gravity Points

Returns: number - Final GP = (1 - (attenuation)) * gravityPoints
Todo

  • allow to adjust center temp & slope %
Param Type Description
attenuation number Attenuiation % from yeast
gravityPoints number Gravity points
rounded bool if return value should be rounded (optional)

Example

// return 13.5
estimateFinalGravity(75, 54)

// return 14
estimateFinalGravity(75, 54, true)

estimateFinalGravity ⇒ number

Estimate Final Gravity (adjusted for simple sugars & mash temp)

Returns: number - FG = (1 - (attenuation x .01)) * GP

Param Type Description
grainPoints number Total gravity points from grains (exclude sugars like dextrose)
sugarPoints number Total gravity points from sugars (dextrose, etc)
attenuation number % from yeast
mashTemp number (optional)

Example

// return 1.061
estimateFinalGravity(54, 17, 75, 154)

About

JS Calculations for DapperBrew

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published