# Path: brew/constants.py
# ABV_CONST = 131.25  # RATIO_C2H6O_TO_CO2 / ALCOHOL_SPECIFIC_GRAVITY * 100.0
# 
# Path: brew/constants.py
# ALCOHOL_SPECIFIC_GRAVITY = 0.7936
# 
# Path: brew/utilities/sugar.py
# def apparent_extract_to_real_extract(original_extract, apparent_extract):
#     """
#     Apparent Extract to Real Extract in degrees Plato
# 
#     :param float original_extract: Original degrees Plato
#     :param float apparent_extract: Apparent degrees Plato of finished beer
#     :return: Real degrees Plato of finished beer
#     :rtype: float
# 
#     Source:
# 
#     * Formula from Balling: De Clerck, Jean, A Textbook Of Brewing, Chapman & Hall Ltd., 1958
#     """  # noqa
#     attenuation_coeff = 0.22 + 0.001 * original_extract
#     real_extract = (attenuation_coeff * original_extract + apparent_extract) / (
#         1 + attenuation_coeff
#     )  # noqa
#     return real_extract


from ..constants import ABV_CONST
from ..constants import ALCOHOL_SPECIFIC_GRAVITY
from .sugar import apparent_extract_to_real_extract
    equation, giving Alcohol by Weight.  This is then converted to Alcohol
    by Volume multiplying by the ratio of Final Gravity to Density of Ethanol.

    The alternate equation reports a higher ABV for higher gravity beers.
    This equation is just a different take on it. Scientists rarely agree
    when it comes to equations. There will probably be another equation for
    ABV down the road.

    The complex formula, and variations on it come from:

    * Ritchie Products Ltd, (Zymurgy, Summer 1995, vol. 18, no. 2)
    * Michael L. Hall's article Brew by the Numbers: Add Up What's in Your Beer, and Designing Great Beers by Daniels.

    Source:

    * http://www.brewersfriend.com/2011/06/16/alcohol-by-volume-calculator-updated/
    """  # noqa
    # Density listed (possibly incorrectly) from Zymergy Mag
    DENSITY_ETHANOL = 0.794
    return (76.08 * (og - fg) / (1.775 - og)) * (fg / DENSITY_ETHANOL) / 100.0


def alcohol_by_weight(abv):
    """
    Alcohol by Weight from ABV

    :param float abv: Alcohol by Volume
    :return: Alcohol by Weight
    :rtype: float
    """

# Path: brew/constants.py
# ABV_CONST = 131.25  # RATIO_C2H6O_TO_CO2 / ALCOHOL_SPECIFIC_GRAVITY * 100.0
# 
# Path: brew/constants.py
# ALCOHOL_SPECIFIC_GRAVITY = 0.7936
# 
# Path: brew/utilities/sugar.py
# def apparent_extract_to_real_extract(original_extract, apparent_extract):
#     """
#     Apparent Extract to Real Extract in degrees Plato
# 
#     :param float original_extract: Original degrees Plato
#     :param float apparent_extract: Apparent degrees Plato of finished beer
#     :return: Real degrees Plato of finished beer
#     :rtype: float
# 
#     Source:
# 
#     * Formula from Balling: De Clerck, Jean, A Textbook Of Brewing, Chapman & Hall Ltd., 1958
#     """  # noqa
#     attenuation_coeff = 0.22 + 0.001 * original_extract
#     real_extract = (attenuation_coeff * original_extract + apparent_extract) / (
#         1 + attenuation_coeff
#     )  # noqa
#     return real_extract


# Path: brew/utilities/abv.py
from ..constants import ABV_CONST
from ..constants import ALCOHOL_SPECIFIC_GRAVITY
from .sugar import apparent_extract_to_real_extract

    equation, giving Alcohol by Weight.  This is then converted to Alcohol
    by Volume multiplying by the ratio of Final Gravity to Density of Ethanol.

    The alternate equation reports a higher ABV for higher gravity beers.
    This equation is just a different take on it. Scientists rarely agree
    when it comes to equations. There will probably be another equation for
    ABV down the road.

    The complex formula, and variations on it come from:

    * Ritchie Products Ltd, (Zymurgy, Summer 1995, vol. 18, no. 2)
    * Michael L. Hall's article Brew by the Numbers: Add Up What's in Your Beer, and Designing Great Beers by Daniels.

    Source:

    * http://www.brewersfriend.com/2011/06/16/alcohol-by-volume-calculator-updated/
    """  # noqa
    # Density listed (possibly incorrectly) from Zymergy Mag
    DENSITY_ETHANOL = 0.794
    return (76.08 * (og - fg) / (1.775 - og)) * (fg / DENSITY_ETHANOL) / 100.0


def alcohol_by_weight(abv):
    """
    Alcohol by Weight from ABV

    :param float abv: Alcohol by Volume
    :return: Alcohol by Weight
    :rtype: float
    """

    return abv * ALCOHOL_SPECIFIC_GRAVITY