docs: def contraction_conical(Di1, Di2, fd=None, l=None, angle=None,
                          Re=None, roughness=0.0, method='Rennels'):
      r'''Returns the loss coefficient for any conical pipe contraction.
      This calculation has five methods available. The 'Idelchik' [2]_ and 
      'Blevins' [3]_ methods use interpolation among tables of values; 'Miller' 
      uses a 2d spline representation of a graph; and the 
      'Rennels' [1]_, 'Crane' [4]_, and 'Swamee' [5]_ methods use formulas for
      their calculations.
      
      The 'Rennels' [1]_ formulas are:
  
      .. math::
          K_2 = K_{fr,2} + K_{conv,2}
          
      .. math::
          K_{fr,2} = \frac{f_d}{1 - \beta^4}{8\sin(\theta/2)}
          
      .. math::
          K_{conv,2} = 0.0696[1+C_B(\sin(\alpha/2)-1)](1-\beta^5)\lambda^2 + (\lambda-1)^2
  
      .. math::
          \lambda = 1 + 0.622(\alpha/180)^{0.8}(1-0.215\beta^2-0.785\beta^5)
  
      .. math::
          \beta = d_2/d_1
      
      The 'Swamee' [5]_ formula is:
      
      .. math::
          K = 0.315 \theta^{1/3}
  
      .. figure:: fittings/contraction_conical.png
         :scale: 30 %
         :alt: contraction conical; after [1]_
  
      Parameters
      ----------
      Di1 : float
          Inside pipe diameter of the larger, upstream, pipe, [m]    
      Di2 : float
          Inside pipe diameter of the smaller, downstream, pipe, [m]    
      fd : float, optional
          Darcy friction factor; used only in the Rennels method and will be 
          calculated if not given, [-]
      l : float, optional
          Length of the contraction, optional [m]
      angle : float, optional
          Angle of contraction (180 = sharp, 0 = infinitely long contraction),
          optional [degrees]
      Re : float, optional
          Reynolds number of the pipe (used in Rennels method only if no friction
          factor given), [m]
      roughness : float, optional
          Roughness of bend wall (used in Rennel method if no friction factor 
          given), [m]   
      method : str, optional
          The method to use for the calculation; one of 'Rennels', 'Idelchik',
          'Crane', 'Swamee' or 'Blevins', [-]
  
      Returns
      -------
      K : float
          Loss coefficient in terms of the following pipe [-]
  
      Notes
      -----
      Cheap and has substantial impact on pressure drop.
      
      The 'Idelchik' method includes two tabular interpolations; its friction
      term is limited to angles between 2 and 20 degrees and area ratios 0.05 to
      0.6, while its main term is limited to length over diameter ratios 0.025 to
      0.6. This seems to give it high results for angles < 25 degrees.
      
      The 'Blevins' method is based on Idelchik data; it should not be used, 
      because its data jumps around and its data is limited to area ratios .1 to
      0.83, and length over diameter ratios 0 to 0.6. The 'Miller' method jumps
      around as well. Unlike most of Miller's method, there is no correction for 
      Reynolds number.
  
      
      There is quite a bit of variance in the predictions of the methods, as 
      demonstrated by the following figure.
  
      .. plot:: plots/contraction_conical.py
  
      Examples
      --------
      >>> contraction_conical(Di1=0.1, Di2=0.04, l=0.04, Re=1E6)
      0.15639885880609544
  
      References
      ----------
      .. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
         and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
      .. [2] 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.
      .. [3] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.: 
         Van Nostrand Reinhold Co., 1984.
      .. [4] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
         2009.
      .. [5] Swamee, Prabhata K., and Ashok K. Sharma. Design of Water Supply 
         Pipe Networks. John Wiley & Sons, 2008.
      .. [6] Miller, Donald S. Internal Flow Systems: Design and Performance
         Prediction. Gulf Publishing Company, 1990.
      '''
      beta = Di2/Di1
      if angle is not None:
          angle_rad = radians(angle)
          l = (Di1 - Di2)/(2.0*tan(0.5*angle_rad)) 
      elif l is not None:
          try:
              angle_rad = 2.0*atan((Di1-Di2)/(2.0*l))
              angle = degrees(angle_rad)
          except ZeroDivisionError:
              angle_rad = pi
              angle = 180.0
      else:
          raise Exception('Either l or angle is required')
      if method is None:
          method == 'Rennels'
  
      if method == 'Rennels':
          if fd is None:
              if Re is None:
                  raise ValueError("The `Rennels` method requires either a "
                                   "specified friction factor or `Re`")
              fd = Colebrook(Re=Re, eD=roughness/Di2, tol=-1)
              
          beta2 = beta*beta
          beta4 = beta2*beta2
          beta5 = beta4*beta
          lbd = 1.0 + 0.622*(angle_rad/pi)**0.8*(1.0 - 0.215*beta2 - 0.785*beta5)
          sin_half_angle = sin(0.5*angle_rad)
          K_fr2 = fd*(1.0 - beta4)/(8.0*sin_half_angle)
          K_conv2 = 0.0696*sin_half_angle*(1.0 - beta5)*lbd*lbd + (lbd - 1.0)**2
          return K_fr2 + K_conv2
      elif method == 'Crane':
          return contraction_conical_Crane(Di1=Di1, Di2=Di2, l=l, angle=angle)
      elif method == 'Swamee':
          return 0.315*angle_rad**(1.0/3.0)
      elif method == 'Idelchik':
          # Diagram 3-6; already digitized for beveled entrance
          K0 = float(entrance_beveled_Idelchik_obj(angle, l/Di2))
          
          # Angles 0 to 20, ratios 0.05 to 0.06
          if angle > 20.0:
              angle_fric = 20.0
          elif angle < 2.0:
              angle_fric = 2.0
          else:
              angle_fric = angle
              
          A_ratio = A_ratio_fric = Di2*Di2/(Di1*Di1)
          if A_ratio_fric < 0.05:
              A_ratio_fric = 0.05
          elif A_ratio_fric > 0.6:
              A_ratio_fric = 0.6
              
          K_fr = float(contraction_conical_frction_Idelchik_obj(angle_fric, A_ratio_fric))
          return K0*(1.0 - A_ratio) + K_fr
      elif method == 'Blevins':
          A_ratio = Di1*Di1/(Di2*Di2)
          if A_ratio < 1.2:
              A_ratio = 1.2
          elif A_ratio > 10.0:
              A_ratio = 10.0
          
          l_ratio = l/Di2
          if l_ratio > 0.6:
              l_ratio= 0.6
          return float(contraction_conical_Blevins_obj(l_ratio, A_ratio))
      elif method == 'Miller':
          A_ratio = Di1*Di1/(Di2*Di2)
          if A_ratio > 4.0:
              A_ratio = 4.0
          elif A_ratio < 1.1:
              A_ratio = 1.1
          l_ratio = l/(Di2*0.5)
          if l_ratio < 0.1:
              l_ratio = 0.1
          elif l_ratio > 10.0:
              l_ratio = 10.0
          # Turning on ofr off the limits - little difference in plot
          return contraction_conical_Miller_obj(l_ratio, A_ratio)
      else:
          raise ValueError('Specified method not recognized; methods are %s'
                           %(contraction_conical_methods))