stko.OpenBabel

class stko.OpenBabel(forcefield, repeat_steps=10, sd_steps=50, cg_steps=50)[source]

Bases: Optimizer

Use OpenBabel to optimize molecules with forcefields.

Warning

This will not work for Python >= 3.13! See https://github.com/JelfsMaterialsGroup/stko/issues/208

Parameters:
  • forcefield (str) – Forcefield to use. Options include uff, gaff, ghemical, mmff94.

  • repeat_steps (int) – Number of optimisation steps. Each optimisation step contains sd_steps steepest descent and then cg_steps conjugate gradient runs.

  • sd_steps (int) – Number of steepest descent steps per optimisations.

  • cg_steps (int) – Number of conjugate gradient steps per optimisations.

Raises:

WrapperNotInstalledError – if openbabel not installed.

Warning

this optimizer seems to be machine dependant, producing different energies after optimisation on Ubunut 18 vs. Ubuntu 20.

Examples

import stk
import stko

mol = stk.BuildingBlock('NCCNCCN')
openbabel = stko.OpenBabel('uff')
opt_mol = openbabel.optimize(mol)

Methods

optimize

Optimize mol.

optimize(mol)[source]

Optimize mol.

Parameters:

mol (MoleculeT) – The molecule to be optimized.

Returns:

The optimized molecule.

Return type:

MoleculeT