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: object

Build a fix bond/react template pair from two Fragment reactants.

Parameters:
  • A (Fragment) – First reactant fragment.

  • B (Fragment) – Second reactant fragment.

  • A_name (str) – Short string used as the dictionary key for A atoms in breaks, makes, changed_typ, and id_map.

  • B_name (str) – Same as A_name for B.

  • 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 — write new_nta into post.atoms[new_id].comment. The integer atom.type is left untouched (downstream atom_typing re-assigns it from the .nta file).

  • vect (tuple[float, float, float]) – Relative displacement between the two fragment initiators in the combined pre state. B’s initiator is placed at A_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 by write_map().

  • id_map (dict): {(name, original_id): preserved_id}.

write_data(pre_path, post_path)[source]

Write pre and post .data files plus their companion .nta files.

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 .nta files are derived from the data file paths by replacing the extension. They feed atom_typing/all2lmp downstream.

Parameters:
  • pre_path (str or Path) – Output path for the pre-reaction .data file.

  • post_path (str or Path) – Output path for the post-reaction .data file.

Returns:

(pre_data, post_data, pre_nta, post_nta) as Path objects.

write_map(path)[source]

Write self.rxn_map to path in mooonpy map-file format.

Parameters:

path (str or mooonpy.tools.file_utils.Path) – Output path. Wrapped in Path if it isn’t one.