194 return srm_to_ebc(kw_to_srm($colormethod, $c)); |
194 return srm_to_ebc(kw_to_srm($colormethod, $c)); |
195 } |
195 } |
196 |
196 |
197 |
197 |
198 |
198 |
|
199 function calc_IBU($useat, $form, $sg, $volume, $mass, $boiltime, $alpha, $method) { |
|
200 |
|
201 $fmoment = 1.0; |
|
202 if (($useat == "Dry Hop") || ($useat == "Dry hop") || ($useat == "Whirlpool") || ($useat == "Aroma")) { |
|
203 $fmoment = 0.0; |
|
204 } else if ($useat == "Mash") { |
|
205 $fmoment += /* Settings.MashHopFactor.Value = -30% */ -30 / 100; // Brouwhulp |
|
206 } else if (($useat == "First Wort") || ($useat == "First wort")) { |
|
207 $fmoment += /* Settings.FWHFactor.Value = 10% */ 10 / 100; // Brouwhulp, Louis, Ozzie |
|
208 } |
|
209 |
|
210 $pfactor = 1.0; |
|
211 if ($form == "Pellet") { |
|
212 $pfactor += /* Settings.PelletFactor.Value = 10% */ 10 / 100; |
|
213 } |
|
214 if ($form == "Plug") { |
|
215 $pfactor += /* Settings.PlugFactor.Value = 2% */ 2 / 100; |
|
216 } |
|
217 |
|
218 $ibu = 0; |
|
219 if (($method == "Tinseth") || ($method == "Garetz")) { // For Garetz, we need the $ibu |
|
220 $AddedAlphaAcids = (($alpha / 100) * $mass * 1000) / $volume; |
|
221 $Bigness_factor = 1.65 * pow( 0.000125, $sg - 1); |
|
222 $BoilTime_factor = ((1 - exp(-0.04 * $boiltime)) / 4.15); |
|
223 $utiisation = $Bigness_factor * $BoilTime_factor; |
|
224 $ibu = (round($utiisation * $AddedAlphaAcids * $fmoment * $pfactor * 10) / 10.0); |
|
225 } |
|
226 if ($method == "Daniels") { |
|
227 |
|
228 if ($form == "Leaf") |
|
229 $boilfactor = -(0.0041*$boiltime*$boiltime)+(0.6162*$boiltime)+1.5779; |
|
230 else |
|
231 $boilfactor = -(0.0051*$boiltime*$boiltime)+(0.7835*$boiltime)+1.9348; |
|
232 if ($sg < 1.050) |
|
233 $sgfactor = 0; |
|
234 else |
|
235 $sgfactor = (($sg * 1000) - 1050) / 200; |
|
236 $ibu = $fmoment * (($mass * $alpha * $boilfactor * 0.1) / ($volume * (1 + $sgfactor))); |
|
237 } |
|
238 if ($method == "Rager") { |
|
239 $boilfactor = $fmoment * 18.11 + 13.86 * tanh(($boiltime * 31.32) / 18.27); |
|
240 if ($sg < 1.050) |
|
241 $sgfactor = 0; |
|
242 else |
|
243 $sgfactor = (($sg * 1000) - 1050) / 200; |
|
244 $ibu = ($mass * $alpha * $boilfactor * 0.1) / ($volume * (1 + $sgfactor)); |
|
245 } |
|
246 if ($method == "Garetz") { |
|
247 /* Something is wrong, late hops and dryhops give negative results. */ |
|
248 $boilfactor = $fmoment * 6.03253 + 16.5289 * tanh(($boiltime - 19.17323) / 26.8013); |
|
249 $cfactor = $volume / (1.1 * $volume); // ConcentratieFactor = (Volume na koelen) / (Volume bij Koken) |
|
250 $kookdichtheid = ($cfactor * (($sg * 1000) - 1000) / 1000) + 1; |
|
251 $sgfactor = ($kookdichtheid - 1.05) / 0.2 + 1; |
|
252 $hopratefactor = (($cfactor * $ibu) / 260) + 1; // $ibu is Tinseth bitterness. Weird. |
|
253 $tempfactor = (32.8/550)*0.02+1; |
|
254 $ibu = ($boilfactor * $alpha * $mass * 0.1) / ($volume * $sgfactor * $hopratefactor * $tempfactor); |
|
255 } |
|
256 /* TODO: Noonan and Mosher */ |
|
257 |
|
258 return $ibu; |
|
259 } |
|
260 |
|
261 |
199 /* |
262 /* |
200 |
263 |
201 Brouwhulp data.pas |
264 Brouwhulp data.pas |
202 |
265 |
203 Function THop.FlavourContribution : double; //in % * concentration in g/l |
266 Function THop.FlavourContribution : double; //in % * concentration in g/l |