r'''Returns the Shape factor `S` of a pipe of constant outer temperature
    and of outer diameter `D1` which is `Z` distance from the center of another
    pipe of outer diameter`D2`. Length `L` must be provided, but can be set to
    1 to obtain a dimensionless shape factor used in some sources.

    .. math::
        S = \frac{2\pi L}{\cosh^{-1}
        \left(\frac{D_2^2 + D_1^2 - 4Z^2}{2D_1D_2}\right)}

    Parameters
    ----------
    D1 : float
        Diameter of inner pipe, [m]
    D2 : float
        Diameter of outer pipe, [m]
    Z : float
        Distance from the middle of inner pipe to the center of the other, [m]
    L : float, optional
        Length of the pipe, [m]

    Returns
    -------
    S : float
        Shape factor [m]

    Examples
    --------
    >>> S_isothermal_pipe_eccentric_to_isothermal_pipe(.1, .4, .05, 10)
    47.709841915608976

    Notes
    -----
    L should be much larger than both diameters. D2 should be larger than D1.

    .. math::
        Q = Sk(T_1 - T_2) \\ R_{\text{shape}}=\frac{1}{Sk}

    References
    ----------
    .. [1] Kreith, Frank, Raj Manglik, and Mark Bohn. Principles of Heat
       Transfer. Cengage, 2010.
    .. [2] Bergman, Theodore L., Adrienne S. Lavine, Frank P. Incropera, and
       David P. DeWitt. Introduction to Heat Transfer. 6E. Hoboken, NJ:
       Wiley, 2011.

def S_isothermal_pipe_eccentric_to_isothermal_pipe(D1, D2, Z, L=1.):
    r'''Returns the Shape factor `S` of a pipe of constant outer temperature
    and of outer diameter `D1` which is `Z` distance from the center of another
    pipe of outer diameter`D2`. Length `L` must be provided, but can be set to
    1 to obtain a dimensionless shape factor used in some sources.

    .. math::
        S = \frac{2\pi L}{\cosh^{-1}
        \left(\frac{D_2^2 + D_1^2 - 4Z^2}{2D_1D_2}\right)}

    Parameters
    ----------
    D1 : float
        Diameter of inner pipe, [m]
    D2 : float
        Diameter of outer pipe, [m]
    Z : float
        Distance from the middle of inner pipe to the center of the other, [m]
    L : float, optional
        Length of the pipe, [m]

    Returns
    -------
    S : float
        Shape factor [m]

    Examples
    --------
    >>> S_isothermal_pipe_eccentric_to_isothermal_pipe(.1, .4, .05, 10)
    47.709841915608976

    Notes
    -----
    L should be much larger than both diameters. D2 should be larger than D1.

    .. math::
        Q = Sk(T_1 - T_2) \\ R_{\text{shape}}=\frac{1}{Sk}

    References
    ----------
    .. [1] Kreith, Frank, Raj Manglik, and Mark Bohn. Principles of Heat
       Transfer. Cengage, 2010.
    .. [2] Bergman, Theodore L., Adrienne S. Lavine, Frank P. Incropera, and
       David P. DeWitt. Introduction to Heat Transfer. 6E. Hoboken, NJ:
       Wiley, 2011.
    '''
    return 2.*pi*L/acosh((D2**2 + D1**2 - 4.*Z**2)/(2.*D1*D2))