268 qDebug() << " preboil SG" << recipe->preboil_sg; |
268 qDebug() << " preboil SG" << recipe->preboil_sg; |
269 |
269 |
270 /* |
270 /* |
271 * Color of the wort |
271 * Color of the wort |
272 */ |
272 */ |
273 if (ui->color_methodEdit->currentIndex() == 4) { // Naudts |
273 if (recipe->color_method == 4) { // Naudts |
274 color = round(((Utils::sg_to_plato(og) / 8.6) * colorn) + (ui->boil_timeEdit->value() / 60)); |
274 color = round(((Utils::sg_to_plato(og) / 8.6) * colorn) + (ui->boil_timeEdit->value() / 60)); |
275 } else if (ui->color_methodEdit->currentIndex() == 3) { // Hans Halberstadt |
275 } else if (recipe->color_method == 3) { // Hans Halberstadt |
276 double bv = 0.925; // Beer loss efficiency |
276 double bv = 0.925; // Beer loss efficiency |
277 double sr = 0.95; // Mash and sparge efficiency |
277 double sr = 0.95; // Mash and sparge efficiency |
278 color = round((4.46 * bv * sr) / ui->batch_sizeEdit->value() * colorh); |
278 color = round((4.46 * bv * sr) / ui->batch_sizeEdit->value() * colorh); |
279 } else { |
279 } else { |
280 double cw = colort / ui->batch_sizeEdit->value() * 8.34436; |
280 double cw = colort / ui->batch_sizeEdit->value() * 8.34436; |
281 color = Utils::kw_to_ebc(ui->color_methodEdit->currentIndex(), cw); |
281 color = Utils::kw_to_ebc(recipe->color_method, cw); |
282 } |
282 } |
283 qDebug() << " color" << ui->est_colorEdit->value() << color << recipe->est_color; |
283 qDebug() << " color" << ui->est_colorEdit->value() << color << recipe->est_color; |
284 recipe->est_color = color; |
284 recipe->est_color = color; |
285 ui->est_colorEdit->setValue(color); |
285 ui->est_colorEdit->setValue(color); |
286 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color)); |
286 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color)); |
344 * Take the alcohol and sugar parts and then combine. |
344 * Take the alcohol and sugar parts and then combine. |
345 */ |
345 */ |
346 double alc = 1881.22 * fg * (og - fg) / (1.775 - og); |
346 double alc = 1881.22 * fg * (og - fg) / (1.775 - og); |
347 double sug = 3550 * fg * (0.1808 * og + 0.8192 * fg - 1.0004); |
347 double sug = 3550 * fg * (0.1808 * og + 0.8192 * fg - 1.0004); |
348 ui->calEdit->setValue(round((alc + sug) / (12 * 0.0295735296))); |
348 ui->calEdit->setValue(round((alc + sug) / (12 * 0.0295735296))); |
|
349 } |
|
350 |
|
351 |
|
352 void EditRecipe::calcFermentablesFromOG(double og) |
|
353 { |
|
354 qDebug() << "calcFermentablesFromOG" << og; |
|
355 |
|
356 int i; |
|
357 double totmass = 0; |
|
358 double tot = 0; |
|
359 double d, amount; |
|
360 double efficiency = recipe->efficiency; |
|
361 double sug = Utils::sg_to_plato(og) * recipe->batch_size * og / 100.0; // total amount of sugars in kg. |
|
362 |
|
363 for (i = 0; i < recipe->fermentables.size(); i++) { |
|
364 if (recipe->fermentables.at(i).f_added < 4) { |
|
365 d = recipe->fermentables.at(i).f_percentage / 100.0 * |
|
366 (recipe->fermentables.at(i).f_yield / 100.0) * |
|
367 (1 - recipe->fermentables.at(i).f_moisture / 100.0); |
|
368 if (recipe->fermentables.at(i).f_added == 0) // Mash |
|
369 d = efficiency / 100.0 * d; |
|
370 tot += d; |
|
371 } |
|
372 } |
|
373 if (tot) |
|
374 totmass = round((sug / tot) * 1000.0) / 1000.0; |
|
375 |
|
376 if (totmass) { |
|
377 for (i = 0; i < recipe->fermentables.size(); i++) { |
|
378 amount = round(recipe->fermentables.at(i).f_percentage * 10.0 * totmass) / 1000.0; |
|
379 recipe->fermentables[i].f_amount = amount; |
|
380 } |
|
381 } |
349 } |
382 } |
350 |
383 |
351 |
384 |
352 void EditRecipe::ferment_perc_mash_valueChanged(int value) |
385 void EditRecipe::ferment_perc_mash_valueChanged(int value) |
353 { |
386 { |