stko.XTBFF

class stko.XTBFF(xtb_path, output_dir=None, opt_level='normal', num_cores=1, charge=0, unlimited_memory=False)[source]

Bases: Optimizer

Uses GFN-FF to optimize molecules.

Parameters:
  • xtb_path (str) – The path to the xTB executable.

  • output_dir (Path | str | None) – The name of the directory into which files generated during the optimization are written, if None then uuid.uuid4() is used.

  • opt_level (str) – Optimization level to use. Can be one of 'crude', 'sloppy', 'loose', 'lax', 'normal', 'tight', 'vtight' or 'extreme'. For details see https://xtb-docs.readthedocs.io/en/latest/optimization.html .

  • num_cores (int) – The number of cores xTB should use.

  • charge (int) – Formal molecular charge.

  • unlimited_memory (bool) – If True optimize() will be run without constraints on the stack size. If memory issues are encountered, this should be True, however this may raise issues on clusters.

Notes

GFN-FF requires >= version 6.3 of xtb.

When running optimize(), this calculator changes the present working directory with os.chdir(). The original working directory will be restored even if an error is raised, so unless multi-threading is being used this implementation detail should not matter.

Currently, we only provide inputs that work with GFN-FF, specifically the charge of the system. Other electronic properties of the molecule are not relavent to a forcefield optimisation.

Examples

Note that for ConstructedMolecule objects constructed by stk, XTBFF should usually be used in a OptimizerSequence. This is because xTB only uses xyz coordinates as input and so will not recognize the long bonds created during construction. An optimizer which can minimize these bonds should be used before XTBFF.

import stk
import stko

bb1 = stk.BuildingBlock('NCCNCCN', [stk.PrimaryAminoFactory()])
bb2 = stk.BuildingBlock('O=CCCC=O', [stk.AldehydeFactory()])
polymer = stk.ConstructedMolecule(
    stk.polymer.Linear(
        building_blocks=(bb1, bb2),
        repeating_unit="AB",
        orientations=[0, 0],
        num_repeating_units=1
    )
)

xtb = stko.OptimizerSequence(
    stko.UFF(),
    stko.XTBFF(
        xtb_path='/opt/gfnxtb/xtb',
        unlimited_memory=True,
    ),
)
polymer = xtb.optimize(polymer)

Methods

optimize

Optimize mol.

optimize(mol)[source]

Optimize mol.

Parameters:

mol (MoleculeT) – The molecule to be optimized.

Returns:

The optimized molecule.

Return type:

MoleculeT