docs: def NTU_from_P_H(P1, R1, Ntp, optimal=True):
      r'''Returns the number of transfer units of a TEMA H type heat exchanger
      with a specified (for side 1) thermal effectiveness `P1`, heat capacity 
      ratio `R1`, the number of tube passes `Ntp`, and for the two-pass case
      whether or not the inlets are arranged optimally. The supported cases are 
      as follows:
          
      * One tube pass (tube fluid split into two streams individually mixed,  
        shell fluid mixed)
      * Two tube passes (shell fluid mixed, tube pass mixed between passes)
      * Two tube passes (shell fluid mixed, tube pass mixed between passes, inlet
        tube side next to inlet shell-side)
                      
      Parameters
      ----------
      P1 : float
          Thermal effectiveness of the heat exchanger in the P-NTU method,
          calculated with respect to stream 1 [-]
      R1 : float
          Heat capacity ratio of the heat exchanger in the P-NTU method,
          calculated with respect to stream 1 (shell side = 1, tube side = 2) [-]
      Ntp : int
          Number of tube passes, 1, or 2, [-]
      optimal : bool, optional
          Whether or not the arrangement is configured to give more of a
          countercurrent and efficient (True) case or an inefficient parallel
          case, [-]
          
      Returns
      -------
      NTU1 : float
          Thermal number of transfer units of the heat exchanger in the P-NTU 
          method, calculated with respect to stream 1 (shell side = 1, tube side
          = 2) [-]
  
      Notes
      -----
      For numbers of tube passes greater than 1 or 2, an exception is raised.
      
      Only numerical solutions are available for this function. For the case of
      1 tube pass or the optimal 2 tube pass, the function is monotonic and a 
      bounded solver is used with NTU1 between 1E-11 and 100; it will find the
      solution anywhere in that range. 
      
      For the non-optimal 2 pass case, the function is not monotonic and a pade
      approximation was used to obtain a curve of NTU1s which give the maximum
      P1s which is used as the upper bound in the bounded solver. The lower 
      bound is still 1E-11. These solvers are all robust. 
  
      Examples
      --------
      >>> NTU_from_P_H(P1=0.573, R1=1/3., Ntp=1)
      0.9997628696881165
      '''
      NTU_min = 1E-11
      function = temperature_effectiveness_TEMA_H
      if Ntp == 1:
          NTU_max = 100
      elif Ntp == 2 and optimal:
          NTU_max = 100
      elif Ntp == 2 and not optimal:
          NTU_max = _NTU_max_for_P_solver(NTU_from_H_2_unoptimal, R1)
      else:
          raise Exception('Supported numbers of tube passes are 1 and 2.')
      return _NTU_from_P_solver(P1, R1, NTU_min, NTU_max, function, Ntp=Ntp, optimal=optimal)