stk.MCHammer

class stk.MCHammer(step_size=0.25, target_bond_length=1.2, num_steps=500, bond_epsilon=50, nonbond_epsilon=20, nonbond_sigma=1.2, nonbond_mu=3, beta=2, random_seed=1000)[source]

Bases: Optimizer

Performs Monte Carlo optimisation of long-bonds in molecules.

Examples

Structure Optimization

Using MCHammer will lead to ConstructedMolecule structures without long bonds.

import stk

bb1 = stk.BuildingBlock('NCCN', [stk.PrimaryAminoFactory()])
bb2 = stk.BuildingBlock('O=CCC=O', [stk.AldehydeFactory()])

polymer = stk.ConstructedMolecule(
    topology_graph=stk.polymer.Linear(
        building_blocks=(bb1, bb2),
        repeating_unit='AB',
        num_repeating_units=6,
        optimizer=stk.MCHammer(),
    ),
)

Optimisation with stk simply collects the final position matrix. The optimisation’s trajectory can be output using the MCHammer implementation if required by the user [1].

The open-source optimization code MCHammer specializes in the collapsing of molecules with long bonds like those constructed by stk. This code is entirely nonphysical and is, therefore, completely general to any chemistry.

References

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

  • target_bond_length (float) – Target equilibrium bond length for long bonds to minimize to in Angstrom.

  • num_steps (int) – Number of MC moves to perform.

  • bond_epsilon (float) – Value of epsilon used in the bond potential in MC moves. Determines strength of the bond potential.

  • nonbond_epsilon (float) – Value of epsilon used in the nonbond potential in MC moves. Determines strength of the nonbond potential. Larger values lead to a larger building block repulsion.

  • nonbond_sigma (float) – Value of sigma used in the nonbond potential in MC moves. Larger values lead to building block repulsion at larger distances.

  • nonbond_mu (float) – Value of mu used in the nonbond potential in MC moves. Determines the steepness of the nonbond potential.

  • beta (float) – Value of beta used in the in MC moves. Beta takes the place of the inverse Boltzmann temperature.

  • random_seed (int | None) – Random seed to use for MC algorithm. If None a system-based random seed will be used and results will not be reproducible between invocations.

Methods

optimize

Optimize the structure of a molecule under construction.

optimize(state)[source]

Optimize the structure of a molecule under construction.

Parameters:

state (ConstructionState) – The molecule being constructed.

Returns:

The optimized construction state.

Return type:

ConstructionState