2
* Algorithms.h is part of Brewtarget, and is Copyright Philip G. Lee
3
* (rocketman768@gmail.com), 2009.
5
* Brewtarget is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* Brewtarget is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#define ROOT_PRECISION 0.0000001
24
// This is the cubic fit to get Plato from specific gravity, measured at 20C
25
// relative to density of water at 20C.
26
// P = -616.868 + 1111.14(SG) - 630.272(SG)^2 + 135.997(SG)^3
27
extern double* PlatoFromSG_20C20C;
28
extern unsigned int PlatoFromSG_20C20C_order;
30
// Water density polynomial, given in kg/L as a function of degrees C.
31
// 1.80544064e-8*x^3 - 6.268385468e-6*x^2 + 3.113930471e-5*x + 0.999924134
32
extern double* waterDensityPoly_C;
33
extern unsigned int waterDensityPoly_C_order;
35
double intPow( double base, unsigned int pow );
37
double polyEval( double* poly, unsigned int order, double x );
39
// Root finding by the secant method. Returns HUGE_VAL on failure.
40
double rootFind( double* poly, unsigned int order, double x0, double x1 );
42
//===================Beer-related stuff=====================
46
double SG_20C20C_toPlato( double sg );
47
double PlatoToSG_20C20C( double plato );
48
double getWaterDensity_kgL( double celsius );
50
#endif /* _ALGORITHMS_H */