def __init__( self, step_size=0.1, distance_threshold=1.5, scale_steps=False, ): """ Initialize an instance of :class:`.PeriodicCollapser`. Parameters ---------- step_size : :class:`float`, optional The relative size of the step to take during collapse in Angstrom. distance_threshold : :class:`float`, optional Distance between distinct building blocks to use as threshold for halting collapse in Angstrom. scale_steps : :class:`bool`, optional Whether to scale the step of each distinct building block by its relative distance from the molecules centroid. """ self._optimizer = mch.Collapser( step_size=step_size, distance_threshold=distance_threshold, scale_steps=scale_steps, )
def collapser(): return mch.Collapser( step_size=0.05, distance_threshold=1.5, scale_steps=True, )
mch_mol = mch.Molecule( atoms=(mch.Atom( id=atom.get_id(), element_string=atom.__class__.__name__, ) for atom in cage.get_atoms()), bonds=(mch.Bond(id=i, atom_ids=( bond.get_atom1().get_id(), bond.get_atom2().get_id(), )) for i, bond in enumerate(cage.get_bonds())), position_matrix=cage.get_position_matrix(), ) optimizer = mch.Collapser( step_size=0.05, distance_threshold=1.2, scale_steps=True, ) subunits = get_subunits(mol=cage) # Get all steps. mch_mol, mch_result = optimizer.get_trajectory( mol=mch_mol, bond_pair_ids=stk_long_bond_ids, subunits=subunits, ) cage = cage.with_position_matrix(mch_result.get_final_position_matrix()) cage.write('coll_poc_opt.mol') with open('coll_opt.out', 'w') as f: f.write(mch_result.get_log())