# HG changeset patch # User Michiel Broek # Date 1668615987 -3600 # Node ID 31419b7cee690e4224441b145dffbd05982ba29f # Parent e06b04ef15799b65023adf9cdc9166392d7fd60f Finally found the right way to calculate the bottle pressure in bar after refermentation. diff -r e06b04ef1579 -r 31419b7cee69 src/EditProduct.h --- a/src/EditProduct.h Tue Nov 15 09:42:25 2022 +0100 +++ b/src/EditProduct.h Wed Nov 16 17:26:27 2022 +0100 @@ -334,7 +334,8 @@ double get_fg(double gravity); double ResCO2(double T); double CarbCO2toS(double CO2, double T, double SFactor); - double GetPressure(double CO2, double T1, double T2); + double GetPressure(double CO2, double T); + double GetPressureBar(double gl, double T); double CarbCO2ToPressure(double CO2, double T); void calcPack(); void exportBeerXML(); diff -r e06b04ef1579 -r 31419b7cee69 src/EditProductTab11.cpp --- a/src/EditProductTab11.cpp Tue Nov 15 09:42:25 2022 +0100 +++ b/src/EditProductTab11.cpp Wed Nov 16 17:26:27 2022 +0100 @@ -34,19 +34,37 @@ } -double EditProduct::GetPressure(double CO2, double T1, double T2) +double EditProduct::GetPressure(double CO2, double T) { - double V = CO2 - ResCO2(T1); - V = CO2; // TODO: temp only total pressure, testing - if (V < 0) + if (CO2 < 0) return 0; - double P = -1.09145427669121 + 0.00800006989646477 * T2 + 0.000260276315484684 * T2 * T2 + 0.0215142075945119 * T2 * V + - 0.674996600795854 * V + -0.00471757220150754 * V * V; + double P = -1.09145427669121 + 0.00800006989646477 * T + 0.000260276315484684 * T * T + 0.0215142075945119 * T * CO2 + + 0.674996600795854 * CO2 + -0.00471757220150754 * CO2 * CO2; + + P = round((P * 1.01325) * 100.0) / 100.0; // atm to bar + qDebug() << " GetPressure(" << CO2 << "," << T << ") CO2:" << CO2 << "Bar:" << P; + return P; +} + + +/* + * Calculate pressure in the bottles after refermentation. + * @param gl Sugar in gram/liter + * @param T Temperature in celsius + * @return Pressure in Bar. + */ +double EditProduct::GetPressureBar(double gl, double T) +{ + if (gl <= 0) + return 0; + + double P = ((gl / 10.0) / exp(-10.73797 + (2617.25 / (T + 273.15)))) - 1.013; if (P < 0) P = 0; - P = round((P * 1.01325) * 100.0) / 100.0; // atm to bar - qDebug() << " GetPressure(" << CO2 << "," << T1 << "," << T2 << ") V:" << V << "Bar:" << P << "ignored ResCO2:" << ResCO2(T1); + + P = round(P * 100.0) / 100.0; + qDebug() << " GetPressureBar(" << gl << "," << T << ") P:" << P; return P; } @@ -143,10 +161,11 @@ refreshFermentables(); } else { product->bottle_priming_amount = CarbCO2toS(product->bottle_carbonation, TSec, SFactor); +// qDebug() << " priming CarbCO2toS(" << product->bottle_carbonation << TSec << SFactor << ") =" << product->bottle_priming_amount; ui->bottle_sug_amountShow->setValue(product->bottle_priming_amount); double total = round(product->bottle_priming_amount * product->bottle_amount * 100.0) / 100000.0; - qDebug() << " total" << total << product->fermentables.at(i).amount; if (total != product->fermentables.at(i).amount) { + qDebug() << " total" << total << product->fermentables.at(i).amount; qDebug() << " update priming sugar" << total; product->fermentables[i].amount = total; refreshFermentables(); @@ -159,7 +178,7 @@ talc = product->bottle_amount - pvol; tvol = pvol + product->bottle_priming_water; product->bottle_abv = talc / (tvol + talc) * 100; - product->bottle_bar = GetPressure(product->bottle_carbonation, TSec, product->bottle_carbonation_temp); + product->bottle_bar = GetPressureBar(product->bottle_priming_amount, product->bottle_carbonation_temp); ui->bottle_abvShow->setValue(product->bottle_abv); ui->bottle_barShow->setValue(product->bottle_bar); } @@ -241,7 +260,7 @@ talc = product->keg_amount - pvol; tvol = pvol + product->keg_priming_water; product->keg_abv = talc / (tvol + talc) * 100; - product->keg_bar = GetPressure(product->keg_carbonation, TSec, product->keg_carbonation_temp); + product->keg_bar = GetPressure(product->keg_carbonation, product->keg_carbonation_temp); ui->keg_abvShow->setValue(product->keg_abv); ui->keg_barShow->setValue(product->keg_bar); } diff -r e06b04ef1579 -r 31419b7cee69 translations/bmsapp_en.ts --- a/translations/bmsapp_en.ts Tue Nov 15 09:42:25 2022 +0100 +++ b/translations/bmsapp_en.ts Wed Nov 16 17:26:27 2022 +0100 @@ -4774,12 +4774,12 @@ - + Confirm package - + Confirm that the beer is packaged and all data is correct diff -r e06b04ef1579 -r 31419b7cee69 translations/bmsapp_nl.ts --- a/translations/bmsapp_nl.ts Tue Nov 15 09:42:25 2022 +0100 +++ b/translations/bmsapp_nl.ts Wed Nov 16 17:26:27 2022 +0100 @@ -5440,12 +5440,12 @@ Batterij volt - + Confirm package Bevestig verpakken - + Confirm that the beer is packaged and all data is correct Bevestig dat het bier verpakt is en de gegevens kloppen