docs: def K_to_discharge_coefficient(D, Do, K):
      r'''Converts a standard loss coefficient to a discharge coefficient.
      
      .. math::
          C = \sqrt{\frac{1}{2 \sqrt{K} \beta^{4} + K \beta^{4}}
          - \frac{\beta^{4}}{2 \sqrt{K} \beta^{4} + K \beta^{4}} }
          
      Parameters
      ----------
      D : float
          Upstream internal pipe diameter, [m]
      Do : float
          Diameter of orifice at flow conditions, [m]
      K : float
          Loss coefficient with respect to the velocity and density of the fluid
          just upstream of the orifice, [-]
  
      Returns
      -------
      C : float
          Coefficient of discharge of the orifice, [-]
  
      Notes
      -----
      If expansibility is used in the orifice calculation, the result will not
      match with the specified pressure drop formula in [1]_; it can almost
      be matched by dividing the calculated mass flow by the expansibility factor
      and using that mass flow with the loss coefficient. 
      
      This expression was derived with SymPy, and checked numerically. There were
      three other, incorrect roots.
      
      Examples
      --------
      >>> K_to_discharge_coefficient(D=0.07366, Do=0.05, K=5.2314291729754)
      0.6151200000000001
      
      References
      ----------
      .. [1] American Society of Mechanical Engineers. Mfc-3M-2004 Measurement 
         Of Fluid Flow In Pipes Using Orifice, Nozzle, And Venturi. ASME, 2001.
      .. [2] ISO 5167-2:2003 - Measurement of Fluid Flow by Means of Pressure 
         Differential Devices Inserted in Circular Cross-Section Conduits Running
         Full -- Part 2: Orifice Plates.
      '''
      beta = Do/D
      beta2 = beta*beta
      beta4 = beta2*beta2
      root_K = K**0.5
      common_term = 2.0*root_K*beta4 + K*beta4
      return (-beta4/(common_term) + 1.0/(common_term))**0.5