src/Utils.cpp

Sat, 05 Mar 2022 21:15:59 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 05 Mar 2022 21:15:59 +0100
changeset 44
5a9a159c2d34
parent 42
88e827ea7172
child 57
75d11cc05ce4
permissions
-rw-r--r--

Added yeasts and hops XML exports.

/**
 * Utils.cpp is part of bmsapp.
 *
 * bmsapp is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * bmsapp is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "Utils.h"

#include <QDebug>
#include <math.h>


double Utils::lintner_to_kolbach(double lintner)
{
    double wk = (3.5 * lintner) - 16;
    if (wk < 0)
	return 0.0;
    return wk;
}


double Utils::kolbach_to_lintner(double kolbach)
{
    return round(((kolbach + 16) / 3.5) * 1000.0) / 1000.0;
}


double Utils::ebc_to_srm(double ebc)
{
    double srm = -1.32303E-12 * pow(ebc, 4) - 0.00000000291515 * pow(ebc, 3) + 0.00000818515 * pow(ebc, 2) + 0.372038 * ebc + 0.596351;
    if (ebc < 0 || srm < 0)
	qDebug() << "ebc_to_srm(" << ebc << ") =" << srm;
    return srm;
}


double Utils::srm_to_ebc(double srm)
{
    // Formule van Adrie Otten. brouwhulp.
    double ebc = round( 0.000000000176506 * pow(srm, 4) + 0.000000154529 * pow(srm, 3) - 0.000159428 * pow(srm, 2) + 2.68837 * srm - 1.6004 );
    if ((ebc < 0) || (srm < 0))
	qDebug() << "srm_to_ebc(" << srm << ") =" << ebc;
    return ebc;
}


mercurial