/
biercalc.h
405 lines (354 loc) · 11.2 KB
/
biercalc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
#ifndef BIERCALC_H
#define BIERCALC_H
// auskommentieren falls nicht als teil von kleiner-brauhelfer-core kompiliert
#include "kleiner-brauhelfer-core_global.h"
#ifdef QT_CORE_LIB
#include <QObject>
#else
#define Q_OBJECT
#define Q_ENUM(x)
#define Q_INVOKABLE
#endif
#ifndef LIB_EXPORT
#define LIB_EXPORT
#endif
/**
* @brief Berechnungen rund um die Bierherstellung
* @note Wird von QObject abgeleitet, damit die Klasse in QML aufgerufen werden kann
*/
#ifdef QT_CORE_LIB
class LIB_EXPORT BierCalc : public QObject
#else
class LIB_EXPORT BierCalc
#endif
{
Q_OBJECT
public:
/**
* @brief Formeln für die Umrechnung von Brix [°brix] nach Plato [°P] bei vergärter Würze.
*/
enum FormulaBrixToPlato
{
Terrill = 0,
TerrillLinear = 1,
Standard = 2
};
Q_ENUM(FormulaBrixToPlato)
/**
* @brief Umrechnungsfaktor von Plato [°P] nach Brix [°brix], da Bierwürze
* keine reine Saccharoselösung ist
* @note Zwischen 1.02 und 1.06 je nach Literaturangabe, meist 1.03
*/
static double faktorPlatoToBrix;
/**
* @brief Ein kg Malzschrot verdrängt eingemaischt je nach
* Feinheitsgrad der Schrotung ein Volumen von 0,65 bis 0,8 l Wasser.
* Näherungsweise rechnet man mit 0,7 l Wasserverdrängung pro kg Malzschrot.
*/
static constexpr double MalzVerdraengung = 0.75;
/**
* @brief Ballingkonstante
*/
static constexpr double Balling = 2.0665;
/**
* @brief Spezifische Wärmekapazität von Wasser [kJ/(kg*°C)]
*/
static constexpr double cWasser = 4.2;
/**
* @brief Spezifische Wärmekapazität von Malz [kJ/(kg*°C)]
*/
static constexpr double cMalz = 1.7;
public:
/**
* @brief Umrechnung von Refraktometerwert [°brix] nach plato [°P]
* @note 1°Plato = 1g Saccharose / 100g Saccharoselösung
* @param brix Refraktometerwert [°brix]
* @return Plato [°P]
*/
Q_INVOKABLE static double brixToPlato(double brix);
/**
* @brief Umrechnung von Refraktometerwert [°brix] nach plato [°P]
* @note 1°Plato = 1g Saccharose / 100g Saccharoselösung
* @param plato Plato [°P]
* @return Refraktometerwert [°brix]
*/
Q_INVOKABLE static double platoToBrix(double plato);
/**
* @brief Umrechnung von Refraktometerwert [°brix] nach spezifische Dichte [g/ml]
* @param sw Stammwürze [°P]
* @param brix Refraktometerwert [°brix]
* @param formel Benutze Umrechnungsformel
* @return Spezifische Dichte [g/ml]
*/
Q_INVOKABLE static double brixToDichte(double sw, double brix, FormulaBrixToPlato formel = Terrill);
/**
* @brief Umrechnung spezifische Dichte bei 20°C [g/ml] nach plato [°P]
* @note 1°Plato = 1g Saccharose / 100g Saccharoselösung
* @param sg Spezifische Dichte [g/ml]
* @return Plato [°P]
*/
Q_INVOKABLE static double dichteToPlato(double sg);
/**
* @brief Umrechnung plato [°P] nach spezifische Dichte bei 20°C [g/ml]
* @note 1°Plato = 1g Saccharose / 100g Saccharoselösung
* @param plato Plato [°P]
* @return Spezifische Dichte [g/ml]
*/
Q_INVOKABLE static double platoToDichte(double plato);
/**
* @brief Spezifische Dichte bei temperatur T
* @param plato
* @param T
* @param Tcalib
* @return
*/
Q_INVOKABLE static double spindelKorrektur(double plato, double T, double Tcalib = 20.0);
/**
* @brief Tatsächlicher Restextrakt (Alkohol-korrigiert) [°P]
* @param sw Stammwürze [°P]
* @param sre Scheinbarer Restextrakt [°P]
* @return Tatsächlicher Restextrakt [°P]
*/
Q_INVOKABLE static double toTRE(double sw, double sre);
/**
* @brief Scheinbarer Restextrakt (Alkohol-verfälscht) [°P]
* @param sw Stammwürze [°P]
* @param tre TatsächlicherScheinbarer Restextrakt [°P]
* @return Scheinbarer Restextrakt [°P]
*/
Q_INVOKABLE static double toSRE(double sw, double tre);
/**
* @brief Vergärungsgrad [%]
* @param sw Stammwuerze [°P]
* @param re Restextrakt [°P]
* @return Vergärungsgrad [%]
*/
Q_INVOKABLE static double vergaerungsgrad(double sw, double re);
/**
* @brief sreAusVergaerungsgrad
* @param sw
* @param vg
* @return
*/
Q_INVOKABLE static double sreAusVergaerungsgrad(double sw, double vg);
/**
* @brief Alkohol [vol%]
* @param sw Stammwürze [°P]
* @param sre Scheinbarer Restextrakt [°P]
* @return Alkohol [vol%]
*/
Q_INVOKABLE static double alkohol(double sw, double sre, double alcZusatz = 0);
/**
* @brief alkoholVonZucker
* @param m
* @return
*/
Q_INVOKABLE static double alkoholVonZucker(double m);
/**
* @brief CO2 Gehalt bei bestimmentem Druck und bestimmter Temperatur [g/l]
* @param p Druck [bar]
* @param T Temperatur [°C]
* @return CO2 Gehalt [g/l]
*/
Q_INVOKABLE static double co2(double p, double T);
/**
* @brief Druck bei bestimmentem CO2 Gehalt und bestimmter Temperatur [bar]
* @param co2 CO2 Gehalt [g/l]
* @param T Temperatur [°C]
* @return Druck [bar]
*/
Q_INVOKABLE static double p(double co2, double T);
/**
* @brief Gruenschlauchzeitpunkt [°P]
* @param co2Soll Soll CO2 Gehalt [g/l]
* @param sw Stammwuerze [°P]
* @param sreSchnellgaerprobe Scheinbarer Restextrakt Schnellgaerprobe [°P]
* @param T Temperatur Jungbier [°C]
* @return Gruenschlauchzeitpunkt [°P]
*/
Q_INVOKABLE static double gruenschlauchzeitpunkt(double co2Soll, double sw, double sreSchnellgaerprobe, double T);
/**
* @brief spundungsdruck Spundungsdruck [bar]
* @param co2Soll Soll CO2 Gehalt [g/l]
* @param T Temperatur Jungbier [°C]
* @return Spundungsdruck [bar]
*/
Q_INVOKABLE static double spundungsdruck(double co2Soll, double T);
/**
* @brief co2Noetig
* @param co2Soll
* @param sw
* @param sreSchnellgaerprobe
* @param sreJungbier
* @param T
* @return
*/
Q_INVOKABLE static double co2Noetig(double co2Soll, double sw, double sreSchnellgaerprobe, double sreJungbier, double T);
/**
* @brief wuerzeCO2Potential
* @param sw
* @param sre
* @return
*/
Q_INVOKABLE static double co2Vergaerung(double sw, double sre);
/**
* @brief zuckerCO2Potential
* @return
*/
Q_INVOKABLE static double co2Zucker();
/**
* @brief Benoetigte Speise fuer Karbonisierung [L/L]
* @param co2Soll Soll CO2 Gehalt [g/l]
* @param sw Stammwuerze [°P]
* @param sreSchnellgaerprobe Scheinbarer Restextrakt Schnellgaerprobe [°P]
* @param sreJungbier Scheinbarer Restextrakt Jungbier [°P]
* @param T Temperatur Jungbier [°C]
* @return Speisemenge [L/L]
*/
Q_INVOKABLE static double speise(double co2Soll, double sw, double sreSchnellgaerprobe, double sreJungbier, double T);
/**
* @brief zucker
* @param co2Soll
* @param sw
* @param sreSchnellgaerprobe
* @param sreJungbier
* @param T
* @return
*/
Q_INVOKABLE static double zucker(double co2Soll, double sw, double sreSchnellgaerprobe, double sreJungbier, double T);
/**
* @brief Dichte von Wasser bei gegebenen Temperatur
* @param T Temperatur [°C]
* @return Dichte [kg/l]
*/
Q_INVOKABLE static double dichteWasser(double T);
/**
* @brief Berechnet das Volumen von Wasser bei einer andere Temperatur
* @param T1 Temperatur 1 [°C]
* @param T2 Temperatur 2 [°C]
* @param V1 Volumen bei Temperatur 1 [L]
* @return Volumen bei Temperatur 2 [L]
*/
Q_INVOKABLE static double volumenWasser(double T1, double T2, double V1);
/**
* @brief Berechnet die Verdampfungsziffer
* @param V1 Anfangsvolumen [L]
* @param V2 Endvolumen [L]
* @param t Kochzeit [min]
* @return Verdampfungsziffer [%]
*/
Q_INVOKABLE static double verdampfungsziffer(double V1, double V2, double t);
/**
* @brief Berechnet die Verdampfungsrate
* @param V1 Anfangsvolumen [L]
* @param V2 Endvolumen [L]
* @param t Kochzeit [min]
* @return Verdampfungsrate [l/h]
*/
Q_INVOKABLE static double verdampfungsrate(double V1, double V2, double t);
/**
* @brief Berechnet die Sudhausausbeute
* @param sw Stammwürze [°P]
* @param V Volumen bei 20°C [L]
* @param schuettung Schüttung [kg]
* @return Sudhausausbeute [%]
*/
Q_INVOKABLE static double sudhausausbeute(double sw, double sw_dichte, double V, double schuettung);
/**
* @brief Berechnet die nötige Schüttung
* @param sw Stammwürze [°P]
* @param V Volumen bei 20°C [L]
* @param sudhausausbeute Sudhausausbeute [%]
* @return Schüttung [kg]
*/
Q_INVOKABLE static double schuettung(double sw, double sw_dichte, double V, double sudhausausbeute);
/**
* @brief Benötigte Wassermenge, um auf die Sollstammwürze zu erreichen
* @param swIst Iststammwürze [°P]
* @param swSoll Sollstammwürze [°P]
* @param menge Volumen [L]
* @return Verschneidung [L]
*/
Q_INVOKABLE static double verschneidung(double swIst, double swSoll, double menge);
/**
* @brief BierCalc::tinseth
* @param t
* @param sw
* @return
*/
Q_INVOKABLE static double tinseth(double t, double sw);
/**
* @brief mischungstemperaturTm
* @param m1
* @param c1
* @param T1
* @param m2
* @param c2
* @param T2
* @return
*/
Q_INVOKABLE static double mischungstemperaturTm(double m1, double c1, double T1, double m2, double c2, double T2);
/**
* @brief mischungstemperaturT2
* @param Tm
* @param m1
* @param c1
* @param T1
* @param m2
* @param c2
* @return
*/
Q_INVOKABLE static double mischungstemperaturT2(double Tm, double m1, double c1, double T1, double m2, double c2);
/**
* @brief mischungstemperaturM2
* @param Tm
* @param m1
* @param c1
* @param T1
* @param c2
* @param T2
* @return
*/
Q_INVOKABLE static double mischungstemperaturM2(double Tm, double m1, double c1, double T1, double c2, double T2);
/**
* @brief cMaische
* @param m_malz
* @param V_wasser
* @return
*/
Q_INVOKABLE static double cMaische(double m_malz, double V_wasser);
/**
* @brief einmaischetemperatur
* @param T_rast
* @param m_malz
* @param T_malt
* @param V_wasser
* @return
*/
Q_INVOKABLE static double einmaischetemperatur(double T_rast, double m_malz, double T_malt, double V_wasser);
/**
* @brief phMalz
* @param farbe
* @return
*/
Q_INVOKABLE static double phMalz(double farbe);
/**
* @brief phMalzCarafa
* @param farbe
* @return
*/
Q_INVOKABLE static double phMalzCarafa(double farbe);
/**
* @brief phMalzRoest
* @param farbe
* @return
*/
Q_INVOKABLE static double phMalzRoest(double farbe);
/**
* @brief Farbe im RGB Raum
* @param ebc EBC Farbwert [EBC]
* @return Farbwert im RGB Raum
*/
Q_INVOKABLE static unsigned int ebcToColor(double ebc);
};
#endif // BIERCALC_H