code: def diam_swamee(FlowRate, HeadLossFric, Length, Nu, PipeRough):
      
      #Checking input validity
      ut.check_range([FlowRate, ">0", "Flow rate"], [Length, ">0", "Length"],
                     [HeadLossFric, ">0", "Headloss due to friction"],
                     [Nu, ">0", "Nu"], [PipeRough, "0-1", "Pipe roughness"])
      a = ((PipeRough ** 1.25)
           * ((Length * FlowRate**2)
              / (gravity.magnitude * HeadLossFric)
              )**4.75
           )
      b = (Nu * FlowRate**9.4
           * (Length / (gravity.magnitude *  HeadLossFric)) ** 5.2
           )
      return 0.66 * (a+b)**0.04
docs: Return the inner diameter of a pipe.
  
      The Swamee Jain equation is dimensionally correct and returns the
      inner diameter of a pipe given the flow rate and the head loss due
      to shear on the pipe walls. The Swamee Jain equation does NOT take
      minor losses into account. This equation ONLY applies to turbulent
      flow.