molecule#

class irmsd.core.molecule.Molecule(symbols: list[str], positions: ~numpy.ndarray, energy: float | None = None, info: dict[str, ~typing.Any] = <factory>, cell: ~numpy.ndarray | None = None, pbc: tuple[bool, bool, bool] | None = None, ids: ~numpy.ndarray | None = None)[source]#

Bases: object

Dependency-free replacement for ase.Atoms.

energy is in Hartree. ids holds optional per-atom canonical atom identifiers, one int32 per atom. Construction raises ValueError on bad shapes or unknown symbols.

__annotations__ = {'cell': 'np.ndarray | None', 'energy': 'float | None', 'ids': 'np.ndarray | None', 'info': 'dict[str, Any]', 'pbc': 'tuple[bool, bool, bool] | None', 'positions': 'np.ndarray', 'symbols': 'list[str]'}#
__dataclass_fields__ = {'cell': Field(name='cell',type='np.ndarray | None',default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'energy': Field(name='energy',type='float | None',default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'ids': Field(name='ids',type='np.ndarray | None',default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'info': Field(name='info',type='dict[str, Any]',default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'dict'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'pbc': Field(name='pbc',type='tuple[bool, bool, bool] | None',default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'positions': Field(name='positions',type='np.ndarray',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'symbols': Field(name='symbols',type='list[str]',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}#
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)#
__dict__ = mappingproxy({'__module__': 'irmsd.core.molecule', '__annotations__': {'symbols': 'list[str]', 'positions': 'np.ndarray', 'energy': 'float | None', 'info': 'dict[str, Any]', 'cell': 'np.ndarray | None', 'pbc': 'tuple[bool, bool, bool] | None', 'ids': 'np.ndarray | None'}, '__doc__': 'Dependency-free replacement for ase.Atoms.\n\n    ``energy`` is in Hartree. ``ids`` holds optional per-atom canonical atom\n    identifiers, one int32 per atom. Construction raises ValueError on bad\n    shapes or unknown symbols.\n    ', 'energy': None, 'cell': None, 'pbc': None, 'ids': None, '__post_init__': <function Molecule.__post_init__>, 'natoms': <property object>, '__len__': <function Molecule.__len__>, 'get_chemical_symbols': <function Molecule.get_chemical_symbols>, 'get_atomic_numbers': <function Molecule.get_atomic_numbers>, 'get_positions': <function Molecule.get_positions>, 'get_ids': <function Molecule.get_ids>, 'set_ids': <function Molecule.set_ids>, 'get_potential_energy': <function Molecule.get_potential_energy>, 'get_chemical_formula': <function Molecule.get_chemical_formula>, 'copy': <function Molecule.copy>, 'set_positions': <function Molecule.set_positions>, 'set_potential_energy': <function Molecule.set_potential_energy>, 'set_atomic_numbers': <function Molecule.set_atomic_numbers>, 'get_cn': <function Molecule.get_cn>, 'get_axis': <function Molecule.get_axis>, 'get_point_group': <function Molecule.get_point_group>, 'get_symmetry_operations': <function Molecule.get_symmetry_operations>, 'get_canonical': <function Molecule.get_canonical>, '__dict__': <attribute '__dict__' of 'Molecule' objects>, '__weakref__': <attribute '__weakref__' of 'Molecule' objects>, '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False), '__dataclass_fields__': {'symbols': Field(name='symbols',type='list[str]',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'positions': Field(name='positions',type='np.ndarray',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'energy': Field(name='energy',type='float | None',default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'info': Field(name='info',type='dict[str, Any]',default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'dict'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'cell': Field(name='cell',type='np.ndarray | None',default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'pbc': Field(name='pbc',type='tuple[bool, bool, bool] | None',default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'ids': Field(name='ids',type='np.ndarray | None',default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}, '__init__': <function Molecule.__init__>, '__repr__': <function Molecule.__repr__>, '__eq__': <function Molecule.__eq__>, '__hash__': None, '__match_args__': ('symbols', 'positions', 'energy', 'info', 'cell', 'pbc', 'ids')})#
__eq__(other)#

Return self==value.

__init__(symbols: list[str], positions: ~numpy.ndarray, energy: float | None = None, info: dict[str, ~typing.Any] = <factory>, cell: ~numpy.ndarray | None = None, pbc: tuple[bool, bool, bool] | None = None, ids: ~numpy.ndarray | None = None) → None#
__len__() → int[source]#
__match_args__ = ('symbols', 'positions', 'energy', 'info', 'cell', 'pbc', 'ids')#
__module__ = 'irmsd.core.molecule'#
__post_init__() → None[source]#
__repr__()#

Return repr(self).

cell: ndarray | None = None#
copy() → Molecule[source]#

Return a deep copy; no array, info or symbols is shared.

energy: float | None = None#
get_atomic_numbers() → ndarray[source]#

Return atomic numbers as int32 array.

get_axis() → tuple[ndarray, ndarray, ndarray][source]#

Return rotation constants, average momentum and rotation matrix.

Returns:

  • rot ((3,) ndarray) – Rotation constants in MHz.

  • avmom ((1,) ndarray) – Average momentum in a.u.

  • evec ((3, 3) ndarray)

get_canonical(wbo: ndarray | None = None, invtype: str = 'apsp+', heavy: bool = False) → ndarray[source]#

Return (N,) int32 canonical ranks from the Fortran core.

Parameters:
  • wbo ((N, N) ndarray, optional) – Wiberg bond orders; required for invtype="cangen".

  • invtype ({"apsp+", "cangen", "apsp+nmr"}) – "apsp+nmr" runs apsp+, then splits any rank shared by exactly two non-hydrogen atoms (propagated to attached hydrogens), a hack for NMR magnetic (in)equivalencies. Rank requests only, not iRMSD.

  • heavy (bool) – Rank heavy atoms only.

get_chemical_formula(mode: str = 'hill') → str[source]#

Return the chemical formula, omitting counts of 1 as ASE does.

mode="hill" puts C and H first, then the rest alphabetically; any other mode sorts all elements alphabetically, matching ASE.

get_chemical_symbols() → list[str][source]#
get_cn() → ndarray[source]#

Return (N,) coordination numbers from the Fortran core.

get_ids(copy: bool = True) → ndarray | None[source]#

Return (N,) canonical atom IDs or None; copy=False returns the internal array.

get_point_group(**settings) → str | None[source]#

Return the Schoenflies symbol (e.g. “C2v”), or None if skipped.

settings are forwarded; see irmsd.get_point_group().

get_positions(copy: bool = True) → ndarray[source]#

Return (N, 3) positions; copy=False returns the internal array.

get_potential_energy() → float[source]#
get_symmetry_operations(**settings) → tuple[str | None, list][source]#

Return the Schoenflies symbol and the symmetry operations.

settings are forwarded; see irmsd.get_point_group().

Returns:

  • symbol (str or None) – None if skipped.

  • operations (list[irmsd.SymmetryOperation]) – Identity first; empty if skipped.

ids: ndarray | None = None#
info: dict[str, Any]#
property natoms: int#
pbc: tuple[bool, bool, bool] | None = None#
positions: ndarray#
set_atomic_numbers(numbers: Sequence[int]) → None[source]#
set_ids(ids: Sequence[int] | ndarray | None) → None[source]#

Set canonical atom IDs, one per atom (ValueError otherwise); None clears them.

set_positions(positions: Sequence[Sequence[float]]) → None[source]#
set_potential_energy(energy: float | None)[source]#
symbols: list[str]#