stko.Collapser

class stko.Collapser(output_dir, step_size, distance_cut, scale_steps=True)[source]

Bases: object

Collapse stk.ConstructedMolecule to decrease enlarged bonds.

It is recommended to use the MCHammer version of this code with MCHammer [1], where a much cleaner version is written. The utilities get_long_bond_ids will help generate sub units.

This optimizer aims to bring extended bonds closer together for further optimisation.

import stk
import stko

bb1 = stk.BuildingBlock('NCCN', [stk.PrimaryAminoFactory()])
bb2 = stk.BuildingBlock(
    smiles='O=CC(C=O)C=O',
    functional_groups=[stk.AldehydeFactory()],
)
cage1 = stk.ConstructedMolecule(
    topology_graph=stk.cage.FourPlusSix((bb1, bb2)),
)

# Perform collapser optimisation.
optimizer = stko.Collapser(
    output_dir='test_coll',
    step_size=0.05,
    distance_cut=2.0,
    scale_steps=True,
)
cage1 = optimizer.optimize(mol=cage1)
Parameters:
  • output_dir (Path | str) – The name of the directory into which files generated during the calculation are written.

  • step_size (float) – The relative size of the step to take during collapse.

  • distance_cut (float) – Distance between distinct building blocks to use as threshold for halting collapse in Angstrom.

  • scale_steps (bool) – Whether to scale the step of each distict building block by their relative distance from the molecules centroid. Defaults to True

References

Methods

optimize

p_optimize

Optimize mol.

optimize(mol)[source]
Parameters:

mol (ConstructedMoleculeT)

Return type:

ConstructedMoleculeT

p_optimize(mol, unit_cell)[source]

Optimize mol.

Parameters:
  • mol (Molecule) – The molecule to be optimized.

  • unit_cell (UnitCell) – The cell to be optimized.

Returns:

The optimized molecule and the optimized cell.

Return type:

tuple[Molecule, UnitCell]