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