r'''A rough equation presented in the HEDH for estimating the tube bundle
    diameter necessary to fit a given number of tubes. 
    No accuracy estimation given. Only 1 pass is supported.

    .. math::
        D_{bundle} = (D_o + (\text{pitch})\sqrt{\frac{1}{0.78}}\cdot
        \sqrt{C_1\cdot N})


    C1 = 0.866 for 30° and 60° layouts, and 1 for 45 and 90° layouts.

    Parameters
    ----------
    N : float
        Number of tubes, [-]
    Do : float
        Tube outer diameter, [m]
    pitch : float
        Pitch; distance between two orthogonal tube centers, [m]
    angle : float
        The angle the tubes are positioned; 30, 45, 60 or 90, [degrees]

    Returns
    -------
    DBundle : float
        Outer diameter of tube bundle, [m]

    Notes
    -----
    Easily reversed from the main formulation.

    Examples
    --------
    >>> DBundle_for_Ntubes_HEDH(N=928, Do=.028, pitch=.036, angle=30)
    1.1839930795640605

    References
    ----------
    .. [1] Schlunder, Ernst U, and International Center for Heat and Mass
       Transfer. Heat Exchanger Design Handbook. Washington:
       Hemisphere Pub. Corp., 1983.

def DBundle_for_Ntubes_HEDH(N, Do, pitch, angle=30):
    r'''A rough equation presented in the HEDH for estimating the tube bundle
    diameter necessary to fit a given number of tubes. 
    No accuracy estimation given. Only 1 pass is supported.

    .. math::
        D_{bundle} = (D_o + (\text{pitch})\sqrt{\frac{1}{0.78}}\cdot
        \sqrt{C_1\cdot N})


    C1 = 0.866 for 30° and 60° layouts, and 1 for 45 and 90° layouts.

    Parameters
    ----------
    N : float
        Number of tubes, [-]
    Do : float
        Tube outer diameter, [m]
    pitch : float
        Pitch; distance between two orthogonal tube centers, [m]
    angle : float
        The angle the tubes are positioned; 30, 45, 60 or 90, [degrees]

    Returns
    -------
    DBundle : float
        Outer diameter of tube bundle, [m]

    Notes
    -----
    Easily reversed from the main formulation.

    Examples
    --------
    >>> DBundle_for_Ntubes_HEDH(N=928, Do=.028, pitch=.036, angle=30)
    1.1839930795640605

    References
    ----------
    .. [1] Schlunder, Ernst U, and International Center for Heat and Mass
       Transfer. Heat Exchanger Design Handbook. Washington:
       Hemisphere Pub. Corp., 1983.
    '''
    if angle == 30 or angle == 60:
        C1 = 13/15.
    elif angle == 45 or angle == 90:
        C1 = 1.
    else:
        raise Exception('Only 30, 60, 45 and 90 degree layouts are supported')
    return (Do + (1./.78)**0.5*pitch*(C1*N)**0.5)