~scottydelicious666/brewtarget/brewtarget

« back to all changes in this revision

Viewing changes to src/Algorithms.h

  • Committer: Philip Greggory Lee
  • Date: 2009-08-23 16:53:43 UTC
  • Revision ID: git-v1:f8d1a25135bd92f06c46c562293800e4faa42c61
Made a src/ and ui/ directory and moved everything.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Algorithms.h is part of Brewtarget, and is Copyright Philip G. Lee
 
3
 * (rocketman768@gmail.com), 2009.
 
4
 *
 
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.
 
9
 
 
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.
 
14
 
 
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/>.
 
17
 */
 
18
 
 
19
#ifndef _ALGORITHMS_H
 
20
#define _ALGORITHMS_H
 
21
 
 
22
#define ROOT_PRECISION 0.0000001
 
23
 
 
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;
 
29
 
 
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;
 
34
 
 
35
double intPow( double base, unsigned int pow );
 
36
 
 
37
double polyEval( double* poly, unsigned int order, double x );
 
38
 
 
39
// Root finding by the secant method. Returns HUGE_VAL on failure.
 
40
double rootFind( double* poly, unsigned int order, double x0, double x1 );
 
41
 
 
42
//===================Beer-related stuff=====================
 
43
 
 
44
void initVars();
 
45
 
 
46
double SG_20C20C_toPlato( double sg );
 
47
double PlatoToSG_20C20C( double plato );
 
48
double getWaterDensity_kgL( double celsius );
 
49
 
 
50
#endif  /* _ALGORITHMS_H */
 
51