From 788a319d1acfba8da081480dfe9e0aa950b473dd Mon Sep 17 00:00:00 2001 From: Erik Hetzner Date: Thu, 12 Nov 2009 23:21:48 -0800 Subject: [PATCH] add ability to change malt specific heat; add brew2F, org-food -> org-cook --- brew-calc.el | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/brew-calc.el b/brew-calc.el index a8e7925..79b562e 100644 --- a/brew-calc.el +++ b/brew-calc.el @@ -21,9 +21,10 @@ ;; calc functions for brewing (provide 'brew-calc) +(require 'calc) (require 'org-cook) -(org-food-alist-append 'math-additional-units +(org-cook-alist-append 'math-additional-units '((degPlato nil "Degrees Plato"))) (setq math-units-table nil) @@ -32,6 +33,19 @@ "Get the norm of a value with units." (math-simplify (math-remove-units v))) +(defmath brew2F (temp) + "Ensure that a temperature is in degF." + (let ((old-units (math-units-in-expr-p temp t))) + (math-simplify + (cond ((not old-units) + (error "Not a temperature.")) + ((eq (car old-units) 'degF) + temp) + ((eq (car old-units) 'degC) + (math-convert-temperature temp '(var degC var-degC) '(var degF var-degF))) + ((eq (car old-units) 'K) + (math-convert-temperature temp '(var K var-K) '(var degF var-degF))))))) + (defmath brew2C (temp) "Ensure that a temperature is in degC." (let ((old-units (math-units-in-expr-p temp t))) @@ -57,7 +71,6 @@ temp) ((eq (car old-units) 'degF) (math-convert-temperature temp '(var degF var-degF) '(var K var-K))))))) - (defmath brew2MG_L (expr) "Ensure that a mass / vol is in mg / L." @@ -288,3 +301,22 @@ priming." (math-simplify (brewGramsGlucoseNeeded (* (- final-level current-level) volume)))))) + +(defvar brew-calc-malt-default-specific-heat + (math-read-number "0.40") + "The default value for the specific heat of malt; can vary from +0.38 to 0.42 depending on moisture.") + +(defmath brewCalcStrike (temp water-vol malt) + (brewCalcStrikeFull temp water-vol malt brew-calc-malt-default-specific-heat)) + +(defmath brewCalcStrikeFull (temp1 water-vol malt malt-sh) + (let* ((temp (brew2K temp1)) + (water (* water-vol (/ '(var kg var-kg) '(var L var-L)))) + (water-sh 1) + (room-temp (brew2K (* 74 '(var degF var-degF))))) + (brew2F (math-simplify-units + (/ (- (* temp (+ (* water water-sh) + (* malt malt-sh))) + (* room-temp (* malt malt-sh))) + (* water-sh water)))))) -- 2.11.4.GIT