src/Utils.h

Fri, 15 Apr 2022 20:20:22 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 15 Apr 2022 20:20:22 +0200
changeset 135
e68b27ad8a40
parent 134
5099df8ba6c6
child 168
4bc92122d001
permissions
-rw-r--r--

Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.

#ifndef _UTILS_H
#define	_UTILS_H

#include <QString>
#include <QColor>

// #define Ka1 0.0000004445
// #define Ka2 0.0000000000468


/**
 * @namespace Utils
 *
 * @brief Global math functions.
 */
namespace Utils {

    double lintner_to_kolbach(double lintner);
    double kolbach_to_lintner(double kolbach);
    double ebc_to_srm(double ebc);
    double srm_to_ebc(double srm);
    double get_kt(int ebc);
    double plato_to_sg(double plato);
    double sg_to_plato(double sg);
    double brix_to_sg(double brix);
    double sg_to_brix(double sg);
    double brix_to_fg(double o_plato, double refracto);
    double calc_svg(double og, double fg);
    double estimate_sg(double sugars, double batch_size);
    double estimate_fg(double psugar, double pcara, double wgratio, double mashtime, double mashtemp, double svg, double og);
    double kw_to_srm(int colormethod, double c);
    double kw_to_ebc(int colormethod, double c);
    double abvol(double og, double fg);
    double toIBU(int Use, int Form, double SG, double Volume, double Amount, double Boiltime, double Alpha,
                 int Method, double Whirlpool9, double Whirlpool7, double Whirlpool6);
    double hopFlavourContribution(double bt, double vol, int use, double amount);
    double hopAromaContribution(double bt, double vol, int use, double amount);
    QString hours_to_string(int hours);

    /**
     * @brief Map SRM color to RGB and return as QColor.
     * @param srm The srm value.
     * @return QColor
     */
    QColor srm_to_color(int srm);

    /**
     * @brief Map EBC color to RGB and return as QColor.
     * @param ebc The ebc value.
     * @return QColor
     */
    QColor ebc_to_color(int ebc);

    /**
     * @brief Map SRM color to a QString for stylesheets.
     * @param srm The srm value.
     * @return A QString with stylesheet colors.
     */
    QString srm_to_style(int ebc);

    /**
     * @brief Map EBC color to a QString for stylesheets.
     * @param ebc The ebc value.
     * @return A QString with stylesheet colors.
     */
    QString ebc_to_style(int srm);

    /**
     * @brief Mix water volumes and ingredients.
     *
     */
    double mix(double v1, double v2, double c1, double c2);

    /**
     * @brief Return mg/l as CaCO3
     */
    double ResidualAlkalinity(double total_alkalinity, double calcium, double magnesium);

    double PartCO3(double pH);

    double PartHCO3(double pH);

    double Charge(double pH);

    double CalcFrac(double TpH, double pK1, double pK2, double pK3);
}

#endif

mercurial