code: def opt_pore_diameter(elements, coordinates, bounds=None, com=None, **kwargs):
      
      args = elements, coordinates
      if com is not None:
          pass
      else:
          com = center_of_mass(elements, coordinates)
      if bounds is None:
          pore_r = pore_diameter(elements, coordinates, com=com)[0] / 2
          bounds = (
              (com[0]-pore_r, com[0]+pore_r),
              (com[1]-pore_r, com[1]+pore_r),
              (com[2]-pore_r, com[2]+pore_r)
          )
      minimisation = minimize(
          correct_pore_diameter, x0=com, args=args, bounds=bounds)
      pored = pore_diameter(elements, coordinates, com=minimisation.x)
      return (pored[0], pored[1], minimisation.x)
docs: Return optimised pore diameter and it's COM.