stko.Optimizer
- class stko.Optimizer(*args, **kwargs)[source]
Bases:
ProtocolA base class for optimizers.
Optimizers are objects used to optimize molecules. Each optimizer is initialized with some settings and can optimize a molecule with
optimize().import stk import stko mol = stk.BuildingBlock('NCCCN', [stk.PrimaryAminoFactory()]) mmff = stko.MMFF() mol = mmff.optimize(mol) # Optimizers also work with ConstructedMolecule objects. polymer = stk.ConstructedMolecule( topology_graph=stk.polymer.Linear( building_blocks=(mol, ), repeating_unit='A', num_repeating_units=3, ) ) etkdg = stko.ETKDG() polymer = etkdg.optimize(polymer)
Sometimes it is desirable to chain multiple optimizations, one after another. For example, before running an optimization, it may be desirable to embed a molecule first, to generate an initial structure.
OptimizerSequencemay be used for this.# Create a new optimizer which chains the previously defined # mmff and etkdg optimizers. optimizer_sequence = stko.OptimizerSequence(etkdg, mmff) # Run each optimizer in sequence. polymer = optimizer_sequence.optimize(polymer)
Making New Optimizers:
New optimizers can be made by simply making a class which defines a
optimize()method. The method must take 1 mandatory mol parameter.optimize()will take the mol and change its structure in whatever way it likes. Beyond this there are no requirements. New optimizers can be added into theoptimizerssubmodule or into a new submodule.Methods
Optimize mol.