Molecule¶
molecule
¶
Clean molecular structure representation for Q2MM.
Built on QCElemental for validated molecular data (symbols, geometry, charge, multiplicity, connectivity) with Q2MM-specific extensions (Hessian, detected bonds/angles, element-based matching).
DetectedBond
dataclass
¶
DetectedBond(atom_i: int, atom_j: int, elements: tuple[str, str], length: float, env_id: str = '', ff_row: int | None = None)
A bond detected from molecular geometry.
element_pair
property
¶
Sorted element pair for matching (e.g., ('C', 'F')).
DetectedAngle
dataclass
¶
DetectedAngle(atom_i: int, atom_j: int, atom_k: int, elements: tuple[str, str, str], value: float, env_id: str = '', ff_row: int | None = None)
An angle detected from molecular bonds.
element_triple
property
¶
Canonical element triple: (outer, center, outer) sorted by outer elements.
Q2MMMolecule
dataclass
¶
Q2MMMolecule(symbols: list[str], geometry: ndarray, atom_types: list[str] | None = None, charge: int = 0, multiplicity: int = 1, name: str = '', bond_tolerance: float = 1.3, hessian: ndarray | None = None, _bonds: list[DetectedBond] | None = None, _angles: list[DetectedAngle] | None = None)
Q2MM's internal molecular structure representation.
Wraps atomic symbols, coordinates, charge, and multiplicity with auto-detected bonds and angles. Optionally carries a Hessian matrix.
Can be created from XYZ files, QCElemental molecules, or raw data.
__post_init__
¶
Validate atom_types length and normalize geometry to float.
Source code in q2mm/models/molecule.py
from_xyz
classmethod
¶
from_xyz(path: str | Path, charge: int = 0, multiplicity: int = 1, name: str = '', bond_tolerance: float = 1.3) -> Q2MMMolecule
Load from XYZ file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bond_tolerance
|
float
|
Multiplier on sum of covalent radii for bond detection. Use 1.3 for ground states, 1.4-1.5 for transition states with partially formed/broken bonds. |
1.3
|
Source code in q2mm/models/molecule.py
from_structure
classmethod
¶
from_structure(structure, *, charge: int = 0, multiplicity: int = 1, name: str = '', bond_tolerance: float = 1.3, hessian: ndarray | None = None) -> Q2MMMolecule
Create from a legacy Structure while preserving bond/angle metadata.
Source code in q2mm/models/molecule.py
from_qcel
classmethod
¶
from_qcel(mol: Molecule, name: str = '') -> Q2MMMolecule
Create from a QCElemental Molecule object.
Source code in q2mm/models/molecule.py
to_qcel
¶
Convert to QCElemental Molecule.
Source code in q2mm/models/molecule.py
with_hessian
¶
with_hessian(hessian: ndarray) -> Q2MMMolecule
Return a copy with Hessian attached.