docs: def entrance_distance(Di, t=None, l=None, method='Rennels'):
      r'''Returns the loss coefficient for a sharp entrance to a pipe at a distance
      from the wall of a reservoir. This calculation has five methods available;
      all but 'Idelchik' require the pipe to be at least `Di/2` into the
      reservoir.
  
      The most conservative formulation is that of Rennels; with Miller being
      almost identical until `t/Di` reaches 0.05, when it continues settling to
      K = 0.53 compared to K = 0.57 for 'Rennels'. 'Idelchik' is offset lower
      by about 0.03 and settles to 0.50. The 'Harris' method is a straight
      interpolation from experimental results with smoothing, and it is the 
      lowest at all points. The 'Crane' [6]_ method returns 0.78 for all cases.
      
      The Rennels [1]_ formula is:
  
      .. math::
          K = 1.12 - 22\frac{t}{d} + 216\left(\frac{t}{d}\right)^2 +
          80\left(\frac{t}{d}\right)^3
  
      .. figure:: fittings/sharp_edged_entrace_extended_mount.png
         :scale: 30 %
         :alt: sharp edged entrace, extended mount; after [1]_
          
      Parameters
      ----------
      Di : float
          Inside diameter of pipe, [m]
      t : float, optional
          Thickness of pipe wall, used in all but 'Crane' method, [m]
      l : float, optional
          The distance the pipe extends into the reservoir; used only in the
          'Idelchik' method, defaults to `Di`, [m]
      method : str, optional
          One of 'Rennels', 'Miller', 'Idelchik', 'Harris', 'Crane', [-]
          
      Returns
      -------
      K : float
          Loss coefficient [-]
  
      Notes
      -----
      This type of inlet is also known as a Borda's mouthpiece.
      It is not of practical interest according to [1]_.
      
      The 'Idelchik' [3]_ data is recommended in [5]_; it also provides rounded
      values for the 'Harris. method.
      
      .. plot:: plots/entrance_distance.py
      
      Examples
      --------
      >>> entrance_distance(Di=0.1, t=0.0005)
      1.0154100000000001
      >>> entrance_distance(Di=0.1, t=0.0005, method='Idelchik')
      0.9249999999999999
      >>> entrance_distance(Di=0.1, t=0.0005, l=.02, method='Idelchik')
      0.8474999999999999
  
      References
      ----------
      .. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
         and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
      .. [2] Miller, Donald S. Internal Flow Systems: Design and Performance
         Prediction. Gulf Publishing Company, 1990.
      .. [3] Idel’chik, I. E. Handbook of Hydraulic Resistance: Coefficients of 
         Local Resistance and of Friction (Spravochnik Po Gidravlicheskim 
         Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
         Treniya). National technical information Service, 1966.
      .. [4] Harris, Charles William. The Influence of Pipe Thickness on 
         Re-Entrant Intake Losses. Vol. 48. University of Washington, 1928.
      .. [5] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.: 
         Van Nostrand Reinhold Co., 1984.
      .. [6] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
         2009.
      '''
      if method is None:
          method = 'Rennels'
      if method == 'Rennels':
          t_Di = t/Di
          if t_Di > 0.05:
              t_Di = 0.05
          return 1.12 + t_Di*(t_Di*(80.0*t_Di + 216.0) - 22.0)
      elif method == 'Miller':
          t_Di = t/Di
          if t_Di > 0.3:
              t_Di = 0.3
          return horner(entrance_distance_Miller_coeffs, 20.0/3.0*(t_Di - 0.15))
      elif method == 'Idelchik':
          if l is None:
              l = Di
          t_Di = min(t/Di, 1.0)
          l_Di = min(l/Di, 10.0)
          K = float(entrance_distance_Idelchik_obj(l_Di, t_Di))
          if K < 0.0:
              K = 0.0
          return K
      elif method == 'Harris':
          ratio = min(t/Di, 0.289145) # max value for interpolation - extrapolation looks bad
          K = float(entrance_distance_Harris_obj(ratio))
          return K
      elif method == 'Crane':
          return 0.78
      else:
          raise ValueError('Specified method not recognized; methods are %s'
                           %(entrance_distance_methods))