/*
 * Copyright (c) 2003 by Domenick Venezia 
 * 
 *  This software is distributed under the so-called ``Berkeley 
 *  License'': 
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met: 
 * 
 * 1. Redistributions of source code must retain the above copyright 
 *    notice, this list of conditions and the following disclaimer. 
 * 2. Redistributions in binary form must reproduce the above copyright 
 *    notice, this list of conditions and the following disclaimer in the 
 *    documentation and/or other materials provided with the distribution. 
 * 
 * This software is provided ``as is'', and any express or implied 
 * warranties, including, but not limited to, the implied warranties of 
 * merchantability and fitness for a particular purpose are disclaimed. 
 * In no event shall Domenick Venezia be liable for any 
 * direct, indirect, incidental, special, exemplary, or consequential 
 * damages (including, but not limited to, procurement of substitute 
 * goods or services; loss of use, data, or profits; or business 
 * interruption) however caused and on any theory of liability, whether 
 * in contract, strict liability, or tort (including negligence or 
 * otherwise) arising in any way out of the use of this software, even if 
 * advised of the possibility of such damage. 
 *
 * Brewing utiltity functions.
 * Author   : Domenick Venezia
 *
 * Modified by Greg Lehey
 * $Id: beer.h,v 1.4 2004/01/28 02:42:14 grog Exp $
 */
#ifndef BEER_H
#define BEER_H
#include <math.h>

/*
 * This is for Jackie Rager's hopping functions
 */
#define RAGER_HIGH_SPECIFIC_GAVITY (1.050)
#define RAGER_HOP_UTIL_MAX_MINUTES (60.0)

/* Define the coefficients for a 3rd order polynomial for SG temp correction
 */

#define A0 (1.313454)
#define A1 (-0.132674)
#define A2 (2.057793e-3)
#define A3 (-2.627634e-6)

/*
 * data for relative density of water
 */
#define BEER_NUM_DENS (111)


extern float density_water[];

float corrected_SG (float SG, float temp, char temptype);
float corrected_SG_at_15C (float SG, float temp, char temptype);
float SG_to_Plato (float SG);
float Plato_to_SG (float Plato);
float lbs_extract_per_gal_SG (float SG_raw, float temp, char temptype);
float SG_change_with_vol (float SG0, float vol0, float vol1);
float vol_change_with_SG (float vol0, float SG0, float SG1);
float temp_to_F_degrees (float temp, char temptype);
float temp_to_C_degrees (float temp, char temptype);
float C_to_F_degrees (float temp);
float F_to_C_degrees (float temp);
float lbs_to_kgs (float lbs);
float kgs_to_lbs (float kgs);
float gals_to_liters (float gals);
float liters_to_gals (float liters);
float qts_to_liters (float qts);
float liters_to_qts (float liters);
float alc_calories_per_12_oz (float OSG, float FSG);
float ext_calories_per_12_oz (float OSG, float FSG);
float CO2_pressure (float vol, float tempF);
float decoct (float vt, float tt, float t0, float td);
float beer_step_add_vol (float vm, float tm, float ta, float tf);
float beer_relative_density_of_water (float t0, float t1);
float beer_relative_volume_of_water (float t0, float v0, float t1);

/* Hopping calculations */

float tinseth_hop_gravity_adjustment (float SGB);
float tinseth_hop_boil_time_factor (float boil_time);
float tinseth_hop_utilization (float SGB, float boil_time);
float tinseth_hop_ibu_from_weight (float Util, float Acid,
				   float Wt, float Vol, float GA, float WtFactor);
float tinseth_hop_weight_from_ibu (float Util, float Acid,
				   float IBU, float Vol, float GA, float WtFactor);

float rager_hop_gravity_adjustment (float SGB);
float rager_hop_util (int boil_minutes);
float rager_hop_ibu_from_weight (float Util, float Acid,
				 float Wt, float Vol, float GA, float WtFactor);
float rager_hop_weight_from_ibu (float Util, float Acid,
				 float IBU, float Vol, float GA, float WtFactor);

float ballings_factor (float P);
float alcohol_by_weight_fix (float OSG, float FSG);
float alcohol_by_weight_AJ (float OSG, float FSG);
float abw_to_abv (float abw);

float brix_to_ri (float brix);
float brix_to_sg (float brix);
float brix_to_fg (float ob, float ab);
float brix_to_abw (float sg, float ab);
float brix_sg_to_abw (float ab, float sg);

#endif

