mooonpy.template.reaction module
ReactionTemplate — build a LAMMPS fix bond/react template pair from two
Fragment objects.
Atom ids are preserved 1:1 between the pre and post Molspaces so the LAMMPS internal topology-map optimizer is sidestepped.
Force-field handling stays out of this module: the output .data files are
emitted with no angles / dihedrals / impropers, all bonds collapsed to a single
dummy bond type, and FF coefficient dicts cleared. NTA strings live in
atom.comment and are the truth source for downstream typing tools, which
overwrite the integer atom.type regardless.
- class mooonpy.template.reaction.ReactionTemplate(A, B, *, A_name='A', B_name='B', breaks=(), makes=(), changed_typ=(), vect=(0.0, 0.0, 0.0), delete_byproduct=True)[source]
Bases:
objectBuild a
fix bond/reacttemplate pair from twoFragmentreactants.- Parameters:
A (Fragment) – First reactant fragment.
B (Fragment) – Second reactant fragment.
A_name (str) – Short string used as the dictionary key for
Aatoms inbreaks,makes,changed_typ, andid_map.B_name (str) – Same as
A_nameforB.breaks (list[tuple[str, int, int]]) – List of
(name, orig_id1, orig_id2)triples — bonds to remove from the post state. Both ids must reference the same reactant.makes (list[tuple[str, int, str, int]]) – List of
(name1, orig_id1, name2, orig_id2)quads — bonds to create in the post state.changed_typ (list[tuple[str, int, str]]) – List of
(name, orig_id, new_nta)triples — writenew_ntaintopost.atoms[new_id].comment. The integeratom.typeis left untouched (downstream atom_typing re-assigns it from the.ntafile).vect (tuple[float, float, float]) – Relative displacement between the two fragment initiators in the combined pre state.
B’s initiator is placed atA_initiator + vect.(0, 0, 0)makes them coincident.delete_byproduct (bool) – After applying bond changes, run cluster ID on the post state; everything not in the largest cluster is added to
DeleteIDs.
Computed attributes:
pre(Molspace): merged pre-reaction state with 1..N ids.post(Molspace): same ids; bonds and NTAs updated.rxn_map(dict): editable intermediate; written bywrite_map().id_map(dict):{(name, original_id): preserved_id}.
- write_data(pre_path, post_path)[source]
Write pre and post
.datafiles plus their companion.ntafiles.Data files are FF-stripped: no angles / dihedrals / impropers, no FF coefficient sections, no Velocities section, and a single dummy bond type. The Masses section is kept so downstream tools can sanity-check atom types. Atom comments are reduced to just the NTA token.
The
.ntafiles are derived from the data file paths by replacing the extension. They feedatom_typing/all2lmpdownstream.- Parameters:
pre_path (str or
Path) – Output path for the pre-reaction.datafile.post_path (str or
Path) – Output path for the post-reaction.datafile.
- Returns:
(pre_data, post_data, pre_nta, post_nta)asPathobjects.
- write_map(path)[source]
Write
self.rxn_maptopathin mooonpy map-file format.- Parameters:
path (str or
mooonpy.tools.file_utils.Path) – Output path. Wrapped inPathif it isn’t one.