src/Utils.cpp

changeset 375
c21567bfd703
parent 373
b02aca4e926c
child 380
8f5c03ed4321
equal deleted inserted replaced
374:74d541ac514c 375:c21567bfd703
396 double alpha = Alpha / 100.0; 396 double alpha = Alpha / 100.0;
397 double mass = Amount * 1000.0; 397 double mass = Amount * 1000.0;
398 double ibu = 0.0; 398 double ibu = 0.0;
399 399
400 /* 400 /*
401 * Most suppliers of CO2 hop extract (not isomerized) use formulas 401 * Basic Glenn Tinseth formula.
402 * like this. For now, manual set a utilisation factor of 35%. 402 * http://realbeer.com/hops/research.html
403 *
404 * kUtilisation was hardcoded as 4.15.
405 * It is now a formula since we need variable Utilisation values per hop.
406 * Default "normal" hops Utilisation is 20.
403 */ 407 */
404 if (Form == HOP_FORMS_CO2EXTRACT) { 408 double kUtilisation = 83.0 / Utilisation;
405 double utilisation = 0.35; // 35%
406 double factor_sg = 1.0;
407 double factor_bt = 1.0;
408 double bt = T2 - T1;
409
410 /* Table from Wildabouthops */
411 if (SG >= 1.150)
412 factor_sg = 1.3;
413 else if (SG >= 1.110)
414 factor_sg = 1.2;
415 else if (SG >= 1.080)
416 factor_sg = 1.1;
417
418 if (bt > 60) {
419 factor_bt = ((bt - 60) / 300) + 1.0;
420 } else {
421 factor_bt = (bt / 60.0);
422 }
423 qDebug() << "factor_sg" << factor_sg << "factor_bt" << factor_bt;
424
425 ibu = ((Utilisation / 100.0) * alpha * mass * 1000.0) / Volume;
426 ibu = (ibu * factor_bt) / factor_sg;
427 qDebug() << "TinsethIBU CO2" << Amount << Alpha << Volume << Utilisation << BU_factor << "SG" << SG << "T" << T1 << T2 << "ibu:" << ibu;
428 return ibu;
429 }
430
431 if (Form == HOP_FORMS_ISOEXTRACT) {
432
433 double dosageHl = ((100.0 / Utilisation) * (100.0 / Alpha) * 0.001) / BU_factor; // IBU per liter
434 qDebug() << (100 / Utilisation) << (100 / Alpha) << dosageHl << dosageHl * Volume << mass / (dosageHl * Volume);
435 ibu = mass / (dosageHl * Volume);
436 qDebug() << "TinsethIBU ISO" << Amount << Alpha << Volume << Utilisation << BU_factor << "ibu:" << ibu;
437 return ibu;
438 }
439
440 /*
441 * Basic Tinseth formula.
442 * http://realbeer.com/hops/research.html
443 */
444 double AddedAlphaAcids = (alpha * mass * 1000) / Volume; 409 double AddedAlphaAcids = (alpha * mass * 1000) / Volume;
445 double Bigness_factor = 1.65 * pow(0.000125, SG - 1); 410 double Bigness_factor = 1.65 * pow(0.000125, SG - 1);
446 double BoilTime_factor1 = ((1 - exp(-0.04 * T1)) / 4.15); 411 double BoilTime_factor1 = ((1 - exp(-0.04 * T1)) / kUtilisation);
447 double BoilTime_factor2 = ((1 - exp(-0.04 * T2)) / 4.15); 412 double BoilTime_factor2 = ((1 - exp(-0.04 * T2)) / kUtilisation);
448 ibu = Bigness_factor * (BoilTime_factor2 - BoilTime_factor1) * AddedAlphaAcids; 413 ibu = Bigness_factor * (BoilTime_factor2 - BoilTime_factor1) * AddedAlphaAcids;
449 qDebug() << "TinsethIBU nor" << SG << Amount << Alpha << Volume << Bigness_factor * (BoilTime_factor2 - BoilTime_factor1) << "ibu:" << ibu; 414 qDebug() << "TinsethIBU" << SG << Amount << Alpha << Volume << kUtilisation << Bigness_factor * (BoilTime_factor2 - BoilTime_factor1) << "ibu:" << ibu;
450 415
451 /* 416 /*
452 * Correction for hop forms 417 * Correction for hop forms
453 */ 418 */
454 if (Form == HOP_FORMS_PELLET) { 419 if (Form == HOP_FORMS_PELLET) {
594 } else if (Use == HOP_USEAT_BOTTLING) { 559 } else if (Use == HOP_USEAT_BOTTLING) {
595 /* 560 /*
596 * Isomerized hop extracts to use at bottling. 561 * Isomerized hop extracts to use at bottling.
597 * Assume 10% volume is lost during fermentation and transfers. 562 * Assume 10% volume is lost during fermentation and transfers.
598 */ 563 */
599 ibu = TinsethIBU(Form, postSG, Volume * 0.9, Amount, 0, 0, Alpha, Utilisation, BU_factor); 564 if (Form == HOP_FORMS_ISOEXTRACT) {
565 /*
566 * ISO-alpha-extract hops, Tetra etc.
567 */
568 double dosageHl = ((100.0 / Utilisation) * (100.0 / Alpha) * 0.001) / BU_factor; // IBU per liter
569 ibu = (Amount * 1000.0) / (dosageHl * Volume * 0.9);
570 qDebug() << "ISO extract" << Amount << Alpha << Volume * 0.9 << Utilisation << BU_factor << "ibu:" << ibu;
571 }
600 } 572 }
601 573
602 double rc = round(ibu * 1000.0) / 1000.0; 574 double rc = round(ibu * 1000.0) / 1000.0;
603 575
604 qDebug() << "toIBU" << Use << Form << preSG << postSG << Volume << Amount << Boiltime << Alpha << Method << Whirlpool9 << Whirlpool7 << Whirlpool6 << Fulltime << Cooltype << Coolparm1 << Coolparm2 << Utilisation << BU_factor << "rc:" << rc; 576 qDebug() << "toIBU" << Use << Form << preSG << postSG << Volume << Amount << Boiltime << Alpha << Method << Whirlpool9 << Whirlpool7 << Whirlpool6 << Fulltime << Cooltype << Coolparm1 << Coolparm2 << Utilisation << BU_factor << "rc:" << rc;

mercurial