pymopac package

Submodules

pymopac.classes module

pymopac.helpers module

BlockToXyz(s: str)[source]
checkOverlap(mol)[source]

checks mol object vor overlapping atoms

find_binaries_in_path()[source]
float_checker(string)[source]
get_mopac()[source]

Checks if the MOPAC binary is within the path. looks for approximate alternatives. E.g., finds run_mopac7 on ubuntu22, but older MOPAC versions might parse files differently, thus being incompatible with this wrapper

get_version_string(mopac_path)[source]
optional_imports(libs, namespace)[source]
xyz_identifier(geometry)[source]
xyz_line_checker(line)[source]

Module contents

PyMOPAC: A Python interface for MOPAC calculations.

This package provides tools and utilities for working with MOPAC, a semi-empirical quantum chemistry program.

class MopacInput(geometry, model: str = 'PM7', custom_header: str = '', comment: str = '#', path=False, addHs: bool = True, preopt: bool = True, verbose: bool = False, stream: bool = False, plot: bool = False, aux: bool = True)[source]

Bases: BaseInput

Class that sets up the input file for a MOPAC calculation.

geometry:
  • pure xyz block

  • SMILES (str)

  • rdkit Mol

model: str

all supported MOPAC keywords, e.g. AM1, PM6, …

custom_header: str

custom string that is attached to other header keywords

comment: str

second line in the input file

path:

if False, a dir is created under /tmp/, else under the given str

AddHs: bool

calls AddHs on the mol object

preopt: bool

uses MMFF to optimize the mol structure

verbose: bool

if True, prints additional class internal statements

stream: bool

if True, streams the outfile to stdout

plot: bool

if True, plots progress via matplotlib

+ run()
runs MOPAC as a subprocess
returns MopacOutput class
+ getInpFile()
returns the MOPAC input as a string
geoToXyz()[source]

Helper function that tries to infer a geometry from any input and returns a xyz block

getAuxResult()[source]
getInpFile()[source]
getOutResult()[source]
run()[source]

runs MOPAC as a subprocess returns MopacOutput class

silentRun()[source]

just runs MOPAC, no feedback or streaming

stream_run()[source]

returns both the mopac process and the stream yielding lines

verboseRun()[source]

Sets up the basics for a stream run and contains switches for being verbose and streaming. If plot is True, it creates a live-updating matplotlib figure of gradient values.

class MopacOutput(outfile: str, stdout=None, stderr=None, aux: str | None = None)[source]

Bases: BaseOutput

Main Output class, calls parsers and structures outputs

Custom parsers can be written, inherinting from input.BaseParser. Every Output class has a list at self.parser which, custom parsers can simply be added. If a parser has been added after Output initialization, parsing can be redone using Output.parseAll() By convention, custom parsers are able to set attributes on the Ouput class by having the Output passed as an argument at parse time.

a .aux file is passed, as is standard when creating the output via the MopacInput.run() method. Using this, all properties can be parsed in an unsupervised manner. Results of this can be found under self.auxDict

keys()[source]
toMol()[source]

returns an rdkit.Chem mol object

get_mopac()[source]

Checks if the MOPAC binary is within the path. looks for approximate alternatives. E.g., finds run_mopac7 on ubuntu22, but older MOPAC versions might parse files differently, thus being incompatible with this wrapper