docs: def K_gate_valve_Crane(D1, D2, angle, fd=None):
      r'''Returns loss coefficient for a gate valve of types wedge disc, double
      disc, or plug type, as shown in [1]_.
  
      If β = 1 and θ = 0:
          
      .. math::
          K = K_1 = K_2 = 8f_d
          
      If β < 1 and θ <= 45°:
          
      .. math::
          K_2 = \frac{K + \sin \frac{\theta}{2} \left[0.8(1-\beta^2) 
          + 2.6(1-\beta^2)^2\right]}{\beta^4}
              
      If β < 1 and θ > 45°:
          
      .. math::
          K_2 = \frac{K + 0.5\sqrt{\sin\frac{\theta}{2}}(1-\beta^2) 
          + (1-\beta^2)^2}{\beta^4}
          
      Parameters
      ----------
      D1 : float
          Diameter of the valve seat bore (must be smaller or equal to `D2`), [m]
      D2 : float
          Diameter of the pipe attached to the valve, [m]
      angle : float
          Angle formed by the reducer in the valve, [degrees]
      fd : float, optional
          Darcy friction factor calculated for the actual pipe flow in clean 
          steel (roughness = 0.0018 inch) in the fully developed turbulent 
          region; do not specify this to use the original Crane friction factor!
          [-]
  
      Returns
      -------
      K : float
          Loss coefficient with respect to the pipe inside diameter [-]
  
      Notes
      -----    
      This method is not valid in the laminar regime and the pressure drop will
      be underestimated in those conditions [2]_.
      
      Examples
      --------
      Example 7-4 in [1]_; a 150 by 100 mm class 600 steel gate valve, conically
      tapered ports, length 550 mm, back of sear ring ~150 mm. The valve is 
      connected to 146 mm schedule 80 pipe. The angle can be calculated to be 
      13 degrees. The valve is specified to be operating in turbulent conditions.
      
      >>> K_gate_valve_Crane(D1=.1, D2=.146, angle=13.115)
      1.1466029421844073
      
      The calculated result is lower than their value of 1.22; the difference is
      due to Crane's generous intermediate rounding. A later, Imperial edition of
      Crane rounds differently - and comes up with K=1.06.
      
      References
      ----------
      .. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
         2009.
      .. [2] Harvey Wilson. "Pressure Drop in Pipe Fittings and Valves | 
         Equivalent Length and Resistance Coefficient." Katmar Software. Accessed
         July 28, 2017. http://www.katmarsoftware.com/articles/pipe-fitting-pressure-drop.htm.
      '''
      angle = radians(angle)
      beta = D1/D2
      if fd is None:
          fd = ft_Crane(D2)
      K1 = 8.0*fd # This does not refer to upstream loss per se
      if beta == 1 or angle == 0:
          return K1 # upstream and down
      else:
          beta2 = beta*beta
          one_m_beta2 = 1.0 - beta2
          if angle <= 0.7853981633974483:
              K = (K1 + sin(0.5*angle)*(0.8*one_m_beta2 + 2.6*one_m_beta2*one_m_beta2))/(beta2*beta2)
          else:
              K = (K1 + 0.5*(sin(0.5*angle))**0.5*one_m_beta2 + one_m_beta2*one_m_beta2)/(beta2*beta2)
      return K