stko.MacroModelForceField

class stko.MacroModelForceField(macromodel_path, output_dir=None, restricted=False, timeout=None, force_field=16, maximum_iterations=2500, minimum_gradient=0.05)[source]

Bases: MacroModel

Uses MacroModel force fields to optimize molecules.

Parameters:
  • macromodel_path (Path | str) – The full path of the Schrodinger suite within the user’s machine. For example, on a Linux machine this may be something like '/opt/schrodinger2017-2'.

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

  • restricted (bool) – If True then an optimization is performed only on bonds created during the ConstructedMolecule creation. All building block bonds will be fixed. If False then all bonds are optimized.

  • timeout (float | None) – The amount in seconds the optimization is allowed to run before being terminated. None means there is no timeout.

  • force_field (int) –

    The number of the force field to be used. Force field arguments can be the following:

    1 | MM2

    2 | MM3

    3 | AMBER

    4 | AMBER94

    5 | OPLSA

    10 | MMFF94 and MMFF94s

    14 | OPLS_2005

    16 | OPLS3e

  • maximum_iterations (int) – The maximum number of iterations done during the optimization. Cannot be more than 999999.

  • minimum_gradient (float) – The gradient at which optimization is stopped. Cannot be less than 0.0001.

Examples

Optimisation of any stk.Molecule is possible with restricted=False.

import stk
import stko

mol = stk.BuildingBlock('NCCCN')
optimizer = stko.MacroModelForceField(
    macromodel_path='/path/to/macromodel/',
)
mol = optimizer.optimize(mol)

Optimisation of long bonds only within stk.ConstructedMolecule is possible with restricted=True. Generally, this means only bonds created during the construction process will be optimized, and those belonging to building blocks will be fixed. If the molecule is not a ConstructedMolecule, no positions will be optimized.

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
    )
)
optimizer = stko.MacroModelForceField(
    macromodel_path='/path/to/macromodel/',
    restricted=True,
)
polymer = optimizer.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