MCHammer

class 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: stk.molecular.topology_graphs.topology_graph.optimizers.optimizer.Optimizer

Performs Monte Carlo optimisation of long-bonds in molecules [1].

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

1(1,2)

https://github.com/andrewtarzia/MCHammer

Methods

optimize(state)

Optimize the structure of a molecule under construction.

__init__(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]

Initialize an instance of MCHammer.

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

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

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

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

  • nonbond_epsilon (float, optional) – 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, optional) – Value of sigma used in the nonbond potential in MC moves. Larger values lead to building block repulsion at larger distances.

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

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

  • random_seed (int or NoneType, optional) – 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.

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