stko.MetalOptimizer

class stko.MetalOptimizer(metal_binder_distance=1.6, metal_binder_forceconstant=100.0, max_iterations=500)[source]

Bases: Optimizer

Applies forcefield optimizers in rdkit that can handle metals.

Parameters:
  • metal_binder_distance (float) – Distance in Angstrom.

  • metal_binder_forceconstant (float) – Force constant to use for restricted metal-ligand bonds.

  • max_iterations (int) – Number of iteractions to run.

See also

Notes

By default, optimize() will run a restricted optimization using constraints and the UFF. To implement this, metal atoms are replaced by noninteracting H atoms, and constraints are applied to maintain the metal centre geometry. Restrictions are applied to the ligand with respect to its input structure. So if that is poorly optimised, then the output will be also.

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

Examples

MetalOptimizer allows for the restricted optimization of ConstructedMolecule instances containing metals. Note that this optimizer algorithm is not very robust to large bonds and may fail.

import stk
import stko

# Produce a Pd+2 atom with 4 functional groups.
palladium_atom = stk.BuildingBlock(
    smiles='[Pd+2]',
    functional_groups=(
        stk.SingleAtom(stk.Pd(0, charge=2))
        for i in range(4)
    ),
    position_matrix=[[0., 0., 0.]],
)

# Build a building block with two functional groups using
# the SmartsFunctionalGroupFactory.
bb1 = stk.BuildingBlock(
    smiles=(
        'C1=NC=CC(C2=CC=CC(C3=C'
        'C=NC=C3)=C2)=C1'
    ),
    functional_groups=[
        stk.SmartsFunctionalGroupFactory(
            smarts='[#6]~[#7X2]~[#6]',
            bonders=(1, ),
            deleters=(),
        ),
    ],
)

cage1 = stk.ConstructedMolecule(
    stk.cage.M3L6(
        building_blocks=(palladium_atom, bb1),
        # Ensure that bonds between the GenericFunctionalGroups
        # of the ligand and the SingleAtom functional groups
        # of the metal are dative.
        reaction_factory=stk.DativeReactionFactory(
            stk.GenericReactionFactory(
                bond_orders={
                    frozenset({
                        stk.GenericFunctionalGroup,
                        stk.SingleAtom
                    }): 9
                }
            )
        ),
        optimizer=stk.MCHammer(),
    )
)

# Define an optimizer.
optimizer = stko.MetalOptimizer()

# Optimize.
opt_cage1 = optimizer.optimize(mol=cage1)

Methods

optimize

Optimize mol.

optimize(mol)[source]

Optimize mol.

Parameters:

mol (MoleculeT) – The molecule to be optimized.

Returns:

The optimized molecule.

Return type:

MoleculeT