r'''Returns the density of a building, insulating, or refractory
    material from tables  in [1]_, [2]_, and [3]_. No temperature dependence is
    available. Function must be provided with either a key to one of the
    dictionaries `refractories`, `ASHRAE`, or `building_materials` - or a
    search term which will pick the closest match based on a fuzzy search. To
    determine which source the fuzzy search will pick, use the function
    `nearest_material`. Fuzzy searches are slow; it is preferable to call this
    function with a material key directly.

    Parameters
    ----------
    ID : str
        String as described above

    Returns
    -------
    rho : float
        Density of the material, [kg/m^3]

    Examples
    --------
    >>> rho_material('Board, Asbestos/cement')
    1900.0

    References
    ----------
    .. [1] ASHRAE Handbook: Fundamentals. American Society of Heating,
       Refrigerating and Air-Conditioning Engineers, Incorporated, 2013.
    .. [2] DIN EN 12524 (2000-07) Building Materials and Products
       Hygrothermal Properties - Tabulated Design Values; English Version of
       DIN EN 12524.
    .. [3] Gesellschaft, V. D. I., ed. VDI Heat Atlas. 2nd edition.
       Berlin; New York:: Springer, 2010.

def rho_material(ID):
    r'''Returns the density of a building, insulating, or refractory
    material from tables  in [1]_, [2]_, and [3]_. No temperature dependence is
    available. Function must be provided with either a key to one of the
    dictionaries `refractories`, `ASHRAE`, or `building_materials` - or a
    search term which will pick the closest match based on a fuzzy search. To
    determine which source the fuzzy search will pick, use the function
    `nearest_material`. Fuzzy searches are slow; it is preferable to call this
    function with a material key directly.

    Parameters
    ----------
    ID : str
        String as described above

    Returns
    -------
    rho : float
        Density of the material, [kg/m^3]

    Examples
    --------
    >>> rho_material('Board, Asbestos/cement')
    1900.0

    References
    ----------
    .. [1] ASHRAE Handbook: Fundamentals. American Society of Heating,
       Refrigerating and Air-Conditioning Engineers, Incorporated, 2013.
    .. [2] DIN EN 12524 (2000-07) Building Materials and Products
       Hygrothermal Properties - Tabulated Design Values; English Version of
       DIN EN 12524.
    .. [3] Gesellschaft, V. D. I., ed. VDI Heat Atlas. 2nd edition.
       Berlin; New York:: Springer, 2010.
    '''
    if ID not in materials_dict:
        ID = nearest_material(ID)
    if ID in refractories:
        rho = float(refractories[ID][0]) # Density available for all hits
    elif ID in building_materials:
        rho = float(building_materials[ID][0]) # Density available for all hits
    else:
        rho = ASHRAE[ID][0]
        if rho is None:
            raise Exception('Density is not available for this material')
        else:
            rho = float(rho)
    return rho