r'''Returns the Shape factor `S` of a pipe of constant outer temperature
    and of outer diameter `D` which is `Z` distance from two infinite
    isothermal planes of equal temperatures, parallel to each other and
    enclosing the pipe. 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}{\ln\frac{8z}{\pi D}}

    Parameters
    ----------
    D : float
        Diameter of the pipe, [m]
    Z : float
        Distance from the middle of the pipe to either of the planes, [m]
    L : float, optional
        Length of the pipe, [m]

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

    Examples
    --------
    >>> S_isothermal_pipe_to_two_planes(.1, 5, 1)
    1.2963749299921428

    Notes
    -----
    L should be much larger than both diameters. L should be larger than W.

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

    References
    ----------
    .. [1] Shape Factors for Heat Conduction Through Bodies with Isothermal or
       Convective Boundary Conditions, J. E. Sunderland, K. R. Johnson, ASHRAE
       Transactions, Vol. 70, 1964.
    .. [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_to_two_planes(D, Z, L=1.):
    r'''Returns the Shape factor `S` of a pipe of constant outer temperature
    and of outer diameter `D` which is `Z` distance from two infinite
    isothermal planes of equal temperatures, parallel to each other and
    enclosing the pipe. 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}{\ln\frac{8z}{\pi D}}

    Parameters
    ----------
    D : float
        Diameter of the pipe, [m]
    Z : float
        Distance from the middle of the pipe to either of the planes, [m]
    L : float, optional
        Length of the pipe, [m]

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

    Examples
    --------
    >>> S_isothermal_pipe_to_two_planes(.1, 5, 1)
    1.2963749299921428

    Notes
    -----
    L should be much larger than both diameters. L should be larger than W.

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

    References
    ----------
    .. [1] Shape Factors for Heat Conduction Through Bodies with Isothermal or
       Convective Boundary Conditions, J. E. Sunderland, K. R. Johnson, ASHRAE
       Transactions, Vol. 70, 1964.
    .. [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/log(8.*Z/(pi*D))