mdgo.mdgopackmol module

This module implements a core class PackmolWrapper for packing molecules into a single box.

You need the Packmol package to run the code, see http://m3g.iqm.unicamp.br/packmol or http://leandro.iqm.unicamp.br/m3g/packmol/home.shtml for download and setup instructions. You may need to manually set the folder of the packmol executable to the PATH environment variable.

class mdgo.mdgopackmol.PackmolWrapper(path, molecules, box=None, tolerance=2.0, seed=1, control_params=None, inputfile='packmol.inp', outputfile='packmol_out.xyz')[source]

Bases: object

Wrapper for the Packmol software that can be used to pack various types of molecules into a one single unit.

Examples

>>> molecules = [{"name": "EMC",
            "number": 2,
          "coords": "/Users/th/Downloads/test_selenium/EMC.lmp.xyz"}]
>>> pw = PackmolWrapper("/path/to/work/dir",
...                     molecules,
...                     [0., 0., 0., 10., 10., 10.]
... )
>>> pw.make_packmol_input()
>>> pw.run_packmol()
Parameters
  • path (str) –

  • molecules (List[Dict]) –

  • box (Optional[List[float]]) –

  • tolerance (float) –

  • seed (int) –

  • control_params (Optional[Dict]) –

  • inputfile (Union[str, Path]) –

  • outputfile (Union[str, Path]) –

run_packmol(timeout=30)[source]

Run packmol and write out the packed structure. :param timeout: Timeout in seconds.

Raises
  • ValueError if packmol does not succeed in packing the box.

  • TimeoutExpiredError if packmold does not finish within the timeout.

make_packmol_input()[source]

Make a Packmol usable input file.