r'''This function handles the calculation of nucleate boiling critical
    heat flux and chooses the best method for performing the calculation.
    
    Preferred methods are 'Serth-HEDH' when a tube diameter is specified,
    and 'Zuber' otherwise.

    Parameters
    ----------
    rhol : float, optional
        Density of the liquid [kg/m^3]
    rhog : float, optional
        Density of the produced gas [kg/m^3]
    sigma : float, optional
        Surface tension of liquid [N/m]
    Hvap : float, optional
        Heat of vaporization of the fluid at T, [J/kg]
    D : float, optional
        Diameter of tubes [m]
    P : float, optional
        Saturation pressure of fluid, [Pa]
    Pc : float, optional
        Critical pressure of fluid, [Pa]

    Returns
    -------
    q : float
        Nucleate boiling critical heat flux [W/m^2]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to calculate qmax with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        A string of the function name to use; one of ('Serth-HEDH', 'Zuber', 
        or 'HEDH-Montinsky')
    AvailableMethods : bool, optional
        If True, function will consider which methods which can be used to
        calculate `qmax` with the given inputs
        
    Examples
    --------
    >>> qmax_boiling(D=0.0127, sigma=8.2E-3, Hvap=272E3, rhol=567, rhog=18.09)
    351867.46522901946

def qmax_boiling(rhol=None, rhog=None, sigma=None, Hvap=None, D=None, P=None, 
                 Pc=None, Method=None, AvailableMethods=False):
    r'''This function handles the calculation of nucleate boiling critical
    heat flux and chooses the best method for performing the calculation.
    
    Preferred methods are 'Serth-HEDH' when a tube diameter is specified,
    and 'Zuber' otherwise.

    Parameters
    ----------
    rhol : float, optional
        Density of the liquid [kg/m^3]
    rhog : float, optional
        Density of the produced gas [kg/m^3]
    sigma : float, optional
        Surface tension of liquid [N/m]
    Hvap : float, optional
        Heat of vaporization of the fluid at T, [J/kg]
    D : float, optional
        Diameter of tubes [m]
    P : float, optional
        Saturation pressure of fluid, [Pa]
    Pc : float, optional
        Critical pressure of fluid, [Pa]

    Returns
    -------
    q : float
        Nucleate boiling critical heat flux [W/m^2]
    methods : list, only returned if AvailableMethods == True
        List of methods which can be used to calculate qmax with the given inputs

    Other Parameters
    ----------------
    Method : string, optional
        A string of the function name to use; one of ('Serth-HEDH', 'Zuber', 
        or 'HEDH-Montinsky')
    AvailableMethods : bool, optional
        If True, function will consider which methods which can be used to
        calculate `qmax` with the given inputs
        
    Examples
    --------
    >>> qmax_boiling(D=0.0127, sigma=8.2E-3, Hvap=272E3, rhol=567, rhog=18.09)
    351867.46522901946
    '''
    def list_methods():
        methods = []
        if all((sigma, Hvap, rhol, rhog, D)):
            methods.append('Serth-HEDH')
        if all((sigma, Hvap, rhol, rhog)):
            methods.append('Zuber')
        if all((P, Pc)):
            methods.append('HEDH-Montinsky')
        return methods

    if AvailableMethods:
        return list_methods()
    if not Method:
        methods = list_methods()
        if methods == []:
            raise Exception('Insufficient property or geometry data for any '
                            'method.')
        Method = methods[0]

    if Method == 'Serth-HEDH':
        return Serth_HEDH(D=D, sigma=sigma, Hvap=Hvap, rhol=rhol, rhog=rhog)
    elif Method == 'Zuber':
        return Zuber(sigma=sigma, Hvap=Hvap, rhol=rhol, rhog=rhog)
    elif Method == 'HEDH-Montinsky':
        return HEDH_Montinsky(P=P, Pc=Pc)
    else:
        raise Exception("Correlation name not recognized; options are "
                        "'Serth-HEDH', 'Zuber' and 'HEDH-Montinsky'")