Ejemplo n.º 1
0
    b_ids = ((bond.get_atom1().get_id(), bond.get_atom2().get_id())
             if bond.get_atom1().get_id() < bond.get_atom2().get_id() else
             (bond.get_atom2().get_id(), bond.get_atom1().get_id()))
    benzene_bonds.append((i, b_ids))

mch_mol = mch.Molecule(
    atoms=(mch.Atom(id=i[0], element_string=i[1]) for i in benzene_atoms),
    bonds=(mch.Bond(id=i[0], atom1_id=i[1][0], atom2_id=i[1][1])
           for i in benzene_bonds),
    position_matrix=benzene.get_position_matrix(),
)

target_bond_length = 1.2
optimizer = mch.Optimizer(
    step_size=0.25,
    target_bond_length=target_bond_length,
    num_steps=100,
)
subunits = mch_mol.get_subunits(bond_pair_ids=((2, 3), (1, 5)), )
# Get all steps.
mch_result = optimizer.get_trajectory(
    mol=mch_mol,
    bond_pair_ids=((2, 3), (1, 5)),
    subunits=subunits,
)
benzene = benzene.with_position_matrix(mch_result.get_final_position_matrix())
benzene.write('benzene_opt.mol')

with open('benzene_opt.out', 'w') as f:
    f.write(mch_result.get_log())
Ejemplo n.º 2
0
        ) for atom in cage.get_atoms()
    ),
    bonds=(
        mch.Bond(
            id=i,
            atom1_id=bond.get_atom1().get_id(),
            atom2_id=bond.get_atom2().get_id()
        ) for i, bond in enumerate(cage.get_bonds())
    ),
    position_matrix=cage.get_position_matrix(),
)
mch_mol_nci = deepcopy(mch_mol)

optimizer = mch.Optimizer(
    step_size=0.25,
    target_bond_length=1.2,
    num_steps=500,
)
subunits = mch_mol.get_subunits(
    bond_pair_ids=stk_long_bond_ids,
)
# Just get final step.
mch_result = optimizer.get_result(
    mol=mch_mol,
    bond_pair_ids=stk_long_bond_ids,
    subunits=subunits,
)


optimizer = mch.Optimizer(
    step_size=0.25,
Ejemplo n.º 3
0
    def __init__(
        self,
        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,
    ):
        """
        Initialize an instance of :class:`.MCHammer`.

        Parameters
        ----------
        step_size : :class:`float`, optional
            The relative size of the step to take during step.

        target_bond_length : :class:`float`, optional
            Target equilibrium bond length for long bonds to minimize
            to in Angstrom.

        num_steps : :class:`int`, optional
            Number of MC moves to perform.

        bond_epsilon : :class:`float`, optional
            Value of epsilon used in the bond potential in MC moves.
            Determines strength of the bond potential.

        nonbond_epsilon : :class:`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 : :class:`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 : :class:`float`, optional
            Value of mu used in the nonbond potential in MC moves.
            Determines the steepness of the nonbond potential.

        beta : :class:`float`, optional
            Value of beta used in the in MC moves. Beta takes the
            place of the inverse Boltzmann temperature.

        random_seed : :class:`int` or :class:`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.

        """

        self._optimizer = mch.Optimizer(
            step_size=step_size,
            target_bond_length=target_bond_length,
            num_steps=num_steps,
            bond_epsilon=bond_epsilon,
            nonbond_epsilon=nonbond_epsilon,
            nonbond_sigma=nonbond_sigma,
            nonbond_mu=nonbond_mu,
            beta=beta,
            random_seed=random_seed,
        )
Ejemplo n.º 4
0
def optimizer():
    return mch.Optimizer(
        step_size=0.1,
        target_bond_length=2.0,
        num_steps=100
    )