Mon, 11 Apr 2022 20:45:22 +0200
Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
20
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Utils.cpp is part of bmsapp. |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * bmsapp is free software: you can redistribute it and/or modify |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * it under the terms of the GNU General Public License as published by |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * the Free Software Foundation, either version 3 of the License, or |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * (at your option) any later version. |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * bmsapp is distributed in the hope that it will be useful, |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * GNU General Public License for more details. |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * You should have received a copy of the GNU General Public License |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | */ |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | #include "Utils.h" |
102
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
18 | #include "MainWindow.h" |
20
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | |
42
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
20 | #include <QDebug> |
20
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | #include <math.h> |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | double Utils::lintner_to_kolbach(double lintner) |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | { |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | double wk = (3.5 * lintner) - 16; |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | if (wk < 0) |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | return 0.0; |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | return wk; |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | } |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | double Utils::kolbach_to_lintner(double kolbach) |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | { |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
35 | return round(((kolbach + 16) / 3.5) * 1000.0) / 1000.0; |
20
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | } |
fcbbddcc22c1
Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | |
42
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
38 | |
98
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
39 | /** |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
40 | * Often used formulas divide or multiply with 1.97 to convert between EBC and SRM. |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
41 | * Almost all software in the world use this '1.97' formula. |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
42 | * The only alternative I have seen is "srm = (ebc * 0.375 + 0.46)", and that has |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
43 | * almost the same results as the formulas used in this program. |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
44 | * These formulas come from the Dutch 'brouwhulp' program written by Adrie Otten. |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
45 | */ |
42
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
46 | double Utils::ebc_to_srm(double ebc) |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
47 | { |
98
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
48 | double srm = -0.00000000000132303 * pow(ebc, 4) - 0.00000000291515 * pow(ebc, 3) + 0.00000818515 * pow(ebc, 2) + 0.372038 * ebc + 0.596351; |
42
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
49 | if (ebc < 0 || srm < 0) |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
50 | qDebug() << "ebc_to_srm(" << ebc << ") =" << srm; |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
51 | return srm; |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
52 | } |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
53 | |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
54 | |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
55 | double Utils::srm_to_ebc(double srm) |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
56 | { |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
57 | double ebc = round( 0.000000000176506 * pow(srm, 4) + 0.000000154529 * pow(srm, 3) - 0.000159428 * pow(srm, 2) + 2.68837 * srm - 1.6004 ); |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
58 | if ((ebc < 0) || (srm < 0)) |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
59 | qDebug() << "srm_to_ebc(" << srm << ") =" << ebc; |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
60 | return ebc; |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
61 | } |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
62 | |
88e827ea7172
Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
63 | |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
64 | QString Utils::hours_to_string(int hours) |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
65 | { |
92
fb0bb9a2a7e1
Added support to build designer plugins, but it is nog yet complete. Added RangedSlider fro the brewtarget project to make our version of it. Started EditRecipe screen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
66 | int dd, hh; |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
67 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
68 | if (hours == 1) |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
69 | return QObject::tr("1 hour"); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
70 | if (hours < 24) |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
71 | return QString("%1 ").arg(hours) + QString(QObject::tr("hours")); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
72 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
73 | dd = hours / 24; |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
74 | hh = hours % 24; |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
75 | if (dd == 1) { |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
76 | if (hh == 0) |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
77 | return QString(QObject::tr("1 day")); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
78 | else if (hh == 1) |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
79 | return QString(QObject::tr("1 day, ")) + QString("%1 ").arg(hh) + QString(QObject::tr("hour")); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
80 | else |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
81 | return QString(QObject::tr("1 day, ")) + QString("%1 ").arg(hh) + QString(QObject::tr("hours")); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
82 | } else { |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
83 | if (hh == 0) |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
84 | return QString("%1 ").arg(dd) + QString(QObject::tr("days")); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
85 | else if (hh == 1) |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
86 | return QString("%1 ").arg(dd) + QString(QObject::tr("days, ")) + QString("%1 ").arg(hh) + QString(QObject::tr("hour")); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
87 | else |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
88 | return QString("%1 ").arg(dd) + QString(QObject::tr("days, ")) + QString("%1 ").arg(hh) + QString(QObject::tr("hours")); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
89 | } |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
90 | return QString("hours_to_string error"); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
91 | } |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
92 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
42
diff
changeset
|
93 | |
95
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
94 | QColor Utils::srm_to_color(int srm) |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
95 | { |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
96 | int i; |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
97 | QColor result; |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
98 | |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
99 | i = round(srm * 10); |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
100 | if (i < 0) |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
101 | i = 0; |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
102 | if (i > 299) |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
103 | i = 299; |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
104 | |
98
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
105 | // A well known table for SRM to RGB conversion, range 0.1 to 30 SRM. |
95
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
106 | const int R[] { |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
107 | 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, //0 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
108 | 250, 250, 250, 250, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, //2 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
109 | 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, //4 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
110 | 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 200, 199, 199, 198, 198, //6 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
111 | 197, 197, 196, 196, 195, 195, 194, 194, 193, 193, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, //8 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
112 | 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, //10 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
113 | 192, 192, 192, 192, 192, 192, 192, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, //12 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
114 | 179, 178, 177, 175, 174, 172, 171, 169, 168, 167, 195, 164, 162, 161, 159, 158, 157, 155, 154, 152, //14 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
115 | 151, 149, 148, 147, 145, 144, 142, 141, 139, 138, 137, 135, 134, 132, 131, 129, 128, 127, 125, 124, //16 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
116 | 122, 121, 119, 118, 117, 115, 114, 112, 111, 109, 108, 107, 105, 104, 102, 101, 99, 98, 97, 95, //18 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
117 | 94, 92, 91, 89, 88, 87, 85, 84, 82, 81, 79, 78, 77, 75, 74, 72, 71, 69, 68, 67, //20 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
118 | 65, 64, 62, 61, 59, 58, 57, 55, 54, 52, 51, 49, 48, 47, 45, 44, 43, 41, 39, 38, //22 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
119 | 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, //24 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
120 | 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, //26 |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
121 | 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8}; |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
122 | |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
123 | const int G[] { |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
124 | 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
125 | 250, 250, 250, 250, 250, 250, 249, 248, 247, 246, 245, 244, 242, 240, 238, 236, 234, 232, 230, 228, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
126 | 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
127 | 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
128 | 146, 144, 142, 141, 140, 139, 139, 138, 137, 136, 136, 135, 134, 133, 133, 132, 131, 130, 130, 129, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
129 | 128, 127, 127, 126, 125, 124, 124, 123, 122, 121, 121, 120, 119, 118, 118, 117, 116, 115, 115, 114, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
130 | 113, 112, 112, 111, 110, 109, 109, 108, 107, 106, 106, 105, 104, 103, 103, 102, 101, 100, 100, 99, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
131 | 98, 97, 97, 96, 95, 94, 94, 93, 92, 91, 91, 90, 89, 88, 88, 87, 86, 85, 85, 84, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
132 | 83, 82, 82, 81, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 72, 71, 70, 69, 69, 68, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
133 | 67, 66, 66, 65, 64, 63, 63, 62, 61, 60, 60, 59, 58, 57, 57, 56, 55, 54, 54, 53, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
134 | 52, 51, 51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43, 42, 42, 41, 40, 39, 39, 38, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
135 | 37, 36, 36, 35, 34, 33, 33, 32, 31, 30, 30, 29, 28, 27, 27, 26, 25, 24, 24, 23, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
136 | 22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
137 | 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
138 | 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3}; |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
139 | |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
140 | const int B[] { |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
141 | 210, 204, 199, 193, 188, 182, 177, 171, 166, 160, 155, 149, 144, 138, 133, 127, 122, 116, 111, 105, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
142 | 100, 94, 89, 83, 78, 72, 67, 61, 56, 50, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
143 | 47, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
144 | 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
145 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
146 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
147 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
148 | 56, 56, 56, 55, 55, 55, 55, 54, 54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 52, 51, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
149 | 51, 51, 51, 50, 50, 50, 50, 49, 49, 48, 47, 47, 46, 45, 45, 44, 43, 43, 42, 41, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
150 | 41, 40, 39, 39, 38, 37, 37, 36, 35, 34, 33, 32, 31, 29, 28, 27, 26, 25, 24, 23, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
151 | 21, 20, 19, 18, 17, 16, 15, 13, 12, 11, 10, 9, 8, 9, 9, 10, 10, 11, 11, 12, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
152 | 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
153 | 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 15, 15, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
154 | 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
155 | 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2}; |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
156 | |
98
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
157 | result = QColor::fromRgb(R[i], G[i], B[i]); |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
158 | return result; |
95
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
159 | } |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
160 | |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
161 | |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
162 | QColor Utils::ebc_to_color(int ebc) |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
163 | { |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
164 | return srm_to_color(ebc_to_srm(ebc)); |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
165 | } |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
166 | |
ef6048186cb3
Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents:
92
diff
changeset
|
167 | |
98
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
168 | QString Utils::srm_to_style(int srm) |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
169 | { |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
170 | QColor color = srm_to_color(srm); |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
171 | return QString("background-color: %1; color: %2;").arg(color.name()).arg((srm > 15) ? "#E0E1E3" : "#19232D"); |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
172 | } |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
173 | |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
174 | |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
175 | QString Utils::ebc_to_style(int ebc) |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
176 | { |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
177 | return srm_to_style(ebc_to_srm(ebc)); |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
178 | } |
1425bf3e18ed
Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
179 | |
102
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
180 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
181 | /* |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
182 | * Return incremented color by the boil and yeast. |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
183 | * https://www.hobbybrouwen.nl/forum/index.php/topic,19020.msg281132.html#msg281132 |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
184 | */ |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
185 | double Utils::get_kt(int ebc) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
186 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
187 | double kt = 1; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
188 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
189 | if (ebc < 3) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
190 | kt = 3.5; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
191 | else if (ebc < 6) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
192 | kt = 3; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
193 | else if (ebc < 8) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
194 | kt = 2.75; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
195 | else if (ebc < 10) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
196 | kt = 2.5; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
197 | else if (ebc < 20) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
198 | kt = 1.8; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
199 | else if (ebc < 30) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
200 | kt = 1.6; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
201 | else if (ebc < 60) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
202 | kt = 1.3; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
203 | else if (ebc < 100) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
204 | kt = 1.2; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
205 | else if (ebc < 300) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
206 | kt = 1.1; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
207 | return kt; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
208 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
209 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
210 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
211 | double Utils::sg_to_plato(double sg) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
212 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
213 | return -668.962 + (1262.45 * sg) - (776.43 * sg * sg) + (182.94 * sg * sg * sg); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
214 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
215 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
216 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
217 | double Utils::plato_to_sg(double plato) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
218 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
219 | return 1.00001 + (0.0038661 * plato) + (1.3488e-5 * plato * plato) + (4.3074e-8 * plato * plato * plato); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
220 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
221 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
222 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
223 | double Utils::sg_to_brix(double sg) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
224 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
225 | return sg_to_plato(sg) * my_brix_correction; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
226 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
227 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
228 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
229 | double Utils::brix_to_sg(double brix) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
230 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
231 | if (my_brix_correction > 0) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
232 | return plato_to_sg(brix / my_brix_correction); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
233 | return plato_to_sg(brix); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
234 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
235 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
236 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
237 | double Utils::calc_svg(double og, double fg) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
238 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
239 | double oe = sg_to_plato(og); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
240 | double ae = sg_to_plato(fg); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
241 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
242 | return (oe - ae) / oe * 100; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
243 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
244 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
245 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
246 | double Utils::estimate_sg(double sugars, double batch_size) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
247 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
248 | double plato = 100 * sugars / batch_size; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
249 | double sg = plato_to_sg(plato); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
250 | for (int i = 0; i < 20; i++) { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
251 | if (sg > 0) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
252 | plato = 100 * sugars / (batch_size * sg); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
253 | sg = plato_to_sg(plato); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
254 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
255 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
256 | return round(sg * 10000) / 10000; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
257 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
258 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
259 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
260 | double Utils::estimate_fg(double psugar, double pcara, double wgratio, double mashtime, double mashtemp, double svg, double og) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
261 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
262 | double BD; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
263 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
264 | if (psugar > 40) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
265 | psugar = 0; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
266 | if (pcara > 50) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
267 | pcara = 0; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
268 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
269 | if (wgratio > 0 && mashtime > 0) { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
270 | BD = wgratio; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
271 | if (BD < 2) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
272 | BD = 2; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
273 | if (BD > 5.5) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
274 | BD = 5.5; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
275 | if (mashtemp < 60) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
276 | mashtemp = 60; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
277 | if (mashtemp > 72) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
278 | mashtemp = 72; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
279 | } else { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
280 | BD = 3.5; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
281 | mashtemp = 67; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
282 | mashtime = 75; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
283 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
284 | if (svg < 30) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
285 | svg = 77; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
286 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
287 | /* |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
288 | * From brouwhulp: |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
289 | * 0.00825 Attenuation factor yeast |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
290 | * 0.00817 Attenuation factor water/grain ratio |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
291 | * -0.00684 Attenuation factor mash temperature |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
292 | * 0.00026 Attenuation factor total mash time (at some places this is 0.0026 this is wrong!) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
293 | * -0.00356 Attenuation factor percentage crystal malt |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
294 | * 0.00553 Attenuation factor percentage simple sugars |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
295 | * 0.547 Attenuation factor constant |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
296 | */ |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
297 | double AttBeer = 0.00825 * svg + 0.00817 * BD - 0.00684 * mashtemp + 0.00026 * mashtime - 0.00356 * pcara + 0.00553 * psugar + 0.547; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
298 | return round((1 + (1 - AttBeer) * (og -1)) * 10000) / 10000; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
299 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
300 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
301 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
302 | /* |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
303 | * Kleurwerking to SRM. Not for Halberstadt, Naudts. |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
304 | */ |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
305 | double Utils::kw_to_srm(int colormethod, double c) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
306 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
307 | if (colormethod == 0) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
308 | return 1.4922 * pow(c, 0.6859); //Morey |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
309 | if (colormethod == 1) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
310 | return 0.3 * c + 4.7; //Mosher |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
311 | if (colormethod == 2) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
312 | return 0.2 * c + 8.4; //Daniels |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
313 | return 0; //Halberstadt,Naudts |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
314 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
315 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
316 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
317 | double Utils::kw_to_ebc(int colormethod, double c) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
318 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
319 | return srm_to_ebc(kw_to_srm(colormethod, c)); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
320 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
321 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
322 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
323 | double Utils::abvol(double og, double fg) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
324 | { |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
325 | if (((og - fg) < 0) || (fg < 0.9)) |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
326 | return 0; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
327 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
328 | double factor = og * 3157 * pow(10, -5) + 9.716 * pow(10, -2); |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
329 | return round((og * 1000 - fg * 1000) * factor * 100) / 100; |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
330 | } |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
331 | |
b017001850df
Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents:
98
diff
changeset
|
332 | |
125
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
333 | double Utils::toIBU(int Use, int Form, double SG, double Volume, double Amount, double Boiltime, double Alpha, |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
334 | int Method, double Whirlpool9, double Whirlpool7, double Whirlpool6) |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
335 | { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
336 | double fmoment = 1.0, pfactor = 1.0, ibu = 0, boilfactor; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
337 | double sgfactor, AddedAlphaAcids, Bigness_factor, BoilTime_factor, utiisation; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
338 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
339 | double gravity = SG; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
340 | double liters = Volume; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
341 | double alpha = Alpha / 100.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
342 | double mass = Amount * 1000.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
343 | double time = Boiltime; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
344 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
345 | if ((Use == 3) || (Use == 4) || (Use == 5)) { // Aroma, Whirlpool or Dry hop. |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
346 | fmoment = 0.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
347 | } else if (Use == 0) { // Mash |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
348 | fmoment += my_factor_mashhop / 100.0; // Brouwhulp |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
349 | } else if (Use == 1) { // First wort |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
350 | fmoment += my_factor_fwh / 100.0; // Brouwhulp, Louis, Ozzie |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
351 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
352 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
353 | if (Form == 0) { // Pellet |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
354 | pfactor += my_factor_pellet / 100.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
355 | } else if (Form == 1) { // Plug |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
356 | pfactor += my_factor_plug / 100.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
357 | } else if (Form == 3) { // Wet leaf |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
358 | pfactor += my_factor_wethop / 100.0; // From https://github.com/chrisgilmerproj/brewday/blob/master/brew/constants.py |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
359 | } else if (Form == 4) { // Cryo hop |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
360 | pfactor += my_factor_cryohop / 100.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
361 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
362 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
363 | // Ideas from Zymurgy March-April 2018. These are not exact formulas! |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
364 | double whirlibus = 0.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
365 | if (Use == 3 || Use == 4) { // Flameout or any whirlpool |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
366 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
367 | if (Whirlpool9) { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
368 | // 20 mg/l/50 min |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
369 | whirlibus += (alpha * mass * 20) / liters * (Whirlpool9 / 50.0); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
370 | qDebug() << "Whirlpool9" << alpha * mass * 20 << " liter:" << liters << " time:" << Whirlpool9 << " ibu" << (alpha * mass * 20) / liters * (Whirlpool9 / 50.0); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
371 | } else { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
372 | if (Use == 3) { // Flameout hops are 2 minutes in this range. |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
373 | whirlibus += (alpha * mass * 20) / liters * (2.0 / 50.0); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
374 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
375 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
376 | if (Whirlpool7) { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
377 | // 6 mg/l/50 min |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
378 | whirlibus += (alpha * mass * 6) / liters * (Whirlpool7 / 50.0); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
379 | qDebug() << "Whirlpool7" << alpha * mass * 6 << " liter:" << liters << " time:" << Whirlpool7 << " ibu" << (alpha * mass * 6) / liters * (Whirlpool7 / 50.0); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
380 | } else { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
381 | if (Use == 3) { // Flameout hops are 4 minutes in this range. |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
382 | whirlibus += (alpha * mass * 6) / liters * (4.0 / 50.0); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
383 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
384 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
385 | if (Whirlpool6) { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
386 | // 2 mg/l/50 min |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
387 | whirlibus += (alpha * mass * 2) / liters * (Whirlpool6 / 50.0); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
388 | //console.log('Whirlpool6:' + alpha * mass * 2 + ' liter:' + liters + ' time:' + Whirlpool6 + ' ibu' + (alpha * mass * 2) / liters * (Whirlpool6 / 50)); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
389 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
390 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
391 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
392 | if (Method == 0) { // Tinseth |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
393 | /* http://realbeer.com/hops/research.html */ |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
394 | AddedAlphaAcids = (alpha * mass * 1000) / liters; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
395 | Bigness_factor = 1.65 * pow(0.000125, gravity - 1); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
396 | BoilTime_factor = ((1 - exp(-0.04 * time)) / 4.15); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
397 | utiisation = Bigness_factor * BoilTime_factor; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
398 | ibu = round((utiisation * AddedAlphaAcids * fmoment * pfactor + whirlibus) * 100) / 100; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
399 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
400 | if (Method == 2) { // Daniels |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
401 | if (Form == 2) // Leaf |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
402 | boilfactor = -(0.0041 * time * time) + (0.6162 * time) + 1.5779; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
403 | else |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
404 | boilfactor = -(0.0051 * time * time) + (0.7835 * time) + 1.9348; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
405 | if (gravity < 1050) |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
406 | sgfactor = 0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
407 | else |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
408 | sgfactor = (gravity - 1050) / 200; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
409 | ibu = round((fmoment * ((mass * (alpha * 100) * boilfactor * 0.1) / (liters * (1 + sgfactor))) + whirlibus) * 100) / 100; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
410 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
411 | if (Method == 1) { // Rager |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
412 | boilfactor = fmoment * 18.11 + 13.86 * tanh((time * 31.32) / 18.27); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
413 | if (gravity < 1050) |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
414 | sgfactor = 0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
415 | else |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
416 | sgfactor = (gravity - 1050) / 200; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
417 | ibu = round(((mass * (alpha * 100) * boilfactor * 0.1) / (liters * (1 + sgfactor)) + whirlibus) * 100) / 100; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
418 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
419 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
420 | return ibu; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
421 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
422 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
423 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
424 | double Utils::hopFlavourContribution(double bt, double vol, int use, double amount) |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
425 | { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
426 | double result; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
427 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
428 | if (use == 4 || use == 5) // Whirlpool or Dry-hop |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
429 | return 0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
430 | if (use == 1) { // First wort |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
431 | result = 0.15; // assume 15% flavourcontribution for fwh |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
432 | } else if (bt > 50) { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
433 | result = 0.10; // assume 10% flavourcontribution as a minimum |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
434 | } else { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
435 | result = 15.25 / (6 * sqrt(2 * 3.1416)) * exp(-0.5 * pow((bt - 21.0) / 6.0, 2.0)); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
436 | if (result < 0.10) |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
437 | result = 0.10; // assume 10% flavourcontribution as a minimum |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
438 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
439 | return (result * amount * 1000.0) / vol; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
440 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
441 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
442 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
443 | double Utils::hopAromaContribution(double bt, double vol, int use, double amount) |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
444 | { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
445 | double result = 0.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
446 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
447 | if (use == 5) { // Dry hop |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
448 | result = 1.33; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
449 | } else if (use == 4) { // Whirlpool |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
450 | if (bt > 30) |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
451 | bt = 30; // Max 30 minutes |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
452 | result = 0.62 * bt / 30.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
453 | } else if (bt > 20) { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
454 | result = 0.0; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
455 | } else if (bt > 7.5) { |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
456 | result = 10.03 / (4 * sqrt(2 * 3.1416)) * exp(-0.5 * pow((bt - 7.5) / 4.0, 2.0)); |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
457 | } else if (use == 2) { // Boil |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
458 | result = 1; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
459 | } else if (use == 3) { // Aroma |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
460 | result = 1.2; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
461 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
462 | return (result * amount * 1000.0) / vol; |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
463 | } |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
464 | |
2e79e0975e58
Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents:
102
diff
changeset
|
465 |